return _rl_function_of_keyseq_internal (keyseq, len, map, type);
}
+/* Assuming there is a numeric argument at the beginning of KEYSEQ (the
+ caller is responsible for checking), return the index of the portion of
+ the key sequence following the numeric argument. If there's no numeric
+ argument (?), or if KEYSEQ consists solely of a numeric argument (?),
+ return -1. */
+int
+rl_trim_arg_from_keyseq (const char *keyseq, size_t len, Keymap map)
+{
+ register int i, j, parsing_digits;
+ unsigned char ic;
+ Keymap map0;
+
+ if (map == 0)
+ map = _rl_keymap;
+ map0 = map;
+
+ /* The digits following the initial one (e.g., the binding to digit-argument)
+ or the optional `-' in a binding to digit-argument or universal-argument
+ are not added to rl_executing_keyseq. This is basically everything read by
+ rl_digit_loop. The parsing_digits logic is here in case they ever are. */
+ for (i = j = parsing_digits = 0; keyseq && i < len; i++)
+ {
+ ic = keyseq[i];
+
+ if (parsing_digits)
+ {
+ if (_rl_digit_p (ic))
+ {
+ j = i + 1;
+ continue;
+ }
+ parsing_digits = 0;
+ }
+
+ if (map[ic].type == ISKMAP)
+ {
+ if (i + 1 == len)
+ return -1;
+ map = FUNCTION_TO_KEYMAP (map, ic);
+ continue;
+ }
+ if (map[ic].type == ISFUNC)
+ {
+#if defined (VI_MODE)
+ if (map[ic].function != rl_digit_argument && map[ic].function != rl_universal_argument && map[ic].function != rl_vi_arg_digit)
+#else
+ if (map[ic].function != rl_digit_argument && map[ic].function != rl_universal_argument)
+#endif
+ return (j);
+
+ /* We don't bother with a keyseq that is only a numeric argument */
+ if (i + 1 == len)
+ return -1;
+
+ map = map0;
+ parsing_digits = 1;
+
+ /* This logic should be identical to rl_digit_loop */
+ /* We accept M-- as equivalent to M--1, C-u- as equivalent to C-u-1
+ but set parsing_digits to 2 to note that we saw `-' */
+ if (map[ic].function == rl_universal_argument && (i + 1 == '-'))
+ {
+ i++;
+ parsing_digits = 2;
+ }
+ if (map[ic].function == rl_digit_argument && ic == '-')
+ {
+ parsing_digits = 2;
+ }
+ j = i + 1;
+ }
+ }
+
+ /* If we're still parsing digits by the time we get here, we don't allow a
+ key sequence that consists solely of a numeric argument */
+ return -1;
+}
+
/* The last key bindings file read. */
static char *last_readline_init_file = (char *)NULL;
"Meta", "M-", (const char *)NULL
};
+/* Forward declarations */
+static int parser_if (char *);
+static int parser_else (char *);
+static int parser_endif (char *);
+static int parser_include (char *);
+
/* Conditionals. */
/* Calling programs set this to have their argv[0]. */
{ "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 },
{ "disable-completion", &rl_inhibit_completion, 0 },
{ "echo-control-characters", &_rl_echo_control_chars, 0 },
+ { "enable-active-region", &_rl_enable_active_region, 0 },
{ "enable-bracketed-paste", &_rl_enable_bracketed_paste, V_SPECIAL },
{ "enable-keypad", &_rl_enable_keypad, 0 },
{ "enable-meta-key", &_rl_enable_meta, 0 },
char cur_face;
for (cur_face = FACE_NORMAL, i = 0; i < n; i++)
- putc_face (str[i], face[i], &cur_face);
+ putc_face ((unsigned char) str[i], face[i], &cur_face);
putc_face (EOF, FACE_NORMAL, &cur_face);
}
((nfd-new) < (prompt_last_invisible-(current_line*_rl_screenwidth+prompt_invis_chars_first_line))))
ADJUST_CPOS (wrap_offset - prompt_invis_chars_first_line);
- /* XXX - what happens if wrap_offset == prompt_invis_chars_first_line
- and we are drawing the first line (current_line == 0)? We should
- adjust by _rl_last_c_pos -= prompt_invis_chars_first_line */
+ /* What happens if wrap_offset == prompt_invis_chars_first_line
+ and we are drawing the first line (current_line == 0), or if we
+ are drawing the first line and changing the number of invisible
+ characters in the line? If we're starting to draw before the last
+ invisible character in the prompt, we need to adjust by
+ _rl_last_c_pos -= prompt_invis_chars_first_line. This can happen
+ when we finish reading a digit argument (with the "(arg: N)"
+ prompt) and are switching back to displaying a line with a prompt
+ containing invisible characters, since we have to redraw the
+ entire prompt string. */
+ if ((mb_cur_max > 1 && rl_byte_oriented == 0) &&
+ current_line == 0 && wrap_offset &&
+ displaying_prompt_first_line &&
+ wrap_offset == prompt_invis_chars_first_line &&
+ visible_wrap_offset != current_invis_chars &&
+ visible_wrap_offset != prompt_invis_chars_first_line &&
+ ((nfd-new) < prompt_last_invisible))
+ ADJUST_CPOS (prompt_invis_chars_first_line);
}
}
else /* Delete characters from line. */
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
-.\" Last Change: Tue Mar 24 09:27:30 EDT 2020
+.\" Last Change: Wed Jun 16 09:49:37 EDT 2021
.\"
-.TH READLINE 3 "2020 October 29" "GNU Readline 8.1"
+.TH READLINE 3 "2021 June 16" "GNU Readline 8.1"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
or equal to the value of this variable,
readline will ask whether or not the user wishes to view them;
otherwise they are simply listed
-on the terminal. A negative value causes readline to never ask.
+on the terminal.
+A negative value causes readline to never ask.
.TP
.B convert\-meta (On)
If set to \fBOn\fP, readline will convert characters with the
non-printing characters, which can be used to embed a terminal control
sequence into the mode string.
.TP
+.B enable\-active\-region (On)
+The \fIpoint\fP is the current cursor position, and \fImark\fP refers
+to a saved cursor position.
+The text between the point and mark is referred to as the \fIregion\fP.
+When this variable is set to \fIOn\fP, readline allows certain commands
+to designate the region as \fIactive\fP.
+When the region is active, readline highlights the text in the region using
+the terminal's standout mode.
+The active region shows the text inserted by bracketed-paste and any
+matching text found by incremental and non-incremental history searches.
+.TP
.B enable\-bracketed\-paste (On)
When set to \fBOn\fP, readline will configure the terminal in a way
that will enable it to insert each paste into the editing buffer as a
Move to the end of the input history, i.e., the line currently being
entered.
.TP
+.B
+operate\-and\-get\-next (C\-o)
+Accept the current line for return to the calling application as if a
+newline had been entered,
+and fetch the next line relative to the current line from the history
+for editing.
+A numeric argument, if supplied, specifies the history entry to use instead
+of the current line.
+.TP
+.B
+fetch\-history
+With a numeric argument, fetch that entry from the history list
+and make it the current line.
+Without an argument, move back to the first entry in the history list.
+.TP
.B reverse\-search\-history (C\-r)
Search backward starting at the current line and moving `up' through
the history as necessary. This is an incremental search.
the direction through the history (back or forward).
The history expansion facilities are used to extract the last argument,
as if the "!$" history expansion had been specified.
-.TP
-.B
-operate\-and\-get\-next (C\-o)
-Accept the current line for return to the calling application as if a
-newline had been entered,
-and fetch the next line relative to the current line from the history
-for editing.
-A numeric argument, if supplied, specifies the history entry to use instead
-of the current line.
.PD
.SS Commands for Changing Text
.PD 0
can include NUL.
@end deftypefun
+@deftypefun {int} rl_trim_arg_from_keyseq (const char *keyseq, size_t len, Keymap map)
+If there is a numeric argument at the beginning of @var{keyseq}, possibly
+including digits, return the index of the first character in @var{keyseq}
+following the numeric argument.
+This can be used to skip over the numeric argument (which is available as
+@code{rl_numeric_arg} while traversing the key sequence that invoked the
+current command.
+@end deftypefun
+
@deftypefun {char **} rl_invoking_keyseqs (rl_command_func_t *function)
Return an array of strings representing the key sequences used to
invoke @var{function} in the current keymap.
Applications may indicate that the prompt contains characters that take
up no physical screen space when displayed by bracketing a sequence of
such characters with the special markers @code{RL_PROMPT_START_IGNORE}
-and @code{RL_PROMPT_END_IGNORE} (declared in @file{readline.h}). This may
-be used to embed terminal-specific escape sequences in prompts.
+and @code{RL_PROMPT_END_IGNORE} (declared in @file{readline.h} as
+@samp{\001} and @samp{\002}, respectively).
+This may be used to embed terminal-specific escape sequences in prompts.
@end deftypefun
@deftypefun int rl_set_prompt (const char *prompt)
Signals are asynchronous events sent to a process by the Unix kernel,
sometimes on behalf of another process. They are intended to indicate
-exceptional events, like a user pressing the interrupt key on his terminal,
+exceptional events, like a user pressing the terminal's interrupt key,
or a network connection being broken. There is a class of signals that can
be sent to the process currently reading input from the keyboard. Since
Readline changes the terminal attributes when it is called, it needs to
@deftypevar int rl_completion_query_items
Up to this many items will be displayed in response to a
-possible-completions call. After that, readline asks the user if she is sure
-she wants to see them all. The default value is 100. A negative value
-indicates that Readline should never ask the user.
+possible-completions call. After that, readline asks the user for
+confirmation before displaying them.
+The default value is 100. A negative value
+indicates that Readline should never ask for confirmation.
@end deftypevar
@deftypevar {int} rl_completion_append_character
keybindings installed by default, it is possible to use a different set
of keybindings.
Any user can customize programs that use Readline by putting
-commands in an @dfn{inputrc} file, conventionally in his home directory.
+commands in an @dfn{inputrc} file,
+conventionally in their home directory.
The name of this
@ifset BashFeatures
file is taken from the value of the shell variable @env{INPUTRC}. If
If the number of possible completions is greater than or equal to this value,
Readline will ask whether or not the user wishes to view them;
otherwise, they are simply listed.
-This variable must be set to an integer value greater than or equal to 0.
-A negative value means Readline should never ask.
+This variable must be set to an integer value greater than or equal to zero.
+A zero value means Readline should never ask; negative values are
+treated as zero.
The default limit is @code{100}.
@item convert-meta
sequence into the mode string.
The default is @samp{@@}.
+@item enable-active-region
+@vindex enable-active-region
+The @dfn{point} is the current cursor position, and @dfn{mark} refers
+to a saved cursor position (@pxref{Commands For Moving}).
+The text between the point and mark is referred to as the @dfn{region}.
+When this variable is set to @samp{On}, Readline allows certain commands
+to designate the region as @dfn{active}.
+When the region is active, Readline highlights the text in the region using
+the terminal's standout mode.
+The active region shows the text inserted by bracketed-paste and any
+matching text found by incremental and non-incremental history searches.
+The default is @samp{On}.
+
@item enable-bracketed-paste
@vindex enable-bracketed-paste
When set to @samp{On}, Readline will configure the terminal in a way
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
+@item fetch-history ()
+With a numeric argument, fetch that entry from the history list
+and make it the current line.
+Without an argument, move back to the first entry in the history list.
+
@end ftable
@node Commands For Text
of an @var{inputrc} file. This command is unbound by default.
@ifset BashFeatures
+@item spell-correct-word (C-x s)
+Perform spelling correction on the current word, treating it as a directory
+or filename, in the same way as the @code{cdspell} shell option.
+Word boundaries are the same as those used by @code{shell-forward-word}.
+
@item glob-complete-word (M-g)
The word before point is treated as a pattern for pathname expansion,
with an asterisk implicitly appended. This pattern is used to
@set EDITION 8.1
@set VERSION 8.1
-@set UPDATED 10 March 2021
-@set UPDATED-MONTH March 2021
+@set UPDATED 16 June 2021
+@set UPDATED-MONTH June 2021
-@set LASTCHANGE Wed Mar 10 15:43:49 EST 2021
+@set LASTCHANGE Wed Jun 16 09:50:11 EDT 2021
{ "end-of-history", rl_end_of_history },
{ "end-of-line", rl_end_of_line },
{ "exchange-point-and-mark", rl_exchange_point_and_mark },
+ { "fetch-history", rl_fetch_history },
{ "forward-backward-delete-char", rl_rubout_or_delete },
{ "forward-byte", rl_forward_byte },
{ "forward-char", rl_forward_char },
{ "vi-set-mark", rl_vi_set_mark },
{ "vi-subst", rl_vi_subst },
{ "vi-tilde-expand", rl_vi_tilde_expand },
+ { "vi-undo", rl_vi_undo },
{ "vi-unix-word-rubout", rl_vi_unix_word_rubout },
{ "vi-yank-arg", rl_vi_yank_arg },
{ "vi-yank-pop", rl_vi_yank_pop },
return 0;
}
+/* With an argument, move back that many history lines, else move to the
+ beginning of history. */
+int
+rl_fetch_history (int count, int c)
+{
+ int wanted, nhist;
+
+ /* Giving an argument of n means we want the nth command in the history
+ file. The command number is interpreted the same way that the bash
+ `history' command does it -- that is, giving an argument count of 450
+ to this command would get the command listed as number 450 in the
+ output of `history'. */
+ if (rl_explicit_arg)
+ {
+ nhist = history_base + where_history ();
+ /* Negative arguments count back from the end of the history list. */
+ wanted = (count >= 0) ? nhist - count : -count;
+
+ if (wanted <= 0 || wanted >= nhist)
+ {
+ /* In vi mode, we don't change the line with an out-of-range
+ argument, as for the `G' command. */
+ if (rl_editing_mode == vi_mode)
+ rl_ding ();
+ else
+ rl_beginning_of_history (0, 0);
+ }
+ else
+ rl_get_previous_history (wanted, c);
+ }
+ else
+ rl_beginning_of_history (count, 0);
+
+ return (0);
+}
+
/* The equivalent of the Korn shell C-o operate-and-get-next-history-line
editing command. */
RESIZE_KEYSEQ_BUFFER ();
rl_executing_keyseq[rl_key_sequence_length++] = key;
}
+
+/* `delete' the last character added to the executing key sequence. Use this
+ before calling rl_execute_next to avoid keys being added twice. */
+void
+_rl_del_executing_keyseq (void)
+{
+ if (rl_key_sequence_length > 0)
+ rl_key_sequence_length--;
+}
extern int rl_get_next_history (int, int);
extern int rl_get_previous_history (int, int);
extern int rl_operate_and_get_next (int, int);
+extern int rl_fetch_history (int, int);
/* Bindable commands for managing the mark and region. */
extern int rl_set_mark (int, int);
extern rl_command_func_t *rl_named_function (const char *);
extern rl_command_func_t *rl_function_of_keyseq (const char *, Keymap, int *);
extern rl_command_func_t *rl_function_of_keyseq_len (const char *, size_t, Keymap, int *);
+extern int rl_trim_arg_from_keyseq (const char *, size_t, Keymap);
extern void rl_list_funmap_names (void);
extern char **rl_invoking_keyseqs_in_map (rl_command_func_t *, Keymap);
extern void _rl_term_executing_keyseq (void);
extern void _rl_end_executing_keyseq (void);
extern void _rl_add_executing_keyseq (int);
+extern void _rl_del_executing_keyseq (void);
/* rltty.c */
extern int _rl_disable_tty_signals (void);
_rl_nsearch_abort (_rl_search_cxt *cxt)
{
rl_maybe_unsave_line ();
- rl_clear_message ();
rl_point = cxt->save_point;
rl_mark = cxt->save_mark;
- _rl_fix_point (1);
rl_restore_prompt ();
+ rl_clear_message ();
+ _rl_fix_point (1);
RL_UNSETSTATE (RL_STATE_NSEARCH);
}
/* This typedef is equivalent to the one for Function; it allows us
to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
-typedef RETSIGTYPE SigHandler ();
+typedef RETSIGTYPE SigHandler (int);
#if defined (HAVE_POSIX_SIGNALS)
typedef struct sigaction sighandler_cxt;
aix4.[2-9]*-*gcc*|aix[5-9].*-*gcc*) # lightly tested by jik@cisco.com
SHOBJ_CFLAGS=-fpic
- SHOBJ_LD='ld'
- SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-Wl,-bdynamic -Wl,-bnoentry -Wl,-bexpall'
SHOBJ_XLDFLAGS='-G'
SHLIB_XLDFLAGS='-bM:SRE'
/* Insert key */
static char *_rl_term_kI;
+/* Page up and page down keys */
+static char *_rl_term_kP;
+static char *_rl_term_kN;
+
/* Cursor control */
static char *_rl_term_vs; /* very visible */
static char *_rl_term_ve; /* normal */
{ "kD", &_rl_term_kD }, /* delete */
{ "kH", &_rl_term_kH }, /* home down ?? */
{ "kI", &_rl_term_kI }, /* insert */
+ { "kN", &_rl_term_kN }, /* page down */
+ { "kN", &_rl_term_kP }, /* page up */
{ "kd", &_rl_term_kd },
{ "ke", &_rl_term_ke }, /* end keypad mode */
{ "kh", &_rl_term_kh }, /* home */
_rl_term_goto = _rl_term_pc = _rl_term_ip = (char *)NULL;
_rl_term_ks = _rl_term_ke =_rl_term_vs = _rl_term_ve = (char *)NULL;
_rl_term_kh = _rl_term_kH = _rl_term_at7 = _rl_term_kI = (char *)NULL;
+ _rl_term_kN = _rl_term_kP = (char *)NULL;
_rl_term_so = _rl_term_se = (char *)NULL;
#if defined(HACK_TERMCAP_MOTION)
_rl_term_forward_char = (char *)NULL;
_rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
_rl_term_kh = _rl_term_kH = _rl_term_kI = _rl_term_kD = (char *)NULL;
_rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL;
+ _rl_term_kN = _rl_term_kP = (char *)NULL;
_rl_term_mm = _rl_term_mo = (char *)NULL;
_rl_term_ve = _rl_term_vs = (char *)NULL;
_rl_term_forward_char = (char *)NULL;
rl_bind_keyseq_if_unbound (_rl_term_kD, rl_delete);
rl_bind_keyseq_if_unbound (_rl_term_kI, rl_overwrite_mode); /* Insert */
+ rl_bind_keyseq_if_unbound (_rl_term_kN, rl_history_search_forward); /* Page Down */
+ rl_bind_keyseq_if_unbound (_rl_term_kP, rl_history_search_backward); /* Page Up */
+
_rl_keymap = xkeymap;
}
int
rl_vi_fetch_history (int count, int c)
{
- int wanted;
-
- /* Giving an argument of n means we want the nth command in the history
- file. The command number is interpreted the same way that the bash
- `history' command does it -- that is, giving an argument count of 450
- to this command would get the command listed as number 450 in the
- output of `history'. */
- if (rl_explicit_arg)
- {
- wanted = history_base + where_history () - count;
- if (wanted <= 0)
- rl_beginning_of_history (0, 0);
- else
- rl_get_previous_history (wanted, c);
- }
- else
- rl_beginning_of_history (count, 0);
- return (0);
+ return (rl_fetch_history (count, c));
}
/* Search again for the last thing searched for. */