-
Notifications
You must be signed in to change notification settings - Fork 280
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
Support Pixel Coordinates in Mouse Events #873
Comments
I just realized |
bump! I would find this useful for the same reason. Basic image interaction in the terminal is an inhibiting feature for making some of my applications fully terminal based |
Rather than bumping consider doing the work to work out / design how something like this should be implemented. Some constraints to keep in mind would be:
Regarding image proto stuff, have you considered using ratatui and ratatui-image? I know that this goes one step further than just raw crossterm, but if your goal is writing working software then this might be a valid approach for your problem. |
Yeah I spent a bunch of time going through SGR-Pixels (1016)... the best that I could make out is that, to simply switch to 1016 would replace character positions altogether with pixel positions, making that an optional feature I think would be actually pretty straight-forward however not nearly as useful as having both pixel and character positions (IMO, thoughts?). Considering that some terminals may not support pixels mouse responses, I imagine that it makes sense to add this under a feature flag (wezterm does, ref). One more complication which I just thought of is if it would be required to somehow query the terminal for pixel compatibility and only provide the character output if pixel output is not available (even with the feature-flag on). More relevant discussions: dankamongmen/notcurses#2326 edit: from that same document bbb651 posted, cells in pixels are |
@joshka btw implementing kitty image protocol from scratch isn't that difficult (I don't know about sixels though, I haven't tried), the need for supporting cursor location in pixels is so that one could hypothetically interact with an image while in the terminal - this logic is much more coupled with the inner workings of crossterm |
That part should be simple. Call |
Maybe this will be useful. To get rid of the dependence on the cell size, it is enough to use floating point coordinates with the following format: fractional_coordinates = integer_cellular_coordinates + coordinates_inside_the_cell / cell_size This approach allows you to easily convert coordinates to pixel coordinates as well as to cell coordinates back and forth. At the same time, the console application does not need to know the cell size at all. The console application simply uses fractional coordinates as it needs. I use this in vtm when the console application tracks mouse drags and reports back to the terminal if it is necessary to move the terminal GUI window at the pixel level, xlink: directvt/vtm#571 (comment), protocol draft: https://github.com/directvt/vtm/blob/master/doc/vt-input-mode.md#mouse You can play with this by moving the vtm GUI windows on Windows (run |
Is your feature request related to a problem? Please describe.
Some terminals offer the ability to report pixel coordinates of mouse events along with the character coordinate. I want to make a UI based on the kitty image protocol (also blocked by #834) where pixel coordinates of events are important.
Describe the solution you'd like
I would like crossterm to provide access to these modes and add the pixel coordinates to
MouseEvent
.Describe alternatives you've considered if any
Additional context
I found this website describing the SGR-Pixels (1016) mode.
The text was updated successfully, but these errors were encountered: