* tui.c (strcat_to_buf): Use const char* for source item.
[deliverable/binutils-gdb.git] / gdb / tui / tuiGeneralWin.c
CommitLineData
f377b406 1/* General window behavior.
f33c6cbf
AC
2
3 Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation,
4 Inc.
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
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
c906108c 24
f33c6cbf
AC
25/* FIXME: cagney/2002-02-28: The GDB coding standard indicates that
26 "defs.h" should be included first. Unfortunatly some systems
27 (currently Debian GNU/Linux) include the <stdbool.h> via <curses.h>
28 and they clash with "bfd.h"'s definiton of true/false. The correct
29 fix is to remove true/false from "bfd.h", however, until that
30 happens, hack around it by including "config.h" and <curses.h>
31 first. */
32
4e8f7a8b
DJ
33#include "config.h"
34#ifdef HAVE_NCURSES_H
35#include <ncurses.h>
36#else
37#ifdef HAVE_CURSES_H
38#include <curses.h>
39#endif
40#endif
41
c906108c
SS
42#include "defs.h"
43#include "tui.h"
44#include "tuiData.h"
45#include "tuiGeneralWin.h"
af101512 46#include "tuiWin.h"
c906108c 47
c906108c
SS
48/***********************
49** PUBLIC FUNCTIONS
50***********************/
51/*
c5aa993b
JM
52 ** tuiRefreshWin()
53 ** Refresh the window
54 */
c906108c 55void
eca6576c 56tuiRefreshWin (TuiGenWinInfoPtr winInfo)
c906108c
SS
57{
58 if (winInfo->type == DATA_WIN && winInfo->contentSize > 0)
59 {
60 int i;
61
62 for (i = 0; (i < winInfo->contentSize); i++)
63 {
64 TuiGenWinInfoPtr dataItemWinPtr;
65
66 dataItemWinPtr = &((TuiWinContent)
67 winInfo->content)[i]->whichElement.dataWindow;
68 if (m_genWinPtrNotNull (dataItemWinPtr) &&
69 dataItemWinPtr->handle != (WINDOW *) NULL)
70 wrefresh (dataItemWinPtr->handle);
71 }
72 }
73 else if (winInfo->type == CMD_WIN)
74 {
75 /* Do nothing */
76 }
77 else
78 {
79 if (winInfo->handle != (WINDOW *) NULL)
80 wrefresh (winInfo->handle);
81 }
82
83 return;
84} /* tuiRefreshWin */
85
86
87/*
c5aa993b
JM
88 ** tuiDelwin()
89 ** Function to delete the curses window, checking for null
90 */
c906108c 91void
eca6576c 92tuiDelwin (WINDOW * window)
c906108c
SS
93{
94 if (window != (WINDOW *) NULL)
95 delwin (window);
96
97 return;
98} /* tuiDelwin */
99
100
af101512 101/* Draw a border arround the window. */
c906108c 102void
eca6576c 103boxWin (TuiGenWinInfoPtr winInfo, int highlightFlag)
c906108c 104{
af101512 105 if (winInfo && winInfo->handle)
c906108c 106 {
af101512
SC
107 WINDOW *win;
108 int attrs;
109
110 win = winInfo->handle;
c906108c 111 if (highlightFlag == HILITE)
af101512 112 attrs = tui_active_border_attrs;
c906108c 113 else
af101512
SC
114 attrs = tui_border_attrs;
115
116 wattron (win, attrs);
117 wborder (win, tui_border_vline, tui_border_vline,
118 tui_border_hline, tui_border_hline,
119 tui_border_ulcorner, tui_border_urcorner,
120 tui_border_llcorner, tui_border_lrcorner);
121 wattroff (win, attrs);
c906108c 122 }
af101512 123}
c906108c
SS
124
125
126/*
c5aa993b
JM
127 ** unhighlightWin().
128 */
c906108c 129void
eca6576c 130unhighlightWin (TuiWinInfoPtr winInfo)
c906108c
SS
131{
132 if (m_winPtrNotNull (winInfo) && winInfo->generic.handle != (WINDOW *) NULL)
133 {
134 boxWin ((TuiGenWinInfoPtr) winInfo, NO_HILITE);
135 wrefresh (winInfo->generic.handle);
136 m_setWinHighlightOff (winInfo);
137 }
138} /* unhighlightWin */
139
140
141/*
c5aa993b
JM
142 ** highlightWin().
143 */
c906108c 144void
eca6576c 145highlightWin (TuiWinInfoPtr winInfo)
c906108c
SS
146{
147 if (m_winPtrNotNull (winInfo) &&
148 winInfo->canHighlight && winInfo->generic.handle != (WINDOW *) NULL)
149 {
150 boxWin ((TuiGenWinInfoPtr) winInfo, HILITE);
151 wrefresh (winInfo->generic.handle);
152 m_setWinHighlightOn (winInfo);
153 }
154} /* highlightWin */
155
156
157/*
c5aa993b
JM
158 ** checkAndDisplayHighlightIfNecessay
159 */
c906108c 160void
eca6576c 161checkAndDisplayHighlightIfNeeded (TuiWinInfoPtr winInfo)
c906108c
SS
162{
163 if (m_winPtrNotNull (winInfo) && winInfo->generic.type != CMD_WIN)
164 {
165 if (winInfo->isHighlighted)
166 highlightWin (winInfo);
167 else
168 unhighlightWin (winInfo);
169
170 }
171 return;
172} /* checkAndDisplayHighlightIfNeeded */
173
174
175/*
c5aa993b
JM
176 ** makeWindow().
177 */
c906108c 178void
eca6576c 179makeWindow (TuiGenWinInfoPtr winInfo, int boxIt)
c906108c
SS
180{
181 WINDOW *handle;
182
183 handle = newwin (winInfo->height,
184 winInfo->width,
185 winInfo->origin.y,
186 winInfo->origin.x);
187 winInfo->handle = handle;
188 if (handle != (WINDOW *) NULL)
189 {
190 if (boxIt == BOX_WINDOW)
191 boxWin (winInfo, NO_HILITE);
192 winInfo->isVisible = TRUE;
193 scrollok (handle, TRUE);
c906108c 194 }
bc712bbf 195}
c906108c
SS
196
197
198/*
c5aa993b
JM
199 ** makeVisible().
200 ** We can't really make windows visible, or invisible. So we
201 ** have to delete the entire window when making it visible,
202 ** and create it again when making it visible.
203 */
c906108c 204void
eca6576c 205makeVisible (TuiGenWinInfoPtr winInfo, int visible)
c906108c
SS
206{
207 /* Don't tear down/recreate command window */
208 if (winInfo->type == CMD_WIN)
209 return;
210
211 if (visible)
212 {
213 if (!winInfo->isVisible)
214 {
215 makeWindow (
216 winInfo,
217 (winInfo->type != CMD_WIN && !m_winIsAuxillary (winInfo->type)));
218 winInfo->isVisible = TRUE;
219 }
c906108c
SS
220 }
221 else if (!visible &&
222 winInfo->isVisible && winInfo->handle != (WINDOW *) NULL)
223 {
224 winInfo->isVisible = FALSE;
c906108c
SS
225 tuiDelwin (winInfo->handle);
226 winInfo->handle = (WINDOW *) NULL;
227 }
228
229 return;
230} /* makeVisible */
231
232
233/*
c5aa993b
JM
234 ** makeAllVisible().
235 ** Makes all windows invisible (except the command and locator windows)
236 */
c906108c 237void
eca6576c 238makeAllVisible (int visible)
c906108c
SS
239{
240 int i;
241
242 for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
243 {
244 if (m_winPtrNotNull (winList[i]) &&
245 ((winList[i])->generic.type) != CMD_WIN)
246 {
247 if (m_winIsSourceType ((winList[i])->generic.type))
248 makeVisible ((winList[i])->detail.sourceInfo.executionInfo,
249 visible);
250 makeVisible ((TuiGenWinInfoPtr) winList[i], visible);
251 }
252 }
253
254 return;
255} /* makeAllVisible */
256
c906108c 257/*
c5aa993b
JM
258 ** refreshAll().
259 ** Function to refresh all the windows currently displayed
260 */
c906108c 261void
eca6576c 262refreshAll (TuiWinInfoPtr * list)
c906108c
SS
263{
264 TuiWinType type;
265 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
266
267 for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
268 {
75fd9bc1 269 if (list[type] && list[type]->generic.isVisible)
c906108c
SS
270 {
271 if (type == SRC_WIN || type == DISASSEM_WIN)
272 {
273 touchwin (list[type]->detail.sourceInfo.executionInfo->handle);
274 tuiRefreshWin (list[type]->detail.sourceInfo.executionInfo);
275 }
276 touchwin (list[type]->generic.handle);
277 tuiRefreshWin (&list[type]->generic);
278 }
279 }
280 if (locator->isVisible)
281 {
282 touchwin (locator->handle);
283 tuiRefreshWin (locator);
284 }
285
286 return;
287} /* refreshAll */
288
289
290/*********************************
291** Local Static Functions
292*********************************/
This page took 0.246457 seconds and 4 git commands to generate.