daily update
[deliverable/binutils-gdb.git] / gdb / tui / tui-wingeneral.c
CommitLineData
f377b406 1/* General window behavior.
f33c6cbf 2
6aba47ca
DJ
3 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2007
4 Free Software Foundation, Inc.
f33c6cbf 5
f377b406
SC
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
88d83552
EZ
22 Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA. */
c906108c 24
96ec9981 25#include "defs.h"
d7b2e967
AC
26#include "tui/tui.h"
27#include "tui/tui-data.h"
28#include "tui/tui-wingeneral.h"
29#include "tui/tui-win.h"
f33c6cbf 30
6a83354a 31#include "gdb_curses.h"
4e8f7a8b 32
c906108c
SS
33/***********************
34** PUBLIC FUNCTIONS
35***********************/
ec7d9e56 36
1cc6d956 37/* Refresh the window. */
c906108c 38void
5b6fe301 39tui_refresh_win (struct tui_gen_win_info *win_info)
c906108c 40{
6d012f14 41 if (win_info->type == DATA_WIN && win_info->content_size > 0)
c906108c
SS
42 {
43 int i;
44
6d012f14 45 for (i = 0; (i < win_info->content_size); i++)
c906108c 46 {
5b6fe301 47 struct tui_gen_win_info *data_item_win_ptr;
c906108c 48
6ba8e26f 49 data_item_win_ptr = &((tui_win_content)
08ef48c5 50 win_info->content)[i]->which_element.data_window;
6ba8e26f
AC
51 if (data_item_win_ptr != NULL
52 && data_item_win_ptr->handle != (WINDOW *) NULL)
53 wrefresh (data_item_win_ptr->handle);
c906108c
SS
54 }
55 }
6d012f14 56 else if (win_info->type == CMD_WIN)
c906108c 57 {
1cc6d956 58 /* Do nothing. */
c906108c
SS
59 }
60 else
61 {
6d012f14
AC
62 if (win_info->handle != (WINDOW *) NULL)
63 wrefresh (win_info->handle);
c906108c
SS
64 }
65
66 return;
ec7d9e56 67}
c906108c
SS
68
69
1cc6d956 70/* Function to delete the curses window, checking for NULL. */
c906108c 71void
5b6fe301 72tui_delete_win (WINDOW *window)
c906108c
SS
73{
74 if (window != (WINDOW *) NULL)
75 delwin (window);
76
77 return;
ec7d9e56 78}
c906108c
SS
79
80
af101512 81/* Draw a border arround the window. */
c906108c 82void
08ef48c5
MS
83box_win (struct tui_gen_win_info *win_info,
84 int highlight_flag)
c906108c 85{
6d012f14 86 if (win_info && win_info->handle)
c906108c 87 {
af101512
SC
88 WINDOW *win;
89 int attrs;
90
6d012f14 91 win = win_info->handle;
6ba8e26f 92 if (highlight_flag == HILITE)
af101512 93 attrs = tui_active_border_attrs;
c906108c 94 else
af101512
SC
95 attrs = tui_border_attrs;
96
97 wattron (win, attrs);
8b9cf735 98#ifdef HAVE_WBORDER
af101512
SC
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);
8b9cf735
MK
103#else
104 box (win, tui_border_vline, tui_border_hline);
105#endif
6d012f14
AC
106 if (win_info->title)
107 mvwaddstr (win, 0, 3, win_info->title);
af101512 108 wattroff (win, attrs);
c906108c 109 }
af101512 110}
c906108c
SS
111
112
c906108c 113void
5b6fe301 114tui_unhighlight_win (struct tui_win_info *win_info)
c906108c 115{
6d012f14 116 if (win_info != NULL && win_info->generic.handle != (WINDOW *) NULL)
c906108c 117 {
6ba8e26f 118 box_win ((struct tui_gen_win_info *) win_info, NO_HILITE);
6d012f14
AC
119 wrefresh (win_info->generic.handle);
120 tui_set_win_highlight (win_info, 0);
c906108c 121 }
ec7d9e56 122}
c906108c
SS
123
124
c906108c 125void
5b6fe301 126tui_highlight_win (struct tui_win_info *win_info)
c906108c 127{
6d012f14
AC
128 if (win_info != NULL
129 && win_info->can_highlight
130 && win_info->generic.handle != (WINDOW *) NULL)
c906108c 131 {
6ba8e26f 132 box_win ((struct tui_gen_win_info *) win_info, HILITE);
6d012f14
AC
133 wrefresh (win_info->generic.handle);
134 tui_set_win_highlight (win_info, 1);
c906108c 135 }
ec7d9e56 136}
c906108c 137
c906108c 138void
5b6fe301 139tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info)
c906108c 140{
6d012f14 141 if (win_info != NULL && win_info->generic.type != CMD_WIN)
c906108c 142 {
6d012f14
AC
143 if (win_info->is_highlighted)
144 tui_highlight_win (win_info);
c906108c 145 else
6d012f14 146 tui_unhighlight_win (win_info);
c906108c
SS
147
148 }
149 return;
ec7d9e56 150}
c906108c
SS
151
152
c906108c 153void
5b6fe301 154tui_make_window (struct tui_gen_win_info *win_info, int box_it)
c906108c
SS
155{
156 WINDOW *handle;
157
6d012f14
AC
158 handle = newwin (win_info->height,
159 win_info->width,
160 win_info->origin.y,
161 win_info->origin.x);
162 win_info->handle = handle;
c906108c
SS
163 if (handle != (WINDOW *) NULL)
164 {
6ba8e26f
AC
165 if (box_it == BOX_WINDOW)
166 box_win (win_info, NO_HILITE);
6d012f14 167 win_info->is_visible = TRUE;
c906108c 168 scrollok (handle, TRUE);
c906108c 169 }
bc712bbf 170}
c906108c
SS
171
172
ec7d9e56
AC
173/* We can't really make windows visible, or invisible. So we have to
174 delete the entire window when making it visible, and create it
175 again when making it visible. */
176static void
177make_visible (struct tui_gen_win_info *win_info, int visible)
c906108c 178{
1cc6d956 179 /* Don't tear down/recreate command window. */
ec7d9e56 180 if (win_info->type == CMD_WIN)
c906108c
SS
181 return;
182
183 if (visible)
184 {
6d012f14 185 if (!win_info->is_visible)
c906108c 186 {
ec7d9e56
AC
187 tui_make_window (win_info,
188 (win_info->type != CMD_WIN
6d012f14
AC
189 && !tui_win_is_auxillary (win_info->type)));
190 win_info->is_visible = TRUE;
c906108c 191 }
c906108c
SS
192 }
193 else if (!visible &&
6d012f14 194 win_info->is_visible && win_info->handle != (WINDOW *) NULL)
c906108c 195 {
6d012f14 196 win_info->is_visible = FALSE;
ec7d9e56
AC
197 tui_delete_win (win_info->handle);
198 win_info->handle = (WINDOW *) NULL;
c906108c
SS
199 }
200
201 return;
ec7d9e56 202}
c906108c 203
ec7d9e56
AC
204void
205tui_make_visible (struct tui_gen_win_info *win_info)
206{
207 make_visible (win_info, 1);
208}
c906108c 209
c906108c 210void
ec7d9e56
AC
211tui_make_invisible (struct tui_gen_win_info *win_info)
212{
213 make_visible (win_info, 0);
214}
215
216
1cc6d956
MS
217/* Makes all windows invisible (except the command and locator
218 windows). */
ec7d9e56
AC
219static void
220make_all_visible (int visible)
c906108c
SS
221{
222 int i;
223
224 for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
225 {
6d012f14
AC
226 if (tui_win_list[i] != NULL
227 && ((tui_win_list[i])->generic.type) != CMD_WIN)
c906108c 228 {
6d012f14
AC
229 if (tui_win_is_source_type ((tui_win_list[i])->generic.type))
230 make_visible ((tui_win_list[i])->detail.source_info.execution_info,
ec7d9e56 231 visible);
6d012f14 232 make_visible ((struct tui_gen_win_info *) tui_win_list[i], visible);
c906108c
SS
233 }
234 }
235
236 return;
ec7d9e56
AC
237}
238
239void
240tui_make_all_visible (void)
241{
242 make_all_visible (1);
243}
244
245void
246tui_make_all_invisible (void)
247{
248 make_all_visible (0);
249}
250
251/* Function to refresh all the windows currently displayed. */
c906108c 252
c906108c 253void
5b6fe301 254tui_refresh_all (struct tui_win_info **list)
c906108c 255{
22940a24 256 enum tui_win_type type;
5b6fe301 257 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
c906108c
SS
258
259 for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
260 {
6d012f14 261 if (list[type] && list[type]->generic.is_visible)
c906108c
SS
262 {
263 if (type == SRC_WIN || type == DISASSEM_WIN)
264 {
6d012f14
AC
265 touchwin (list[type]->detail.source_info.execution_info->handle);
266 tui_refresh_win (list[type]->detail.source_info.execution_info);
c906108c
SS
267 }
268 touchwin (list[type]->generic.handle);
ec7d9e56 269 tui_refresh_win (&list[type]->generic);
c906108c
SS
270 }
271 }
6d012f14 272 if (locator->is_visible)
c906108c
SS
273 {
274 touchwin (locator->handle);
ec7d9e56 275 tui_refresh_win (locator);
c906108c 276 }
6ba8e26f 277}
c906108c
SS
278
279
280/*********************************
281** Local Static Functions
282*********************************/
This page took 0.732715 seconds and 4 git commands to generate.