Git Product home page Git Product logo

Comments (8)

erikgeiser avatar erikgeiser commented on July 17, 2024

Hey, I'm not the maintainer but I'm the one who introduced this change in my PR (#120). First, I'm very sorry I broke your app.

I disabled windows.ENABLE_VIRTUAL_TERMINAL_INPUT out of necessity because it being disabled is important to support running multiple bubbletea programs in a single Go program on Windows Terminal. However I totally missed that this also disables special keys such as arrow keys. Ultimately, working specials keys is way more important that running multiple programs so I think we should re-enable windows.ENABLE_VIRTUAL_TERMINAL_INPUT as you suggested.

However, as far as I know, mouse was never supported by bubbletea on Windows. Am I wrong?

Some background: bubbletea currently reads bytes from stdin and decodes special byte sequences as special keys. This works on Windows, macOS and Linux. However, in order to be able to stop an ongoing read if the bubbletea program terminates, I had to implement a mechanism where we ask the OS if something is available and start the read only if something is there to read. However, on windows stdin can contain a lot of different events and some of them cannot be read as bytes. By carefully setting the terminal mode I can avoid such unreadable events. With windows.ENABLE_VIRTUAL_TERMINAL_INPUT some of these events are re-introduced (may key release events), so Windows says "something is available on stdin" and when I try to read it as bytes, nothing is there and I'm stuck in an uncancelable read.

There are also some good news:

  • The unreable events from windows.ENABLE_VIRTUAL_TERMINAL_INPUT happen only on Windows Terminal, in the old conhost with Powershell or cmd this is not an issue
  • I'm already working on reading events as events instead of byte-sequences such that no event is unreadable. This also enables windows size change events and mouse events.

from bubbletea.

aschey avatar aschey commented on July 17, 2024

No need to apologize, I appreciate all the hard work you must've put into that PR. My mistake, I didn't check to see if the mouse was working on previous versions as I was not using it in my app. I just ran through the examples to test my change and noticed that the mouse does work with ENABLE_VIRTUAL_TERMINAL_INPUT enabled, so I guess that's a secondary benefit to enabling it. Thanks for taking the time to explain that, it definitely makes sense to me now.

from bubbletea.

meowgorithm avatar meowgorithm commented on July 17, 2024

@aschey, thanks so much for reporting this regression. It totally slipped past all of us.

We’ll have a patch for this in shortly, enabling the flag as you and Erik suggest. It’s really nice to hear that it will enable the mouse as well.

As Erik mentions, reading further input in a Go application after a Bubble Tea program has existed will be unreliable, as it was previously. This, of course, will be fixed once Erik’s Windows input reader is in.

from bubbletea.

erikgeiser avatar erikgeiser commented on July 17, 2024

@aschey I you have working mouse events on the earlier bubbletea version it would be very interesting to know your Windows version and which Terminal you use. We were under the impression that mouse events were not emitted at all on Windows.

from bubbletea.

aschey avatar aschey commented on July 17, 2024

Sounds good, thanks both! @erikgeiser Here's my system info:
Windows build: 19043.1237
Windows Terminal version: 1.10.2383.0
Powershell 7 version: 7.1.4
Old Windows-only Powershell version: 5.1.19041.1237

I tried on Windows Terminal and the built-in Powershell host and it seems to work with every combination of these, with both old and new Powershell. Here's a quick demo I recorded on the lastest master branch with no changes except the one line I posted earlier. Every input seems to work - mouse movement, wheel up, wheel down, left click, right click, middle click, and release.

from bubbletea.

meowgorithm avatar meowgorithm commented on July 17, 2024

Ok! This has been fixed via #138, which was just merged into master. It'll be available in the next release shortly.

Thanks @aschey (and @erikgeiser) for all the insight and help here. We've temporarily lost cancelReader functionality but have gained mouse support on Windows across the board.

from bubbletea.

meowgorithm avatar meowgorithm commented on July 17, 2024

Alright, this is now available in v0.17.0.

from bubbletea.

aschey avatar aschey commented on July 17, 2024

Thanks, appreciate the quick turnaround!

from bubbletea.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.