shell: meta-keys handle condition update

Meta keys are active when they are enabled and when shell echo is set
to on.
Updated meta keys description in shell's Kconfig file.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
Jakub Rzeszutko 2019-01-27 13:09:39 +01:00 committed by Carles Cufí
commit e7b55a6eb5
3 changed files with 12 additions and 6 deletions

View file

@ -88,8 +88,9 @@ config SHELL_METAKEYS
bool "Enable metakeys" bool "Enable metakeys"
default y default y
help help
Enables shell metakeys: Home, End, ctrl+a, ctrl+c, ctrl+e, ctrl+l, Enables shell meta keys: Ctrl+a, Ctrl+b, Ctrl+c, Ctrl+d, Ctrl+e,
ctrl+u, ctrl+w Ctrl+f, Ctrl+k, Ctrl+l, Ctrl+u, Ctrl+w, Alt+b, Alt+f
Meta keys will not be active when shell echo is set to off.
config SHELL_HELP config SHELL_HELP
bool "Enable help message" bool "Enable help message"

View file

@ -949,7 +949,7 @@ static void state_collect(const struct shell *shell)
if (isprint((int) data)) { if (isprint((int) data)) {
flag_history_exit_set(shell, true); flag_history_exit_set(shell, true);
shell_op_char_insert(shell, data); shell_op_char_insert(shell, data);
} else { } else if (flag_echo_get(shell)) {
ctrl_metakeys_handle(shell, data); ctrl_metakeys_handle(shell, data);
} }
break; break;
@ -960,11 +960,11 @@ static void state_collect(const struct shell *shell)
if (data == '[') { if (data == '[') {
receive_state_change(shell, receive_state_change(shell,
SHELL_RECEIVE_ESC_SEQ); SHELL_RECEIVE_ESC_SEQ);
} else { break;
} else if (flag_echo_get(shell)) {
alt_metakeys_handle(shell, data); alt_metakeys_handle(shell, data);
receive_state_change(shell,
SHELL_RECEIVE_DEFAULT);
} }
receive_state_change(shell, SHELL_RECEIVE_DEFAULT);
break; break;
case SHELL_RECEIVE_ESC_SEQ: case SHELL_RECEIVE_ESC_SEQ:

View file

@ -261,6 +261,11 @@ static void data_insert(const struct shell *shell, const char *data, u16_t len)
void char_replace(const struct shell *shell, char data) void char_replace(const struct shell *shell, char data)
{ {
shell->ctx->cmd_buff[shell->ctx->cmd_buff_pos++] = data; shell->ctx->cmd_buff[shell->ctx->cmd_buff_pos++] = data;
if (!flag_echo_get(shell)) {
return;
}
shell_raw_fprintf(shell->fprintf_ctx, "%c", data); shell_raw_fprintf(shell->fprintf_ctx, "%c", data);
if (shell_cursor_in_empty_line(shell)) { if (shell_cursor_in_empty_line(shell)) {
cursor_next_line_move(shell); cursor_next_line_move(shell);