Remove TUI data window special case
[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 (visible)
169 {
170 if (!is_visible)
171 {
172 tui_make_window (this, (tui_win_is_auxiliary (type)
173 ? DONT_BOX_WINDOW : BOX_WINDOW));
174 is_visible = true;
175 }
176 }
177 else if (!visible
178 && is_visible
179 && handle != NULL)
180 {
181 is_visible = false;
182 tui_delete_win (handle);
183 handle = NULL;
184 }
185 }
186
187 void
188 tui_make_visible (struct tui_gen_win_info *win_info)
189 {
190 win_info->make_visible (true);
191 }
192
193 void
194 tui_make_invisible (struct tui_gen_win_info *win_info)
195 {
196 win_info->make_visible (false);
197 }
198
199 /* See tui-data.h. */
200
201 void
202 tui_source_window_base::make_visible (bool visible)
203 {
204 if (execution_info != nullptr)
205 execution_info->make_visible (visible);
206 tui_win_info::make_visible (visible);
207 }
208
209 /* Makes all windows invisible (except the command and locator
210 windows). */
211 static void
212 make_all_visible (bool visible)
213 {
214 for (tui_win_info *win_info : all_tui_windows ())
215 win_info->make_visible (visible);
216 }
217
218 void
219 tui_make_all_visible (void)
220 {
221 make_all_visible (true);
222 }
223
224 void
225 tui_make_all_invisible (void)
226 {
227 make_all_visible (false);
228 }
229
230 /* See tui-data.h. */
231
232 void
233 tui_source_window_base::refresh_window ()
234 {
235 execution_info->refresh_window ();
236 tui_win_info::refresh_window ();
237 }
238
239 /* Function to refresh all the windows currently displayed. */
240
241 void
242 tui_refresh_all ()
243 {
244 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
245
246 for (tui_win_info *win_info : all_tui_windows ())
247 {
248 if (win_info->is_visible)
249 win_info->refresh_window ();
250 }
251 if (locator->is_visible)
252 locator->refresh_window ();
253 }
254
255
256 /*********************************
257 ** Local Static Functions
258 *********************************/
This page took 0.047481 seconds and 5 git commands to generate.