18 m_lineBuffer(lineBuffer),
19 m_lineBufferSize(lineBufferSize),
33 m_charCount = charCount;
35 m_current = m_commands.cbegin();
44bool Tabulator::prefixMatch(std::string_view sub, std::string_view str)
const
46 if (sub.size() > str.size())
48 str.remove_suffix(str.size() - sub.size());
52void Tabulator::searchMatches()
54 for (; m_current != m_commands.cend(); m_current++)
56 if (prefixMatch(std::string_view(m_lineBuffer, m_charCount), m_current->name()))
59 m_lastMatch = m_current;
60 m_printer.dataWritten.connect(m_printCommandNameSlot);
61 m_printer.
print(
"\r\n");
66 if (m_matchCount == 1)
68 m_charCount = m_lastMatch->name().size();
69 std::copy(m_lastMatch->name().begin(), m_lastMatch->name().end(), m_lineBuffer);
70 m_lineBuffer[m_charCount] = 0;
73 if (m_matchCount != 0)
75 m_printer.dataWritten.clear();
76 m_printer.dataWritten.connect(m_updatePromptSlot);
77 m_printer.
print(
"\r\n");
85void Tabulator::printCommandName()
87 m_printer.dataWritten.disconnect(m_printCommandNameSlot);
88 m_printer.dataWritten.connect(m_continueSearchSlot);
89 m_printer.
print(m_current->name());
92void Tabulator::continueSearch()
94 m_printer.dataWritten.disconnect(m_continueSearchSlot);
99void Tabulator::updatePrompt()
101 m_printer.dataWritten.clear();
102 m_printer.dataWritten.connect(m_printCommandSlot);
103 m_printer.
print(kPrompt);
106void Tabulator::printCommand()
108 m_printer.dataWritten.clear();
109 m_printer.dataWritten.connect(m_onDoneSlot);
110 m_printer.
print(m_lineBuffer);
113void Tabulator::onDone()
115 m_printer.dataWritten.disconnect(m_onDoneSlot);
Class for representing errors. Every error should have a unique source code. As a user feel encourage...
LinkedList is an managed double linked list implementation.
Class for string related UART communication. Using this class outside of an esh-context can make sens...
void print(char character, size_t count)
Prints a single character count times.
void start(size_t charCount)
Starts the auto completion.
bool isBusy() const
Returns the busy-flag.
Tabulator(Printer &printer, const LinkedList< Command > &commands, char lineBuffer[], size_t lineBufferSize, std::string_view prompt)
Constructor.