Commit | Line | Data |
---|---|---|
5796c8dc SS |
1 | /* General window behavior. |
2 | ||
25e4902b | 3 | Copyright (C) 1998-2015 Free Software Foundation, Inc. |
5796c8dc SS |
4 | |
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 | |
11 | the Free Software Foundation; either version 3 of the License, or | |
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 | |
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
21 | ||
22 | #include "defs.h" | |
23 | #include "tui/tui.h" | |
24 | #include "tui/tui-data.h" | |
25 | #include "tui/tui-wingeneral.h" | |
26 | #include "tui/tui-win.h" | |
27 | ||
28 | #include "gdb_curses.h" | |
29 | ||
30 | /*********************** | |
31 | ** PUBLIC FUNCTIONS | |
32 | ***********************/ | |
33 | ||
34 | /* Refresh the window. */ | |
35 | void | |
36 | tui_refresh_win (struct tui_gen_win_info *win_info) | |
37 | { | |
38 | if (win_info->type == DATA_WIN && win_info->content_size > 0) | |
39 | { | |
40 | int i; | |
41 | ||
42 | for (i = 0; (i < win_info->content_size); i++) | |
43 | { | |
44 | struct tui_gen_win_info *data_item_win_ptr; | |
45 | ||
46 | data_item_win_ptr = &((tui_win_content) | |
47 | win_info->content)[i]->which_element.data_window; | |
48 | if (data_item_win_ptr != NULL | |
49 | && data_item_win_ptr->handle != (WINDOW *) NULL) | |
50 | wrefresh (data_item_win_ptr->handle); | |
51 | } | |
52 | } | |
53 | else if (win_info->type == CMD_WIN) | |
54 | { | |
55 | /* Do nothing. */ | |
56 | } | |
57 | else | |
58 | { | |
59 | if (win_info->handle != (WINDOW *) NULL) | |
60 | wrefresh (win_info->handle); | |
61 | } | |
62 | ||
63 | return; | |
64 | } | |
65 | ||
66 | ||
67 | /* Function to delete the curses window, checking for NULL. */ | |
68 | void | |
69 | tui_delete_win (WINDOW *window) | |
70 | { | |
71 | if (window != (WINDOW *) NULL) | |
72 | delwin (window); | |
73 | ||
74 | return; | |
75 | } | |
76 | ||
77 | ||
78 | /* Draw a border arround the window. */ | |
79 | static void | |
80 | box_win (struct tui_gen_win_info *win_info, | |
81 | int highlight_flag) | |
82 | { | |
83 | if (win_info && win_info->handle) | |
84 | { | |
85 | WINDOW *win; | |
86 | int attrs; | |
87 | ||
88 | win = win_info->handle; | |
89 | if (highlight_flag == HILITE) | |
90 | attrs = tui_active_border_attrs; | |
91 | else | |
92 | attrs = tui_border_attrs; | |
93 | ||
94 | wattron (win, attrs); | |
95 | #ifdef HAVE_WBORDER | |
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); | |
100 | #else | |
101 | box (win, tui_border_vline, tui_border_hline); | |
102 | #endif | |
103 | if (win_info->title) | |
104 | mvwaddstr (win, 0, 3, win_info->title); | |
105 | wattroff (win, attrs); | |
106 | } | |
107 | } | |
108 | ||
109 | ||
110 | void | |
111 | tui_unhighlight_win (struct tui_win_info *win_info) | |
112 | { | |
113 | if (win_info != NULL | |
114 | && win_info->generic.handle != (WINDOW *) NULL) | |
115 | { | |
116 | box_win ((struct tui_gen_win_info *) win_info, NO_HILITE); | |
117 | wrefresh (win_info->generic.handle); | |
118 | tui_set_win_highlight (win_info, 0); | |
119 | } | |
120 | } | |
121 | ||
122 | ||
123 | void | |
124 | tui_highlight_win (struct tui_win_info *win_info) | |
125 | { | |
126 | if (win_info != NULL | |
127 | && win_info->can_highlight | |
128 | && win_info->generic.handle != (WINDOW *) NULL) | |
129 | { | |
130 | box_win ((struct tui_gen_win_info *) win_info, HILITE); | |
131 | wrefresh (win_info->generic.handle); | |
132 | tui_set_win_highlight (win_info, 1); | |
133 | } | |
134 | } | |
135 | ||
136 | void | |
137 | tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info) | |
138 | { | |
139 | if (win_info != NULL && win_info->generic.type != CMD_WIN) | |
140 | { | |
141 | if (win_info->is_highlighted) | |
142 | tui_highlight_win (win_info); | |
143 | else | |
144 | tui_unhighlight_win (win_info); | |
145 | ||
146 | } | |
147 | return; | |
148 | } | |
149 | ||
150 | ||
151 | void | |
152 | tui_make_window (struct tui_gen_win_info *win_info, int box_it) | |
153 | { | |
154 | WINDOW *handle; | |
155 | ||
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; | |
161 | if (handle != (WINDOW *) NULL) | |
162 | { | |
163 | if (box_it == BOX_WINDOW) | |
164 | box_win (win_info, NO_HILITE); | |
165 | win_info->is_visible = TRUE; | |
166 | scrollok (handle, TRUE); | |
167 | } | |
168 | } | |
169 | ||
170 | ||
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) | |
176 | { | |
177 | /* Don't tear down/recreate command window. */ | |
178 | if (win_info->type == CMD_WIN) | |
179 | return; | |
180 | ||
181 | if (visible) | |
182 | { | |
183 | if (!win_info->is_visible) | |
184 | { | |
185 | tui_make_window (win_info, | |
186 | (win_info->type != CMD_WIN | |
187 | && !tui_win_is_auxillary (win_info->type))); | |
188 | win_info->is_visible = TRUE; | |
189 | } | |
190 | } | |
191 | else if (!visible | |
192 | && win_info->is_visible | |
193 | && win_info->handle != (WINDOW *) NULL) | |
194 | { | |
195 | win_info->is_visible = FALSE; | |
196 | tui_delete_win (win_info->handle); | |
197 | win_info->handle = (WINDOW *) NULL; | |
198 | } | |
199 | ||
200 | return; | |
201 | } | |
202 | ||
203 | void | |
204 | tui_make_visible (struct tui_gen_win_info *win_info) | |
205 | { | |
206 | make_visible (win_info, 1); | |
207 | } | |
208 | ||
209 | void | |
210 | tui_make_invisible (struct tui_gen_win_info *win_info) | |
211 | { | |
212 | make_visible (win_info, 0); | |
213 | } | |
214 | ||
215 | ||
216 | /* Makes all windows invisible (except the command and locator | |
217 | windows). */ | |
218 | static void | |
219 | make_all_visible (int visible) | |
220 | { | |
221 | int i; | |
222 | ||
223 | for (i = 0; i < MAX_MAJOR_WINDOWS; i++) | |
224 | { | |
225 | if (tui_win_list[i] != NULL | |
226 | && ((tui_win_list[i])->generic.type) != CMD_WIN) | |
227 | { | |
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, | |
230 | visible); | |
231 | make_visible ((struct tui_gen_win_info *) tui_win_list[i], visible); | |
232 | } | |
233 | } | |
234 | ||
235 | return; | |
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. */ | |
251 | ||
252 | void | |
253 | tui_refresh_all (struct tui_win_info **list) | |
254 | { | |
25e4902b | 255 | int type; |
5796c8dc SS |
256 | struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); |
257 | ||
258 | for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++) | |
259 | { | |
260 | if (list[type] && list[type]->generic.is_visible) | |
261 | { | |
262 | if (type == SRC_WIN || type == DISASSEM_WIN) | |
263 | { | |
264 | touchwin (list[type]->detail.source_info.execution_info->handle); | |
265 | tui_refresh_win (list[type]->detail.source_info.execution_info); | |
266 | } | |
267 | touchwin (list[type]->generic.handle); | |
268 | tui_refresh_win (&list[type]->generic); | |
269 | } | |
270 | } | |
271 | if (locator->is_visible) | |
272 | { | |
273 | touchwin (locator->handle); | |
274 | tui_refresh_win (locator); | |
275 | } | |
276 | } | |
277 | ||
278 | ||
279 | /********************************* | |
280 | ** Local Static Functions | |
281 | *********************************/ |