This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 1/2] 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: Tue, 25 Aug 2015 21:06:12 -0400
- Subject: [PATCH 1/2] tui: make updating of start_line in tui_puts more consistent
- Authentication-results: sourceware.org; auth=none
The command window's start_line field is used by the function
tui_redisplay_readline to figure out on which window line to start
redrawing the (possibly multi-line) command line. It differs from the Y
coordinate of the window cursor only when the length of the line being
outputted is longer than the width of the window.
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 update start_line in a way that's
consistent with how tui_redisplay_readline does it. This patch also
explicitly documents this property of start_line.
gdb/ChangeLog:
* tui/tui-data.h (tui_command_info): Add comment documenting the
field start_line.
* tui/tui-io.c (tui_puts): Fix the updating of start_line.
---
gdb/tui/tui-data.h | 5 +++++
gdb/tui/tui-io.c | 17 ++++++++++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index df1fe6c..2f9030a 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -265,6 +265,11 @@ struct tui_source_info
struct tui_command_info
{
+ /* The line number (i.e. the Y coordinate of the command window) that
+ contains the start of the latest line being outputted. START_LINE differs
+ from the Y coordinate of the window cursor only when the current line is
+ longer than the width of the window, i.e. only when the current line has
+ wrapped to the next line one or more times. */
int start_line;
};
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index c7a092f..311c96c 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,11 +188,21 @@ 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;
}
- TUI_CMD_WIN->detail.command_info.start_line = getcury (w);
}
/* Readline callback.
--
2.5.0.417.g69c5dbd.dirty