StateTerminal

abstract class StateTerminal : Terminal(source)

Base class for terminal implementations that maintain formatting state.

This abstract class provides a foundation for terminals that need to track the current formatting state and transition between different styles. It handles the logic of opening and closing formatting contexts.

Subclasses should override the opening/closing methods for each style and implement sendText for actual output.

Inheritors

Constructors

Link copied to clipboard
constructor()

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 fun openingError(previous: ContentStyle)

Called when transitioning to error text formatting.

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

Called when transitioning to parameter/code text formatting.

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

Called when transitioning to plain text formatting.

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

Called when transitioning to strong/bold text formatting.

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

Sends raw text to the output destination.

Link copied to clipboard
open override fun startEmit()

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