public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/2] [gdb/tui] Show focus window in status line
@ 2023-11-27  3:45 Tom de Vries
  2023-12-08 15:37 ` Tom Tromey
  0 siblings, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2023-11-27  3:45 UTC (permalink / raw)
  To: gdb-patches

The focused window is highlighting by using active-border-kind instead of
border-kind.

But if the focused window is the cmd window (which is an unboxed window), then
no highlighting is done, and it's not obvious from looking at the screen which
window has the focus.  Instead, you have to notice the absence of highlighting
on boxed windows, and then infer that the focus is on the unboxed window.

That approach stops working if there are multiple unboxed windows.

Likewise if highlighting is switched off by setting active-border-kind to the
same value as border-kind.

Make it more explicit which window has the focus by mentioning it in the status
window, like so:
...
native process 8282 (src) In: main                      L7    PC: 0x400525
...

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.tui/single-key.exp |  4 ++--
 gdb/tui/tui-data.c                   |  2 ++
 gdb/tui/tui-stack.c                  | 16 ++++++++++++++++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.tui/single-key.exp b/gdb/testsuite/gdb.tui/single-key.exp
index 07c9b00cce5..3925a8142c1 100644
--- a/gdb/testsuite/gdb.tui/single-key.exp
+++ b/gdb/testsuite/gdb.tui/single-key.exp
@@ -25,12 +25,12 @@ set status_win { 0 15 80 1 }
 set command_win { 0 16 80 8 }
 
 # Check that the status window doesn't show Singlekey.
-set re "No process In:"
+set re [string_to_regexp "No process (src) In:"]
 Term::check_region_contents  "status window: initial" {*}$status_win $re
 
 # Enter single-key mode.  Check that the status window does show Singlekey.
 send_gdb "\030s"
-set re "No process \\(SingleKey\\) In:"
+set re [string_to_regexp "No process (SingleKey) (src) In:"]
 gdb_assert { [Term::wait_for_region_contents {*}$status_win $re] } \
     "status window: single-key mode"
 
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index fc90df25ddd..5e05cccf603 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -26,6 +26,7 @@
 #include "tui/tui-win.h"
 #include "tui/tui-wingeneral.h"
 #include "tui/tui-winsource.h"
+#include "tui/tui-stack.h"
 #include "gdb_curses.h"
 #include <algorithm>
 
@@ -69,6 +70,7 @@ tui_set_win_focus_to (struct tui_win_info *win_info)
       tui_unhighlight_win (win_with_focus);
       win_with_focus = win_info;
       tui_highlight_win (win_info);
+      tui_show_locator_content ();
     }
 }
 
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 723d6268aad..8bf65ea3556 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -106,6 +106,12 @@ tui_locator_window::make_status_line () const
   const char *pc_buf = pc_out.c_str ();
   int pc_width = pc_out.size ();
 
+  /* Width of the field showing the window with current focus.  For a window
+     named "src" we show "(src)".  */
+  int focus_width = (tui_win_with_focus () != nullptr
+		     ? 1 + strlen (tui_win_with_focus ()->name ()) + 1
+		     : 0);
+
   /* First determine the amount of proc name width we have available.
      The +1 are for a space separator between fields.  */
   proc_width = (status_size
@@ -116,6 +122,9 @@ tui_locator_window::make_status_line () const
 		- (PC_PREFIX.size () + pc_width + 1)
 		- (tui_current_key_mode == TUI_SINGLE_KEY_MODE
 		   ? (SINGLE_KEY.size () + 1)
+		   : 0)
+		- (focus_width > 0
+		   ? focus_width + 1
 		   : 0));
 
   /* If there is no room to print the function name, try by removing
@@ -159,6 +168,13 @@ tui_locator_window::make_status_line () const
       string.puts (" ");
     }
 
+  if (tui_win_with_focus () != nullptr)
+    {
+      string.puts ("(");
+      string.puts (tui_win_with_focus ()->name ());
+      string.puts (") ");
+    }
+
   /* Procedure/class name.  */
   if (proc_width > 0)
     {
-- 
2.35.3


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

* Re: [PATCH 2/2] [gdb/tui] Show focus window in status line
  2023-11-27  3:45 [PATCH 2/2] [gdb/tui] Show focus window in status line Tom de Vries
@ 2023-12-08 15:37 ` Tom Tromey
  2023-12-08 16:51   ` Tom de Vries
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2023-12-08 15:37 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> The focused window is highlighting by using active-border-kind instead of
Tom> border-kind.

Tom> But if the focused window is the cmd window (which is an unboxed window), then
Tom> no highlighting is done, and it's not obvious from looking at the screen which
Tom> window has the focus.  Instead, you have to notice the absence of highlighting
Tom> on boxed windows, and then infer that the focus is on the unboxed window.

Tom> That approach stops working if there are multiple unboxed windows.

Tom> Likewise if highlighting is switched off by setting active-border-kind to the
Tom> same value as border-kind.

Tom> Make it more explicit which window has the focus by mentioning it in the status
Tom> window, like so:
Tom> ...
Tom> native process 8282 (src) In: main                      L7    PC: 0x400525
Tom> ...

This seems fine to me, but the contents of the status line are
documented in the "TUI Overview" section, so I think that should be
updated.

Tom

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

* Re: [PATCH 2/2] [gdb/tui] Show focus window in status line
  2023-12-08 15:37 ` Tom Tromey
@ 2023-12-08 16:51   ` Tom de Vries
  0 siblings, 0 replies; 6+ messages in thread
From: Tom de Vries @ 2023-12-08 16:51 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 12/8/23 16:37, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
> 
> Tom> The focused window is highlighting by using active-border-kind instead of
> Tom> border-kind.
> 
> Tom> But if the focused window is the cmd window (which is an unboxed window), then
> Tom> no highlighting is done, and it's not obvious from looking at the screen which
> Tom> window has the focus.  Instead, you have to notice the absence of highlighting
> Tom> on boxed windows, and then infer that the focus is on the unboxed window.
> 
> Tom> That approach stops working if there are multiple unboxed windows.
> 
> Tom> Likewise if highlighting is switched off by setting active-border-kind to the
> Tom> same value as border-kind.
> 
> Tom> Make it more explicit which window has the focus by mentioning it in the status
> Tom> window, like so:
> Tom> ...
> Tom> native process 8282 (src) In: main                      L7    PC: 0x400525
> Tom> ...
> 
> This seems fine to me, but the contents of the status line are
> documented in the "TUI Overview" section, so I think that should be
> updated.

Thanks for the review.

I've sent a v2 with doc added here ( 
https://sourceware.org/pipermail/gdb-patches/2023-December/204912.html ).

Thanks,
- Tom



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

* Re: [PATCH 2/2] [gdb/tui] Show focus window in status line
  2023-11-28 15:22   ` Alexandra Petlanova Hajkova
@ 2023-11-28 17:03     ` Tom de Vries
  0 siblings, 0 replies; 6+ messages in thread
From: Tom de Vries @ 2023-11-28 17:03 UTC (permalink / raw)
  To: Alexandra Petlanova Hajkova; +Cc: gdb-patches, Tom Tromey

On 11/28/23 16:22, Alexandra Petlanova Hajkova wrote:
> 
> 
> On Mon, Nov 27, 2023 at 4:48 AM Tom de Vries <tdevries@suse.de 
> <mailto:tdevries@suse.de>> wrote:
> 
>     The focused window is highlighting by using active-border-kind

Hi,

I see now this should be "highlighted".

>     instead of
>     border-kind.
> 
>     But if the focused window is the cmd window (which is an unboxed
>     window), then
>     no highlighting is done, and it's not obvious from looking at the
>     screen which
>     window has the focus.  Instead, you have to notice the absence of
>     highlighting
>     on boxed windows, and then infer that the focus is on the unboxed
>     window.
> 
>     That approach stops working if there are multiple unboxed windows.
> 
>     Likewise if highlighting is switched off by setting
>     active-border-kind to the
>     same value as border-kind.
> 
>     Make it more explicit which window has the focus by mentioning it in
>     the status
>     window, like so:
>     ...
>     native process 8282 (src) In: main                      L7    PC:
>     0x400525
>     ...
> 
>     Tested on x86_64-linux.
>     ---
>     I can confirm it works for ppc64le Fedora Rawhide, the (src) is
>     neatly there. Causes no regressions.
> 

Thanks for testing this.

Since this is user-visible, I'll leave this for Tom to comment.

Thanks,
- Tom


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

* Re: [PATCH 2/2] [gdb/tui] Show focus window in status line
  2023-11-27  3:39 ` [PATCH 2/2] [gdb/tui] Show focus window in status line Tom de Vries
@ 2023-11-28 15:22   ` Alexandra Petlanova Hajkova
  2023-11-28 17:03     ` Tom de Vries
  0 siblings, 1 reply; 6+ messages in thread
From: Alexandra Petlanova Hajkova @ 2023-11-28 15:22 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]

On Mon, Nov 27, 2023 at 4:48 AM Tom de Vries <tdevries@suse.de> wrote:

> The focused window is highlighting by using active-border-kind instead of
> border-kind.
>
> But if the focused window is the cmd window (which is an unboxed window),
> then
> no highlighting is done, and it's not obvious from looking at the screen
> which
> window has the focus.  Instead, you have to notice the absence of
> highlighting
> on boxed windows, and then infer that the focus is on the unboxed window.
>
> That approach stops working if there are multiple unboxed windows.
>
> Likewise if highlighting is switched off by setting active-border-kind to
> the
> same value as border-kind.
>
> Make it more explicit which window has the focus by mentioning it in the
> status
> window, like so:
> ...
> native process 8282 (src) In: main                      L7    PC: 0x400525
> ...
>
> Tested on x86_64-linux.
> ---
> I can confirm it works for ppc64le Fedora Rawhide, the (src) is neatly
> there. Causes no regressions.
>

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

* [PATCH 2/2] [gdb/tui] Show focus window in status line
  2023-11-27  3:39 [PATCH 1/2] [gdb/tui] Use const std::string for string literals in tui-stack.c Tom de Vries
@ 2023-11-27  3:39 ` Tom de Vries
  2023-11-28 15:22   ` Alexandra Petlanova Hajkova
  0 siblings, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2023-11-27  3:39 UTC (permalink / raw)
  To: gdb-patches

The focused window is highlighting by using active-border-kind instead of
border-kind.

But if the focused window is the cmd window (which is an unboxed window), then
no highlighting is done, and it's not obvious from looking at the screen which
window has the focus.  Instead, you have to notice the absence of highlighting
on boxed windows, and then infer that the focus is on the unboxed window.

That approach stops working if there are multiple unboxed windows.

Likewise if highlighting is switched off by setting active-border-kind to the
same value as border-kind.

Make it more explicit which window has the focus by mentioning it in the status
window, like so:
...
native process 8282 (src) In: main                      L7    PC: 0x400525
...

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.tui/single-key.exp |  4 ++--
 gdb/tui/tui-data.c                   |  2 ++
 gdb/tui/tui-stack.c                  | 16 ++++++++++++++++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.tui/single-key.exp b/gdb/testsuite/gdb.tui/single-key.exp
index 07c9b00cce5..3925a8142c1 100644
--- a/gdb/testsuite/gdb.tui/single-key.exp
+++ b/gdb/testsuite/gdb.tui/single-key.exp
@@ -25,12 +25,12 @@ set status_win { 0 15 80 1 }
 set command_win { 0 16 80 8 }
 
 # Check that the status window doesn't show Singlekey.
-set re "No process In:"
+set re [string_to_regexp "No process (src) In:"]
 Term::check_region_contents  "status window: initial" {*}$status_win $re
 
 # Enter single-key mode.  Check that the status window does show Singlekey.
 send_gdb "\030s"
-set re "No process \\(SingleKey\\) In:"
+set re [string_to_regexp "No process (SingleKey) (src) In:"]
 gdb_assert { [Term::wait_for_region_contents {*}$status_win $re] } \
     "status window: single-key mode"
 
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index fc90df25ddd..5e05cccf603 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -26,6 +26,7 @@
 #include "tui/tui-win.h"
 #include "tui/tui-wingeneral.h"
 #include "tui/tui-winsource.h"
+#include "tui/tui-stack.h"
 #include "gdb_curses.h"
 #include <algorithm>
 
@@ -69,6 +70,7 @@ tui_set_win_focus_to (struct tui_win_info *win_info)
       tui_unhighlight_win (win_with_focus);
       win_with_focus = win_info;
       tui_highlight_win (win_info);
+      tui_show_locator_content ();
     }
 }
 
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 723d6268aad..8bf65ea3556 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -106,6 +106,12 @@ tui_locator_window::make_status_line () const
   const char *pc_buf = pc_out.c_str ();
   int pc_width = pc_out.size ();
 
+  /* Width of the field showing the window with current focus.  For a window
+     named "src" we show "(src)".  */
+  int focus_width = (tui_win_with_focus () != nullptr
+		     ? 1 + strlen (tui_win_with_focus ()->name ()) + 1
+		     : 0);
+
   /* First determine the amount of proc name width we have available.
      The +1 are for a space separator between fields.  */
   proc_width = (status_size
@@ -116,6 +122,9 @@ tui_locator_window::make_status_line () const
 		- (PC_PREFIX.size () + pc_width + 1)
 		- (tui_current_key_mode == TUI_SINGLE_KEY_MODE
 		   ? (SINGLE_KEY.size () + 1)
+		   : 0)
+		- (focus_width > 0
+		   ? focus_width + 1
 		   : 0));
 
   /* If there is no room to print the function name, try by removing
@@ -159,6 +168,13 @@ tui_locator_window::make_status_line () const
       string.puts (" ");
     }
 
+  if (tui_win_with_focus () != nullptr)
+    {
+      string.puts ("(");
+      string.puts (tui_win_with_focus ()->name ());
+      string.puts (") ");
+    }
+
   /* Procedure/class name.  */
   if (proc_width > 0)
     {
-- 
2.35.3


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

end of thread, other threads:[~2023-12-08 16:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-27  3:45 [PATCH 2/2] [gdb/tui] Show focus window in status line Tom de Vries
2023-12-08 15:37 ` Tom Tromey
2023-12-08 16:51   ` Tom de Vries
  -- strict thread matches above, loose matches on Subject: below --
2023-11-27  3:39 [PATCH 1/2] [gdb/tui] Use const std::string for string literals in tui-stack.c Tom de Vries
2023-11-27  3:39 ` [PATCH 2/2] [gdb/tui] Show focus window in status line Tom de Vries
2023-11-28 15:22   ` Alexandra Petlanova Hajkova
2023-11-28 17:03     ` Tom de Vries

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