Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native mouse support in Windows Terminal #103

Closed
irevenko opened this issue May 28, 2021 · 7 comments · Fixed by #138
Closed

Native mouse support in Windows Terminal #103

irevenko opened this issue May 28, 2021 · 7 comments · Fixed by #138
Labels
enhancement New feature or request

Comments

@irevenko
Copy link
Contributor

I've tried this example on Windows Terminal which is new replacement for cmd
nor cmd nor power shell mode are working and most of the time (x y) bar is not rendering
ezgif-4-8189ee8a9868

@meowgorithm
Copy link
Member

meowgorithm commented May 28, 2021

If you’re using the Windows Linux Subsystem in Windows Terminal the mouse will work (you can enter the subsystem with wsl).

Beyond that, I'm not entirely sure if Windows Terminal supports the mouse outside of WSL so we'll need to do some research here. Currently, we're only processing X10/X11 mouse events (which all unix-like systems support).

@irevenko
Copy link
Contributor Author

But you did write support for usual win command line

@meowgorithm
Copy link
Member

@irevenko If it's possible to add native mouse support in Windows we'll definitely do it. In the meantime, you're welcome to submit a PR which adds the functionality.

@meowgorithm meowgorithm changed the title Mouse example doesn't work on Windows Terminal Native mouse support in Windows Terminal May 28, 2021
@meowgorithm meowgorithm added the enhancement New feature or request label May 28, 2021
@jon4hz
Copy link
Contributor

jon4hz commented Jul 25, 2021

If I remember correctly, gocui has implemented mouse support for Linux and for Windows. Maybe you can take a look at how they did it. Unfortunately I can't do a PR as this is beyond my skill level

@erikgeiser
Copy link
Contributor

erikgeiser commented Aug 12, 2021

Windows supports mouse events which can be read (alongside all other input events) with ReadConsoleInput. However, this means that the Windows input event parsing logic (which would then be based on INPUT_RECORD structs) would have to be decoupled from the Unix logic.

This is quite a bit of work but if the Windows implementation is rewritten to read INPUT_RECORDs, it can also likely use PeekConsoleInput which can replace the WaitForMultipleObjects mechanism introduced in #120 and thereby also solve #24 for the Windows Terminal where the mechanism from #120 does not work reliably.

By the way, a INPUT_RECORD can also be a WINDOW_BUFFER_SIZE_EVENT which sounds like a good replacement for SIGWINCH on Windows.

@meowgorithm
Copy link
Member

Bubble Tea now supports mouse events in Windows in master. This functionality will be available in the next release.

As a technical note, we're only processing X10 mouse events, which are fairly basic across the board. It's possible to ReadConsoleInput (mentioned by @erikgeiser above) to gain access to higher fidelity mouse events on Windows.

@meowgorithm
Copy link
Member

This is now available in v0.17.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants