Terminal escape sequence parser. More...
#include <terminal.h>
Public Member Functions | |
void | apply () |
Apply the current internal state (colors) on the terminal. More... | |
bool | parse (char c) |
parse single character c More... | |
void | parse (const std::string &str) |
parse string More... | |
Parser () | |
Parser (Terminal *terminal) | |
std::vector< std::string > | wrap (const std::string &str, unsigned int columns) |
Apply line wrapping. More... | |
Private Types | |
enum | State { STATE_ESCAPE, STATE_TYPE, STATE_CSI } |
Private Member Functions | |
void | parseSetAttributes (const std::string &str) |
Private Attributes | |
Color | m_bgColor |
bool | m_bold = false |
std::string | m_buf |
Color | m_fgColor |
State | m_state = STATE_ESCAPE |
Terminal * | m_term = nullptr |
Terminal escape sequence parser.
This class allows the user to parse Linux escape sequences (restricted to simple color sequences for now).
Definition at line 102 of file terminal.h.
|
private |
Enumerator | |
---|---|
STATE_ESCAPE | |
STATE_TYPE | |
STATE_CSI |
Definition at line 127 of file terminal.h.
|
inline |
Definition at line 105 of file terminal.h.
rosmon::Terminal::Parser::Parser | ( | Terminal * | terminal | ) |
Definition at line 31 of file terminal.cpp.
void rosmon::Terminal::Parser::apply | ( | ) |
Apply the current internal state (colors) on the terminal.
Definition at line 161 of file terminal.cpp.
bool rosmon::Terminal::Parser::parse | ( | char | c | ) |
parse single character c
Definition at line 71 of file terminal.cpp.
void rosmon::Terminal::Parser::parse | ( | const std::string & | str | ) |
parse string
Definition at line 111 of file terminal.cpp.
|
private |
Definition at line 36 of file terminal.cpp.
std::vector< std::string > rosmon::Terminal::Parser::wrap | ( | const std::string & | str, |
unsigned int | columns | ||
) |
Apply line wrapping.
Each returned line contains the appropriate escape sequences to set up the current color mode.
Definition at line 120 of file terminal.cpp.
|
private |
Definition at line 140 of file terminal.h.
|
private |
Definition at line 141 of file terminal.h.
|
private |
Definition at line 137 of file terminal.h.
|
private |
Definition at line 139 of file terminal.h.
|
private |
Definition at line 136 of file terminal.h.
|
private |
Definition at line 134 of file terminal.h.