-
Notifications
You must be signed in to change notification settings - Fork 18
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
input: Driver.Cancel Doesn't Work On Windows #248
Comments
After digging around a bit:
|
I have verified locally that removing the windows-specific code for Driver.ReadEvents fixes this issue (and also successfully retrieves the background color in the preview version of windows terminal) but I don't know what knock-on consequences that might have elsewhere. I see that bubbletea v2 has its own version of this code and has a |
This drops the dependency on `github.com/charmbracelet/x/input` and `github.com/erikgeiser/coninput` by manually parsing the terminal response to the background color query using `ansi`. Since we moved `x/input` to Bubble Tea, and the code is no longer maintained, we need a different approach to query the terminal for the background color. This is basically doing the same thing as before, but manually parsing the response instead of using the `x/input` package. Fixes: charmbracelet/x#248 Supersedes: charmbracelet/x#249
Hi @CannibalVox, thank you for reaching out and reporting this issue. Indeed, Bubble Tea has its own version of As for the issue, I suspect the problem was due to this hack. You see, when using the Windows Console API instead of their Virtual Terminal mode (the default), we need to parse escape sequences as if they were key events. The code in I've opened charmbracelet/lipgloss#429 to fix this issue in Lip Gloss. |
Thank you! I've confirmed that the linked PR fixes the issue:
|
This drops the dependency on `github.com/charmbracelet/x/input` and `github.com/erikgeiser/coninput` by manually parsing the terminal response to the background color query using `ansi`. Since we moved `x/input` to Bubble Tea, and the code is no longer maintained, we need a different approach to query the terminal for the background color. This is basically doing the same thing as before, but manually parsing the response instead of using the `x/input` package. Fixes: charmbracelet/x#248 Supersedes: charmbracelet/x#249
Describe the bug
A clear and concise description of what the bug is.
The Input package has a Driver type that has a ReadEvents method and a Cancel method that seems like it is supposed to cause in-flight ReadEvents calls to die and return an error. This does not work on Windows, because the underlying engine of ReadEvents is the
github.com/erikgeiser/coninput ReadConsoleInput
method, whose underlying engine is Windows'ReadConsoleInputW
syscall. This syscall has no cancellation or timeout mechanism and will hang forever until it receives some sort of input.Setup
Please complete the following information along with version numbers, if applicable.
To Reproduce
Steps to reproduce the behavior:
Source Code
lipgloss v2's standalone color example
Expected behavior
Either retrieving the background successfully or time out
The text was updated successfully, but these errors were encountered: