KetraTerm
API · DevelopmentAll versions

TerminalBuffer

Full public contract for the terminal buffer.

Composes all role-specific interfaces into a single surface for host applications and host tests.

Cursor positions and cell/line reads use zero-based viewport coordinates. Margin and rectangular commands retain the DEC one-based conventions documented on each method, including zero for omitted rectangle parameters. The host adapter owns conversion from parser commands; the parser does not own grid coordinates.

Instances returned by io.github.ketraterm.core.TerminalBuffers require external serialization of mutations and grid/cursor/history reads. Atomic mode snapshots may be read independently as documented by TerminalModeReader. Borrowed line and render views are valid only while that serialization is held. Session-backed hosts access terminal state through their session boundary rather than concurrently mutating this buffer.

Host adapters should depend on the narrower interfaces they need; this facade composes the complete core contract for direct embedders.

Inheritors

Properties

Link copied to clipboard
abstract val cursorCol: Int

Active cursor column in zero-based viewport coordinates.

Link copied to clipboard
abstract val cursorRow: Int

Active cursor row in zero-based viewport coordinates.

Link copied to clipboard

Invalidation token for incomplete transfers, changed by reset, screen switch and destructive clearing. Compare for inequality, not ordering. This is separate from the render frame's graphics generation.

Link copied to clipboard
abstract val height: Int

Current viewport height in rows.

Link copied to clipboard
abstract val historySize: Int

Number of retained off-screen history lines in the active buffer.

Link copied to clipboard
abstract val iconTitle: String

Active xterm icon title.

Link copied to clipboard

Actual active screen. Read synchronously under the same serialization as terminal mutations.

Link copied to clipboard

Current immutable effective palette, including application color overrides. Reading retains the existing object without allocating or reading a render frame. Synchronize with terminal mutations before reading; a retained palette remains safe to use after releasing that synchronization.

Link copied to clipboard

The number of queued response bytes currently waiting to be read.

Link copied to clipboard
abstract val width: Int

Current viewport width in cells.

Link copied to clipboard
abstract val windowTitle: String

Active xterm window title.

Functions

Link copied to clipboard
abstract fun applyColorRequest(request: TerminalColorRequest, allowResponses: Boolean)

Applies borrowed OSC 21 color operations in order, without retaining request. Queries observe preceding operations and share one response in request order. Resets restore the latest theme; dynamic selection and cursor roles retain their dynamic behavior until changed or reset. Application changes do not emit color-scheme notifications.

Link copied to clipboard

Commits an externally decoded upload or query under the same admission, placement and reply rules as applyGraphicsCommand. The decoder owns payload validation; core still validates controls, image bounds and placement before replacing any retained image. PNG dimensions come from image.

Link copied to clipboard
abstract fun applyGraphicsCommand(command: TerminalGraphicsCommand, data: ByteArray, length: Int, result: TerminalGraphicsResult, allowReplies: Boolean)

Applies a complete command using the Base64-decoded prefix data[0 until length]. command and data are borrowed for this call. Raw RGB/RGBA pixels are copied into immutable storage before returning; upload-only and query operations do not place an image. Placement uses the current cursor and known cell-pixel geometry.

Link copied to clipboard
abstract fun carriageReturn()

Executes a carriage return (CR, 0x0D).

Link copied to clipboard
abstract fun changeRectangleAttributes(top: Int, left: Int, bottom: Int, right: Int, setMask: Int, clearMask: Int)

Changes DECCARA visual attributes without changing cell values, protection, hyperlinks, or the current SGR pen. Masks use io.github.ketraterm.protocol.DecRectangleAttribute bits.

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 clearAllTabStops()

Clears all tab stops (TBC 3, CSI 3 g).

Link copied to clipboard
abstract fun clearResponseBytes()

Discards all queued response bytes from this channel.

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 clearTabStop()

Clears the tab stop at the current cursor column (TBC 0, CSI 0 g).

Link copied to clipboard
abstract fun copyRectangle(sourceTop: Int, sourceLeft: Int, sourceBottom: Int, sourceRight: Int, sourcePage: Int, destinationTop: Int, destinationLeft: Int, destinationPage: Int)

Copies a VT420 rectangular area (DECCRA) without moving the cursor.

Link copied to clipboard
abstract fun cursorBackwardTab(count: Int = 1)

Moves the cursor backward by count tab stops (CBT, CSI Ps Z).

Link copied to clipboard
abstract fun cursorDown(n: Int = 1)

Moves the cursor down by n rows (CUD, CSI n B).

Link copied to clipboard
abstract fun cursorForwardTab(count: Int = 1)

Advances the cursor forward by count tab stops (CHT, CSI Ps I).

Link copied to clipboard
abstract fun cursorLeft(n: Int = 1)

Moves the cursor left by n columns (CUB, CSI n D).

Link copied to clipboard
abstract fun cursorRight(n: Int = 1)

Moves the cursor right by n columns (CUF, CSI n C).

Link copied to clipboard
abstract fun cursorUp(n: Int = 1)

Moves the cursor up by n rows (CUU, CSI n A).

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 deleteColumns(count: Int)

Deletes DECDC columns at the cursor column across the active vertical scroll region.

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 enterAltBuffer()

Switches to the alternate screen buffer with cursor save (CSI ? 1049 h).

Link copied to clipboard
abstract fun enterAltBufferWithoutCursorSave(clearBeforeEnter: Boolean)

Switches to the alternate screen buffer without saving the primary cursor state.

Link copied to clipboard
open fun eraseBuffer()

Erases the active screen and history with the current erase attributes. Preserves the cursor position, pen, modes, margins, tabs, saved cursor, and inactive buffer. Cancels pending wrap and replaces erased line identities. The caller must serialize access with all other terminal operations.

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 eraseRectangle(top: Int, left: Int, bottom: Int, right: Int, selective: Boolean)

Erases a VT400 rectangular area (DECERA / DECSERA).

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 executeDeccolm(newWidth: Int)

Executes DECCOLM (CSI ? 3 h / CSI ? 3 l) as a core-owned macro command.

Link copied to clipboard
abstract fun exitAltBuffer()

Returns to the primary screen buffer with cursor restore (CSI ? 1049 l).

Link copied to clipboard

Returns to the primary screen buffer without restoring a saved cursor.

Link copied to clipboard
abstract fun fillRectangle(codepoint: Int, top: Int, left: Int, bottom: Int, right: Int)

Fills a VT420 rectangular area (DECFRA) with a one-cell DEC character.

Link copied to clipboard
abstract fun getAllAsString(): String

Returns scrollback history followed by the visible screen as a newline-joined string, oldest line first.

Link copied to clipboard
abstract fun getAttrAt(col: Int, row: Int): CellAttributes?

Returns the attributes at a screen position as an unpacked CellAttributes object.

Link copied to clipboard
abstract fun getCodepointAt(col: Int, row: Int): Int

Returns the display/base codepoint at [col, row].

Link copied to clipboard
open override fun getInputModeBits(): Long

Returns one atomic packed snapshot for input encoders.

Link copied to clipboard
abstract fun getLine(row: Int): TerminalLine

Returns the visible line at row, or a shared void line when row is out of bounds.

Link copied to clipboard
abstract fun getLineAsString(row: Int): String

Returns the content of a visible row as a string, trimming trailing blank cells while preserving intentional space characters.

Link copied to clipboard
abstract fun getModeBitsSnapshot(): Long

Returns one atomic snapshot of the published packed mode subset.

Link copied to clipboard

Returns an immutable snapshot of the published TerminalModeSnapshot fields.

Link copied to clipboard
abstract fun getScreenAsString(): String

Returns the visible screen as a newline-joined string, top to bottom.

Link copied to clipboard
abstract fun horizontalTab()

Advances the cursor to the next tab stop (HT, 0x09).

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 insertColumns(count: Int)

Inserts DECIC blank columns at the cursor column across the active vertical scroll region.

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 popColors()

Restores and removes the most recently saved colors; an empty stack has no effect. The latest host theme remains the source for color resets. Host light/dark preference and bold-as-bright behavior are preserved. An effective change invalidates visible rows without emitting a color-scheme notification; unchanged colors preserve palette identity and render generations.

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

Pops up to count entries from the active screen's Kitty keyboard stack. A positive count that empties the stack (or finds it empty) resets all flags to zero. Otherwise, restores the last popped flags. Work is independent of count; nonpositive counts leave flags and stack unchanged.

Link copied to clipboard
abstract fun positionCursor(col: Int, row: Int)

Moves the cursor to an absolute position (CUP / HVP, CSI row ; col H).

Link copied to clipboard
abstract fun pushColors()

Saves effective indexed and named colors, including dynamic presentation, on a terminal-wide stack of ten entries. A full stack discards its oldest entry. Screen switches, resize, and theme changes preserve saved colors; hard and soft terminal resets clear the stack. Saving does not repaint.

Link copied to clipboard
abstract fun pushKittyKeyboardFlags(flags: Int)

Pushes the current Kitty keyboard progressive-enhancement flags to the stack, and sets the new active flags. Each screen retains at most 32 entries, evicting the oldest when full.

Link copied to clipboard
abstract fun queryDynamicColor(target: Int)

Enqueues the color query response for a dynamic target (10, 11, or 12).

Link copied to clipboard
abstract fun queryPaletteColor(index: Int)

Enqueues the color query response for a specific 256-color palette index.

Link copied to clipboard
abstract fun queryStatusString(query: String)

Enqueues the response for a DCS DECRQSS request.

Link copied to clipboard
abstract fun queryTerminfo(rawPayload: String)

Enqueues the response for a DCS XTGETTCAP request.

Link copied to clipboard
abstract fun readResponseBytes(dst: ByteArray, offset: Int = 0, length: Int = dst.size - offset): Int

Reads up to length queued response bytes into dst.

Link copied to clipboard
abstract fun requestDeviceAttributes(kind: Int, parameter: Int)

Enqueues a device attributes (DA) report response.

Link copied to clipboard
abstract fun requestDeviceStatusReport(mode: Int, decPrivate: Boolean)

Enqueues a device status report (DSR) response.

Link copied to clipboard
abstract fun requestKeyFormatOption(resource: Int)

Enqueues an allowlisted XTQFMTKEYS reply using the active format resource. Unknown and reserved resources stay silent; this protocol defines no failure reply. Host adapters must enforce terminal-response policy before calling this API.

Link copied to clipboard
abstract fun requestKeyModifierOption(resource: Int)

Enqueues an allowlisted xterm key-modifier option response.

Link copied to clipboard

Enqueues the active Kitty keyboard progressive-enhancement flags as a parameterless CSI ? u query response. Core reports only flags retained by its supported-mode mask.

Link copied to clipboard
abstract fun requestModeStatus(mode: Int, decPrivate: Boolean, hostCapabilities: Int = 0, defaultBackarrowSendsBackspace: Boolean = false)

Enqueues one ANSI or DEC private DECRPM reply (CSI [?] mode;status $ y). The explicit mode allowlist returns status 0 for unsupported queries. Negative identifiers produce no response. Queries do not mutate modes or invalidate rendering. Invoke under the same synchronization as core mutation. Host adapters must enforce terminal-response policy before calling this API.

Link copied to clipboard
abstract fun requestRectangleChecksum(requestId: Int, page: Int, top: Int, left: Int, bottom: Int, right: Int)

Enqueues a VT420 DECRQCRA response for an active-page rectangular area.

Link copied to clipboard
abstract fun requestWindowReport(mode: Int)

Enqueues an allowlisted window report response using current host geometry. Pixel-size query reports remain silent when the host has not supplied usable dimensions. Cell pixel dimensions use the integer text-area pixel size divided by the grid dimensions. Callers must enforce terminal-response permission for application queries.

Link copied to clipboard
abstract fun reset()

Performs a full terminal reset (RIS, ESC c).

Link copied to clipboard
abstract fun resetCursor()

Resets the cursor to the home position (col=0, row=0).

Link copied to clipboard
abstract fun resetCursorStyle()

Restores the configured default shape and enables cursor blinking.

Link copied to clipboard
abstract fun resetDynamicColor(target: Int)

Restores one dynamic color from the latest host-configured theme. Other application overrides are preserved; unsupported targets are ignored.

Link copied to clipboard
abstract fun resetKeyFormatOption(resource: Int)

Restores one format resource to 0; unknown resources are ignored.

Link copied to clipboard
abstract fun resetKeyFormatOptions()

Restores all xterm format resources atomically, preserving modifier resources.

Link copied to clipboard
abstract fun resetKeyModifierOption(resource: Int)

Restores one modifier resource's initial value; unknown resources are ignored.

Link copied to clipboard

Restores all xterm modifier resources atomically, preserving format resources.

Link copied to clipboard
abstract fun resetPaletteColors(indices: IntArray, count: Int = indices.size)

Restores indexed colors from the latest host-configured theme in one update.

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 resize(newWidth: Int, newHeight: Int, oldScrollbackOffset: Int = 0): Pair<Int, Int>

Resizes the terminal to newWidth x newHeight.

abstract fun resize(newWidth: Int, newHeight: Int, oldScrollbackOffset: Int, pixelWidth: Int, pixelHeight: Int): Pair<Int, Int>

Resizes the grid and records text-area pixels as one completed operation.

Link copied to clipboard
abstract fun restoreCursor()

Restores the core-owned state saved by saveCursor (DECRC, ESC 8).

Link copied to clipboard
abstract fun reverseLineFeed()

Executes Reverse Index (RI, ESC M).

Link copied to clipboard
abstract fun reverseRectangleAttributes(top: Int, left: Int, bottom: Int, right: Int, reverseMask: Int)

Reverses DECRARA visual attributes without changing cell values, protection, hyperlinks, or the current SGR pen. reverseMask uses io.github.ketraterm.protocol.DecRectangleAttribute bits.

Link copied to clipboard
abstract fun saveCursor()

Saves the core-owned cursor state (DECSC, ESC 7).

Link copied to clipboard
abstract fun scrollDown()

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

abstract fun scrollDown(count: Int)

Scrolls the active region down by count lines, capped at its height. Non-positive counts are ignored. Preserves the cursor position and uses the same horizontal-margin rules as scrollDown, without consuming history. Work is bounded by the grid dimensions, not the supplied count.

Link copied to clipboard
abstract fun scrollUp()

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

abstract fun scrollUp(count: Int)

Scrolls the active region up by count lines, capped at its height. Non-positive counts are ignored. Preserves the cursor position and uses the same horizontal-margin and history-admission rules as scrollUp. Work is bounded by the grid dimensions, not the supplied count.

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 setAlternateScrollEnabled(enabled: Boolean)

Sets alternate-screen wheel scrolling (DEC private mode 1007). Enabled by default; host policy may suppress wheel-to-key translation. Preserves pending wrap and survives screen switches, resize, and DECSTR.

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

Toggles application cursor key mode (DECCKM, CSI ? 1 h / CSI ? 1 l).

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

Toggles application keypad mode (DECNKM).

Link copied to clipboard
abstract fun setAttributeChangeExtent(extent: Int)

Selects DECSACE extent for future DECCARA and DECRARA operations.

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

Enables or disables DECAWM auto-wrap (CSI ? 7 h / CSI ? 7 l).

Link copied to clipboard
abstract fun setBackarrowKeyMode(sendsBackspace: Boolean)

Selects the Backspace wire byte through DECBKM (CSI ? 67 h/l).

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

Toggles urgent bell mode (?1042).

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

Enables or disables bracketed paste reporting (CSI ? 2004 h / CSI ? 2004 l).

Link copied to clipboard
abstract fun setChangeNotificationsAllowed(allowed: Boolean)

Publishes host permission for automatic color-scheme and resize reports.

Link copied to clipboard

Subscribes to host color-scheme changes (DECSET/DECRST ?2031).

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

Toggles cursor blink presentation state.

Link copied to clipboard

Sets the cursor shape/style.

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

Toggles cursor visibility presentation state (DECTCEM, CSI ? 25 h / CSI ? 25 l).

Link copied to clipboard

Sets the default cursor shape/style restored on reset.

Link copied to clipboard
abstract fun setDynamicColor(target: Int, color: Int)

Updates a dynamic target color (foreground, background, or cursor color).

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

Enables or disables focus in/out reporting (CSI ? 1004 h / CSI ? 1004 l).

Link copied to clipboard
abstract fun setFormatOtherKeysMode(mode: Int)

Sets the format-other-keys wire format used when modify-other-keys applies.

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

Subscribes to text-area resize reports (DECSET/DECRST ?2048).

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

Enables or disables Insert Replace Mode (IRM, CSI 4 h / CSI 4 l).

Link copied to clipboard
abstract fun setKeyFormatOption(resource: Int, value: Int)

Selects format 0 (CSI 27) or 1 (CSI u) for one xterm resource. Resource 0 is independent storage, as in xterm; it does not override per-class formats.

Link copied to clipboard
abstract fun setKeyModifierOption(resource: Int, value: Int)

Sets one xterm modifier resource. Resource 0 retains the legacy-profile admission mask; the current PC profile always permits modifiers. Values are -1 (disable), 0..3 for ordinary keys, 0..15 for resource 0, and 0..4 for other key classes.

Link copied to clipboard
abstract fun setKittyKeyboardFlags(flags: Int)

Sets active Kitty keyboard progressive-enhancement flags.

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

Enables or disables left/right margin mode (DECLRMM, CSI ? 69 h / CSI ? 69 l).

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 setModifyOtherKeysMode(mode: Int)

Sets the modify-other-keys reporting level.

Link copied to clipboard

Sets the active mouse report encoding mode used by terminal-to-host reporting.

Link copied to clipboard

Sets the active mouse tracking mode used by terminal-to-host reporting.

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

Enables or disables New Line Mode (LNM, CSI 20 h / CSI 20 l).

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

Enables or disables Origin Mode (DECOM, CSI ? 6 h / CSI ? 6 l).

Link copied to clipboard
abstract fun setPaletteColor(index: Int, color: Int)

Updates an individual color index in the active 256-color palette.

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 setPopOnBell(enabled: Boolean)

Toggles pop on bell mode (?1043).

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

Toggles reverse-video presentation state (DECSCNM, CSI ? 5 h / CSI ? 5 l).

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

Enables reverse wrap across soft-wrapped rows (DEC private mode 45). Requires auto-wrap. Stops at hard line breaks and the top margin. Changing this mode preserves the cursor and pending wrap.

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

Enables extended reverse wrap (DEC private mode 1045). Requires auto-wrap and takes precedence over mode 45. Crosses hard line breaks and cycles from the top margin to the bottom margin. Changing this mode preserves the cursor and pending wrap.

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 setShiftMouseCaptureEnabled(enabled: Boolean)

Requests Shift as a mouse reporting modifier (XTSHIFTESCAPE). Disabled by default so Shift restores local interaction. Hosts may deny reporting. Preserves pending wrap and survives screen switches, resize, and DECSTR.

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

Toggles synchronized output mode (DECSET/DECRST ?2026).

Link copied to clipboard
abstract fun setTabStop()

Sets a tab stop at the current cursor column (HTS, ESC H).

Link copied to clipboard
abstract fun setThemePalette(palette: TerminalColorPalette)

Sets the theme-configured color palette for the terminal session.

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

Controls how East Asian Ambiguous codepoints are measured for future writes.

Link copied to clipboard
abstract fun setWindowMinimized(minimized: Boolean)

Updates the recorded window minimization state.

Link copied to clipboard
abstract fun setWindowSizePixels(width: Int, height: Int)

Updates the recorded text-area size in pixels, excluding host padding. A changed size emits a subscribed mode 2048 report when permitted. Use the pixel-aware TerminalBuffer.resize overload when both grid and pixel dimensions change so one report describes the completed resize. If either dimension is nonpositive, both are recorded as unknown zero.

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

Sets the xterm window title.

Link copied to clipboard
abstract fun softReset()

Performs a soft terminal reset (DECSTR, CSI ! p).

Link copied to clipboard
abstract fun updatePenColors(foreground: CellColor? = null, background: CellColor? = null, underlineColor: CellColor? = null, bold: Boolean? = null, faint: Boolean? = null, italic: Boolean? = null, underlineStyle: UnderlineStyle? = null, strikethrough: Boolean? = null, overline: Boolean? = null, blink: Boolean? = null, inverse: Boolean? = null, conceal: Boolean? = null)

Updates only the supplied SGR pen fields. A null field is unchanged; CellColor.DEFAULT explicitly selects the default color and false clears a flag. Hyperlink and selective-erase protection are preserved. With all fields null this is a no-op. Consumed synchronously; serialize with other terminal reads and writes. No cell is changed.

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

Updates the most recently written printable cell with a complete grapheme sequence.

Link copied to clipboard
open fun writeAscii(bytes: ByteArray, offset: Int, length: Int)

Writes length printable ASCII bytes starting at offset, using the active pen.

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.