Table of Contents

Class EscSeqUtils

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

Provides a platform-independent API for managing ANSI escape sequences.

public static class EscSeqUtils
Inheritance
EscSeqUtils
Inherited Members

Remarks

Fields

CSI

ESC [ - The CSI (Control Sequence Introducer).

CSI_ActivateAltBufferNoBackscroll

ESC [ ? 1047 h - Activate xterm alternative buffer (no backscroll)

CSI_DisableAnyEventMouse

ESC [ ? 1003 l - Disable any mouse event tracking.

CSI_DisableSgrExtModeMouse

ESC [ ? 1006 l - Disable SGR (Select Graphic Rendition).

CSI_DisableUrxvtExtModeMouse

ESC [ ? 1015 l - Disable URXVT (Unicode Extended Virtual Terminal).

CSI_EnableAnyEventMouse

ESC [ ? 1003 h - Enable mouse event tracking.

CSI_EnableSgrExtModeMouse

ESC [ ? 1006 h - Enable SGR (Select Graphic Rendition).

CSI_EnableUrxvtExtModeMouse

ESC [ ? 1015 h - Enable URXVT (Unicode Extended Virtual Terminal).

CSI_HideCursor

ESC [ ? 25 l - DECTCEM Text Cursor Enable Mode Hide Hide the cursor

CSI_ReportDeviceAttributes_Terminator

The terminator indicating a reply to CSI_SendDeviceAttributes or CSI_SendDeviceAttributes2

CSI_ReportTerminalSizeInChars

CSI 1 8 t | yes | yes | yes | report window size in chars https://terminalguide.namepad.de/seq/csi_st-18/

CSI_ReportTerminalSizeInChars_ResponseValue

The value of the response to CSI_ReportTerminalSizeInChars indicating value 1 and 2 are the terminal size in chars.

CSI_ReportTerminalSizeInChars_Terminator

The terminator indicating a reply to CSI_ReportTerminalSizeInChars : ESC [ 8 ; height ; width t

CSI_RequestCursorPositionReport

ESC [ ? 6 n - Request Cursor Position Report (?) (DECXCPR) https://terminalguide.namepad.de/seq/csi_sn__p-6/

CSI_RequestCursorPositionReport_Terminator

The terminal reply to CSI_RequestCursorPositionReport. ESC [ ? (y) ; (x) R

CSI_RestoreAltBufferWithBackscroll

ESC [ ? 1047 l - Restore xterm working buffer (with backscroll)

CSI_RestoreCursorAndRestoreAltBufferWithBackscroll

ESC [ ? 1049 l - Restore cursor position and restore xterm working buffer (with backscroll)

CSI_RestoreCursorPosition

ESC [ 8 - DECSR Restore Cursor Position from Memory**

CSI_SaveCursorAndActivateAltBufferNoBackscroll

ESC [ ? 1049 h - Save cursor position and activate xterm alternative buffer (no backscroll)

CSI_SaveCursorPosition

ESC [ 7 - Save Cursor Position in Memory**

CSI_SendDeviceAttributes

ESC [ 0 c - Send Device Attributes (Primary DA) https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Application-Program-Command-functions https://www.xfree86.org/current/ctlseqs.html Windows Terminal v1.17 and below emits “\x1b[?1;0c”, indicating "VT101 with No Options". Windows Terminal v1.18+ emits: \x1b[?61;6;7;22;23;24;28;32;42c" See https://github.com/microsoft/terminal/pull/14906 61 - The device conforms to level 1 of the character cell display architecture (See https://github.com/microsoft/terminal/issues/15693#issuecomment-1633304497) 6 = Selective erase 7 = Soft fonts 22 = Color text 23 = Greek character sets 24 = Turkish character sets 28 = Rectangular area operations 32 = Text macros 42 = ISO Latin-2 character set

CSI_SendDeviceAttributes2

ESC [ > 0 c - Send Device Attributes (Secondary DA) Windows Terminal v1.18+ emits: "\x1b[>0;10;1c" (vt100, firmware version 1.0, vt220)

CSI_ShowCursor

ESC [ ? 25 h - DECTCEM Text Cursor Enable Mode Show Show the cursor

KeyEsc

Escape key code (ASCII 27/0x1B).

Properties

CSI_DisableMouseEvents

Control sequence for disabling mouse events.

CSI_EnableMouseEvents

Control sequence for enabling mouse events.

Methods

CSI_ClearScreen(ClearScreenOptions)

ESC [ x J - Clears part of the screen. See EscSeqUtils.ClearScreenOptions.

CSI_SetBackgroundColor(AnsiColorCode)

ESC [ (n) m - Uses CSI_SetGraphicsRendition(params int[]) to set the background color.

CSI_SetBackgroundColor256(int)

ESC[48;5;{id}m - Set background color (256 colors)

CSI_SetBackgroundColorRGB(int, int, int)

ESC[48;2;{r};{g};{b}m Set background color as RGB.

CSI_SetCursorPosition(int, int)

ESC [ y ; x H - CUP Cursor Position - Cursor moves to x ; y coordinate within the viewport, where x is the column of the y line

CSI_SetCursorStyle(DECSCUSR_Style)

ESC [ n SP q - Select Cursor Style (DECSCUSR) https://terminalguide.namepad.de/seq/csi_sq_t_space/

CSI_SetForegroundColor(AnsiColorCode)

ESC [ (n) m - Uses CSI_SetGraphicsRendition(params int[]) to set the foreground color.

CSI_SetForegroundColor256(int)

ESC[38;5;{id}m - Set foreground color (256 colors)

CSI_SetForegroundColorRGB(int, int, int)

ESC[38;2;{r};{g};{b}m Set foreground color as RGB.

CSI_SetGraphicsRendition(params int[])

ESC [ (n) m - SGR - Set Graphics Rendition - Set the format of the screen and text as specified by (n) This command is special in that the (n) position can accept between 0 and 16 parameters separated by semicolons. When no parameters are specified, it is treated the same as a single 0 parameter. https://terminalguide.namepad.de/seq/csi_sm/

CSI_SetTerminalWindowSize(int, int)

ESC [ 8 ; height ; width t - Set Terminal Window Size https://terminalguide.namepad.de/seq/csi_st-8/

DecodeEscSeq(EscSeqRequests, ref ConsoleKeyInfo, ref ConsoleKey, ConsoleKeyInfo[], ref ConsoleModifiers, out string, out string, out string[], out string, out bool, out List<MouseFlags>, out Point, out bool, Action<MouseFlags, Point>)

Decodes an ANSI escape sequence.

GetC1ControlChar(in char)

Gets the c1Control used in the called escape sequence.

GetConsoleKey(char, string?, ref ConsoleModifiers, ref char)

Gets the ConsoleKey depending on terminating and value.

GetConsoleModifiers(string?)

Gets the ConsoleModifiers from the value.

GetEscapeResult(char[])

Gets all the needed information about an escape sequence.

GetKeyCharArray(ConsoleKeyInfo[])

A helper to get only the KeyChar from the ConsoleKeyInfo array.

GetMouse(ConsoleKeyInfo[], out List<MouseFlags>, out Point, Action<MouseFlags, Point>)

Gets the MouseFlags mouse button flags and the position.

MapConsoleKeyInfo(ConsoleKeyInfo)

Ensures a console key is mapped to one that works correctly with ANSI escape sequences.

ResizeArray(ConsoleKeyInfo, ConsoleKeyInfo[])

A helper to resize the ConsoleKeyInfo as needed.