public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Patrick Palka <patrick@parcs.ath.cx>
To: gdb-patches@sourceware.org
Cc: Patrick Palka <patrick@parcs.ath.cx>
Subject: [PATCH] Fix truncation of TUI command history
Date: Sat, 10 Jan 2015 03:49:00 -0000	[thread overview]
Message-ID: <1420861759-10700-2-git-send-email-patrick@parcs.ath.cx> (raw)
In-Reply-To: <1420861759-10700-1-git-send-email-patrick@parcs.ath.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

  reply	other threads:[~2015-01-10  3:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-10  3:49 [PATCH] Fix a pair of screen-resizing issues in TUI Patrick Palka
2015-01-10  3:49 ` Patrick Palka [this message]
2015-01-10  3:59   ` [PATCH] Fix truncation of TUI command history Patrick Palka
2015-01-27  2:13   ` Patrick Palka
2015-02-04 14:50     ` Patrick Palka
2015-02-10 17:30   ` Pedro Alves
2015-01-10  3:56 ` [PATCH] Fix a pair of screen-resizing issues in TUI Patrick Palka
2015-01-26 21:55 ` Patrick Palka
2015-02-04 14:49   ` Patrick Palka
2015-02-10 17:27 ` Pedro Alves
  -- strict thread matches above, loose matches on Subject: below --
2014-08-30 18:11 [PATCH] Fix truncation of TUI command history Patrick Palka
2014-09-04  9:44 ` Pedro Alves
2014-09-04 12:17   ` Patrick Palka

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=1420861759-10700-2-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).