diff mbox

Fix truncation of TUI command history

Message ID 1409422278-19284-1-git-send-email-patrick@parcs.ath.cx
State New
Headers show

Commit Message

Patrick Palka Aug. 30, 2014, 6:11 p.m. UTC
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.

	* tui/tui-io.c (tui_getc): Move cursor to the end of the command
	line before printing a newline.
---
 gdb/tui/tui-io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Pedro Alves Sept. 4, 2014, 9:44 a.m. UTC | #1
Hi Patrick,

On 08/30/2014 07:11 PM, Patrick Palka wrote:
> index aa14790..eee5f1ac6 100644
> --- a/gdb/tui/tui-io.c
> +++ b/gdb/tui/tui-io.c
> @@ -678,8 +678,9 @@ tui_getc (FILE *fp)
>          }
>        else
>          {
> +          /* Move cursor to the end of the command line.  */
>            wmove (w, TUI_CMD_WIN->detail.command_info.cur_line,
> -                 TUI_CMD_WIN->detail.command_info.curch);
> +		 strlen (tui_rl_saved_prompt) + rl_end);
>            waddch (w, ch);

Does this still do the right thing with secondary prompts?

E.g., if you do "quit" while a program is running, and then
press enter a few times just to have the query repeat (and
then pagination kick in, for extra stress).

Thanks,
Pedro Alves
Patrick Palka Sept. 4, 2014, 12:17 p.m. UTC | #2
On Thu, Sep 4, 2014 at 5:44 AM, Pedro Alves <palves@redhat.com> wrote:
> Hi Patrick,
>
> On 08/30/2014 07:11 PM, Patrick Palka wrote:
>> index aa14790..eee5f1ac6 100644
>> --- a/gdb/tui/tui-io.c
>> +++ b/gdb/tui/tui-io.c
>> @@ -678,8 +678,9 @@ tui_getc (FILE *fp)
>>          }
>>        else
>>          {
>> +          /* Move cursor to the end of the command line.  */
>>            wmove (w, TUI_CMD_WIN->detail.command_info.cur_line,
>> -                 TUI_CMD_WIN->detail.command_info.curch);
>> +              strlen (tui_rl_saved_prompt) + rl_end);
>>            waddch (w, ch);
>
> Does this still do the right thing with secondary prompts?
>
> E.g., if you do "quit" while a program is running, and then
> press enter a few times just to have the query repeat (and
> then pagination kick in, for extra stress).
>
> Thanks,
> Pedro Alves
>

Good point.  It doesn't work correctly in this case.  I'll try to find
a better solution.
diff mbox

Patch

diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index aa14790..eee5f1ac6 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -678,8 +678,9 @@  tui_getc (FILE *fp)
         }
       else
         {
+          /* Move cursor to the end of the command line.  */
           wmove (w, TUI_CMD_WIN->detail.command_info.cur_line,
-                 TUI_CMD_WIN->detail.command_info.curch);
+		 strlen (tui_rl_saved_prompt) + rl_end);
           waddch (w, ch);
         }
     }