-
Notifications
You must be signed in to change notification settings - Fork 275
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
Async reader doesn't produce MouseEvents #271
Comments
It looks like it doesn't enable raw mode.... Because it print's the ANSI code to the screen. |
I am testing on linux now |
I can validate the same for Linux, not windows. This has to be due to some changes made in the latest PR's. I am sure this worked before. It looks like it breaks out of the loop when Escape his hit. Esc is returned in a fiew scenario's. We should checkout why it returns escape while we press any mouse button. |
I don't think that we did this in any of the last PRs. It looks like a duplicate of #199 (or is somehow related aka swallowed Esc). |
I might have a clue why this is caused. |
Mind to share the clue? Also it enables the raw mode ... When I add this line ... InputEvent::Keyboard(KeyEvent::Char(c)) => println!("Char: {}", c), ... the output looks like ... ... see that Another weird think is that I've got panic in 30%. Run, hit Enter two times, click with mouse button and boom. Have to enable backtrace output and try to simulate this again. |
This line ... ... returns ... returns |
It looks like this should be KeyEvent::UnKnown, can you validate whether the code returns the Escape on that line? |
Also the rare (30%) panic happens here ... https://github.com/crossterm-rs/crossterm-input/blob/master/src/input/unix.rs#L452 |
I'll check which line returns the right Esc, not sure even about Unknown here. First, I have to wrap my head around how the whole async & parsing is done. |
With read async, we loop trough the bytes from TTY. We sent them over a channel, then we read the bytes one by one here, and when there is a byte on the channel we pass the iterator into the
The SyncReader solves this by reading 2 bytes, then it checks if it contains only the escape key or continues parsing. |
I am currently researching how we can do input reading better. I noticed that it is very difficult to do well and that there are very few examples whom have a similar implementation like we have. The current input system for Linux is mostly copied from termion (sometimes you have to steal like an artist), but I like to design something my self now because it has some limitations. I looked at how the new windows terminal did this, and how other libraries were doing this. I might have an nice idea, but I am not sure how to implement that. I designed something in UML and tried to realize a bit of it. But I came to a difficult part where I need to know the whole ANSI input code before I want to do the parsing. How we do it now is that we parse the ANSI code as we iterate. Because the ANSI codes defer in lenght we can't just read into a fixed-size buffer. But we have to assume when we see certain ANSI codes we can read other bytes, which is not wrong, but things would become way easier if we could read the whole ANSI code directly, without having to iterate everything manually. But that is something not related to this issue. Just something I liked to share |
The idea of |
I read the whole code and now I see where the problem is. I'll reimplement the internals, already have an idea how to do it without breaking changes. |
Good, do you want to share how you are going about this? |
This is rough idea, my observations, ... and not saying the final one. My plan is to work on this tomorrow. |
input.read_async();
withinput.read_sync();
examples/foo.rs
:The text was updated successfully, but these errors were encountered: