| e8555c89 Andy McCall |
1 |
#ifndef CONSOLE_LINE_HH |
| 2 |
#define CONSOLE_LINE_HH |
| 3 |
|
| 4 |
#include "ImGuiUtils.hh" |
| 5 |
|
| 6 |
#include <cstdint> |
| 7 |
#include <string> |
| 8 |
#include <string_view> |
| 9 |
#include <vector> |
| 10 |
|
| 11 |
namespace openmsx { |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
class ConsoleLine |
| 16 |
{ |
| 17 |
public: |
| 18 |
|
| 19 |
ConsoleLine() = default; |
| 20 |
|
| 21 |
|
| 22 |
void clear() { |
| 23 |
line.clear(); |
| 24 |
chunks.clear(); |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
explicit ConsoleLine(std::string line, imColor color = imColor::TEXT); |
| 29 |
|
| 30 |
|
| 31 |
void addChunk(std::string_view text, imColor color = imColor::TEXT); |
| 32 |
|
| 33 |
|
| 34 |
void addLine(const ConsoleLine& ln); |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
ConsoleLine splitAtColumn(unsigned column); |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
[[nodiscard]] size_t numChars() const; |
| 44 |
|
| 45 |
[[nodiscard]] const std::string& str() const { return line; } |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
[[nodiscard]] size_t numChunks() const { return chunks.size(); } |
| 50 |
|
| 51 |
[[nodiscard]] imColor chunkColor(size_t i) const; |
| 52 |
|
| 53 |
[[nodiscard]] std::string_view chunkText(size_t i) const; |
| 54 |
|
| 55 |
[[nodiscard]] const auto& getChunks() const { return chunks; } |
| 56 |
|
| 57 |
public: |
| 58 |
struct Chunk { |
| 59 |
imColor color; |
| 60 |
std::string_view::size_type pos; |
| 61 |
}; |
| 62 |
|
| 63 |
private: |
| 64 |
std::string line; |
| 65 |
std::vector<Chunk> chunks; |
| 66 |
}; |
| 67 |
|
| 68 |
} |
| 69 |
|
| 70 |
#endif |