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

Add SGR-Pixels (mouse mode 1016) #18591

Open
salt-die opened this issue Feb 19, 2025 · 5 comments
Open

Add SGR-Pixels (mouse mode 1016) #18591

salt-die opened this issue Feb 19, 2025 · 5 comments
Labels
Area-Input Related to input processing (key presses, mouse, etc.) Area-VT Virtual Terminal sequence support Help Wanted We encourage anyone to jump in on these. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Milestone

Comments

@salt-die
Copy link

salt-die commented Feb 19, 2025

Description of the new feature

Now that sixel is implemented, SGR-Pixels mouse mode would be a nice feature to have. Also helps to implement features such as, e.g., smooth scrolling.

I've searched through issues and only found two references to this feature (below), so hopefully this isn't a duplicate:

#448 (comment) with response from @j4james :

I wasn't considering 1016, but I do have a POC of the DEC locator mode. There's no point in doing either of them until we have sixel, though, because the pixel coordinates will need to be tightly coupled to the sixel resolution.

And listed as not supported here #10531 (comment) from @DHowett

Would prefer 1016 over DEC Locator since it seems to be more widely used?
dankamongmen/notcurses#2326
wezterm/wezterm#1457
https://github.com/mahmoudimus/jexer/blob/16d27b6f4182e3c2cfecd7673934ebe09782861a/README.md?plain=1#L26C1-L26C70
Aetf/libtsm#29
xtermjs/xterm.js#4092

Proposed technical implementation details

No response

@salt-die salt-die added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Feb 19, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Feb 19, 2025
@carlos-zamora carlos-zamora added Area-VT Virtual Terminal sequence support Product-Terminal The new Windows Terminal. Area-Input Related to input processing (key presses, mouse, etc.) and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Feb 19, 2025
@carlos-zamora carlos-zamora added this to the Backlog milestone Feb 19, 2025
@carlos-zamora carlos-zamora added the Help Wanted We encourage anyone to jump in on these. label Feb 19, 2025
@j4james
Copy link
Collaborator

j4james commented Feb 20, 2025

Also helps to implement features such as, e.g., smooth scrolling.

That's neat, but it's disappointing that they felt the need to resort to proprietary sequences. Here's a similar demo running in OpenConsole using DEC sequences from the 1980's. They could have achieved this 30+ years ago if terminal devs weren't constantly reinventing the wheel.

Smooth scrolling demonstration

This is using my POC of DEC Locator mode btw. I never got around to turning it into a PR, because it required significant rewrites to the mouse handling, and I suspect there are things that got broken in the process. Implementing mode 1016 will almost certainly have the same problem.

But I'm not opposed to mode 1016. I just prefer the DEC Locator mode because it's more powerful, and has been around for 30 more years.

@schrmh
Copy link

schrmh commented Mar 3, 2025

@j4james Interesting, that's the first time I heard that it even is more powerful. I was told SGR is more useful (wezterm/wezterm#217 (comment)) but given your comment I would rather lean towards supporting the DEC way as well (and then just trying to do positive propaganda for implementing that or PRs. I think the SGR is not really used by many applications for mouse location tracking anyways since I did not stumple upon other than the mention stuff so far even when actively looking for it mid 2022).
Btw. which terminal emulator (that would need to run on GNU/Linux since I don't use Windows, sorry) would you recommend specifically for trying out stuff with DEC Locator mode? E.g. some are a bit glitchy or require a full-screened terminal. Ideally I would like to have a SIXEL-using application to respond to mouse clicks at certain locations (e.g. https://github.com/schrmh/pdfgrepSIXEL to do something with the clicked on slide)...

@j4james
Copy link
Collaborator

j4james commented Mar 3, 2025

@schrmh It's been a few years since I last tested, but the only Linux terminals I'm aware of that have DEC locator support are mlterm and xterm, and it's possible you may have had to compile xterm with a specific build flag (--enable-dec-locator) to get that functionality.

Neither implementation was perfect (and I think the DEC documentation itself had errors), but if you just need basic click reporting it shouldn't be too complicated. However, I'd recommend testing with more than one terminal, just to make sure you aren't relying on behavior specific to one implementation.

@schrmh
Copy link

schrmh commented Mar 4, 2025

Yeah, sadly saitoha's drawing example did not work in mlterm at all when I tried it years ago. The full-screen thing I mentioned was with xterm regarding that example.

@j4james
Copy link
Collaborator

j4james commented Mar 4, 2025

saitoha's drawing example did not work in mlterm at all when I tried it years ago.

Yeah, I've just looked at my notes on mlterm, and it seems that it doesn't (or at least didn't) handle DECRQLP requests when a mouse button is held down. And saitoha's drawing example is entirely dependent on DECRQLP polling, so I can see why that wouldn't work. But if you just need to detect click events, I think mlterm should be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Input Related to input processing (key presses, mouse, etc.) Area-VT Virtual Terminal sequence support Help Wanted We encourage anyone to jump in on these. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

4 participants