From: Patrick Palka <patrick@parcs.ath.cx>
To: gdb-patches@sourceware.org
Cc: Patrick Palka <patrick@parcs.ath.cx>
Subject: [PATCH 3/5] tui: simplify and fix up handling of start_line in tui_redisplay_readline
Date: Sun, 05 Jul 2015 21:04:00 -0000 [thread overview]
Message-ID: <1436130241-21443-3-git-send-email-patrick@parcs.ath.cx> (raw)
In-Reply-To: <1436130241-21443-1-git-send-email-patrick@parcs.ath.cx>
This patch makes three small changes:
The code guarded by the c == '\n' condition is dead code because
whatever value start_line and curch get set to will be overwritten after
the while-loop finishes anyway. So this patch removes this dead code.
Besides that, the remaining two writes to start_line are combined into
one write.
Finally, if start_line ever falls below 0, which can happen if the
command line is so long that it wraps along the height of the entire
command window, just reset it to 0 so that we avoid passing an invalid y
parameter to wmove() later, and emit a beep to "warn" the user that the
command line is too long.
gdb/ChangeLog:
* tui/tui-io.c (tui_redisplay_readline): Simplify the updating
of start_line. If start_line is negative, re-set it to 0 and
emit a beep.
---
gdb/tui/tui-io.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index ba42c18..5b9ca20 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -270,26 +270,33 @@ tui_redisplay_readline (void)
{
waddch (w, c);
}
- if (c == '\n')
- {
- getyx (w, TUI_CMD_WIN->detail.command_info.start_line,
- TUI_CMD_WIN->detail.command_info.curch);
- }
getyx (w, line, col);
if (col < prev_col)
height++;
prev_col = col;
}
+
wclrtobot (w);
- getyx (w, TUI_CMD_WIN->detail.command_info.start_line,
- TUI_CMD_WIN->detail.command_info.curch);
+
+ TUI_CMD_WIN->detail.command_info.start_line
+ = getcury (w) - (height - 1);
+ TUI_CMD_WIN->detail.command_info.curch
+ = getcurx (w);
+
+ /* This can happen if the command line is so long that it wraps along the
+ height of the entire window. */
+ if (TUI_CMD_WIN->detail.command_info.start_line < 0)
+ {
+ beep ();
+ TUI_CMD_WIN->detail.command_info.start_line = 0;
+ }
+
if (c_line >= 0)
{
wmove (w, c_line, c_pos);
TUI_CMD_WIN->detail.command_info.cur_line = c_line;
TUI_CMD_WIN->detail.command_info.curch = c_pos;
}
- TUI_CMD_WIN->detail.command_info.start_line -= height - 1;
wrefresh (w);
fflush(stdout);
--
2.5.0.rc0.5.g91e10c5.dirty
prev parent reply other threads:[~2015-07-05 21:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-05 21:03 [PATCH 0/5] An attempt to provide "scrolling" functionality to TUI (PR tui/14584) Patrick Palka
2015-07-05 21:04 ` [PATCH 1/5] tui: reset start_line whenever cur_line is reset Patrick Palka
2015-07-05 21:04 ` [PATCH 5/5] tui: maintain a scrollback buffer and dump it upon exit (PR tui/14584) Patrick Palka
2015-07-05 21:04 ` [PATCH 2/5] tui: use tui_putc to output newline entered by the user Patrick Palka
2015-07-05 21:04 ` [PATCH 4/5] tui: make updating of start_line in tui_puts more consistent Patrick Palka
2015-07-05 21:04 ` Patrick Palka [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436130241-21443-3-git-send-email-patrick@parcs.ath.cx \
--to=patrick@parcs.ath.cx \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).