openMSX
|
This class represents a single text line in the console. More...
#include <ConsoleLine.hh>
Classes | |
struct | Chunk |
Public Member Functions | |
ConsoleLine ()=default | |
Construct empty line. | |
void | clear () |
Reinitialize to an empty line. | |
ConsoleLine (std::string line, imColor color=imColor::TEXT) | |
Construct line with a single color (by default white). | |
void | addChunk (std::string_view text, imColor color=imColor::TEXT) |
Append a chunk with a (different) color. | |
void | addLine (const ConsoleLine &ln) |
Append another line (possibly containing multiple chunks). | |
ConsoleLine | splitAtColumn (unsigned column) |
Split this line at a given column number. | |
size_t | numChars () const |
Get the number of UTF8 characters in this line. | |
const std::string & | str () const |
Get the total string, ignoring color differences. | |
size_t | numChunks () const |
Get the number of different chunks. | |
imColor | chunkColor (size_t i) const |
Get the color for the i-th chunk. | |
std::string_view | chunkText (size_t i) const |
Get the text for the i-th chunk. | |
const auto & | getChunks () const |
This class represents a single text line in the console.
The line can have several chunks with different colors.
Definition at line 15 of file ConsoleLine.hh.
|
default |
Construct empty line.
|
explicit |
Construct line with a single color (by default white).
Definition at line 12 of file ConsoleLine.cc.
void openmsx::ConsoleLine::addChunk | ( | std::string_view | text, |
imColor | color = imColor::TEXT |
||
) |
Append a chunk with a (different) color.
Definition at line 18 of file ConsoleLine.cc.
Referenced by splitAtColumn(), and TEST_CASE().
void openmsx::ConsoleLine::addLine | ( | const ConsoleLine & | ln | ) |
Append another line (possibly containing multiple chunks).
Definition at line 24 of file ConsoleLine.cc.
References strAppend().
Referenced by openmsx::ImGuiConsole::paint().
imColor openmsx::ConsoleLine::chunkColor | ( | size_t | i | ) | const |
Get the color for the i-th chunk.
Definition at line 76 of file ConsoleLine.cc.
Referenced by openmsx::ImGuiConsole::paint().
std::string_view openmsx::ConsoleLine::chunkText | ( | size_t | i | ) | const |
Get the text for the i-th chunk.
Definition at line 82 of file ConsoleLine.cc.
Referenced by openmsx::ImGuiConsole::paint().
|
inline |
Reinitialize to an empty line.
Definition at line 22 of file ConsoleLine.hh.
Referenced by openmsx::ImGuiConsole::paint().
|
inline |
Definition at line 55 of file ConsoleLine.hh.
Referenced by TEST_CASE().
size_t 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 71 of file ConsoleLine.cc.
References utf8::unchecked::size().
|
inline |
Get the number of different chunks.
Each chunk is a a part of the line that has the same color.
Definition at line 49 of file ConsoleLine.hh.
Referenced by openmsx::ImGuiConsole::paint().
ConsoleLine openmsx::ConsoleLine::splitAtColumn | ( | unsigned | column | ) |
Split this line at a given column number.
This line will contain (up to) 'column' number of characters. The remainder of the line is returned, this could be an empty line.
Definition at line 40 of file ConsoleLine.cc.
References addChunk(), view::drop(), utf8::unchecked::next(), openmsx::ConsoleLine::Chunk::pos, and ranges::upper_bound().
Referenced by TEST_CASE().
|
inline |
Get the total string, ignoring color differences.
Definition at line 45 of file ConsoleLine.hh.
Referenced by TEST_CASE().