+2020-02-22 Tom Tromey <tom@tromey.com>
+
+ * tui/tui-data.c (tui_next_win, tui_prev_win): Reimplement.
+
2020-02-22 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.h (struct tui_source_window_iterator)
#include "tui/tui-wingeneral.h"
#include "tui/tui-winsource.h"
#include "gdb_curses.h"
+#include <algorithm>
struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
struct tui_win_info *
tui_next_win (struct tui_win_info *cur_win)
{
- int type = cur_win->type;
- struct tui_win_info *next_win = NULL;
-
- if (cur_win->type == CMD_WIN)
- type = SRC_WIN;
- else
- type = cur_win->type + 1;
- while (type != cur_win->type && (next_win == NULL))
- {
- if (tui_win_list[type]
- && tui_win_list[type]->is_visible ())
- next_win = tui_win_list[type];
- else
- {
- if (type == CMD_WIN)
- type = SRC_WIN;
- else
- type++;
- }
- }
+ auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win);
+ gdb_assert (iter != tui_windows.end ());
- return next_win;
+ ++iter;
+ if (iter == tui_windows.end ())
+ return tui_windows[0];
+ return *iter;
}
struct tui_win_info *
tui_prev_win (struct tui_win_info *cur_win)
{
- int type = cur_win->type;
- struct tui_win_info *prev = NULL;
-
- if (cur_win->type == SRC_WIN)
- type = CMD_WIN;
- else
- type = cur_win->type - 1;
- while (type != cur_win->type && (prev == NULL))
- {
- if (tui_win_list[type]
- && tui_win_list[type]->is_visible ())
- prev = tui_win_list[type];
- else
- {
- if (type == SRC_WIN)
- type = CMD_WIN;
- else
- type--;
- }
- }
+ auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win);
+ gdb_assert (iter != tui_windows.end ());
- return prev;
+ if (iter == tui_windows.begin ())
+ return tui_windows.back ();
+ --iter;
+ return *iter;
}