Table of Contents

Class EscSeqUtils

Namespace
Terminal.Gui.Drivers
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_DisableMouseEvents

Control sequence for disabling mouse events.

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_EnableMouseEvents

Control sequence for enabling mouse events.

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_ReportWindowSizeInChars

CSI 1 8 t | yes | yes | yes | report window size in chars https://terminalguide.namepad.de/seq/csi_st-18/ The terminator indicating a reply to CSI_ReportWindowSizeInChars : ESC [ 8 ; height ; width t

CSI_ReportWindowSizeInChars_ResponseValue

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

CSI_ReportWindowSizeInChars_Terminator

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

CSI_RequestCursorPositionReport

ESC [ ? 6 n - Request Cursor Position Report (?) (DECXCPR) https://terminalguide.namepad.de/seq/csi_sn__p-6/ The terminal reply to CSI_RequestCursorPositionReport. ESC [ ? (y) ; (x) ; 1 R

CSI_RequestCursorPositionReport_Terminator

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

CSI_RequestSixelResolution

CSI 16 t - Request sixel resolution (width and height in pixels)

CSI_RequestWindowSizeInPixels

CSI 14 t - Request window size in pixels (width x height)

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 The terminator indicating a reply to CSI_SendDeviceAttributes or CSI_SendDeviceAttributes2

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).

OSC

OSC (Operating System Command) escape sequence prefix.

ST

String Terminator (ST) - terminates OSC sequences.

Methods

CSI_AppendBackgroundColorRGB(StringBuilder, int, int, int)

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

CSI_AppendCursorPosition(StringBuilder, 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_AppendForegroundColorRGB(StringBuilder, int, int, int)

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

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/

CSI_WriteCursorPosition(TextWriter, 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

MapChar(char)

Helper to set the Control key states based on the char.

MapConsoleKeyInfo(ConsoleKeyInfo)

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

OSC_EndHyperlink()

Ends a hyperlink using OSC 8 escape sequence.

OSC_StartHyperlink(string, string?)

Starts a hyperlink using OSC 8 escape sequence.

ToString(ConsoleKeyInfo[])

Convert a ConsoleKeyInfo array to string.