Remove tui_make_visible and tui_make_invisible
[deliverable/binutils-gdb.git] / gdb / tui / tui-wingeneral.c
1 /* General window behavior.
2
3 Copyright (C) 1998-2019 Free Software Foundation, Inc.
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 /* See tui-data.h. */
35
36 void
37 tui_gen_win_info::refresh_window ()
38 {
39 if (handle != NULL)
40 {
41 touchwin (handle);
42 wrefresh (handle);
43 }
44 }
45
46 /* See tui-data.h. */
47
48 void
49 tui_data_window::refresh_window ()
50 {
51 tui_gen_win_info::refresh_window ();
52 for (auto &&win : regs_content)
53 {
54 if (win != NULL)
55 win->refresh_window ();
56 }
57 }
58
59 /* Function to delete the curses window, checking for NULL. */
60 void
61 tui_delete_win (WINDOW *window)
62 {
63 if (window != NULL)
64 delwin (window);
65 }
66
67
68 /* Draw a border arround the window. */
69 static void
70 box_win (struct tui_gen_win_info *win_info,
71 int highlight_flag)
72 {
73 if (win_info && win_info->handle)
74 {
75 WINDOW *win;
76 int attrs;
77
78 win = win_info->handle;
79 if (highlight_flag == HILITE)
80 attrs = tui_active_border_attrs;
81 else
82 attrs = tui_border_attrs;
83
84 wattron (win, attrs);
85 #ifdef HAVE_WBORDER
86 wborder (win, tui_border_vline, tui_border_vline,
87 tui_border_hline, tui_border_hline,
88 tui_border_ulcorner, tui_border_urcorner,
89 tui_border_llcorner, tui_border_lrcorner);
90 #else
91 box (win, tui_border_vline, tui_border_hline);
92 #endif
93 if (win_info->title)
94 mvwaddstr (win, 0, 3, win_info->title);
95 wattroff (win, attrs);
96 }
97 }
98
99
100 void
101 tui_unhighlight_win (struct tui_win_info *win_info)
102 {
103 if (win_info != NULL
104 && win_info->can_highlight
105 && win_info->handle != NULL)
106 {
107 box_win (win_info, NO_HILITE);
108 win_info->refresh_window ();
109 win_info->set_highlight (false);
110 }
111 }
112
113
114 void
115 tui_highlight_win (struct tui_win_info *win_info)
116 {
117 if (win_info != NULL
118 && win_info->can_highlight
119 && win_info->handle != NULL)
120 {
121 box_win (win_info, HILITE);
122 win_info->refresh_window ();
123 win_info->set_highlight (true);
124 }
125 }
126
127 void
128 tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info)
129 {
130 if (win_info != NULL && win_info->can_highlight)
131 {
132 if (win_info->is_highlighted)
133 tui_highlight_win (win_info);
134 else
135 tui_unhighlight_win (win_info);
136
137 }
138 return;
139 }
140
141
142 void
143 tui_make_window (struct tui_gen_win_info *win_info, enum tui_box box_it)
144 {
145 WINDOW *handle;
146
147 handle = newwin (win_info->height,
148 win_info->width,
149 win_info->origin.y,
150 win_info->origin.x);
151 win_info->handle = handle;
152 if (handle != NULL)
153 {
154 if (box_it == BOX_WINDOW)
155 box_win (win_info, NO_HILITE);
156 win_info->is_visible = true;
157 scrollok (handle, TRUE);
158 }
159 }
160
161
162 /* We can't really make windows visible, or invisible. So we have to
163 delete the entire window when making it visible, and create it
164 again when making it visible. */
165 void
166 tui_gen_win_info::make_visible (bool visible)
167 {
168 if (is_visible == visible)
169 return;
170 is_visible = visible;
171
172 if (visible)
173 tui_make_window (this, (tui_win_is_auxiliary (type)
174 ? DONT_BOX_WINDOW : BOX_WINDOW));
175 else
176 {
177 tui_delete_win (handle);
178 handle = NULL;
179 }
180 }
181
182 /* See tui-data.h. */
183
184 void
185 tui_source_window_base::make_visible (bool visible)
186 {
187 execution_info->make_visible (visible);
188 tui_win_info::make_visible (visible);
189 }
190
191 /* Makes all windows invisible (except the command and locator
192 windows). */
193 static void
194 make_all_visible (bool visible)
195 {
196 for (tui_win_info *win_info : all_tui_windows ())
197 win_info->make_visible (visible);
198 }
199
200 void
201 tui_make_all_visible (void)
202 {
203 make_all_visible (true);
204 }
205
206 void
207 tui_make_all_invisible (void)
208 {
209 make_all_visible (false);
210 }
211
212 /* See tui-data.h. */
213
214 void
215 tui_source_window_base::refresh_window ()
216 {
217 execution_info->refresh_window ();
218 tui_win_info::refresh_window ();
219 }
220
221 /* Function to refresh all the windows currently displayed. */
222
223 void
224 tui_refresh_all ()
225 {
226 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
227
228 for (tui_win_info *win_info : all_tui_windows ())
229 {
230 if (win_info->is_visible)
231 win_info->refresh_window ();
232 }
233 if (locator->is_visible)
234 locator->refresh_window ();
235 }
236
237
238 /*********************************
239 ** Local Static Functions
240 *********************************/
This page took 0.036736 seconds and 5 git commands to generate.