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

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/3963
Author: @carlos-zamora
Created: 12/14/2019
Status: ✅ Merged
Merged: 2/3/2020
Merged by: @undefined

Base: master ← Head: dev/cazamor/vt-mouse-mode


📝 Commits (9)

  • 629b43e SGR Mouse Mode for InputStateMachine
  • cc092de Testing Modifications and Additions:
  • ae3e8a4 Test and feature polish
  • e20291e make sure we always update the state. fix static analysis error
  • dbed160 merge master
  • d4542bf PR Changes
  • ab40735 PR Comments
  • e60003e caught off guard by the formatter
  • 11286f5 scrolling tests and bugfix

📊 Changes

3 files changed (+614 additions, -93 deletions)

View changed files

📝 src/terminal/parser/InputStateMachineEngine.cpp (+227 -82)
📝 src/terminal/parser/InputStateMachineEngine.hpp (+123 -0)
📝 src/terminal/parser/ut_parser/InputEngineTest.cpp (+264 -11)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/3963 **Author:** [@carlos-zamora](https://github.com/carlos-zamora) **Created:** 12/14/2019 **Status:** ✅ Merged **Merged:** 2/3/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/cazamor/vt-mouse-mode` --- ### 📝 Commits (9) - [`629b43e`](https://github.com/microsoft/terminal/commit/629b43eb64be6281f1f4831373184f592813c130) SGR Mouse Mode for InputStateMachine - [`cc092de`](https://github.com/microsoft/terminal/commit/cc092de071986b5a2365ebde604c93ae74c00124) Testing Modifications and Additions: - [`ae3e8a4`](https://github.com/microsoft/terminal/commit/ae3e8a4606636a90dc88a63ce80c66d07f40f7df) Test and feature polish - [`e20291e`](https://github.com/microsoft/terminal/commit/e20291ed33c85c3172f71c76a6daeeab2b9e0b5b) make sure we always update the state. fix static analysis error - [`dbed160`](https://github.com/microsoft/terminal/commit/dbed1602811884125108d806fbf2e54aff4fc4c4) merge master - [`d4542bf`](https://github.com/microsoft/terminal/commit/d4542bfa4999bf0e1c197c1bf82aa3d31c18334d) PR Changes - [`ab40735`](https://github.com/microsoft/terminal/commit/ab407353620ada41a81b02d5c1a2e0d2a6898524) PR Comments - [`e60003e`](https://github.com/microsoft/terminal/commit/e60003ec449c6a8a42cd8ec1bf5fe1e9d194daa2) caught off guard by the formatter - [`11286f5`](https://github.com/microsoft/terminal/commit/11286f50035e3903be897c9c5f406963ffb33732) scrolling tests and bugfix ### 📊 Changes **3 files changed** (+614 additions, -93 deletions) <details> <summary>View changed files</summary> 📝 `src/terminal/parser/InputStateMachineEngine.cpp` (+227 -82) 📝 `src/terminal/parser/InputStateMachineEngine.hpp` (+123 -0) 📝 `src/terminal/parser/ut_parser/InputEngineTest.cpp` (+264 -11) </details> ### 📄 Description ## 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:10:25 +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#25580