Inspired by Simon Ford's "Terminal" library, this is a clean-room reimplementation that supports a larger set of the ANSI escape sequences and includes a few handy drawing routines. Useful for making console UIs for your projects. The box-drawing stuff requires your terminal to be set to codepage 850.

Fork of ANSITerm by Dan Summers

Committer:
dansummers
Date:
Tue Sep 18 18:58:19 2012 +0000
Revision:
0:863811463610
Child:
1:e3403c93f864
ANSITerm first release: supports colour and styling, cursor movement, box drawing with Codepage850 box-drawing characters.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dansummers 0:863811463610 1 /**
dansummers 0:863811463610 2 * @file ANSITerm.h
dansummers 0:863811463610 3 * @author Dan Summers [ https://mbed.org/users/dansummers ]
dansummers 0:863811463610 4 * @date 20120918
dansummers 0:863811463610 5 */
dansummers 0:863811463610 6 /*
dansummers 0:863811463610 7 Copyright (c) 2012 dansummers
dansummers 0:863811463610 8
dansummers 0:863811463610 9 Permission is hereby granted, free of charge, to any person obtaining a copy of
dansummers 0:863811463610 10 this software and associated documentation files (the "Software"), to deal in
dansummers 0:863811463610 11 the Software without restriction, including without limitation the rights to
dansummers 0:863811463610 12 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
dansummers 0:863811463610 13 of the Software, and to permit persons to whom the Software is furnished to do
dansummers 0:863811463610 14 so, subject to the following conditions:
dansummers 0:863811463610 15
dansummers 0:863811463610 16 The above copyright notice and this permission notice shall be included in all
dansummers 0:863811463610 17 copies or substantial portions of the Software.
dansummers 0:863811463610 18
dansummers 0:863811463610 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dansummers 0:863811463610 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dansummers 0:863811463610 21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
dansummers 0:863811463610 22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dansummers 0:863811463610 23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
dansummers 0:863811463610 24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
dansummers 0:863811463610 25 SOFTWARE.
dansummers 0:863811463610 26 */
dansummers 0:863811463610 27
dansummers 0:863811463610 28 #ifndef _ANSITERM_
dansummers 0:863811463610 29 #define _ANSITERM_
dansummers 0:863811463610 30
dansummers 0:863811463610 31 #define _ANSITERM_CP850_ /* Use CodePage 850 for box-drawing. */
dansummers 0:863811463610 32
dansummers 0:863811463610 33 #include "mbed.h"
dansummers 0:863811463610 34
dansummers 0:863811463610 35 /** ANSI Terminal control library, inheriting from Serial.
dansummers 0:863811463610 36 *
dansummers 0:863811463610 37 * ANSITerm encapsulates a large portion of the ANSI escape sequence set,
dansummers 0:863811463610 38 * so that a user unfamiliar with the escape sequences can manipulate the
dansummers 0:863811463610 39 * terminal. It also provides a tidy point of abstraction, should it be
dansummers 0:863811463610 40 * necessary to support multiple different escape sets in the future.
dansummers 0:863811463610 41 *
dansummers 0:863811463610 42 * ANSITerm assumes that the terminal being manipulated implements the
dansummers 0:863811463610 43 * ANSI-standard escapes. The terminal is divided into cells, each one
dansummers 0:863811463610 44 * the size of a character (a typical "default" terminal will have 25 rows of
dansummers 0:863811463610 45 * cells, each with 80 character cells in it, but this will change if the
dansummers 0:863811463610 46 * terminal is resized.)
dansummers 0:863811463610 47 *
dansummers 0:863811463610 48 * The box-drawing functions currently assume that the terminal is using
dansummers 0:863811463610 49 * CodePage 850 to interpret received characters. It is untested under
dansummers 0:863811463610 50 * UNIX and MacOS (fixing this is on the TODO list).
dansummers 0:863811463610 51 *
dansummers 0:863811463610 52 * Example:
dansummers 0:863811463610 53 * @code
dansummers 0:863811463610 54 * terminal.clear_screen();
dansummers 0:863811463610 55 * terminal.hide_cursor();
dansummers 0:863811463610 56 * terminal.set_display_style(ANSITerm::SGR_NONE);
dansummers 0:863811463610 57 * terminal.set_text_colour(ANSITerm::SGR_RED);
dansummers 0:863811463610 58 * terminal.draw_box(3,3,19,5,ANSITerm::simple,false);
dansummers 0:863811463610 59 * terminal.set_text_colour(ANSITerm::SGR_WHITE);
dansummers 0:863811463610 60 * terminal.set_display_style(ANSITerm::SGR_BOLD);
dansummers 0:863811463610 61 * terminal.set_cursor_position(5,4);
dansummers 0:863811463610 62 * terminal.printf("ANSI Terminal");
dansummers 0:863811463610 63 * @endcode
dansummers 0:863811463610 64 */
dansummers 0:863811463610 65 class ANSITerm : public Serial
dansummers 0:863811463610 66 {
dansummers 0:863811463610 67 public:
dansummers 0:863811463610 68 /* Internal buffer for the SGR style flagset currently in use. */
dansummers 0:863811463610 69 char current_style;
dansummers 0:863811463610 70
dansummers 0:863811463610 71 /** SGR "flag" indicating the default text style. */
dansummers 0:863811463610 72 const static char SGR_NONE = 0;
dansummers 0:863811463610 73
dansummers 0:863811463610 74 /** SGR flag to request bold text. */
dansummers 0:863811463610 75 const static char SGR_BOLD = 1;
dansummers 0:863811463610 76
dansummers 0:863811463610 77 /** SGR flag to request faint text. */
dansummers 0:863811463610 78 const static char SGR_FAINT = 2;
dansummers 0:863811463610 79
dansummers 0:863811463610 80 /** SGR flag to request italic text. */
dansummers 0:863811463610 81 const static char SGR_ITALIC = 4;
dansummers 0:863811463610 82
dansummers 0:863811463610 83 /** SGR flag to request underlined text. */
dansummers 0:863811463610 84 const static char SGR_UNDERLINE = 8;
dansummers 0:863811463610 85
dansummers 0:863811463610 86 /** SGR flag to request slow-blinking text (not always supported). */
dansummers 0:863811463610 87 const static char SGR_BLINK_SLOW = 16;
dansummers 0:863811463610 88
dansummers 0:863811463610 89 /** SGR flag to request fast-flashing text (not always supported). */
dansummers 0:863811463610 90 const static char SGR_BLINK_RAPID = 32;
dansummers 0:863811463610 91
dansummers 0:863811463610 92 /** SGR flag to request inverse-video. */
dansummers 0:863811463610 93 const static char SGR_IMAGE_NEGATIVE = 64; /* Switch on inverse video */
dansummers 0:863811463610 94
dansummers 0:863811463610 95 /** SGR flag to request struck-through text (not commonly supported).*/
dansummers 0:863811463610 96 const static char SGR_CROSSED_OUT = 128;
dansummers 0:863811463610 97
dansummers 0:863811463610 98 /* SGR colours */
dansummers 0:863811463610 99 /** SGR colour indicator for ANSI Black.*/
dansummers 0:863811463610 100 const static char SGR_BLACK = 1; //30
dansummers 0:863811463610 101
dansummers 0:863811463610 102 /** SGR colour indicator for ANSI Red.*/
dansummers 0:863811463610 103 const static char SGR_RED = 2; //31
dansummers 0:863811463610 104
dansummers 0:863811463610 105 /** SGR colour indicator for ANSI Green.*/
dansummers 0:863811463610 106 const static char SGR_GREEN = 4; //32
dansummers 0:863811463610 107
dansummers 0:863811463610 108 /** SGR colour indicator for ANSI Yellow.*/
dansummers 0:863811463610 109 const static char SGR_YELLOW = 8; //33
dansummers 0:863811463610 110
dansummers 0:863811463610 111 /** SGR colour indicator for ANSI Blue.*/
dansummers 0:863811463610 112 const static char SGR_BLUE = 16; //34
dansummers 0:863811463610 113
dansummers 0:863811463610 114 /** SGR colour indicator for ANSI Magenta.*/
dansummers 0:863811463610 115 const static char SGR_MAGENTA = 32; //35
dansummers 0:863811463610 116
dansummers 0:863811463610 117 /** SGR colour indicator for ANSI Cyan.*/
dansummers 0:863811463610 118 const static char SGR_CYAN = 64; //36
dansummers 0:863811463610 119
dansummers 0:863811463610 120 /** SGR colour indicator for ANSI White.*/
dansummers 0:863811463610 121 const static char SGR_WHITE = 128; //37
dansummers 0:863811463610 122
dansummers 0:863811463610 123 /* Box styles */
dansummers 0:863811463610 124 #ifdef _ANSITERM_CP850_
dansummers 0:863811463610 125 /** Box-drawing style using ASCII two-line box-drawing characters. */
dansummers 0:863811463610 126 static const char two_lines[11];
dansummers 0:863811463610 127
dansummers 0:863811463610 128 /** Box-drawing style using ASCII one-line box-drawing characters. */
dansummers 0:863811463610 129 static const char one_line[11];
dansummers 0:863811463610 130
dansummers 0:863811463610 131 /** Box-drawing style using pluses, minuses and pipes (low-ASCII, should work anywhere).*/
dansummers 0:863811463610 132 static const char simple[11];
dansummers 0:863811463610 133 #endif
dansummers 0:863811463610 134
dansummers 0:863811463610 135 ANSITerm(PinName tx, PinName rx);
dansummers 0:863811463610 136
dansummers 0:863811463610 137 /* Emit a Control Sequence Initiator (which is the header for an ANSI escape sequence). */
dansummers 0:863811463610 138 inline void ansi_csi() { this->putc(0x1B); this->putc('['); }
dansummers 0:863811463610 139 /* Cursor Up by n rows. */
dansummers 0:863811463610 140 inline void ansi_cuu(int n) { this->printf("%dA", n); }
dansummers 0:863811463610 141 /* Cursor Down by n rows. */
dansummers 0:863811463610 142 inline void ansi_cud(int n) { this->printf("%dB", n); }
dansummers 0:863811463610 143 /* Cursor Forward by n columns. */
dansummers 0:863811463610 144 inline void ansi_cuf(int n) { this->printf("%dC", n); }
dansummers 0:863811463610 145 /* Cursor Back by n columns. */
dansummers 0:863811463610 146 inline void ansi_cub(int n) { this->printf("%dD", n); }
dansummers 0:863811463610 147 /* Cursor Next Line (moves the cursor to the start of the line n lines down). */
dansummers 0:863811463610 148 inline void ansi_cnl(int n) { this->printf("%dE", n); }
dansummers 0:863811463610 149 /* Cursor Previous Line (moves the cursor to the start of the line n lines up). */
dansummers 0:863811463610 150 inline void ansi_cpl(int n) { this->printf("%dF", n); }
dansummers 0:863811463610 151 /* Cursor Horizontal Absolute (moves the cursor to column n). */
dansummers 0:863811463610 152 inline void ansi_cha(int n) { this->printf("%dG", n); }
dansummers 0:863811463610 153 /* Cursor Position (positions the cursor at column x, row y, on a 1-based grid starting top-left). */
dansummers 0:863811463610 154 inline void ansi_cup(int x, int y) { this->printf("%d;%dH", y, x); }
dansummers 0:863811463610 155 /* Erase Data (0 = from cursor to end of screen, 1 = from cursor to beginning of screen, 2 = entire screen) */
dansummers 0:863811463610 156 inline void ansi_ed(int n) { this->printf("%dJ", n); }
dansummers 0:863811463610 157 /* Erase in Line (0 = from cursor to end of screen, 1 = from cursor to beginning of screen, 2 = entire screen) */
dansummers 0:863811463610 158 inline void ansi_el(int n) { this->printf("%dK", n); }
dansummers 0:863811463610 159 /* Scroll Up by n lines. */
dansummers 0:863811463610 160 inline void ansi_su(int n) { this->printf("%dS", n); }
dansummers 0:863811463610 161 /* Scroll Down by n lines. */
dansummers 0:863811463610 162 inline void ansi_sd(int n) { this->printf("%dT", n); }
dansummers 0:863811463610 163 /* Horizontal and Vertical Position (positions the cursor at column x, row y, on a 1-based grid starting top-left). */
dansummers 0:863811463610 164 inline void ansi_hvp(int y, int x) { this->printf("%d;%dH", y, x); }
dansummers 0:863811463610 165 /* Save Cursor Position */
dansummers 0:863811463610 166 inline void ansi_scp() { this->putc('s'); }
dansummers 0:863811463610 167 /* Restore Cursor Position */
dansummers 0:863811463610 168 inline void ansi_rcp() { this->putc('u'); }
dansummers 0:863811463610 169 /*DEC Terminal Cursor Enable Mode - hide cursor */
dansummers 0:863811463610 170 inline void ansi_dectcem_hide() { this->printf("?25l"); }
dansummers 0:863811463610 171 /*DEC Terminal Cursor Enable Mode - show cursor */
dansummers 0:863811463610 172 inline void ansi_dectcem_show() { this->printf("?25h"); }
dansummers 0:863811463610 173
dansummers 0:863811463610 174 /* Select Graphic Rendition - Make the output bold, underlined, coloured... all manner of things.*/
dansummers 0:863811463610 175 /*
dansummers 0:863811463610 176 reset = 1 to reset to defaults. 0 to read and apply the rest of the inputs.
dansummers 0:863811463610 177 text_style is an OR of SGR_{BOLD,FAINT,ITALIC,UNDERLINE,BLINK_SLOW,BLINK_RAPID,IMAGE_NEGATIVE,CROSSED_OUT}
dansummers 0:863811463610 178 text_colour is one of SGR_{BLACK,RED,GREEN,YELLOW,BLUE,MAGENTA,CYAN,WHITE}
dansummers 0:863811463610 179 background_colour is one of SGR_{BLACK,RED,GREEN,YELLOW,BLUE,MAGENTA,CYAN,WHITE}
dansummers 0:863811463610 180 */
dansummers 0:863811463610 181 void ansi_sgr(bool reset, char text_style, char text_colour, char background_colour);
dansummers 0:863811463610 182
dansummers 0:863811463610 183 /* Device Status Report (Returns CSIn;mR, where n,m is the coordinates of the cursor). */
dansummers 0:863811463610 184 void ansi_dsr(int* x_coord, int* y_coord);
dansummers 0:863811463610 185
dansummers 0:863811463610 186 /** Position the cursor at the requested coordinates, relative to the terminal frame.
dansummers 0:863811463610 187 * Coordinates are calculated from the top left of the frame, using character
dansummers 0:863811463610 188 * cells as the unit, and start at an origin of (1,1).
dansummers 0:863811463610 189 * @param x_coord the x-coordinate (column number) in which to place the cursor, starting at 1.
dansummers 0:863811463610 190 * @param y_coord the y coordinate (row number) in which to place the cursor, starting at 1.
dansummers 0:863811463610 191 */
dansummers 0:863811463610 192 inline void set_cursor_position(int x_coord, int y_coord)
dansummers 0:863811463610 193 {
dansummers 0:863811463610 194 this->ansi_csi();
dansummers 0:863811463610 195 this->ansi_cup(x_coord, y_coord);
dansummers 0:863811463610 196 }
dansummers 0:863811463610 197
dansummers 0:863811463610 198 /** Get the current position of the cursor, relative to the terminal frame.
dansummers 0:863811463610 199 * Coordinates are calculated from the top left of the frame, using character
dansummers 0:863811463610 200 * cells as the unit, and start at an origin of (1,1).
dansummers 0:863811463610 201 * @param x_coord A pointer into which the current x-coordinate of the cursor should be written.
dansummers 0:863811463610 202 * @param y_coord A pointer into which the current y-coordinate of the cursor should be written.
dansummers 0:863811463610 203 */
dansummers 0:863811463610 204 inline void get_cursor_position(int* x_coord, int* y_coord)
dansummers 0:863811463610 205 {
dansummers 0:863811463610 206 this->ansi_csi();
dansummers 0:863811463610 207 this->ansi_dsr(x_coord, y_coord);
dansummers 0:863811463610 208 }
dansummers 0:863811463610 209
dansummers 0:863811463610 210 /** Blank all cells on the screen.
dansummers 0:863811463610 211 */
dansummers 0:863811463610 212 inline void clear_screen()
dansummers 0:863811463610 213 {
dansummers 0:863811463610 214 this->ansi_csi();
dansummers 0:863811463610 215 this->ansi_ed(2);
dansummers 0:863811463610 216 }
dansummers 0:863811463610 217
dansummers 0:863811463610 218 /** Draw a box with these top-left and bottom-right points. Various styling options exist.
dansummers 0:863811463610 219 * @param x1 The x-coordinate of the top-left point.
dansummers 0:863811463610 220 * @param y1 The y-coordinate of the top-left point.
dansummers 0:863811463610 221 * @param x2 The x-coordinate of the bottom-right point.
dansummers 0:863811463610 222 * @param style The style of box-drawing to use (an 11-cell array of glyphs to use: three sets are defined above).
dansummers 0:863811463610 223 * The styles are stored as arrays of eleven glyphs, with the following descriptive names:
dansummers 0:863811463610 224 * [0]top-left corner, [1]top-right corner, [2]bottom-left corner, [3]bottom-right corner,
dansummers 0:863811463610 225 * [4]horizontal bar, [5]vertical bar,
dansummers 0:863811463610 226 * [6]upward-pointing tee, [7]downward-pointing tee, [8]left-pointing tee, [9]right-pointing tee,
dansummers 0:863811463610 227 * [10]cross
dansummers 0:863811463610 228 * @param clear_inner If true, the space contained within the box will be overwritten with space characters. If not, it will be unmodified.
dansummers 0:863811463610 229 */
dansummers 0:863811463610 230 void draw_box(int x1, int y1, int x2, int y2, const char* style, bool clear_inner);
dansummers 0:863811463610 231
dansummers 0:863811463610 232 /** Draw a box containing these top-left and bottom-right points. Various styling options exist.
dansummers 0:863811463610 233 * @param x1 The x-coordinate of the top-left point.
dansummers 0:863811463610 234 * @param y1 The y-coordinate of the top-left point.
dansummers 0:863811463610 235 * @param x2 The x-coordinate of the bottom-right point.
dansummers 0:863811463610 236 * @param style The style of box-drawing to use (an 11-cell array of glyphs to use: three sets are defined above).
dansummers 0:863811463610 237 * The styles are stored as arrays of eleven glyphs, with the following descriptive names:
dansummers 0:863811463610 238 * [0]top-left corner, [1]top-right corner, [2]bottom-left corner, [3]bottom-right corner,
dansummers 0:863811463610 239 * [4]horizontal bar, [5]vertical bar,
dansummers 0:863811463610 240 * [6]upward-pointing tee, [7]downward-pointing tee, [8]left-pointing tee, [9]right-pointing tee,
dansummers 0:863811463610 241 * [10]cross
dansummers 0:863811463610 242 * @param clear_inner If true, the space contained within the box will be overwritten with space characters. If not, it will be unmodified.
dansummers 0:863811463610 243 *
dansummers 0:863811463610 244 * draw_enclosing_box differs from draw_box because it draws around a space
dansummers 0:863811463610 245 * rather than inscribing it. If draw_box and draw_enclosing_box are given
dansummers 0:863811463610 246 * the same parameters, they will draw concentric boxes and the box from
dansummers 0:863811463610 247 * draw_box will be two cells smaller in both dimensions.
dansummers 0:863811463610 248 */
dansummers 0:863811463610 249 inline void draw_enclosing_box(int x1, int y1, int x2, int y2, const char* style, bool clear_inner)
dansummers 0:863811463610 250 {
dansummers 0:863811463610 251 draw_box((x1-1), (y1-1), (x2+1), (y2+1), style, clear_inner);
dansummers 0:863811463610 252 }
dansummers 0:863811463610 253
dansummers 0:863811463610 254 /** Set the SGR display style for subsequent characters.
dansummers 0:863811463610 255 * @param style A flagset ORred together from the SGR parameters above.
dansummers 0:863811463610 256 * Flags that are set in the flagset will be turned on,
dansummers 0:863811463610 257 * flags that are clear will be turned off.
dansummers 0:863811463610 258 *
dansummers 0:863811463610 259 * Example:
dansummers 0:863811463610 260 * @code
dansummers 0:863811463610 261 * terminal.printf("Some text.");
dansummers 0:863811463610 262 * terminal.set_display_style(SGR_BOLD|SGR_UNDERLINE);
dansummers 0:863811463610 263 * terminal.printf("Some very important text!");
dansummers 0:863811463610 264 * terminal.set_display_style(SGR_NONE);
dansummers 0:863811463610 265 * terminal.printf("Some more normal text.");
dansummers 0:863811463610 266 * @endcode
dansummers 0:863811463610 267 */
dansummers 0:863811463610 268 inline void set_display_style(char style)
dansummers 0:863811463610 269 {
dansummers 0:863811463610 270 this->current_style = style;
dansummers 0:863811463610 271 this->ansi_csi();
dansummers 0:863811463610 272 this->ansi_sgr(false, style, 0, 0);
dansummers 0:863811463610 273 }
dansummers 0:863811463610 274
dansummers 0:863811463610 275 /** Set the colour of subsequent characters.
dansummers 0:863811463610 276 * @param sgr_colour One of the SGR Colours defined above (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White).
dansummers 0:863811463610 277 *
dansummers 0:863811463610 278 * Example:
dansummers 0:863811463610 279 * @code
dansummers 0:863811463610 280 * terminal.printf("Some text in the default terminal colour.");
dansummers 0:863811463610 281 * terminal.set_display_text_colour(SGR_RED);
dansummers 0:863811463610 282 * terminal.printf("Some text in red.);
dansummers 0:863811463610 283 * @endcode
dansummers 0:863811463610 284 */
dansummers 0:863811463610 285 inline void set_text_colour(char sgr_colour)
dansummers 0:863811463610 286 {
dansummers 0:863811463610 287 this->ansi_csi();
dansummers 0:863811463610 288 this->ansi_sgr(false, this->current_style, sgr_colour, 0);
dansummers 0:863811463610 289 }
dansummers 0:863811463610 290
dansummers 0:863811463610 291 /** Set the background colour for subsequent characters.
dansummers 0:863811463610 292 * @param sgr_colour One of the SGR Colours defined above (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White).
dansummers 0:863811463610 293 *
dansummers 0:863811463610 294 * Example:
dansummers 0:863811463610 295 * @code
dansummers 0:863811463610 296 * terminal.printf("Some text in the default terminal colour.");
dansummers 0:863811463610 297 * terminal.set_display_background_colour(SGR_RED);
dansummers 0:863811463610 298 * terminal.printf("Some text on a red background.);
dansummers 0:863811463610 299 * @endcode
dansummers 0:863811463610 300 */
dansummers 0:863811463610 301 inline void set_background_colour(char sgr_colour)
dansummers 0:863811463610 302 {
dansummers 0:863811463610 303 this->ansi_csi();
dansummers 0:863811463610 304 this->ansi_sgr(false, this->current_style, 0, sgr_colour);
dansummers 0:863811463610 305 }
dansummers 0:863811463610 306
dansummers 0:863811463610 307 /** Tell the terminal not to display the cursor.
dansummers 0:863811463610 308 */
dansummers 0:863811463610 309 inline void hide_cursor()
dansummers 0:863811463610 310 {
dansummers 0:863811463610 311 this->ansi_csi();
dansummers 0:863811463610 312 this->ansi_dectcem_hide();
dansummers 0:863811463610 313 }
dansummers 0:863811463610 314
dansummers 0:863811463610 315 /** Tell the terminal to display the cursor.
dansummers 0:863811463610 316 */
dansummers 0:863811463610 317 inline void show_cursor()
dansummers 0:863811463610 318 {
dansummers 0:863811463610 319 this->ansi_csi();
dansummers 0:863811463610 320 this->ansi_dectcem_show();
dansummers 0:863811463610 321 }
dansummers 0:863811463610 322
dansummers 0:863811463610 323 /** Reset the display to its default parameters (clearing all text styling and colour settings).
dansummers 0:863811463610 324 */
dansummers 0:863811463610 325 inline void set_display_to_defaults()
dansummers 0:863811463610 326 {
dansummers 0:863811463610 327 this->ansi_csi();
dansummers 0:863811463610 328 this->ansi_sgr(true, 0, 0, 0);
dansummers 0:863811463610 329 }
dansummers 0:863811463610 330
dansummers 0:863811463610 331 };
dansummers 0:863811463610 332
dansummers 0:863811463610 333
dansummers 0:863811463610 334 #endif