aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui/tui-data.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/tui/tui-data.c')
-rw-r--r--gdb/tui/tui-data.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 8f7d257..d475d03 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -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;
}