Terminal

Encapsulates the I/O capabilities of a terminal.

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.

Disabled Default Constructor

A disabled default is present on this object. To use it, use one of the other constructors or a factory function.

Constructors

this
this(ConsoleOutputType type, int fdIn = 0, int fdOut = 1, int[] delegate() getSizeOverride = null)
this(ConsoleOutputType type)

Constructs an instance of Terminal representing the capabilities of the current terminal.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Postblit

Copying this object is disabled.

A postblit is present on this object, but not explicitly documented in the source.

Members

Functions

clear
void clear()

Clears the screen.

color
void color(int foreground, int background, ForceOption force = ForceOption.automatic, bool reverseVideo = false)

Changes the current color. See enum Color for the values.

flush
void 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
string getline(string prompt = null)

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
void hideCursor()

hides the cursor

moveTo
void moveTo(int x, int y, ForceOption force = ForceOption.automatic)

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
void reset()

Returns the terminal to normal output colors

setTitle
void setTitle(string t)

Changes the terminal's title

setTrueColor
bool setTrueColor(RGB foreground, RGB background, ForceOption force = ForceOption.automatic)

Attempts to set color according to a 24 bit value (r, g, b, each >= 0 and < 256).

showCursor
void showCursor()

shows the cursor

underline
void underline(bool set, ForceOption force = ForceOption.automatic)

Note: the Windows console does not support underlining

write
void write(T t)

Writes to the terminal at the current cursor position.

writef
void writef(string f, T t)
writefln
void writefln(string f, T t)
writeln
void writeln(T t)

Writes to the terminal at the current cursor position.

Properties

cursorX
int cursorX [@property getter]

The current x position of the output cursor. 0 == leftmost column

cursorY
int cursorY [@property getter]

The current y position of the output cursor. 0 == topmost row

height
int height [@property getter]

The current height of the terminal (the number of rows)

width
int width [@property getter]

The current width of the terminal (the number of columns)

Meta