GNU Binutils with patches for OS216
Revision | eb9c88745686d46c5100bdf1c2f112d699c7f702 (tree) |
---|---|
Time | 2020-02-23 03:48:35 |
Author | Tom Tromey <tom@trom...> |
Commiter | Tom Tromey |
Reimplement tui_next_win and tui_prev_win
This reimplements tui_next_win and tui_prev_win. Now they account for
the possibility of windows not on tui_win_list.
gdb/ChangeLog
2020-02-22 Tom Tromey <tom@tromey.com>
* tui/tui-data.c (tui_next_win, tui_prev_win): Reimplement.
Change-Id: Ifcd402f76fe0a16e0fe9275a185d550279c01660
@@ -1,5 +1,9 @@ | ||
1 | 1 | 2020-02-22 Tom Tromey <tom@tromey.com> |
2 | 2 | |
3 | + * tui/tui-data.c (tui_next_win, tui_prev_win): Reimplement. | |
4 | + | |
5 | +2020-02-22 Tom Tromey <tom@tromey.com> | |
6 | + | |
3 | 7 | * tui/tui-winsource.h (struct tui_source_window_iterator) |
4 | 8 | <inner_iterator>: New etytypedef. |
5 | 9 | <tui_source_window_iterator>: Take "end" parameter. |
@@ -26,6 +26,7 @@ | ||
26 | 26 | #include "tui/tui-wingeneral.h" |
27 | 27 | #include "tui/tui-winsource.h" |
28 | 28 | #include "gdb_curses.h" |
29 | +#include <algorithm> | |
29 | 30 | |
30 | 31 | struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS]; |
31 | 32 |
@@ -103,28 +104,13 @@ tui_set_term_width_to (int w) | ||
103 | 104 | struct tui_win_info * |
104 | 105 | tui_next_win (struct tui_win_info *cur_win) |
105 | 106 | { |
106 | - int type = cur_win->type; | |
107 | - struct tui_win_info *next_win = NULL; | |
108 | - | |
109 | - if (cur_win->type == CMD_WIN) | |
110 | - type = SRC_WIN; | |
111 | - else | |
112 | - type = cur_win->type + 1; | |
113 | - while (type != cur_win->type && (next_win == NULL)) | |
114 | - { | |
115 | - if (tui_win_list[type] | |
116 | - && tui_win_list[type]->is_visible ()) | |
117 | - next_win = tui_win_list[type]; | |
118 | - else | |
119 | - { | |
120 | - if (type == CMD_WIN) | |
121 | - type = SRC_WIN; | |
122 | - else | |
123 | - type++; | |
124 | - } | |
125 | - } | |
107 | + auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win); | |
108 | + gdb_assert (iter != tui_windows.end ()); | |
126 | 109 | |
127 | - return next_win; | |
110 | + ++iter; | |
111 | + if (iter == tui_windows.end ()) | |
112 | + return tui_windows[0]; | |
113 | + return *iter; | |
128 | 114 | } |
129 | 115 | |
130 | 116 |
@@ -133,28 +119,13 @@ tui_next_win (struct tui_win_info *cur_win) | ||
133 | 119 | struct tui_win_info * |
134 | 120 | tui_prev_win (struct tui_win_info *cur_win) |
135 | 121 | { |
136 | - int type = cur_win->type; | |
137 | - struct tui_win_info *prev = NULL; | |
138 | - | |
139 | - if (cur_win->type == SRC_WIN) | |
140 | - type = CMD_WIN; | |
141 | - else | |
142 | - type = cur_win->type - 1; | |
143 | - while (type != cur_win->type && (prev == NULL)) | |
144 | - { | |
145 | - if (tui_win_list[type] | |
146 | - && tui_win_list[type]->is_visible ()) | |
147 | - prev = tui_win_list[type]; | |
148 | - else | |
149 | - { | |
150 | - if (type == SRC_WIN) | |
151 | - type = CMD_WIN; | |
152 | - else | |
153 | - type--; | |
154 | - } | |
155 | - } | |
122 | + auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win); | |
123 | + gdb_assert (iter != tui_windows.end ()); | |
156 | 124 | |
157 | - return prev; | |
125 | + if (iter == tui_windows.begin ()) | |
126 | + return tui_windows.back (); | |
127 | + --iter; | |
128 | + return *iter; | |
158 | 129 | } |
159 | 130 | |
160 | 131 |