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.

Properties

NameTypeDescription
cursorX[get] intThe current x position of the output cursor. 0 == leftmost column
cursorY[get] intThe current y position of the output cursor. 0 == topmost row
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
clear () Clears the screen.
color (foreground, background, force, reverseVideo) Changes the current color. See enum Color for the values.
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) gets a line, including user editing. Convenience method around the LineGetter class and RealTimeConsoleInput facilities - use them if you need more control. You really shouldn't call this if stdin isn't actually a user-interactive terminal! So if you expect people to pipe data to your app, check for that or use something else.
hideCursor () hides the cursor
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
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
underline (set, force)
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.

Aliases

NameDescription
writeString use write() or writePrintableString instead

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.