KetraTerm
API · DevelopmentAll versions

TerminalModeController

Mode-control contract for the terminal buffer.

These toggles affect how subsequent cursor motion and printable writes behave. They do not expose the underlying storage model to the parser.

Inheritors

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

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

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