This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 4/5] tui: make updating of start_line in tui_puts more consistent
- 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: Sun, 5 Jul 2015 17:04:00 -0400
- Subject: [PATCH 4/5] tui: make updating of start_line in tui_puts more consistent
- Authentication-results: sourceware.org; auth=none
- References: <1436130177-21362-1-git-send-email-patrick at parcs dot ath dot cx> <1436130241-21443-1-git-send-email-patrick at parcs dot ath dot cx>
The command window's start_line field is used by tui_redisplay_readline
to figure out on which window line to start redrawing the (possibly
multi-line) command line. It differs from cur_line only when the length
of the line being outputted is longer than the width of the window. In
this case, start_line will not equal to cur_line. Instead, start_line
will be equal to cur_line - N where N is the number of times the current
line was wrapped around the width of the command window. start_line
takes into consideration whether line wrapping has occurred, and
cur_line does not.
The function tui_puts however currently does not respect this property
of start_line. After a call to tui_puts, start_line will always be
equal to cur_line even when the outputted line may have wrapped a few
times. This patch makes tui_puts properly update start_line. It must
only be updated if a newline is emitted, or if ncurses scrolls the
command window (thus shifting all the line numbers).
gdb/ChangeLog:
* tui/tui-io.c (tui_puts): Fix the updating of start_line.
---
gdb/tui/tui-io.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 5b9ca20..9302391 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -168,7 +168,12 @@ tui_puts (const char *string)
}
else if (tui_skip_line != 1)
{
+ int prev_line, prev_col;
+
tui_skip_line = -1;
+
+ getyx (w, prev_line, prev_col);
+
/* Expand TABs, since ncurses on MS-Windows doesn't. */
if (c == '\t')
{
@@ -183,14 +188,23 @@ tui_puts (const char *string)
}
else
waddch (w, c);
+
+ if (c == '\n')
+ TUI_CMD_WIN->detail.command_info.start_line = getcury (w);
+ else if (getcurx (w) <= prev_col && getcury (w) == prev_line)
+ {
+ /* If the cursor is on the last line of the command window and the
+ added character caused the line to wrap, then we have to adjust
+ start_line to compensate for the scrolling up of each line that
+ the line wrapping caused. */
+ TUI_CMD_WIN->detail.command_info.start_line--;
+ }
}
else if (c == '\n')
tui_skip_line = -1;
}
getyx (w, TUI_CMD_WIN->detail.command_info.cur_line,
TUI_CMD_WIN->detail.command_info.curch);
- TUI_CMD_WIN->detail.command_info.start_line
- = TUI_CMD_WIN->detail.command_info.cur_line;
}
/* Readline callback.
--
2.5.0.rc0.5.g91e10c5.dirty