aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui/tui-io.c
diff options
context:
space:
mode:
authorPatrick Palka <patrick@parcs.ath.cx>2015-01-09 13:27:56 -0500
committerPatrick Palka <patrick@parcs.ath.cx>2015-01-09 13:27:56 -0500
commit588dcc3edbde19f90e76de969dbfa7ab3e17951a (patch)
tree74ff874df9945ec8b323c95d766438bb3f91940d /gdb/tui/tui-io.c
parentede9f622af1f2634c1227a3ed5f5ea44929573d2 (diff)
downloadgdb-588dcc3edbde19f90e76de969dbfa7ab3e17951a.zip
gdb-588dcc3edbde19f90e76de969dbfa7ab3e17951a.tar.gz
gdb-588dcc3edbde19f90e76de969dbfa7ab3e17951a.tar.bz2
Consolidate the custom TUI query hook with the default query hook
This patch primarily rewrites defaulted_query() to use gdb_readline_wrapper() to prompt the user for input, like prompt_for_continue() does. The motivation for this rewrite is to be able to reuse the default query hook in TUI, obviating the need for a custom TUI query hook. However, having TUI use the default query mechanism exposed a couple of latent bugs in tui_redisplay_readline() related to the handling of multi-line prompts, in particular GDB's multi-line quit prompt. The first issue is an off-by-one error in the calculation of the height of the prompt. The check in question should be col <= prev_col, not c < prev_col, to properly account for the case when a prompt contains multiple consecutive newlines. Failing to do so makes TUI have the wrong idea of the vertical height of the prompt. This patch fixes the column check. The second issue is that cur_line does not get updated to reflect the cursor position if the user's prompt cursor is at the end of the prompt (i.e. if rl_point == rl_end). cur_line only gets updated if rl_point lies between 0..rl_end-1 because that is the bounds of the for loop responsible for updating cur_line. This patch changes the loop's bounds to 0..rl_end so that cur_line always gets updated. With these two bug fixes out of the way, the default query mechanism works well in TUI even with multi-line prompts like GDB's quit prompt. gdb/ChangeLog: * utils.c (defaulted_query): Rewrite to use gdb_readline_wrapper to prompt for input. * tui/tui-hooks.c (tui_query_hook): Remove. (tui_install_hooks): Don't set deprecated_query_hook. * tui/tui-io.c (tui_redisplay_readline): Fix off-by-one error in height calculation. Always update the command window's cur_line.
Diffstat (limited to 'gdb/tui/tui-io.c')
-rw-r--r--gdb/tui/tui-io.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 233e7a6..7e8a3bc 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -234,20 +234,23 @@ tui_redisplay_readline (void)
{
waddch (w, prompt[in]);
getyx (w, line, col);
- if (col < prev_col)
+ if (col <= prev_col)
height++;
prev_col = col;
}
- for (in = 0; in < rl_end; in++)
+ for (in = 0; in <= rl_end; in++)
{
unsigned char c;
- c = (unsigned char) rl_line_buffer[in];
if (in == rl_point)
{
getyx (w, c_line, c_pos);
}
+ if (in == rl_end)
+ break;
+
+ c = (unsigned char) rl_line_buffer[in];
if (CTRL_CHAR (c) || c == RUBOUT)
{
waddch (w, '^');