mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-07 20:30:52 +02:00
new readline application hook to print macro key sequences and values; change bind -X default output format; bind -x accepts more input formats; quoting changes for pathname expansion patterns
This commit is contained in:
+15
-9
@@ -68,6 +68,9 @@ extern int errno;
|
||||
/* Variables exported by this file. */
|
||||
Keymap rl_binding_keymap;
|
||||
|
||||
/* Functions exported by this file. */
|
||||
rl_macro_print_func_t *rl_macro_display_hook = (rl_macro_print_func_t *)NULL;
|
||||
|
||||
static int _rl_skip_to_delim (char *, int, int);
|
||||
|
||||
static void _rl_init_file_error (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
|
||||
@@ -2861,16 +2864,19 @@ _rl_macro_dumper_internal (int print_readably, Keymap map, char *prefix)
|
||||
{
|
||||
case ISMACR:
|
||||
keyname = _rl_get_keyname (key);
|
||||
if (print_readably < 0)
|
||||
out = savestring ((char *)map[key].function);
|
||||
else
|
||||
out = _rl_untranslate_macro_value ((char *)map[key].function, 0);
|
||||
out = _rl_untranslate_macro_value ((char *)map[key].function, 0);
|
||||
|
||||
if (print_readably < 0)
|
||||
fprintf (rl_outstream, "\"%s%s\": %s\n", prefix ? prefix : "",
|
||||
keyname,
|
||||
out ? out : "");
|
||||
else if (print_readably > 0)
|
||||
/* If the application wants to print macros, let it. Give it the
|
||||
ascii-fied value with backslash escapes, so it will have to use
|
||||
rl_macro_bind (with its call to rl_translate_keyseq) to get the
|
||||
same value back. */
|
||||
if (rl_macro_display_hook)
|
||||
{
|
||||
(*rl_macro_display_hook) (keyname, out, print_readably, prefix);
|
||||
break;
|
||||
}
|
||||
|
||||
if (print_readably)
|
||||
fprintf (rl_outstream, "\"%s%s\": \"%s\"\n", prefix ? prefix : "",
|
||||
keyname,
|
||||
out ? out : "");
|
||||
|
||||
@@ -515,6 +515,15 @@ By default, this is set to @code{rl_deprep_terminal}
|
||||
(@pxref{Terminal Management}).
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {void} rl_macro_display_hook
|
||||
If set, this points to a function that @code{rl_macro_dumper} will call to
|
||||
display a key sequence bound to a macro.
|
||||
It is called with the key sequence, the "untranslated" macro value (i.e.,
|
||||
with backslash escapes included, as when passed to @code{rl_macro_bind}),
|
||||
the @code{readable} argument passed to @code{rl_macro_dumper}, and any
|
||||
prefix to display before the key sequence.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {Keymap} rl_executing_keymap
|
||||
This variable is set to the keymap (@pxref{Keymaps}) in which the
|
||||
currently executing Readline function was found.
|
||||
@@ -1354,12 +1363,10 @@ use @code{rl_generic_bind} instead.
|
||||
@deftypefun void rl_macro_dumper (int readable)
|
||||
Print the key sequences bound to macros and their values, using
|
||||
the current keymap, to @code{rl_outstream}.
|
||||
If the application has assigned a value to @code{rl_macro_display_hook},
|
||||
@code{rl_macro_dumper} calls it instead of printing anything.
|
||||
If @var{readable} is greater than zero, the list is formatted in such a way
|
||||
that it can be made part of an @code{inputrc} file and re-read.
|
||||
If @var{readable} is less than zero, the list is printed in a
|
||||
"translated" form that can be used by applications that wish to bind
|
||||
key sequences directly without calling @code{rl_parse_and_bind}
|
||||
(e.g., by calling @code{rl_generic_bind}).
|
||||
|
||||
@end deftypefun
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Copyright (C) 1988-2023 Free Software Foundation, Inc.
|
||||
@set EDITION 8.3
|
||||
@set VERSION 8.3
|
||||
|
||||
@set UPDATED 17 July 2023
|
||||
@set UPDATED 31 July 2023
|
||||
@set UPDATED-MONTH July 2023
|
||||
|
||||
@set LASTCHANGE Mon Jul 17 16:47:01 EDT 2023
|
||||
@set LASTCHANGE Mon Jul 31 10:09:09 EDT 2023
|
||||
|
||||
@@ -623,6 +623,8 @@ extern rl_voidfunc_t *rl_redisplay_function;
|
||||
extern rl_vintfunc_t *rl_prep_term_function;
|
||||
extern rl_voidfunc_t *rl_deprep_term_function;
|
||||
|
||||
extern rl_macro_print_func_t *rl_macro_display_hook;
|
||||
|
||||
/* Dispatch variables. */
|
||||
extern Keymap rl_executing_keymap;
|
||||
extern Keymap rl_binding_keymap;
|
||||
|
||||
@@ -57,6 +57,9 @@ typedef int rl_compignore_func_t (char **);
|
||||
|
||||
typedef void rl_compdisp_func_t (char **, int, int);
|
||||
|
||||
/* Functions for displaying key bindings. Currently only one. */
|
||||
typedef void rl_macro_print_func_t (const char *, const char *, int, const char *);
|
||||
|
||||
/* Type for input and pre-read hook functions like rl_event_hook */
|
||||
typedef int rl_hook_func_t (void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user