AnsiTerminal

class AnsiTerminal(val colorMode: ColorMode = ColorMode.detect()) : Terminal(source)

An implementation of Terminal that uses ANSI escape sequences.

This implementation handles raw mode management, cursor control, screen clearing, and input parsing for standard terminal emulators.

Constructors

Link copied to clipboard
constructor(colorMode: ColorMode = ColorMode.detect())

Properties

Link copied to clipboard

The ColorMode to use for rendering.

Functions

Link copied to clipboard
open override fun clear()

Clears the entire terminal screen.

Link copied to clipboard
open override fun clearLine()

Clears the current line.

Link copied to clipboard
open override fun enterRawMode()

Enters terminal raw mode and initializes state.

Link copied to clipboard
open override fun exitRawMode()

Exits raw mode and restores the terminal state.

Link copied to clipboard
open override fun flush()

Flushes any pending output to the terminal.

Link copied to clipboard
open override fun hideCursor()

Hides the terminal cursor.

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

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

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

Waits for input to become available.

Link copied to clipboard
open override fun read(): Event?

Attempts to read the next input Event.

Link copied to clipboard
open override fun setTitle(title: String)

Sets the terminal window title.

Link copied to clipboard
open override fun showCursor()

Shows the terminal cursor.

Link copied to clipboard
open override 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
open override fun write(text: String)

Writes raw text to the terminal.