libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
AnsiStream Class Reference

ANSI escape code writer backed by an IODevice. Writes ANSI escape sequences and raw text to an IODevice. Also serves as the source of truth for ANSI color palette data and color matching. More...

#include <ansistream.h>

Public Types

enum  TextStyle {
  Bold = 1 , Dim = 2 , Italic = 3 , Underlined = 4 ,
  Blink = 5 , Inverted = 7 , Hidden = 8
}
 ANSI text styles. More...
 
enum  AnsiColor : uint8_t {
  Black = 0 , Maroon = 1 , DarkRed = 1 , Green = 2 ,
  DarkGreen = 2 , Olive = 3 , DarkYellow = 3 , Navy = 4 ,
  DarkBlue = 4 , Purple = 5 , DarkMagenta = 5 , Teal = 6 ,
  DarkCyan = 6 , Silver = 7 , LightGray = 7 , Grey = 8 ,
  DarkGray = 8 , Red = 9 , Lime = 10 , Yellow = 11 ,
  Blue = 12 , Fuchsia = 13 , Magenta = 13 , Aqua = 14 ,
  Cyan = 14 , White = 15 , Grey0 = 16 , NavyBlue = 17 ,
  DarkBlue_18 = 18 , Blue3_19 = 19 , Blue3_20 = 20 , Blue1 = 21 ,
  DarkGreen_22 = 22 , DeepSkyBlue4_23 = 23 , DeepSkyBlue4_24 = 24 , DeepSkyBlue4_25 = 25 ,
  DodgerBlue3 = 26 , DodgerBlue2 = 27 , Green4 = 28 , SpringGreen4 = 29 ,
  Turquoise4 = 30 , DeepSkyBlue3_31 = 31 , DeepSkyBlue3_32 = 32 , DodgerBlue1 = 33 ,
  Green3_34 = 34 , SpringGreen3_35 = 35 , DarkCyan_36 = 36 , LightSeaGreen = 37 ,
  DeepSkyBlue2 = 38 , DeepSkyBlue1 = 39 , Green3_40 = 40 , SpringGreen3_41 = 41 ,
  SpringGreen2_42 = 42 , Cyan3 = 43 , DarkTurquoise = 44 , Turquoise2 = 45 ,
  Green1 = 46 , SpringGreen2_47 = 47 , SpringGreen1 = 48 , MediumSpringGreen = 49 ,
  Cyan2 = 50 , Cyan1 = 51 , DarkRed_52 = 52 , DeepPink4_53 = 53 ,
  Purple4_54 = 54 , Purple4_55 = 55 , Purple3 = 56 , BlueViolet = 57 ,
  Orange4_58 = 58 , Grey37 = 59 , MediumPurple4 = 60 , SlateBlue3_61 = 61 ,
  SlateBlue3_62 = 62 , RoyalBlue1 = 63 , Chartreuse4 = 64 , DarkSeaGreen4_65 = 65 ,
  PaleTurquoise4 = 66 , SteelBlue = 67 , SteelBlue3 = 68 , CornflowerBlue = 69 ,
  Chartreuse3_70 = 70 , DarkSeaGreen4_71 = 71 , CadetBlue_72 = 72 , CadetBlue_73 = 73 ,
  SkyBlue3 = 74 , SteelBlue1_75 = 75 , Chartreuse3_76 = 76 , PaleGreen3_77 = 77 ,
  SeaGreen3 = 78 , Aquamarine3 = 79 , MediumTurquoise = 80 , SteelBlue1_81 = 81 ,
  Chartreuse2_82 = 82 , SeaGreen2 = 83 , SeaGreen1_84 = 84 , SeaGreen1_85 = 85 ,
  Aquamarine1_86 = 86 , DarkSlateGray2 = 87 , DarkRed_88 = 88 , DeepPink4_89 = 89 ,
  DarkMagenta_90 = 90 , DarkMagenta_91 = 91 , DarkViolet_92 = 92 , Purple_93 = 93 ,
  Orange4_94 = 94 , LightPink4 = 95 , Plum4 = 96 , MediumPurple3_97 = 97 ,
  MediumPurple3_98 = 98 , SlateBlue1 = 99 , Yellow4_100 = 100 , Wheat4 = 101 ,
  Grey53 = 102 , LightSlateGrey = 103 , MediumPurple = 104 , LightSlateBlue = 105 ,
  Yellow4_106 = 106 , DarkOliveGreen3_107 = 107 , DarkSeaGreen = 108 , LightSkyBlue3_109 = 109 ,
  LightSkyBlue3_110 = 110 , SkyBlue2 = 111 , Chartreuse2_112 = 112 , DarkOliveGreen3_113 = 113 ,
  PaleGreen3_114 = 114 , DarkSeaGreen3_115 = 115 , DarkSlateGray3 = 116 , SkyBlue1 = 117 ,
  Chartreuse1 = 118 , LightGreen_119 = 119 , LightGreen_120 = 120 , PaleGreen1_121 = 121 ,
  Aquamarine1_122 = 122 , DarkSlateGray1 = 123 , Red3_124 = 124 , DeepPink4_125 = 125 ,
  MediumVioletRed = 126 , Magenta3_127 = 127 , DarkViolet_128 = 128 , Purple_129 = 129 ,
  DarkOrange3_130 = 130 , IndianRed_131 = 131 , HotPink3_132 = 132 , MediumOrchid3 = 133 ,
  MediumOrchid = 134 , MediumPurple2_135 = 135 , DarkGoldenrod = 136 , LightSalmon3_137 = 137 ,
  RosyBrown = 138 , Grey63 = 139 , MediumPurple2_140 = 140 , MediumPurple1 = 141 ,
  Gold3_142 = 142 , DarkKhaki = 143 , NavajoWhite3 = 144 , Grey69 = 145 ,
  LightSteelBlue3 = 146 , LightSteelBlue = 147 , Yellow3_148 = 148 , DarkOliveGreen3_149 = 149 ,
  DarkSeaGreen3_150 = 150 , DarkSeaGreen2_151 = 151 , LightCyan3 = 152 , LightSkyBlue1 = 153 ,
  GreenYellow = 154 , DarkOliveGreen2 = 155 , PaleGreen1_156 = 156 , DarkSeaGreen2_157 = 157 ,
  DarkSeaGreen1_158 = 158 , PaleTurquoise1 = 159 , Red3_160 = 160 , DeepPink3_161 = 161 ,
  DeepPink3_162 = 162 , Magenta3_163 = 163 , Magenta3_164 = 164 , Magenta2_165 = 165 ,
  DarkOrange3_166 = 166 , IndianRed_167 = 167 , HotPink3_168 = 168 , HotPink2 = 169 ,
  Orchid = 170 , MediumOrchid1_171 = 171 , Orange3 = 172 , LightSalmon3_173 = 173 ,
  LightPink3 = 174 , Pink3 = 175 , Plum3 = 176 , Violet = 177 ,
  Gold3_178 = 178 , LightGoldenrod3 = 179 , Tan = 180 , MistyRose3 = 181 ,
  Thistle3 = 182 , Plum2 = 183 , Yellow3_184 = 184 , Khaki3 = 185 ,
  LightGoldenrod2_186 = 186 , LightYellow3 = 187 , Grey84 = 188 , LightSteelBlue1 = 189 ,
  Yellow2 = 190 , DarkOliveGreen1_191 = 191 , DarkOliveGreen1_192 = 192 , DarkSeaGreen1_193 = 193 ,
  Honeydew2 = 194 , LightCyan1 = 195 , Red1 = 196 , DeepPink2 = 197 ,
  DeepPink1_198 = 198 , DeepPink1_199 = 199 , Magenta2_200 = 200 , Magenta1 = 201 ,
  OrangeRed1 = 202 , IndianRed1_203 = 203 , IndianRed1_204 = 204 , HotPink_205 = 205 ,
  HotPink_206 = 206 , MediumOrchid1_207 = 207 , DarkOrange = 208 , Salmon1 = 209 ,
  LightCoral = 210 , PaleVioletRed1 = 211 , Orchid2 = 212 , Orchid1 = 213 ,
  Orange1 = 214 , SandyBrown = 215 , LightSalmon1 = 216 , LightPink1 = 217 ,
  Pink1 = 218 , Plum1 = 219 , Gold1 = 220 , LightGoldenrod2_221 = 221 ,
  LightGoldenrod2_222 = 222 , NavajoWhite1 = 223 , MistyRose1 = 224 , Thistle1 = 225 ,
  Yellow1 = 226 , LightGoldenrod1 = 227 , Khaki1 = 228 , Wheat1 = 229 ,
  Cornsilk1 = 230 , Grey100 = 231 , Grey3 = 232 , Grey7 = 233 ,
  Grey11 = 234 , Grey15 = 235 , Grey19 = 236 , Grey23 = 237 ,
  Grey27 = 238 , Grey30 = 239 , Grey35 = 240 , Grey39 = 241 ,
  Grey42 = 242 , Grey46 = 243 , Grey50 = 244 , Grey54 = 245 ,
  Grey58 = 246 , Grey62 = 247 , Grey66 = 248 , Grey70 = 249 ,
  Grey74 = 250 , Grey78 = 251 , Grey82 = 252 , Grey85 = 253 ,
  Grey89 = 254 , Grey93 = 255
}
 ANSI 256-color palette indices. More...
 

Public Member Functions

 AnsiStream (IODevice *device)
 Constructs an AnsiStream writing to the given device.
 
void setAnsiEnabled (bool val)
 Sets the ANSI output enabled. If not enabled, no ANSI codes will be output but non-ANSI content will pass-thru.
 
IODevicedevice () const
 Returns the underlying IODevice.
 
AnsiStreamwrite (const String &text)
 Writes raw text to the underlying device.
 
AnsiStreamwrite (const char *text)
 Writes a C string to the underlying device.
 
AnsiStreamwrite (char ch)
 Writes a single character to the underlying device.
 
AnsiStreamwrite (int val)
 Writes an integer to the underlying device.
 
void flush ()
 Flushes the underlying device.
 
AnsiStreamoperator<< (const String &text)
 Writes a String via operator<<.
 
AnsiStreamoperator<< (const char *text)
 Writes a C string via operator<<.
 
AnsiStreamoperator<< (char ch)
 Writes a single character via operator<<.
 
AnsiStreamoperator<< (int val)
 Writes an integer via operator<<.
 
AnsiStreamsetForeground (AnsiColor color)
 Sets the foreground to an ANSI palette color.
 
AnsiStreamsetBackground (AnsiColor color)
 Sets the background to an ANSI palette color.
 
AnsiStreamsetForeground (const Color &color, int maxIndex=255)
 Sets the foreground to the closest ANSI palette match.
 
AnsiStreamsetBackground (const Color &color, int maxIndex=255)
 Sets the background to the closest ANSI palette match.
 
AnsiStreamcursorUp (int n)
 Moves the cursor up N rows.
 
AnsiStreamcursorDown (int n)
 Moves the cursor down N rows.
 
AnsiStreamcursorRight (int n)
 Moves the cursor right N columns.
 
AnsiStreamcursorLeft (int n)
 Moves the cursor left N columns.
 
AnsiStreamsetCursorPosition (int r, int c)
 Sets the absolute cursor position.
 
AnsiStreamclearScreen ()
 Clears the screen.
 
AnsiStreammoveToStartOfLine ()
 Moves the cursor to the start of the current line.
 
AnsiStreammoveToEndOfLine ()
 Moves the cursor to the end of the current line.
 
AnsiStreamclearLine ()
 Clears the current line.
 
AnsiStreamclearLineBeforeCursor ()
 Clears between the cursor and the start of the current line.
 
AnsiStreamclearLineAfterCursor ()
 Clears between the cursor and the end of the current line.
 
AnsiStreamreset ()
 Resets the terminal to default configuration.
 
AnsiStreamresetForeground ()
 Resets the foreground to the terminal default.
 
AnsiStreamresetBackground ()
 Resets the background to the terminal default.
 
AnsiStreamshowCursor ()
 Makes the cursor visible.
 
AnsiStreamhideCursor ()
 Makes the cursor invisible.
 
AnsiStreamsaveCursorPosition ()
 Saves the cursor position for later recall.
 
AnsiStreamrestoreCursorPosition ()
 Recalls a saved cursor position.
 
AnsiStreamenableScrollingRegion (int startRow, int endRow)
 Enables a region of the screen to scroll.
 
AnsiStreamscrollUp (int n)
 Causes the scrolling region to scroll up N rows.
 
AnsiStreamscrollDown (int n)
 Causes the scrolling region to scroll down N rows.
 
AnsiStreameraseCharacters (int n)
 Erases N characters at cursor.
 
AnsiStreamsetForeground256 (uint8_t index)
 Sets the foreground to a 256-color palette index.
 
AnsiStreamsetBackground256 (uint8_t index)
 Sets the background to a 256-color palette index.
 
AnsiStreamsetForegroundRGB (uint8_t r, uint8_t g, uint8_t b)
 Sets the foreground to a 24-bit RGB color.
 
AnsiStreamsetBackgroundRGB (uint8_t r, uint8_t g, uint8_t b)
 Sets the background to a 24-bit RGB color.
 
AnsiStreamsetStrikethrough (bool enable)
 Enables strike-through mode if supported.
 
AnsiStreamuseAlternateScreenBuffer ()
 Terminal should switch to an alternate buffer.
 
AnsiStreamuseMainScreenBuffer ()
 Terminal should switch to main screen buffer.
 
bool getCursorPosition (IODevice *input, int &row, int &col)
 Requests the current cursor position from the terminal.
 

Static Public Member Functions

static Color ansiColor (int index)
 Returns the RGB color for a 256-color palette entry.
 
static Color ansiColor (AnsiColor color)
 Returns the RGB color for an AnsiColor palette entry.
 
static AnsiColor findClosestAnsiColor (const Color &color, int maxIndex=255)
 Finds the closest ANSI palette entry for an RGB color.
 
static bool stdoutWindowSize (int &rows, int &cols)
 Returns the window size of the current STDOUT device.
 
static bool stdoutSupportsANSI ()
 Returns true if the current STDOUT can support ANSI signaling.
 

Detailed Description

ANSI escape code writer backed by an IODevice. Writes ANSI escape sequences and raw text to an IODevice. Also serves as the source of truth for ANSI color palette data and color matching.

Member Enumeration Documentation

◆ AnsiColor

ANSI 256-color palette indices.

Values 0-15 are the 16 standard system colors. Values 16-231 are the 6x6x6 color cube. Values 232-255 are the grayscale ramp. Any uint8_t value is a valid AnsiColor.

Xterm standard names are used throughout. Where the same xterm name appears at multiple palette indices, the index is appended as a suffix to disambiguate.

See also
https://www.ditig.com/256-colors-cheat-sheet
Enumerator
DarkRed 

Alias for Maroon.

DarkGreen 

Alias for Green (system).

DarkYellow 

Alias for Olive.

DarkBlue 

Alias for Navy.

DarkMagenta 

Alias for Purple (system).

DarkCyan 

Alias for Teal.

LightGray 

Alias for Silver.

DarkGray 

Alias for Grey.

Magenta 

Alias for Fuchsia.

Cyan 

Alias for Aqua.

◆ TextStyle

ANSI text styles.

Enumerator
Bold 

Bold or increased intensity.

Dim 

Faint or decreased intensity.

Italic 

Italic text.

Underlined 

Underlined text.

Blink 

Blinking text.

Inverted 

Swapped foreground and background colors.

Hidden 

Hidden (invisible) text.

Constructor & Destructor Documentation

◆ AnsiStream()

AnsiStream::AnsiStream ( IODevice device)
inline

Constructs an AnsiStream writing to the given device.

Parameters
deviceThe IODevice to write to. Must be open for writing.

Member Function Documentation

◆ ansiColor() [1/2]

static Color AnsiStream::ansiColor ( AnsiColor  color)
inlinestatic

Returns the RGB color for an AnsiColor palette entry.

Parameters
colorThe palette entry.
Returns
The RGB color.

◆ ansiColor() [2/2]

static Color AnsiStream::ansiColor ( int  index)
static

Returns the RGB color for a 256-color palette entry.

Parameters
indexPalette index (0-255).
Returns
The RGB color, or an invalid Color if out of range.

◆ clearLine()

AnsiStream & AnsiStream::clearLine ( )
inline

Clears the current line.

Returns
Reference to this stream for chaining.

◆ clearLineAfterCursor()

AnsiStream & AnsiStream::clearLineAfterCursor ( )
inline

Clears between the cursor and the end of the current line.

Returns
Reference to this stream for chaining.

◆ clearLineBeforeCursor()

AnsiStream & AnsiStream::clearLineBeforeCursor ( )
inline

Clears between the cursor and the start of the current line.

Returns
Reference to this stream for chaining.

◆ clearScreen()

AnsiStream & AnsiStream::clearScreen ( )
inline

Clears the screen.

Returns
Reference to this stream for chaining.

◆ cursorDown()

AnsiStream & AnsiStream::cursorDown ( int  n)
inline

Moves the cursor down N rows.

Parameters
[in]nNumber of rows to move down.
Returns
Reference to this stream for chaining.

◆ cursorLeft()

AnsiStream & AnsiStream::cursorLeft ( int  n)
inline

Moves the cursor left N columns.

Parameters
[in]nNumber of columns to move left.
Returns
Reference to this stream for chaining.

◆ cursorRight()

AnsiStream & AnsiStream::cursorRight ( int  n)
inline

Moves the cursor right N columns.

Parameters
[in]nNumber of columns to move right.
Returns
Reference to this stream for chaining.

◆ cursorUp()

AnsiStream & AnsiStream::cursorUp ( int  n)
inline

Moves the cursor up N rows.

Parameters
[in]nNumber of rows to move up.
Returns
Reference to this stream for chaining.

◆ device()

IODevice * AnsiStream::device ( ) const
inline

Returns the underlying IODevice.

Returns
Pointer to the IODevice this stream writes to.

◆ enableScrollingRegion()

AnsiStream & AnsiStream::enableScrollingRegion ( int  startRow,
int  endRow 
)
inline

Enables a region of the screen to scroll.

Parameters
[in]startRowRow where scrolling should start.
[in]endRowRow where scrolling should end.
Returns
Reference to this stream for chaining.

◆ eraseCharacters()

AnsiStream & AnsiStream::eraseCharacters ( int  n)
inline

Erases N characters at cursor.

Parameters
nNumber of characters to erase.
Returns
Reference to this stream for chaining.

◆ findClosestAnsiColor()

static AnsiColor AnsiStream::findClosestAnsiColor ( const Color color,
int  maxIndex = 255 
)
static

Finds the closest ANSI palette entry for an RGB color.

Uses redmean-weighted Euclidean distance for perceptual accuracy. Chromatic inputs are biased toward colored palette entries over grays.

Parameters
colorThe RGB color to match.
maxIndexMaximum palette index to search (15 for 16-color, 255 for 256-color).
Returns
The closest palette entry.

◆ getCursorPosition()

bool AnsiStream::getCursorPosition ( IODevice input,
int &  row,
int &  col 
)

Requests the current cursor position from the terminal.

Parameters
[in]inputInput IODevice for the terminal (e.g. stdinDevice())
[out]rowCursor Row
[out]colCursor Column
Returns
True if successful.

◆ hideCursor()

AnsiStream & AnsiStream::hideCursor ( )
inline

Makes the cursor invisible.

Returns
Reference to this stream for chaining.

◆ moveToEndOfLine()

AnsiStream & AnsiStream::moveToEndOfLine ( )
inline

Moves the cursor to the end of the current line.

Returns
Reference to this stream for chaining.

◆ moveToStartOfLine()

AnsiStream & AnsiStream::moveToStartOfLine ( )
inline

Moves the cursor to the start of the current line.

Returns
Reference to this stream for chaining.

◆ reset()

AnsiStream & AnsiStream::reset ( )
inline

Resets the terminal to default configuration.

Returns
Reference to this stream for chaining.

◆ resetBackground()

AnsiStream & AnsiStream::resetBackground ( )
inline

Resets the background to the terminal default.

Returns
Reference to this stream for chaining.

◆ resetForeground()

AnsiStream & AnsiStream::resetForeground ( )
inline

Resets the foreground to the terminal default.

Returns
Reference to this stream for chaining.

◆ restoreCursorPosition()

AnsiStream & AnsiStream::restoreCursorPosition ( )
inline

Recalls a saved cursor position.

See also
saveCursorPosition()
Returns
Reference to this stream for chaining.

◆ saveCursorPosition()

AnsiStream & AnsiStream::saveCursorPosition ( )
inline

Saves the cursor position for later recall.

Returns
Reference to this stream for chaining.

◆ scrollDown()

AnsiStream & AnsiStream::scrollDown ( int  n)
inline

Causes the scrolling region to scroll down N rows.

Parameters
[in]nNumber of rows to scroll.
Returns
Reference to this stream for chaining.

◆ scrollUp()

AnsiStream & AnsiStream::scrollUp ( int  n)
inline

Causes the scrolling region to scroll up N rows.

Parameters
[in]nNumber of rows to scroll.
Returns
Reference to this stream for chaining.

◆ setAnsiEnabled()

void AnsiStream::setAnsiEnabled ( bool  val)
inline

Sets the ANSI output enabled. If not enabled, no ANSI codes will be output but non-ANSI content will pass-thru.

Parameters
valTrue to enable ANSI output, false to disable.

◆ setBackground() [1/2]

AnsiStream & AnsiStream::setBackground ( AnsiColor  color)

Sets the background to an ANSI palette color.

For indices 0-7, emits the standard SGR code (40-47). For indices 8-15, emits the bright SGR code (100-107). For indices 16-255, emits a 256-color sequence.

Parameters
colorThe palette index (0-255).
Returns
Reference to this stream for chaining.

◆ setBackground() [2/2]

AnsiStream & AnsiStream::setBackground ( const Color color,
int  maxIndex = 255 
)

Sets the background to the closest ANSI palette match.

Parameters
colorThe RGB color to match.
maxIndexMaximum palette index (15 for 16-color, 255 for 256-color).
Returns
Reference to this stream for chaining.

◆ setBackground256()

AnsiStream & AnsiStream::setBackground256 ( uint8_t  index)
inline

Sets the background to a 256-color palette index.

Always uses the extended 256-color escape sequence format (\033[48;5;Nm) regardless of index. Use setBackground() for automatic selection of the most compatible format.

Parameters
indexColor index (0-255).
Returns
Reference to this stream for chaining.

◆ setBackgroundRGB()

AnsiStream & AnsiStream::setBackgroundRGB ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)
inline

Sets the background to a 24-bit RGB color.

Parameters
rRed component (0-255).
gGreen component (0-255).
bBlue component (0-255).
Returns
Reference to this stream for chaining.

◆ setCursorPosition()

AnsiStream & AnsiStream::setCursorPosition ( int  r,
int  c 
)
inline

Sets the absolute cursor position.

Parameters
[in]rRow to move cursor.
[in]cColumn to move cursor.
Returns
Reference to this stream for chaining.

◆ setForeground() [1/2]

AnsiStream & AnsiStream::setForeground ( AnsiColor  color)

Sets the foreground to an ANSI palette color.

For indices 0-7, emits the standard SGR code (30-37). For indices 8-15, emits the bright SGR code (90-97). For indices 16-255, emits a 256-color sequence.

Parameters
colorThe palette index (0-255).
Returns
Reference to this stream for chaining.

◆ setForeground() [2/2]

AnsiStream & AnsiStream::setForeground ( const Color color,
int  maxIndex = 255 
)

Sets the foreground to the closest ANSI palette match.

Parameters
colorThe RGB color to match.
maxIndexMaximum palette index (15 for 16-color, 255 for 256-color).
Returns
Reference to this stream for chaining.

◆ setForeground256()

AnsiStream & AnsiStream::setForeground256 ( uint8_t  index)
inline

Sets the foreground to a 256-color palette index.

Always uses the extended 256-color escape sequence format (\033[38;5;Nm) regardless of index. Use setForeground() for automatic selection of the most compatible format.

Parameters
indexColor index (0-255).
Returns
Reference to this stream for chaining.

◆ setForegroundRGB()

AnsiStream & AnsiStream::setForegroundRGB ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)
inline

Sets the foreground to a 24-bit RGB color.

Parameters
rRed component (0-255).
gGreen component (0-255).
bBlue component (0-255).
Returns
Reference to this stream for chaining.

◆ setStrikethrough()

AnsiStream & AnsiStream::setStrikethrough ( bool  enable)
inline

Enables strike-through mode if supported.

Parameters
[in]enableTrue if strike-through should be enabled.
Returns
Reference to this stream for chaining.

◆ showCursor()

AnsiStream & AnsiStream::showCursor ( )
inline

Makes the cursor visible.

Returns
Reference to this stream for chaining.

◆ stdoutSupportsANSI()

static bool AnsiStream::stdoutSupportsANSI ( )
static

Returns true if the current STDOUT can support ANSI signaling.

Returns
True if STDOUT supports ANSI escape sequences.

◆ stdoutWindowSize()

static bool AnsiStream::stdoutWindowSize ( int &  rows,
int &  cols 
)
static

Returns the window size of the current STDOUT device.

Parameters
[out]rowsNumber of rows in window.
[out]colsNumber of columns in window.
Returns
True if the window size was retrieved successfully.

◆ useAlternateScreenBuffer()

AnsiStream & AnsiStream::useAlternateScreenBuffer ( )
inline

Terminal should switch to an alternate buffer.

Returns
Reference to this stream for chaining.

◆ useMainScreenBuffer()

AnsiStream & AnsiStream::useMainScreenBuffer ( )
inline

Terminal should switch to main screen buffer.

Returns
Reference to this stream for chaining.

◆ write() [1/4]

AnsiStream & AnsiStream::write ( char  ch)

Writes a single character to the underlying device.

Parameters
chThe character to write.
Returns
Reference to this stream for chaining.

◆ write() [2/4]

AnsiStream & AnsiStream::write ( const char text)

Writes a C string to the underlying device.

Parameters
textThe null-terminated string to write.
Returns
Reference to this stream for chaining.

◆ write() [3/4]

AnsiStream & AnsiStream::write ( const String text)

Writes raw text to the underlying device.

Parameters
textThe text to write.
Returns
Reference to this stream for chaining.

◆ write() [4/4]

AnsiStream & AnsiStream::write ( int  val)

Writes an integer to the underlying device.

Parameters
valThe integer to write (formatted as decimal).
Returns
Reference to this stream for chaining.

The documentation for this class was generated from the following file: