TerminalRecorder

A TerminalInterface that records all output and allows you to provide input.

Exmaple

val recorder = TerminalRecorder()
val t = Terminal(terminalInterface = recorder)
t.println("Hello, world!")
assertEquals(recorder.output(), "Hello, world!\n")

Constructors

Link copied to clipboard
constructor(ansiLevel: AnsiLevel = AnsiLevel.TRUECOLOR, width: Int = 79, height: Int = 24, hyperlinks: Boolean = ansiLevel != AnsiLevel.NONE, outputInteractive: Boolean = ansiLevel != AnsiLevel.NONE, inputInteractive: Boolean = ansiLevel != AnsiLevel.NONE, supportsAnsiCursor: Boolean = false)

Properties

Link copied to clipboard

Input events to return when reading in raw mode

Link copied to clipboard

Lines of input to return from readLineOrNull.

Functions

Link copied to clipboard

Clear stdout, stderr, and output

Link copied to clipboard
open override fun completePrintRequest(request: PrintRequest)

Display a PrintRequest on this terminal.

Link copied to clipboard
open override fun enterRawMode(mouseTracking: MouseTracking): AutoCloseable

Enter raw mode on the terminal, disabling line buffering and echoing to enable reading individual character.

Link copied to clipboard
open override fun getTerminalSize(): Size

Return the current size, in cells, of the terminal, or null if the size is unknown.

Link copied to clipboard
open override fun info(ansiLevel: AnsiLevel?, hyperlinks: Boolean?, outputInteractive: Boolean?, inputInteractive: Boolean?): TerminalInfo

Get information about the current terminal.

Link copied to clipboard
fun output(): String

The combined content of stdout and stderr

Link copied to clipboard
fun TerminalRecorder.outputAsHtml(includeBodyTag: Boolean = true, includeCodeTag: Boolean = true, backgroundColor: Color? = SRGB("#0c0c0c")): String

Render the contents of this TerminalRecorder as an HTML document.

Link copied to clipboard
open override fun readInputEvent(timeout: TimeMark, mouseTracking: MouseTracking): InputEvent?

Read a single input event from the terminal, or null if no event is available but this call should be retried immediately.

Link copied to clipboard
open override fun readLineOrNull(hideInput: Boolean): String?

Read a single line of input from stdin, returning null if no input is available

Link copied to clipboard

Return true if the getTerminalSize method should be called frequently to update the size.

Link copied to clipboard
fun stderr(): String

The content written to stderr

Link copied to clipboard
fun stdout(): String

The content written to stdout