[PR #3963] [VT Mouse Mode] Translate SGR Mouse VT Sequences to MOUSE_EVENT_RECORD #25585

Open
opened 2026-01-31 09:10:26 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/3963

State: closed
Merged: Yes


Summary of the Pull Request

Upgrades the InputStateMachineEngine to take SGR Mouse VT Sequences and translate them into MOUSE_EVENT_RECORDS.

References

https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Extended-coordinates
#376

PR Checklist

Detailed Description of the Pull Request / Additional comments

Modifications to InputStateMachineEngine

I introduced various enum types...

  • CsiIntermediateCodes: our supported intermediate codes. Currently only <
  • CsiEndCodes: the last code used for SGR Mouse Mode
  • CsiMouseButtonCodes: which button was pressed. Mutually exclusive. Buttons beyond button 11 are ambiguous.
  • CsiMouseModifierCodes: bitfield of modifiers active for SGR Mouse Mode.

CsiIntermediateCodes is used first in ActionCsiDispatch to detect the VT Sequence. This kicks off a chain of function calls...

  • _GetXYPosition(): figure out where the mouse was clicked
  • _UpdateSGRMouseButtonState: read in what we found and update our internal state
  • _WriteMouseEvent(): generate an INPUT_RECORD and send it off

Modifications to Testing Suite

read below.
Also, made the test state a globally accessible/modifiable variable.

Validation Steps Performed

Added tests that cover...

  • button clicks
  • button clicks with modifiers
  • mouse movement
  • mouse movement and entering/exiting a state where multiple buttons were pressed
**Original Pull Request:** https://github.com/microsoft/terminal/pull/3963 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Upgrades the `InputStateMachineEngine` to take SGR Mouse VT Sequences and translate them into `MOUSE_EVENT_RECORDS`. ## References https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Extended-coordinates #376 ## PR Checklist * [X] Contributes to #376 * [X] CLA signed. * [X] Tests added/passed * [ ] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments ### Modifications to `InputStateMachineEngine` I introduced various enum types... - `CsiIntermediateCodes`: our supported intermediate codes. Currently only `<` - `CsiEndCodes`: the last code used for SGR Mouse Mode - `CsiMouseButtonCodes`: which button was pressed. Mutually exclusive. Buttons beyond button 11 are ambiguous. - `CsiMouseModifierCodes`: bitfield of modifiers active for SGR Mouse Mode. `CsiIntermediateCodes` is used first in `ActionCsiDispatch` to detect the VT Sequence. This kicks off a chain of function calls... - `_GetXYPosition()`: figure out where the mouse was clicked - `_UpdateSGRMouseButtonState`: read in what we found and update our internal state - `_WriteMouseEvent()`: generate an INPUT_RECORD and send it off ### Modifications to Testing Suite read below. Also, made the test state a globally accessible/modifiable variable. ## Validation Steps Performed Added tests that cover... - button clicks - button clicks with modifiers - mouse movement - mouse movement and entering/exiting a state where multiple buttons were pressed
claunia added the pull-request label 2026-01-31 09:10:26 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25585