]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/tui/tui-wingeneral.c
2007-08-14 Michael Snyder <msnyder@access-company.com>
[thirdparty/binutils-gdb.git] / gdb / tui / tui-wingeneral.c
1 /* General window behavior.
2
3 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2007
4 Free Software Foundation, Inc.
5
6 Contributed by Hewlett-Packard Company.
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA. */
24
25 #include "defs.h"
26 #include "tui/tui.h"
27 #include "tui/tui-data.h"
28 #include "tui/tui-wingeneral.h"
29 #include "tui/tui-win.h"
30
31 #include "gdb_curses.h"
32
33 /***********************
34 ** PUBLIC FUNCTIONS
35 ***********************/
36
37 /* Refresh the window. */
38 void
39 tui_refresh_win (struct tui_gen_win_info *win_info)
40 {
41 if (win_info->type == DATA_WIN && win_info->content_size > 0)
42 {
43 int i;
44
45 for (i = 0; (i < win_info->content_size); i++)
46 {
47 struct tui_gen_win_info *data_item_win_ptr;
48
49 data_item_win_ptr = &((tui_win_content)
50 win_info->content)[i]->which_element.data_window;
51 if (data_item_win_ptr != NULL
52 && data_item_win_ptr->handle != (WINDOW *) NULL)
53 wrefresh (data_item_win_ptr->handle);
54 }
55 }
56 else if (win_info->type == CMD_WIN)
57 {
58 /* Do nothing. */
59 }
60 else
61 {
62 if (win_info->handle != (WINDOW *) NULL)
63 wrefresh (win_info->handle);
64 }
65
66 return;
67 }
68
69
70 /* Function to delete the curses window, checking for NULL. */
71 void
72 tui_delete_win (WINDOW *window)
73 {
74 if (window != (WINDOW *) NULL)
75 delwin (window);
76
77 return;
78 }
79
80
81 /* Draw a border arround the window. */
82 void
83 box_win (struct tui_gen_win_info *win_info,
84 int highlight_flag)
85 {
86 if (win_info && win_info->handle)
87 {
88 WINDOW *win;
89 int attrs;
90
91 win = win_info->handle;
92 if (highlight_flag == HILITE)
93 attrs = tui_active_border_attrs;
94 else
95 attrs = tui_border_attrs;
96
97 wattron (win, attrs);
98 #ifdef HAVE_WBORDER
99 wborder (win, tui_border_vline, tui_border_vline,
100 tui_border_hline, tui_border_hline,
101 tui_border_ulcorner, tui_border_urcorner,
102 tui_border_llcorner, tui_border_lrcorner);
103 #else
104 box (win, tui_border_vline, tui_border_hline);
105 #endif
106 if (win_info->title)
107 mvwaddstr (win, 0, 3, win_info->title);
108 wattroff (win, attrs);
109 }
110 }
111
112
113 void
114 tui_unhighlight_win (struct tui_win_info *win_info)
115 {
116 if (win_info != NULL
117 && win_info->generic.handle != (WINDOW *) NULL)
118 {
119 box_win ((struct tui_gen_win_info *) win_info, NO_HILITE);
120 wrefresh (win_info->generic.handle);
121 tui_set_win_highlight (win_info, 0);
122 }
123 }
124
125
126 void
127 tui_highlight_win (struct tui_win_info *win_info)
128 {
129 if (win_info != NULL
130 && win_info->can_highlight
131 && win_info->generic.handle != (WINDOW *) NULL)
132 {
133 box_win ((struct tui_gen_win_info *) win_info, HILITE);
134 wrefresh (win_info->generic.handle);
135 tui_set_win_highlight (win_info, 1);
136 }
137 }
138
139 void
140 tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info)
141 {
142 if (win_info != NULL && win_info->generic.type != CMD_WIN)
143 {
144 if (win_info->is_highlighted)
145 tui_highlight_win (win_info);
146 else
147 tui_unhighlight_win (win_info);
148
149 }
150 return;
151 }
152
153
154 void
155 tui_make_window (struct tui_gen_win_info *win_info, int box_it)
156 {
157 WINDOW *handle;
158
159 handle = newwin (win_info->height,
160 win_info->width,
161 win_info->origin.y,
162 win_info->origin.x);
163 win_info->handle = handle;
164 if (handle != (WINDOW *) NULL)
165 {
166 if (box_it == BOX_WINDOW)
167 box_win (win_info, NO_HILITE);
168 win_info->is_visible = TRUE;
169 scrollok (handle, TRUE);
170 }
171 }
172
173
174 /* We can't really make windows visible, or invisible. So we have to
175 delete the entire window when making it visible, and create it
176 again when making it visible. */
177 static void
178 make_visible (struct tui_gen_win_info *win_info, int visible)
179 {
180 /* Don't tear down/recreate command window. */
181 if (win_info->type == CMD_WIN)
182 return;
183
184 if (visible)
185 {
186 if (!win_info->is_visible)
187 {
188 tui_make_window (win_info,
189 (win_info->type != CMD_WIN
190 && !tui_win_is_auxillary (win_info->type)));
191 win_info->is_visible = TRUE;
192 }
193 }
194 else if (!visible
195 && win_info->is_visible
196 && win_info->handle != (WINDOW *) NULL)
197 {
198 win_info->is_visible = FALSE;
199 tui_delete_win (win_info->handle);
200 win_info->handle = (WINDOW *) NULL;
201 }
202
203 return;
204 }
205
206 void
207 tui_make_visible (struct tui_gen_win_info *win_info)
208 {
209 make_visible (win_info, 1);
210 }
211
212 void
213 tui_make_invisible (struct tui_gen_win_info *win_info)
214 {
215 make_visible (win_info, 0);
216 }
217
218
219 /* Makes all windows invisible (except the command and locator
220 windows). */
221 static void
222 make_all_visible (int visible)
223 {
224 int i;
225
226 for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
227 {
228 if (tui_win_list[i] != NULL
229 && ((tui_win_list[i])->generic.type) != CMD_WIN)
230 {
231 if (tui_win_is_source_type ((tui_win_list[i])->generic.type))
232 make_visible ((tui_win_list[i])->detail.source_info.execution_info,
233 visible);
234 make_visible ((struct tui_gen_win_info *) tui_win_list[i], visible);
235 }
236 }
237
238 return;
239 }
240
241 void
242 tui_make_all_visible (void)
243 {
244 make_all_visible (1);
245 }
246
247 void
248 tui_make_all_invisible (void)
249 {
250 make_all_visible (0);
251 }
252
253 /* Function to refresh all the windows currently displayed. */
254
255 void
256 tui_refresh_all (struct tui_win_info **list)
257 {
258 enum tui_win_type type;
259 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
260
261 for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
262 {
263 if (list[type] && list[type]->generic.is_visible)
264 {
265 if (type == SRC_WIN || type == DISASSEM_WIN)
266 {
267 touchwin (list[type]->detail.source_info.execution_info->handle);
268 tui_refresh_win (list[type]->detail.source_info.execution_info);
269 }
270 touchwin (list[type]->generic.handle);
271 tui_refresh_win (&list[type]->generic);
272 }
273 }
274 if (locator->is_visible)
275 {
276 touchwin (locator->handle);
277 tui_refresh_win (locator);
278 }
279 }
280
281
282 /*********************************
283 ** Local Static Functions
284 *********************************/