Add completion styling
Readline has a styling feature for completion -- if it is enabled, the common prefix of completions will be displayed in a different style. This doesn't work in gdb, because gdb implements its own completer. This patch implements the feature. However, it doesn't directly use the Readline feature, because gdb can do a bit better: it can let the user control the styling using the existing mechanisms. This version incorporates an Emacs idea, via Eli: style the prefix, the "difference character", and the suffix differently. gdb/ChangeLog 2020-05-23 Tom Tromey <tom@tromey.com> * NEWS: Add entry for completion styling. * completer.c (_rl_completion_prefix_display_length): Move declaration earlier. (gdb_fnprint): Use completion_style. (gdb_display_match_list_1): Likewise. * cli/cli-style.c (completion_prefix_style) (completion_difference_style, completion_suffix_style): New globals. (_initialize_cli_style): Register new globals. * cli/cli-style.h (completion_prefix_style) (completion_difference_style, completion_suffix_style): Declare. gdb/doc/ChangeLog 2020-05-23 Tom Tromey <tom@tromey.com> * gdb.texinfo (Output Styling): Mention completion styling. (Editing): Mention readline completion styling. gdb/testsuite/ChangeLog 2020-05-23 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add completion styling test. * lib/gdb-utils.exp (style): Add completion styles.
This commit is contained in:
parent
51e2cfa2dc
commit
eca1f90cf4
10 changed files with 172 additions and 7 deletions
|
@ -98,6 +98,21 @@ cli_style_option metadata_style ("metadata", ui_file_style::DIM);
|
|||
|
||||
/* See cli-style.h. */
|
||||
|
||||
cli_style_option completion_prefix_style ("completion-prefix",
|
||||
ui_file_style::DIM);
|
||||
|
||||
/* See cli-style.h. */
|
||||
|
||||
cli_style_option completion_difference_style ("completion-difference",
|
||||
ui_file_style::MAGENTA);
|
||||
|
||||
/* See cli-style.h. */
|
||||
|
||||
cli_style_option completion_suffix_style ("completion-suffix",
|
||||
ui_file_style::NONE);
|
||||
|
||||
/* See cli-style.h. */
|
||||
|
||||
cli_style_option::cli_style_option (const char *name,
|
||||
ui_file_style::basic_color fg)
|
||||
: changed (name),
|
||||
|
@ -366,6 +381,33 @@ your data, for example \"<unavailable>\""),
|
|||
&style_set_list, &style_show_list,
|
||||
false);
|
||||
|
||||
completion_prefix_style.add_setshow_commands (no_class, _("\
|
||||
Completion prefix display styling.\n\
|
||||
Configure completion prefix colors and display intensity\n\
|
||||
The \"completion-prefix\" style is used when GDB displays the shared\n\
|
||||
prefix common to the possible completions."),
|
||||
&style_set_list,
|
||||
&style_show_list,
|
||||
false);
|
||||
|
||||
completion_difference_style.add_setshow_commands (no_class, _("\
|
||||
Completion difference display styling.\n\
|
||||
Configure completion difference colors and display intensity\n\
|
||||
The \"completion-difference\" style is used when GDB displays the\n\
|
||||
character that differs between the possible completions."),
|
||||
&style_set_list,
|
||||
&style_show_list,
|
||||
false);
|
||||
|
||||
completion_suffix_style.add_setshow_commands (no_class, _("\
|
||||
Completion suffix display styling.\n\
|
||||
Configure completion suffix colors and display intensity\n\
|
||||
The \"completion-suffix\" style is used when GDB displays the suffix\n\
|
||||
of the possible completions."),
|
||||
&style_set_list,
|
||||
&style_show_list,
|
||||
false);
|
||||
|
||||
tui_border_style.add_setshow_commands (no_class, _("\
|
||||
TUI border display styling.\n\
|
||||
Configure TUI border colors\n\
|
||||
|
|
|
@ -124,6 +124,15 @@ extern cli_style_option tui_border_style;
|
|||
/* The border style of a TUI window that does have the focus. */
|
||||
extern cli_style_option tui_active_border_style;
|
||||
|
||||
/* The style for the common prefix of completions. */
|
||||
extern cli_style_option completion_prefix_style;
|
||||
|
||||
/* The style for the difference character of completions. */
|
||||
extern cli_style_option completion_difference_style;
|
||||
|
||||
/* The style for the suffix of completions. */
|
||||
extern cli_style_option completion_suffix_style;
|
||||
|
||||
/* True if source styling is enabled. */
|
||||
extern bool source_styling;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue