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