terminal 1.0.0

Colors, formatting and utilities for the terminal


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Colors, formatting and utilities for the terminal.

DUB Package Build Status

Usage

The module terminal contains everything needed to use the library.

The class Terminal uses a File (stdout by default) to perform the actions.

Title

The console's title can be obtained using the title property (Windows only) and set using the same property.

auto terminal = new Terminal();
terminal.title = "My Terminal";
version(Windows) assert(terminal.title == "My Terminal");

Size

The terminal's size (width and height) can be obtained through the size property.

auto terminal = new Terminal();
auto size = terminal.size;
assert(size.columns == terminal.width);
assert(size.rows == terminal.height);

Colors and formatting

Colors and formatting can be changed using direct properties or directly in the Terminal's write and writeln functions.

terminal.background = Color.black;
terminal.foreground = Color.white;
terminal.italic = true;
terminal.writeln("White on black!");
terminal.reset();

The color can be changed directly using the background and foreground properties, setting them to a value from the Color enum or an array of 3 bytes (24-bit color). The Color.reset value resets the background or the foreground to its original value.

Available colors:

  • black
  • red
  • green
  • blue
  • yellow
  • magenta
  • cyan
  • lightGray
  • gray
  • brightRed
  • brightGreen
  • brightBlue
  • brightYellow
  • brightMagenta
  • brightCyan
  • white

Available formatting (support may vary between various terminals):

  • bold
  • italic
  • strikethrough
  • underlined
  • overlined
  • inversed
terminal.writelnr(Background(Color.black), Foreground(Color.white), Underlined.yes, "Underlined white on black!");
terminal.writelnr(Bold.yes, Foreground(255, 0, 0), "Bold red using 16m colors! ", Bold.no, "Just red.");
terminal.writelnr(Foreground(Color.green), "green text, ", reset, "default text");
Authors:
  • Kripth
Dependencies:
none
Versions:
1.0.0 2018-Mar-13
0.3.0 2018-Mar-03
0.2.1 2018-Feb-16
0.2.0 2018-Feb-16
0.1.0 2018-Feb-12
Show all 6 versions
Download Stats:
  • 4 downloads today

  • 22 downloads this week

  • 77 downloads this month

  • 1675 downloads total

Score:
1.4
Short URL:
terminal.dub.pm