3 ** This module supports general window behavior
9 #include "tuiGeneralWin.h"
13 ** local support functions
15 static void _winResize (void);
18 /***********************
20 ***********************/
28 TuiGenWinInfoPtr winInfo)
30 tuiRefreshWin (winInfo)
31 TuiGenWinInfoPtr winInfo;
34 if (winInfo->type == DATA_WIN && winInfo->contentSize > 0)
38 for (i = 0; (i < winInfo->contentSize); i++)
40 TuiGenWinInfoPtr dataItemWinPtr;
42 dataItemWinPtr = &((TuiWinContent)
43 winInfo->content)[i]->whichElement.dataWindow;
44 if (m_genWinPtrNotNull (dataItemWinPtr) &&
45 dataItemWinPtr->handle != (WINDOW *) NULL)
46 wrefresh (dataItemWinPtr->handle);
49 else if (winInfo->type == CMD_WIN)
55 if (winInfo->handle != (WINDOW *) NULL)
56 wrefresh (winInfo->handle);
65 ** Function to delete the curses window, checking for null
76 if (window != (WINDOW *) NULL)
89 TuiGenWinInfoPtr winInfo,
92 boxWin (winInfo, highlightFlag)
93 TuiGenWinInfoPtr winInfo;
97 if (m_genWinPtrNotNull (winInfo) && winInfo->handle != (WINDOW *) NULL)
99 if (highlightFlag == HILITE)
100 box (winInfo->handle, '|', '-');
103 /* wattron(winInfo->handle, A_DIM); */
104 box (winInfo->handle, ':', '.');
105 /* wattroff(winInfo->handle, A_DIM); */
119 TuiWinInfoPtr winInfo)
121 unhighlightWin (winInfo)
122 TuiWinInfoPtr winInfo;
125 if (m_winPtrNotNull (winInfo) && winInfo->generic.handle != (WINDOW *) NULL)
127 boxWin ((TuiGenWinInfoPtr) winInfo, NO_HILITE);
128 wrefresh (winInfo->generic.handle);
129 m_setWinHighlightOff (winInfo);
131 } /* unhighlightWin */
140 TuiWinInfoPtr winInfo)
142 highlightWin (winInfo)
143 TuiWinInfoPtr winInfo;
146 if (m_winPtrNotNull (winInfo) &&
147 winInfo->canHighlight && winInfo->generic.handle != (WINDOW *) NULL)
149 boxWin ((TuiGenWinInfoPtr) winInfo, HILITE);
150 wrefresh (winInfo->generic.handle);
151 m_setWinHighlightOn (winInfo);
157 ** checkAndDisplayHighlightIfNecessay
161 checkAndDisplayHighlightIfNeeded (
162 TuiWinInfoPtr winInfo)
164 checkAndDisplayHighlightIfNeeded (winInfo)
165 TuiWinInfoPtr winInfo;
168 if (m_winPtrNotNull (winInfo) && winInfo->generic.type != CMD_WIN)
170 if (winInfo->isHighlighted)
171 highlightWin (winInfo);
173 unhighlightWin (winInfo);
177 } /* checkAndDisplayHighlightIfNeeded */
186 TuiGenWinInfoPtr winInfo,
189 makeWindow (winInfo, boxIt)
190 TuiGenWinInfoPtr winInfo;
196 handle = newwin (winInfo->height,
200 winInfo->handle = handle;
201 if (handle != (WINDOW *) NULL)
203 if (boxIt == BOX_WINDOW)
204 boxWin (winInfo, NO_HILITE);
205 winInfo->isVisible = TRUE;
206 scrollok (handle, TRUE);
207 tuiRefreshWin (winInfo);
210 if ( /*!m_WinIsAuxillary(winInfo->type) && */
211 (winInfo->type != CMD_WIN) &&
212 (winInfo->content == (OpaquePtr) NULL))
214 mvwaddstr (handle, 1, 1, winName (winInfo));
215 tuiRefreshWin (winInfo);
226 ** Clear the window of all contents without calling wclear.
231 TuiGenWinInfoPtr winInfo)
233 tuiClearWin (winInfo)
234 TuiGenWinInfoPtr winInfo;
237 if (m_genWinPtrNotNull (winInfo) && winInfo->handle != (WINDOW *) NULL)
241 for (curRow = 0; (curRow < winInfo->height); curRow++)
242 for (curCol = 0; (curCol < winInfo->width); curCol++)
243 mvwaddch (winInfo->handle, curRow, curCol, ' ');
245 tuiRefreshWin (winInfo);
254 ** We can't really make windows visible, or invisible. So we
255 ** have to delete the entire window when making it visible,
256 ** and create it again when making it visible.
261 TuiGenWinInfoPtr winInfo,
264 makeVisible (winInfo, visible)
265 TuiGenWinInfoPtr winInfo;
269 /* Don't tear down/recreate command window */
270 if (winInfo->type == CMD_WIN)
275 if (!winInfo->isVisible)
279 (winInfo->type != CMD_WIN && !m_winIsAuxillary (winInfo->type)));
280 winInfo->isVisible = TRUE;
282 tuiRefreshWin (winInfo);
285 winInfo->isVisible && winInfo->handle != (WINDOW *) NULL)
287 winInfo->isVisible = FALSE;
288 tuiClearWin (winInfo);
289 tuiDelwin (winInfo->handle);
290 winInfo->handle = (WINDOW *) NULL;
299 ** Makes all windows invisible (except the command and locator windows)
306 makeAllVisible (visible)
312 for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
314 if (m_winPtrNotNull (winList[i]) &&
315 ((winList[i])->generic.type) != CMD_WIN)
317 if (m_winIsSourceType ((winList[i])->generic.type))
318 makeVisible ((winList[i])->detail.sourceInfo.executionInfo,
320 makeVisible ((TuiGenWinInfoPtr) winList[i], visible);
325 } /* makeAllVisible */
334 TuiGenWinInfoPtr winInfo,
337 scrollWinForward (winInfo, numLines)
338 TuiGenWinInfoPtr winInfo;
342 if (winInfo->content != (OpaquePtr) NULL &&
343 winInfo->lastVisibleLine < winInfo->contentSize - 1)
345 int i, firstLine, newLastLine;
347 firstLine = winInfo->lastVisibleLine - winInfo->viewportHeight + 1;
348 if (winInfo->lastVisibleLine + numLines > winInfo->contentSize)
349 newLastLine = winInfo->contentSize - 1;
351 newLastLine = winInfo->lastVisibleLine + numLines - 1;
353 for (i = (newLastLine - winInfo->viewportHeight);
354 (i <= newLastLine); i++)
356 TuiWinElementPtr line;
359 line = (TuiWinElementPtr) winInfo->content[i];
361 wstandout (winInfo->handle);
362 mvwaddstr (winInfo->handle,
363 i - (newLastLine - winInfo->viewportHeight),
365 displayableWinContentOf (winInfo, line));
367 wstandend (winInfo->handle);
368 lineHeight = winElementHeight (winInfo, line);
369 newLastLine += (lineHeight - 1);
371 winInfo->lastVisibleLine = newLastLine;
375 } /* scrollWinForward */
384 TuiGenWinInfoPtr winInfo,
387 scrollWinBackward (winInfo, numLines)
388 TuiGenWinInfoPtr winInfo;
392 if (winInfo->content != (OpaquePtr) NULL &&
393 (winInfo->lastVisibleLine - winInfo->viewportHeight) > 0)
395 int i, newLastLine, firstLine;
397 firstLine = winInfo->lastVisibleLine - winInfo->viewportHeight + 1;
398 if ((firstLine - numLines) < 0)
399 newLastLine = winInfo->viewportHeight - 1;
401 newLastLine = winInfo->lastVisibleLine - numLines + 1;
403 for (i = newLastLine - winInfo->viewportHeight; (i <= newLastLine); i++)
405 TuiWinElementPtr line;
408 line = (TuiWinElementPtr) winInfo->content[i];
410 wstandout (winInfo->handle);
411 mvwaddstr (winInfo->handle,
412 i - (newLastLine - winInfo->viewportHeight),
414 displayableWinContentOf (winInfo, line));
416 wstandend (winInfo->handle);
417 lineHeight = winElementHeight (winInfo, line);
418 newLastLine += (lineHeight - 1);
420 winInfo->lastVisibleLine = newLastLine;
424 } /* scrollWinBackward */
429 ** Function to refresh all the windows currently displayed
434 TuiWinInfoPtr * list)
441 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
443 for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
445 if (list[type]->generic.isVisible)
447 if (type == SRC_WIN || type == DISASSEM_WIN)
449 touchwin (list[type]->detail.sourceInfo.executionInfo->handle);
450 tuiRefreshWin (list[type]->detail.sourceInfo.executionInfo);
452 touchwin (list[type]->generic.handle);
453 tuiRefreshWin (&list[type]->generic);
456 if (locator->isVisible)
458 touchwin (locator->handle);
459 tuiRefreshWin (locator);
466 /*********************************
467 ** Local Static Functions
468 *********************************/