]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/tui] Show focus window in status line
authorTom de Vries <tdevries@suse.de>
Fri, 8 Dec 2023 22:02:31 +0000 (23:02 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 8 Dec 2023 22:02:31 +0000 (23:02 +0100)
The focused window is highlighted 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 and ppc64le-linux.

Tested-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
gdb/doc/gdb.texinfo
gdb/testsuite/gdb.tui/single-key.exp
gdb/tui/tui-data.c
gdb/tui/tui-stack.c

index 15c71998d28dd6f2157cf75353719eadb964a766..58685a77fd4e194e38d4324a25f170e65507a807 100644 (file)
@@ -30340,6 +30340,9 @@ Indicates the current @value{GDBN} target.
 Gives the current process or thread number.
 When no process is being debugged, this field is set to @code{No process}.
 
+@item focus
+Shows the name of the TUI window that has the focus.
+
 @item function
 Gives the current function name for the selected frame.
 The name is demangled if demangling is turned on (@pxref{Print Settings}).
index 07c9b00cce563e4ba603ebbe2a352eb1a26cc44a..3925a8142c1e3f617a3f4834a4c48a7328d860d9 100644 (file)
@@ -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"
 
index c51bd118165a3229740d143a90e6dff53b063d63..f5a98233ea0af71a139a3acec2d4d8c317c4641e 100644 (file)
@@ -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 ();
     }
 }
 
index 723d6268aada0286a450bf97448607fc914403dd..8bf65ea355692a4aeb4c9e8b0446f25e01972de3 100644 (file)
@@ -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)
     {