Struct Terminal

Encapsulates the I/O capabilities of a terminal.

struct Terminal;

Constructors

NameDescription
this ()
this (type, fdIn, fdOut, getSizeOverride) Constructs an instance of Terminal representing the capabilities of the current terminal.

Fields

NameTypeDescription
lineGetter LineGetterThe cached object used by [getline]. You can set it yourself if you like.

Properties

NameTypeDescription
cursorX[get] intThe current cached x and y positions of the output cursor. 0 == leftmost column for x and topmost row for y.
cursorY[get] intThe current cached x and y positions of the output cursor. 0 == leftmost column for x and topmost row for y.
height[get] intThe current height of the terminal (the number of rows)
width[get] intThe current width of the terminal (the number of columns)

Methods

NameDescription
bold (set, force) Sets or resets the terminal's text rendering options.
clear () Clears the screen.
clearToEndOfLine () Clears the current line from the cursor onwards.
color (foreground, background, force, reverseVideo) Changes the current color. See enum [Color] for the values and note colors can be [arsd.docs.general_concepts#bitmasks|bitwise-or] combined with [Bright].
cursor (what, force) Changes the current cursor.
enableAlternateScreen (active) It is not valid to call this if you constructed with minimalProcessing.
flush () Flushes your updates to the terminal. It is important to call this when you are finished writing for now if you are using the version=with_eventloop
getline (prompt, echoChar, prefilledData) Gets a line, including user editing. Convenience method around the [LineGetter] class and [RealTimeConsoleInput] facilities - use them if you need more control.
hideCursor () hides the cursor
hyperlink (text, identifier, autoStyle) Outputs a hyperlink to my custom terminal (v0.0.7 or later) or to version TerminalDirectToEmulator. The way it works is a bit strange...
hyperlinkSupported () Returns true if the terminal advertised compatibility with the [hyperlink] function's implementation.
italic (set, force) Sets or resets the terminal's text rendering options.
moveTo (x, y, force) Moves the output cursor to the given position. (0, 0) is the upper left corner of the screen. The force parameter can be used to force an update, even if Terminal doesn't think it is necessary
reset () Returns the terminal to normal output colors
restoreCursorPosition () Saves/restores cursor position to a stack.
saveCursorPosition () Saves/restores cursor position to a stack.
setTitle (t) Changes the terminal's title
setTrueColor (foreground, background, force) Attempts to set color according to a 24 bit value (r, g, b, each >= 0 and < 256).
showCursor () shows the cursor
stdinIsTerminal ()
stdoutIsTerminal () Terminal is only valid to use on an actual console device or terminal handle. You should not attempt to construct a Terminal instance if this returns false. Real time input is similarly impossible if !stdinIsTerminal.
underline (set, force) Sets or resets the terminal's text rendering options.
updateCursorPosition () Forces [cursorX] and [cursorY] to resync from the terminal.
write (t) Writes to the terminal at the current cursor position.
writef (f, t) Writes to the terminal at the current cursor position.
writefln (f, t) Writes to the terminal at the current cursor position.
writeln (t) Writes to the terminal at the current cursor position.

Warning

do not write out escape sequences to the terminal. This won't work on Windows and will confuse Terminal's internal state on Posix.