|
ASL
|
Helper class to control the text console, change output text color and cursor position.
In modern consoles, color can be set as RGB components:
If many different colors are to be printed in sequence, better performance is achieved by forming a string with all color-changing terminal codes followed by the text, and then printing this string.
_(This is still work in progress)_
#include <Console.h>
Public Types | |
| enum | Color |
Colors for text or background, there are normal and bright/bold versions (prefixed by a B): RED, GREEN, BLUE, WHITE, MAGENTA, CYAN, YELLOW, BLACK, BRIGHT, BRED, BGREEN, BBLUE, BWHITE, BMAGENTA, BCYAN, BYELLOW, BBLACK | |
Public Member Functions | |
| void | setCP (int cp=0, bool loc=false) |
| On Windows, sets the console output code page (if 0 given, uses the system code page, if -1 uses the default console page), and if loc is true sets the locale for string case management to the system locale. | |
| void | gotoxy (int x, int y) |
Sets the cursor position to coordinates x, y | |
| void | clear () |
| Clear the console. | |
| void | setColorMode (int mode) |
| Sets color mode: 1=256 colors (RGB 6x6x6), 2=true color (RGB 24bit) for RGB color setting functions (only for relatively modern consoles) | |
| void | color (Color color=DEFAULT) |
| Sets the current text output color, or if no argument is given, the color will be the default terminal text color. | |
| void | bgcolor (Color color=DEFAULT) |
| Sets the current output background color. | |
| void | color (int r, int g, int b) |
| Sets current text color as RGB (if supported) | |
| void | bgcolor (int r, int g, int b) |
| Sets current text color as RGB (if supported) | |
| String | bg () const |
| Returns the prefix code to set a background color. | |
| String | fg () const |
| Returns the prefix code to set a foreground color. | |
| String | rgb (int r, int g, int b) const |
| Returns terminal code to set an RGB color (or the closest if full RGB is not supported) | |
| void | inverse (bool on=true) |
| Reverses text and background colors. | |
| void | showCursor (bool on) |
| Shows or hides the cursor. | |
| void | reset () |
| Resets attributes to defaults. | |
| Size | size () |
| Returns the size of the console window in characters {width, height}. | |
On Windows, sets the console output code page (if 0 given, uses the system code page, if -1 uses the default console page), and if loc is true sets the locale for string case management to the system locale.
(this behavior might change in the future)