Encapsulates terminal control. More...
#include <terminal.h>
Classes | |
| class | Parser |
| Terminal escape sequence parser. More... | |
Public Types | |
| enum | SimpleColor { Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, IntenseBlack, IntenseRed, IntenseGreen, IntenseYellow, IntenseBlue, IntenseMagenta, IntenseCyan, IntenseWhite, Grayscale = 0xe8 } |
| Simple colors. More... | |
| enum | SpecialKey { SK_F1 = 0x100, SK_F2, SK_F3, SK_F4, SK_F5, SK_F6, SK_F7, SK_F8, SK_F9, SK_F10, SK_F11, SK_F12 } |
Public Member Functions | |
| void | clearToEndOfLine () |
| Clear characters from cursor to end of line. More... | |
| void | clearWindowTitle (const std::string &backup) |
| bool | getSize (int *columns, int *rows) |
| Get current window size. More... | |
| bool | has256Colors () const |
| bool | interactive () const |
| void | moveCursorToStartOfLine () |
| Move cursor to start of the line. More... | |
| void | moveCursorUp (int numLines) |
| Move cursor up by numLines. More... | |
| int | readKey () |
| void | setBackgroundColor (uint32_t color) |
| Set 24-bit background color. More... | |
| void | setBold (bool on) |
| void | setCursorInvisible () |
| hide cursor More... | |
| void | setCursorVisible () |
| restore cursor More... | |
| void | setEcho (bool on) |
| void | setForegroundColor (uint32_t color) |
| Set 24-bit foreground color. More... | |
| void | setStandardColors () |
| Reset fg + bg to standard terminal colors. More... | |
| void | setWindowTitle (const std::string &title) |
| Terminal () | |
Set indexed foreground/background color | |
| void | setSimpleBackground (SimpleColor color) |
| void | setSimpleForeground (SimpleColor color) |
| void | setSimplePair (SimpleColor fg, SimpleColor bg) |
Private Attributes | |
| bool | m_256colors |
| std::string | m_bgColorStr |
| std::string | m_boldStr |
| std::string | m_currentEscapeStr |
| std::string | m_elStr |
| std::string | m_fgColorStr |
| std::string | m_opStr |
| std::string | m_sgr0Str |
| std::map< std::string, SpecialKey > | m_specialKeys |
| bool | m_truecolor |
| std::string | m_upStr |
| bool | m_valid |
Encapsulates terminal control.
This class enables low-level manipulation of the terminal. It uses the ncurses/terminfo library internally to stay somewhat portable.
Definition at line 20 of file terminal.h.
Simple colors.
These colors can be used with the setSimpleForeground(), setSimpleBackground(), setSimplePair() methods.
| Enumerator | |
|---|---|
| Black | |
| Red | |
| Green | |
| Yellow | |
| Blue | |
| Magenta | |
| Cyan | |
| White | |
| IntenseBlack | |
| IntenseRed | |
| IntenseGreen | |
| IntenseYellow | |
| IntenseBlue | |
| IntenseMagenta | |
| IntenseCyan | |
| IntenseWhite | |
| Grayscale |
24-step grayscale starts here |
Definition at line 29 of file terminal.h.
| Enumerator | |
|---|---|
| SK_F1 | |
| SK_F2 | |
| SK_F3 | |
| SK_F4 | |
| SK_F5 | |
| SK_F6 | |
| SK_F7 | |
| SK_F8 | |
| SK_F9 | |
| SK_F10 | |
| SK_F11 | |
| SK_F12 | |
Definition at line 163 of file terminal.h.
| rosmon::Terminal::Terminal | ( | ) |
Definition at line 122 of file terminal.cpp.
| void rosmon::Terminal::clearToEndOfLine | ( | ) |
Clear characters from cursor to end of line.
Definition at line 359 of file terminal.cpp.
| void rosmon::Terminal::clearWindowTitle | ( | const std::string & | backup | ) |
Definition at line 406 of file terminal.cpp.
| bool rosmon::Terminal::getSize | ( | int * | columns, |
| int * | rows | ||
| ) |
| bool rosmon::Terminal::has256Colors | ( | ) | const |
Returns whether the terminal supports 256 colors. If it does not suppport 256 colors, you should not use the setForegroundColor() / setBackgroundColor() functions.
Definition at line 223 of file terminal.cpp.
|
inline |
Terminal supports escape codes
Definition at line 156 of file terminal.h.
| void rosmon::Terminal::moveCursorToStartOfLine | ( | ) |
Move cursor to start of the line.
Definition at line 375 of file terminal.cpp.
| void rosmon::Terminal::moveCursorUp | ( | int | numLines | ) |
Move cursor up by numLines.
Definition at line 367 of file terminal.cpp.
| int rosmon::Terminal::readKey | ( | ) |
Definition at line 414 of file terminal.cpp.
| void rosmon::Terminal::setBackgroundColor | ( | uint32_t | color | ) |
Set 24-bit background color.
This automatically falls back to 256 colors if the terminal does not support true color.
Definition at line 257 of file terminal.cpp.
| void rosmon::Terminal::setBold | ( | bool | on | ) |
Definition at line 314 of file terminal.cpp.
| void rosmon::Terminal::setCursorInvisible | ( | ) |
hide cursor
Definition at line 228 of file terminal.cpp.
| void rosmon::Terminal::setCursorVisible | ( | ) |
restore cursor
Definition at line 236 of file terminal.cpp.
| void rosmon::Terminal::setEcho | ( | bool | on | ) |
Enable/disable automatic echo of keypresses
Definition at line 293 of file terminal.cpp.
| void rosmon::Terminal::setForegroundColor | ( | uint32_t | color | ) |
Set 24-bit foreground color.
This automatically falls back to 256 colors if the terminal does not support true color.
Definition at line 275 of file terminal.cpp.
| void rosmon::Terminal::setSimpleBackground | ( | SimpleColor | color | ) |
Definition at line 332 of file terminal.cpp.
| void rosmon::Terminal::setSimpleForeground | ( | SimpleColor | color | ) |
Definition at line 323 of file terminal.cpp.
| void rosmon::Terminal::setSimplePair | ( | SimpleColor | fg, |
| SimpleColor | bg | ||
| ) |
Definition at line 341 of file terminal.cpp.
| void rosmon::Terminal::setStandardColors | ( | ) |
Reset fg + bg to standard terminal colors.
Definition at line 350 of file terminal.cpp.
| void rosmon::Terminal::setWindowTitle | ( | const std::string & | title | ) |
Definition at line 393 of file terminal.cpp.
|
private |
Definition at line 174 of file terminal.h.
|
private |
Definition at line 177 of file terminal.h.
|
private |
Definition at line 183 of file terminal.h.
|
private |
Definition at line 187 of file terminal.h.
|
private |
Definition at line 181 of file terminal.h.
|
private |
Definition at line 178 of file terminal.h.
|
private |
Definition at line 179 of file terminal.h.
|
private |
Definition at line 180 of file terminal.h.
|
private |
Definition at line 185 of file terminal.h.
|
private |
Definition at line 175 of file terminal.h.
|
private |
Definition at line 182 of file terminal.h.
|
private |
Definition at line 173 of file terminal.h.