Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions lib/src/embedded_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,29 @@ static void onEscapedInput(EmbeddedCli *cli, char c) {
impl->cursorPos++;
writeToOutput(cli, escSeqCursorLeft);
}

// Home
if (c == 'H' || (c == '~' && (impl->lastChar == '1' || impl->lastChar == '7'))) {
if (impl->cursorPos < impl->cmdSize) {
moveCursor(cli, impl->cmdSize - impl->cursorPos, CURSOR_DIRECTION_BACKWARD);
impl->cursorPos = impl->cmdSize;
}
}
// End
if (c == 'F' || (c == '~' && (impl->lastChar == '4' || impl->lastChar == '8'))) {
if (impl->cursorPos > 0) {
moveCursor(cli, impl->cursorPos, CURSOR_DIRECTION_FORWARD);
impl->cursorPos = 0;
}
}
// Delete
if (c == '~' && impl->lastChar == '3' && impl->cursorPos > 0) {
size_t insertPos = strlen(impl->cmdBuffer) - impl->cursorPos;
memmove(&impl->cmdBuffer[insertPos], &impl->cmdBuffer[insertPos + 1], impl->cursorPos);
--impl->cmdSize;
--impl->cursorPos;
writeToOutput(cli, escSeqDeleteChar);
}
}
}

Expand Down Expand Up @@ -878,12 +901,7 @@ static void parseCommand(EmbeddedCli *cli) {
embeddedCliTokenizeArgs(cmdArgs);
// currently, output is blank line, so we can just print directly
SET_FLAG(impl->flags, CLI_FLAG_DIRECT_PRINT);
// check if help was requested (help is printed when no other options are set)
if (cmdArgs != NULL && (strcmp(cmdArgs, "-h") == 0 || strcmp(cmdArgs, "--help") == 0)) {
printBindingHelp(cli, &impl->bindings[i]);
} else {
impl->bindings[i].binding(cli, cmdArgs, impl->bindings[i].context);
}
impl->bindings[i].binding(cli, cmdArgs, impl->bindings[i].context);
UNSET_U8FLAG(impl->flags, CLI_FLAG_DIRECT_PRINT);
return;
}
Expand Down