This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Call nonl before wgetch in TUI
- From: Tom Tromey <tromey at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 6 Oct 2018 22:01:07 -0000
- Subject: [binutils-gdb] Call nonl before wgetch in TUI
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7a9569281a63e472750e3b7b481e2cdf5c931ed8
commit 7a9569281a63e472750e3b7b481e2cdf5c931ed8
Author: Tom Tromey <tom@tromey.com>
Date: Mon Sep 3 15:23:48 2018 -0600
Call nonl before wgetch in TUI
PR tui/28819 points out that, in the TUI, the C-j and C-m keys cannot
be bound differently in one's ~/.inputrc. However, this works in
other readline applications.
The bug is that the TUI uses curses' "nl" mode, which causes wgetch to
return the same value for both keys. There is a "nonl" mode, but it
also affects output.
This patch fixes the bug by arranging to call nonl before reading a
key and then nl afterward. This avoids any potential problem with
changing the output if gdb was to use nonl globally.
gdb/ChangeLog
2018-10-06 Tom Tromey <tom@tromey.com>
PR tui/28819:
* tui/tui-io.c (gdb_wgetch): New function.
(tui_mld_getc, tui_getc): Use it.
Diff:
---
gdb/ChangeLog | 6 ++++++
gdb/tui/tui-io.c | 21 ++++++++++++++++++---
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a533ffd..28e969c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2018-10-06 Tom Tromey <tom@tromey.com>
+
+ PR tui/28819:
+ * tui/tui-io.c (gdb_wgetch): New function.
+ (tui_mld_getc, tui_getc): Use it.
+
2018-10-05 Tom Tromey <tom@tromey.com>
* sol-thread.c (sol_thread_target::wait): Rename inner
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index c7df50a..4476151 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -412,6 +412,21 @@ tui_mld_beep (const struct match_list_displayer *displayer)
beep ();
}
+/* A wrapper for wgetch that enters nonl mode. We We normally want
+ curses' "nl" mode, but when reading from the user, we'd like to
+ differentiate between C-j and C-m, because some users bind these
+ keys differently in their .inputrc. So, put curses into nonl mode
+ just when reading from the user. See PR tui/20819. */
+
+static int
+gdb_wgetch (WINDOW *win)
+{
+ nonl ();
+ int r = wgetch (win);
+ nl ();
+ return r;
+}
+
/* Helper function for tui_mld_read_key.
This temporarily replaces tui_getc for use during tab-completion
match list display. */
@@ -420,7 +435,7 @@ static int
tui_mld_getc (FILE *fp)
{
WINDOW *w = TUI_CMD_WIN->generic.handle;
- int c = wgetch (w);
+ int c = gdb_wgetch (w);
return c;
}
@@ -612,7 +627,7 @@ tui_getc (FILE *fp)
tui_readline_output (0, 0);
#endif
- ch = wgetch (w);
+ ch = gdb_wgetch (w);
/* The \n must be echoed because it will not be printed by
readline. */
@@ -659,7 +674,7 @@ tui_getc (FILE *fp)
int ch_pending;
nodelay (w, TRUE);
- ch_pending = wgetch (w);
+ ch_pending = gdb_wgetch (w);
nodelay (w, FALSE);
/* If we have pending input following a start sequence, call the stdin