Fix truncation of TUI command history
authorPatrick Palka <patrick@parcs.ath.cx>
Tue, 10 Feb 2015 23:44:56 +0000 (18:44 -0500)
committerPatrick Palka <patrick@parcs.ath.cx>
Wed, 11 Feb 2015 00:06:49 +0000 (19:06 -0500)
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/ChangeLog
gdb/tui/tui-io.c

index fe61d24244b1d9bcdac3004c2e5c8da2783a55d4..2a75ceaaf52a7adf5d1712ecb4038b59ca9bb3a4 100644 (file)
@@ -1,8 +1,13 @@
+2015-02-11  Patrick Palka  <patrick@parcs.ath.cx>
+
+       * tui/tui-io.c (tui_getc): Move cursor to the end of the command
+       line before printing a newline.
+
 2015-02-11  Mark Wielaard  <mjw@redhat.com>
 
        * utils.c (producer_is_gcc): Return true or false.
 
-2015-02-04  Mark Wielaard  <mjw@redhat.com>
+2015-02-10  Mark Wielaard  <mjw@redhat.com>
 
        * utils.h (producer_is_gcc): Change return type to bool. Add major
        argument.
index 21b2a001f5d35b90cf7533b9375b227f31a0ec24..4083cdede2997b55dc23f4e7f0d023accbc2d830 100644 (file)
@@ -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);
         }
     }
   
This page took 0.02967 seconds and 4 git commands to generate.