Commit | Line | Data |
---|---|---|
f377b406 | 1 | /* General window behavior. |
f33c6cbf | 2 | |
42a4f53d | 3 | Copyright (C) 1998-2019 Free Software Foundation, Inc. |
f33c6cbf | 4 | |
f377b406 SC |
5 | Contributed by Hewlett-Packard Company. |
6 | ||
7 | This file is part of GDB. | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 11 | the Free Software Foundation; either version 3 of the License, or |
f377b406 SC |
12 | (at your option) any later version. |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c | 21 | |
96ec9981 | 22 | #include "defs.h" |
d7b2e967 AC |
23 | #include "tui/tui.h" |
24 | #include "tui/tui-data.h" | |
25 | #include "tui/tui-wingeneral.h" | |
26 | #include "tui/tui-win.h" | |
f33c6cbf | 27 | |
6a83354a | 28 | #include "gdb_curses.h" |
4e8f7a8b | 29 | |
c906108c SS |
30 | /*********************** |
31 | ** PUBLIC FUNCTIONS | |
32 | ***********************/ | |
ec7d9e56 | 33 | |
1cc6d956 | 34 | /* Refresh the window. */ |
c906108c | 35 | void |
5b6fe301 | 36 | tui_refresh_win (struct tui_gen_win_info *win_info) |
c906108c | 37 | { |
6d012f14 | 38 | if (win_info->type == DATA_WIN && win_info->content_size > 0) |
c906108c SS |
39 | { |
40 | int i; | |
41 | ||
6d012f14 | 42 | for (i = 0; (i < win_info->content_size); i++) |
c906108c | 43 | { |
5b6fe301 | 44 | struct tui_gen_win_info *data_item_win_ptr; |
c906108c | 45 | |
dc2c33e4 | 46 | data_item_win_ptr = win_info->content[i]->which_element.data_window; |
6ba8e26f | 47 | if (data_item_win_ptr != NULL |
cafb3438 | 48 | && data_item_win_ptr->handle != NULL) |
6ba8e26f | 49 | wrefresh (data_item_win_ptr->handle); |
c906108c SS |
50 | } |
51 | } | |
6d012f14 | 52 | else if (win_info->type == CMD_WIN) |
c906108c | 53 | { |
1cc6d956 | 54 | /* Do nothing. */ |
c906108c SS |
55 | } |
56 | else | |
57 | { | |
cafb3438 | 58 | if (win_info->handle != NULL) |
6d012f14 | 59 | wrefresh (win_info->handle); |
c906108c SS |
60 | } |
61 | ||
62 | return; | |
ec7d9e56 | 63 | } |
c906108c SS |
64 | |
65 | ||
1cc6d956 | 66 | /* Function to delete the curses window, checking for NULL. */ |
c906108c | 67 | void |
5b6fe301 | 68 | tui_delete_win (WINDOW *window) |
c906108c | 69 | { |
cafb3438 | 70 | if (window != NULL) |
c906108c SS |
71 | delwin (window); |
72 | ||
73 | return; | |
ec7d9e56 | 74 | } |
c906108c SS |
75 | |
76 | ||
af101512 | 77 | /* Draw a border arround the window. */ |
2c0b251b | 78 | static void |
08ef48c5 MS |
79 | box_win (struct tui_gen_win_info *win_info, |
80 | int highlight_flag) | |
c906108c | 81 | { |
6d012f14 | 82 | if (win_info && win_info->handle) |
c906108c | 83 | { |
af101512 SC |
84 | WINDOW *win; |
85 | int attrs; | |
86 | ||
6d012f14 | 87 | win = win_info->handle; |
6ba8e26f | 88 | if (highlight_flag == HILITE) |
af101512 | 89 | attrs = tui_active_border_attrs; |
c906108c | 90 | else |
af101512 SC |
91 | attrs = tui_border_attrs; |
92 | ||
93 | wattron (win, attrs); | |
8b9cf735 | 94 | #ifdef HAVE_WBORDER |
af101512 SC |
95 | wborder (win, tui_border_vline, tui_border_vline, |
96 | tui_border_hline, tui_border_hline, | |
97 | tui_border_ulcorner, tui_border_urcorner, | |
98 | tui_border_llcorner, tui_border_lrcorner); | |
8b9cf735 MK |
99 | #else |
100 | box (win, tui_border_vline, tui_border_hline); | |
101 | #endif | |
6d012f14 | 102 | if (win_info->title) |
63a33118 | 103 | mvwaddstr (win, 0, 3, win_info->title); |
af101512 | 104 | wattroff (win, attrs); |
c906108c | 105 | } |
af101512 | 106 | } |
c906108c SS |
107 | |
108 | ||
c906108c | 109 | void |
5b6fe301 | 110 | tui_unhighlight_win (struct tui_win_info *win_info) |
c906108c | 111 | { |
e5908723 | 112 | if (win_info != NULL |
cb2ce893 | 113 | && win_info->handle != NULL) |
c906108c | 114 | { |
cb2ce893 TT |
115 | box_win (win_info, NO_HILITE); |
116 | wrefresh (win_info->handle); | |
214a5cbe | 117 | win_info->set_highlight (false); |
c906108c | 118 | } |
ec7d9e56 | 119 | } |
c906108c SS |
120 | |
121 | ||
c906108c | 122 | void |
5b6fe301 | 123 | tui_highlight_win (struct tui_win_info *win_info) |
c906108c | 124 | { |
6d012f14 AC |
125 | if (win_info != NULL |
126 | && win_info->can_highlight | |
cb2ce893 | 127 | && win_info->handle != NULL) |
c906108c | 128 | { |
cb2ce893 TT |
129 | box_win (win_info, HILITE); |
130 | wrefresh (win_info->handle); | |
214a5cbe | 131 | win_info->set_highlight (true); |
c906108c | 132 | } |
ec7d9e56 | 133 | } |
c906108c | 134 | |
c906108c | 135 | void |
5b6fe301 | 136 | tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info) |
c906108c | 137 | { |
cb2ce893 | 138 | if (win_info != NULL && win_info->type != CMD_WIN) |
c906108c | 139 | { |
6d012f14 AC |
140 | if (win_info->is_highlighted) |
141 | tui_highlight_win (win_info); | |
c906108c | 142 | else |
6d012f14 | 143 | tui_unhighlight_win (win_info); |
c906108c SS |
144 | |
145 | } | |
146 | return; | |
ec7d9e56 | 147 | } |
c906108c SS |
148 | |
149 | ||
c906108c | 150 | void |
5b6fe301 | 151 | tui_make_window (struct tui_gen_win_info *win_info, int box_it) |
c906108c SS |
152 | { |
153 | WINDOW *handle; | |
154 | ||
6d012f14 AC |
155 | handle = newwin (win_info->height, |
156 | win_info->width, | |
157 | win_info->origin.y, | |
158 | win_info->origin.x); | |
159 | win_info->handle = handle; | |
cafb3438 | 160 | if (handle != NULL) |
c906108c | 161 | { |
6ba8e26f AC |
162 | if (box_it == BOX_WINDOW) |
163 | box_win (win_info, NO_HILITE); | |
56122977 | 164 | win_info->is_visible = true; |
c906108c | 165 | scrollok (handle, TRUE); |
c906108c | 166 | } |
bc712bbf | 167 | } |
c906108c SS |
168 | |
169 | ||
ec7d9e56 AC |
170 | /* We can't really make windows visible, or invisible. So we have to |
171 | delete the entire window when making it visible, and create it | |
172 | again when making it visible. */ | |
173 | static void | |
56122977 | 174 | make_visible (struct tui_gen_win_info *win_info, bool visible) |
c906108c | 175 | { |
1cc6d956 | 176 | /* Don't tear down/recreate command window. */ |
ec7d9e56 | 177 | if (win_info->type == CMD_WIN) |
c906108c SS |
178 | return; |
179 | ||
180 | if (visible) | |
181 | { | |
6d012f14 | 182 | if (!win_info->is_visible) |
c906108c | 183 | { |
8e2daf15 | 184 | tui_make_window (win_info, !tui_win_is_auxillary (win_info->type)); |
56122977 | 185 | win_info->is_visible = true; |
c906108c | 186 | } |
c906108c | 187 | } |
e5908723 MS |
188 | else if (!visible |
189 | && win_info->is_visible | |
cafb3438 | 190 | && win_info->handle != NULL) |
c906108c | 191 | { |
56122977 | 192 | win_info->is_visible = false; |
ec7d9e56 | 193 | tui_delete_win (win_info->handle); |
e65b5245 | 194 | win_info->handle = NULL; |
c906108c SS |
195 | } |
196 | ||
197 | return; | |
ec7d9e56 | 198 | } |
c906108c | 199 | |
ec7d9e56 AC |
200 | void |
201 | tui_make_visible (struct tui_gen_win_info *win_info) | |
202 | { | |
56122977 | 203 | make_visible (win_info, true); |
ec7d9e56 | 204 | } |
c906108c | 205 | |
c906108c | 206 | void |
ec7d9e56 AC |
207 | tui_make_invisible (struct tui_gen_win_info *win_info) |
208 | { | |
56122977 | 209 | make_visible (win_info, false); |
ec7d9e56 AC |
210 | } |
211 | ||
cda37efb TT |
212 | /* See tui-data.h. */ |
213 | ||
214 | void | |
56122977 | 215 | tui_win_info::make_visible (bool visible) |
cda37efb | 216 | { |
cb2ce893 | 217 | ::make_visible (this, visible); |
cda37efb TT |
218 | } |
219 | ||
220 | /* See tui-data.h. */ | |
221 | ||
222 | void | |
56122977 | 223 | tui_source_window_base::make_visible (bool visible) |
cda37efb TT |
224 | { |
225 | ::make_visible (execution_info, visible); | |
226 | tui_win_info::make_visible (visible); | |
227 | } | |
ec7d9e56 | 228 | |
1cc6d956 MS |
229 | /* Makes all windows invisible (except the command and locator |
230 | windows). */ | |
ec7d9e56 | 231 | static void |
56122977 | 232 | make_all_visible (bool visible) |
c906108c SS |
233 | { |
234 | int i; | |
235 | ||
236 | for (i = 0; i < MAX_MAJOR_WINDOWS; i++) | |
237 | { | |
cda37efb TT |
238 | if (tui_win_list[i] != NULL) |
239 | tui_win_list[i]->make_visible (visible); | |
c906108c SS |
240 | } |
241 | ||
242 | return; | |
ec7d9e56 AC |
243 | } |
244 | ||
245 | void | |
246 | tui_make_all_visible (void) | |
247 | { | |
56122977 | 248 | make_all_visible (true); |
ec7d9e56 AC |
249 | } |
250 | ||
251 | void | |
252 | tui_make_all_invisible (void) | |
253 | { | |
56122977 | 254 | make_all_visible (false); |
ec7d9e56 AC |
255 | } |
256 | ||
2042b506 TT |
257 | /* See tui-data.h. */ |
258 | ||
259 | void | |
260 | tui_win_info::refresh () | |
261 | { | |
cb2ce893 TT |
262 | touchwin (handle); |
263 | tui_refresh_win (this); | |
2042b506 TT |
264 | } |
265 | ||
266 | /* See tui-data.h. */ | |
267 | ||
268 | void | |
269 | tui_source_window_base::refresh () | |
270 | { | |
271 | touchwin (execution_info->handle); | |
272 | tui_refresh_win (execution_info); | |
273 | tui_win_info::refresh (); | |
274 | } | |
275 | ||
ec7d9e56 | 276 | /* Function to refresh all the windows currently displayed. */ |
c906108c | 277 | |
c906108c | 278 | void |
5b6fe301 | 279 | tui_refresh_all (struct tui_win_info **list) |
c906108c | 280 | { |
570dc176 | 281 | int type; |
5b6fe301 | 282 | struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); |
c906108c SS |
283 | |
284 | for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++) | |
285 | { | |
cb2ce893 | 286 | if (list[type] && list[type]->is_visible) |
2042b506 | 287 | list[type]->refresh (); |
c906108c | 288 | } |
6d012f14 | 289 | if (locator->is_visible) |
c906108c SS |
290 | { |
291 | touchwin (locator->handle); | |
ec7d9e56 | 292 | tui_refresh_win (locator); |
c906108c | 293 | } |
6ba8e26f | 294 | } |
c906108c SS |
295 | |
296 | ||
297 | /********************************* | |
298 | ** Local Static Functions | |
299 | *********************************/ |