public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCHv2 1/2] Prevent flickering when redrawing the TUI python window
       [not found] <20210521143322.1293-1-ssbssa.ref@yahoo.de>
@ 2021-05-21 14:33 ` Hannes Domani
  2021-05-21 14:33   ` [PATCHv2 2/2] Add optional full_window argument to TuiWindow.write Hannes Domani
  2021-05-24 14:12   ` [PATCHv2 1/2] Prevent flickering when redrawing the TUI python window Tom Tromey
  0 siblings, 2 replies; 10+ messages in thread
From: Hannes Domani @ 2021-05-21 14:33 UTC (permalink / raw)
  To: gdb-patches

tui_win_info::refresh_window first redraws the background window, then
tui_wrefresh draws the python text on top of it, which flickers.

By using wnoutrefresh for the background window, the actual drawing on
the screen is only done once, without flickering.

gdb/ChangeLog:

2021-05-21  Hannes Domani  <ssbssa@yahoo.de>

	* python/py-tui.c (tui_py_window::refresh_window):
	Avoid flickering.
---
v2:
- Add ChangeLog.
---
 gdb/python/py-tui.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index 72e9c0d5e2b..22f4b0ffd43 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -91,12 +91,14 @@ class tui_py_window : public tui_win_info
 
   void refresh_window () override
   {
-    tui_win_info::refresh_window ();
     if (m_inner_window != nullptr)
       {
+	wnoutrefresh (handle.get ());
 	touchwin (m_inner_window.get ());
 	tui_wrefresh (m_inner_window.get ());
       }
+    else
+      tui_win_info::refresh_window ();
   }
 
   /* Erase and re-box the window.  */
-- 
2.31.1


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

* [PATCHv2 2/2] Add optional full_window argument to TuiWindow.write
  2021-05-21 14:33 ` [PATCHv2 1/2] Prevent flickering when redrawing the TUI python window Hannes Domani
@ 2021-05-21 14:33   ` Hannes Domani
  2021-05-21 14:35     ` Eli Zaretskii
                       ` (2 more replies)
  2021-05-24 14:12   ` [PATCHv2 1/2] Prevent flickering when redrawing the TUI python window Tom Tromey
  1 sibling, 3 replies; 10+ messages in thread
From: Hannes Domani @ 2021-05-21 14:33 UTC (permalink / raw)
  To: gdb-patches

To prevent flickering when first calling erase, then write, this new
argument indicates that the passed string contains the full contents of
the window.  This fills every unused cell of the window with a space, so
it's not necessary to call erase beforehand.

gdb/ChangeLog:

2021-05-21  Hannes Domani  <ssbssa@yahoo.de>

	* python/py-tui.c (tui_py_window::output): Add full_window
	argument.
	(gdbpy_tui_write): Parse "full_window" argument.

gdb/doc/ChangeLog:

2021-05-21  Hannes Domani  <ssbssa@yahoo.de>

	* python.texi (TUI Windows In Python): Document "full_window"
	argument.
---
v2:
- Add ChangeLog.
- Describe full_window argument in ouput function comment.
---
 gdb/doc/python.texi |  6 +++++-
 gdb/python/py-tui.c | 20 ++++++++++++++------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index fa9aa703519..aad480b2a5c 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -5961,10 +5961,14 @@ displayed above the window.  This attribute can be modified.
 Remove all the contents of the window.
 @end defun
 
-@defun TuiWindow.write (@var{string})
+@defun TuiWindow.write (@var{string} @r{[}, @var{full_window}@r{]})
 Write @var{string} to the window.  @var{string} can contain ANSI
 terminal escape styling sequences; @value{GDBN} will translate these
 as appropriate for the terminal.
+
+If the @var{full_window} parameter is @code{True}, then @var{string}
+contains the full contents of the window.  This is similar to calling
+@code{erase} before @code{write}, but avoids the flickering.
 @end defun
 
 The factory function that you supply should return an object
diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index 22f4b0ffd43..97e9de7a00c 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -111,8 +111,9 @@ class tui_py_window : public tui_win_info
       }
   }
 
-  /* Write STR to the window.  */
-  void output (const char *str);
+  /* Write STR to the window.  FULL_WINDOW is true to erase the window
+     contents beforehand.  */
+  void output (const char *str, bool full_window);
 
   /* A helper function to compute the viewport width.  */
   int viewport_width () const
@@ -229,12 +230,18 @@ tui_py_window::do_scroll_vertical (int num_to_scroll)
 }
 
 void
-tui_py_window::output (const char *text)
+tui_py_window::output (const char *text, bool full_window)
 {
   if (m_inner_window != nullptr)
     {
+      if (full_window)
+	werase (m_inner_window.get ());
+
       tui_puts (text, m_inner_window.get ());
-      tui_wrefresh (m_inner_window.get ());
+      if (full_window)
+	check_and_display_highlight_if_needed ();
+      else
+	tui_wrefresh (m_inner_window.get ());
     }
 }
 
@@ -405,13 +412,14 @@ gdbpy_tui_write (PyObject *self, PyObject *args)
 {
   gdbpy_tui_window *win = (gdbpy_tui_window *) self;
   const char *text;
+  int full_window = 0;
 
-  if (!PyArg_ParseTuple (args, "s", &text))
+  if (!PyArg_ParseTuple (args, "s|i", &text, &full_window))
     return nullptr;
 
   REQUIRE_WINDOW (win);
 
-  win->window->output (text);
+  win->window->output (text, full_window);
 
   Py_RETURN_NONE;
 }
-- 
2.31.1


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

* Re: [PATCHv2 2/2] Add optional full_window argument to TuiWindow.write
  2021-05-21 14:33   ` [PATCHv2 2/2] Add optional full_window argument to TuiWindow.write Hannes Domani
@ 2021-05-21 14:35     ` Eli Zaretskii
  2021-05-24 14:17     ` Tom Tromey
  2021-05-24 14:18     ` Tom Tromey
  2 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2021-05-21 14:35 UTC (permalink / raw)
  To: Hannes Domani; +Cc: gdb-patches

> Date: Fri, 21 May 2021 16:33:22 +0200
> From: Hannes Domani via Gdb-patches <gdb-patches@sourceware.org>
> 
> To prevent flickering when first calling erase, then write, this new
> argument indicates that the passed string contains the full contents of
> the window.  This fills every unused cell of the window with a space, so
> it's not necessary to call erase beforehand.
> 
> gdb/ChangeLog:
> 
> 2021-05-21  Hannes Domani  <ssbssa@yahoo.de>
> 
> 	* python/py-tui.c (tui_py_window::output): Add full_window
> 	argument.
> 	(gdbpy_tui_write): Parse "full_window" argument.
> 
> gdb/doc/ChangeLog:
> 
> 2021-05-21  Hannes Domani  <ssbssa@yahoo.de>
> 
> 	* python.texi (TUI Windows In Python): Document "full_window"
> 	argument.

OK for the documentation change.

Thanks.

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

* Re: [PATCHv2 1/2] Prevent flickering when redrawing the TUI python window
  2021-05-21 14:33 ` [PATCHv2 1/2] Prevent flickering when redrawing the TUI python window Hannes Domani
  2021-05-21 14:33   ` [PATCHv2 2/2] Add optional full_window argument to TuiWindow.write Hannes Domani
@ 2021-05-24 14:12   ` Tom Tromey
  2021-05-24 15:18     ` Hannes Domani
  1 sibling, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2021-05-24 14:12 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches

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

Hannes> 2021-05-21  Hannes Domani  <ssbssa@yahoo.de>

Hannes> 	* python/py-tui.c (tui_py_window::refresh_window):
Hannes> 	Avoid flickering.

Thank you.  This is ok.

I suspect we could improve the anti-flickering logic somehow.  It seems
to me that right now there are too many calls to wnoutrefresh, and maybe
there's some more principled approach waiting to be found.

Meanwhile this seems like worthwhile progress to me.

Tom

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

* Re: [PATCHv2 2/2] Add optional full_window argument to TuiWindow.write
  2021-05-21 14:33   ` [PATCHv2 2/2] Add optional full_window argument to TuiWindow.write Hannes Domani
  2021-05-21 14:35     ` Eli Zaretskii
@ 2021-05-24 14:17     ` Tom Tromey
  2021-05-24 14:18     ` Tom Tromey
  2 siblings, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2021-05-24 14:17 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches

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

Hannes> 2021-05-21  Hannes Domani  <ssbssa@yahoo.de>

Hannes> 	* python/py-tui.c (tui_py_window::output): Add full_window
Hannes> 	argument.
Hannes> 	(gdbpy_tui_write): Parse "full_window" argument.

Hi.  Thanks for the patch.

Hannes> -  if (!PyArg_ParseTuple (args, "s", &text))
Hannes> +  if (!PyArg_ParseTuple (args, "s|i", &text, &full_window))
Hannes>      return nullptr;

I was surprised to find out that "i" handles boolean values.

The patch looks good to me, though.  If we really want full truthy
behavior here, we can always change this to "O".  I tend to think this
wouldn't be super useful, though.

thanks,
Tom

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

* Re: [PATCHv2 2/2] Add optional full_window argument to TuiWindow.write
  2021-05-21 14:33   ` [PATCHv2 2/2] Add optional full_window argument to TuiWindow.write Hannes Domani
  2021-05-21 14:35     ` Eli Zaretskii
  2021-05-24 14:17     ` Tom Tromey
@ 2021-05-24 14:18     ` Tom Tromey
  2021-05-24 14:25       ` Hannes Domani
  2 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2021-05-24 14:18 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches

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

Hannes> To prevent flickering when first calling erase, then write, this new
Hannes> argument indicates that the passed string contains the full contents of
Hannes> the window.  This fills every unused cell of the window with a space, so
Hannes> it's not necessary to call erase beforehand.

Hannes> gdb/ChangeLog:

Hannes> 2021-05-21  Hannes Domani  <ssbssa@yahoo.de>

Hannes> 	* python/py-tui.c (tui_py_window::output): Add full_window
Hannes> 	argument.
Hannes> 	(gdbpy_tui_write): Parse "full_window" argument.

It occurred to me after I sent the email, but this patch would benefit
from a simple test.

Tom

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

* Re: [PATCHv2 2/2] Add optional full_window argument to TuiWindow.write
  2021-05-24 14:18     ` Tom Tromey
@ 2021-05-24 14:25       ` Hannes Domani
  2021-05-27 18:22         ` Tom Tromey
  0 siblings, 1 reply; 10+ messages in thread
From: Hannes Domani @ 2021-05-24 14:25 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches, Tom Tromey

 Am Montag, 24. Mai 2021, 16:18:17 MESZ hat Tom Tromey <tom@tromey.com> Folgendes geschrieben:

> >>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Hannes> To prevent flickering when first calling erase, then write, this new
> Hannes> argument indicates that the passed string contains the full contents of
> Hannes> the window.  This fills every unused cell of the window with a space, so
> Hannes> it's not necessary to call erase beforehand.
>
> Hannes> gdb/ChangeLog:
>
> Hannes> 2021-05-21  Hannes Domani  <ssbssa@yahoo.de>
>
> Hannes>     * python/py-tui.c (tui_py_window::output): Add full_window
> Hannes>     argument.
> Hannes>     (gdbpy_tui_write): Parse "full_window" argument.
>
> It occurred to me after I sent the email, but this patch would benefit
> from a simple test.

I don't think it's possible to do any curses-related tests on Windows,
at least I couldn't figure out a way to do that (same problem as the syntax
color tests).


Hannes

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

* Re: [PATCHv2 1/2] Prevent flickering when redrawing the TUI python window
  2021-05-24 14:12   ` [PATCHv2 1/2] Prevent flickering when redrawing the TUI python window Tom Tromey
@ 2021-05-24 15:18     ` Hannes Domani
  0 siblings, 0 replies; 10+ messages in thread
From: Hannes Domani @ 2021-05-24 15:18 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches, Tom Tromey

 Am Montag, 24. Mai 2021, 16:13:05 MESZ hat Tom Tromey <tom@tromey.com> Folgendes geschrieben:

> >>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Hannes> 2021-05-21  Hannes Domani  <ssbssa@yahoo.de>
>
> Hannes>     * python/py-tui.c (tui_py_window::refresh_window):
> Hannes>     Avoid flickering.
>
> Thank you.  This is ok.
>
> I suspect we could improve the anti-flickering logic somehow.  It seems
> to me that right now there are too many calls to wnoutrefresh, and maybe
> there's some more principled approach waiting to be found.
>
> Meanwhile this seems like worthwhile progress to me.

Pushed, thanks.


Hannes

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

* Re: [PATCHv2 2/2] Add optional full_window argument to TuiWindow.write
  2021-05-24 14:25       ` Hannes Domani
@ 2021-05-27 18:22         ` Tom Tromey
  2021-05-27 18:44           ` Hannes Domani
  0 siblings, 1 reply; 10+ messages in thread
From: Tom Tromey @ 2021-05-27 18:22 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches; +Cc: Tom Tromey, Hannes Domani

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

>> It occurred to me after I sent the email, but this patch would benefit
>> from a simple test.

Hannes> I don't think it's possible to do any curses-related tests on Windows,
Hannes> at least I couldn't figure out a way to do that (same problem as the syntax
Hannes> color tests).

I asked Hannes on irc to go ahead and push this.
I'll write the test at some point.

Tom

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

* Re: [PATCHv2 2/2] Add optional full_window argument to TuiWindow.write
  2021-05-27 18:22         ` Tom Tromey
@ 2021-05-27 18:44           ` Hannes Domani
  0 siblings, 0 replies; 10+ messages in thread
From: Hannes Domani @ 2021-05-27 18:44 UTC (permalink / raw)
  To: Hannes Domani via Gdb-patches, Tom Tromey

 Am Donnerstag, 27. Mai 2021, 20:22:18 MESZ hat Tom Tromey <tom@tromey.com> Folgendes geschrieben:

> >>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> >> It occurred to me after I sent the email, but this patch would benefit
> >> from a simple test.
>
> Hannes> I don't think it's possible to do any curses-related tests on Windows,
> Hannes> at least I couldn't figure out a way to do that (same problem as the syntax
> Hannes> color tests).
>
> I asked Hannes on irc to go ahead and push this.
> I'll write the test at some point.

Pushed, thanks.


Hannes

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

end of thread, other threads:[~2021-05-27 18:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210521143322.1293-1-ssbssa.ref@yahoo.de>
2021-05-21 14:33 ` [PATCHv2 1/2] Prevent flickering when redrawing the TUI python window Hannes Domani
2021-05-21 14:33   ` [PATCHv2 2/2] Add optional full_window argument to TuiWindow.write Hannes Domani
2021-05-21 14:35     ` Eli Zaretskii
2021-05-24 14:17     ` Tom Tromey
2021-05-24 14:18     ` Tom Tromey
2021-05-24 14:25       ` Hannes Domani
2021-05-27 18:22         ` Tom Tromey
2021-05-27 18:44           ` Hannes Domani
2021-05-24 14:12   ` [PATCHv2 1/2] Prevent flickering when redrawing the TUI python window Tom Tromey
2021-05-24 15:18     ` 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).