diff options
author | Patrick Palka <patrick@parcs.ath.cx> | 2015-02-10 18:44:56 -0500 |
---|---|---|
committer | Patrick Palka <patrick@parcs.ath.cx> | 2015-02-10 19:06:49 -0500 |
commit | d9080678121a84fc433a5f2ee141ee98512d2167 (patch) | |
tree | da50ba69158beec20287e92ff638b44de11afe09 /gdb/tui | |
parent | 084910afdd2d98e3e60ff35f124549fc3c180edc (diff) | |
download | binutils-d9080678121a84fc433a5f2ee141ee98512d2167.zip binutils-d9080678121a84fc433a5f2ee141ee98512d2167.tar.gz binutils-d9080678121a84fc433a5f2ee141ee98512d2167.tar.bz2 |
Fix truncation of TUI command history
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.
Diffstat (limited to 'gdb/tui')
-rw-r--r-- | gdb/tui/tui-io.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 21b2a00..4083cde 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -627,9 +627,16 @@ 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. We need to do so because when ncurses outputs a newline + it truncates any text that appears past the end of the cursor. */ + 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); } } |