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 | |
1cc6d956 | 46 | /* Function to delete the curses window, checking for NULL. */ |
c906108c | 47 | void |
5b6fe301 | 48 | tui_delete_win (WINDOW *window) |
c906108c | 49 | { |
cafb3438 | 50 | if (window != NULL) |
c906108c | 51 | delwin (window); |
ec7d9e56 | 52 | } |
c906108c SS |
53 | |
54 | ||
af101512 | 55 | /* Draw a border arround the window. */ |
2c0b251b | 56 | static void |
08ef48c5 MS |
57 | box_win (struct tui_gen_win_info *win_info, |
58 | int highlight_flag) | |
c906108c | 59 | { |
6d012f14 | 60 | if (win_info && win_info->handle) |
c906108c | 61 | { |
af101512 SC |
62 | WINDOW *win; |
63 | int attrs; | |
64 | ||
6d012f14 | 65 | win = win_info->handle; |
6ba8e26f | 66 | if (highlight_flag == HILITE) |
af101512 | 67 | attrs = tui_active_border_attrs; |
c906108c | 68 | else |
af101512 SC |
69 | attrs = tui_border_attrs; |
70 | ||
71 | wattron (win, attrs); | |
8b9cf735 | 72 | #ifdef HAVE_WBORDER |
af101512 SC |
73 | wborder (win, tui_border_vline, tui_border_vline, |
74 | tui_border_hline, tui_border_hline, | |
75 | tui_border_ulcorner, tui_border_urcorner, | |
76 | tui_border_llcorner, tui_border_lrcorner); | |
8b9cf735 MK |
77 | #else |
78 | box (win, tui_border_vline, tui_border_hline); | |
79 | #endif | |
6d012f14 | 80 | if (win_info->title) |
63a33118 | 81 | mvwaddstr (win, 0, 3, win_info->title); |
af101512 | 82 | wattroff (win, attrs); |
c906108c | 83 | } |
af101512 | 84 | } |
c906108c SS |
85 | |
86 | ||
c906108c | 87 | void |
5b6fe301 | 88 | tui_unhighlight_win (struct tui_win_info *win_info) |
c906108c | 89 | { |
e5908723 | 90 | if (win_info != NULL |
bbc228ee | 91 | && win_info->can_highlight |
cb2ce893 | 92 | && win_info->handle != NULL) |
c906108c | 93 | { |
cb2ce893 | 94 | box_win (win_info, NO_HILITE); |
cf82af05 | 95 | win_info->refresh_window (); |
214a5cbe | 96 | win_info->set_highlight (false); |
c906108c | 97 | } |
ec7d9e56 | 98 | } |
c906108c SS |
99 | |
100 | ||
c906108c | 101 | void |
5b6fe301 | 102 | tui_highlight_win (struct tui_win_info *win_info) |
c906108c | 103 | { |
6d012f14 AC |
104 | if (win_info != NULL |
105 | && win_info->can_highlight | |
cb2ce893 | 106 | && win_info->handle != NULL) |
c906108c | 107 | { |
cb2ce893 | 108 | box_win (win_info, HILITE); |
cf82af05 | 109 | win_info->refresh_window (); |
214a5cbe | 110 | win_info->set_highlight (true); |
c906108c | 111 | } |
ec7d9e56 | 112 | } |
c906108c | 113 | |
c906108c | 114 | void |
b4ef5aeb | 115 | tui_win_info::check_and_display_highlight_if_needed () |
c906108c | 116 | { |
b4ef5aeb | 117 | if (can_highlight) |
c906108c | 118 | { |
b4ef5aeb TT |
119 | if (is_highlighted) |
120 | tui_highlight_win (this); | |
c906108c | 121 | else |
b4ef5aeb | 122 | tui_unhighlight_win (this); |
c906108c | 123 | } |
ec7d9e56 | 124 | } |
c906108c SS |
125 | |
126 | ||
c906108c | 127 | void |
17374de4 | 128 | tui_make_window (struct tui_gen_win_info *win_info, enum tui_box box_it) |
c906108c SS |
129 | { |
130 | WINDOW *handle; | |
131 | ||
6d012f14 AC |
132 | handle = newwin (win_info->height, |
133 | win_info->width, | |
134 | win_info->origin.y, | |
135 | win_info->origin.x); | |
136 | win_info->handle = handle; | |
cafb3438 | 137 | if (handle != NULL) |
c906108c | 138 | { |
6ba8e26f AC |
139 | if (box_it == BOX_WINDOW) |
140 | box_win (win_info, NO_HILITE); | |
56122977 | 141 | win_info->is_visible = true; |
c906108c | 142 | scrollok (handle, TRUE); |
c906108c | 143 | } |
bc712bbf | 144 | } |
c906108c SS |
145 | |
146 | ||
ec7d9e56 AC |
147 | /* We can't really make windows visible, or invisible. So we have to |
148 | delete the entire window when making it visible, and create it | |
149 | again when making it visible. */ | |
48a3bd16 TT |
150 | void |
151 | tui_gen_win_info::make_visible (bool visible) | |
c906108c | 152 | { |
8e3cfd09 TT |
153 | if (is_visible == visible) |
154 | return; | |
155 | is_visible = visible; | |
156 | ||
c906108c | 157 | if (visible) |
8e3cfd09 TT |
158 | tui_make_window (this, (tui_win_is_auxiliary (type) |
159 | ? DONT_BOX_WINDOW : BOX_WINDOW)); | |
160 | else | |
c906108c | 161 | { |
48a3bd16 TT |
162 | tui_delete_win (handle); |
163 | handle = NULL; | |
c906108c | 164 | } |
ec7d9e56 | 165 | } |
c906108c | 166 | |
3f3ffe54 | 167 | /* See tui-wingeneral.h. */ |
ec7d9e56 | 168 | |
ec7d9e56 AC |
169 | void |
170 | tui_make_all_invisible (void) | |
171 | { | |
3f3ffe54 TT |
172 | for (tui_win_info *win_info : all_tui_windows ()) |
173 | win_info->make_visible (false); | |
ec7d9e56 AC |
174 | } |
175 | ||
176 | /* Function to refresh all the windows currently displayed. */ | |
c906108c | 177 | |
c906108c | 178 | void |
1ce3e844 | 179 | tui_refresh_all () |
c906108c | 180 | { |
3add462f | 181 | struct tui_locator_window *locator = tui_locator_win_info_ptr (); |
c906108c | 182 | |
1ce3e844 | 183 | for (tui_win_info *win_info : all_tui_windows ()) |
c906108c | 184 | { |
1ce3e844 | 185 | if (win_info->is_visible) |
fd6c75ee | 186 | win_info->refresh_window (); |
c906108c | 187 | } |
6d012f14 | 188 | if (locator->is_visible) |
fd6c75ee | 189 | locator->refresh_window (); |
6ba8e26f | 190 | } |
c906108c SS |
191 | |
192 | ||
193 | /********************************* | |
194 | ** Local Static Functions | |
195 | *********************************/ |