Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions include/system/readline.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ extern "C"
*
* If a prompt string is used by the application, then the application
* must provide the prompt string to readline() by calling this function.
* This is needed only for tab completion in cases where is it necessary
* to reprint the prompt string.
* This is needed for tab completion, and for line editing's full-line
* redraws (Home, End, history recall, ...), in cases where it is
* necessary to reprint the prompt string.
*
* Input Parameters:
* prompt - The prompt string. This function may then be
Expand All @@ -108,7 +109,7 @@ extern "C"
*
****************************************************************************/

#ifdef CONFIG_READLINE_TABCOMPLETION
#if defined(CONFIG_READLINE_TABCOMPLETION) || defined(CONFIG_READLINE_EDIT)
FAR const char *readline_prompt(FAR const char *prompt);
#else
# define readline_prompt(p)
Expand Down
6 changes: 6 additions & 0 deletions nshlib/nsh_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ int nsh_session(FAR struct console_stdio_s *pstate,

write(OUTFD(pstate), nsh_prompt(), strlen(nsh_prompt()));

#if defined(CONFIG_READLINE_TABCOMPLETION) || defined(CONFIG_READLINE_EDIT)
/* Set the prompt so readline can redraw it for editing features */

readline_prompt(nsh_prompt());
#endif

/* readline() normally returns the number of characters read, but
* will return EOF on end of file or if an error occurs. EOF
* will cause the session to terminate.
Expand Down
27 changes: 27 additions & 0 deletions system/readline/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ config READLINE_MAX_EXTCMDS

endif # READLINE_TABCOMPLETION

config READLINE_EDIT
bool "Command line editing"
default y if !DEFAULT_SMALL
Comment thread
acassis marked this conversation as resolved.
---help---
Build in support for full command-line editing using cursor keys,
Home/End, Delete. Requires a VT100/ANSI-compatible terminal.

config READLINE_EDIT_EMACS
bool "Emacs-style control keys"
default n
depends on READLINE_EDIT
---help---
Enable emacs-style control key bindings:
Ctrl+A Home, Ctrl+E End, Ctrl+K kill-to-end,
Ctrl+U kill-to-start, Ctrl+Left/Right word movement.

config READLINE_CMD_HISTORY
bool "Command line history"
default n
Expand Down Expand Up @@ -96,6 +112,17 @@ config READLINE_CMD_HISTORY_LEN
will be READLINE_CMD_HISTORY_LINELEN x READLINE_CMD_HISTORY_LEN.
Default: 16

config READLINE_EDIT_EMACS_REVERSE_SEARCH
bool "Reverse incremental search (Ctrl+R)"
default y
depends on READLINE_EDIT_EMACS
---help---
Enable bash-style Ctrl+R reverse incremental search through the
command history. Typing narrows the search to the most recent
matching command; Ctrl+R again searches further back; Enter
submits the match; Ctrl+G/Ctrl+C cancels back to the line being
edited before Ctrl+R was pressed.

endif # READLINE_CMD_HISTORY
endif # READLINE_ECHO
endif # SYSTEM_READLINE
Loading
Loading