Class AnsiMouseParser
Parses ANSI mouse escape sequences into Mouse including support for button press/release, mouse wheel, and motion events.
public class AnsiMouseParser
- Inheritance
-
AnsiMouseParser
- Inherited Members
Remarks
This parser handles SGR (1006) extended mouse mode format: ESC[<button;x;yM/m
where 'M' indicates button press and 'm' indicates button release.
Prerequisites: The terminal must have mouse tracking enabled via CSI_EnableMouseEvents, which enables modes 1003 (any-event tracking), 1015 (URXVT), and 1006 (SGR format).
Common User Actions and ANSI Behavior:
- Click: Terminal sends one press event (M) at button down, one release event (m) at button up. No auto-repeat while held stationary.
- Drag: Terminal sends one press event (M), multiple motion events with PositionReport and the button flag set (e.g., button code 32-34 for drag), then one release event (m).
- Mouse Move (no button): Terminal sends motion events with button code 35-63 and PositionReport flag (mode 1003 only).
- Scroll Wheel: Terminal sends single events with button codes 64 (up) or 65 (down). No press/release distinction - wheel events don't use M/m terminators.
- Horizontal Wheel: Terminal sends button codes 68 (left) or 69 (right), typically with Shift modifier.
Coordinate System: ANSI uses 1-based coordinates where (1,1) is the top-left corner. This parser converts to 0-based coordinates for Terminal.Gui's internal representation.
Methods
- IsMouse(string?)
Returns true if it is a mouse event
- ProcessMouseInput(string?)
Parses a mouse ansi escape sequence into a mouse event. Returns null if input is not a mouse event or its syntax is not understood.