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