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