Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix truncation of TUI command history
@ 2014-08-30 18:11 Patrick Palka
  2014-09-04  9:44 ` Pedro Alves
  0 siblings, 1 reply; 8+ messages in thread
From: Patrick Palka @ 2014-08-30 18:11 UTC (permalink / raw)
  To: gdb-patches; +Cc: Patrick Palka

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(-)

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);
         }
     }
-- 
2.1.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Fix truncation of TUI command history
  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
  0 siblings, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2014-09-04  9:44 UTC (permalink / raw)
  To: Patrick Palka, gdb-patches

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Fix truncation of TUI command history
  2014-09-04  9:44 ` Pedro Alves
@ 2014-09-04 12:17   ` Patrick Palka
  0 siblings, 0 replies; 8+ messages in thread
From: Patrick Palka @ 2014-09-04 12:17 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Fix truncation of TUI command history
  2015-01-10  3:49 ` [PATCH] Fix truncation of TUI command history Patrick Palka
  2015-01-10  3:59   ` Patrick Palka
  2015-01-27  2:13   ` Patrick Palka
@ 2015-02-10 17:30   ` Pedro Alves
  2 siblings, 0 replies; 8+ messages in thread
From: Pedro Alves @ 2015-02-10 17:30 UTC (permalink / raw)
  To: Patrick Palka, gdb-patches

On 01/10/2015 03:49 AM, Patrick Palka wrote:

> We need to move the cursor because
> when ncurses outputs a newline it truncates any text that appears
> past the end of the cursor.

Can you merge this sentence into the comment in the code?

>        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.  */

... as this as is doesn't explain _why_ we need to do that, which
may make the reader wonder.

> +	  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);
>          }
>      }
>    
> 

OK with that change.  Thanks!

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Fix truncation of TUI command history
  2015-01-27  2:13   ` Patrick Palka
@ 2015-02-04 14:50     ` Patrick Palka
  0 siblings, 0 replies; 8+ messages in thread
From: Patrick Palka @ 2015-02-04 14:50 UTC (permalink / raw)
  To: gdb-patches; +Cc: Patrick Palka

Ping.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Fix truncation of TUI command history
  2015-01-10  3:49 ` [PATCH] Fix truncation of TUI command history Patrick Palka
  2015-01-10  3:59   ` Patrick Palka
@ 2015-01-27  2:13   ` Patrick Palka
  2015-02-04 14:50     ` Patrick Palka
  2015-02-10 17:30   ` Pedro Alves
  2 siblings, 1 reply; 8+ messages in thread
From: Patrick Palka @ 2015-01-27  2:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Patrick Palka

Ping.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Fix truncation of TUI command history
  2015-01-10  3:49 ` [PATCH] Fix truncation of TUI command history Patrick Palka
@ 2015-01-10  3:59   ` Patrick Palka
  2015-01-27  2:13   ` Patrick Palka
  2015-02-10 17:30   ` Pedro Alves
  2 siblings, 0 replies; 8+ messages in thread
From: Patrick Palka @ 2015-01-10  3:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Patrick Palka

This is an improved variant of the patch here
https://sourceware.org/ml/gdb-patches/2014-09/msg00109.html that also
works properly for secondary prompts (and overlong lines).


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] Fix truncation of TUI command history
  2015-01-10  3:49 [PATCH] Fix a pair of screen-resizing issues in TUI Patrick Palka
@ 2015-01-10  3:49 ` Patrick Palka
  2015-01-10  3:59   ` Patrick Palka
                     ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Patrick Palka @ 2015-01-10  3:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Patrick Palka

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-02-10 17:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2015-01-10  3:49 [PATCH] Fix a pair of screen-resizing issues in TUI Patrick Palka
2015-01-10  3:49 ` [PATCH] Fix truncation of TUI command history Patrick Palka
2015-01-10  3:59   ` Patrick Palka
2015-01-27  2:13   ` Patrick Palka
2015-02-04 14:50     ` Patrick Palka
2015-02-10 17:30   ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox