From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 6B74E3858CD1; Fri, 8 Dec 2023 22:02:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B74E3858CD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1702072946; bh=IBA2XlOhLiDv4/JVig+PABadvdYv/pp+e9kvoA5pBQY=; h=From:To:Subject:Date:From; b=kB9yRhgNOGOHAerdR0qdbRTSsEn8CiwXRLQ5zH0Vnip94yJaYXyO9Yh/aumXus72N gMmUSZcYeB+SngGqzSiloHXxookaf5G/GcBMnHatH5J5VLsKieM40xgmRytmxsPSy2 W9rxSzUlyQDYNE9fUMxRmrom9M3IeDml+KNaqJ+w= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/tui] Show focus window in status line X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 576745e26c0ec76a53ba45b20af464628a50b3e4 X-Git-Newrev: 612f120d41e81056bf29db07f494f0cdf27b545d Message-Id: <20231208220226.6B74E3858CD1@sourceware.org> Date: Fri, 8 Dec 2023 22:02:26 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D612f120d41e8= 1056bf29db07f494f0cdf27b545d commit 612f120d41e81056bf29db07f494f0cdf27b545d Author: Tom de Vries Date: Fri Dec 8 23:02:31 2023 +0100 [gdb/tui] Show focus window in status line =20 The focused window is highlighted by using active-border-kind instead of border-kind. =20 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 scree= n which window has the focus. Instead, you have to notice the absence of highl= ighting on boxed windows, and then infer that the focus is on the unboxed windo= w. =20 That approach stops working if there are multiple unboxed windows. =20 Likewise if highlighting is switched off by setting active-border-kind = to the same value as border-kind. =20 Make it more explicit which window has the focus by mentioning it in th= e status window, like so: ... native process 8282 (src) In: main L7 PC: 0x400= 525 ... =20 Tested on x86_64-linux and ppc64le-linux. =20 Tested-By: Alexandra Petlanova Hajkova Reviewed-By: Eli Zaretskii Approved-By: Tom Tromey Diff: --- gdb/doc/gdb.texinfo | 3 +++ gdb/testsuite/gdb.tui/single-key.exp | 4 ++-- gdb/tui/tui-data.c | 2 ++ gdb/tui/tui-stack.c | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 15c71998d28..58685a77fd4 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -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}. =20 +@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}). diff --git a/gdb/testsuite/gdb.tui/single-key.exp b/gdb/testsuite/gdb.tui/s= ingle-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 } =20 # 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 =20 # 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" =20 diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index c51bd118165..f5a98233ea0 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 =20 @@ -69,6 +70,7 @@ tui_set_win_focus_to (struct tui_win_info *win_info) tui_unhighlight_win (win_with_focus); win_with_focus =3D win_info; tui_highlight_win (win_info); + tui_show_locator_content (); } } =20 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 =3D pc_out.c_str (); int pc_width =3D pc_out.size (); =20 + /* Width of the field showing the window with current focus. For a wind= ow + named "src" we show "(src)". */ + int focus_width =3D (tui_win_with_focus () !=3D 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 =3D (status_size @@ -116,6 +122,9 @@ tui_locator_window::make_status_line () const - (PC_PREFIX.size () + pc_width + 1) - (tui_current_key_mode =3D=3D TUI_SINGLE_KEY_MODE ? (SINGLE_KEY.size () + 1) + : 0) + - (focus_width > 0 + ? focus_width + 1 : 0)); =20 /* 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 (" "); } =20 + if (tui_win_with_focus () !=3D nullptr) + { + string.puts ("("); + string.puts (tui_win_with_focus ()->name ()); + string.puts (") "); + } + /* Procedure/class name. */ if (proc_width > 0) {