public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Don't erase TUI source window when switching focus
@ 2020-10-09 20:27 Tom Tromey
  2020-10-19 19:45 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2020-10-09 20:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

PR tui/26719 points out that switching the focus can erase the TUI
source window.  This is a regression introduced by the patch to switch
the source window to using a pad.

This patch fixes the bug by arranging to call prefresh whenever the
window is refreshed.

gdb/ChangeLog
2020-10-09  Tom Tromey  <tromey@adacore.com>

	PR tui/26719
	* tui/tui-winsource.h (struct tui_source_window_base)
	<refresh_window>: Rename from refresh_pad.
	* tui/tui-winsource.c (tui_source_window_base::refresh_window):
	Rename from refresh_pad.
	(tui_source_window_base::show_source_content)
	(tui_source_window_base::do_scroll_horizontal): Update.

gdb/testsuite/ChangeLog
2020-10-09  Tom Tromey  <tromey@adacore.com>

	PR tui/26719
	* gdb.tui/list.exp: Check source window contents after focus
	change.
---
 gdb/ChangeLog                  | 10 ++++++++++
 gdb/testsuite/ChangeLog        |  6 ++++++
 gdb/testsuite/gdb.tui/list.exp |  3 +++
 gdb/tui/tui-winsource.c        |  8 ++++----
 gdb/tui/tui-winsource.h        |  5 ++---
 5 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/gdb.tui/list.exp b/gdb/testsuite/gdb.tui/list.exp
index 576b33fa869..435540418ed 100644
--- a/gdb/testsuite/gdb.tui/list.exp
+++ b/gdb/testsuite/gdb.tui/list.exp
@@ -35,8 +35,11 @@ Term::command "layout asm"
 Term::check_contents "asm window shows main" "$hex <main>"
 
 Term::command "list main"
+Term::dump_screen
 Term::check_contents "list main" "21 *return 0"
 # The following 'focus next' must be immediately after 'list main' to
 # ensure that GDB has a valid idea of what is currently focused.
 Term::command "focus next"
 Term::check_contents "focus next" "Focus set to cmd window"
+# PR tui/26719 - switching focus would clear the source window.
+Term::check_contents "source is still visible" "21 *return 0"
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 30b8f69027a..957d9310f7a 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -250,8 +250,10 @@ tui_source_window_base::show_source_line (int lineno)
 /* See tui-winsource.h.  */
 
 void
-tui_source_window_base::refresh_pad ()
+tui_source_window_base::refresh_window ()
 {
+  tui_win_info::refresh_window ();
+
   int pad_width = std::max (m_max_length, width);
   int left_margin = 1 + TUI_EXECINFO_SIZE + extra_margin ();
   int view_width = width - left_margin - 1;
@@ -278,8 +280,6 @@ tui_source_window_base::show_source_content ()
   for (int lineno = 0; lineno < m_content.size (); lineno++)
     show_source_line (lineno);
 
-  refresh_pad ();
-
   refresh_window ();
 }
 
@@ -377,7 +377,7 @@ tui_source_window_base::do_scroll_horizontal (int num_to_scroll)
       if (offset < 0)
 	offset = 0;
       m_horizontal_offset = offset;
-      refresh_pad ();
+      refresh_window ();
     }
 }
 
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 5fc6a6d8126..6dcf0efe4b9 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -171,6 +171,8 @@ struct tui_source_window_base : public tui_win_info
   /* Erase the source content.  */
   virtual void erase_source_content () = 0;
 
+  void refresh_window () override;
+
   /* Return the start address and gdbarch.  */
   virtual void display_start_addr (struct gdbarch **gdbarch_p,
 				   CORE_ADDR *addr_p) = 0;
@@ -179,9 +181,6 @@ struct tui_source_window_base : public tui_win_info
 
   void show_source_content ();
 
-  /* Re-display the pad in the window.  */
-  void refresh_pad ();
-
   /* Called when the user "set style enabled" setting is changed.  */
   void style_changed ();
 
-- 
2.26.2


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

* Re: [PATCH] Don't erase TUI source window when switching focus
  2020-10-09 20:27 [PATCH] Don't erase TUI source window when switching focus Tom Tromey
@ 2020-10-19 19:45 ` Tom Tromey
  2020-10-19 20:03   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2020-10-19 19:45 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:

Tom> PR tui/26719 points out that switching the focus can erase the TUI
Tom> source window.  This is a regression introduced by the patch to switch
Tom> the source window to using a pad.

Tom> This patch fixes the bug by arranging to call prefresh whenever the
Tom> window is refreshed.

I'm checking this in now.

Tom

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

* Re: [PATCH] Don't erase TUI source window when switching focus
  2020-10-19 19:45 ` Tom Tromey
@ 2020-10-19 20:03   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2020-10-19 20:03 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 2020-10-19 3:45 p.m., Tom Tromey wrote:
>>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:
> 
> Tom> PR tui/26719 points out that switching the focus can erase the TUI
> Tom> source window.  This is a regression introduced by the patch to switch
> Tom> the source window to using a pad.
> 
> Tom> This patch fixes the bug by arranging to call prefresh whenever the
> Tom> window is refreshed.
> 
> I'm checking this in now.
> 
> Tom

Thanks, I confirm it fixes it for me.

Simon

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

end of thread, other threads:[~2020-10-19 20:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-09 20:27 [PATCH] Don't erase TUI source window when switching focus Tom Tromey
2020-10-19 19:45 ` Tom Tromey
2020-10-19 20:03   ` Simon Marchi

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