1 /* General window behavior.
2 Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Hewlett-Packard Company.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
25 #include "tuiGeneralWin.h"
29 ** local support functions
31 static void _winResize (void);
34 /***********************
36 ***********************/
42 tuiRefreshWin (TuiGenWinInfoPtr winInfo
)
44 if (winInfo
->type
== DATA_WIN
&& winInfo
->contentSize
> 0)
48 for (i
= 0; (i
< winInfo
->contentSize
); i
++)
50 TuiGenWinInfoPtr dataItemWinPtr
;
52 dataItemWinPtr
= &((TuiWinContent
)
53 winInfo
->content
)[i
]->whichElement
.dataWindow
;
54 if (m_genWinPtrNotNull (dataItemWinPtr
) &&
55 dataItemWinPtr
->handle
!= (WINDOW
*) NULL
)
56 wrefresh (dataItemWinPtr
->handle
);
59 else if (winInfo
->type
== CMD_WIN
)
65 if (winInfo
->handle
!= (WINDOW
*) NULL
)
66 wrefresh (winInfo
->handle
);
75 ** Function to delete the curses window, checking for null
78 tuiDelwin (WINDOW
* window
)
80 if (window
!= (WINDOW
*) NULL
)
91 boxWin (TuiGenWinInfoPtr winInfo
, int highlightFlag
)
93 if (m_genWinPtrNotNull (winInfo
) && winInfo
->handle
!= (WINDOW
*) NULL
)
95 if (highlightFlag
== HILITE
)
96 box (winInfo
->handle
, '|', '-');
99 /* wattron(winInfo->handle, A_DIM); */
100 box (winInfo
->handle
, ':', '.');
101 /* wattroff(winInfo->handle, A_DIM); */
113 unhighlightWin (TuiWinInfoPtr winInfo
)
115 if (m_winPtrNotNull (winInfo
) && winInfo
->generic
.handle
!= (WINDOW
*) NULL
)
117 boxWin ((TuiGenWinInfoPtr
) winInfo
, NO_HILITE
);
118 wrefresh (winInfo
->generic
.handle
);
119 m_setWinHighlightOff (winInfo
);
121 } /* unhighlightWin */
128 highlightWin (TuiWinInfoPtr winInfo
)
130 if (m_winPtrNotNull (winInfo
) &&
131 winInfo
->canHighlight
&& winInfo
->generic
.handle
!= (WINDOW
*) NULL
)
133 boxWin ((TuiGenWinInfoPtr
) winInfo
, HILITE
);
134 wrefresh (winInfo
->generic
.handle
);
135 m_setWinHighlightOn (winInfo
);
141 ** checkAndDisplayHighlightIfNecessay
144 checkAndDisplayHighlightIfNeeded (TuiWinInfoPtr winInfo
)
146 if (m_winPtrNotNull (winInfo
) && winInfo
->generic
.type
!= CMD_WIN
)
148 if (winInfo
->isHighlighted
)
149 highlightWin (winInfo
);
151 unhighlightWin (winInfo
);
155 } /* checkAndDisplayHighlightIfNeeded */
162 makeWindow (TuiGenWinInfoPtr winInfo
, int boxIt
)
166 handle
= newwin (winInfo
->height
,
170 winInfo
->handle
= handle
;
171 if (handle
!= (WINDOW
*) NULL
)
173 if (boxIt
== BOX_WINDOW
)
174 boxWin (winInfo
, NO_HILITE
);
175 winInfo
->isVisible
= TRUE
;
176 scrollok (handle
, TRUE
);
177 tuiRefreshWin (winInfo
);
180 if ( /*!m_WinIsAuxillary(winInfo->type) && */
181 (winInfo
->type
!= CMD_WIN
) &&
182 (winInfo
->content
== (OpaquePtr
) NULL
))
184 mvwaddstr (handle
, 1, 1, winName (winInfo
));
185 tuiRefreshWin (winInfo
);
196 ** Clear the window of all contents without calling wclear.
199 tuiClearWin (TuiGenWinInfoPtr winInfo
)
201 if (m_genWinPtrNotNull (winInfo
) && winInfo
->handle
!= (WINDOW
*) NULL
)
205 for (curRow
= 0; (curRow
< winInfo
->height
); curRow
++)
206 for (curCol
= 0; (curCol
< winInfo
->width
); curCol
++)
207 mvwaddch (winInfo
->handle
, curRow
, curCol
, ' ');
209 tuiRefreshWin (winInfo
);
218 ** We can't really make windows visible, or invisible. So we
219 ** have to delete the entire window when making it visible,
220 ** and create it again when making it visible.
223 makeVisible (TuiGenWinInfoPtr winInfo
, int visible
)
225 /* Don't tear down/recreate command window */
226 if (winInfo
->type
== CMD_WIN
)
231 if (!winInfo
->isVisible
)
235 (winInfo
->type
!= CMD_WIN
&& !m_winIsAuxillary (winInfo
->type
)));
236 winInfo
->isVisible
= TRUE
;
238 tuiRefreshWin (winInfo
);
241 winInfo
->isVisible
&& winInfo
->handle
!= (WINDOW
*) NULL
)
243 winInfo
->isVisible
= FALSE
;
244 tuiClearWin (winInfo
);
245 tuiDelwin (winInfo
->handle
);
246 winInfo
->handle
= (WINDOW
*) NULL
;
255 ** Makes all windows invisible (except the command and locator windows)
258 makeAllVisible (int visible
)
262 for (i
= 0; i
< MAX_MAJOR_WINDOWS
; i
++)
264 if (m_winPtrNotNull (winList
[i
]) &&
265 ((winList
[i
])->generic
.type
) != CMD_WIN
)
267 if (m_winIsSourceType ((winList
[i
])->generic
.type
))
268 makeVisible ((winList
[i
])->detail
.sourceInfo
.executionInfo
,
270 makeVisible ((TuiGenWinInfoPtr
) winList
[i
], visible
);
275 } /* makeAllVisible */
282 scrollWinForward (TuiGenWinInfoPtr winInfo
, int numLines
)
284 if (winInfo
->content
!= (OpaquePtr
) NULL
&&
285 winInfo
->lastVisibleLine
< winInfo
->contentSize
- 1)
287 int i
, firstLine
, newLastLine
;
289 firstLine
= winInfo
->lastVisibleLine
- winInfo
->viewportHeight
+ 1;
290 if (winInfo
->lastVisibleLine
+ numLines
> winInfo
->contentSize
)
291 newLastLine
= winInfo
->contentSize
- 1;
293 newLastLine
= winInfo
->lastVisibleLine
+ numLines
- 1;
295 for (i
= (newLastLine
- winInfo
->viewportHeight
);
296 (i
<= newLastLine
); i
++)
298 TuiWinElementPtr line
;
301 line
= (TuiWinElementPtr
) winInfo
->content
[i
];
303 wstandout (winInfo
->handle
);
304 mvwaddstr (winInfo
->handle
,
305 i
- (newLastLine
- winInfo
->viewportHeight
),
307 displayableWinContentOf (winInfo
, line
));
309 wstandend (winInfo
->handle
);
310 lineHeight
= winElementHeight (winInfo
, line
);
311 newLastLine
+= (lineHeight
- 1);
313 winInfo
->lastVisibleLine
= newLastLine
;
317 } /* scrollWinForward */
324 scrollWinBackward (TuiGenWinInfoPtr winInfo
, int numLines
)
326 if (winInfo
->content
!= (OpaquePtr
) NULL
&&
327 (winInfo
->lastVisibleLine
- winInfo
->viewportHeight
) > 0)
329 int i
, newLastLine
, firstLine
;
331 firstLine
= winInfo
->lastVisibleLine
- winInfo
->viewportHeight
+ 1;
332 if ((firstLine
- numLines
) < 0)
333 newLastLine
= winInfo
->viewportHeight
- 1;
335 newLastLine
= winInfo
->lastVisibleLine
- numLines
+ 1;
337 for (i
= newLastLine
- winInfo
->viewportHeight
; (i
<= newLastLine
); i
++)
339 TuiWinElementPtr line
;
342 line
= (TuiWinElementPtr
) winInfo
->content
[i
];
344 wstandout (winInfo
->handle
);
345 mvwaddstr (winInfo
->handle
,
346 i
- (newLastLine
- winInfo
->viewportHeight
),
348 displayableWinContentOf (winInfo
, line
));
350 wstandend (winInfo
->handle
);
351 lineHeight
= winElementHeight (winInfo
, line
);
352 newLastLine
+= (lineHeight
- 1);
354 winInfo
->lastVisibleLine
= newLastLine
;
358 } /* scrollWinBackward */
363 ** Function to refresh all the windows currently displayed
366 refreshAll (TuiWinInfoPtr
* list
)
369 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
371 for (type
= SRC_WIN
; (type
< MAX_MAJOR_WINDOWS
); type
++)
373 if (list
[type
]->generic
.isVisible
)
375 if (type
== SRC_WIN
|| type
== DISASSEM_WIN
)
377 touchwin (list
[type
]->detail
.sourceInfo
.executionInfo
->handle
);
378 tuiRefreshWin (list
[type
]->detail
.sourceInfo
.executionInfo
);
380 touchwin (list
[type
]->generic
.handle
);
381 tuiRefreshWin (&list
[type
]->generic
);
384 if (locator
->isVisible
)
386 touchwin (locator
->handle
);
387 tuiRefreshWin (locator
);
394 /*********************************
395 ** Local Static Functions
396 *********************************/