19 m_history(config.historyBuffer, config.numberOfEntries, config.lineBufferSize),
21 m_tab(m_printer, m_commands, config.lineBuffer, config.lineBufferSize, config.prompt),
22 m_processor(m_commands, m_printer, config.lineBuffer, config.lineBufferSize, config.argvBuffer, config.argvBufferSize),
23 m_arrow(m_printer, m_count, config.echo)
25 m_printer.error.connect(m_onErrorSlot);
26 m_arrow.up.connect(m_onArrowUpSlot);
27 m_arrow.down.connect(m_onArrowDownSlot);
28 m_arrow.error.connect(m_onErrorSlot);
29 m_tab.error.connect(m_onErrorSlot);
30 m_tab.done.connect(m_onTabDoneSlot);
31 m_processor.error.connect(m_onErrorSlot);
36 m_commands.pushBack(cmd);
41 m_printer.dataWritten.disconnect(m_restartShell);
42 m_printer.dataWritten.connect(m_readNextCharSlot);
51void Shell::onCharAvailable(
char character)
53 m_printer.dataAvailable.disconnect(m_onCharAvailableSlot);
60 m_processor.done.connect(m_onExecutedSlot);
73 m_printer.dataWritten.connect(m_readNextCharSlot);
74 m_printer.
print(
"\b \b", m_config.
echo ? 1 : 3);
85 if (m_config.
echo && character != kDelete && character !=
'\b')
87 m_printer.dataWritten.connect(m_readNextCharSlot);
88 m_printer.
print(character, 1);
97void Shell::onTabDone(
size_t charCount)
106void Shell::onExecuted()
108 m_processor.done.disconnect(m_onExecutedSlot);
109 m_printer.dataWritten.connect(m_restartShell);
112 m_printer.
print(
"\r\n");
115void Shell::onArrowUp()
118 updateStateAndPrint();
120void Shell::onArrowDown()
123 updateStateAndPrint();
126void Shell::updateStateAndPrint()
128 m_count = std::char_traits<char>::length(m_config.
lineBuffer);
129 m_printer.dataWritten.connect(m_readNextCharSlot);
133void Shell::onError(Error error)
138 m_printer.dataAvailable.connect(m_onCharAvailableSlot);
147void Shell::readNextCharacter()
149 m_printer.dataWritten.disconnect(m_readNextCharSlot);
150 m_printer.dataAvailable.connect(m_onCharAvailableSlot);
Class for using UART hardware.
void start()
Starts the reading process.
@ OnSecondChar_UnexpectedChar
@ OnThirdChar_UnexpectedChar
Wrapper class for shell command. The user has to create object of this class for adding their functio...
void insert(std::string_view command)
Inserts a command.
void handleArrowUp(char commandBuffer[])
Performes a lookup based on an up-arrow key stroke.
void handleArrowDown(char commandBuffer[])
Performes a lookup based on an down-arrow key stroke.
void print(char character, size_t count)
Prints a single character count times.
void readCharacter()
Triggers a read cyle for reading a single character.
void loadCommand()
Load a command for execution according to the current command line.
void execLoadedCommand()
Execute the currenty loaded command. Returns with no error if no command is loaded....
void start()
Starts the reading process of the shell. The user should call this function once.
void addCommand(Command &cmd)
Adds a command to the shell.
void loop()
Performs the command execution.
Shell(UartHardware &uart, const Config &config)
Constructor.
void start(size_t charCount)
Starts the auto completion.
Configuarion parameters of the shell.
const size_t lineBufferSize