This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Fix truncation of TUI command history
- From: Patrick Palka <patrick at parcs dot ath dot cx>
- To: gdb-patches at sourceware dot org
- Cc: Patrick Palka <patrick at parcs dot ath dot cx>
- Date: Fri, 9 Jan 2015 22:49:19 -0500
- Subject: [PATCH] Fix truncation of TUI command history
- Authentication-results: sourceware.org; auth=none
- References: <1420861759-10700-1-git-send-email-patrick at parcs dot ath dot cx>
If we submit a command while the prompt cursor is somewhere other than
at the end of the command line, the command line gets truncated as the
command window gets shifted one line up. This happens because we fail
to properly move the cursor to the end of the command line before
transmitting the newline to ncurses. We need to move the cursor because
when ncurses outputs a newline it truncates any text that appears
past the end of the cursor.
The fix is generic enough to work properly even in multi-line secondary
prompts like the quit prompt.
gdb/ChangeLog:
* tui/tui-io.c (tui_getc): Move cursor to the end of the command
line before printing a newline.
---
gdb/tui/tui-io.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 73dbcfc..94c3ec2 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -708,9 +708,15 @@ tui_getc (FILE *fp)
}
else
{
- wmove (w, TUI_CMD_WIN->detail.command_info.cur_line,
- TUI_CMD_WIN->detail.command_info.curch);
- waddch (w, ch);
+ /* Move cursor to the end of the command line before emitting the
+ newline. */
+ int px = TUI_CMD_WIN->detail.command_info.curch;
+ int py = TUI_CMD_WIN->detail.command_info.cur_line;
+ px += rl_end - rl_point;
+ py += px / TUI_CMD_WIN->generic.width;
+ px %= TUI_CMD_WIN->generic.width;
+ wmove (w, py, px);
+ waddch (w, ch);
}
}
--
2.2.1.212.gc5b9256