|
typedef uint8_t | underline |
| Defines the type underlined as unsigned integer 1 byte large.
|
typedef uint8_t | ansiStandardColors |
| Defines the type ansiStandardColors as unsigned integer 1 byte large.
|
typedef struct rgb | rgb |
| Defines a basic structure for RGB colors.
|
typedef struct ansiStandardColor | ansiStandardColor |
| Defines a basic structure for standard ANSI foreground color and background color for a piece of printable text.
|
typedef struct ansiRgbColor | ansiRgbColor |
| Defines a basic structure for RGB foreground color and background color for a piece of printable text.
|
typedef union __color | __color |
| Defines a union between RGB colors and standard ANSI colors (should not be used externally)
|
typedef struct color | color |
| Defines a struct for representing a generic color.
|
typedef struct graphicRendition | graphicRendition |
| Defines a struct for graphic rendition including properties for bold, italic, underlined and colored text.
|
|
rgb | buildRgb () |
| Builds a rgb struct.
|
ansiRgbColor | buildAnsiRgbColor () |
| Builds a ANSI rgb color struct.
|
ansiStandardColor | buildAnsiStandardColor () |
| Builds a ANSI standard color struct.
|
color | buildColor () |
| Builds a color struct.
|
graphicRendition | buildGraphicRendition () |
| Builds a graphic rendition struct.
|
void | clearScreen () |
| Clears the entire terminal's window's content.
|
void | setForegroundColor (color color) |
| Sets the terminal's foreground color.
|
void | setBackgroundColor (color color) |
| Sets the terminal's background color.
|
void | setColor (color color) |
| Sets both terminal's foreground color and background color, if specified.
|
void | printGraphicRendition (char *text, graphicRendition rendition) |
| Prints a text with the graphic rendition specified with the struct. Standard C format specifiers are not handled.
|
void | printgr (const char *text) |
| Prints a text with the graphic rendition specified with custom graphic rendition format specifiers.
|
void | printfgr (char *text,...) |
| Prints text as printgr but handles standard C format specifiers %, d, i, u, x, X, f, F, s, n. Integers are always interpreted in base 10.
|
char | getChar () |
| Gets the char pressed on the keyboard without waiting for 'Enter' to be pressed.
|
void | Pause (bool clear) |
| Waits for the user to press a key without waiting for 'Enter' to be pressed.
|
void | screenSize (int *width, int *height) |
| It returns the width and the height of the screen. On unix-like platforms, in case of errors, it sets them to -1.
|
void | cursorUp (int n) |
| Moves the cursor up by n rows.
|
void | cursorDown (int n) |
| Moves the cursor down by n rows.
|
void | cursorForward (int n) |
| Moves the cursor to the right by n columns.
|
void | cursorBack (int n) |
| Moves the cursor to the left by n columns.
|
void | cursorNextLine (int n) |
| Moves the cursor at the beginning of the line n rows down.
|
void | cursorPreviousLine (int n) |
| Moves the cursor at the beginning of the line n rows up.
|
void | cursorHorizontalAbsolute (int n) |
| Moves the cursor to column n.
|
void | cursorPosition (int n, int m) |
| Moves the cursor at n-th row and at the m-th column.
|
void | eraseInDisplay (int n) |
| Clears part of the screen.
|
void | eraseInLine (int n) |
| Erases part of the line.
|
void | scrollUp (int n) |
| Scrolls the whole page up by n rows.
|
void | scrollDown (int n) |
| Scrolls the whole page down by n rows.
|
void | deviceStatusReport (int *row, int *col) |
| Gets the cursor position.
|
void | graphicReset () |
| Resets the graphic rendition.
|
void | bold () |
| Toggles bold text.
|
void | italic () |
| Toggles italic text.
|
void | underlined () |
| Toggles singled underlined text.
|
void | slowBlinking () |
| Toggles slow blinking.
|
void | doublyUnderlined () |
| Toggles doubly underlined text.
|
void | setStandardForegroundColor (ansiStandardColors foregroundColor) |
| Sets the ANSI standard foreground color.
|
void | setRGBForegroundColor (rgb rgbColor) |
| Sets the RGB foreground color.
|
void | defaultForegroundColor () |
| Resets the foreground color.
|
void | setStandardBackgroundColor (ansiStandardColors backgroundColor) |
| Sets the ANSI standard background color.
|
void | setRGBBackgroundColor (rgb rgbColor) |
| Sets the RGB background color.
|
void | defaultBackgroundColor () |
| Resets the background color.
|
Implemented following https://en.wikipedia.org/wiki/ANSI_escape_code.
Function's names are as much as possible consistent with the quoted document.
NOTICE: not every function declared in this header is part of ANSI standard.
NOTICE: for these structures are available some builder functions that you should use if you want to build structures with default set properties.
Definition in file ansi.h.
void printfgr |
( |
char * | text, |
|
|
| ... ) |
Prints text as printgr but handles standard C format specifiers %, d, i, u, x, X, f, F, s, n. Integers are always interpreted in base 10.
- Parameters
-
text | The text with custom graphic rendition format specifiers and standard C format specifiers. |
Values | Values to be concatenated. |
Definition at line 222 of file ansi.c.
void printgr |
( |
const char * | text | ) |
|
Prints a text with the graphic rendition specified with custom graphic rendition format specifiers.
Custom graphic rendition format specifiers: #b# for bold text, #i# for italic text, #u# for underlined text, #du# for doubly underlined text, #n# for setting ANSI standard color represented by n, #bl# for slow blinking, #r# for graphic reset.
For setting RGB colors use #fg;r;g;b# or #bg;r;g;b# where fg or bg represents if the color has to be applied to the foreground or to the background and r, g, b are the values for r, g, b components of the color representation and must be between 0 and 255;
If the passed format does not comply with this specification, then the passed format text is going to be printed except for the #s.
If printing # is needed, use ##.
Standard C formats specifiers are not handled.
- Parameters
-
text | The text with custom graphic rendition format specifiers to be printed. |
Definition at line 127 of file ansi.c.