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

EventStream produces sequence of KeyEvents instead of mouse ScrollUp/ScrollDown #668

Closed
chyvonomys opened this issue May 20, 2022 · 5 comments

Comments

@chyvonomys
Copy link

chyvonomys commented May 20, 2022

Describe the bug
I'm using EventStream like this:

        futures_executor::block_on(async {
            let mut term_events = EventStream::new();
            while !grid.is_done() {
                let dirty = if let Some(Ok(e)) = term_events.next().await {
                    self.process_terminal_event(e, grid)
                } else {
                    break
                };

                match dirty {
                    Update::Nothing => (),
                    Update::All => {
                        grid.draw(self);
                    },
                    _ => grid.draw(self),
                }
            }
        });

In process_terminal_event I log all incoming events to a file. If I do some continuous scroll up/down with two finger gesture on MacOS I get sequence of Key events (that btw looks like some mouse sequence ^[[<65;118;23M) in the middle of ScrollDown events.

...
Mouse(MouseEvent { kind: ScrollDown, column: 117, row: 22, modifiers: NONE })
Mouse(MouseEvent { kind: ScrollDown, column: 117, row: 22, modifiers: NONE })
Mouse(MouseEvent { kind: ScrollDown, column: 117, row: 22, modifiers: NONE })
Key(KeyEvent { code: Esc, modifiers: NONE })
Key(KeyEvent { code: Char('['), modifiers: NONE })
Key(KeyEvent { code: Char('<'), modifiers: NONE })
Key(KeyEvent { code: Char('6'), modifiers: NONE })
Key(KeyEvent { code: Char('5'), modifiers: NONE })
Key(KeyEvent { code: Char(';'), modifiers: NONE })
Key(KeyEvent { code: Char('1'), modifiers: NONE })
Key(KeyEvent { code: Char('1'), modifiers: NONE })
Key(KeyEvent { code: Char('8'), modifiers: NONE })
Key(KeyEvent { code: Char(';'), modifiers: NONE })
Key(KeyEvent { code: Char('2'), modifiers: NONE })
Key(KeyEvent { code: Char('3'), modifiers: NONE })
Key(KeyEvent { code: Char('M'), modifiers: SHIFT })
Mouse(MouseEvent { kind: ScrollDown, column: 117, row: 22, modifiers: NONE })
Mouse(MouseEvent { kind: ScrollDown, column: 117, row: 22, modifiers: NONE })
Mouse(MouseEvent { kind: ScrollDown, column: 117, row: 22, modifiers: NONE })
...

Observation: this escape sequence has x, y coordination off by one compared to ScrollDown events.

To Reproduce
See above.

Expected behavior
Raw escape sequence should not appear in EventStream.

OS
MacOS Catalina 10.15.5

Terminal/Console

  • kitty 0.18.3
  • Terminal 2.10 (433)
@TimonPost
Copy link
Member

You have executed 'EnableMouseCapture' and raw modes?

@chyvonomys
Copy link
Author

@TimonPost yes, at the beginning I do this:

        terminal::enable_raw_mode().unwrap();
        execute!(
            self.screen,
            terminal::EnterAlternateScreen,
            crossterm::event::EnableMouseCapture,
        ).unwrap();

self.screen is basically std::io::stdout()

@TimonPost
Copy link
Member

That is odd. Will have to investigate it a bit.

@TimonPost
Copy link
Member

Ah, I am afraid using gestures and two fingers is not yet supported. I'll move his issue to: #685

@chyvonomys
Copy link
Author

@TimonPost hmm, gesture is in fact supported because it does recognize it as ScrollDown, column: 117, row: 22 most of the time. but sometimes it suddenly refuses to recognize and returns it as raw sequence: ^[[<65;118;23M

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

No branches or pull requests

2 participants