Terminal

interface Terminal(source)

The high-level interface for terminal interaction.

Provides methods for controlling the terminal state, managing the cursor, and handling input/output.

Inheritors

Functions

Link copied to clipboard
abstract fun clear()

Clears the entire terminal screen.

Link copied to clipboard
abstract fun clearLine()

Clears the current line.

Link copied to clipboard
abstract fun enterRawMode()

Enters terminal raw mode and initializes state.

Link copied to clipboard
abstract fun exitRawMode()

Exits raw mode and restores the terminal state.

Link copied to clipboard
abstract fun flush()

Flushes any pending output to the terminal.

Link copied to clipboard
abstract fun hideCursor()

Hides the terminal cursor.

Link copied to clipboard
abstract fun moveCursor(x: Int, y: Int)

Moves the cursor to the specified coordinates (0-indexed).

Link copied to clipboard
abstract fun poll(timeoutMs: Int): Boolean

Waits for input to become available.

Link copied to clipboard
abstract fun read(): Event?

Attempts to read the next input Event.

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

Sets the terminal window title.

Link copied to clipboard
abstract fun showCursor()

Shows the terminal cursor.

Link copied to clipboard
abstract fun size(): Size

Returns the current physical size of the terminal.

Link copied to clipboard
inline fun <T> Terminal.useRawMode(block: (Terminal) -> T): T

Safely enters raw mode, executes the block, and ensures raw mode is exited even if an exception occurs.

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

Writes raw text to the terminal.