1 /* General window behavior.
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
6 Contributed by Hewlett-Packard Company.
8 This file is part of GDB.
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.
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.
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., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
27 #include "tui/tui-data.h"
28 #include "tui/tui-wingeneral.h"
29 #include "tui/tui-win.h"
31 #include "gdb_curses.h"
33 /***********************
35 ***********************/
37 /* Refresh the window. */
39 tui_refresh_win (struct tui_gen_win_info * win_info)
41 if (win_info->type == DATA_WIN && win_info->content_size > 0)
45 for (i = 0; (i < win_info->content_size); i++)
47 struct tui_gen_win_info * data_item_win_ptr;
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);
56 else if (win_info->type == CMD_WIN)
62 if (win_info->handle != (WINDOW *) NULL)
63 wrefresh (win_info->handle);
70 /* Function to delete the curses window, checking for NULL. */
72 tui_delete_win (WINDOW * window)
74 if (window != (WINDOW *) NULL)
81 /* Draw a border arround the window. */
83 box_win (struct tui_gen_win_info * win_info, int highlight_flag)
85 if (win_info && win_info->handle)
90 win = win_info->handle;
91 if (highlight_flag == HILITE)
92 attrs = tui_active_border_attrs;
94 attrs = tui_border_attrs;
97 wborder (win, tui_border_vline, tui_border_vline,
98 tui_border_hline, tui_border_hline,
99 tui_border_ulcorner, tui_border_urcorner,
100 tui_border_llcorner, tui_border_lrcorner);
102 mvwaddstr (win, 0, 3, win_info->title);
103 wattroff (win, attrs);
109 tui_unhighlight_win (struct tui_win_info * win_info)
111 if (win_info != NULL && win_info->generic.handle != (WINDOW *) NULL)
113 box_win ((struct tui_gen_win_info *) win_info, NO_HILITE);
114 wrefresh (win_info->generic.handle);
115 tui_set_win_highlight (win_info, 0);
121 tui_highlight_win (struct tui_win_info * win_info)
124 && win_info->can_highlight
125 && win_info->generic.handle != (WINDOW *) NULL)
127 box_win ((struct tui_gen_win_info *) win_info, HILITE);
128 wrefresh (win_info->generic.handle);
129 tui_set_win_highlight (win_info, 1);
134 tui_check_and_display_highlight_if_needed (struct tui_win_info * win_info)
136 if (win_info != NULL && win_info->generic.type != CMD_WIN)
138 if (win_info->is_highlighted)
139 tui_highlight_win (win_info);
141 tui_unhighlight_win (win_info);
149 tui_make_window (struct tui_gen_win_info * win_info, int box_it)
153 handle = newwin (win_info->height,
157 win_info->handle = handle;
158 if (handle != (WINDOW *) NULL)
160 if (box_it == BOX_WINDOW)
161 box_win (win_info, NO_HILITE);
162 win_info->is_visible = TRUE;
163 scrollok (handle, TRUE);
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. */
172 make_visible (struct tui_gen_win_info *win_info, int visible)
174 /* Don't tear down/recreate command window */
175 if (win_info->type == CMD_WIN)
180 if (!win_info->is_visible)
182 tui_make_window (win_info,
183 (win_info->type != CMD_WIN
184 && !tui_win_is_auxillary (win_info->type)));
185 win_info->is_visible = TRUE;
189 win_info->is_visible && win_info->handle != (WINDOW *) NULL)
191 win_info->is_visible = FALSE;
192 tui_delete_win (win_info->handle);
193 win_info->handle = (WINDOW *) NULL;
200 tui_make_visible (struct tui_gen_win_info *win_info)
202 make_visible (win_info, 1);
206 tui_make_invisible (struct tui_gen_win_info *win_info)
208 make_visible (win_info, 0);
212 /* Makes all windows invisible (except the command and locator windows). */
214 make_all_visible (int visible)
218 for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
220 if (tui_win_list[i] != NULL
221 && ((tui_win_list[i])->generic.type) != CMD_WIN)
223 if (tui_win_is_source_type ((tui_win_list[i])->generic.type))
224 make_visible ((tui_win_list[i])->detail.source_info.execution_info,
226 make_visible ((struct tui_gen_win_info *) tui_win_list[i], visible);
234 tui_make_all_visible (void)
236 make_all_visible (1);
240 tui_make_all_invisible (void)
242 make_all_visible (0);
245 /* Function to refresh all the windows currently displayed. */
248 tui_refresh_all (struct tui_win_info * * list)
250 enum tui_win_type type;
251 struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
253 for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
255 if (list[type] && list[type]->generic.is_visible)
257 if (type == SRC_WIN || type == DISASSEM_WIN)
259 touchwin (list[type]->detail.source_info.execution_info->handle);
260 tui_refresh_win (list[type]->detail.source_info.execution_info);
262 touchwin (list[type]->generic.handle);
263 tui_refresh_win (&list[type]->generic);
266 if (locator->is_visible)
268 touchwin (locator->handle);
269 tui_refresh_win (locator);
274 /*********************************
275 ** Local Static Functions
276 *********************************/