-
Notifications
You must be signed in to change notification settings - Fork 374
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
Incomplete event escape sequence on OSX (escape sequences split in 2 broken events) #132
Comments
Note : I might be able to look into it as I have access to a Mac, but wanted to check first if it's a know issue or if you have any ideas/comments. |
Related: #120 |
So, yeah, if anyone can help me solve this (if it's even possible), that'd be nice. I don't have a mac. |
This fixed it for me: But I' working off an old fork of termbox-go so it seems that code has changed a lot since. Let me try to see if it's a problem / need a fix in termbox master. |
The bug does happen in master too, will try to fix it there and provide a PR |
This worked on master, same idea of keeping existing (partial) input data, and defering event parsing until more data is available.
|
Hm... I don't see how it solves the problem. What if the data arrives is ESC symbol, it can be a partial escape sequence or an actual ESC key. It's ambiguous. That's why I never understood how even terminals work in the first place, because their input is always ambiguous if you slice it into bytes. |
Actually for the new code that might not work well, in the old code I would only do that if Maybe a slightly "better" approach would be (pseudo code)
It's kinda lame and ugly no question, but with the terminal data being non deterministic, I'm not sure much better can be done. |
Well, I don't like that kind of solutions to be honest. I guess I'll have to take a look at other terminal-based software and what it does on mac. Btw, is it a problem only with mouse events? |
Unless you can force the os/terminal to not send partial events (didn't find a way to do this so far), I'm not sure what else you could do. I have only seen it happen with mouse events, but it might just be because they are the longest ones (more bytes) |
@nsf According to this page the ambiguity is frequently resolved by checking to see if another character comes quickly after. This is obviously not an ideal solution, but I think we can do a bit better by (upon hitting an ESC character) continuing to read until we've ruled out all known escape sequences, rather than simply stopping because syscall.Read() didn't read in a full known escape sequence. |
@nsf are you still opposed to a solution here that involves a small delay after detecting an escape key, and then re-checking for escape sequences? Granted this is nasty because
I'm toying with the idea of trying to fix this but if you feel like such a fix is unacceptable due to the nature of the problem then I may not bother. In theory would you accept a PR on this? |
If that behaviour will be enabled only on OSX I will accept it. |
Great! I've got a proof of concept working which I should be able to clean up, test, and isolate to macOS some time in the next few days and will submit a PR. |
…eypress detection nsf#132
This should be resolved after PR #176. I would be interested in knowing if anyone hits further problems, as the delay can be increased if necessary (currently set to 50ms). |
…eypress detection nsf#132
On OSX when scrolling up and down sometimes the mouse event seem to be getting cut in half,
a normal event would be
\x1b[<64;55;28M
, but sometimes instead I get\x1b[<64;55;28
, followed by 'M', I'm guessing it might some sort of buffering issue whereas termbox is parsing as the event is flowing in ? Obviously it's very annoying as I received what looks like aM
Key pressed event.Are there some known issues with this ? Note: I have never seen it on Linux(mostly gnome terminal), but it's very frequent on OSX(iTerm 2).
This is output from _demos/raw_input.go
See the bottom where it gets
x1b[<65;55;28
and thenM
as two (wrong) events.The text was updated successfully, but these errors were encountered: