3 ** This module contains procedures for handling tui window functions
4 ** like resize, scrolling, scrolling, changing focus, etc.
6 ** Author: Susan B. Macchia
14 #include "breakpoint.h"
19 #include "tuiGeneralWin.h"
21 #include "tuiSourceWin.h"
22 #include "tuiDataWin.h"
24 /*******************************
25 ** External Declarations
26 ********************************/
27 extern void init_page_info ();
29 /*******************************
31 ********************************/
32 static void _makeVisibleWithNewHeight PARAMS ((TuiWinInfoPtr));
33 static void _makeInvisibleAndSetNewHeight PARAMS ((TuiWinInfoPtr, int));
34 static TuiStatus _tuiAdjustWinHeights PARAMS ((TuiWinInfoPtr, int));
35 static int _newHeightOk PARAMS ((TuiWinInfoPtr, int));
36 static void _tuiSetTabWidth_command PARAMS ((char *, int));
37 static void _tuiRefreshAll_command PARAMS ((char *, int));
38 static void _tuiSetWinHeight_command PARAMS ((char *, int));
39 static void _tuiXDBsetWinHeight_command PARAMS ((char *, int));
40 static void _tuiAllWindowsInfo PARAMS ((char *, int));
41 static void _tuiSetFocus_command PARAMS ((char *, int));
42 static void _tuiScrollForward_command PARAMS ((char *, int));
43 static void _tuiScrollBackward_command PARAMS ((char *, int));
44 static void _tuiScrollLeft_command PARAMS ((char *, int));
45 static void _tuiScrollRight_command PARAMS ((char *, int));
46 static void _parseScrollingArgs PARAMS ((char *, TuiWinInfoPtr *, int *));
49 /***************************************
51 ***************************************/
52 #define WIN_HEIGHT_USAGE "Usage: winheight <win_name> [+ | -] <#lines>\n"
53 #define XDBWIN_HEIGHT_USAGE "Usage: w <#lines>\n"
54 #define FOCUS_USAGE "Usage: focus {<win> | next | prev}\n"
56 /***************************************
58 ***************************************/
61 ** _initialize_tuiWin().
62 ** Function to initialize gdb commands, for tui window manipulation.
69 add_com ("refresh", class_tui, _tuiRefreshAll_command,
70 "Refresh the terminal display.\n");
72 add_com_alias ("U", "refresh", class_tui, 0);
73 add_com ("tabset", class_tui, _tuiSetTabWidth_command,
74 "Set the width (in characters) of tab stops.\n\
75 Usage: tabset <n>\n");
76 add_com ("winheight", class_tui, _tuiSetWinHeight_command,
77 "Set the height of a specified window.\n\
78 Usage: winheight <win_name> [+ | -] <#lines>\n\
80 src : the source window\n\
81 cmd : the command window\n\
82 asm : the disassembly window\n\
83 regs : the register display\n");
84 add_com_alias ("wh", "winheight", class_tui, 0);
85 add_info ("win", _tuiAllWindowsInfo,
86 "List of all displayed windows.\n");
87 add_com ("focus", class_tui, _tuiSetFocus_command,
88 "Set focus to named window or next/prev window.\n\
89 Usage: focus {<win> | next | prev}\n\
90 Valid Window names are:\n\
91 src : the source window\n\
92 asm : the disassembly window\n\
93 regs : the register display\n\
94 cmd : the command window\n");
95 add_com_alias ("fs", "focus", class_tui, 0);
96 add_com ("+", class_tui, _tuiScrollForward_command,
97 "Scroll window forward.\nUsage: + [win] [n]\n");
98 add_com ("-", class_tui, _tuiScrollBackward_command,
99 "Scroll window backward.\nUsage: - [win] [n]\n");
100 add_com ("<", class_tui, _tuiScrollLeft_command,
101 "Scroll window forward.\nUsage: < [win] [n]\n");
102 add_com (">", class_tui, _tuiScrollRight_command,
103 "Scroll window backward.\nUsage: > [win] [n]\n");
105 add_com ("w", class_xdb, _tuiXDBsetWinHeight_command,
106 "XDB compatibility command for setting the height of a command window.\n\
107 Usage: w <#lines>\n");
111 } /* _intialize_tuiWin */
115 ** tuiClearWinFocusFrom
116 ** Clear the logical focus from winInfo
120 tuiClearWinFocusFrom (
121 TuiWinInfoPtr winInfo)
123 tuiClearWinFocusFrom (winInfo)
124 TuiWinInfoPtr winInfo;
127 if (m_winPtrNotNull (winInfo))
129 if (winInfo->generic.type != CMD_WIN)
130 unhighlightWin (winInfo);
131 tuiSetWinWithFocus ((TuiWinInfoPtr) NULL);
135 } /* tuiClearWinFocusFrom */
139 ** tuiClearWinFocus().
140 ** Clear the window that has focus.
144 tuiClearWinFocus (void)
149 tuiClearWinFocusFrom (tuiWinWithFocus ());
152 } /* tuiClearWinFocus */
157 ** Set the logical focus to winInfo
162 TuiWinInfoPtr winInfo)
164 tuiSetWinFocusTo (winInfo)
165 TuiWinInfoPtr winInfo;
168 if (m_winPtrNotNull (winInfo))
170 TuiWinInfoPtr winWithFocus = tuiWinWithFocus ();
172 if (m_winPtrNotNull (winWithFocus) &&
173 winWithFocus->generic.type != CMD_WIN)
174 unhighlightWin (winWithFocus);
175 tuiSetWinWithFocus (winInfo);
176 if (winInfo->generic.type != CMD_WIN)
177 highlightWin (winInfo);
181 } /* tuiSetWinFocusTo */
193 char *newStr = (char *) NULL;
195 if (str != (char *) NULL)
197 newStr = (char *) xmalloc (strlen (str) + 1);
198 strcpy (newStr, str);
206 ** tuiScrollForward().
211 TuiWinInfoPtr winToScroll,
214 tuiScrollForward (winToScroll, numToScroll)
215 TuiWinInfoPtr winToScroll;
219 if (winToScroll != cmdWin)
221 int _numToScroll = numToScroll;
223 if (numToScroll == 0)
224 _numToScroll = winToScroll->generic.height - 3;
226 ** If we are scrolling the source or disassembly window, do a
227 ** "psuedo" scroll since not all of the source is in memory,
228 ** only what is in the viewport. If winToScroll is the
229 ** command window do nothing since the term should handle it.
231 if (winToScroll == srcWin)
232 tuiVerticalSourceScroll (FORWARD_SCROLL, _numToScroll);
233 else if (winToScroll == disassemWin)
234 tuiVerticalDisassemScroll (FORWARD_SCROLL, _numToScroll);
235 else if (winToScroll == dataWin)
236 tuiVerticalDataScroll (FORWARD_SCROLL, _numToScroll);
240 } /* tuiScrollForward */
244 ** tuiScrollBackward().
249 TuiWinInfoPtr winToScroll,
252 tuiScrollBackward (winToScroll, numToScroll)
253 TuiWinInfoPtr winToScroll;
257 if (winToScroll != cmdWin)
259 int _numToScroll = numToScroll;
261 if (numToScroll == 0)
262 _numToScroll = winToScroll->generic.height - 3;
264 ** If we are scrolling the source or disassembly window, do a
265 ** "psuedo" scroll since not all of the source is in memory,
266 ** only what is in the viewport. If winToScroll is the
267 ** command window do nothing since the term should handle it.
269 if (winToScroll == srcWin)
270 tuiVerticalSourceScroll (BACKWARD_SCROLL, _numToScroll);
271 else if (winToScroll == disassemWin)
272 tuiVerticalDisassemScroll (BACKWARD_SCROLL, _numToScroll);
273 else if (winToScroll == dataWin)
274 tuiVerticalDataScroll (BACKWARD_SCROLL, _numToScroll);
277 } /* tuiScrollBackward */
286 TuiWinInfoPtr winToScroll,
289 tuiScrollLeft (winToScroll, numToScroll)
290 TuiWinInfoPtr winToScroll;
294 if (winToScroll != cmdWin)
296 int _numToScroll = numToScroll;
298 if (_numToScroll == 0)
301 ** If we are scrolling the source or disassembly window, do a
302 ** "psuedo" scroll since not all of the source is in memory,
303 ** only what is in the viewport. If winToScroll is the
304 ** command window do nothing since the term should handle it.
306 if (winToScroll == srcWin || winToScroll == disassemWin)
307 tuiHorizontalSourceScroll (winToScroll, LEFT_SCROLL, _numToScroll);
310 } /* tuiScrollLeft */
319 TuiWinInfoPtr winToScroll,
322 tuiScrollRight (winToScroll, numToScroll)
323 TuiWinInfoPtr winToScroll;
327 if (winToScroll != cmdWin)
329 int _numToScroll = numToScroll;
331 if (_numToScroll == 0)
334 ** If we are scrolling the source or disassembly window, do a
335 ** "psuedo" scroll since not all of the source is in memory,
336 ** only what is in the viewport. If winToScroll is the
337 ** command window do nothing since the term should handle it.
339 if (winToScroll == srcWin || winToScroll == disassemWin)
340 tuiHorizontalSourceScroll (winToScroll, RIGHT_SCROLL, _numToScroll);
343 } /* tuiScrollRight */
348 ** Scroll a window. Arguments are passed through a va_list.
359 TuiScrollDirection direction = va_arg (args, TuiScrollDirection);
360 TuiWinInfoPtr winToScroll = va_arg (args, TuiWinInfoPtr);
361 int numToScroll = va_arg (args, int);
366 tuiScrollForward (winToScroll, numToScroll);
368 case BACKWARD_SCROLL:
369 tuiScrollBackward (winToScroll, numToScroll);
372 tuiScrollLeft (winToScroll, numToScroll);
375 tuiScrollRight (winToScroll, numToScroll);
397 refreshAll (winList);
398 for (type = SRC_WIN; type < MAX_MAJOR_WINDOWS; type++)
400 if (winList[type]->generic.isVisible)
406 tuiClearWin (&winList[type]->generic);
407 if (winList[type]->detail.sourceInfo.hasLocator)
408 tuiClearLocatorDisplay ();
409 tuiShowSourceContent (winList[type]);
410 checkAndDisplayHighlightIfNeeded (winList[type]);
411 tuiEraseExecInfoContent (winList[type]);
412 tuiUpdateExecInfo (winList[type]);
415 tuiRefreshDataWin ();
422 tuiClearLocatorDisplay ();
423 tuiShowLocatorContent ();
426 } /* tuiRefreshAll */
431 ** Resize all the windows based on the the terminal size. This
432 ** function gets called from within the readline sinwinch handler.
441 int heightDiff, widthDiff;
442 extern int screenheight, screenwidth; /* in readline */
444 widthDiff = screenwidth - termWidth ();
445 heightDiff = screenheight - termHeight ();
446 if (heightDiff || widthDiff)
448 TuiLayoutType curLayout = currentLayout ();
449 TuiWinInfoPtr winWithFocus = tuiWinWithFocus ();
450 TuiWinInfoPtr firstWin, secondWin;
451 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
453 int i, newHeight, splitDiff, cmdSplitDiff, numWinsDisplayed = 2;
455 /* turn keypad off while we resize */
456 if (winWithFocus != cmdWin)
457 keypad (cmdWin->generic.handle, FALSE);
459 setTermHeightTo (screenheight);
460 setTermWidthTo (screenwidth);
461 if (curLayout == SRC_DISASSEM_COMMAND ||
462 curLayout == SRC_DATA_COMMAND || curLayout == DISASSEM_DATA_COMMAND)
464 splitDiff = heightDiff / numWinsDisplayed;
465 cmdSplitDiff = splitDiff;
466 if (heightDiff % numWinsDisplayed)
473 /* now adjust each window */
479 case DISASSEM_COMMAND:
480 firstWin = (TuiWinInfoPtr) (sourceWindows ())->list[0];
481 firstWin->generic.width += widthDiff;
482 locator->width += widthDiff;
483 /* check for invalid heights */
485 newHeight = firstWin->generic.height;
486 else if ((firstWin->generic.height + splitDiff) >=
487 (screenheight - MIN_CMD_WIN_HEIGHT - 1))
488 newHeight = screenheight - MIN_CMD_WIN_HEIGHT - 1;
489 else if ((firstWin->generic.height + splitDiff) <= 0)
490 newHeight = MIN_WIN_HEIGHT;
492 newHeight = firstWin->generic.height + splitDiff;
494 _makeInvisibleAndSetNewHeight (firstWin, newHeight);
495 cmdWin->generic.origin.y = locator->origin.y + 1;
496 cmdWin->generic.width += widthDiff;
497 newHeight = screenheight - cmdWin->generic.origin.y;
498 _makeInvisibleAndSetNewHeight (cmdWin, newHeight);
499 _makeVisibleWithNewHeight (firstWin);
500 _makeVisibleWithNewHeight (cmdWin);
501 if (firstWin->generic.contentSize <= 0)
502 tuiEraseSourceContent (firstWin, EMPTY_SOURCE_PROMPT);
505 if (curLayout == SRC_DISASSEM_COMMAND)
508 firstWin->generic.width += widthDiff;
509 secondWin = disassemWin;
510 secondWin->generic.width += widthDiff;
515 firstWin->generic.width += widthDiff;
516 secondWin = (TuiWinInfoPtr) (sourceWindows ())->list[0];
517 secondWin->generic.width += widthDiff;
519 /* Change the first window's height/width */
520 /* check for invalid heights */
522 newHeight = firstWin->generic.height;
523 else if ((firstWin->generic.height +
524 secondWin->generic.height + (splitDiff * 2)) >=
525 (screenheight - MIN_CMD_WIN_HEIGHT - 1))
526 newHeight = (screenheight - MIN_CMD_WIN_HEIGHT - 1) / 2;
527 else if ((firstWin->generic.height + splitDiff) <= 0)
528 newHeight = MIN_WIN_HEIGHT;
530 newHeight = firstWin->generic.height + splitDiff;
531 _makeInvisibleAndSetNewHeight (firstWin, newHeight);
533 if (firstWin == dataWin && widthDiff != 0)
534 firstWin->detail.dataDisplayInfo.regsColumnCount =
535 tuiCalculateRegsColumnCount (
536 firstWin->detail.dataDisplayInfo.regsDisplayType);
537 locator->width += widthDiff;
539 /* Change the second window's height/width */
540 /* check for invalid heights */
542 newHeight = secondWin->generic.height;
543 else if ((firstWin->generic.height +
544 secondWin->generic.height + (splitDiff * 2)) >=
545 (screenheight - MIN_CMD_WIN_HEIGHT - 1))
547 newHeight = screenheight - MIN_CMD_WIN_HEIGHT - 1;
549 newHeight = (newHeight / 2) + 1;
553 else if ((secondWin->generic.height + splitDiff) <= 0)
554 newHeight = MIN_WIN_HEIGHT;
556 newHeight = secondWin->generic.height + splitDiff;
557 secondWin->generic.origin.y = firstWin->generic.height - 1;
558 _makeInvisibleAndSetNewHeight (secondWin, newHeight);
560 /* Change the command window's height/width */
561 cmdWin->generic.origin.y = locator->origin.y + 1;
562 _makeInvisibleAndSetNewHeight (
563 cmdWin, cmdWin->generic.height + cmdSplitDiff);
564 _makeVisibleWithNewHeight (firstWin);
565 _makeVisibleWithNewHeight (secondWin);
566 _makeVisibleWithNewHeight (cmdWin);
567 if (firstWin->generic.contentSize <= 0)
568 tuiEraseSourceContent (firstWin, EMPTY_SOURCE_PROMPT);
569 if (secondWin->generic.contentSize <= 0)
570 tuiEraseSourceContent (secondWin, EMPTY_SOURCE_PROMPT);
574 ** Now remove all invisible windows, and their content so that they get
575 ** created again when called for with the new size
577 for (winType = SRC_WIN; (winType < MAX_MAJOR_WINDOWS); winType++)
579 if (winType != CMD_WIN && m_winPtrNotNull (winList[winType]) &&
580 !winList[winType]->generic.isVisible)
582 freeWindow (winList[winType]);
583 winList[winType] = (TuiWinInfoPtr) NULL;
586 tuiSetWinResizedTo (TRUE);
587 /* turn keypad back on, unless focus is in the command window */
588 if (winWithFocus != cmdWin)
589 keypad (cmdWin->generic.handle, TRUE);
596 ** tuiSigwinchHandler()
597 ** SIGWINCH signal handler for the tui. This signal handler is
598 ** always called, even when the readline package clears signals
599 ** because it is set as the old_sigwinch() (TUI only)
606 tuiSigwinchHandler (signal)
611 ** Say that a resize was done so that the readline can do it
612 ** later when appropriate.
614 tuiSetWinResizedTo (TRUE);
617 } /* tuiSigwinchHandler */
621 /*************************
622 ** STATIC LOCAL FUNCTIONS
623 **************************/
627 ** _tuiScrollForward_command().
631 _tuiScrollForward_command (
635 _tuiScrollForward_command (arg, fromTTY)
641 TuiWinInfoPtr winToScroll;
643 if (arg == (char *) NULL)
644 _parseScrollingArgs (arg, &winToScroll, (int *) NULL);
646 _parseScrollingArgs (arg, &winToScroll, &numToScroll);
647 tuiDo ((TuiOpaqueFuncPtr) tui_vScroll,
653 } /* _tuiScrollForward_command */
657 ** _tuiScrollBackward_command().
661 _tuiScrollBackward_command (
665 _tuiScrollBackward_command (arg, fromTTY)
671 TuiWinInfoPtr winToScroll;
673 if (arg == (char *) NULL)
674 _parseScrollingArgs (arg, &winToScroll, (int *) NULL);
676 _parseScrollingArgs (arg, &winToScroll, &numToScroll);
677 tuiDo ((TuiOpaqueFuncPtr) tui_vScroll,
683 } /* _tuiScrollBackward_command */
687 ** _tuiScrollLeft_command().
691 _tuiScrollLeft_command (
695 _tuiScrollLeft_command (arg, fromTTY)
701 TuiWinInfoPtr winToScroll;
703 _parseScrollingArgs (arg, &winToScroll, &numToScroll);
704 tuiDo ((TuiOpaqueFuncPtr) tui_vScroll,
710 } /* _tuiScrollLeft_command */
714 ** _tuiScrollRight_command().
718 _tuiScrollRight_command (
722 _tuiScrollRight_command (arg, fromTTY)
728 TuiWinInfoPtr winToScroll;
730 _parseScrollingArgs (arg, &winToScroll, &numToScroll);
731 tuiDo ((TuiOpaqueFuncPtr) tui_vScroll,
737 } /* _tuiScrollRight_command */
742 ** Set focus to the window named by 'arg'
750 _tuiSetFocus (arg, fromTTY)
755 if (arg != (char *) NULL)
757 char *bufPtr = (char *) tuiStrDup (arg);
759 TuiWinInfoPtr winInfo = (TuiWinInfoPtr) NULL;
761 for (i = 0; (i < strlen (bufPtr)); i++)
762 bufPtr[i] = toupper (arg[i]);
764 if (subsetCompare (bufPtr, "NEXT"))
765 winInfo = tuiNextWin (tuiWinWithFocus ());
766 else if (subsetCompare (bufPtr, "PREV"))
767 winInfo = tuiPrevWin (tuiWinWithFocus ());
769 winInfo = partialWinByName (bufPtr);
771 if (winInfo == (TuiWinInfoPtr) NULL || !winInfo->generic.isVisible)
772 warning ("Invalid window specified. \n\
773 The window name specified must be valid and visible.\n");
776 tuiSetWinFocusTo (winInfo);
777 keypad (cmdWin->generic.handle, (winInfo != cmdWin));
780 if (dataWin->generic.isVisible)
781 tuiRefreshDataWin ();
783 printf_filtered ("Focus set to %s window.\n",
784 winName ((TuiGenWinInfoPtr) tuiWinWithFocus ()));
787 warning ("Incorrect Number of Arguments.\n%s", FOCUS_USAGE);
801 _tui_vSetFocus (args)
805 char *arg = va_arg (args, char *);
806 int fromTTY = va_arg (args, int);
808 _tuiSetFocus (arg, fromTTY);
811 } /* tui_vSetFocus */
815 ** _tuiSetFocus_command()
819 _tuiSetFocus_command (
823 _tuiSetFocus_command (arg, fromTTY)
828 tuiDo ((TuiOpaqueFuncPtr) _tui_vSetFocus, arg, fromTTY);
835 ** _tuiAllWindowsInfo().
843 _tuiAllWindowsInfo (arg, fromTTY)
849 TuiWinInfoPtr winWithFocus = tuiWinWithFocus ();
851 for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
852 if (winList[type]->generic.isVisible)
854 if (winWithFocus == winList[type])
855 printf_filtered (" %s\t(%d lines) <has focus>\n",
856 winName (&winList[type]->generic),
857 winList[type]->generic.height);
859 printf_filtered (" %s\t(%d lines)\n",
860 winName (&winList[type]->generic),
861 winList[type]->generic.height);
865 } /* _tuiAllWindowsInfo */
869 ** _tuiRefreshAll_command().
873 _tuiRefreshAll_command (
877 _tuiRefreshAll_command (arg, fromTTY)
882 tuiDo ((TuiOpaqueFuncPtr) tuiRefreshAll);
887 ** _tuiSetWinTabWidth_command().
888 ** Set the height of the specified window.
892 _tuiSetTabWidth_command (
896 _tuiSetTabWidth_command (arg, fromTTY)
901 if (arg != (char *) NULL)
907 tuiSetDefaultTabLen (ts);
909 warning ("Tab widths greater than 0 must be specified.\n");
913 } /* _tuiSetTabWidth_command */
917 ** _tuiSetWinHeight().
918 ** Set the height of the specified window.
926 _tuiSetWinHeight (arg, fromTTY)
931 if (arg != (char *) NULL)
933 char *buf = tuiStrDup (arg);
935 char *wname = (char *) NULL;
937 TuiWinInfoPtr winInfo;
940 bufPtr = strchr (bufPtr, ' ');
941 if (bufPtr != (char *) NULL)
946 ** Validate the window name
948 for (i = 0; i < strlen (wname); i++)
949 wname[i] = toupper (wname[i]);
950 winInfo = partialWinByName (wname);
952 if (winInfo == (TuiWinInfoPtr) NULL || !winInfo->generic.isVisible)
953 warning ("Invalid window specified. \n\
954 The window name specified must be valid and visible.\n");
957 /* Process the size */
958 while (*(++bufPtr) == ' ')
961 if (*bufPtr != (char) 0)
964 int fixedSize = TRUE;
967 if (*bufPtr == '+' || *bufPtr == '-')
974 inputNo = atoi (bufPtr);
982 newHeight = winInfo->generic.height + inputNo;
984 ** Now change the window's height, and adjust all
985 ** other windows around it
987 if (_tuiAdjustWinHeights (winInfo,
988 newHeight) == TUI_FAILURE)
989 warning ("Invalid window height specified.\n%s",
995 warning ("Invalid window height specified.\n%s",
1001 printf_filtered (WIN_HEIGHT_USAGE);
1003 if (buf != (char *) NULL)
1007 printf_filtered (WIN_HEIGHT_USAGE);
1010 } /* _tuiSetWinHeight */
1014 ** _tui_vSetWinHeight().
1015 ** Set the height of the specified window, with va_list.
1019 _tui_vSetWinHeight (
1022 _tui_vSetWinHeight (args)
1026 char *arg = va_arg (args, char *);
1027 int fromTTY = va_arg (args, int);
1029 _tuiSetWinHeight (arg, fromTTY);
1032 } /* _tui_vSetWinHeight */
1036 ** _tuiSetWinHeight_command().
1037 ** Set the height of the specified window, with va_list.
1041 _tuiSetWinHeight_command (
1045 _tuiSetWinHeight_command (arg, fromTTY)
1050 tuiDo ((TuiOpaqueFuncPtr) _tui_vSetWinHeight, arg, fromTTY);
1053 } /* _tuiSetWinHeight_command */
1057 ** _tuiXDBsetWinHeight().
1058 ** XDB Compatibility command for setting the window height. This will
1059 ** increase or decrease the command window by the specified amount.
1063 _tuiXDBsetWinHeight (
1067 _tuiXDBsetWinHeight (arg, fromTTY)
1072 if (arg != (char *) NULL)
1074 int inputNo = atoi (arg);
1077 { /* Add 1 for the locator */
1078 int newHeight = termHeight () - (inputNo + 1);
1080 if (!_newHeightOk (winList[CMD_WIN], newHeight) ||
1081 _tuiAdjustWinHeights (winList[CMD_WIN],
1082 newHeight) == TUI_FAILURE)
1083 warning ("Invalid window height specified.\n%s",
1084 XDBWIN_HEIGHT_USAGE);
1087 warning ("Invalid window height specified.\n%s",
1088 XDBWIN_HEIGHT_USAGE);
1091 warning ("Invalid window height specified.\n%s", XDBWIN_HEIGHT_USAGE);
1094 } /* _tuiXDBsetWinHeight */
1098 ** _tui_vXDBsetWinHeight().
1099 ** Set the height of the specified window, with va_list.
1103 _tui_vXDBsetWinHeight (
1106 _tui_vXDBsetWinHeight (args)
1110 char *arg = va_arg (args, char *);
1111 int fromTTY = va_arg (args, int);
1113 _tuiXDBsetWinHeight (arg, fromTTY);
1116 } /* _tui_vXDBsetWinHeight */
1120 ** _tuiSetWinHeight_command().
1121 ** Set the height of the specified window, with va_list.
1125 _tuiXDBsetWinHeight_command (
1129 _tuiXDBsetWinHeight_command (arg, fromTTY)
1134 tuiDo ((TuiOpaqueFuncPtr) _tui_vXDBsetWinHeight, arg, fromTTY);
1137 } /* _tuiXDBsetWinHeight_command */
1141 ** _tuiAdjustWinHeights().
1142 ** Function to adjust all window heights around the primary
1146 _tuiAdjustWinHeights (
1147 TuiWinInfoPtr primaryWinInfo,
1150 _tuiAdjustWinHeights (primaryWinInfo, newHeight)
1151 TuiWinInfoPtr primaryWinInfo;
1155 TuiStatus status = TUI_FAILURE;
1157 if (_newHeightOk (primaryWinInfo, newHeight))
1159 status = TUI_SUCCESS;
1160 if (newHeight != primaryWinInfo->generic.height)
1163 TuiWinInfoPtr winInfo;
1164 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
1165 TuiLayoutType curLayout = currentLayout ();
1167 diff = (newHeight - primaryWinInfo->generic.height) * (-1);
1168 if (curLayout == SRC_COMMAND || curLayout == DISASSEM_COMMAND)
1170 TuiWinInfoPtr srcWinInfo;
1172 _makeInvisibleAndSetNewHeight (primaryWinInfo, newHeight);
1173 if (primaryWinInfo->generic.type == CMD_WIN)
1175 winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[0];
1176 srcWinInfo = winInfo;
1180 winInfo = winList[CMD_WIN];
1181 srcWinInfo = primaryWinInfo;
1183 _makeInvisibleAndSetNewHeight (winInfo,
1184 winInfo->generic.height + diff);
1185 cmdWin->generic.origin.y = locator->origin.y + 1;
1186 _makeVisibleWithNewHeight (winInfo);
1187 _makeVisibleWithNewHeight (primaryWinInfo);
1188 if (srcWinInfo->generic.contentSize <= 0)
1189 tuiEraseSourceContent (srcWinInfo, EMPTY_SOURCE_PROMPT);
1193 TuiWinInfoPtr firstWin, secondWin;
1195 if (curLayout == SRC_DISASSEM_COMMAND)
1198 secondWin = disassemWin;
1203 secondWin = (TuiWinInfoPtr) (sourceWindows ())->list[0];
1205 if (primaryWinInfo == cmdWin)
1207 ** Split the change in height accross the 1st & 2nd windows
1208 ** adjusting them as well.
1210 int firstSplitDiff = diff / 2; /* subtract the locator */
1211 int secondSplitDiff = firstSplitDiff;
1215 if (firstWin->generic.height >
1216 secondWin->generic.height)
1229 /* make sure that the minimum hieghts are honored */
1230 while ((firstWin->generic.height + firstSplitDiff) < 3)
1235 while ((secondWin->generic.height + secondSplitDiff) < 3)
1240 _makeInvisibleAndSetNewHeight (
1242 firstWin->generic.height + firstSplitDiff);
1243 secondWin->generic.origin.y = firstWin->generic.height - 1;
1244 _makeInvisibleAndSetNewHeight (
1245 secondWin, secondWin->generic.height + secondSplitDiff);
1246 cmdWin->generic.origin.y = locator->origin.y + 1;
1247 _makeInvisibleAndSetNewHeight (cmdWin, newHeight);
1251 if ((cmdWin->generic.height + diff) < 1)
1253 ** If there is no way to increase the command window
1254 ** take real estate from the 1st or 2nd window.
1256 if ((cmdWin->generic.height + diff) < 1)
1259 for (i = cmdWin->generic.height + diff;
1261 if (primaryWinInfo == firstWin)
1262 secondWin->generic.height--;
1264 firstWin->generic.height--;
1267 if (primaryWinInfo == firstWin)
1268 _makeInvisibleAndSetNewHeight (firstWin, newHeight);
1270 _makeInvisibleAndSetNewHeight (
1272 firstWin->generic.height);
1273 secondWin->generic.origin.y = firstWin->generic.height - 1;
1274 if (primaryWinInfo == secondWin)
1275 _makeInvisibleAndSetNewHeight (secondWin, newHeight);
1277 _makeInvisibleAndSetNewHeight (
1278 secondWin, secondWin->generic.height);
1279 cmdWin->generic.origin.y = locator->origin.y + 1;
1280 if ((cmdWin->generic.height + diff) < 1)
1281 _makeInvisibleAndSetNewHeight (cmdWin, 1);
1283 _makeInvisibleAndSetNewHeight (
1284 cmdWin, cmdWin->generic.height + diff);
1286 _makeVisibleWithNewHeight (cmdWin);
1287 _makeVisibleWithNewHeight (secondWin);
1288 _makeVisibleWithNewHeight (firstWin);
1289 if (firstWin->generic.contentSize <= 0)
1290 tuiEraseSourceContent (firstWin, EMPTY_SOURCE_PROMPT);
1291 if (secondWin->generic.contentSize <= 0)
1292 tuiEraseSourceContent (secondWin, EMPTY_SOURCE_PROMPT);
1298 } /* _tuiAdjustWinHeights */
1302 ** _makeInvisibleAndSetNewHeight().
1303 ** Function make the target window (and auxillary windows associated
1304 ** with the targer) invisible, and set the new height and location.
1308 _makeInvisibleAndSetNewHeight (
1309 TuiWinInfoPtr winInfo,
1312 _makeInvisibleAndSetNewHeight (winInfo, height)
1313 TuiWinInfoPtr winInfo;
1319 TuiGenWinInfoPtr genWinInfo;
1322 m_beInvisible (&winInfo->generic);
1323 winInfo->generic.height = height;
1325 winInfo->generic.viewportHeight = height - 1;
1327 winInfo->generic.viewportHeight = height;
1328 if (winInfo != cmdWin)
1329 winInfo->generic.viewportHeight--;
1331 /* Now deal with the auxillary windows associated with winInfo */
1332 switch (winInfo->generic.type)
1336 genWinInfo = winInfo->detail.sourceInfo.executionInfo;
1337 m_beInvisible (genWinInfo);
1338 genWinInfo->height = height;
1339 genWinInfo->origin.y = winInfo->generic.origin.y;
1341 genWinInfo->viewportHeight = height - 1;
1343 genWinInfo->viewportHeight = height;
1344 if (winInfo != cmdWin)
1345 genWinInfo->viewportHeight--;
1347 if (m_hasLocator (winInfo))
1349 genWinInfo = locatorWinInfoPtr ();
1350 m_beInvisible (genWinInfo);
1351 genWinInfo->origin.y = winInfo->generic.origin.y + height;
1355 /* delete all data item windows */
1356 for (i = 0; i < winInfo->generic.contentSize; i++)
1358 genWinInfo = (TuiGenWinInfoPtr) & ((TuiWinElementPtr)
1359 winInfo->generic.content[i])->whichElement.dataWindow;
1360 tuiDelwin (genWinInfo->handle);
1361 genWinInfo->handle = (WINDOW *) NULL;
1369 } /* _makeInvisibleAndSetNewHeight */
1373 ** _makeVisibleWithNewHeight().
1374 ** Function to make the windows with new heights visible.
1375 ** This means re-creating the windows' content since the window
1376 ** had to be destroyed to be made invisible.
1380 _makeVisibleWithNewHeight (
1381 TuiWinInfoPtr winInfo)
1383 _makeVisibleWithNewHeight (winInfo)
1384 TuiWinInfoPtr winInfo;
1390 m_beVisible (&winInfo->generic);
1391 checkAndDisplayHighlightIfNeeded (winInfo);
1392 switch (winInfo->generic.type)
1396 freeWinContent (winInfo->detail.sourceInfo.executionInfo);
1397 m_beVisible (winInfo->detail.sourceInfo.executionInfo);
1398 if (winInfo->generic.content != (OpaquePtr) NULL)
1400 TuiLineOrAddress lineOrAddr;
1402 if (winInfo->generic.type == SRC_WIN)
1404 winInfo->detail.sourceInfo.startLineOrAddr.lineNo;
1407 winInfo->detail.sourceInfo.startLineOrAddr.addr;
1408 freeWinContent (&winInfo->generic);
1409 tuiUpdateSourceWindow (winInfo,
1410 current_source_symtab,
1411 ((winInfo->generic.type == SRC_WIN) ?
1412 (Opaque) lineOrAddr.lineNo :
1416 else if (selected_frame != (struct frame_info *) NULL)
1419 extern int current_source_line;
1421 s = find_pc_symtab (selected_frame->pc);
1422 if (winInfo->generic.type == SRC_WIN)
1423 line = (Opaque) current_source_line;
1425 line = (Opaque) find_line_pc (s, current_source_line);
1426 tuiUpdateSourceWindow (winInfo, s, line, TRUE);
1428 if (m_hasLocator (winInfo))
1430 m_beVisible (locatorWinInfoPtr ());
1431 tuiClearLocatorDisplay ();
1432 tuiShowLocatorContent ();
1436 tuiDisplayAllData ();
1439 winInfo->detail.commandInfo.curLine = 0;
1440 winInfo->detail.commandInfo.curch = 0;
1441 wmove (winInfo->generic.handle,
1442 winInfo->detail.commandInfo.curLine,
1443 winInfo->detail.commandInfo.curch);
1450 } /* _makeVisibleWithNewHeight */
1456 TuiWinInfoPtr primaryWinInfo,
1459 _newHeightOk (primaryWinInfo, newHeight)
1460 TuiWinInfoPtr primaryWinInfo;
1464 int ok = (newHeight < termHeight ());
1468 int diff, curHeight;
1469 TuiLayoutType curLayout = currentLayout ();
1471 diff = (newHeight - primaryWinInfo->generic.height) * (-1);
1472 if (curLayout == SRC_COMMAND || curLayout == DISASSEM_COMMAND)
1474 ok = ((primaryWinInfo->generic.type == CMD_WIN &&
1475 newHeight <= (termHeight () - 4) &&
1476 newHeight >= MIN_CMD_WIN_HEIGHT) ||
1477 (primaryWinInfo->generic.type != CMD_WIN &&
1478 newHeight <= (termHeight () - 2) &&
1479 newHeight >= MIN_WIN_HEIGHT));
1481 { /* check the total height */
1482 TuiWinInfoPtr winInfo;
1484 if (primaryWinInfo == cmdWin)
1485 winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[0];
1489 (winInfo->generic.height + diff)) <= termHeight ());
1494 int curTotalHeight, totalHeight, minHeight;
1495 TuiWinInfoPtr firstWin, secondWin;
1497 if (curLayout == SRC_DISASSEM_COMMAND)
1500 secondWin = disassemWin;
1505 secondWin = (TuiWinInfoPtr) (sourceWindows ())->list[0];
1508 ** We could simply add all the heights to obtain the same result
1509 ** but below is more explicit since we subtract 1 for the
1510 ** line that the first and second windows share, and add one
1514 (firstWin->generic.height + secondWin->generic.height - 1)
1515 + cmdWin->generic.height + 1 /*locator*/ ;
1516 if (primaryWinInfo == cmdWin)
1518 /* locator included since first & second win share a line */
1519 ok = ((firstWin->generic.height +
1520 secondWin->generic.height + diff) >=
1521 (MIN_WIN_HEIGHT * 2) &&
1522 newHeight >= MIN_CMD_WIN_HEIGHT);
1525 totalHeight = newHeight + (firstWin->generic.height +
1526 secondWin->generic.height + diff);
1527 minHeight = MIN_CMD_WIN_HEIGHT;
1532 minHeight = MIN_WIN_HEIGHT;
1534 ** First see if we can increase/decrease the command
1535 ** window. And make sure that the command window is
1538 ok = ((cmdWin->generic.height + diff) > 0);
1541 ** Looks like we have to increase/decrease one of
1542 ** the other windows
1544 if (primaryWinInfo == firstWin)
1545 ok = (secondWin->generic.height + diff) >= minHeight;
1547 ok = (firstWin->generic.height + diff) >= minHeight;
1551 if (primaryWinInfo == firstWin)
1552 totalHeight = newHeight +
1553 secondWin->generic.height +
1554 cmdWin->generic.height + diff;
1556 totalHeight = newHeight +
1557 firstWin->generic.height +
1558 cmdWin->generic.height + diff;
1562 ** Now make sure that the proposed total height doesn't exceed
1563 ** the old total height.
1566 ok = (newHeight >= minHeight && totalHeight <= curTotalHeight);
1571 } /* _newHeightOk */
1575 ** _parseScrollingArgs().
1579 _parseScrollingArgs (
1581 TuiWinInfoPtr * winToScroll,
1584 _parseScrollingArgs (arg, winToScroll, numToScroll)
1586 TuiWinInfoPtr *winToScroll;
1592 *winToScroll = tuiWinWithFocus ();
1595 ** First set up the default window to scroll, in case there is no
1598 if (arg != (char *) NULL)
1602 /* process the number of lines to scroll */
1603 buf = bufPtr = tuiStrDup (arg);
1604 if (isdigit (*bufPtr))
1609 bufPtr = strchr (bufPtr, ' ');
1610 if (bufPtr != (char *) NULL)
1614 *numToScroll = atoi (numStr);
1617 else if (numToScroll)
1618 *numToScroll = atoi (numStr);
1621 /* process the window name if one is specified */
1622 if (bufPtr != (char *) NULL)
1628 while (*(++bufPtr) == ' ')
1631 if (*bufPtr != (char) 0)
1634 /* Validate the window name */
1635 for (i = 0; i < strlen (wname); i++)
1636 wname[i] = toupper (wname[i]);
1637 *winToScroll = partialWinByName (wname);
1639 if (*winToScroll == (TuiWinInfoPtr) NULL ||
1640 !(*winToScroll)->generic.isVisible)
1641 warning ("Invalid window specified. \n\
1642 The window name specified must be valid and visible.\n");
1643 else if (*winToScroll == cmdWin)
1644 *winToScroll = (TuiWinInfoPtr) (sourceWindows ())->list[0];
1650 } /* _parseScrollingArgs */