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

Panic in parse_csi_sgr_mouse #835

Open
Timmmm opened this issue Oct 25, 2023 · 0 comments
Open

Panic in parse_csi_sgr_mouse #835

Timmmm opened this issue Oct 25, 2023 · 0 comments

Comments

@Timmmm
Copy link

Timmmm commented Oct 25, 2023

If you enable pixel mouse position reporting like this:

stdout.write_all(b"\x1B[?1016h").unwrap();

Then it works fine except if you move your mouse to the top of the screen, then it can report 0, and that causes this code to panic:

    // See http://www.xfree86.org/current/ctlseqs.html#Mouse%20Tracking
    // The upper left character position on the terminal is denoted as 1,1.
    // Subtract 1 to keep it synced with cursor
    let cx = next_parsed::<u16>(&mut split)? - 1;
    let cy = next_parsed::<u16>(&mut split)? - 1;

Because 0 - 1 underflows. Simple hack: use saturating subtract. I suspect nobody is going to care about the difference between pixel 0 and 1.

OS
Linux

Terminal/Console
Kitty

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

1 participant