Give a name to the TUI SingleKey keymap
authorTom Tromey <tom@tromey.com>
Tue, 10 Sep 2019 23:25:35 +0000 (17:25 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 18 Sep 2019 21:03:29 +0000 (15:03 -0600)
Readline 8.0 has a feature that lets an application name a keymap.
This in turn makes it simpler for users to bind keys in keymaps in
their .inputrc.

This patch gives a name to the TUI SingleKey keymap, so that
additional bindings can be made there.  For example:

    $if gdb
    set keymap SingleKey
    "X": "echo hello\\n\n"
    $endif

The call to rl_initialize, in tui_initialize_readline, had to be
removed so that .inputrc was not read too early.  Note that Readline
explicitly documents that this call is not needed.

gdb/ChangeLog
2019-09-18  Tom Tromey  <tom@tromey.com>

* NEWS: Add entry.
* tui/tui.c (tui_initialize_readline): Set name of keymap.  Do not
call rl_initialize.
(tui_enable): Do not call rl_initialize.

gdb/doc/ChangeLog
2019-09-18  Tom Tromey  <tom@tromey.com>

* gdb.texinfo (Editing): Document readline application name.
(TUI Single Key Mode): Document TUI SingleKey keymap name.

gdb/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/tui/tui.c

index 1ad694a20a68e48d900888e75274c642d8a8ae5a..f8228b459ce661167c7540aaba6ba1a34aeb75f8 100644 (file)
@@ -1,3 +1,10 @@
+2019-09-18  Tom Tromey  <tom@tromey.com>
+
+       * NEWS: Add entry.
+       * tui/tui.c (tui_initialize_readline): Set name of keymap.  Do not
+       call rl_initialize.
+       (tui_enable): Do not call rl_initialize.
+
 2019-09-18  Christian Groessler  <chris@groessler.org>
 
        * alpha-linux-nat.c: Include gdbarch.h.
index 947b743533744a30e11bc0cb38921ca5077455ae..1fefd814095e75855b5f269d11cdd38458727101 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -323,6 +323,10 @@ maint show test-options-completion-result
   GDB now bundles GNU readline 8.0, but if you choose to use
   --with-system-readline, only readline >= 7.0 can be used.
 
+* The TUI SingleKey keymap is now named "SingleKey".  This can be used
+  from .inputrc to bind keys in this keymap.  This feature is only
+  available when gdb is built against GNU readline 8.0 or later.
+
 *** Changes in GDB 8.3
 
 * GDB and GDBserver now support access to additional registers on
index a16d32d48aeae96c735e89cadf7db919927b5a4e..8eaaab3ae1f3564d862de7e7fad8adcb4ec0e198 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-18  Tom Tromey  <tom@tromey.com>
+
+       * gdb.texinfo (Editing): Document readline application name.
+       (TUI Single Key Mode): Document TUI SingleKey keymap name.
+
 2019-09-17  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * gdb.texinfo (Source Path): Additional text to better describe
index f4bfd9f9809b63045feeb416ef644def2f6b87a2..a129ea0aa1b57ec73542790b95e7d9e7e184071d 100644 (file)
@@ -25056,6 +25056,10 @@ for more details about the Readline
 interface.  Users unfamiliar with @sc{gnu} Emacs or @code{vi} are
 encouraged to read that chapter.
 
+@cindex Readline application name
+@value{GDBN} sets the Readline application name to @samp{gdb}.  This
+is useful for conditions in @file{.inputrc}.
+
 @node Command History
 @section Command History
 @cindex command history
@@ -27658,6 +27662,10 @@ with the TUI SingleKey mode.  Once the command is entered the TUI
 SingleKey mode is restored.  The only way to permanently leave
 this mode is by typing @kbd{q} or @kbd{C-x s}.
 
+@cindex SingleKey keymap name
+If @value{GDBN} was built with Readline 8.0 or later, the TUI
+SingleKey keymap will be named @samp{SingleKey}.  This can be used in
+@file{.inputrc} to add additional bindings to this keymap.
 
 @node TUI Commands
 @section TUI-specific Commands
index db34e0c0441cd88a5f9cbb8b0473a92e81f1b84c..5d6b9f320368f2d0e4e37f738622729f01657f34 100644 (file)
@@ -329,13 +329,17 @@ tui_initialize_readline (void)
   int i;
   Keymap tui_ctlx_keymap;
 
-  rl_initialize ();
-
   rl_add_defun ("tui-switch-mode", tui_rl_switch_mode, -1);
   rl_add_defun ("gdb-command", tui_rl_command_key, -1);
   rl_add_defun ("next-keymap", tui_rl_next_keymap, -1);
 
   tui_keymap = rl_make_bare_keymap ();
+
+  /* The named keymap feature was added in Readline 8.0.  */
+#if RL_READLINE_VERSION >= 0x800
+  rl_set_keymap_name ("SingleKey", tui_keymap);
+#endif
+
   tui_ctlx_keymap = rl_make_bare_keymap ();
   tui_readline_standard_keymap = rl_get_keymap ();
 
@@ -467,7 +471,6 @@ tui_enable (void)
       nodelay(w, FALSE);
       nl();
       keypad (w, TRUE);
-      rl_initialize ();
       tui_set_term_height_to (LINES);
       tui_set_term_width_to (COLS);
       def_prog_mode ();
This page took 0.056437 seconds and 4 git commands to generate.