From eca1f90cf47a2edc1a1cd22e12c6c0f3b900654e Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 23 May 2020 09:23:09 -0600 Subject: 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 * 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 * gdb.texinfo (Output Styling): Mention completion styling. (Editing): Mention readline completion styling. gdb/testsuite/ChangeLog 2020-05-23 Tom Tromey * gdb.base/style.exp: Add completion styling test. * lib/gdb-utils.exp (style): Add completion styles. --- gdb/testsuite/lib/gdb-utils.exp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gdb/testsuite/lib/gdb-utils.exp') diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp index 9741f0a9591..98bdd7206a4 100644 --- a/gdb/testsuite/lib/gdb-utils.exp +++ b/gdb/testsuite/lib/gdb-utils.exp @@ -55,6 +55,8 @@ proc style {str style} { variable { set style 36 } address { set style 34 } metadata { set style 2 } + completion-prefix { set style 2 } + completion-difference { set style 35 } } return "\033\\\[${style}m${str}\033\\\[m" } -- cgit v1.2.1