]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Don't let TUI focus on locator
authorTom Tromey <tromey@adacore.com>
Wed, 23 Sep 2020 18:57:19 +0000 (12:57 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 24 Sep 2020 19:03:18 +0000 (13:03 -0600)
PR tui/26638 notes that the C-x o binding can put the focus on the
locator window.  However, this is not useful and did not happen
historically.  This patch changes the TUI to skip this window when
switching focus.

2020-09-24  Tom Tromey  <tromey@adacore.com>

PR tui/26638:
* tui/tui-stack.h (struct tui_locator_window) <can_focus>: New
method.
* tui/tui-data.h (struct tui_win_info) <can_focus>: New method.
* tui/tui-data.c (tui_next_win): Exclude non-focusable windows.
(tui_prev_win): Rewrite.

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

PR tui/26638:
* gdb.tui/list.exp: Check output of "focus next".

gdb/ChangeLog
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.tui/list.exp
gdb/tui/tui-data.c
gdb/tui/tui-data.h
gdb/tui/tui-stack.h

index f26afc042da9b4a3cfa03b654fc05b9d0149ef69..e7d020314d01db1265a19e1d3e9e45af7895c7ce 100644 (file)
@@ -1,3 +1,12 @@
+2020-09-24  Tom Tromey  <tromey@adacore.com>
+
+       PR tui/26638:
+       * tui/tui-stack.h (struct tui_locator_window) <can_focus>: New
+       method.
+       * tui/tui-data.h (struct tui_win_info) <can_focus>: New method.
+       * tui/tui-data.c (tui_next_win): Exclude non-focusable windows.
+       (tui_prev_win): Rewrite.
+
 2020-09-23  Hannes Domani  <ssbssa@yahoo.de>
 
        * nat/windows-nat.c (handle_exception): Handle 64bit breakpoints
index 3fe12bfe3660f6f5d76e37cce6f91d9947599b4c..bef594693d2a2c918f59648c35721b432eb95090 100644 (file)
@@ -1,3 +1,8 @@
+2020-09-24  Tom Tromey  <tromey@adacore.com>
+
+       PR tui/26638:
+       * gdb.tui/list.exp: Check output of "focus next".
+
 2020-09-18  Victor Collod  <vcollod@nvidia.com>
 
        PR gdb/26635
index 77dbd69efd85850852d22c1196294104eeb4221f..576b33fa8698df5ba3f3ba9e789590bb5577d99a 100644 (file)
@@ -39,3 +39,4 @@ 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"
index 8f7d257e9457a8ef344b56f198e9f722abae6317..d475d03106517574f5e6eaefcee4b86fd95ce051 100644 (file)
@@ -113,9 +113,18 @@ tui_next_win (struct tui_win_info *cur_win)
   auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win);
   gdb_assert (iter != tui_windows.end ());
 
-  ++iter;
-  if (iter == tui_windows.end ())
-    return tui_windows[0];
+  gdb_assert (cur_win->can_focus ());
+  /* This won't loop forever since we can't have just an un-focusable
+     window.  */
+  while (true)
+    {
+      ++iter;
+      if (iter == tui_windows.end ())
+       iter = tui_windows.begin ();
+      if ((*iter)->can_focus ())
+       break;
+    }
+
   return *iter;
 }
 
@@ -125,12 +134,21 @@ tui_next_win (struct tui_win_info *cur_win)
 struct tui_win_info *
 tui_prev_win (struct tui_win_info *cur_win)
 {
-  auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win);
-  gdb_assert (iter != tui_windows.end ());
+  auto iter = std::find (tui_windows.rbegin (), tui_windows.rend (), cur_win);
+  gdb_assert (iter != tui_windows.rend ());
+
+  gdb_assert (cur_win->can_focus ());
+  /* This won't loop forever since we can't have just an un-focusable
+     window.  */
+  while (true)
+    {
+      ++iter;
+      if (iter == tui_windows.rend ())
+       iter = tui_windows.rbegin ();
+      if ((*iter)->can_focus ())
+       break;
+    }
 
-  if (iter == tui_windows.begin ())
-    return tui_windows.back ();
-  --iter;
   return *iter;
 }
 
index 5e7a12293c9a2d8ce42a378346140dcc2759d1ec..d61bfc7dff8d9947b24fbeeb3b2879586911a759 100644 (file)
@@ -99,6 +99,12 @@ public:
     return handle != nullptr;
   }
 
+  /* Return true if this window can accept the focus.  */
+  virtual bool can_focus () const
+  {
+    return true;
+  }
+
   /* Disable output until the next call to doupdate.  */
   void no_refresh ()
   {
index 9ff57b1ba73e4e07607edc39c57c9c8544cb77fa..0e5916f0ce33730f5d91f71e11663e49e5a1c7de 100644 (file)
@@ -52,6 +52,11 @@ struct tui_locator_window : public tui_win_info
     return false;
   }
 
+  bool can_focus () const override
+  {
+    return false;
+  }
+
   void rerender () override;
 
   /* Update the locator, with the provided arguments.