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 */
27 /* If we need <curses.h>, we must include it before we get "bfd.h". */
42 #include "breakpoint.h"
44 #include "cli/cli-cmds.h"
48 #include "tuiGeneralWin.h"
51 #include "tuiDisassem.h"
52 #include "tuiSource.h"
53 #include "tuiSourceWin.h"
54 #include "tuiDataWin.h"
56 /*******************************
57 ** External Declarations
58 ********************************/
59 extern void init_page_info ();
61 /*******************************
63 ********************************/
64 static void _makeVisibleWithNewHeight (TuiWinInfoPtr
);
65 static void _makeInvisibleAndSetNewHeight (TuiWinInfoPtr
, int);
66 static TuiStatus
_tuiAdjustWinHeights (TuiWinInfoPtr
, int);
67 static int _newHeightOk (TuiWinInfoPtr
, int);
68 static void _tuiSetTabWidth_command (char *, int);
69 static void _tuiRefreshAll_command (char *, int);
70 static void _tuiSetWinHeight_command (char *, int);
71 static void _tuiXDBsetWinHeight_command (char *, int);
72 static void _tuiAllWindowsInfo (char *, int);
73 static void _tuiSetFocus_command (char *, int);
74 static void _tuiScrollForward_command (char *, int);
75 static void _tuiScrollBackward_command (char *, int);
76 static void _tuiScrollLeft_command (char *, int);
77 static void _tuiScrollRight_command (char *, int);
78 static void _parseScrollingArgs (char *, TuiWinInfoPtr
*, int *);
81 /***************************************
83 ***************************************/
84 #define WIN_HEIGHT_USAGE "Usage: winheight <win_name> [+ | -] <#lines>\n"
85 #define XDBWIN_HEIGHT_USAGE "Usage: w <#lines>\n"
86 #define FOCUS_USAGE "Usage: focus {<win> | next | prev}\n"
88 /***************************************
90 ***************************************/
92 /* Possible values for tui-border-kind variable. */
93 static const char *tui_border_kind_enums
[] = {
100 /* Possible values for tui-border-mode and tui-active-border-mode. */
101 static const char *tui_border_mode_enums
[] = {
118 /* Translation table for border-mode variables.
119 The list of values must be terminated by a NULL.
120 After the NULL value, an entry defines the default. */
121 struct tui_translate tui_border_mode_translate
[] = {
122 { "normal", A_NORMAL
},
123 { "standout", A_STANDOUT
},
124 { "reverse", A_REVERSE
},
126 { "half-standout", A_DIM
| A_STANDOUT
},
128 { "bold-standout", A_BOLD
| A_STANDOUT
},
130 { "normal", A_NORMAL
}
133 /* Translation tables for border-kind, one for each border
134 character (see wborder, border curses operations).
135 -1 is used to indicate the ACS because ACS characters
136 are determined at run time by curses (depends on terminal). */
137 struct tui_translate tui_border_kind_translate_vline
[] = {
145 struct tui_translate tui_border_kind_translate_hline
[] = {
153 struct tui_translate tui_border_kind_translate_ulcorner
[] = {
161 struct tui_translate tui_border_kind_translate_urcorner
[] = {
169 struct tui_translate tui_border_kind_translate_llcorner
[] = {
177 struct tui_translate tui_border_kind_translate_lrcorner
[] = {
186 /* Tui configuration variables controlled with set/show command. */
187 const char *tui_active_border_mode
= "bold-standout";
188 const char *tui_border_mode
= "normal";
189 const char *tui_border_kind
= "acs";
191 /* Tui internal configuration variables. These variables are
192 updated by tui_update_variables to reflect the tui configuration
194 chtype tui_border_vline
;
195 chtype tui_border_hline
;
196 chtype tui_border_ulcorner
;
197 chtype tui_border_urcorner
;
198 chtype tui_border_llcorner
;
199 chtype tui_border_lrcorner
;
201 int tui_border_attrs
;
202 int tui_active_border_attrs
;
204 /* Identify the item in the translation table.
205 When the item is not recognized, use the default entry. */
206 static struct tui_translate
*
207 translate (const char *name
, struct tui_translate
*table
)
211 if (name
&& strcmp (table
->name
, name
) == 0)
216 /* Not found, return default entry. */
221 /* Update the tui internal configuration according to gdb settings.
222 Returns 1 if the configuration has changed and the screen should
225 tui_update_variables ()
228 struct tui_translate
*entry
;
230 entry
= translate (tui_border_mode
, tui_border_mode_translate
);
231 if (tui_border_attrs
!= entry
->value
)
233 tui_border_attrs
= entry
->value
;
236 entry
= translate (tui_active_border_mode
, tui_border_mode_translate
);
237 if (tui_active_border_attrs
!= entry
->value
)
239 tui_active_border_attrs
= entry
->value
;
243 /* If one corner changes, all characters are changed.
244 Only check the first one. The ACS characters are determined at
245 run time by curses terminal management. */
246 entry
= translate (tui_border_kind
, tui_border_kind_translate_lrcorner
);
247 if (tui_border_lrcorner
!= (chtype
) entry
->value
)
249 tui_border_lrcorner
= (entry
->value
< 0) ? ACS_LRCORNER
: entry
->value
;
252 entry
= translate (tui_border_kind
, tui_border_kind_translate_llcorner
);
253 tui_border_llcorner
= (entry
->value
< 0) ? ACS_LLCORNER
: entry
->value
;
255 entry
= translate (tui_border_kind
, tui_border_kind_translate_ulcorner
);
256 tui_border_ulcorner
= (entry
->value
< 0) ? ACS_ULCORNER
: entry
->value
;
258 entry
= translate (tui_border_kind
, tui_border_kind_translate_urcorner
);
259 tui_border_urcorner
= (entry
->value
< 0) ? ACS_URCORNER
: entry
->value
;
261 entry
= translate (tui_border_kind
, tui_border_kind_translate_hline
);
262 tui_border_hline
= (entry
->value
< 0) ? ACS_HLINE
: entry
->value
;
264 entry
= translate (tui_border_kind
, tui_border_kind_translate_vline
);
265 tui_border_vline
= (entry
->value
< 0) ? ACS_VLINE
: entry
->value
;
271 set_tui_cmd (char *args
, int from_tty
)
276 show_tui_cmd (char *args
, int from_tty
)
281 ** _initialize_tuiWin().
282 ** Function to initialize gdb commands, for tui window manipulation.
285 _initialize_tuiWin (void)
287 struct cmd_list_element
*c
;
288 static struct cmd_list_element
*tui_setlist
;
289 static struct cmd_list_element
*tui_showlist
;
291 /* Define the classes of commands.
292 They will appear in the help list in the reverse of this order. */
293 add_cmd ("tui", class_tui
, NULL
,
294 "Text User Interface commands.",
297 add_prefix_cmd ("tui", class_tui
, set_tui_cmd
,
298 "TUI configuration variables",
299 &tui_setlist
, "set tui ",
300 0/*allow-unknown*/, &setlist
);
301 add_prefix_cmd ("tui", class_tui
, show_tui_cmd
,
302 "TUI configuration variables",
303 &tui_showlist
, "show tui ",
304 0/*allow-unknown*/, &showlist
);
306 add_com ("refresh", class_tui
, _tuiRefreshAll_command
,
307 "Refresh the terminal display.\n");
309 add_com_alias ("U", "refresh", class_tui
, 0);
310 add_com ("tabset", class_tui
, _tuiSetTabWidth_command
,
311 "Set the width (in characters) of tab stops.\n\
312 Usage: tabset <n>\n");
313 add_com ("winheight", class_tui
, _tuiSetWinHeight_command
,
314 "Set the height of a specified window.\n\
315 Usage: winheight <win_name> [+ | -] <#lines>\n\
317 src : the source window\n\
318 cmd : the command window\n\
319 asm : the disassembly window\n\
320 regs : the register display\n");
321 add_com_alias ("wh", "winheight", class_tui
, 0);
322 add_info ("win", _tuiAllWindowsInfo
,
323 "List of all displayed windows.\n");
324 add_com ("focus", class_tui
, _tuiSetFocus_command
,
325 "Set focus to named window or next/prev window.\n\
326 Usage: focus {<win> | next | prev}\n\
327 Valid Window names are:\n\
328 src : the source window\n\
329 asm : the disassembly window\n\
330 regs : the register display\n\
331 cmd : the command window\n");
332 add_com_alias ("fs", "focus", class_tui
, 0);
333 add_com ("+", class_tui
, _tuiScrollForward_command
,
334 "Scroll window forward.\nUsage: + [win] [n]\n");
335 add_com ("-", class_tui
, _tuiScrollBackward_command
,
336 "Scroll window backward.\nUsage: - [win] [n]\n");
337 add_com ("<", class_tui
, _tuiScrollLeft_command
,
338 "Scroll window forward.\nUsage: < [win] [n]\n");
339 add_com (">", class_tui
, _tuiScrollRight_command
,
340 "Scroll window backward.\nUsage: > [win] [n]\n");
342 add_com ("w", class_xdb
, _tuiXDBsetWinHeight_command
,
343 "XDB compatibility command for setting the height of a command window.\n\
344 Usage: w <#lines>\n");
346 /* Define the tui control variables. */
348 ("border-kind", no_class
,
349 tui_border_kind_enums
, &tui_border_kind
,
350 "Set the kind of border for TUI windows.\n"
351 "This variable controls the border of TUI windows:\n"
352 "space use a white space\n"
353 "ascii use ascii characters + - | for the border\n"
354 "acs use the Alternate Character Set\n",
356 add_show_from_set (c
, &tui_showlist
);
359 ("border-mode", no_class
,
360 tui_border_mode_enums
, &tui_border_mode
,
361 "Set the attribute mode to use for the TUI window borders.\n"
362 "This variable controls the attributes to use for the window borders:\n"
363 "normal normal display\n"
364 "standout use highlight mode of terminal\n"
365 "reverse use reverse video mode\n"
366 "half use half bright\n"
367 "half-standout use half bright and standout mode\n"
368 "bold use extra bright or bold\n"
369 "bold-standout use extra bright or bold with standout mode\n",
371 add_show_from_set (c
, &tui_showlist
);
374 ("active-border-mode", no_class
,
375 tui_border_mode_enums
, &tui_active_border_mode
,
376 "Set the attribute mode to use for the active TUI window border.\n"
377 "This variable controls the attributes to use for the active window border:\n"
378 "normal normal display\n"
379 "standout use highlight mode of terminal\n"
380 "reverse use reverse video mode\n"
381 "half use half bright\n"
382 "half-standout use half bright and standout mode\n"
383 "bold use extra bright or bold\n"
384 "bold-standout use extra bright or bold with standout mode\n",
386 add_show_from_set (c
, &tui_showlist
);
391 ** tuiClearWinFocusFrom
392 ** Clear the logical focus from winInfo
395 tuiClearWinFocusFrom (TuiWinInfoPtr winInfo
)
397 if (m_winPtrNotNull (winInfo
))
399 if (winInfo
->generic
.type
!= CMD_WIN
)
400 unhighlightWin (winInfo
);
401 tuiSetWinWithFocus ((TuiWinInfoPtr
) NULL
);
405 } /* tuiClearWinFocusFrom */
409 ** tuiClearWinFocus().
410 ** Clear the window that has focus.
413 tuiClearWinFocus (void)
415 tuiClearWinFocusFrom (tuiWinWithFocus ());
418 } /* tuiClearWinFocus */
423 ** Set the logical focus to winInfo
426 tuiSetWinFocusTo (TuiWinInfoPtr winInfo
)
428 if (m_winPtrNotNull (winInfo
))
430 TuiWinInfoPtr winWithFocus
= tuiWinWithFocus ();
432 if (m_winPtrNotNull (winWithFocus
) &&
433 winWithFocus
->generic
.type
!= CMD_WIN
)
434 unhighlightWin (winWithFocus
);
435 tuiSetWinWithFocus (winInfo
);
436 if (winInfo
->generic
.type
!= CMD_WIN
)
437 highlightWin (winInfo
);
441 } /* tuiSetWinFocusTo */
445 ** tuiScrollForward().
448 tuiScrollForward (TuiWinInfoPtr winToScroll
, int numToScroll
)
450 if (winToScroll
!= cmdWin
)
452 int _numToScroll
= numToScroll
;
454 if (numToScroll
== 0)
455 _numToScroll
= winToScroll
->generic
.height
- 3;
457 ** If we are scrolling the source or disassembly window, do a
458 ** "psuedo" scroll since not all of the source is in memory,
459 ** only what is in the viewport. If winToScroll is the
460 ** command window do nothing since the term should handle it.
462 if (winToScroll
== srcWin
)
463 tuiVerticalSourceScroll (FORWARD_SCROLL
, _numToScroll
);
464 else if (winToScroll
== disassemWin
)
465 tuiVerticalDisassemScroll (FORWARD_SCROLL
, _numToScroll
);
466 else if (winToScroll
== dataWin
)
467 tuiVerticalDataScroll (FORWARD_SCROLL
, _numToScroll
);
471 } /* tuiScrollForward */
475 ** tuiScrollBackward().
478 tuiScrollBackward (TuiWinInfoPtr winToScroll
, int numToScroll
)
480 if (winToScroll
!= cmdWin
)
482 int _numToScroll
= numToScroll
;
484 if (numToScroll
== 0)
485 _numToScroll
= winToScroll
->generic
.height
- 3;
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
)
493 tuiVerticalSourceScroll (BACKWARD_SCROLL
, _numToScroll
);
494 else if (winToScroll
== disassemWin
)
495 tuiVerticalDisassemScroll (BACKWARD_SCROLL
, _numToScroll
);
496 else if (winToScroll
== dataWin
)
497 tuiVerticalDataScroll (BACKWARD_SCROLL
, _numToScroll
);
500 } /* tuiScrollBackward */
507 tuiScrollLeft (TuiWinInfoPtr winToScroll
, int numToScroll
)
509 if (winToScroll
!= cmdWin
)
511 int _numToScroll
= numToScroll
;
513 if (_numToScroll
== 0)
516 ** If we are scrolling the source or disassembly window, do a
517 ** "psuedo" scroll since not all of the source is in memory,
518 ** only what is in the viewport. If winToScroll is the
519 ** command window do nothing since the term should handle it.
521 if (winToScroll
== srcWin
|| winToScroll
== disassemWin
)
522 tuiHorizontalSourceScroll (winToScroll
, LEFT_SCROLL
, _numToScroll
);
525 } /* tuiScrollLeft */
532 tuiScrollRight (TuiWinInfoPtr winToScroll
, int numToScroll
)
534 if (winToScroll
!= cmdWin
)
536 int _numToScroll
= numToScroll
;
538 if (_numToScroll
== 0)
541 ** If we are scrolling the source or disassembly window, do a
542 ** "psuedo" scroll since not all of the source is in memory,
543 ** only what is in the viewport. If winToScroll is the
544 ** command window do nothing since the term should handle it.
546 if (winToScroll
== srcWin
|| winToScroll
== disassemWin
)
547 tuiHorizontalSourceScroll (winToScroll
, RIGHT_SCROLL
, _numToScroll
);
550 } /* tuiScrollRight */
555 ** Scroll a window. Arguments are passed through a va_list.
558 tui_scroll (TuiScrollDirection direction
,
559 TuiWinInfoPtr winToScroll
,
565 tuiScrollForward (winToScroll
, numToScroll
);
567 case BACKWARD_SCROLL
:
568 tuiScrollBackward (winToScroll
, numToScroll
);
571 tuiScrollLeft (winToScroll
, numToScroll
);
574 tuiScrollRight (winToScroll
, numToScroll
);
590 clearok (curscr
, TRUE
);
591 refreshAll (winList
);
592 for (type
= SRC_WIN
; type
< MAX_MAJOR_WINDOWS
; type
++)
594 if (winList
[type
] && winList
[type
]->generic
.isVisible
)
600 tuiClearWin (&winList
[type
]->generic
);
601 if (winList
[type
]->detail
.sourceInfo
.hasLocator
)
602 tuiClearLocatorDisplay ();
603 tuiShowSourceContent (winList
[type
]);
604 checkAndDisplayHighlightIfNeeded (winList
[type
]);
605 tuiEraseExecInfoContent (winList
[type
]);
606 tuiUpdateExecInfo (winList
[type
]);
609 tuiRefreshDataWin ();
616 tuiClearLocatorDisplay ();
617 tuiShowLocatorContent ();
620 } /* tuiRefreshAll */
625 ** Resize all the windows based on the the terminal size. This
626 ** function gets called from within the readline sinwinch handler.
631 int heightDiff
, widthDiff
;
632 extern int screenheight
, screenwidth
; /* in readline */
634 widthDiff
= screenwidth
- termWidth ();
635 heightDiff
= screenheight
- termHeight ();
636 if (heightDiff
|| widthDiff
)
638 TuiLayoutType curLayout
= currentLayout ();
639 TuiWinInfoPtr winWithFocus
= tuiWinWithFocus ();
640 TuiWinInfoPtr firstWin
, secondWin
;
641 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
643 int i
, newHeight
, splitDiff
, cmdSplitDiff
, numWinsDisplayed
= 2;
645 /* turn keypad off while we resize */
646 if (winWithFocus
!= cmdWin
)
647 keypad (cmdWin
->generic
.handle
, FALSE
);
649 setTermHeightTo (screenheight
);
650 setTermWidthTo (screenwidth
);
651 if (curLayout
== SRC_DISASSEM_COMMAND
||
652 curLayout
== SRC_DATA_COMMAND
|| curLayout
== DISASSEM_DATA_COMMAND
)
654 splitDiff
= heightDiff
/ numWinsDisplayed
;
655 cmdSplitDiff
= splitDiff
;
656 if (heightDiff
% numWinsDisplayed
)
663 /* now adjust each window */
669 case DISASSEM_COMMAND
:
670 firstWin
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
671 firstWin
->generic
.width
+= widthDiff
;
672 locator
->width
+= widthDiff
;
673 /* check for invalid heights */
675 newHeight
= firstWin
->generic
.height
;
676 else if ((firstWin
->generic
.height
+ splitDiff
) >=
677 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
678 newHeight
= screenheight
- MIN_CMD_WIN_HEIGHT
- 1;
679 else if ((firstWin
->generic
.height
+ splitDiff
) <= 0)
680 newHeight
= MIN_WIN_HEIGHT
;
682 newHeight
= firstWin
->generic
.height
+ splitDiff
;
684 _makeInvisibleAndSetNewHeight (firstWin
, newHeight
);
685 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
686 cmdWin
->generic
.width
+= widthDiff
;
687 newHeight
= screenheight
- cmdWin
->generic
.origin
.y
;
688 _makeInvisibleAndSetNewHeight (cmdWin
, newHeight
);
689 _makeVisibleWithNewHeight (firstWin
);
690 _makeVisibleWithNewHeight (cmdWin
);
691 if (firstWin
->generic
.contentSize
<= 0)
692 tuiEraseSourceContent (firstWin
, EMPTY_SOURCE_PROMPT
);
695 if (curLayout
== SRC_DISASSEM_COMMAND
)
698 firstWin
->generic
.width
+= widthDiff
;
699 secondWin
= disassemWin
;
700 secondWin
->generic
.width
+= widthDiff
;
705 firstWin
->generic
.width
+= widthDiff
;
706 secondWin
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
707 secondWin
->generic
.width
+= widthDiff
;
709 /* Change the first window's height/width */
710 /* check for invalid heights */
712 newHeight
= firstWin
->generic
.height
;
713 else if ((firstWin
->generic
.height
+
714 secondWin
->generic
.height
+ (splitDiff
* 2)) >=
715 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
716 newHeight
= (screenheight
- MIN_CMD_WIN_HEIGHT
- 1) / 2;
717 else if ((firstWin
->generic
.height
+ splitDiff
) <= 0)
718 newHeight
= MIN_WIN_HEIGHT
;
720 newHeight
= firstWin
->generic
.height
+ splitDiff
;
721 _makeInvisibleAndSetNewHeight (firstWin
, newHeight
);
723 if (firstWin
== dataWin
&& widthDiff
!= 0)
724 firstWin
->detail
.dataDisplayInfo
.regsColumnCount
=
725 tuiCalculateRegsColumnCount (
726 firstWin
->detail
.dataDisplayInfo
.regsDisplayType
);
727 locator
->width
+= widthDiff
;
729 /* Change the second window's height/width */
730 /* check for invalid heights */
732 newHeight
= secondWin
->generic
.height
;
733 else if ((firstWin
->generic
.height
+
734 secondWin
->generic
.height
+ (splitDiff
* 2)) >=
735 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
737 newHeight
= screenheight
- MIN_CMD_WIN_HEIGHT
- 1;
739 newHeight
= (newHeight
/ 2) + 1;
743 else if ((secondWin
->generic
.height
+ splitDiff
) <= 0)
744 newHeight
= MIN_WIN_HEIGHT
;
746 newHeight
= secondWin
->generic
.height
+ splitDiff
;
747 secondWin
->generic
.origin
.y
= firstWin
->generic
.height
- 1;
748 _makeInvisibleAndSetNewHeight (secondWin
, newHeight
);
750 /* Change the command window's height/width */
751 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
752 _makeInvisibleAndSetNewHeight (
753 cmdWin
, cmdWin
->generic
.height
+ cmdSplitDiff
);
754 _makeVisibleWithNewHeight (firstWin
);
755 _makeVisibleWithNewHeight (secondWin
);
756 _makeVisibleWithNewHeight (cmdWin
);
757 if (firstWin
->generic
.contentSize
<= 0)
758 tuiEraseSourceContent (firstWin
, EMPTY_SOURCE_PROMPT
);
759 if (secondWin
->generic
.contentSize
<= 0)
760 tuiEraseSourceContent (secondWin
, EMPTY_SOURCE_PROMPT
);
764 ** Now remove all invisible windows, and their content so that they get
765 ** created again when called for with the new size
767 for (winType
= SRC_WIN
; (winType
< MAX_MAJOR_WINDOWS
); winType
++)
769 if (winType
!= CMD_WIN
&& m_winPtrNotNull (winList
[winType
]) &&
770 !winList
[winType
]->generic
.isVisible
)
772 freeWindow (winList
[winType
]);
773 winList
[winType
] = (TuiWinInfoPtr
) NULL
;
776 tuiSetWinResizedTo (TRUE
);
777 /* turn keypad back on, unless focus is in the command window */
778 if (winWithFocus
!= cmdWin
)
779 keypad (cmdWin
->generic
.handle
, TRUE
);
786 ** tuiSigwinchHandler()
787 ** SIGWINCH signal handler for the tui. This signal handler is
788 ** always called, even when the readline package clears signals
789 ** because it is set as the old_sigwinch() (TUI only)
792 tuiSigwinchHandler (int signal
)
795 ** Say that a resize was done so that the readline can do it
796 ** later when appropriate.
798 tuiSetWinResizedTo (TRUE
);
801 } /* tuiSigwinchHandler */
805 /*************************
806 ** STATIC LOCAL FUNCTIONS
807 **************************/
811 ** _tuiScrollForward_command().
814 _tuiScrollForward_command (char *arg
, int fromTTY
)
817 TuiWinInfoPtr winToScroll
;
819 /* Make sure the curses mode is enabled. */
821 if (arg
== (char *) NULL
)
822 _parseScrollingArgs (arg
, &winToScroll
, (int *) NULL
);
824 _parseScrollingArgs (arg
, &winToScroll
, &numToScroll
);
825 tui_scroll (FORWARD_SCROLL
, winToScroll
, numToScroll
);
830 ** _tuiScrollBackward_command().
833 _tuiScrollBackward_command (char *arg
, int fromTTY
)
836 TuiWinInfoPtr winToScroll
;
838 /* Make sure the curses mode is enabled. */
840 if (arg
== (char *) NULL
)
841 _parseScrollingArgs (arg
, &winToScroll
, (int *) NULL
);
843 _parseScrollingArgs (arg
, &winToScroll
, &numToScroll
);
844 tui_scroll (BACKWARD_SCROLL
, winToScroll
, numToScroll
);
849 ** _tuiScrollLeft_command().
852 _tuiScrollLeft_command (char *arg
, int fromTTY
)
855 TuiWinInfoPtr winToScroll
;
857 /* Make sure the curses mode is enabled. */
859 _parseScrollingArgs (arg
, &winToScroll
, &numToScroll
);
860 tui_scroll (LEFT_SCROLL
, winToScroll
, numToScroll
);
865 ** _tuiScrollRight_command().
868 _tuiScrollRight_command (char *arg
, int fromTTY
)
871 TuiWinInfoPtr winToScroll
;
873 /* Make sure the curses mode is enabled. */
875 _parseScrollingArgs (arg
, &winToScroll
, &numToScroll
);
876 tui_scroll (RIGHT_SCROLL
, winToScroll
, numToScroll
);
882 ** Set focus to the window named by 'arg'
885 _tuiSetFocus (char *arg
, int fromTTY
)
887 if (arg
!= (char *) NULL
)
889 char *bufPtr
= (char *) xstrdup (arg
);
891 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
893 for (i
= 0; (i
< strlen (bufPtr
)); i
++)
894 bufPtr
[i
] = toupper (arg
[i
]);
896 if (subset_compare (bufPtr
, "NEXT"))
897 winInfo
= tuiNextWin (tuiWinWithFocus ());
898 else if (subset_compare (bufPtr
, "PREV"))
899 winInfo
= tuiPrevWin (tuiWinWithFocus ());
901 winInfo
= partialWinByName (bufPtr
);
903 if (winInfo
== (TuiWinInfoPtr
) NULL
|| !winInfo
->generic
.isVisible
)
904 warning ("Invalid window specified. \n\
905 The window name specified must be valid and visible.\n");
908 tuiSetWinFocusTo (winInfo
);
909 keypad (cmdWin
->generic
.handle
, (winInfo
!= cmdWin
));
912 if (dataWin
&& dataWin
->generic
.isVisible
)
913 tuiRefreshDataWin ();
915 printf_filtered ("Focus set to %s window.\n",
916 winName ((TuiGenWinInfoPtr
) tuiWinWithFocus ()));
919 warning ("Incorrect Number of Arguments.\n%s", FOCUS_USAGE
);
925 ** _tuiSetFocus_command()
928 _tuiSetFocus_command (char *arg
, int fromTTY
)
930 /* Make sure the curses mode is enabled. */
932 _tuiSetFocus (arg
, fromTTY
);
937 ** _tuiAllWindowsInfo().
940 _tuiAllWindowsInfo (char *arg
, int fromTTY
)
943 TuiWinInfoPtr winWithFocus
= tuiWinWithFocus ();
945 for (type
= SRC_WIN
; (type
< MAX_MAJOR_WINDOWS
); type
++)
946 if (winList
[type
]->generic
.isVisible
)
948 if (winWithFocus
== winList
[type
])
949 printf_filtered (" %s\t(%d lines) <has focus>\n",
950 winName (&winList
[type
]->generic
),
951 winList
[type
]->generic
.height
);
953 printf_filtered (" %s\t(%d lines)\n",
954 winName (&winList
[type
]->generic
),
955 winList
[type
]->generic
.height
);
959 } /* _tuiAllWindowsInfo */
963 ** _tuiRefreshAll_command().
966 _tuiRefreshAll_command (char *arg
, int fromTTY
)
968 /* Make sure the curses mode is enabled. */
976 ** _tuiSetWinTabWidth_command().
977 ** Set the height of the specified window.
980 _tuiSetTabWidth_command (char *arg
, int fromTTY
)
982 /* Make sure the curses mode is enabled. */
984 if (arg
!= (char *) NULL
)
990 tuiSetDefaultTabLen (ts
);
992 warning ("Tab widths greater than 0 must be specified.\n");
996 } /* _tuiSetTabWidth_command */
1000 ** _tuiSetWinHeight().
1001 ** Set the height of the specified window.
1004 _tuiSetWinHeight (char *arg
, int fromTTY
)
1006 /* Make sure the curses mode is enabled. */
1008 if (arg
!= (char *) NULL
)
1010 char *buf
= xstrdup (arg
);
1012 char *wname
= (char *) NULL
;
1014 TuiWinInfoPtr winInfo
;
1017 bufPtr
= strchr (bufPtr
, ' ');
1018 if (bufPtr
!= (char *) NULL
)
1023 ** Validate the window name
1025 for (i
= 0; i
< strlen (wname
); i
++)
1026 wname
[i
] = toupper (wname
[i
]);
1027 winInfo
= partialWinByName (wname
);
1029 if (winInfo
== (TuiWinInfoPtr
) NULL
|| !winInfo
->generic
.isVisible
)
1030 warning ("Invalid window specified. \n\
1031 The window name specified must be valid and visible.\n");
1034 /* Process the size */
1035 while (*(++bufPtr
) == ' ')
1038 if (*bufPtr
!= (char) 0)
1041 int fixedSize
= TRUE
;
1044 if (*bufPtr
== '+' || *bufPtr
== '-')
1051 inputNo
= atoi (bufPtr
);
1057 newHeight
= inputNo
;
1059 newHeight
= winInfo
->generic
.height
+ inputNo
;
1061 ** Now change the window's height, and adjust all
1062 ** other windows around it
1064 if (_tuiAdjustWinHeights (winInfo
,
1065 newHeight
) == TUI_FAILURE
)
1066 warning ("Invalid window height specified.\n%s",
1072 warning ("Invalid window height specified.\n%s",
1078 printf_filtered (WIN_HEIGHT_USAGE
);
1080 if (buf
!= (char *) NULL
)
1084 printf_filtered (WIN_HEIGHT_USAGE
);
1087 } /* _tuiSetWinHeight */
1090 ** _tuiSetWinHeight_command().
1091 ** Set the height of the specified window, with va_list.
1094 _tuiSetWinHeight_command (char *arg
, int fromTTY
)
1096 /* Make sure the curses mode is enabled. */
1098 _tuiSetWinHeight (arg
, fromTTY
);
1103 ** _tuiXDBsetWinHeight().
1104 ** XDB Compatibility command for setting the window height. This will
1105 ** increase or decrease the command window by the specified amount.
1108 _tuiXDBsetWinHeight (char *arg
, int fromTTY
)
1110 /* Make sure the curses mode is enabled. */
1112 if (arg
!= (char *) NULL
)
1114 int inputNo
= atoi (arg
);
1117 { /* Add 1 for the locator */
1118 int newHeight
= termHeight () - (inputNo
+ 1);
1120 if (!_newHeightOk (winList
[CMD_WIN
], newHeight
) ||
1121 _tuiAdjustWinHeights (winList
[CMD_WIN
],
1122 newHeight
) == TUI_FAILURE
)
1123 warning ("Invalid window height specified.\n%s",
1124 XDBWIN_HEIGHT_USAGE
);
1127 warning ("Invalid window height specified.\n%s",
1128 XDBWIN_HEIGHT_USAGE
);
1131 warning ("Invalid window height specified.\n%s", XDBWIN_HEIGHT_USAGE
);
1134 } /* _tuiXDBsetWinHeight */
1137 ** _tuiSetWinHeight_command().
1138 ** Set the height of the specified window, with va_list.
1141 _tuiXDBsetWinHeight_command (char *arg
, int fromTTY
)
1143 _tuiXDBsetWinHeight (arg
, fromTTY
);
1148 ** _tuiAdjustWinHeights().
1149 ** Function to adjust all window heights around the primary
1152 _tuiAdjustWinHeights (TuiWinInfoPtr primaryWinInfo
, int newHeight
)
1154 TuiStatus status
= TUI_FAILURE
;
1156 if (_newHeightOk (primaryWinInfo
, newHeight
))
1158 status
= TUI_SUCCESS
;
1159 if (newHeight
!= primaryWinInfo
->generic
.height
)
1162 TuiWinInfoPtr winInfo
;
1163 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
1164 TuiLayoutType curLayout
= currentLayout ();
1166 diff
= (newHeight
- primaryWinInfo
->generic
.height
) * (-1);
1167 if (curLayout
== SRC_COMMAND
|| curLayout
== DISASSEM_COMMAND
)
1169 TuiWinInfoPtr srcWinInfo
;
1171 _makeInvisibleAndSetNewHeight (primaryWinInfo
, newHeight
);
1172 if (primaryWinInfo
->generic
.type
== CMD_WIN
)
1174 winInfo
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1175 srcWinInfo
= winInfo
;
1179 winInfo
= winList
[CMD_WIN
];
1180 srcWinInfo
= primaryWinInfo
;
1182 _makeInvisibleAndSetNewHeight (winInfo
,
1183 winInfo
->generic
.height
+ diff
);
1184 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1185 _makeVisibleWithNewHeight (winInfo
);
1186 _makeVisibleWithNewHeight (primaryWinInfo
);
1187 if (srcWinInfo
->generic
.contentSize
<= 0)
1188 tuiEraseSourceContent (srcWinInfo
, EMPTY_SOURCE_PROMPT
);
1192 TuiWinInfoPtr firstWin
, secondWin
;
1194 if (curLayout
== SRC_DISASSEM_COMMAND
)
1197 secondWin
= disassemWin
;
1202 secondWin
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1204 if (primaryWinInfo
== cmdWin
)
1206 ** Split the change in height accross the 1st & 2nd windows
1207 ** adjusting them as well.
1209 int firstSplitDiff
= diff
/ 2; /* subtract the locator */
1210 int secondSplitDiff
= firstSplitDiff
;
1214 if (firstWin
->generic
.height
>
1215 secondWin
->generic
.height
)
1228 /* make sure that the minimum hieghts are honored */
1229 while ((firstWin
->generic
.height
+ firstSplitDiff
) < 3)
1234 while ((secondWin
->generic
.height
+ secondSplitDiff
) < 3)
1239 _makeInvisibleAndSetNewHeight (
1241 firstWin
->generic
.height
+ firstSplitDiff
);
1242 secondWin
->generic
.origin
.y
= firstWin
->generic
.height
- 1;
1243 _makeInvisibleAndSetNewHeight (
1244 secondWin
, secondWin
->generic
.height
+ secondSplitDiff
);
1245 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1246 _makeInvisibleAndSetNewHeight (cmdWin
, newHeight
);
1250 if ((cmdWin
->generic
.height
+ diff
) < 1)
1252 ** If there is no way to increase the command window
1253 ** take real estate from the 1st or 2nd window.
1255 if ((cmdWin
->generic
.height
+ diff
) < 1)
1258 for (i
= cmdWin
->generic
.height
+ diff
;
1260 if (primaryWinInfo
== firstWin
)
1261 secondWin
->generic
.height
--;
1263 firstWin
->generic
.height
--;
1266 if (primaryWinInfo
== firstWin
)
1267 _makeInvisibleAndSetNewHeight (firstWin
, newHeight
);
1269 _makeInvisibleAndSetNewHeight (
1271 firstWin
->generic
.height
);
1272 secondWin
->generic
.origin
.y
= firstWin
->generic
.height
- 1;
1273 if (primaryWinInfo
== secondWin
)
1274 _makeInvisibleAndSetNewHeight (secondWin
, newHeight
);
1276 _makeInvisibleAndSetNewHeight (
1277 secondWin
, secondWin
->generic
.height
);
1278 cmdWin
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1279 if ((cmdWin
->generic
.height
+ diff
) < 1)
1280 _makeInvisibleAndSetNewHeight (cmdWin
, 1);
1282 _makeInvisibleAndSetNewHeight (
1283 cmdWin
, cmdWin
->generic
.height
+ diff
);
1285 _makeVisibleWithNewHeight (cmdWin
);
1286 _makeVisibleWithNewHeight (secondWin
);
1287 _makeVisibleWithNewHeight (firstWin
);
1288 if (firstWin
->generic
.contentSize
<= 0)
1289 tuiEraseSourceContent (firstWin
, EMPTY_SOURCE_PROMPT
);
1290 if (secondWin
->generic
.contentSize
<= 0)
1291 tuiEraseSourceContent (secondWin
, EMPTY_SOURCE_PROMPT
);
1297 } /* _tuiAdjustWinHeights */
1301 ** _makeInvisibleAndSetNewHeight().
1302 ** Function make the target window (and auxillary windows associated
1303 ** with the targer) invisible, and set the new height and location.
1306 _makeInvisibleAndSetNewHeight (TuiWinInfoPtr winInfo
, int height
)
1310 TuiGenWinInfoPtr genWinInfo
;
1313 m_beInvisible (&winInfo
->generic
);
1314 winInfo
->generic
.height
= height
;
1316 winInfo
->generic
.viewportHeight
= height
- 1;
1318 winInfo
->generic
.viewportHeight
= height
;
1319 if (winInfo
!= cmdWin
)
1320 winInfo
->generic
.viewportHeight
--;
1322 /* Now deal with the auxillary windows associated with winInfo */
1323 switch (winInfo
->generic
.type
)
1327 genWinInfo
= winInfo
->detail
.sourceInfo
.executionInfo
;
1328 m_beInvisible (genWinInfo
);
1329 genWinInfo
->height
= height
;
1330 genWinInfo
->origin
.y
= winInfo
->generic
.origin
.y
;
1332 genWinInfo
->viewportHeight
= height
- 1;
1334 genWinInfo
->viewportHeight
= height
;
1335 if (winInfo
!= cmdWin
)
1336 genWinInfo
->viewportHeight
--;
1338 if (m_hasLocator (winInfo
))
1340 genWinInfo
= locatorWinInfoPtr ();
1341 m_beInvisible (genWinInfo
);
1342 genWinInfo
->origin
.y
= winInfo
->generic
.origin
.y
+ height
;
1346 /* delete all data item windows */
1347 for (i
= 0; i
< winInfo
->generic
.contentSize
; i
++)
1349 genWinInfo
= (TuiGenWinInfoPtr
) & ((TuiWinElementPtr
)
1350 winInfo
->generic
.content
[i
])->whichElement
.dataWindow
;
1351 tuiDelwin (genWinInfo
->handle
);
1352 genWinInfo
->handle
= (WINDOW
*) NULL
;
1360 } /* _makeInvisibleAndSetNewHeight */
1364 ** _makeVisibleWithNewHeight().
1365 ** Function to make the windows with new heights visible.
1366 ** This means re-creating the windows' content since the window
1367 ** had to be destroyed to be made invisible.
1370 _makeVisibleWithNewHeight (TuiWinInfoPtr winInfo
)
1375 m_beVisible (&winInfo
->generic
);
1376 checkAndDisplayHighlightIfNeeded (winInfo
);
1377 switch (winInfo
->generic
.type
)
1381 freeWinContent (winInfo
->detail
.sourceInfo
.executionInfo
);
1382 m_beVisible (winInfo
->detail
.sourceInfo
.executionInfo
);
1383 if (winInfo
->generic
.content
!= (OpaquePtr
) NULL
)
1385 TuiLineOrAddress lineOrAddr
;
1387 if (winInfo
->generic
.type
== SRC_WIN
)
1389 winInfo
->detail
.sourceInfo
.startLineOrAddr
.lineNo
;
1392 winInfo
->detail
.sourceInfo
.startLineOrAddr
.addr
;
1393 freeWinContent (&winInfo
->generic
);
1394 tuiUpdateSourceWindow (winInfo
,
1395 current_source_symtab
, lineOrAddr
, TRUE
);
1397 else if (selected_frame
!= (struct frame_info
*) NULL
)
1399 TuiLineOrAddress line
;
1400 extern int current_source_line
;
1402 s
= find_pc_symtab (selected_frame
->pc
);
1403 if (winInfo
->generic
.type
== SRC_WIN
)
1404 line
.lineNo
= current_source_line
;
1407 find_line_pc (s
, current_source_line
, &line
.addr
);
1409 tuiUpdateSourceWindow (winInfo
, s
, line
, TRUE
);
1411 if (m_hasLocator (winInfo
))
1413 m_beVisible (locatorWinInfoPtr ());
1414 tuiClearLocatorDisplay ();
1415 tuiShowLocatorContent ();
1419 tuiDisplayAllData ();
1422 winInfo
->detail
.commandInfo
.curLine
= 0;
1423 winInfo
->detail
.commandInfo
.curch
= 0;
1424 wmove (winInfo
->generic
.handle
,
1425 winInfo
->detail
.commandInfo
.curLine
,
1426 winInfo
->detail
.commandInfo
.curch
);
1433 } /* _makeVisibleWithNewHeight */
1437 _newHeightOk (TuiWinInfoPtr primaryWinInfo
, int newHeight
)
1439 int ok
= (newHeight
< termHeight ());
1443 int diff
, curHeight
;
1444 TuiLayoutType curLayout
= currentLayout ();
1446 diff
= (newHeight
- primaryWinInfo
->generic
.height
) * (-1);
1447 if (curLayout
== SRC_COMMAND
|| curLayout
== DISASSEM_COMMAND
)
1449 ok
= ((primaryWinInfo
->generic
.type
== CMD_WIN
&&
1450 newHeight
<= (termHeight () - 4) &&
1451 newHeight
>= MIN_CMD_WIN_HEIGHT
) ||
1452 (primaryWinInfo
->generic
.type
!= CMD_WIN
&&
1453 newHeight
<= (termHeight () - 2) &&
1454 newHeight
>= MIN_WIN_HEIGHT
));
1456 { /* check the total height */
1457 TuiWinInfoPtr winInfo
;
1459 if (primaryWinInfo
== cmdWin
)
1460 winInfo
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1464 (winInfo
->generic
.height
+ diff
)) <= termHeight ());
1469 int curTotalHeight
, totalHeight
, minHeight
;
1470 TuiWinInfoPtr firstWin
, secondWin
;
1472 if (curLayout
== SRC_DISASSEM_COMMAND
)
1475 secondWin
= disassemWin
;
1480 secondWin
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1483 ** We could simply add all the heights to obtain the same result
1484 ** but below is more explicit since we subtract 1 for the
1485 ** line that the first and second windows share, and add one
1489 (firstWin
->generic
.height
+ secondWin
->generic
.height
- 1)
1490 + cmdWin
->generic
.height
+ 1 /*locator */ ;
1491 if (primaryWinInfo
== cmdWin
)
1493 /* locator included since first & second win share a line */
1494 ok
= ((firstWin
->generic
.height
+
1495 secondWin
->generic
.height
+ diff
) >=
1496 (MIN_WIN_HEIGHT
* 2) &&
1497 newHeight
>= MIN_CMD_WIN_HEIGHT
);
1500 totalHeight
= newHeight
+ (firstWin
->generic
.height
+
1501 secondWin
->generic
.height
+ diff
);
1502 minHeight
= MIN_CMD_WIN_HEIGHT
;
1507 minHeight
= MIN_WIN_HEIGHT
;
1509 ** First see if we can increase/decrease the command
1510 ** window. And make sure that the command window is
1513 ok
= ((cmdWin
->generic
.height
+ diff
) > 0);
1516 ** Looks like we have to increase/decrease one of
1517 ** the other windows
1519 if (primaryWinInfo
== firstWin
)
1520 ok
= (secondWin
->generic
.height
+ diff
) >= minHeight
;
1522 ok
= (firstWin
->generic
.height
+ diff
) >= minHeight
;
1526 if (primaryWinInfo
== firstWin
)
1527 totalHeight
= newHeight
+
1528 secondWin
->generic
.height
+
1529 cmdWin
->generic
.height
+ diff
;
1531 totalHeight
= newHeight
+
1532 firstWin
->generic
.height
+
1533 cmdWin
->generic
.height
+ diff
;
1537 ** Now make sure that the proposed total height doesn't exceed
1538 ** the old total height.
1541 ok
= (newHeight
>= minHeight
&& totalHeight
<= curTotalHeight
);
1546 } /* _newHeightOk */
1550 ** _parseScrollingArgs().
1553 _parseScrollingArgs (char *arg
, TuiWinInfoPtr
* winToScroll
, int *numToScroll
)
1557 *winToScroll
= tuiWinWithFocus ();
1560 ** First set up the default window to scroll, in case there is no
1563 if (arg
!= (char *) NULL
)
1567 /* process the number of lines to scroll */
1568 buf
= bufPtr
= xstrdup (arg
);
1569 if (isdigit (*bufPtr
))
1574 bufPtr
= strchr (bufPtr
, ' ');
1575 if (bufPtr
!= (char *) NULL
)
1579 *numToScroll
= atoi (numStr
);
1582 else if (numToScroll
)
1583 *numToScroll
= atoi (numStr
);
1586 /* process the window name if one is specified */
1587 if (bufPtr
!= (char *) NULL
)
1593 while (*(++bufPtr
) == ' ')
1596 if (*bufPtr
!= (char) 0)
1601 /* Validate the window name */
1602 for (i
= 0; i
< strlen (wname
); i
++)
1603 wname
[i
] = toupper (wname
[i
]);
1604 *winToScroll
= partialWinByName (wname
);
1606 if (*winToScroll
== (TuiWinInfoPtr
) NULL
||
1607 !(*winToScroll
)->generic
.isVisible
)
1608 warning ("Invalid window specified. \n\
1609 The window name specified must be valid and visible.\n");
1610 else if (*winToScroll
== cmdWin
)
1611 *winToScroll
= (TuiWinInfoPtr
) (sourceWindows ())->list
[0];
1617 } /* _parseScrollingArgs */