1 /* TUI window generic functions.
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. */
22 /* This module contains procedures for handling tui window functions
23 like resize, scrolling, scrolling, changing focus, etc.
25 Author: Susan B. Macchia */
31 #include "breakpoint.h"
36 #include "tuiGeneralWin.h"
38 #include "tuiSourceWin.h"
39 #include "tuiDataWin.h"
41 /*******************************
42 ** External Declarations
43 ********************************/
44 extern void init_page_info ();
46 /*******************************
48 ********************************/
49 static void _makeVisibleWithNewHeight (TuiWinInfoPtr
);
50 static void _makeInvisibleAndSetNewHeight (TuiWinInfoPtr
, int);
51 static TuiStatus
_tuiAdjustWinHeights (TuiWinInfoPtr
, int);
52 static int _newHeightOk (TuiWinInfoPtr
, int);
53 static void _tuiSetTabWidth_command (char *, int);
54 static void _tuiRefreshAll_command (char *, int);
55 static void _tuiSetWinHeight_command (char *, int);
56 static void _tuiXDBsetWinHeight_command (char *, int);
57 static void _tuiAllWindowsInfo (char *, int);
58 static void _tuiSetFocus_command (char *, int);
59 static void _tuiScrollForward_command (char *, int);
60 static void _tuiScrollBackward_command (char *, int);
61 static void _tuiScrollLeft_command (char *, int);
62 static void _tuiScrollRight_command (char *, int);
63 static void _parseScrollingArgs (char *, TuiWinInfoPtr
*, int *);
66 /***************************************
68 ***************************************/
69 #define WIN_HEIGHT_USAGE "Usage: winheight <win_name> [+ | -] <#lines>\n"
70 #define XDBWIN_HEIGHT_USAGE "Usage: w <#lines>\n"
71 #define FOCUS_USAGE "Usage: focus {<win> | next | prev}\n"
73 /***************************************
75 ***************************************/
78 ** _initialize_tuiWin().
79 ** Function to initialize gdb commands, for tui window manipulation.
82 _initialize_tuiWin (void)
86 add_com ("refresh", class_tui
, _tuiRefreshAll_command
,
87 "Refresh the terminal display.\n");
89 add_com_alias ("U", "refresh", class_tui
, 0);
90 add_com ("tabset", class_tui
, _tuiSetTabWidth_command
,
91 "Set the width (in characters) of tab stops.\n\
92 Usage: tabset <n>\n");
93 add_com ("winheight", class_tui
, _tuiSetWinHeight_command
,
94 "Set the height of a specified window.\n\
95 Usage: winheight <win_name> [+ | -] <#lines>\n\
97 src : the source window\n\
98 cmd : the command window\n\
99 asm : the disassembly window\n\
100 regs : the register display\n");
101 add_com_alias ("wh", "winheight", class_tui
, 0);
102 add_info ("win", _tuiAllWindowsInfo
,
103 "List of all displayed windows.\n");
104 add_com ("focus", class_tui
, _tuiSetFocus_command
,
105 "Set focus to named window or next/prev window.\n\
106 Usage: focus {<win> | next | prev}\n\
107 Valid Window names are:\n\
108 src : the source window\n\
109 asm : the disassembly window\n\
110 regs : the register display\n\
111 cmd : the command window\n");
112 add_com_alias ("fs", "focus", class_tui
, 0);
113 add_com ("+", class_tui
, _tuiScrollForward_command
,
114 "Scroll window forward.\nUsage: + [win] [n]\n");
115 add_com ("-", class_tui
, _tuiScrollBackward_command
,
116 "Scroll window backward.\nUsage: - [win] [n]\n");
117 add_com ("<", class_tui
, _tuiScrollLeft_command
,
118 "Scroll window forward.\nUsage: < [win] [n]\n");
119 add_com (">", class_tui
, _tuiScrollRight_command
,
120 "Scroll window backward.\nUsage: > [win] [n]\n");
122 add_com ("w", class_xdb
, _tuiXDBsetWinHeight_command
,
123 "XDB compatibility command for setting the height of a command window.\n\
124 Usage: w <#lines>\n");
128 } /* _intialize_tuiWin */
132 ** tuiClearWinFocusFrom
133 ** Clear the logical focus from winInfo
137 tuiClearWinFocusFrom (
138 TuiWinInfoPtr winInfo
)
140 tuiClearWinFocusFrom (winInfo
)
141 TuiWinInfoPtr winInfo
;
144 if (m_winPtrNotNull (winInfo
))
146 if (winInfo
->generic
.type
!= CMD_WIN
)
147 unhighlightWin (winInfo
);
148 tuiSetWinWithFocus ((TuiWinInfoPtr
) NULL
);
152 } /* tuiClearWinFocusFrom */
156 ** tuiClearWinFocus().
157 ** Clear the window that has focus.
161 tuiClearWinFocus (void)
166 tuiClearWinFocusFrom (tuiWinWithFocus ());
169 } /* tuiClearWinFocus */
174 ** Set the logical focus to winInfo
179 TuiWinInfoPtr winInfo
)
181 tuiSetWinFocusTo (winInfo
)
182 TuiWinInfoPtr winInfo
;
185 if (m_winPtrNotNull (winInfo
))
187 TuiWinInfoPtr winWithFocus
= tuiWinWithFocus ();
189 if (m_winPtrNotNull (winWithFocus
) &&
190 winWithFocus
->generic
.type
!= CMD_WIN
)
191 unhighlightWin (winWithFocus
);
192 tuiSetWinWithFocus (winInfo
);
193 if (winInfo
->generic
.type
!= CMD_WIN
)
194 highlightWin (winInfo
);
198 } /* tuiSetWinFocusTo */
210 char *newStr
= (char *) NULL
;
212 if (str
!= (char *) NULL
)
214 newStr
= (char *) xmalloc (strlen (str
) + 1);
215 strcpy (newStr
, str
);
223 ** tuiScrollForward().
228 TuiWinInfoPtr winToScroll
,
231 tuiScrollForward (winToScroll
, numToScroll
)
232 TuiWinInfoPtr winToScroll
;
236 if (winToScroll
!= cmdWin
)
238 int _numToScroll
= numToScroll
;
240 if (numToScroll
== 0)
241 _numToScroll
= winToScroll
->generic
.height
- 3;
243 ** If we are scrolling the source or disassembly window, do a
244 ** "psuedo" scroll since not all of the source is in memory,
245 ** only what is in the viewport. If winToScroll is the
246 ** command window do nothing since the term should handle it.
248 if (winToScroll
== srcWin
)
249 tuiVerticalSourceScroll (FORWARD_SCROLL
, _numToScroll
);
250 else if (winToScroll
== disassemWin
)
251 tuiVerticalDisassemScroll (FORWARD_SCROLL
, _numToScroll
);
252 else if (winToScroll
== dataWin
)
253 tuiVerticalDataScroll (FORWARD_SCROLL
, _numToScroll
);
257 } /* tuiScrollForward */
261 ** tuiScrollBackward().
266 TuiWinInfoPtr winToScroll
,
269 tuiScrollBackward (winToScroll
, numToScroll
)
270 TuiWinInfoPtr winToScroll
;
274 if (winToScroll
!= cmdWin
)
276 int _numToScroll
= numToScroll
;
278 if (numToScroll
== 0)
279 _numToScroll
= winToScroll
->generic
.height
- 3;
281 ** If we are scrolling the source or disassembly window, do a
282 ** "psuedo" scroll since not all of the source is in memory,
283 ** only what is in the viewport. If winToScroll is the
284 ** command window do nothing since the term should handle it.
286 if (winToScroll
== srcWin
)
287 tuiVerticalSourceScroll (BACKWARD_SCROLL
, _numToScroll
);
288 else if (winToScroll
== disassemWin
)
289 tuiVerticalDisassemScroll (BACKWARD_SCROLL
, _numToScroll
);
290 else if (winToScroll
== dataWin
)
291 tuiVerticalDataScroll (BACKWARD_SCROLL
, _numToScroll
);
294 } /* tuiScrollBackward */
303 TuiWinInfoPtr winToScroll
,
306 tuiScrollLeft (winToScroll
, numToScroll
)
307 TuiWinInfoPtr winToScroll
;
311 if (winToScroll
!= cmdWin
)
313 int _numToScroll
= numToScroll
;
315 if (_numToScroll
== 0)
318 ** If we are scrolling the source or disassembly window, do a
319 ** "psuedo" scroll since not all of the source is in memory,
320 ** only what is in the viewport. If winToScroll is the
321 ** command window do nothing since the term should handle it.
323 if (winToScroll
== srcWin
|| winToScroll
== disassemWin
)
324 tuiHorizontalSourceScroll (winToScroll
, LEFT_SCROLL
, _numToScroll
);
327 } /* tuiScrollLeft */
336 TuiWinInfoPtr winToScroll
,
339 tuiScrollRight (winToScroll
, numToScroll
)
340 TuiWinInfoPtr winToScroll
;
344 if (winToScroll
!= cmdWin
)
346 int _numToScroll
= numToScroll
;
348 if (_numToScroll
== 0)
351 ** If we are scrolling the source or disassembly window, do a
352 ** "psuedo" scroll since not all of the source is in memory,
353 ** only what is in the viewport. If winToScroll is the
354 ** command window do nothing since the term should handle it.
356 if (winToScroll
== srcWin
|| winToScroll
== disassemWin
)
357 tuiHorizontalSourceScroll (winToScroll
, RIGHT_SCROLL
, _numToScroll
);
360 } /* tuiScrollRight */
365 ** Scroll a window. Arguments are passed through a va_list.
376 TuiScrollDirection direction
= va_arg (args
, TuiScrollDirection
);
377 TuiWinInfoPtr winToScroll
= va_arg (args
, TuiWinInfoPtr
);
378 int numToScroll
= va_arg (args
, int);
383 tuiScrollForward (winToScroll
, numToScroll
);
385 case BACKWARD_SCROLL
:
386 tuiScrollBackward (winToScroll
, numToScroll
);
389 tuiScrollLeft (winToScroll
, numToScroll
);
392 tuiScrollRight (winToScroll
, numToScroll
);
414 refreshAll (winList
);
415 for (type
= SRC_WIN
; type
< MAX_MAJOR_WINDOWS
; type
++)
417 if (winList
[type
]->generic
.isVisible
)
423 tuiClearWin (&winList
[type
]->generic
);
424 if (winList
[type
]->detail
.sourceInfo
.hasLocator
)
425 tuiClearLocatorDisplay ();
426 tuiShowSourceContent (winList
[type
]);
427 checkAndDisplayHighlightIfNeeded (winList
[type
]);
428 tuiEraseExecInfoContent (winList
[type
]);
429 tuiUpdateExecInfo (winList
[type
]);
432 tuiRefreshDataWin ();
439 tuiClearLocatorDisplay ();
440 tuiShowLocatorContent ();
443 } /* tuiRefreshAll */
448 ** Resize all the windows based on the the terminal size. This
449 ** function gets called from within the readline sinwinch handler.
458 int heightDiff
, widthDiff
;
459 extern int screenheight
, screenwidth
; /* in readline */
461 widthDiff
= screenwidth
- termWidth ();
462 heightDiff
= screenheight
- termHeight ();
463 if (heightDiff
|| widthDiff
)
465 TuiLayoutType curLayout
= currentLayout ();
466 TuiWinInfoPtr winWithFocus
= tuiWinWithFocus ();
467 TuiWinInfoPtr firstWin
, secondWin
;
468 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
470 int i
, newHeight
, splitDiff
, cmdSplitDiff
, numWinsDisplayed
= 2;
472 /* turn keypad off while we resize */
473 if (winWithFocus
!= cmdWin
)
474 keypad (cmdWin
->generic
.handle
, FALSE
);
476 setTermHeightTo (screenheight
);
477 setTermWidthTo (screenwidth
);
478 if (curLayout
== SRC_DISASSEM_COMMAND
||
479 curLayout
== SRC_DATA_COMMAND
|| curLayout
== DISASSEM_DATA_COMMAND
)
481 splitDiff
= heightDiff
/ numWinsDisplayed
;
482 cmdSplitDiff
= splitDiff
;
483 if (heightDiff
% numWinsDisplayed
)
490 /* now adjust each window */
496 case DISASSEM_COMMAND
:
497 firstWin
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
498 firstWin
->generic
.width
+= widthDiff
;
499 locator
->width
+= widthDiff
;
500 /* check for invalid heights */
502 newHeight
= firstWin
->generic
.height
;
503 else if ((firstWin
->generic
.height
+ splitDiff
) >=
504 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
505 newHeight
= screenheight
- MIN_CMD_WIN_HEIGHT
- 1;
506 else if ((firstWin
->generic
.height
+ splitDiff
) <= 0)
507 newHeight
= MIN_WIN_HEIGHT
;
509 newHeight
= firstWin
->generic
.height
+ splitDiff
;
511 _makeInvisibleAndSetNewHeight (firstWin
, newHeight
);
512 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
513 cmdWin
->generic
.width
+= widthDiff
;
514 newHeight
= screenheight
- cmdWin
->generic
.origin
.y
;
515 _makeInvisibleAndSetNewHeight (cmdWin
, newHeight
);
516 _makeVisibleWithNewHeight (firstWin
);
517 _makeVisibleWithNewHeight (cmdWin
);
518 if (firstWin
->generic
.contentSize
<= 0)
519 tuiEraseSourceContent (firstWin
, EMPTY_SOURCE_PROMPT
);
522 if (curLayout
== SRC_DISASSEM_COMMAND
)
525 firstWin
->generic
.width
+= widthDiff
;
526 secondWin
= disassemWin
;
527 secondWin
->generic
.width
+= widthDiff
;
532 firstWin
->generic
.width
+= widthDiff
;
533 secondWin
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
534 secondWin
->generic
.width
+= widthDiff
;
536 /* Change the first window's height/width */
537 /* check for invalid heights */
539 newHeight
= firstWin
->generic
.height
;
540 else if ((firstWin
->generic
.height
+
541 secondWin
->generic
.height
+ (splitDiff
* 2)) >=
542 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
543 newHeight
= (screenheight
- MIN_CMD_WIN_HEIGHT
- 1) / 2;
544 else if ((firstWin
->generic
.height
+ splitDiff
) <= 0)
545 newHeight
= MIN_WIN_HEIGHT
;
547 newHeight
= firstWin
->generic
.height
+ splitDiff
;
548 _makeInvisibleAndSetNewHeight (firstWin
, newHeight
);
550 if (firstWin
== dataWin
&& widthDiff
!= 0)
551 firstWin
->detail
.dataDisplayInfo
.regsColumnCount
=
552 tuiCalculateRegsColumnCount (
553 firstWin
->detail
.dataDisplayInfo
.regsDisplayType
);
554 locator
->width
+= widthDiff
;
556 /* Change the second window's height/width */
557 /* check for invalid heights */
559 newHeight
= secondWin
->generic
.height
;
560 else if ((firstWin
->generic
.height
+
561 secondWin
->generic
.height
+ (splitDiff
* 2)) >=
562 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
564 newHeight
= screenheight
- MIN_CMD_WIN_HEIGHT
- 1;
566 newHeight
= (newHeight
/ 2) + 1;
570 else if ((secondWin
->generic
.height
+ splitDiff
) <= 0)
571 newHeight
= MIN_WIN_HEIGHT
;
573 newHeight
= secondWin
->generic
.height
+ splitDiff
;
574 secondWin
->generic
.origin
.y
= firstWin
->generic
.height
- 1;
575 _makeInvisibleAndSetNewHeight (secondWin
, newHeight
);
577 /* Change the command window's height/width */
578 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
579 _makeInvisibleAndSetNewHeight (
580 cmdWin
, cmdWin
->generic
.height
+ cmdSplitDiff
);
581 _makeVisibleWithNewHeight (firstWin
);
582 _makeVisibleWithNewHeight (secondWin
);
583 _makeVisibleWithNewHeight (cmdWin
);
584 if (firstWin
->generic
.contentSize
<= 0)
585 tuiEraseSourceContent (firstWin
, EMPTY_SOURCE_PROMPT
);
586 if (secondWin
->generic
.contentSize
<= 0)
587 tuiEraseSourceContent (secondWin
, EMPTY_SOURCE_PROMPT
);
591 ** Now remove all invisible windows, and their content so that they get
592 ** created again when called for with the new size
594 for (winType
= SRC_WIN
; (winType
< MAX_MAJOR_WINDOWS
); winType
++)
596 if (winType
!= CMD_WIN
&& m_winPtrNotNull (winList
[winType
]) &&
597 !winList
[winType
]->generic
.isVisible
)
599 freeWindow (winList
[winType
]);
600 winList
[winType
] = (TuiWinInfoPtr
) NULL
;
603 tuiSetWinResizedTo (TRUE
);
604 /* turn keypad back on, unless focus is in the command window */
605 if (winWithFocus
!= cmdWin
)
606 keypad (cmdWin
->generic
.handle
, TRUE
);
613 ** tuiSigwinchHandler()
614 ** SIGWINCH signal handler for the tui. This signal handler is
615 ** always called, even when the readline package clears signals
616 ** because it is set as the old_sigwinch() (TUI only)
623 tuiSigwinchHandler (signal
)
628 ** Say that a resize was done so that the readline can do it
629 ** later when appropriate.
631 tuiSetWinResizedTo (TRUE
);
634 } /* tuiSigwinchHandler */
638 /*************************
639 ** STATIC LOCAL FUNCTIONS
640 **************************/
644 ** _tuiScrollForward_command().
648 _tuiScrollForward_command (
652 _tuiScrollForward_command (arg
, fromTTY
)
658 TuiWinInfoPtr winToScroll
;
660 if (arg
== (char *) NULL
)
661 _parseScrollingArgs (arg
, &winToScroll
, (int *) NULL
);
663 _parseScrollingArgs (arg
, &winToScroll
, &numToScroll
);
664 tuiDo ((TuiOpaqueFuncPtr
) tui_vScroll
,
670 } /* _tuiScrollForward_command */
674 ** _tuiScrollBackward_command().
678 _tuiScrollBackward_command (
682 _tuiScrollBackward_command (arg
, fromTTY
)
688 TuiWinInfoPtr winToScroll
;
690 if (arg
== (char *) NULL
)
691 _parseScrollingArgs (arg
, &winToScroll
, (int *) NULL
);
693 _parseScrollingArgs (arg
, &winToScroll
, &numToScroll
);
694 tuiDo ((TuiOpaqueFuncPtr
) tui_vScroll
,
700 } /* _tuiScrollBackward_command */
704 ** _tuiScrollLeft_command().
708 _tuiScrollLeft_command (
712 _tuiScrollLeft_command (arg
, fromTTY
)
718 TuiWinInfoPtr winToScroll
;
720 _parseScrollingArgs (arg
, &winToScroll
, &numToScroll
);
721 tuiDo ((TuiOpaqueFuncPtr
) tui_vScroll
,
727 } /* _tuiScrollLeft_command */
731 ** _tuiScrollRight_command().
735 _tuiScrollRight_command (
739 _tuiScrollRight_command (arg
, fromTTY
)
745 TuiWinInfoPtr winToScroll
;
747 _parseScrollingArgs (arg
, &winToScroll
, &numToScroll
);
748 tuiDo ((TuiOpaqueFuncPtr
) tui_vScroll
,
754 } /* _tuiScrollRight_command */
759 ** Set focus to the window named by 'arg'
767 _tuiSetFocus (arg
, fromTTY
)
772 if (arg
!= (char *) NULL
)
774 char *bufPtr
= (char *) tuiStrDup (arg
);
776 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
778 for (i
= 0; (i
< strlen (bufPtr
)); i
++)
779 bufPtr
[i
] = toupper (arg
[i
]);
781 if (subsetCompare (bufPtr
, "NEXT"))
782 winInfo
= tuiNextWin (tuiWinWithFocus ());
783 else if (subsetCompare (bufPtr
, "PREV"))
784 winInfo
= tuiPrevWin (tuiWinWithFocus ());
786 winInfo
= partialWinByName (bufPtr
);
788 if (winInfo
== (TuiWinInfoPtr
) NULL
|| !winInfo
->generic
.isVisible
)
789 warning ("Invalid window specified. \n\
790 The window name specified must be valid and visible.\n");
793 tuiSetWinFocusTo (winInfo
);
794 keypad (cmdWin
->generic
.handle
, (winInfo
!= cmdWin
));
797 if (dataWin
->generic
.isVisible
)
798 tuiRefreshDataWin ();
800 printf_filtered ("Focus set to %s window.\n",
801 winName ((TuiGenWinInfoPtr
) tuiWinWithFocus ()));
804 warning ("Incorrect Number of Arguments.\n%s", FOCUS_USAGE
);
818 _tui_vSetFocus (args
)
822 char *arg
= va_arg (args
, char *);
823 int fromTTY
= va_arg (args
, int);
825 _tuiSetFocus (arg
, fromTTY
);
828 } /* tui_vSetFocus */
832 ** _tuiSetFocus_command()
836 _tuiSetFocus_command (
840 _tuiSetFocus_command (arg
, fromTTY
)
845 tuiDo ((TuiOpaqueFuncPtr
) _tui_vSetFocus
, arg
, fromTTY
);
852 ** _tuiAllWindowsInfo().
860 _tuiAllWindowsInfo (arg
, fromTTY
)
866 TuiWinInfoPtr winWithFocus
= tuiWinWithFocus ();
868 for (type
= SRC_WIN
; (type
< MAX_MAJOR_WINDOWS
); type
++)
869 if (winList
[type
]->generic
.isVisible
)
871 if (winWithFocus
== winList
[type
])
872 printf_filtered (" %s\t(%d lines) <has focus>\n",
873 winName (&winList
[type
]->generic
),
874 winList
[type
]->generic
.height
);
876 printf_filtered (" %s\t(%d lines)\n",
877 winName (&winList
[type
]->generic
),
878 winList
[type
]->generic
.height
);
882 } /* _tuiAllWindowsInfo */
886 ** _tuiRefreshAll_command().
890 _tuiRefreshAll_command (
894 _tuiRefreshAll_command (arg
, fromTTY
)
899 tuiDo ((TuiOpaqueFuncPtr
) tuiRefreshAll
);
904 ** _tuiSetWinTabWidth_command().
905 ** Set the height of the specified window.
909 _tuiSetTabWidth_command (
913 _tuiSetTabWidth_command (arg
, fromTTY
)
918 if (arg
!= (char *) NULL
)
924 tuiSetDefaultTabLen (ts
);
926 warning ("Tab widths greater than 0 must be specified.\n");
930 } /* _tuiSetTabWidth_command */
934 ** _tuiSetWinHeight().
935 ** Set the height of the specified window.
943 _tuiSetWinHeight (arg
, fromTTY
)
948 if (arg
!= (char *) NULL
)
950 char *buf
= tuiStrDup (arg
);
952 char *wname
= (char *) NULL
;
954 TuiWinInfoPtr winInfo
;
957 bufPtr
= strchr (bufPtr
, ' ');
958 if (bufPtr
!= (char *) NULL
)
963 ** Validate the window name
965 for (i
= 0; i
< strlen (wname
); i
++)
966 wname
[i
] = toupper (wname
[i
]);
967 winInfo
= partialWinByName (wname
);
969 if (winInfo
== (TuiWinInfoPtr
) NULL
|| !winInfo
->generic
.isVisible
)
970 warning ("Invalid window specified. \n\
971 The window name specified must be valid and visible.\n");
974 /* Process the size */
975 while (*(++bufPtr
) == ' ')
978 if (*bufPtr
!= (char) 0)
981 int fixedSize
= TRUE
;
984 if (*bufPtr
== '+' || *bufPtr
== '-')
991 inputNo
= atoi (bufPtr
);
999 newHeight
= winInfo
->generic
.height
+ inputNo
;
1001 ** Now change the window's height, and adjust all
1002 ** other windows around it
1004 if (_tuiAdjustWinHeights (winInfo
,
1005 newHeight
) == TUI_FAILURE
)
1006 warning ("Invalid window height specified.\n%s",
1012 warning ("Invalid window height specified.\n%s",
1018 printf_filtered (WIN_HEIGHT_USAGE
);
1020 if (buf
!= (char *) NULL
)
1024 printf_filtered (WIN_HEIGHT_USAGE
);
1027 } /* _tuiSetWinHeight */
1031 ** _tui_vSetWinHeight().
1032 ** Set the height of the specified window, with va_list.
1036 _tui_vSetWinHeight (
1039 _tui_vSetWinHeight (args
)
1043 char *arg
= va_arg (args
, char *);
1044 int fromTTY
= va_arg (args
, int);
1046 _tuiSetWinHeight (arg
, fromTTY
);
1049 } /* _tui_vSetWinHeight */
1053 ** _tuiSetWinHeight_command().
1054 ** Set the height of the specified window, with va_list.
1058 _tuiSetWinHeight_command (
1062 _tuiSetWinHeight_command (arg
, fromTTY
)
1067 tuiDo ((TuiOpaqueFuncPtr
) _tui_vSetWinHeight
, arg
, fromTTY
);
1070 } /* _tuiSetWinHeight_command */
1074 ** _tuiXDBsetWinHeight().
1075 ** XDB Compatibility command for setting the window height. This will
1076 ** increase or decrease the command window by the specified amount.
1080 _tuiXDBsetWinHeight (
1084 _tuiXDBsetWinHeight (arg
, fromTTY
)
1089 if (arg
!= (char *) NULL
)
1091 int inputNo
= atoi (arg
);
1094 { /* Add 1 for the locator */
1095 int newHeight
= termHeight () - (inputNo
+ 1);
1097 if (!_newHeightOk (winList
[CMD_WIN
], newHeight
) ||
1098 _tuiAdjustWinHeights (winList
[CMD_WIN
],
1099 newHeight
) == TUI_FAILURE
)
1100 warning ("Invalid window height specified.\n%s",
1101 XDBWIN_HEIGHT_USAGE
);
1104 warning ("Invalid window height specified.\n%s",
1105 XDBWIN_HEIGHT_USAGE
);
1108 warning ("Invalid window height specified.\n%s", XDBWIN_HEIGHT_USAGE
);
1111 } /* _tuiXDBsetWinHeight */
1115 ** _tui_vXDBsetWinHeight().
1116 ** Set the height of the specified window, with va_list.
1120 _tui_vXDBsetWinHeight (
1123 _tui_vXDBsetWinHeight (args
)
1127 char *arg
= va_arg (args
, char *);
1128 int fromTTY
= va_arg (args
, int);
1130 _tuiXDBsetWinHeight (arg
, fromTTY
);
1133 } /* _tui_vXDBsetWinHeight */
1137 ** _tuiSetWinHeight_command().
1138 ** Set the height of the specified window, with va_list.
1142 _tuiXDBsetWinHeight_command (
1146 _tuiXDBsetWinHeight_command (arg
, fromTTY
)
1151 tuiDo ((TuiOpaqueFuncPtr
) _tui_vXDBsetWinHeight
, arg
, fromTTY
);
1154 } /* _tuiXDBsetWinHeight_command */
1158 ** _tuiAdjustWinHeights().
1159 ** Function to adjust all window heights around the primary
1163 _tuiAdjustWinHeights (
1164 TuiWinInfoPtr primaryWinInfo
,
1167 _tuiAdjustWinHeights (primaryWinInfo
, newHeight
)
1168 TuiWinInfoPtr primaryWinInfo
;
1172 TuiStatus status
= TUI_FAILURE
;
1174 if (_newHeightOk (primaryWinInfo
, newHeight
))
1176 status
= TUI_SUCCESS
;
1177 if (newHeight
!= primaryWinInfo
->generic
.height
)
1180 TuiWinInfoPtr winInfo
;
1181 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
1182 TuiLayoutType curLayout
= currentLayout ();
1184 diff
= (newHeight
- primaryWinInfo
->generic
.height
) * (-1);
1185 if (curLayout
== SRC_COMMAND
|| curLayout
== DISASSEM_COMMAND
)
1187 TuiWinInfoPtr srcWinInfo
;
1189 _makeInvisibleAndSetNewHeight (primaryWinInfo
, newHeight
);
1190 if (primaryWinInfo
->generic
.type
== CMD_WIN
)
1192 winInfo
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1193 srcWinInfo
= winInfo
;
1197 winInfo
= winList
[CMD_WIN
];
1198 srcWinInfo
= primaryWinInfo
;
1200 _makeInvisibleAndSetNewHeight (winInfo
,
1201 winInfo
->generic
.height
+ diff
);
1202 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1203 _makeVisibleWithNewHeight (winInfo
);
1204 _makeVisibleWithNewHeight (primaryWinInfo
);
1205 if (srcWinInfo
->generic
.contentSize
<= 0)
1206 tuiEraseSourceContent (srcWinInfo
, EMPTY_SOURCE_PROMPT
);
1210 TuiWinInfoPtr firstWin
, secondWin
;
1212 if (curLayout
== SRC_DISASSEM_COMMAND
)
1215 secondWin
= disassemWin
;
1220 secondWin
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1222 if (primaryWinInfo
== cmdWin
)
1224 ** Split the change in height accross the 1st & 2nd windows
1225 ** adjusting them as well.
1227 int firstSplitDiff
= diff
/ 2; /* subtract the locator */
1228 int secondSplitDiff
= firstSplitDiff
;
1232 if (firstWin
->generic
.height
>
1233 secondWin
->generic
.height
)
1246 /* make sure that the minimum hieghts are honored */
1247 while ((firstWin
->generic
.height
+ firstSplitDiff
) < 3)
1252 while ((secondWin
->generic
.height
+ secondSplitDiff
) < 3)
1257 _makeInvisibleAndSetNewHeight (
1259 firstWin
->generic
.height
+ firstSplitDiff
);
1260 secondWin
->generic
.origin
.y
= firstWin
->generic
.height
- 1;
1261 _makeInvisibleAndSetNewHeight (
1262 secondWin
, secondWin
->generic
.height
+ secondSplitDiff
);
1263 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1264 _makeInvisibleAndSetNewHeight (cmdWin
, newHeight
);
1268 if ((cmdWin
->generic
.height
+ diff
) < 1)
1270 ** If there is no way to increase the command window
1271 ** take real estate from the 1st or 2nd window.
1273 if ((cmdWin
->generic
.height
+ diff
) < 1)
1276 for (i
= cmdWin
->generic
.height
+ diff
;
1278 if (primaryWinInfo
== firstWin
)
1279 secondWin
->generic
.height
--;
1281 firstWin
->generic
.height
--;
1284 if (primaryWinInfo
== firstWin
)
1285 _makeInvisibleAndSetNewHeight (firstWin
, newHeight
);
1287 _makeInvisibleAndSetNewHeight (
1289 firstWin
->generic
.height
);
1290 secondWin
->generic
.origin
.y
= firstWin
->generic
.height
- 1;
1291 if (primaryWinInfo
== secondWin
)
1292 _makeInvisibleAndSetNewHeight (secondWin
, newHeight
);
1294 _makeInvisibleAndSetNewHeight (
1295 secondWin
, secondWin
->generic
.height
);
1296 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1297 if ((cmdWin
->generic
.height
+ diff
) < 1)
1298 _makeInvisibleAndSetNewHeight (cmdWin
, 1);
1300 _makeInvisibleAndSetNewHeight (
1301 cmdWin
, cmdWin
->generic
.height
+ diff
);
1303 _makeVisibleWithNewHeight (cmdWin
);
1304 _makeVisibleWithNewHeight (secondWin
);
1305 _makeVisibleWithNewHeight (firstWin
);
1306 if (firstWin
->generic
.contentSize
<= 0)
1307 tuiEraseSourceContent (firstWin
, EMPTY_SOURCE_PROMPT
);
1308 if (secondWin
->generic
.contentSize
<= 0)
1309 tuiEraseSourceContent (secondWin
, EMPTY_SOURCE_PROMPT
);
1315 } /* _tuiAdjustWinHeights */
1319 ** _makeInvisibleAndSetNewHeight().
1320 ** Function make the target window (and auxillary windows associated
1321 ** with the targer) invisible, and set the new height and location.
1325 _makeInvisibleAndSetNewHeight (
1326 TuiWinInfoPtr winInfo
,
1329 _makeInvisibleAndSetNewHeight (winInfo
, height
)
1330 TuiWinInfoPtr winInfo
;
1336 TuiGenWinInfoPtr genWinInfo
;
1339 m_beInvisible (&winInfo
->generic
);
1340 winInfo
->generic
.height
= height
;
1342 winInfo
->generic
.viewportHeight
= height
- 1;
1344 winInfo
->generic
.viewportHeight
= height
;
1345 if (winInfo
!= cmdWin
)
1346 winInfo
->generic
.viewportHeight
--;
1348 /* Now deal with the auxillary windows associated with winInfo */
1349 switch (winInfo
->generic
.type
)
1353 genWinInfo
= winInfo
->detail
.sourceInfo
.executionInfo
;
1354 m_beInvisible (genWinInfo
);
1355 genWinInfo
->height
= height
;
1356 genWinInfo
->origin
.y
= winInfo
->generic
.origin
.y
;
1358 genWinInfo
->viewportHeight
= height
- 1;
1360 genWinInfo
->viewportHeight
= height
;
1361 if (winInfo
!= cmdWin
)
1362 genWinInfo
->viewportHeight
--;
1364 if (m_hasLocator (winInfo
))
1366 genWinInfo
= locatorWinInfoPtr ();
1367 m_beInvisible (genWinInfo
);
1368 genWinInfo
->origin
.y
= winInfo
->generic
.origin
.y
+ height
;
1372 /* delete all data item windows */
1373 for (i
= 0; i
< winInfo
->generic
.contentSize
; i
++)
1375 genWinInfo
= (TuiGenWinInfoPtr
) & ((TuiWinElementPtr
)
1376 winInfo
->generic
.content
[i
])->whichElement
.dataWindow
;
1377 tuiDelwin (genWinInfo
->handle
);
1378 genWinInfo
->handle
= (WINDOW
*) NULL
;
1386 } /* _makeInvisibleAndSetNewHeight */
1390 ** _makeVisibleWithNewHeight().
1391 ** Function to make the windows with new heights visible.
1392 ** This means re-creating the windows' content since the window
1393 ** had to be destroyed to be made invisible.
1397 _makeVisibleWithNewHeight (
1398 TuiWinInfoPtr winInfo
)
1400 _makeVisibleWithNewHeight (winInfo
)
1401 TuiWinInfoPtr winInfo
;
1407 m_beVisible (&winInfo
->generic
);
1408 checkAndDisplayHighlightIfNeeded (winInfo
);
1409 switch (winInfo
->generic
.type
)
1413 freeWinContent (winInfo
->detail
.sourceInfo
.executionInfo
);
1414 m_beVisible (winInfo
->detail
.sourceInfo
.executionInfo
);
1415 if (winInfo
->generic
.content
!= (OpaquePtr
) NULL
)
1417 TuiLineOrAddress lineOrAddr
;
1419 if (winInfo
->generic
.type
== SRC_WIN
)
1421 winInfo
->detail
.sourceInfo
.startLineOrAddr
.lineNo
;
1424 winInfo
->detail
.sourceInfo
.startLineOrAddr
.addr
;
1425 freeWinContent (&winInfo
->generic
);
1426 tuiUpdateSourceWindow (winInfo
,
1427 current_source_symtab
,
1428 ((winInfo
->generic
.type
== SRC_WIN
) ?
1429 (Opaque
) lineOrAddr
.lineNo
:
1433 else if (selected_frame
!= (struct frame_info
*) NULL
)
1436 extern int current_source_line
;
1438 s
= find_pc_symtab (selected_frame
->pc
);
1439 if (winInfo
->generic
.type
== SRC_WIN
)
1440 line
= (Opaque
) current_source_line
;
1442 line
= (Opaque
) find_line_pc (s
, current_source_line
);
1443 tuiUpdateSourceWindow (winInfo
, s
, line
, TRUE
);
1445 if (m_hasLocator (winInfo
))
1447 m_beVisible (locatorWinInfoPtr ());
1448 tuiClearLocatorDisplay ();
1449 tuiShowLocatorContent ();
1453 tuiDisplayAllData ();
1456 winInfo
->detail
.commandInfo
.curLine
= 0;
1457 winInfo
->detail
.commandInfo
.curch
= 0;
1458 wmove (winInfo
->generic
.handle
,
1459 winInfo
->detail
.commandInfo
.curLine
,
1460 winInfo
->detail
.commandInfo
.curch
);
1467 } /* _makeVisibleWithNewHeight */
1473 TuiWinInfoPtr primaryWinInfo
,
1476 _newHeightOk (primaryWinInfo
, newHeight
)
1477 TuiWinInfoPtr primaryWinInfo
;
1481 int ok
= (newHeight
< termHeight ());
1485 int diff
, curHeight
;
1486 TuiLayoutType curLayout
= currentLayout ();
1488 diff
= (newHeight
- primaryWinInfo
->generic
.height
) * (-1);
1489 if (curLayout
== SRC_COMMAND
|| curLayout
== DISASSEM_COMMAND
)
1491 ok
= ((primaryWinInfo
->generic
.type
== CMD_WIN
&&
1492 newHeight
<= (termHeight () - 4) &&
1493 newHeight
>= MIN_CMD_WIN_HEIGHT
) ||
1494 (primaryWinInfo
->generic
.type
!= CMD_WIN
&&
1495 newHeight
<= (termHeight () - 2) &&
1496 newHeight
>= MIN_WIN_HEIGHT
));
1498 { /* check the total height */
1499 TuiWinInfoPtr winInfo
;
1501 if (primaryWinInfo
== cmdWin
)
1502 winInfo
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1506 (winInfo
->generic
.height
+ diff
)) <= termHeight ());
1511 int curTotalHeight
, totalHeight
, minHeight
;
1512 TuiWinInfoPtr firstWin
, secondWin
;
1514 if (curLayout
== SRC_DISASSEM_COMMAND
)
1517 secondWin
= disassemWin
;
1522 secondWin
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1525 ** We could simply add all the heights to obtain the same result
1526 ** but below is more explicit since we subtract 1 for the
1527 ** line that the first and second windows share, and add one
1531 (firstWin
->generic
.height
+ secondWin
->generic
.height
- 1)
1532 + cmdWin
->generic
.height
+ 1 /*locator */ ;
1533 if (primaryWinInfo
== cmdWin
)
1535 /* locator included since first & second win share a line */
1536 ok
= ((firstWin
->generic
.height
+
1537 secondWin
->generic
.height
+ diff
) >=
1538 (MIN_WIN_HEIGHT
* 2) &&
1539 newHeight
>= MIN_CMD_WIN_HEIGHT
);
1542 totalHeight
= newHeight
+ (firstWin
->generic
.height
+
1543 secondWin
->generic
.height
+ diff
);
1544 minHeight
= MIN_CMD_WIN_HEIGHT
;
1549 minHeight
= MIN_WIN_HEIGHT
;
1551 ** First see if we can increase/decrease the command
1552 ** window. And make sure that the command window is
1555 ok
= ((cmdWin
->generic
.height
+ diff
) > 0);
1558 ** Looks like we have to increase/decrease one of
1559 ** the other windows
1561 if (primaryWinInfo
== firstWin
)
1562 ok
= (secondWin
->generic
.height
+ diff
) >= minHeight
;
1564 ok
= (firstWin
->generic
.height
+ diff
) >= minHeight
;
1568 if (primaryWinInfo
== firstWin
)
1569 totalHeight
= newHeight
+
1570 secondWin
->generic
.height
+
1571 cmdWin
->generic
.height
+ diff
;
1573 totalHeight
= newHeight
+
1574 firstWin
->generic
.height
+
1575 cmdWin
->generic
.height
+ diff
;
1579 ** Now make sure that the proposed total height doesn't exceed
1580 ** the old total height.
1583 ok
= (newHeight
>= minHeight
&& totalHeight
<= curTotalHeight
);
1588 } /* _newHeightOk */
1592 ** _parseScrollingArgs().
1596 _parseScrollingArgs (
1598 TuiWinInfoPtr
* winToScroll
,
1601 _parseScrollingArgs (arg
, winToScroll
, numToScroll
)
1603 TuiWinInfoPtr
*winToScroll
;
1609 *winToScroll
= tuiWinWithFocus ();
1612 ** First set up the default window to scroll, in case there is no
1615 if (arg
!= (char *) NULL
)
1619 /* process the number of lines to scroll */
1620 buf
= bufPtr
= tuiStrDup (arg
);
1621 if (isdigit (*bufPtr
))
1626 bufPtr
= strchr (bufPtr
, ' ');
1627 if (bufPtr
!= (char *) NULL
)
1631 *numToScroll
= atoi (numStr
);
1634 else if (numToScroll
)
1635 *numToScroll
= atoi (numStr
);
1638 /* process the window name if one is specified */
1639 if (bufPtr
!= (char *) NULL
)
1645 while (*(++bufPtr
) == ' ')
1648 if (*bufPtr
!= (char) 0)
1651 /* Validate the window name */
1652 for (i
= 0; i
< strlen (wname
); i
++)
1653 wname
[i
] = toupper (wname
[i
]);
1654 *winToScroll
= partialWinByName (wname
);
1656 if (*winToScroll
== (TuiWinInfoPtr
) NULL
||
1657 !(*winToScroll
)->generic
.isVisible
)
1658 warning ("Invalid window specified. \n\
1659 The window name specified must be valid and visible.\n");
1660 else if (*winToScroll
== cmdWin
)
1661 *winToScroll
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1667 } /* _parseScrollingArgs */