ANSITerminal

class ANSITerminal(useStdErr: Boolean = false) : StateTerminal(source)

Terminal implementation that uses ANSI escape codes for colored output.

This terminal provides colored formatting using ANSI escape sequences:

  • Strong text: Orange color (ANSI 208)

  • Parameters: Cyan color (ANSI 36)

  • Errors: Red color (ANSI 31)

  • Plain text: Reset to default color

Parameters

useStdErr

Whether to output to standard error instead of standard output

Constructors

Link copied to clipboard
constructor(useStdErr: Boolean = false)

Properties

Link copied to clipboard
open val infoColumn: Int

Column position for aligning help text descriptions.

Link copied to clipboard
open val width: Int

The terminal width in characters for text wrapping. Defaults to system terminal width.

Functions

Link copied to clipboard
open fun closingError()

Called when closing error text formatting.

Link copied to clipboard
open fun closingParam()

Called when closing parameter/code text formatting.

Link copied to clipboard
open fun closingPlain()

Called when closing plain text formatting.

Link copied to clipboard
open fun closingStrong()

Called when closing strong/bold text formatting.

Link copied to clipboard
open override fun emitError(text: String)

Emits text formatted as an error message.

Link copied to clipboard
open fun emitNewLine()

Emits a platform-appropriate newline sequence.

Link copied to clipboard
open override fun emitParam(text: String)

Emits text formatted as a parameter (e.g., option names, values).

Link copied to clipboard
open override fun emitPlain(text: String)

Emits plain text without any formatting.

Link copied to clipboard
open override fun emitStrong(text: String)

Emits text with strong/bold formatting. Default implementation outputs as plain text.

Link copied to clipboard
open override fun endEmit()

Called after completing a sequence of text emissions. Override for cleanup operations.

Link copied to clipboard
open override fun openingError(previous: ContentStyle)

Outputs ANSI escape sequence for error text (red color).

Link copied to clipboard
open override fun openingParam(previous: ContentStyle)

Outputs ANSI escape sequence for parameter text (cyan color).

Link copied to clipboard
open override fun openingPlain(previous: ContentStyle)

Outputs ANSI reset sequence to return to plain text formatting.

Link copied to clipboard
open override fun openingStrong(previous: ContentStyle)

Outputs ANSI escape sequence for strong/bold text (orange color).

Link copied to clipboard
open override fun sendText(text: String)

Sends raw text to the output stream.

Link copied to clipboard
open override fun startEmit()

Called before starting a sequence of text emissions. Override for setup operations.