public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/4] Fix TUI source window drawing
       [not found] <20201221142343.4810-1-ssbssa.ref@yahoo.de>
@ 2020-12-21 14:23 ` Hannes Domani
  2020-12-21 14:23   ` [PATCH 2/4] Redraw both spaces between line numbers and source code Hannes Domani
                     ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Hannes Domani @ 2020-12-21 14:23 UTC (permalink / raw)
  To: gdb-patches

The smaxrow and smaxcol parameters of prefresh are the bottom right corner
of the text area inclusive, not exclusive.

And if the source window grows bigger in height, the pad has to grow as
well.

gdb/ChangeLog:

2020-12-21  Hannes Domani  <ssbssa@yahoo.de>

	PR tui/26927
	* tui/tui-winsource.c (tui_source_window_base::refresh_window):
	Fix source pad size in prefresh.
	(tui_source_window_base::show_source_content): Grow source pad
	if necessary.
---
 gdb/tui/tui-winsource.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index b371e62459..79f233090e 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -262,7 +262,7 @@ tui_source_window_base::refresh_window ()
      scrolled beyond where we clip.  */
   m_horizontal_offset = pad_x;
   prefresh (m_pad.get (), 0, pad_x, y + 1, x + left_margin,
-	    y + 1 + m_content.size (), x + left_margin + view_width - 1);
+	    y + m_content.size (), x + left_margin + view_width - 1);
 }
 
 void
@@ -273,7 +273,8 @@ tui_source_window_base::show_source_content ()
   check_and_display_highlight_if_needed ();
 
   int pad_width = std::max (m_max_length, width);
-  if (m_pad == nullptr || pad_width > getmaxx (m_pad.get ()))
+  if (m_pad == nullptr || pad_width > getmaxx (m_pad.get ())
+      || m_content.size () > getmaxy (m_pad.get ()))
     m_pad.reset (newpad (m_content.size (), pad_width));
 
   werase (m_pad.get ());
-- 
2.29.2


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

* [PATCH 2/4] Redraw both spaces between line numbers and source code
  2020-12-21 14:23 ` [PATCH 1/4] Fix TUI source window drawing Hannes Domani
@ 2020-12-21 14:23   ` Hannes Domani
  2021-01-04 20:43     ` Tom Tromey
  2020-12-21 14:23   ` [PATCH 3/4] Don't add window duplicates to tui_windows Hannes Domani
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Hannes Domani @ 2020-12-21 14:23 UTC (permalink / raw)
  To: gdb-patches

There a 2 spaces between the numbers and source code, but only one of
them was redrawn.
So if you increase the source window height, the second space keeps the
character of the border rectangle.

With this both spaces are redrawn, so the border rectangle character is
overwritten.

gdb/ChangeLog:

2020-12-21  Hannes Domani  <ssbssa@yahoo.de>

	* tui/tui-source.c (tui_source_window::show_line_number):
	Redraw second space after line number.
---
 gdb/tui/tui-source.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index cc6680406d..bdfd3de9e5 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -233,6 +233,6 @@ tui_source_window::show_line_number (int offset) const
 {
   int lineno = m_content[0].line_or_addr.u.line_no + offset;
   char text[20];
-  xsnprintf (text, sizeof (text), "%*d ", m_digits - 1, lineno);
+  xsnprintf (text, sizeof (text), "%*d  ", m_digits - 1, lineno);
   waddstr (handle.get (), text);
 }
-- 
2.29.2


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

* [PATCH 3/4] Don't add window duplicates to tui_windows
  2020-12-21 14:23 ` [PATCH 1/4] Fix TUI source window drawing Hannes Domani
  2020-12-21 14:23   ` [PATCH 2/4] Redraw both spaces between line numbers and source code Hannes Domani
@ 2020-12-21 14:23   ` Hannes Domani
  2021-01-04 20:50     ` Tom Tromey
  2020-12-21 14:23   ` [PATCH 4/4] Prevent flickering when redrawing the TUI source window Hannes Domani
  2021-01-04 20:35   ` [PATCH 1/4] Fix TUI source window drawing Tom Tromey
  3 siblings, 1 reply; 12+ messages in thread
From: Hannes Domani @ 2020-12-21 14:23 UTC (permalink / raw)
  To: gdb-patches

Otherwise, each time a window size is change with 'winheight', all windows
are duplicated, and when done multiple times, slows down redrawing.

gdb/ChangeLog:

2020-12-21  Hannes Domani  <ssbssa@yahoo.de>

	* tui/tui-layout.c (tui_layout_window::apply):
	Check if tui_windows already contains the current window.
---
 gdb/tui/tui-layout.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 2dd7c3d4ba..dd72980efd 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -424,7 +424,9 @@ tui_layout_window::apply (int x_, int y_, int width_, int height_)
   height = height_;
   gdb_assert (m_window != nullptr);
   m_window->resize (height, width, x, y);
-  tui_windows.push_back (m_window);
+  if (std::find (tui_windows.begin (), tui_windows.end (),
+		 m_window) == tui_windows.end ())
+    tui_windows.push_back (m_window);
 }
 
 /* See tui-layout.h.  */
-- 
2.29.2


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

* [PATCH 4/4] Prevent flickering when redrawing the TUI source window
  2020-12-21 14:23 ` [PATCH 1/4] Fix TUI source window drawing Hannes Domani
  2020-12-21 14:23   ` [PATCH 2/4] Redraw both spaces between line numbers and source code Hannes Domani
  2020-12-21 14:23   ` [PATCH 3/4] Don't add window duplicates to tui_windows Hannes Domani
@ 2020-12-21 14:23   ` Hannes Domani
  2021-01-04 20:55     ` Tom Tromey
  2021-01-05 11:57     ` Christian Biesinger
  2021-01-04 20:35   ` [PATCH 1/4] Fix TUI source window drawing Tom Tromey
  3 siblings, 2 replies; 12+ messages in thread
From: Hannes Domani @ 2020-12-21 14:23 UTC (permalink / raw)
  To: gdb-patches

tui_win_info::refresh_window simply calls wrefresh, which internally
does a doupdate.
This redraws the source background window without the source pad.
Then prefresh of the source pad draws the actual source code on top,
which flickers.

By changing this to wnoutrefresh, the actual drawing on the screen is
only done once in the following prefresh, without flickering.

gdb/ChangeLog:

2020-12-21  Hannes Domani  <ssbssa@yahoo.de>

	* tui/tui-winsource.c (tui_source_window_base::refresh_window):
	Call wnoutrefresh instead of tui_win_info::refresh_window.
---
 gdb/tui/tui-winsource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 79f233090e..882ce391f7 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -252,7 +252,7 @@ tui_source_window_base::show_source_line (int lineno)
 void
 tui_source_window_base::refresh_window ()
 {
-  tui_win_info::refresh_window ();
+  wnoutrefresh (handle.get ());
 
   int pad_width = std::max (m_max_length, width);
   int left_margin = 1 + TUI_EXECINFO_SIZE + extra_margin ();
-- 
2.29.2


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

* Re: [PATCH 1/4] Fix TUI source window drawing
  2020-12-21 14:23 ` [PATCH 1/4] Fix TUI source window drawing Hannes Domani
                     ` (2 preceding siblings ...)
  2020-12-21 14:23   ` [PATCH 4/4] Prevent flickering when redrawing the TUI source window Hannes Domani
@ 2021-01-04 20:35   ` Tom Tromey
  2021-01-05 13:10     ` Hannes Domani
  3 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2021-01-04 20:35 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches

>>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:

Hannes> 2020-12-21  Hannes Domani  <ssbssa@yahoo.de>

Hannes> 	PR tui/26927
Hannes> 	* tui/tui-winsource.c (tui_source_window_base::refresh_window):
Hannes> 	Fix source pad size in prefresh.
Hannes> 	(tui_source_window_base::show_source_content): Grow source pad
Hannes> 	if necessary.

Thank you for the patch.  This is ok.

Tom

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

* Re: [PATCH 2/4] Redraw both spaces between line numbers and source code
  2020-12-21 14:23   ` [PATCH 2/4] Redraw both spaces between line numbers and source code Hannes Domani
@ 2021-01-04 20:43     ` Tom Tromey
  2021-01-05 13:11       ` Hannes Domani
  0 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2021-01-04 20:43 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches

>>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:

Hannes> 2020-12-21  Hannes Domani  <ssbssa@yahoo.de>

Hannes> 	* tui/tui-source.c (tui_source_window::show_line_number):
Hannes> 	Redraw second space after line number.

Thanks for the patch.

Hannes> -  xsnprintf (text, sizeof (text), "%*d ", m_digits - 1, lineno);
Hannes> +  xsnprintf (text, sizeof (text), "%*d  ", m_digits - 1, lineno);

Would you mind adding a brief comment here explaining the need for two
spaces?  I think that may prove useful in the future.  This is ok with
this tweak.

Tom

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

* Re: [PATCH 3/4] Don't add window duplicates to tui_windows
  2020-12-21 14:23   ` [PATCH 3/4] Don't add window duplicates to tui_windows Hannes Domani
@ 2021-01-04 20:50     ` Tom Tromey
  0 siblings, 0 replies; 12+ messages in thread
From: Tom Tromey @ 2021-01-04 20:50 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches

>>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:

Hannes> Otherwise, each time a window size is change with 'winheight', all windows
Hannes> are duplicated, and when done multiple times, slows down redrawing.

Ugh.  Thank you for finding this.

Hannes> 2020-12-21  Hannes Domani  <ssbssa@yahoo.de>

Hannes> 	* tui/tui-layout.c (tui_layout_window::apply):
Hannes> 	Check if tui_windows already contains the current window.

I gather the problem is that tui_layout_split::adjust_size is called,
but it doesn't clear the window list first.

I think this patch is safe, but I wonder whether it would be better to
instead pass a flag to apply to indicate that whether the window list
ought to be updated.

Tom

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

* Re: [PATCH 4/4] Prevent flickering when redrawing the TUI source window
  2020-12-21 14:23   ` [PATCH 4/4] Prevent flickering when redrawing the TUI source window Hannes Domani
@ 2021-01-04 20:55     ` Tom Tromey
  2021-01-05 13:13       ` Hannes Domani
  2021-01-05 11:57     ` Christian Biesinger
  1 sibling, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2021-01-04 20:55 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches

>>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:

Hannes> 2020-12-21  Hannes Domani  <ssbssa@yahoo.de>

Hannes> 	* tui/tui-winsource.c (tui_source_window_base::refresh_window):
Hannes> 	Call wnoutrefresh instead of tui_win_info::refresh_window.

Looks good.  Thank you.

Tom

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

* Re: [PATCH 4/4] Prevent flickering when redrawing the TUI source window
  2020-12-21 14:23   ` [PATCH 4/4] Prevent flickering when redrawing the TUI source window Hannes Domani
  2021-01-04 20:55     ` Tom Tromey
@ 2021-01-05 11:57     ` Christian Biesinger
  1 sibling, 0 replies; 12+ messages in thread
From: Christian Biesinger @ 2021-01-05 11:57 UTC (permalink / raw)
  To: Hannes Domani; +Cc: gdb-patches

On Mon, Dec 21, 2020 at 3:24 PM Hannes Domani via Gdb-patches
<gdb-patches@sourceware.org> wrote:
>  tui_source_window_base::refresh_window ()
>  {
> -  tui_win_info::refresh_window ();
> +  wnoutrefresh (handle.get ());

Maybe it would be good to add a comment saying why you're calling
wnoutrefresh instead of the superclass? Or is this obvious anyway to
someone knowing ncurses?

Christian

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

* Re: [PATCH 1/4] Fix TUI source window drawing
  2021-01-04 20:35   ` [PATCH 1/4] Fix TUI source window drawing Tom Tromey
@ 2021-01-05 13:10     ` Hannes Domani
  0 siblings, 0 replies; 12+ messages in thread
From: Hannes Domani @ 2021-01-05 13:10 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches, Tom Tromey

 Am Montag, 4. Januar 2021, 21:35:45 MEZ hat Tom Tromey <tom@tromey.com> Folgendes geschrieben:

> >>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Hannes> 2020-12-21  Hannes Domani  <ssbssa@yahoo.de>
>
> Hannes>     PR tui/26927
> Hannes>     * tui/tui-winsource.c (tui_source_window_base::refresh_window):
> Hannes>     Fix source pad size in prefresh.
> Hannes>     (tui_source_window_base::show_source_content): Grow source pad
> Hannes>     if necessary.
>
> Thank you for the patch.  This is ok.

Pushed, thanks.


Hannes

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

* Re: [PATCH 2/4] Redraw both spaces between line numbers and source code
  2021-01-04 20:43     ` Tom Tromey
@ 2021-01-05 13:11       ` Hannes Domani
  0 siblings, 0 replies; 12+ messages in thread
From: Hannes Domani @ 2021-01-05 13:11 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches, Tom Tromey

 Am Montag, 4. Januar 2021, 21:44:59 MEZ hat Tom Tromey <tom@tromey.com> Folgendes geschrieben:

> >>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Hannes> 2020-12-21  Hannes Domani  <ssbssa@yahoo.de>
>
> Hannes>     * tui/tui-source.c (tui_source_window::show_line_number):
> Hannes>     Redraw second space after line number.
>
> Thanks for the patch.
>
> Hannes> -  xsnprintf (text, sizeof (text), "%*d ", m_digits - 1, lineno);
> Hannes> +  xsnprintf (text, sizeof (text), "%*d  ", m_digits - 1, lineno);
>
> Would you mind adding a brief comment here explaining the need for two
> spaces?  I think that may prove useful in the future.  This is ok with
> this tweak.

Pushed with an added comment, thanks.


Hannes

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

* Re: [PATCH 4/4] Prevent flickering when redrawing the TUI source window
  2021-01-04 20:55     ` Tom Tromey
@ 2021-01-05 13:13       ` Hannes Domani
  0 siblings, 0 replies; 12+ messages in thread
From: Hannes Domani @ 2021-01-05 13:13 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches, Tom Tromey, Christian Biesinger

 Am Montag, 4. Januar 2021, 21:55:28 MEZ hat Tom Tromey <tom@tromey.com> Folgendes geschrieben:

> >>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Hannes> 2020-12-21  Hannes Domani  <ssbssa@yahoo.de>
>
> Hannes>     * tui/tui-winsource.c (tui_source_window_base::refresh_window):
> Hannes>     Call wnoutrefresh instead of tui_win_info::refresh_window.
>
> Looks good.  Thank you.


Am Dienstag, 5. Januar 2021, 12:58:20 MEZ hat Christian Biesinger <cbiesinger@google.com> Folgendes geschrieben:

> Maybe it would be good to add a comment saying why you're calling
> wnoutrefresh instead of the superclass? Or is this obvious anyway to
> someone knowing ncurses?

Pushed with an added comment, thanks.


Hannes

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

end of thread, other threads:[~2021-01-05 13:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20201221142343.4810-1-ssbssa.ref@yahoo.de>
2020-12-21 14:23 ` [PATCH 1/4] Fix TUI source window drawing Hannes Domani
2020-12-21 14:23   ` [PATCH 2/4] Redraw both spaces between line numbers and source code Hannes Domani
2021-01-04 20:43     ` Tom Tromey
2021-01-05 13:11       ` Hannes Domani
2020-12-21 14:23   ` [PATCH 3/4] Don't add window duplicates to tui_windows Hannes Domani
2021-01-04 20:50     ` Tom Tromey
2020-12-21 14:23   ` [PATCH 4/4] Prevent flickering when redrawing the TUI source window Hannes Domani
2021-01-04 20:55     ` Tom Tromey
2021-01-05 13:13       ` Hannes Domani
2021-01-05 11:57     ` Christian Biesinger
2021-01-04 20:35   ` [PATCH 1/4] Fix TUI source window drawing Tom Tromey
2021-01-05 13:10     ` Hannes Domani

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