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

Mouse Input Pixel Mode #929

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

bogzbonny
Copy link

Closes #873

Based on conversations within #873 I'd originally thought it'd be useful to be able to provide the mouse location in pixels and in cells, however upon further reflection this would require that crossterm hold state of what the most recent cell size was (which would change with each Resize) - hence I think the best way we can address this is to simply allow for users to get the mouse size in pixels and provide tooling for users to get the cell size in pixels themselves and hold this state, so if necessary the user is able to easily calculate the cell coordinates as well whenever they need it.

This PR has 3 main changes

  • Ansi for pixel capture mode (see EnableMousePixelCapture)
  • Ansi for cell size in pixels (see cell_size()) [CAN MAYBE REMOVE]
  • An example (cargo run --features="event-stream" --example event-stream-tokio-pixels)

OPEN QUESTION:

  • why does the cell size according window calculation differ (by 1 in width and height) from the CSI response cell size?
    • if you run the PRs example an hit s you will see the difference in both calculations

@bbb651 @joshka

@bogzbonny bogzbonny changed the title implement cell size pixels CSI and pixel mouse input example Mouse Input Pixel Mode Sep 22, 2024
@bogzbonny
Copy link
Author

bogzbonny commented Sep 22, 2024

it seems that margins may be the culprit as to cell size difference... suggesting that we really should keep the cell_size() function


edit... not so sure anymore, it seems that the difference between the two calculations is ALWAYS off by one for both the height and the width, nomatter how I resize the terminal or change the font size. I've tested this in both wezterm and kitty

@bogzbonny
Copy link
Author

Additionally to this PR it would be good to have the ability to Request Ansi Mode (DECRQM) so the user could actually determine if 1016 is supported - I'm not sure but it seems as though this form of request is not supported anywhere in crossterm.

for context (ref):

CSI Ps $ p
          Request ANSI mode (DECRQM).  For VT300 and up, reply DECRPM is
            CSI Ps ; Pm $ y
          where Ps is the mode number as in SM/RM, and Pm is the mode
          value:
            0 - not recognized
            1 - set
            2 - reset
            3 - permanently set
            4 - permanently reset

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

Successfully merging this pull request may close these issues.

Support Pixel Coordinates in Mouse Events
1 participant