shell: add Ctrl+N and Ctrl+P meta-keys
Ctrl+N - moves in history to next entry Ctrl+P - moves in history to previous entry Behavior of those meta-keys is the same as in bash and emacs, which makes Zephyr shell even more familiar to play with. Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
This commit is contained in:
parent
74818bcb49
commit
0d6fabe6c3
3 changed files with 12 additions and 2 deletions
|
@ -801,6 +801,14 @@ static void ctrl_metakeys_handle(const struct shell *shell, char data)
|
|||
shell_print_prompt_and_cmd(shell);
|
||||
break;
|
||||
|
||||
case SHELL_VT100_ASCII_CTRL_N: /* CTRL + N */
|
||||
history_handle(shell, false);
|
||||
break;
|
||||
|
||||
case SHELL_VT100_ASCII_CTRL_P: /* CTRL + P */
|
||||
history_handle(shell, true);
|
||||
break;
|
||||
|
||||
case SHELL_VT100_ASCII_CTRL_U: /* CTRL + U */
|
||||
shell_op_cursor_home_move(shell);
|
||||
cmd_buffer_clear(shell);
|
||||
|
|
|
@ -288,8 +288,8 @@ static int cmd_help(const struct shell *shell, size_t argc, char **argv)
|
|||
shell_print(shell,
|
||||
"Shell supports following meta-keys:\n"
|
||||
"Ctrl+a, Ctrl+b, Ctrl+c, Ctrl+d, Ctrl+e, Ctrl+f, Ctrl+k,"
|
||||
" Ctrl+l, Ctrl+u, Ctrl+w\nAlt+b, Alt+f.\nPlease refer to"
|
||||
" shell documentation for more details.");
|
||||
" Ctrl+l, Ctrl+n, Ctrl+p, Ctrl+u, Ctrl+w\nAlt+b, Alt+f.\n"
|
||||
"Please refer to shell documentation for more details.");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#define SHELL_VT100_ASCII_CTRL_F (0x06)
|
||||
#define SHELL_VT100_ASCII_CTRL_K (0x0B)
|
||||
#define SHELL_VT100_ASCII_CTRL_L (0x0C)
|
||||
#define SHELL_VT100_ASCII_CTRL_N (0x0E)
|
||||
#define SHELL_VT100_ASCII_CTRL_P (0x10)
|
||||
#define SHELL_VT100_ASCII_CTRL_U (0x15)
|
||||
#define SHELL_VT100_ASCII_CTRL_W (0x17)
|
||||
#define SHELL_VT100_ASCII_ALT_B (0x62)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue