Skip to content

MouseParser ​

Namespace: Hex1b.Input

Assembly: Hex1b.dll

Parses mouse escape sequences from the terminal. Supports SGR extended mouse mode (\e[<...M/m) which is the most portable.

csharp
public static class MouseParser

Inheritance ​

Object → MouseParser

Methods ​

TryParseSgr(string, out Hex1bMouseEvent?) ​

Tries to parse a mouse escape sequence. SGR format: \e[<Cb;Cx;CyM (button down) or \e[<Cb;Cx;Cym (button up) Where Cb is button code, Cx is 1-based column, Cy is 1-based row.

Parameters:

  • sequence (String): The escape sequence to parse (without the leading \e[<).
  • mouseEvent (Hex1bMouseEvent): The parsed mouse event if successful.

Returns: Boolean

True if the sequence was a valid mouse event.

csharp
public static bool TryParseSgr(string sequence, out Hex1bMouseEvent? mouseEvent)

Fields ​

DisableMouseTracking ​

ANSI escape sequence to disable mouse tracking.

Returns: String

csharp
public const string DisableMouseTracking = "\u001b[?1006l\u001b[?1003l\u001b[?1002l\u001b[?1000l"

EnableMouseTracking ​

ANSI escape sequence to enable SGR extended mouse mode with motion tracking.

Returns: String

csharp
public const string EnableMouseTracking = "\u001b[?1000h\u001b[?1002h\u001b[?1003h\u001b[?1006h"

Released under the MIT License.