terminal 0.3.0
Colors, formatting and utilities for the terminal
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
Colors, formatting and utilities for the terminal.
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");
- Registered by Kripth
- 0.3.0 released 6 years ago
- Kripth/terminal
- MIT
- Authors:
- 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 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
1897 downloads total
-
- Score:
- 1.2
- Short URL:
- terminal.dub.pm