Skip to content

Class TerminalEmulator

The terminal state machine: screen, cursor, attributes, modes, and responses. Feed host output through Feed; bytes the terminal sends back to the host (query responses) arrive on Output. All calls are expected on one thread. It is a VT100, VT52 mode included, with the VT102 and xterm additions programs rely on.

Declaration
public sealed class TerminalEmulator
Declaration
public ScreenBuffer Screen { get; }
Declaration
public ScreenBuffer MainScreen { get; }
Declaration
public bool AltScreenActive { get; }
Declaration
public int Cols { get; }
Declaration
public int Rows { get; }
Declaration
public int CursorX { get; }
Declaration
public int CursorY { get; }
Declaration
public bool CursorVisible { get; }
Declaration
public CursorShape CursorStyle { get; }
Declaration
public string Title { get; }
Declaration
public bool ApplicationCursorKeys { get; }

DECKPAM: the numeric keypad sends application codes.

Declaration
public bool ApplicationKeypad { get; }

DECANM reset: the terminal takes VT52 escape sequences until ESC < returns it to ANSI.

Declaration
public bool Vt52Mode { get; }

LNM: a line feed also returns the carriage, and Enter sends CR LF.

Declaration
public bool NewLineMode { get; }

SRM reset: the host does not echo, so typed input is shown by the terminal itself.

Declaration
public bool LocalEcho { get; }

KAM: the host has locked the keyboard; input is dropped until it unlocks it.

Declaration
public bool KeyboardLocked { get; }

DECSCNM: the whole screen shows light on dark as dark on light.

Declaration
public bool ReverseVideo { get; }

DECLL: the keyboard’s L1 to L4 lights, as bits 0 to 3.

Declaration
public int KeyboardLeds { get; }

What ENQ is answered with. Empty answers nothing.

Declaration
public string Answerback { get; set; }

Lets DECCOLM switch the terminal between 80 and 132 columns, as xterm’s mode 40 does. Off, the mode still clears the screen and homes the cursor, as on a VT100, but the width stays.

Declaration
public bool AllowColumnChange { get; set; }
Declaration
public bool BracketedPaste { get; }
Declaration
public MouseTrackingMode MouseTracking { get; }
Declaration
public MouseEncoding MouseEncode { get; }

Bumped on every visible change; renderers compare and redraw.

Declaration
public int ChangeVersion { get; }

The keyboard modes the host has set, for an input encoder.

Declaration
public KeyboardModes KeyboardModes { get; }
Declaration
public void Feed(byte[] data, int offset, int count)
Type Name
System.Byte[] data
System.Int32 offset
System.Int32 count
Declaration
public void Feed(byte[] data)
Type Name
System.Byte[] data
Declaration
public void FeedText(string text)
Type Name
System.String text
Declaration
public void Resize(int cols, int rows)
Type Name
System.Int32 cols
System.Int32 rows
Declaration
public void FullReset()

Reads the text a selection covers, for copy. Rows below 0 reach into scrollback.

Declaration
public string GetText(CellRange range)

System.String

Type Name
DarkEffekt.Terminal.CellRange range

Reads a run of text from (x0, y0) through (x1, y1), inclusive. Rows below 0 reach into scrollback.

Declaration
public string GetText(int x0, int y0, int x1, int y1)

System.String

Type Name
System.Int32 x0
System.Int32 y0
System.Int32 x1
System.Int32 y1

Bytes the terminal sends to the host: query responses.

Declaration
public event Action<byte[]> Output

System.Action<System.Byte[]>

Raised when the host rings the bell.

Declaration
public event Action Bell

System.Action

Raised when the host sets the window title through OSC 0 or 2.

Declaration
public event Action<string> TitleChanged

System.Action<System.String>

Raised when the host changes the keyboard lights with DECLL.

Declaration
public event Action<int> KeyboardLedsChanged

System.Action<System.Int32>

Raised when DECCOLM asks for 80 or 132 columns, before the terminal resizes itself if AllowColumnChange is on.

Declaration
public event Action<int> ColumnsRequested

System.Action<System.Int32>