Terminal: report the mouse to programs that ask for it - #2902
Open
insjang wants to merge 3 commits into
Open
Conversation
… on request, and support bracketed paste DEC private mode sequences may carry several modes at once, and ncurses does exactly that when it turns the mouse on: CSI ? 1006 ; 1000 h. The emulator looked at the first parameter only and dropped the rest, so a program could end up with half of what it asked for. Every parameter is now set or reset. DECTCEM (mode 25) lets a program hide the cursor while it draws, or for good; a full screen program that hides it, such as htop, showed a cursor wandering over its screen. The request is passed to the view, which keeps its own blinking and focus handling and simply does not draw the cursor while a program has hidden it. Bracketed paste (mode 2004) marks pasted text with CSI 200~ and CSI 201~ so that a program can take it as text rather than as keys typed - a shell does not run every line of a pasted snippet, an editor does not auto-indent it. Programs that ask for it and do not get it misread multi-line pastes. An end marker inside the text is removed so the paste cannot close its own bracket early.
Programs that draw their own screen - htop, ncurses menus, and lately CLIs with clickable options and wheel scrolling - ask the terminal for mouse events with DEC modes 1000 (presses and releases), 1002 (also drags) and 1003 (every move), in xterm's legacy encoding or the SGR one (mode 1006). The terminal ignored the request and kept every click for its own selection, so such programs could not be clicked on or scrolled. The canvas now hands presses, releases, moves and the wheel to the control while a program has asked for them, with the alt and control keys folded into the button as xterm does. Shift keeps the mouse for the terminal, which is the convention every terminal uses to still allow a selection while a program is listening. A press that went to the program takes the terminal's selection away and moves the selection anchor to the click, so a later shift-drag starts from where the user last clicked rather than from a selection made long before. A release goes wherever its press went, whatever the keyboard state by then, so press and release always reach the same side. Mode 1004 tells the program when the terminal gains or loses focus, and mode 2026 (synchronized output) lets it mark the beginning and end of a redraw, during which the view leaves the screen alone rather than showing it half drawn. This builds on the DEC private mode parsing change (every parameter in a set/reset), since ncurses turns the mouse on with CSI ? 1006 ; 1000 h.
Package-private static access does not cross an OSGi bundle boundary even within the same package name; MouseReportTest lives in a separate test bundle and failed with IllegalAccessError.
insjang
added a commit
to insjang/eclipse.platform
that referenced
this pull request
Sep 3, 2026
Same cross-bundle package-private access problem as mouseReport in eclipse-platform#2902 -- the test bundle is a separate OSGi bundle, so package-private static does not reach it even under the same package name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #2901 (the DEC private mode parsing change): ncurses turns the mouse on with
CSI ? 1006 ; 1000 h, which needs every parameter of a set/reset to be taken. This PR shows that commit as well until #2901 is merged; only the second commit is new here.Programs that draw their own screen — htop, ncurses menus, and lately CLIs with clickable options and wheel scrolling — ask the terminal for mouse events with DEC modes 1000 (presses and releases), 1002 (also drags) and 1003 (every move), in xterm's legacy encoding or the SGR one (mode 1006). The terminal ignored the request and kept every click for its own selection, so such programs could not be clicked on or scrolled.
Tests:
MouseReportTest(both encodings, modifiers, wide columns) and mode handling inVT100EmulatorTest.