|
openMSX
|
This class represents a single text line in the console. More...
#include <CommandConsole.hh>
Public Member Functions | |
| ConsoleLine () | |
| Construct empty line. | |
| ConsoleLine (string_ref line, unsigned rgb=0xffffff) | |
| Construct line with a single color (by default white). | |
| void | addChunk (string_ref text, unsigned rgb) |
| Append a chunk with a (different) color. | |
| unsigned | numChars () const |
| Get the number of UTF8 characters in this line. | |
| const std::string & | str () const |
| Get the total string, ignoring color differences. | |
| unsigned | numChunks () const |
| Get the number of different chunks. | |
| unsigned | chunkColor (unsigned i) const |
| Get the color for the i-th chunk. | |
| string_ref | chunkText (unsigned i) const |
| Get the text for the i-th chunk. | |
| ConsoleLine | substr (unsigned pos, unsigned len) const |
| Get a part of total line. | |
This class represents a single text line in the console.
The line can have several chunks with different colors.
Definition at line 25 of file CommandConsole.hh.
| openmsx::ConsoleLine::ConsoleLine | ( | ) |
Construct empty line.
Definition at line 39 of file CommandConsole.cc.
|
explicit |
Construct line with a single color (by default white).
Definition at line 43 of file CommandConsole.cc.
| void openmsx::ConsoleLine::addChunk | ( | string_ref | text, |
| unsigned | rgb | ||
| ) |
Append a chunk with a (different) color.
This is currently the only way to construct a multi-colored line/
Definition at line 49 of file CommandConsole.cc.
References string_ref::data(), and string_ref::size().
| unsigned openmsx::ConsoleLine::chunkColor | ( | unsigned | i | ) | const |
Get the color for the i-th chunk.
Definition at line 70 of file CommandConsole.cc.
| string_ref openmsx::ConsoleLine::chunkText | ( | unsigned | i | ) | const |
Get the text for the i-th chunk.
Definition at line 76 of file CommandConsole.cc.
References string_ref::npos, and string_ref::substr().
| unsigned openmsx::ConsoleLine::numChars | ( | ) | const |
Get the number of UTF8 characters in this line.
So multi-byte characters are counted as a single character.
Definition at line 55 of file CommandConsole.cc.
References utf8::unchecked::size().
| unsigned openmsx::ConsoleLine::numChunks | ( | ) | const |
Get the number of different chunks.
Each chunk is a a part of the line that has the same color.
Definition at line 65 of file CommandConsole.cc.
| const string & openmsx::ConsoleLine::str | ( | ) | const |
Get the total string, ignoring color differences.
Definition at line 60 of file CommandConsole.cc.
| ConsoleLine openmsx::ConsoleLine::substr | ( | unsigned | pos, |
| unsigned | len | ||
| ) | const |
Get a part of total line.
The result keeps the same colors as this line. E.g. used to get part of (long) line that should be wrapped over multiple console lines.
| pos | First character (multi-byte sequence counted as 1 character). |
| len | Length of the substring, also counted in characters |
Definition at line 86 of file CommandConsole.cc.
References utf8::advance(), and utf8::unchecked::next().
1.8.1.2