1#ifndef COMMANDCONSOLE_HH
2#define COMMANDCONSOLE_HH
16class GlobalCommandController;
17class EventDistributor;
30 explicit ConsoleLine(std::string line, uint32_t rgb = 0xffffff);
34 void addChunk(std::string_view text, uint32_t rgb);
38 [[nodiscard]]
size_t numChars()
const;
40 [[nodiscard]]
const std::string&
str()
const {
return line; }
44 [[nodiscard]]
size_t numChunks()
const {
return chunks.size(); }
46 [[nodiscard]] uint32_t
chunkColor(
size_t i)
const;
48 [[nodiscard]] std::string_view
chunkText(
size_t i)
const;
50 [[nodiscard]]
const auto&
getChunks()
const {
return chunks; }
56 std::string_view::size_type pos;
58 std::vector<Chunk> chunks;
73 [[nodiscard]]
unsigned getScrollBack()
const {
return consoleScrollBack; }
76 void setColumns(
unsigned columns_) { columns = columns_; }
77 [[nodiscard]]
unsigned getColumns()
const {
return columns; }
78 void setRows(
unsigned rows_) { rows = rows_; }
79 [[nodiscard]]
unsigned getRows()
const {
return rows; }
81 [[nodiscard]]
const auto&
getLines()
const {
return lines; }
85 void output(std::string_view text)
override;
86 [[nodiscard]]
unsigned getOutputColumns()
const override;
89 int signalEvent(
const Event& event)
override;
91 bool handleEvent(
const KeyEvent& keyEvent);
93 void commandExecute();
94 void scroll(
int delta);
95 void gotoStartOfWord();
96 void deleteToStartOfWord();
98 void deleteToEndOfWord();
105 void normalKey(uint32_t chr);
106 void putCommandHistory(
const std::string& command);
107 void newLineConsole(std::string line);
110 void resetScrollBack();
112 [[nodiscard]]
ConsoleLine highLight(std::string_view line);
116 void print(std::string_view text,
unsigned rgb = 0xffffff);
129 static constexpr int LINES_HISTORY = 1000;
131 std::string commandBuffer;
134 std::string currentLine;
136 unsigned commandScrollBack;
139 int consoleScrollBack;
141 unsigned cursorPosition;
142 bool executingCommand =
false;
CommandConsole(GlobalCommandController &commandController, EventDistributor &eventDistributor, Display &display)
unsigned getScrollBack() const
gl::ivec2 getCursorPosition() const
BooleanSetting & getConsoleSetting()
void setRows(unsigned rows_)
unsigned getColumns() const
const auto & getLines() const
void setColumns(unsigned columns_)
This class represents a single text line in the console.
std::string_view chunkText(size_t i) const
Get the text for the i-th chunk.
const std::string & str() const
Get the total string, ignoring color differences.
ConsoleLine()=default
Construct empty line.
const auto & getChunks() const
size_t numChars() const
Get the number of UTF8 characters in this line.
size_t numChunks() const
Get the number of different chunks.
uint32_t chunkColor(size_t i) const
Get the color for the i-th chunk.
void addChunk(std::string_view text, uint32_t rgb)
Append a chunk with a (different) color.
Represents the output window/screen of openMSX.
A Setting with an integer value.
This file implemented 3 utility functions: