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 */
32 #include "breakpoint.h"
34 #include "cli/cli-cmds.h"
38 #include "tuiGeneralWin.h"
41 #include "tuiDisassem.h"
42 #include "tuiSource.h"
43 #include "tuiSourceWin.h"
44 #include "tuiDataWin.h"
46 /*******************************
47 ** External Declarations
48 ********************************/
49 extern void init_page_info ();
51 /*******************************
53 ********************************/
54 static void _makeVisibleWithNewHeight (TuiWinInfoPtr
);
55 static void _makeInvisibleAndSetNewHeight (TuiWinInfoPtr
, int);
56 static TuiStatus
_tuiAdjustWinHeights (TuiWinInfoPtr
, int);
57 static int _newHeightOk (TuiWinInfoPtr
, int);
58 static void _tuiSetTabWidth_command (char *, int);
59 static void _tuiRefreshAll_command (char *, int);
60 static void _tuiSetWinHeight_command (char *, int);
61 static void _tuiXDBsetWinHeight_command (char *, int);
62 static void _tuiAllWindowsInfo (char *, int);
63 static void _tuiSetFocus_command (char *, int);
64 static void _tuiScrollForward_command (char *, int);
65 static void _tuiScrollBackward_command (char *, int);
66 static void _tuiScrollLeft_command (char *, int);
67 static void _tuiScrollRight_command (char *, int);
68 static void _parseScrollingArgs (char *, TuiWinInfoPtr
*, int *);
71 /***************************************
73 ***************************************/
74 #define WIN_HEIGHT_USAGE "Usage: winheight <win_name> [+ | -] <#lines>\n"
75 #define XDBWIN_HEIGHT_USAGE "Usage: w <#lines>\n"
76 #define FOCUS_USAGE "Usage: focus {<win> | next | prev}\n"
78 /***************************************
80 ***************************************/
82 /* Possible values for tui-border-kind variable. */
83 static const char *tui_border_kind_enums
[] = {
90 /* Possible values for tui-border-mode and tui-active-border-mode. */
91 static const char *tui_border_mode_enums
[] = {
108 /* Translation table for border-mode variables.
109 The list of values must be terminated by a NULL.
110 After the NULL value, an entry defines the default. */
111 struct tui_translate tui_border_mode_translate
[] = {
112 { "normal", A_NORMAL
},
113 { "standout", A_STANDOUT
},
114 { "reverse", A_REVERSE
},
116 { "half-standout", A_DIM
| A_STANDOUT
},
118 { "bold-standout", A_BOLD
| A_STANDOUT
},
120 { "normal", A_NORMAL
}
123 /* Translation tables for border-kind, one for each border
124 character (see wborder, border curses operations).
125 -1 is used to indicate the ACS because ACS characters
126 are determined at run time by curses (depends on terminal). */
127 struct tui_translate tui_border_kind_translate_vline
[] = {
135 struct tui_translate tui_border_kind_translate_hline
[] = {
143 struct tui_translate tui_border_kind_translate_ulcorner
[] = {
151 struct tui_translate tui_border_kind_translate_urcorner
[] = {
159 struct tui_translate tui_border_kind_translate_llcorner
[] = {
167 struct tui_translate tui_border_kind_translate_lrcorner
[] = {
176 /* Tui configuration variables controlled with set/show command. */
177 const char *tui_active_border_mode
= "bold-standout";
178 const char *tui_border_mode
= "normal";
179 const char *tui_border_kind
= "acs";
181 /* Tui internal configuration variables. These variables are
182 updated by tui_update_variables to reflect the tui configuration
184 chtype tui_border_vline
;
185 chtype tui_border_hline
;
186 chtype tui_border_ulcorner
;
187 chtype tui_border_urcorner
;
188 chtype tui_border_llcorner
;
189 chtype tui_border_lrcorner
;
191 int tui_border_attrs
;
192 int tui_active_border_attrs
;
194 /* Identify the item in the translation table.
195 When the item is not recognized, use the default entry. */
196 static struct tui_translate
*
197 translate (const char *name
, struct tui_translate
*table
)
201 if (name
&& strcmp (table
->name
, name
) == 0)
206 /* Not found, return default entry. */
211 /* Update the tui internal configuration according to gdb settings.
212 Returns 1 if the configuration has changed and the screen should
215 tui_update_variables ()
218 struct tui_translate
*entry
;
220 entry
= translate (tui_border_mode
, tui_border_mode_translate
);
221 if (tui_border_attrs
!= entry
->value
)
223 tui_border_attrs
= entry
->value
;
226 entry
= translate (tui_active_border_mode
, tui_border_mode_translate
);
227 if (tui_active_border_attrs
!= entry
->value
)
229 tui_active_border_attrs
= entry
->value
;
233 /* If one corner changes, all characters are changed.
234 Only check the first one. The ACS characters are determined at
235 run time by curses terminal management. */
236 entry
= translate (tui_border_kind
, tui_border_kind_translate_lrcorner
);
237 if (tui_border_lrcorner
!= (chtype
) entry
->value
)
239 tui_border_lrcorner
= (entry
->value
< 0) ? ACS_LRCORNER
: entry
->value
;
242 entry
= translate (tui_border_kind
, tui_border_kind_translate_llcorner
);
243 tui_border_llcorner
= (entry
->value
< 0) ? ACS_LLCORNER
: entry
->value
;
245 entry
= translate (tui_border_kind
, tui_border_kind_translate_ulcorner
);
246 tui_border_ulcorner
= (entry
->value
< 0) ? ACS_ULCORNER
: entry
->value
;
248 entry
= translate (tui_border_kind
, tui_border_kind_translate_urcorner
);
249 tui_border_urcorner
= (entry
->value
< 0) ? ACS_URCORNER
: entry
->value
;
251 entry
= translate (tui_border_kind
, tui_border_kind_translate_hline
);
252 tui_border_hline
= (entry
->value
< 0) ? ACS_HLINE
: entry
->value
;
254 entry
= translate (tui_border_kind
, tui_border_kind_translate_vline
);
255 tui_border_vline
= (entry
->value
< 0) ? ACS_VLINE
: entry
->value
;
262 ** _initialize_tuiWin().
263 ** Function to initialize gdb commands, for tui window manipulation.
266 _initialize_tuiWin (void)
268 struct cmd_list_element
*c
;
270 /* Define the classes of commands.
271 They will appear in the help list in the reverse of this order. */
273 add_cmd ("tui", class_tui
, NO_FUNCTION
,
274 "Text User Interface commands.",
277 add_com ("refresh", class_tui
, _tuiRefreshAll_command
,
278 "Refresh the terminal display.\n");
280 add_com_alias ("U", "refresh", class_tui
, 0);
281 add_com ("tabset", class_tui
, _tuiSetTabWidth_command
,
282 "Set the width (in characters) of tab stops.\n\
283 Usage: tabset <n>\n");
284 add_com ("winheight", class_tui
, _tuiSetWinHeight_command
,
285 "Set the height of a specified window.\n\
286 Usage: winheight <win_name> [+ | -] <#lines>\n\
288 src : the source window\n\
289 cmd : the command window\n\
290 asm : the disassembly window\n\
291 regs : the register display\n");
292 add_com_alias ("wh", "winheight", class_tui
, 0);
293 add_info ("win", _tuiAllWindowsInfo
,
294 "List of all displayed windows.\n");
295 add_com ("focus", class_tui
, _tuiSetFocus_command
,
296 "Set focus to named window or next/prev window.\n\
297 Usage: focus {<win> | next | prev}\n\
298 Valid Window names are:\n\
299 src : the source window\n\
300 asm : the disassembly window\n\
301 regs : the register display\n\
302 cmd : the command window\n");
303 add_com_alias ("fs", "focus", class_tui
, 0);
304 add_com ("+", class_tui
, _tuiScrollForward_command
,
305 "Scroll window forward.\nUsage: + [win] [n]\n");
306 add_com ("-", class_tui
, _tuiScrollBackward_command
,
307 "Scroll window backward.\nUsage: - [win] [n]\n");
308 add_com ("<", class_tui
, _tuiScrollLeft_command
,
309 "Scroll window forward.\nUsage: < [win] [n]\n");
310 add_com (">", class_tui
, _tuiScrollRight_command
,
311 "Scroll window backward.\nUsage: > [win] [n]\n");
313 add_com ("w", class_xdb
, _tuiXDBsetWinHeight_command
,
314 "XDB compatibility command for setting the height of a command window.\n\
315 Usage: w <#lines>\n");
317 /* Define the tui control variables. */
319 ("tui-border-kind", class_tui
,
320 tui_border_kind_enums
, (char*) &tui_border_kind
,
321 "Set the kind of border for TUI windows.\n"
322 "This variable controls the border of TUI windows:\n"
323 "space use a white space\n"
324 "ascii use ascii characters + - | for the border\n"
325 "acs use the Alternate Character Set\n",
327 add_show_from_set (c
, &showlist
);
330 ("tui-border-mode", class_tui
,
331 tui_border_mode_enums
, (char*) &tui_border_mode
,
332 "Set the attribute mode to use for the TUI window borders.\n"
333 "This variable controls the attributes to use for the window borders:\n"
334 "normal normal display\n"
335 "standout use highlight mode of terminal\n"
336 "reverse use reverse video mode\n"
337 "half use half bright\n"
338 "half-standout use half bright and standout mode\n"
339 "bold use extra bright or bold\n"
340 "bold-standout use extra bright or bold with standout mode\n",
342 add_show_from_set (c
, &showlist
);
345 ("tui-active-border-mode", class_tui
,
346 tui_border_mode_enums
, (char*) &tui_active_border_mode
,
347 "Set the attribute mode to use for the active TUI window border.\n"
348 "This variable controls the attributes to use for the active window border:\n"
349 "normal normal display\n"
350 "standout use highlight mode of terminal\n"
351 "reverse use reverse video mode\n"
352 "half use half bright\n"
353 "half-standout use half bright and standout mode\n"
354 "bold use extra bright or bold\n"
355 "bold-standout use extra bright or bold with standout mode\n",
357 add_show_from_set (c
, &showlist
);
362 ** tuiClearWinFocusFrom
363 ** Clear the logical focus from winInfo
366 tuiClearWinFocusFrom (TuiWinInfoPtr winInfo
)
368 if (m_winPtrNotNull (winInfo
))
370 if (winInfo
->generic
.type
!= CMD_WIN
)
371 unhighlightWin (winInfo
);
372 tuiSetWinWithFocus ((TuiWinInfoPtr
) NULL
);
376 } /* tuiClearWinFocusFrom */
380 ** tuiClearWinFocus().
381 ** Clear the window that has focus.
384 tuiClearWinFocus (void)
386 tuiClearWinFocusFrom (tuiWinWithFocus ());
389 } /* tuiClearWinFocus */
394 ** Set the logical focus to winInfo
397 tuiSetWinFocusTo (TuiWinInfoPtr winInfo
)
399 if (m_winPtrNotNull (winInfo
))
401 TuiWinInfoPtr winWithFocus
= tuiWinWithFocus ();
403 if (m_winPtrNotNull (winWithFocus
) &&
404 winWithFocus
->generic
.type
!= CMD_WIN
)
405 unhighlightWin (winWithFocus
);
406 tuiSetWinWithFocus (winInfo
);
407 if (winInfo
->generic
.type
!= CMD_WIN
)
408 highlightWin (winInfo
);
412 } /* tuiSetWinFocusTo */
416 ** tuiScrollForward().
419 tuiScrollForward (TuiWinInfoPtr winToScroll
, int numToScroll
)
421 if (winToScroll
!= cmdWin
)
423 int _numToScroll
= numToScroll
;
425 if (numToScroll
== 0)
426 _numToScroll
= winToScroll
->generic
.height
- 3;
428 ** If we are scrolling the source or disassembly window, do a
429 ** "psuedo" scroll since not all of the source is in memory,
430 ** only what is in the viewport. If winToScroll is the
431 ** command window do nothing since the term should handle it.
433 if (winToScroll
== srcWin
)
434 tuiVerticalSourceScroll (FORWARD_SCROLL
, _numToScroll
);
435 else if (winToScroll
== disassemWin
)
436 tuiVerticalDisassemScroll (FORWARD_SCROLL
, _numToScroll
);
437 else if (winToScroll
== dataWin
)
438 tuiVerticalDataScroll (FORWARD_SCROLL
, _numToScroll
);
442 } /* tuiScrollForward */
446 ** tuiScrollBackward().
449 tuiScrollBackward (TuiWinInfoPtr winToScroll
, int numToScroll
)
451 if (winToScroll
!= cmdWin
)
453 int _numToScroll
= numToScroll
;
455 if (numToScroll
== 0)
456 _numToScroll
= winToScroll
->generic
.height
- 3;
458 ** If we are scrolling the source or disassembly window, do a
459 ** "psuedo" scroll since not all of the source is in memory,
460 ** only what is in the viewport. If winToScroll is the
461 ** command window do nothing since the term should handle it.
463 if (winToScroll
== srcWin
)
464 tuiVerticalSourceScroll (BACKWARD_SCROLL
, _numToScroll
);
465 else if (winToScroll
== disassemWin
)
466 tuiVerticalDisassemScroll (BACKWARD_SCROLL
, _numToScroll
);
467 else if (winToScroll
== dataWin
)
468 tuiVerticalDataScroll (BACKWARD_SCROLL
, _numToScroll
);
471 } /* tuiScrollBackward */
478 tuiScrollLeft (TuiWinInfoPtr winToScroll
, int numToScroll
)
480 if (winToScroll
!= cmdWin
)
482 int _numToScroll
= numToScroll
;
484 if (_numToScroll
== 0)
487 ** If we are scrolling the source or disassembly window, do a
488 ** "psuedo" scroll since not all of the source is in memory,
489 ** only what is in the viewport. If winToScroll is the
490 ** command window do nothing since the term should handle it.
492 if (winToScroll
== srcWin
|| winToScroll
== disassemWin
)
493 tuiHorizontalSourceScroll (winToScroll
, LEFT_SCROLL
, _numToScroll
);
496 } /* tuiScrollLeft */
503 tuiScrollRight (TuiWinInfoPtr winToScroll
, int numToScroll
)
505 if (winToScroll
!= cmdWin
)
507 int _numToScroll
= numToScroll
;
509 if (_numToScroll
== 0)
512 ** If we are scrolling the source or disassembly window, do a
513 ** "psuedo" scroll since not all of the source is in memory,
514 ** only what is in the viewport. If winToScroll is the
515 ** command window do nothing since the term should handle it.
517 if (winToScroll
== srcWin
|| winToScroll
== disassemWin
)
518 tuiHorizontalSourceScroll (winToScroll
, RIGHT_SCROLL
, _numToScroll
);
521 } /* tuiScrollRight */
526 ** Scroll a window. Arguments are passed through a va_list.
529 tui_scroll (TuiScrollDirection direction
,
530 TuiWinInfoPtr winToScroll
,
536 tuiScrollForward (winToScroll
, numToScroll
);
538 case BACKWARD_SCROLL
:
539 tuiScrollBackward (winToScroll
, numToScroll
);
542 tuiScrollLeft (winToScroll
, numToScroll
);
545 tuiScrollRight (winToScroll
, numToScroll
);
561 clearok (curscr
, TRUE
);
562 refreshAll (winList
);
563 for (type
= SRC_WIN
; type
< MAX_MAJOR_WINDOWS
; type
++)
565 if (winList
[type
] && winList
[type
]->generic
.isVisible
)
571 tuiClearWin (&winList
[type
]->generic
);
572 if (winList
[type
]->detail
.sourceInfo
.hasLocator
)
573 tuiClearLocatorDisplay ();
574 tuiShowSourceContent (winList
[type
]);
575 checkAndDisplayHighlightIfNeeded (winList
[type
]);
576 tuiEraseExecInfoContent (winList
[type
]);
577 tuiUpdateExecInfo (winList
[type
]);
580 tuiRefreshDataWin ();
587 tuiClearLocatorDisplay ();
588 tuiShowLocatorContent ();
591 } /* tuiRefreshAll */
596 ** Resize all the windows based on the the terminal size. This
597 ** function gets called from within the readline sinwinch handler.
602 int heightDiff
, widthDiff
;
603 extern int screenheight
, screenwidth
; /* in readline */
605 widthDiff
= screenwidth
- termWidth ();
606 heightDiff
= screenheight
- termHeight ();
607 if (heightDiff
|| widthDiff
)
609 TuiLayoutType curLayout
= currentLayout ();
610 TuiWinInfoPtr winWithFocus
= tuiWinWithFocus ();
611 TuiWinInfoPtr firstWin
, secondWin
;
612 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
614 int i
, newHeight
, splitDiff
, cmdSplitDiff
, numWinsDisplayed
= 2;
616 /* turn keypad off while we resize */
617 if (winWithFocus
!= cmdWin
)
618 keypad (cmdWin
->generic
.handle
, FALSE
);
620 setTermHeightTo (screenheight
);
621 setTermWidthTo (screenwidth
);
622 if (curLayout
== SRC_DISASSEM_COMMAND
||
623 curLayout
== SRC_DATA_COMMAND
|| curLayout
== DISASSEM_DATA_COMMAND
)
625 splitDiff
= heightDiff
/ numWinsDisplayed
;
626 cmdSplitDiff
= splitDiff
;
627 if (heightDiff
% numWinsDisplayed
)
634 /* now adjust each window */
640 case DISASSEM_COMMAND
:
641 firstWin
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
642 firstWin
->generic
.width
+= widthDiff
;
643 locator
->width
+= widthDiff
;
644 /* check for invalid heights */
646 newHeight
= firstWin
->generic
.height
;
647 else if ((firstWin
->generic
.height
+ splitDiff
) >=
648 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
649 newHeight
= screenheight
- MIN_CMD_WIN_HEIGHT
- 1;
650 else if ((firstWin
->generic
.height
+ splitDiff
) <= 0)
651 newHeight
= MIN_WIN_HEIGHT
;
653 newHeight
= firstWin
->generic
.height
+ splitDiff
;
655 _makeInvisibleAndSetNewHeight (firstWin
, newHeight
);
656 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
657 cmdWin
->generic
.width
+= widthDiff
;
658 newHeight
= screenheight
- cmdWin
->generic
.origin
.y
;
659 _makeInvisibleAndSetNewHeight (cmdWin
, newHeight
);
660 _makeVisibleWithNewHeight (firstWin
);
661 _makeVisibleWithNewHeight (cmdWin
);
662 if (firstWin
->generic
.contentSize
<= 0)
663 tuiEraseSourceContent (firstWin
, EMPTY_SOURCE_PROMPT
);
666 if (curLayout
== SRC_DISASSEM_COMMAND
)
669 firstWin
->generic
.width
+= widthDiff
;
670 secondWin
= disassemWin
;
671 secondWin
->generic
.width
+= widthDiff
;
676 firstWin
->generic
.width
+= widthDiff
;
677 secondWin
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
678 secondWin
->generic
.width
+= widthDiff
;
680 /* Change the first window's height/width */
681 /* check for invalid heights */
683 newHeight
= firstWin
->generic
.height
;
684 else if ((firstWin
->generic
.height
+
685 secondWin
->generic
.height
+ (splitDiff
* 2)) >=
686 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
687 newHeight
= (screenheight
- MIN_CMD_WIN_HEIGHT
- 1) / 2;
688 else if ((firstWin
->generic
.height
+ splitDiff
) <= 0)
689 newHeight
= MIN_WIN_HEIGHT
;
691 newHeight
= firstWin
->generic
.height
+ splitDiff
;
692 _makeInvisibleAndSetNewHeight (firstWin
, newHeight
);
694 if (firstWin
== dataWin
&& widthDiff
!= 0)
695 firstWin
->detail
.dataDisplayInfo
.regsColumnCount
=
696 tuiCalculateRegsColumnCount (
697 firstWin
->detail
.dataDisplayInfo
.regsDisplayType
);
698 locator
->width
+= widthDiff
;
700 /* Change the second window's height/width */
701 /* check for invalid heights */
703 newHeight
= secondWin
->generic
.height
;
704 else if ((firstWin
->generic
.height
+
705 secondWin
->generic
.height
+ (splitDiff
* 2)) >=
706 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
708 newHeight
= screenheight
- MIN_CMD_WIN_HEIGHT
- 1;
710 newHeight
= (newHeight
/ 2) + 1;
714 else if ((secondWin
->generic
.height
+ splitDiff
) <= 0)
715 newHeight
= MIN_WIN_HEIGHT
;
717 newHeight
= secondWin
->generic
.height
+ splitDiff
;
718 secondWin
->generic
.origin
.y
= firstWin
->generic
.height
- 1;
719 _makeInvisibleAndSetNewHeight (secondWin
, newHeight
);
721 /* Change the command window's height/width */
722 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
723 _makeInvisibleAndSetNewHeight (
724 cmdWin
, cmdWin
->generic
.height
+ cmdSplitDiff
);
725 _makeVisibleWithNewHeight (firstWin
);
726 _makeVisibleWithNewHeight (secondWin
);
727 _makeVisibleWithNewHeight (cmdWin
);
728 if (firstWin
->generic
.contentSize
<= 0)
729 tuiEraseSourceContent (firstWin
, EMPTY_SOURCE_PROMPT
);
730 if (secondWin
->generic
.contentSize
<= 0)
731 tuiEraseSourceContent (secondWin
, EMPTY_SOURCE_PROMPT
);
735 ** Now remove all invisible windows, and their content so that they get
736 ** created again when called for with the new size
738 for (winType
= SRC_WIN
; (winType
< MAX_MAJOR_WINDOWS
); winType
++)
740 if (winType
!= CMD_WIN
&& m_winPtrNotNull (winList
[winType
]) &&
741 !winList
[winType
]->generic
.isVisible
)
743 freeWindow (winList
[winType
]);
744 winList
[winType
] = (TuiWinInfoPtr
) NULL
;
747 tuiSetWinResizedTo (TRUE
);
748 /* turn keypad back on, unless focus is in the command window */
749 if (winWithFocus
!= cmdWin
)
750 keypad (cmdWin
->generic
.handle
, TRUE
);
757 ** tuiSigwinchHandler()
758 ** SIGWINCH signal handler for the tui. This signal handler is
759 ** always called, even when the readline package clears signals
760 ** because it is set as the old_sigwinch() (TUI only)
763 tuiSigwinchHandler (int signal
)
766 ** Say that a resize was done so that the readline can do it
767 ** later when appropriate.
769 tuiSetWinResizedTo (TRUE
);
772 } /* tuiSigwinchHandler */
776 /*************************
777 ** STATIC LOCAL FUNCTIONS
778 **************************/
782 ** _tuiScrollForward_command().
785 _tuiScrollForward_command (char *arg
, int fromTTY
)
788 TuiWinInfoPtr winToScroll
;
790 /* Make sure the curses mode is enabled. */
792 if (arg
== (char *) NULL
)
793 _parseScrollingArgs (arg
, &winToScroll
, (int *) NULL
);
795 _parseScrollingArgs (arg
, &winToScroll
, &numToScroll
);
796 tui_scroll (FORWARD_SCROLL
, winToScroll
, numToScroll
);
801 ** _tuiScrollBackward_command().
804 _tuiScrollBackward_command (char *arg
, int fromTTY
)
807 TuiWinInfoPtr winToScroll
;
809 /* Make sure the curses mode is enabled. */
811 if (arg
== (char *) NULL
)
812 _parseScrollingArgs (arg
, &winToScroll
, (int *) NULL
);
814 _parseScrollingArgs (arg
, &winToScroll
, &numToScroll
);
815 tui_scroll (BACKWARD_SCROLL
, winToScroll
, numToScroll
);
820 ** _tuiScrollLeft_command().
823 _tuiScrollLeft_command (char *arg
, int fromTTY
)
826 TuiWinInfoPtr winToScroll
;
828 /* Make sure the curses mode is enabled. */
830 _parseScrollingArgs (arg
, &winToScroll
, &numToScroll
);
831 tui_scroll (LEFT_SCROLL
, winToScroll
, numToScroll
);
836 ** _tuiScrollRight_command().
839 _tuiScrollRight_command (char *arg
, int fromTTY
)
842 TuiWinInfoPtr winToScroll
;
844 /* Make sure the curses mode is enabled. */
846 _parseScrollingArgs (arg
, &winToScroll
, &numToScroll
);
847 tui_scroll (RIGHT_SCROLL
, winToScroll
, numToScroll
);
853 ** Set focus to the window named by 'arg'
856 _tuiSetFocus (char *arg
, int fromTTY
)
858 if (arg
!= (char *) NULL
)
860 char *bufPtr
= (char *) xstrdup (arg
);
862 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
864 for (i
= 0; (i
< strlen (bufPtr
)); i
++)
865 bufPtr
[i
] = toupper (arg
[i
]);
867 if (subset_compare (bufPtr
, "NEXT"))
868 winInfo
= tuiNextWin (tuiWinWithFocus ());
869 else if (subset_compare (bufPtr
, "PREV"))
870 winInfo
= tuiPrevWin (tuiWinWithFocus ());
872 winInfo
= partialWinByName (bufPtr
);
874 if (winInfo
== (TuiWinInfoPtr
) NULL
|| !winInfo
->generic
.isVisible
)
875 warning ("Invalid window specified. \n\
876 The window name specified must be valid and visible.\n");
879 tuiSetWinFocusTo (winInfo
);
880 keypad (cmdWin
->generic
.handle
, (winInfo
!= cmdWin
));
883 if (dataWin
&& dataWin
->generic
.isVisible
)
884 tuiRefreshDataWin ();
886 printf_filtered ("Focus set to %s window.\n",
887 winName ((TuiGenWinInfoPtr
) tuiWinWithFocus ()));
890 warning ("Incorrect Number of Arguments.\n%s", FOCUS_USAGE
);
896 ** _tuiSetFocus_command()
899 _tuiSetFocus_command (char *arg
, int fromTTY
)
901 /* Make sure the curses mode is enabled. */
903 _tuiSetFocus (arg
, fromTTY
);
908 ** _tuiAllWindowsInfo().
911 _tuiAllWindowsInfo (char *arg
, int fromTTY
)
914 TuiWinInfoPtr winWithFocus
= tuiWinWithFocus ();
916 for (type
= SRC_WIN
; (type
< MAX_MAJOR_WINDOWS
); type
++)
917 if (winList
[type
]->generic
.isVisible
)
919 if (winWithFocus
== winList
[type
])
920 printf_filtered (" %s\t(%d lines) <has focus>\n",
921 winName (&winList
[type
]->generic
),
922 winList
[type
]->generic
.height
);
924 printf_filtered (" %s\t(%d lines)\n",
925 winName (&winList
[type
]->generic
),
926 winList
[type
]->generic
.height
);
930 } /* _tuiAllWindowsInfo */
934 ** _tuiRefreshAll_command().
937 _tuiRefreshAll_command (char *arg
, int fromTTY
)
939 /* Make sure the curses mode is enabled. */
947 ** _tuiSetWinTabWidth_command().
948 ** Set the height of the specified window.
951 _tuiSetTabWidth_command (char *arg
, int fromTTY
)
953 /* Make sure the curses mode is enabled. */
955 if (arg
!= (char *) NULL
)
961 tuiSetDefaultTabLen (ts
);
963 warning ("Tab widths greater than 0 must be specified.\n");
967 } /* _tuiSetTabWidth_command */
971 ** _tuiSetWinHeight().
972 ** Set the height of the specified window.
975 _tuiSetWinHeight (char *arg
, int fromTTY
)
977 /* Make sure the curses mode is enabled. */
979 if (arg
!= (char *) NULL
)
981 char *buf
= xstrdup (arg
);
983 char *wname
= (char *) NULL
;
985 TuiWinInfoPtr winInfo
;
988 bufPtr
= strchr (bufPtr
, ' ');
989 if (bufPtr
!= (char *) NULL
)
994 ** Validate the window name
996 for (i
= 0; i
< strlen (wname
); i
++)
997 wname
[i
] = toupper (wname
[i
]);
998 winInfo
= partialWinByName (wname
);
1000 if (winInfo
== (TuiWinInfoPtr
) NULL
|| !winInfo
->generic
.isVisible
)
1001 warning ("Invalid window specified. \n\
1002 The window name specified must be valid and visible.\n");
1005 /* Process the size */
1006 while (*(++bufPtr
) == ' ')
1009 if (*bufPtr
!= (char) 0)
1012 int fixedSize
= TRUE
;
1015 if (*bufPtr
== '+' || *bufPtr
== '-')
1022 inputNo
= atoi (bufPtr
);
1028 newHeight
= inputNo
;
1030 newHeight
= winInfo
->generic
.height
+ inputNo
;
1032 ** Now change the window's height, and adjust all
1033 ** other windows around it
1035 if (_tuiAdjustWinHeights (winInfo
,
1036 newHeight
) == TUI_FAILURE
)
1037 warning ("Invalid window height specified.\n%s",
1043 warning ("Invalid window height specified.\n%s",
1049 printf_filtered (WIN_HEIGHT_USAGE
);
1051 if (buf
!= (char *) NULL
)
1055 printf_filtered (WIN_HEIGHT_USAGE
);
1058 } /* _tuiSetWinHeight */
1061 ** _tuiSetWinHeight_command().
1062 ** Set the height of the specified window, with va_list.
1065 _tuiSetWinHeight_command (char *arg
, int fromTTY
)
1067 /* Make sure the curses mode is enabled. */
1069 _tuiSetWinHeight (arg
, fromTTY
);
1074 ** _tuiXDBsetWinHeight().
1075 ** XDB Compatibility command for setting the window height. This will
1076 ** increase or decrease the command window by the specified amount.
1079 _tuiXDBsetWinHeight (char *arg
, int fromTTY
)
1081 /* Make sure the curses mode is enabled. */
1083 if (arg
!= (char *) NULL
)
1085 int inputNo
= atoi (arg
);
1088 { /* Add 1 for the locator */
1089 int newHeight
= termHeight () - (inputNo
+ 1);
1091 if (!_newHeightOk (winList
[CMD_WIN
], newHeight
) ||
1092 _tuiAdjustWinHeights (winList
[CMD_WIN
],
1093 newHeight
) == TUI_FAILURE
)
1094 warning ("Invalid window height specified.\n%s",
1095 XDBWIN_HEIGHT_USAGE
);
1098 warning ("Invalid window height specified.\n%s",
1099 XDBWIN_HEIGHT_USAGE
);
1102 warning ("Invalid window height specified.\n%s", XDBWIN_HEIGHT_USAGE
);
1105 } /* _tuiXDBsetWinHeight */
1108 ** _tuiSetWinHeight_command().
1109 ** Set the height of the specified window, with va_list.
1112 _tuiXDBsetWinHeight_command (char *arg
, int fromTTY
)
1114 _tuiXDBsetWinHeight (arg
, fromTTY
);
1119 ** _tuiAdjustWinHeights().
1120 ** Function to adjust all window heights around the primary
1123 _tuiAdjustWinHeights (TuiWinInfoPtr primaryWinInfo
, int newHeight
)
1125 TuiStatus status
= TUI_FAILURE
;
1127 if (_newHeightOk (primaryWinInfo
, newHeight
))
1129 status
= TUI_SUCCESS
;
1130 if (newHeight
!= primaryWinInfo
->generic
.height
)
1133 TuiWinInfoPtr winInfo
;
1134 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
1135 TuiLayoutType curLayout
= currentLayout ();
1137 diff
= (newHeight
- primaryWinInfo
->generic
.height
) * (-1);
1138 if (curLayout
== SRC_COMMAND
|| curLayout
== DISASSEM_COMMAND
)
1140 TuiWinInfoPtr srcWinInfo
;
1142 _makeInvisibleAndSetNewHeight (primaryWinInfo
, newHeight
);
1143 if (primaryWinInfo
->generic
.type
== CMD_WIN
)
1145 winInfo
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1146 srcWinInfo
= winInfo
;
1150 winInfo
= winList
[CMD_WIN
];
1151 srcWinInfo
= primaryWinInfo
;
1153 _makeInvisibleAndSetNewHeight (winInfo
,
1154 winInfo
->generic
.height
+ diff
);
1155 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1156 _makeVisibleWithNewHeight (winInfo
);
1157 _makeVisibleWithNewHeight (primaryWinInfo
);
1158 if (srcWinInfo
->generic
.contentSize
<= 0)
1159 tuiEraseSourceContent (srcWinInfo
, EMPTY_SOURCE_PROMPT
);
1163 TuiWinInfoPtr firstWin
, secondWin
;
1165 if (curLayout
== SRC_DISASSEM_COMMAND
)
1168 secondWin
= disassemWin
;
1173 secondWin
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1175 if (primaryWinInfo
== cmdWin
)
1177 ** Split the change in height accross the 1st & 2nd windows
1178 ** adjusting them as well.
1180 int firstSplitDiff
= diff
/ 2; /* subtract the locator */
1181 int secondSplitDiff
= firstSplitDiff
;
1185 if (firstWin
->generic
.height
>
1186 secondWin
->generic
.height
)
1199 /* make sure that the minimum hieghts are honored */
1200 while ((firstWin
->generic
.height
+ firstSplitDiff
) < 3)
1205 while ((secondWin
->generic
.height
+ secondSplitDiff
) < 3)
1210 _makeInvisibleAndSetNewHeight (
1212 firstWin
->generic
.height
+ firstSplitDiff
);
1213 secondWin
->generic
.origin
.y
= firstWin
->generic
.height
- 1;
1214 _makeInvisibleAndSetNewHeight (
1215 secondWin
, secondWin
->generic
.height
+ secondSplitDiff
);
1216 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1217 _makeInvisibleAndSetNewHeight (cmdWin
, newHeight
);
1221 if ((cmdWin
->generic
.height
+ diff
) < 1)
1223 ** If there is no way to increase the command window
1224 ** take real estate from the 1st or 2nd window.
1226 if ((cmdWin
->generic
.height
+ diff
) < 1)
1229 for (i
= cmdWin
->generic
.height
+ diff
;
1231 if (primaryWinInfo
== firstWin
)
1232 secondWin
->generic
.height
--;
1234 firstWin
->generic
.height
--;
1237 if (primaryWinInfo
== firstWin
)
1238 _makeInvisibleAndSetNewHeight (firstWin
, newHeight
);
1240 _makeInvisibleAndSetNewHeight (
1242 firstWin
->generic
.height
);
1243 secondWin
->generic
.origin
.y
= firstWin
->generic
.height
- 1;
1244 if (primaryWinInfo
== secondWin
)
1245 _makeInvisibleAndSetNewHeight (secondWin
, newHeight
);
1247 _makeInvisibleAndSetNewHeight (
1248 secondWin
, secondWin
->generic
.height
);
1249 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1250 if ((cmdWin
->generic
.height
+ diff
) < 1)
1251 _makeInvisibleAndSetNewHeight (cmdWin
, 1);
1253 _makeInvisibleAndSetNewHeight (
1254 cmdWin
, cmdWin
->generic
.height
+ diff
);
1256 _makeVisibleWithNewHeight (cmdWin
);
1257 _makeVisibleWithNewHeight (secondWin
);
1258 _makeVisibleWithNewHeight (firstWin
);
1259 if (firstWin
->generic
.contentSize
<= 0)
1260 tuiEraseSourceContent (firstWin
, EMPTY_SOURCE_PROMPT
);
1261 if (secondWin
->generic
.contentSize
<= 0)
1262 tuiEraseSourceContent (secondWin
, EMPTY_SOURCE_PROMPT
);
1268 } /* _tuiAdjustWinHeights */
1272 ** _makeInvisibleAndSetNewHeight().
1273 ** Function make the target window (and auxillary windows associated
1274 ** with the targer) invisible, and set the new height and location.
1277 _makeInvisibleAndSetNewHeight (TuiWinInfoPtr winInfo
, int height
)
1281 TuiGenWinInfoPtr genWinInfo
;
1284 m_beInvisible (&winInfo
->generic
);
1285 winInfo
->generic
.height
= height
;
1287 winInfo
->generic
.viewportHeight
= height
- 1;
1289 winInfo
->generic
.viewportHeight
= height
;
1290 if (winInfo
!= cmdWin
)
1291 winInfo
->generic
.viewportHeight
--;
1293 /* Now deal with the auxillary windows associated with winInfo */
1294 switch (winInfo
->generic
.type
)
1298 genWinInfo
= winInfo
->detail
.sourceInfo
.executionInfo
;
1299 m_beInvisible (genWinInfo
);
1300 genWinInfo
->height
= height
;
1301 genWinInfo
->origin
.y
= winInfo
->generic
.origin
.y
;
1303 genWinInfo
->viewportHeight
= height
- 1;
1305 genWinInfo
->viewportHeight
= height
;
1306 if (winInfo
!= cmdWin
)
1307 genWinInfo
->viewportHeight
--;
1309 if (m_hasLocator (winInfo
))
1311 genWinInfo
= locatorWinInfoPtr ();
1312 m_beInvisible (genWinInfo
);
1313 genWinInfo
->origin
.y
= winInfo
->generic
.origin
.y
+ height
;
1317 /* delete all data item windows */
1318 for (i
= 0; i
< winInfo
->generic
.contentSize
; i
++)
1320 genWinInfo
= (TuiGenWinInfoPtr
) & ((TuiWinElementPtr
)
1321 winInfo
->generic
.content
[i
])->whichElement
.dataWindow
;
1322 tuiDelwin (genWinInfo
->handle
);
1323 genWinInfo
->handle
= (WINDOW
*) NULL
;
1331 } /* _makeInvisibleAndSetNewHeight */
1335 ** _makeVisibleWithNewHeight().
1336 ** Function to make the windows with new heights visible.
1337 ** This means re-creating the windows' content since the window
1338 ** had to be destroyed to be made invisible.
1341 _makeVisibleWithNewHeight (TuiWinInfoPtr winInfo
)
1346 m_beVisible (&winInfo
->generic
);
1347 checkAndDisplayHighlightIfNeeded (winInfo
);
1348 switch (winInfo
->generic
.type
)
1352 freeWinContent (winInfo
->detail
.sourceInfo
.executionInfo
);
1353 m_beVisible (winInfo
->detail
.sourceInfo
.executionInfo
);
1354 if (winInfo
->generic
.content
!= (OpaquePtr
) NULL
)
1356 TuiLineOrAddress lineOrAddr
;
1358 if (winInfo
->generic
.type
== SRC_WIN
)
1360 winInfo
->detail
.sourceInfo
.startLineOrAddr
.lineNo
;
1363 winInfo
->detail
.sourceInfo
.startLineOrAddr
.addr
;
1364 freeWinContent (&winInfo
->generic
);
1365 tuiUpdateSourceWindow (winInfo
,
1366 current_source_symtab
, lineOrAddr
, TRUE
);
1368 else if (selected_frame
!= (struct frame_info
*) NULL
)
1370 TuiLineOrAddress line
;
1371 extern int current_source_line
;
1373 s
= find_pc_symtab (selected_frame
->pc
);
1374 if (winInfo
->generic
.type
== SRC_WIN
)
1375 line
.lineNo
= current_source_line
;
1378 find_line_pc (s
, current_source_line
, &line
.addr
);
1380 tuiUpdateSourceWindow (winInfo
, s
, line
, TRUE
);
1382 if (m_hasLocator (winInfo
))
1384 m_beVisible (locatorWinInfoPtr ());
1385 tuiClearLocatorDisplay ();
1386 tuiShowLocatorContent ();
1390 tuiDisplayAllData ();
1393 winInfo
->detail
.commandInfo
.curLine
= 0;
1394 winInfo
->detail
.commandInfo
.curch
= 0;
1395 wmove (winInfo
->generic
.handle
,
1396 winInfo
->detail
.commandInfo
.curLine
,
1397 winInfo
->detail
.commandInfo
.curch
);
1404 } /* _makeVisibleWithNewHeight */
1408 _newHeightOk (TuiWinInfoPtr primaryWinInfo
, int newHeight
)
1410 int ok
= (newHeight
< termHeight ());
1414 int diff
, curHeight
;
1415 TuiLayoutType curLayout
= currentLayout ();
1417 diff
= (newHeight
- primaryWinInfo
->generic
.height
) * (-1);
1418 if (curLayout
== SRC_COMMAND
|| curLayout
== DISASSEM_COMMAND
)
1420 ok
= ((primaryWinInfo
->generic
.type
== CMD_WIN
&&
1421 newHeight
<= (termHeight () - 4) &&
1422 newHeight
>= MIN_CMD_WIN_HEIGHT
) ||
1423 (primaryWinInfo
->generic
.type
!= CMD_WIN
&&
1424 newHeight
<= (termHeight () - 2) &&
1425 newHeight
>= MIN_WIN_HEIGHT
));
1427 { /* check the total height */
1428 TuiWinInfoPtr winInfo
;
1430 if (primaryWinInfo
== cmdWin
)
1431 winInfo
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1435 (winInfo
->generic
.height
+ diff
)) <= termHeight ());
1440 int curTotalHeight
, totalHeight
, minHeight
;
1441 TuiWinInfoPtr firstWin
, secondWin
;
1443 if (curLayout
== SRC_DISASSEM_COMMAND
)
1446 secondWin
= disassemWin
;
1451 secondWin
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1454 ** We could simply add all the heights to obtain the same result
1455 ** but below is more explicit since we subtract 1 for the
1456 ** line that the first and second windows share, and add one
1460 (firstWin
->generic
.height
+ secondWin
->generic
.height
- 1)
1461 + cmdWin
->generic
.height
+ 1 /*locator */ ;
1462 if (primaryWinInfo
== cmdWin
)
1464 /* locator included since first & second win share a line */
1465 ok
= ((firstWin
->generic
.height
+
1466 secondWin
->generic
.height
+ diff
) >=
1467 (MIN_WIN_HEIGHT
* 2) &&
1468 newHeight
>= MIN_CMD_WIN_HEIGHT
);
1471 totalHeight
= newHeight
+ (firstWin
->generic
.height
+
1472 secondWin
->generic
.height
+ diff
);
1473 minHeight
= MIN_CMD_WIN_HEIGHT
;
1478 minHeight
= MIN_WIN_HEIGHT
;
1480 ** First see if we can increase/decrease the command
1481 ** window. And make sure that the command window is
1484 ok
= ((cmdWin
->generic
.height
+ diff
) > 0);
1487 ** Looks like we have to increase/decrease one of
1488 ** the other windows
1490 if (primaryWinInfo
== firstWin
)
1491 ok
= (secondWin
->generic
.height
+ diff
) >= minHeight
;
1493 ok
= (firstWin
->generic
.height
+ diff
) >= minHeight
;
1497 if (primaryWinInfo
== firstWin
)
1498 totalHeight
= newHeight
+
1499 secondWin
->generic
.height
+
1500 cmdWin
->generic
.height
+ diff
;
1502 totalHeight
= newHeight
+
1503 firstWin
->generic
.height
+
1504 cmdWin
->generic
.height
+ diff
;
1508 ** Now make sure that the proposed total height doesn't exceed
1509 ** the old total height.
1512 ok
= (newHeight
>= minHeight
&& totalHeight
<= curTotalHeight
);
1517 } /* _newHeightOk */
1521 ** _parseScrollingArgs().
1524 _parseScrollingArgs (char *arg
, TuiWinInfoPtr
* winToScroll
, int *numToScroll
)
1528 *winToScroll
= tuiWinWithFocus ();
1531 ** First set up the default window to scroll, in case there is no
1534 if (arg
!= (char *) NULL
)
1538 /* process the number of lines to scroll */
1539 buf
= bufPtr
= xstrdup (arg
);
1540 if (isdigit (*bufPtr
))
1545 bufPtr
= strchr (bufPtr
, ' ');
1546 if (bufPtr
!= (char *) NULL
)
1550 *numToScroll
= atoi (numStr
);
1553 else if (numToScroll
)
1554 *numToScroll
= atoi (numStr
);
1557 /* process the window name if one is specified */
1558 if (bufPtr
!= (char *) NULL
)
1564 while (*(++bufPtr
) == ' ')
1567 if (*bufPtr
!= (char) 0)
1572 /* Validate the window name */
1573 for (i
= 0; i
< strlen (wname
); i
++)
1574 wname
[i
] = toupper (wname
[i
]);
1575 *winToScroll
= partialWinByName (wname
);
1577 if (*winToScroll
== (TuiWinInfoPtr
) NULL
||
1578 !(*winToScroll
)->generic
.isVisible
)
1579 warning ("Invalid window specified. \n\
1580 The window name specified must be valid and visible.\n");
1581 else if (*winToScroll
== cmdWin
)
1582 *winToScroll
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1588 } /* _parseScrollingArgs */