1 /* General window behavior.
3 Copyright (C) 1998-2013 Free Software Foundation, Inc.
5 Contributed by Hewlett-Packard Company.
7 This file is part of GDB.
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.
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.
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/>. */
24 #include "tui/tui-data.h"
25 #include "tui/tui-wingeneral.h"
26 #include "tui/tui-win.h"
28 #include "gdb_curses.h"
30 /***********************
32 ***********************/
34 /* Refresh the window. */
36 tui_refresh_win (struct tui_gen_win_info *win_info)
38 if (win_info->type == DATA_WIN && win_info->content_size > 0)
42 for (i = 0; (i < win_info->content_size); i++)
44 struct tui_gen_win_info *data_item_win_ptr;
46 data_item_win_ptr = &((tui_win_content)
47 win_info->content)[i]->which_element.data_window;
48 if (data_item_win_ptr != NULL
49 && data_item_win_ptr->handle != (WINDOW *) NULL)
50 wrefresh (data_item_win_ptr->handle);
53 else if (win_info->type == CMD_WIN)
59 if (win_info->handle != (WINDOW *) NULL)
60 wrefresh (win_info->handle);
67 /* Function to delete the curses window, checking for NULL. */
69 tui_delete_win (WINDOW *window)
71 if (window != (WINDOW *) NULL)
78 /* Draw a border arround the window. */
80 box_win (struct tui_gen_win_info *win_info,
83 if (win_info && win_info->handle)
88 win = win_info->handle;
89 if (highlight_flag == HILITE)
90 attrs = tui_active_border_attrs;
92 attrs = tui_border_attrs;
96 wborder (win, tui_border_vline, tui_border_vline,
97 tui_border_hline, tui_border_hline,
98 tui_border_ulcorner, tui_border_urcorner,
99 tui_border_llcorner, tui_border_lrcorner);
101 box (win, tui_border_vline, tui_border_hline);
104 mvwaddstr (win, 0, 3, win_info->title);
105 wattroff (win, attrs);
111 tui_unhighlight_win (struct tui_win_info *win_info)
114 && win_info->generic.handle != (WINDOW *) NULL)
116 box_win ((struct tui_gen_win_info *) win_info, NO_HILITE);
117 wrefresh (win_info->generic.handle);
118 tui_set_win_highlight (win_info, 0);
124 tui_highlight_win (struct tui_win_info *win_info)
127 && win_info->can_highlight
128 && win_info->generic.handle != (WINDOW *) NULL)
130 box_win ((struct tui_gen_win_info *) win_info, HILITE);
131 wrefresh (win_info->generic.handle);
132 tui_set_win_highlight (win_info, 1);
137 tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info)
139 if (win_info != NULL && win_info->generic.type != CMD_WIN)
141 if (win_info->is_highlighted)
142 tui_highlight_win (win_info);
144 tui_unhighlight_win (win_info);
152 tui_make_window (struct tui_gen_win_info *win_info, int box_it)
156 handle = newwin (win_info->height,
160 win_info->handle = handle;
161 if (handle != (WINDOW *) NULL)
163 if (box_it == BOX_WINDOW)
164 box_win (win_info, NO_HILITE);
165 win_info->is_visible = TRUE;
166 scrollok (handle, TRUE);
171 /* We can't really make windows visible, or invisible. So we have to
172 delete the entire window when making it visible, and create it
173 again when making it visible. */
175 make_visible (struct tui_gen_win_info *win_info, int visible)
177 /* Don't tear down/recreate command window. */
178 if (win_info->type == CMD_WIN)
183 if (!win_info->is_visible)
185 tui_make_window (win_info,
186 (win_info->type != CMD_WIN
187 && !tui_win_is_auxillary (win_info->type)));
188 win_info->is_visible = TRUE;
192 && win_info->is_visible
193 && win_info->handle != (WINDOW *) NULL)
195 win_info->is_visible = FALSE;
196 tui_delete_win (win_info->handle);
197 win_info->handle = (WINDOW *) NULL;
204 tui_make_visible (struct tui_gen_win_info *win_info)
206 make_visible (win_info, 1);
210 tui_make_invisible (struct tui_gen_win_info *win_info)
212 make_visible (win_info, 0);
216 /* Makes all windows invisible (except the command and locator
219 make_all_visible (int visible)
223 for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
225 if (tui_win_list[i] != NULL
226 && ((tui_win_list[i])->generic.type) != CMD_WIN)
228 if (tui_win_is_source_type ((tui_win_list[i])->generic.type))
229 make_visible ((tui_win_list[i])->detail.source_info.execution_info,
231 make_visible ((struct tui_gen_win_info *) tui_win_list[i], visible);
239 tui_make_all_visible (void)
241 make_all_visible (1);
245 tui_make_all_invisible (void)
247 make_all_visible (0);
250 /* Function to refresh all the windows currently displayed. */
253 tui_refresh_all (struct tui_win_info **list)
255 enum tui_win_type type;
256 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
258 for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
260 if (list[type] && list[type]->generic.is_visible)
262 if (type == SRC_WIN || type == DISASSEM_WIN)
264 touchwin (list[type]->detail.source_info.execution_info->handle);
265 tui_refresh_win (list[type]->detail.source_info.execution_info);
267 touchwin (list[type]->generic.handle);
268 tui_refresh_win (&list[type]->generic);
271 if (locator->is_visible)
273 touchwin (locator->handle);
274 tui_refresh_win (locator);
279 /*********************************
280 ** Local Static Functions
281 *********************************/