Commit | Line | Data |
---|---|---|
f377b406 | 1 | /* General window behavior. |
f33c6cbf | 2 | |
32d0add0 | 3 | Copyright (C) 1998-2015 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 | |
6ba8e26f | 46 | data_item_win_ptr = &((tui_win_content) |
08ef48c5 | 47 | win_info->content)[i]->which_element.data_window; |
6ba8e26f AC |
48 | if (data_item_win_ptr != NULL |
49 | && data_item_win_ptr->handle != (WINDOW *) NULL) | |
50 | wrefresh (data_item_win_ptr->handle); | |
c906108c SS |
51 | } |
52 | } | |
6d012f14 | 53 | else if (win_info->type == CMD_WIN) |
c906108c | 54 | { |
1cc6d956 | 55 | /* Do nothing. */ |
c906108c SS |
56 | } |
57 | else | |
58 | { | |
6d012f14 AC |
59 | if (win_info->handle != (WINDOW *) NULL) |
60 | wrefresh (win_info->handle); | |
c906108c SS |
61 | } |
62 | ||
63 | return; | |
ec7d9e56 | 64 | } |
c906108c SS |
65 | |
66 | ||
1cc6d956 | 67 | /* Function to delete the curses window, checking for NULL. */ |
c906108c | 68 | void |
5b6fe301 | 69 | tui_delete_win (WINDOW *window) |
c906108c SS |
70 | { |
71 | if (window != (WINDOW *) NULL) | |
72 | delwin (window); | |
73 | ||
74 | return; | |
ec7d9e56 | 75 | } |
c906108c SS |
76 | |
77 | ||
af101512 | 78 | /* Draw a border arround the window. */ |
2c0b251b | 79 | static void |
08ef48c5 MS |
80 | box_win (struct tui_gen_win_info *win_info, |
81 | int highlight_flag) | |
c906108c | 82 | { |
6d012f14 | 83 | if (win_info && win_info->handle) |
c906108c | 84 | { |
af101512 SC |
85 | WINDOW *win; |
86 | int attrs; | |
87 | ||
6d012f14 | 88 | win = win_info->handle; |
6ba8e26f | 89 | if (highlight_flag == HILITE) |
af101512 | 90 | attrs = tui_active_border_attrs; |
c906108c | 91 | else |
af101512 SC |
92 | attrs = tui_border_attrs; |
93 | ||
94 | wattron (win, attrs); | |
8b9cf735 | 95 | #ifdef HAVE_WBORDER |
af101512 SC |
96 | wborder (win, tui_border_vline, tui_border_vline, |
97 | tui_border_hline, tui_border_hline, | |
98 | tui_border_ulcorner, tui_border_urcorner, | |
99 | tui_border_llcorner, tui_border_lrcorner); | |
8b9cf735 MK |
100 | #else |
101 | box (win, tui_border_vline, tui_border_hline); | |
102 | #endif | |
6d012f14 AC |
103 | if (win_info->title) |
104 | mvwaddstr (win, 0, 3, win_info->title); | |
af101512 | 105 | wattroff (win, attrs); |
c906108c | 106 | } |
af101512 | 107 | } |
c906108c SS |
108 | |
109 | ||
c906108c | 110 | void |
5b6fe301 | 111 | tui_unhighlight_win (struct tui_win_info *win_info) |
c906108c | 112 | { |
e5908723 MS |
113 | if (win_info != NULL |
114 | && win_info->generic.handle != (WINDOW *) NULL) | |
c906108c | 115 | { |
6ba8e26f | 116 | box_win ((struct tui_gen_win_info *) win_info, NO_HILITE); |
6d012f14 AC |
117 | wrefresh (win_info->generic.handle); |
118 | tui_set_win_highlight (win_info, 0); | |
c906108c | 119 | } |
ec7d9e56 | 120 | } |
c906108c SS |
121 | |
122 | ||
c906108c | 123 | void |
5b6fe301 | 124 | tui_highlight_win (struct tui_win_info *win_info) |
c906108c | 125 | { |
6d012f14 AC |
126 | if (win_info != NULL |
127 | && win_info->can_highlight | |
128 | && win_info->generic.handle != (WINDOW *) NULL) | |
c906108c | 129 | { |
6ba8e26f | 130 | box_win ((struct tui_gen_win_info *) win_info, HILITE); |
6d012f14 AC |
131 | wrefresh (win_info->generic.handle); |
132 | tui_set_win_highlight (win_info, 1); | |
c906108c | 133 | } |
ec7d9e56 | 134 | } |
c906108c | 135 | |
c906108c | 136 | void |
5b6fe301 | 137 | tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info) |
c906108c | 138 | { |
6d012f14 | 139 | if (win_info != NULL && win_info->generic.type != CMD_WIN) |
c906108c | 140 | { |
6d012f14 AC |
141 | if (win_info->is_highlighted) |
142 | tui_highlight_win (win_info); | |
c906108c | 143 | else |
6d012f14 | 144 | tui_unhighlight_win (win_info); |
c906108c SS |
145 | |
146 | } | |
147 | return; | |
ec7d9e56 | 148 | } |
c906108c SS |
149 | |
150 | ||
c906108c | 151 | void |
5b6fe301 | 152 | tui_make_window (struct tui_gen_win_info *win_info, int box_it) |
c906108c SS |
153 | { |
154 | WINDOW *handle; | |
155 | ||
6d012f14 AC |
156 | handle = newwin (win_info->height, |
157 | win_info->width, | |
158 | win_info->origin.y, | |
159 | win_info->origin.x); | |
160 | win_info->handle = handle; | |
c906108c SS |
161 | if (handle != (WINDOW *) NULL) |
162 | { | |
6ba8e26f AC |
163 | if (box_it == BOX_WINDOW) |
164 | box_win (win_info, NO_HILITE); | |
6d012f14 | 165 | win_info->is_visible = TRUE; |
c906108c | 166 | scrollok (handle, TRUE); |
c906108c | 167 | } |
bc712bbf | 168 | } |
c906108c SS |
169 | |
170 | ||
ec7d9e56 AC |
171 | /* We can't really make windows visible, or invisible. So we have to |
172 | delete the entire window when making it visible, and create it | |
173 | again when making it visible. */ | |
174 | static void | |
175 | make_visible (struct tui_gen_win_info *win_info, int visible) | |
c906108c | 176 | { |
1cc6d956 | 177 | /* Don't tear down/recreate command window. */ |
ec7d9e56 | 178 | if (win_info->type == CMD_WIN) |
c906108c SS |
179 | return; |
180 | ||
181 | if (visible) | |
182 | { | |
6d012f14 | 183 | if (!win_info->is_visible) |
c906108c | 184 | { |
ec7d9e56 AC |
185 | tui_make_window (win_info, |
186 | (win_info->type != CMD_WIN | |
6d012f14 AC |
187 | && !tui_win_is_auxillary (win_info->type))); |
188 | win_info->is_visible = TRUE; | |
c906108c | 189 | } |
c906108c | 190 | } |
e5908723 MS |
191 | else if (!visible |
192 | && win_info->is_visible | |
193 | && win_info->handle != (WINDOW *) NULL) | |
c906108c | 194 | { |
6d012f14 | 195 | win_info->is_visible = FALSE; |
ec7d9e56 AC |
196 | tui_delete_win (win_info->handle); |
197 | win_info->handle = (WINDOW *) NULL; | |
c906108c SS |
198 | } |
199 | ||
200 | return; | |
ec7d9e56 | 201 | } |
c906108c | 202 | |
ec7d9e56 AC |
203 | void |
204 | tui_make_visible (struct tui_gen_win_info *win_info) | |
205 | { | |
206 | make_visible (win_info, 1); | |
207 | } | |
c906108c | 208 | |
c906108c | 209 | void |
ec7d9e56 AC |
210 | tui_make_invisible (struct tui_gen_win_info *win_info) |
211 | { | |
212 | make_visible (win_info, 0); | |
213 | } | |
214 | ||
215 | ||
1cc6d956 MS |
216 | /* Makes all windows invisible (except the command and locator |
217 | windows). */ | |
ec7d9e56 AC |
218 | static void |
219 | make_all_visible (int visible) | |
c906108c SS |
220 | { |
221 | int i; | |
222 | ||
223 | for (i = 0; i < MAX_MAJOR_WINDOWS; i++) | |
224 | { | |
6d012f14 AC |
225 | if (tui_win_list[i] != NULL |
226 | && ((tui_win_list[i])->generic.type) != CMD_WIN) | |
c906108c | 227 | { |
6d012f14 AC |
228 | if (tui_win_is_source_type ((tui_win_list[i])->generic.type)) |
229 | make_visible ((tui_win_list[i])->detail.source_info.execution_info, | |
ec7d9e56 | 230 | visible); |
6d012f14 | 231 | make_visible ((struct tui_gen_win_info *) tui_win_list[i], visible); |
c906108c SS |
232 | } |
233 | } | |
234 | ||
235 | return; | |
ec7d9e56 AC |
236 | } |
237 | ||
238 | void | |
239 | tui_make_all_visible (void) | |
240 | { | |
241 | make_all_visible (1); | |
242 | } | |
243 | ||
244 | void | |
245 | tui_make_all_invisible (void) | |
246 | { | |
247 | make_all_visible (0); | |
248 | } | |
249 | ||
250 | /* Function to refresh all the windows currently displayed. */ | |
c906108c | 251 | |
c906108c | 252 | void |
5b6fe301 | 253 | tui_refresh_all (struct tui_win_info **list) |
c906108c | 254 | { |
570dc176 | 255 | int type; |
5b6fe301 | 256 | struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); |
c906108c SS |
257 | |
258 | for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++) | |
259 | { | |
6d012f14 | 260 | if (list[type] && list[type]->generic.is_visible) |
c906108c SS |
261 | { |
262 | if (type == SRC_WIN || type == DISASSEM_WIN) | |
263 | { | |
6d012f14 AC |
264 | touchwin (list[type]->detail.source_info.execution_info->handle); |
265 | tui_refresh_win (list[type]->detail.source_info.execution_info); | |
c906108c SS |
266 | } |
267 | touchwin (list[type]->generic.handle); | |
ec7d9e56 | 268 | tui_refresh_win (&list[type]->generic); |
c906108c SS |
269 | } |
270 | } | |
6d012f14 | 271 | if (locator->is_visible) |
c906108c SS |
272 | { |
273 | touchwin (locator->handle); | |
ec7d9e56 | 274 | tui_refresh_win (locator); |
c906108c | 275 | } |
6ba8e26f | 276 | } |
c906108c SS |
277 | |
278 | ||
279 | /********************************* | |
280 | ** Local Static Functions | |
281 | *********************************/ |