TerminalWriter

interface TerminalWriter

Write-side contract for the terminal buffer.

Consumed by the ANSI parser to push character data and control codes into the active screen. All operations target the cursor's current position unless otherwise stated.

The core is intentionally spatial rather than temporal. Parser layers are expected to decide grapheme-cluster boundaries and call either the scalar fast path (writeCodepoint) or the explicit cluster ingress (writeCluster).

Inheritors

Functions

Link copied to clipboard
abstract fun appendToPreviousCluster(codepoint: Int)

Appends one grapheme-continuation codepoint to the most recently written printable cell without moving the cursor.

Link copied to clipboard
abstract fun carriageReturn()

Executes a carriage return (CR, 0x0D).

Link copied to clipboard
abstract fun clearAll()

Clears all visible content and scrollback history, resets the pen, homes the cursor, clears the DECSC saved-cursor slot, and restores tab stops to the VT100 default spacing.

Link copied to clipboard
abstract fun clearScreen()

Clears the visible screen and homes the cursor (equivalent to ED 2 + CUP).

Link copied to clipboard
abstract fun decaln()

Executes the DEC Screen Alignment Test (DECALN, ESC # 8).

Link copied to clipboard
abstract fun deleteCharacters(count: Int)

Deletes count characters at the cursor column, shifting the remainder of the line left and filling the vacated right cells with blanks using the active pen attribute (DCH, CSI n P). Cursor position is not changed.

Link copied to clipboard
abstract fun deleteLines(count: Int)

Deletes count lines starting at the cursor row within the active scroll region (DL, CSI n M).

Link copied to clipboard
abstract fun eraseCharacters(count: Int)

Erases count characters starting at the cursor column without shifting the remainder of the line (ECH, CSI n X).

Link copied to clipboard
abstract fun eraseCurrentLine()

Erases the entire current line without moving the cursor (EL 2, CSI 2 K).

Link copied to clipboard
abstract fun eraseEntireScreen()

Erases the entire visible screen without moving the cursor (ED 2, CSI 2 J).

Link copied to clipboard
abstract fun eraseLineToCursor()

Erases from the start of the current line through the cursor (EL 1, CSI 1 K).

Link copied to clipboard
abstract fun eraseLineToEnd()

Erases from the cursor to the end of the current line (EL 0, CSI 0 K).

Link copied to clipboard
abstract fun eraseScreenAndHistory()

Erases all scrollback history while preserving the visible viewport (xterm/VTE ED 3, CSI 3 J).

Link copied to clipboard
abstract fun eraseScreenToCursor()

Erases from the start of the visible screen through the cursor (ED 1, CSI 1 J).

Link copied to clipboard
abstract fun eraseScreenToEnd()

Erases from the cursor to the end of the visible screen (ED 0, CSI 0 J).

Link copied to clipboard
abstract fun insertBlankCharacters(count: Int)

Inserts count blank cells at the cursor column, shifting existing cells right (ICH, CSI n @). Cells pushed past the right margin are discarded.

Link copied to clipboard
abstract fun insertLines(count: Int)

Inserts count blank lines at the cursor row within the active scroll region (IL, CSI n L).

Link copied to clipboard
abstract fun newLine()

Executes a line feed (LF, 0x0A).

Link copied to clipboard
abstract fun resetPen()

Resets the active pen to the terminal default attributes (SGR 0, CSI 0 m).

Link copied to clipboard
abstract fun resetScrollRegion()

Resets the scroll region to the full viewport and homes the cursor.

Link copied to clipboard
abstract fun reverseLineFeed()

Executes Reverse Index (RI, ESC M).

Link copied to clipboard
abstract fun scrollDown()

Scrolls the active scroll region down by one line (SD, CSI 1 T).

Link copied to clipboard
abstract fun scrollUp()

Scrolls the active scroll region up by one line (SU, CSI 1 S).

Link copied to clipboard

Selectively erases the entire current line without moving the cursor (DECSEL 2).

Link copied to clipboard

Selectively erases the entire visible screen without moving the cursor (DECSED 2).

Link copied to clipboard

Selectively erases from the start of the current line through the cursor (DECSEL 1).

Link copied to clipboard

Selectively erases from the cursor to the end of the current line (DECSEL 0).

Link copied to clipboard

Selectively erases from the start of the visible screen through the cursor (DECSED 1).

Link copied to clipboard

Selectively erases from the cursor through the end of the visible screen (DECSED 0).

Link copied to clipboard
abstract fun setHyperlinkId(hyperlinkId: Int)

Sets the active OSC 8 hyperlink id stamped onto future printed cells.

Link copied to clipboard
abstract fun setIconTitle(title: String)

Sets the xterm icon title.

Link copied to clipboard
abstract fun setLeftRightMargins(left: Int, right: Int)

Sets the active horizontal margins (DECSLRM, CSI left ; right s).

Link copied to clipboard
abstract fun setPenAttributes(fg: Int, bg: Int, bold: Boolean = false, faint: Boolean = false, italic: Boolean = false, underlineStyle: UnderlineStyle = UnderlineStyle.NONE, strikethrough: Boolean = false, overline: Boolean = false, blink: Boolean = false, inverse: Boolean = false, conceal: Boolean = false, underlineColor: Int = 0)

Sets the active pen attributes used by all subsequent write and erase operations.

Link copied to clipboard
abstract fun setPenColors(foreground: CellColor, background: CellColor, underlineColor: CellColor = CellColor.DEFAULT, bold: Boolean = false, faint: Boolean = false, italic: Boolean = false, underlineStyle: UnderlineStyle = UnderlineStyle.NONE, strikethrough: Boolean = false, overline: Boolean = false, blink: Boolean = false, inverse: Boolean = false, conceal: Boolean = false)

Sets the active pen attributes using explicit default, indexed, or RGB colors.

Link copied to clipboard
abstract fun setScrollRegion(top: Int, bottom: Int)

Sets the active vertical scroll region (DECSTBM, CSI top ; bottom r).

Link copied to clipboard
abstract fun setSelectiveEraseProtection(enabled: Boolean)

Enables or disables selective-erase protection on future printed cells (DECSCA).

Link copied to clipboard
abstract fun setWindowTitle(title: String)

Sets the xterm window title.

Link copied to clipboard
abstract fun writeCluster(codepoints: IntArray, length: Int = codepoints.size)

Writes one pre-segmented grapheme cluster to the grid.

Link copied to clipboard
abstract fun writeCodepoint(codepoint: Int)

Writes one Unicode scalar value at the cursor position using the active pen attributes, then advances the cursor.

Link copied to clipboard
abstract fun writeText(text: String)

Writes text literally to the buffer using the active pen attributes.