1 /* TUI window generic functions.
3 Copyright (C) 1998-2015 Free Software Foundation, Inc.
5 Contributed by Hewlett-Packard Company.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 /* This module contains procedures for handling tui window functions
23 like resize, scrolling, scrolling, changing focus, etc.
25 Author: Susan B. Macchia */
30 #include "breakpoint.h"
32 #include "cli/cli-cmds.h"
35 #include "event-loop.h"
38 #include "tui/tui-io.h"
39 #include "tui/tui-data.h"
40 #include "tui/tui-wingeneral.h"
41 #include "tui/tui-stack.h"
42 #include "tui/tui-regs.h"
43 #include "tui/tui-disasm.h"
44 #include "tui/tui-source.h"
45 #include "tui/tui-winsource.h"
46 #include "tui/tui-windata.h"
47 #include "tui/tui-win.h"
49 #include "gdb_curses.h"
51 #include "readline/readline.h"
55 /*******************************
57 ********************************/
58 static void make_visible_with_new_height (struct tui_win_info
*);
59 static void make_invisible_and_set_new_height (struct tui_win_info
*,
61 static enum tui_status
tui_adjust_win_heights (struct tui_win_info
*,
63 static int new_height_ok (struct tui_win_info
*, int);
64 static void tui_set_tab_width_command (char *, int);
65 static void tui_refresh_all_command (char *, int);
66 static void tui_set_win_height_command (char *, int);
67 static void tui_xdb_set_win_height_command (char *, int);
68 static void tui_all_windows_info (char *, int);
69 static void tui_set_focus_command (char *, int);
70 static void tui_scroll_forward_command (char *, int);
71 static void tui_scroll_backward_command (char *, int);
72 static void tui_scroll_left_command (char *, int);
73 static void tui_scroll_right_command (char *, int);
74 static void parse_scrolling_args (char *,
75 struct tui_win_info
**,
79 /***************************************
81 ***************************************/
82 #define WIN_HEIGHT_USAGE "Usage: winheight <win_name> [+ | -] <#lines>\n"
83 #define XDBWIN_HEIGHT_USAGE "Usage: w <#lines>\n"
84 #define FOCUS_USAGE "Usage: focus {<win> | next | prev}\n"
86 /***************************************
88 ***************************************/
91 # define ACS_LRCORNER '+'
94 # define ACS_LLCORNER '+'
97 # define ACS_ULCORNER '+'
100 # define ACS_URCORNER '+'
103 # define ACS_HLINE '-'
106 # define ACS_VLINE '|'
109 /* Possible values for tui-border-kind variable. */
110 static const char *const tui_border_kind_enums
[] = {
117 /* Possible values for tui-border-mode and tui-active-border-mode. */
118 static const char *const tui_border_mode_enums
[] = {
135 /* Translation table for border-mode variables.
136 The list of values must be terminated by a NULL.
137 After the NULL value, an entry defines the default. */
138 struct tui_translate tui_border_mode_translate
[] = {
139 { "normal", A_NORMAL
},
140 { "standout", A_STANDOUT
},
141 { "reverse", A_REVERSE
},
143 { "half-standout", A_DIM
| A_STANDOUT
},
145 { "bold-standout", A_BOLD
| A_STANDOUT
},
147 { "normal", A_NORMAL
}
150 /* Translation tables for border-kind, one for each border
151 character (see wborder, border curses operations).
152 -1 is used to indicate the ACS because ACS characters
153 are determined at run time by curses (depends on terminal). */
154 struct tui_translate tui_border_kind_translate_vline
[] = {
162 struct tui_translate tui_border_kind_translate_hline
[] = {
170 struct tui_translate tui_border_kind_translate_ulcorner
[] = {
178 struct tui_translate tui_border_kind_translate_urcorner
[] = {
186 struct tui_translate tui_border_kind_translate_llcorner
[] = {
194 struct tui_translate tui_border_kind_translate_lrcorner
[] = {
203 /* Tui configuration variables controlled with set/show command. */
204 const char *tui_active_border_mode
= "bold-standout";
206 show_tui_active_border_mode (struct ui_file
*file
,
208 struct cmd_list_element
*c
,
211 fprintf_filtered (file
, _("\
212 The attribute mode to use for the active TUI window border is \"%s\".\n"),
216 const char *tui_border_mode
= "normal";
218 show_tui_border_mode (struct ui_file
*file
,
220 struct cmd_list_element
*c
,
223 fprintf_filtered (file
, _("\
224 The attribute mode to use for the TUI window borders is \"%s\".\n"),
228 const char *tui_border_kind
= "acs";
230 show_tui_border_kind (struct ui_file
*file
,
232 struct cmd_list_element
*c
,
235 fprintf_filtered (file
, _("The kind of border for TUI windows is \"%s\".\n"),
240 /* Tui internal configuration variables. These variables are updated
241 by tui_update_variables to reflect the tui configuration
243 chtype tui_border_vline
;
244 chtype tui_border_hline
;
245 chtype tui_border_ulcorner
;
246 chtype tui_border_urcorner
;
247 chtype tui_border_llcorner
;
248 chtype tui_border_lrcorner
;
250 int tui_border_attrs
;
251 int tui_active_border_attrs
;
253 /* Identify the item in the translation table.
254 When the item is not recognized, use the default entry. */
255 static struct tui_translate
*
256 translate (const char *name
, struct tui_translate
*table
)
260 if (name
&& strcmp (table
->name
, name
) == 0)
265 /* Not found, return default entry. */
270 /* Update the tui internal configuration according to gdb settings.
271 Returns 1 if the configuration has changed and the screen should
274 tui_update_variables (void)
277 struct tui_translate
*entry
;
279 entry
= translate (tui_border_mode
, tui_border_mode_translate
);
280 if (tui_border_attrs
!= entry
->value
)
282 tui_border_attrs
= entry
->value
;
285 entry
= translate (tui_active_border_mode
, tui_border_mode_translate
);
286 if (tui_active_border_attrs
!= entry
->value
)
288 tui_active_border_attrs
= entry
->value
;
292 /* If one corner changes, all characters are changed.
293 Only check the first one. The ACS characters are determined at
294 run time by curses terminal management. */
295 entry
= translate (tui_border_kind
, tui_border_kind_translate_lrcorner
);
296 if (tui_border_lrcorner
!= (chtype
) entry
->value
)
298 tui_border_lrcorner
= (entry
->value
< 0) ? ACS_LRCORNER
: entry
->value
;
301 entry
= translate (tui_border_kind
, tui_border_kind_translate_llcorner
);
302 tui_border_llcorner
= (entry
->value
< 0) ? ACS_LLCORNER
: entry
->value
;
304 entry
= translate (tui_border_kind
, tui_border_kind_translate_ulcorner
);
305 tui_border_ulcorner
= (entry
->value
< 0) ? ACS_ULCORNER
: entry
->value
;
307 entry
= translate (tui_border_kind
, tui_border_kind_translate_urcorner
);
308 tui_border_urcorner
= (entry
->value
< 0) ? ACS_URCORNER
: entry
->value
;
310 entry
= translate (tui_border_kind
, tui_border_kind_translate_hline
);
311 tui_border_hline
= (entry
->value
< 0) ? ACS_HLINE
: entry
->value
;
313 entry
= translate (tui_border_kind
, tui_border_kind_translate_vline
);
314 tui_border_vline
= (entry
->value
< 0) ? ACS_VLINE
: entry
->value
;
320 set_tui_cmd (char *args
, int from_tty
)
325 show_tui_cmd (char *args
, int from_tty
)
329 static struct cmd_list_element
*tuilist
;
332 tui_command (char *args
, int from_tty
)
334 printf_unfiltered (_("\"tui\" must be followed by the name of a "
336 help_list (tuilist
, "tui ", all_commands
, gdb_stdout
);
339 struct cmd_list_element
**
340 tui_get_cmd_list (void)
343 add_prefix_cmd ("tui", class_tui
, tui_command
,
344 _("Text User Interface commands."),
345 &tuilist
, "tui ", 0, &cmdlist
);
349 /* The set_func hook of "set tui ..." commands that affect the window
350 borders on the TUI display. */
352 tui_set_var_cmd (char *null_args
, int from_tty
, struct cmd_list_element
*c
)
354 if (tui_update_variables () && tui_active
)
355 tui_rehighlight_all ();
358 /* Function to initialize gdb commands, for tui window
361 /* Provide a prototype to silence -Wmissing-prototypes. */
362 extern initialize_file_ftype _initialize_tui_win
;
365 _initialize_tui_win (void)
367 static struct cmd_list_element
*tui_setlist
;
368 static struct cmd_list_element
*tui_showlist
;
370 /* Define the classes of commands.
371 They will appear in the help list in the reverse of this order. */
372 add_prefix_cmd ("tui", class_tui
, set_tui_cmd
,
373 _("TUI configuration variables"),
374 &tui_setlist
, "set tui ",
375 0 /* allow-unknown */, &setlist
);
376 add_prefix_cmd ("tui", class_tui
, show_tui_cmd
,
377 _("TUI configuration variables"),
378 &tui_showlist
, "show tui ",
379 0 /* allow-unknown */, &showlist
);
381 add_com ("refresh", class_tui
, tui_refresh_all_command
,
382 _("Refresh the terminal display.\n"));
384 add_com_alias ("U", "refresh", class_tui
, 0);
385 add_com ("tabset", class_tui
, tui_set_tab_width_command
, _("\
386 Set the width (in characters) of tab stops.\n\
387 Usage: tabset <n>\n"));
388 add_com ("winheight", class_tui
, tui_set_win_height_command
, _("\
389 Set the height of a specified window.\n\
390 Usage: winheight <win_name> [+ | -] <#lines>\n\
392 src : the source window\n\
393 cmd : the command window\n\
394 asm : the disassembly window\n\
395 regs : the register display\n"));
396 add_com_alias ("wh", "winheight", class_tui
, 0);
397 add_info ("win", tui_all_windows_info
,
398 _("List of all displayed windows.\n"));
399 add_com ("focus", class_tui
, tui_set_focus_command
, _("\
400 Set focus to named window or next/prev window.\n\
401 Usage: focus {<win> | next | prev}\n\
402 Valid Window names are:\n\
403 src : the source window\n\
404 asm : the disassembly window\n\
405 regs : the register display\n\
406 cmd : the command window\n"));
407 add_com_alias ("fs", "focus", class_tui
, 0);
408 add_com ("+", class_tui
, tui_scroll_forward_command
, _("\
409 Scroll window forward.\n\
410 Usage: + [win] [n]\n"));
411 add_com ("-", class_tui
, tui_scroll_backward_command
, _("\
412 Scroll window backward.\n\
413 Usage: - [win] [n]\n"));
414 add_com ("<", class_tui
, tui_scroll_left_command
, _("\
415 Scroll window text to the left.\n\
416 Usage: < [win] [n]\n"));
417 add_com (">", class_tui
, tui_scroll_right_command
, _("\
418 Scroll window text to the right.\n\
419 Usage: > [win] [n]\n"));
421 add_com ("w", class_xdb
, tui_xdb_set_win_height_command
, _("\
422 XDB compatibility command for setting the height of a command window.\n\
423 Usage: w <#lines>\n"));
425 /* Define the tui control variables. */
426 add_setshow_enum_cmd ("border-kind", no_class
, tui_border_kind_enums
,
427 &tui_border_kind
, _("\
428 Set the kind of border for TUI windows."), _("\
429 Show the kind of border for TUI windows."), _("\
430 This variable controls the border of TUI windows:\n\
431 space use a white space\n\
432 ascii use ascii characters + - | for the border\n\
433 acs use the Alternate Character Set"),
435 show_tui_border_kind
,
436 &tui_setlist
, &tui_showlist
);
438 add_setshow_enum_cmd ("border-mode", no_class
, tui_border_mode_enums
,
439 &tui_border_mode
, _("\
440 Set the attribute mode to use for the TUI window borders."), _("\
441 Show the attribute mode to use for the TUI window borders."), _("\
442 This variable controls the attributes to use for the window borders:\n\
443 normal normal display\n\
444 standout use highlight mode of terminal\n\
445 reverse use reverse video mode\n\
446 half use half bright\n\
447 half-standout use half bright and standout mode\n\
448 bold use extra bright or bold\n\
449 bold-standout use extra bright or bold with standout mode"),
451 show_tui_border_mode
,
452 &tui_setlist
, &tui_showlist
);
454 add_setshow_enum_cmd ("active-border-mode", no_class
, tui_border_mode_enums
,
455 &tui_active_border_mode
, _("\
456 Set the attribute mode to use for the active TUI window border."), _("\
457 Show the attribute mode to use for the active TUI window border."), _("\
458 This variable controls the attributes to use for the active window border:\n\
459 normal normal display\n\
460 standout use highlight mode of terminal\n\
461 reverse use reverse video mode\n\
462 half use half bright\n\
463 half-standout use half bright and standout mode\n\
464 bold use extra bright or bold\n\
465 bold-standout use extra bright or bold with standout mode"),
467 show_tui_active_border_mode
,
468 &tui_setlist
, &tui_showlist
);
471 /* Update gdb's knowledge of the terminal size. */
473 tui_update_gdb_sizes (void)
477 /* Set to TUI command window dimension or use readline values. */
478 xsnprintf (cmd
, sizeof (cmd
), "set width %d",
479 tui_active
? TUI_CMD_WIN
->generic
.width
: tui_term_width());
480 execute_command (cmd
, 0);
481 xsnprintf (cmd
, sizeof (cmd
), "set height %d",
482 tui_active
? TUI_CMD_WIN
->generic
.height
: tui_term_height());
483 execute_command (cmd
, 0);
487 /* Set the logical focus to win_info. */
489 tui_set_win_focus_to (struct tui_win_info
*win_info
)
491 if (win_info
!= NULL
)
493 struct tui_win_info
*win_with_focus
= tui_win_with_focus ();
495 if (win_with_focus
!= NULL
496 && win_with_focus
->generic
.type
!= CMD_WIN
)
497 tui_unhighlight_win (win_with_focus
);
498 tui_set_win_with_focus (win_info
);
499 if (win_info
->generic
.type
!= CMD_WIN
)
500 tui_highlight_win (win_info
);
506 tui_scroll_forward (struct tui_win_info
*win_to_scroll
,
509 if (win_to_scroll
!= TUI_CMD_WIN
)
511 int _num_to_scroll
= num_to_scroll
;
513 if (num_to_scroll
== 0)
514 _num_to_scroll
= win_to_scroll
->generic
.height
- 3;
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 win_to_scroll is the
519 command window do nothing since the term should handle
521 if (win_to_scroll
== TUI_SRC_WIN
)
522 tui_vertical_source_scroll (FORWARD_SCROLL
, _num_to_scroll
);
523 else if (win_to_scroll
== TUI_DISASM_WIN
)
524 tui_vertical_disassem_scroll (FORWARD_SCROLL
, _num_to_scroll
);
525 else if (win_to_scroll
== TUI_DATA_WIN
)
526 tui_vertical_data_scroll (FORWARD_SCROLL
, _num_to_scroll
);
531 tui_scroll_backward (struct tui_win_info
*win_to_scroll
,
534 if (win_to_scroll
!= TUI_CMD_WIN
)
536 int _num_to_scroll
= num_to_scroll
;
538 if (num_to_scroll
== 0)
539 _num_to_scroll
= win_to_scroll
->generic
.height
- 3;
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 win_to_scroll is the
544 command window do nothing since the term should handle
546 if (win_to_scroll
== TUI_SRC_WIN
)
547 tui_vertical_source_scroll (BACKWARD_SCROLL
, _num_to_scroll
);
548 else if (win_to_scroll
== TUI_DISASM_WIN
)
549 tui_vertical_disassem_scroll (BACKWARD_SCROLL
, _num_to_scroll
);
550 else if (win_to_scroll
== TUI_DATA_WIN
)
551 tui_vertical_data_scroll (BACKWARD_SCROLL
, _num_to_scroll
);
557 tui_scroll_left (struct tui_win_info
*win_to_scroll
,
560 if (win_to_scroll
!= TUI_CMD_WIN
)
562 int _num_to_scroll
= num_to_scroll
;
564 if (_num_to_scroll
== 0)
567 /* If we are scrolling the source or disassembly window, do a
568 "psuedo" scroll since not all of the source is in memory,
569 only what is in the viewport. If win_to_scroll is the command
570 window do nothing since the term should handle it. */
571 if (win_to_scroll
== TUI_SRC_WIN
572 || win_to_scroll
== TUI_DISASM_WIN
)
573 tui_horizontal_source_scroll (win_to_scroll
, LEFT_SCROLL
,
580 tui_scroll_right (struct tui_win_info
*win_to_scroll
,
583 if (win_to_scroll
!= TUI_CMD_WIN
)
585 int _num_to_scroll
= num_to_scroll
;
587 if (_num_to_scroll
== 0)
590 /* If we are scrolling the source or disassembly window, do a
591 "psuedo" scroll since not all of the source is in memory,
592 only what is in the viewport. If win_to_scroll is the command
593 window do nothing since the term should handle it. */
594 if (win_to_scroll
== TUI_SRC_WIN
595 || win_to_scroll
== TUI_DISASM_WIN
)
596 tui_horizontal_source_scroll (win_to_scroll
, RIGHT_SCROLL
,
602 /* Scroll a window. Arguments are passed through a va_list. */
604 tui_scroll (enum tui_scroll_direction direction
,
605 struct tui_win_info
*win_to_scroll
,
611 tui_scroll_forward (win_to_scroll
, num_to_scroll
);
613 case BACKWARD_SCROLL
:
614 tui_scroll_backward (win_to_scroll
, num_to_scroll
);
617 tui_scroll_left (win_to_scroll
, num_to_scroll
);
620 tui_scroll_right (win_to_scroll
, num_to_scroll
);
629 tui_refresh_all_win (void)
633 clearok (curscr
, TRUE
);
634 tui_refresh_all (tui_win_list
);
635 for (type
= SRC_WIN
; type
< MAX_MAJOR_WINDOWS
; type
++)
637 if (tui_win_list
[type
]
638 && tui_win_list
[type
]->generic
.is_visible
)
644 tui_show_source_content (tui_win_list
[type
]);
645 tui_check_and_display_highlight_if_needed (tui_win_list
[type
]);
646 tui_erase_exec_info_content (tui_win_list
[type
]);
647 tui_update_exec_info (tui_win_list
[type
]);
650 tui_refresh_data_win ();
657 tui_show_locator_content ();
661 tui_rehighlight_all (void)
665 for (type
= SRC_WIN
; type
< MAX_MAJOR_WINDOWS
; type
++)
666 tui_check_and_display_highlight_if_needed (tui_win_list
[type
]);
669 /* Resize all the windows based on the terminal size. This function
670 gets called from within the readline sinwinch handler. */
672 tui_resize_all (void)
674 int height_diff
, width_diff
;
675 int screenheight
, screenwidth
;
677 rl_get_screen_size (&screenheight
, &screenwidth
);
678 width_diff
= screenwidth
- tui_term_width ();
679 height_diff
= screenheight
- tui_term_height ();
680 if (height_diff
|| width_diff
)
682 enum tui_layout_type cur_layout
= tui_current_layout ();
683 struct tui_win_info
*win_with_focus
= tui_win_with_focus ();
684 struct tui_win_info
*first_win
;
685 struct tui_win_info
*second_win
;
686 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
688 int new_height
, split_diff
, cmd_split_diff
, num_wins_displayed
= 2;
690 #ifdef HAVE_RESIZE_TERM
691 resize_term (screenheight
, screenwidth
);
693 /* Turn keypad off while we resize. */
694 if (win_with_focus
!= TUI_CMD_WIN
)
695 keypad (TUI_CMD_WIN
->generic
.handle
, FALSE
);
696 tui_update_gdb_sizes ();
697 tui_set_term_height_to (screenheight
);
698 tui_set_term_width_to (screenwidth
);
699 if (cur_layout
== SRC_DISASSEM_COMMAND
700 || cur_layout
== SRC_DATA_COMMAND
701 || cur_layout
== DISASSEM_DATA_COMMAND
)
702 num_wins_displayed
++;
703 split_diff
= height_diff
/ num_wins_displayed
;
704 cmd_split_diff
= split_diff
;
705 if (height_diff
% num_wins_displayed
)
712 /* Now adjust each window. */
713 /* erase + clearok are used instead of a straightforward clear as
714 AIX 5.3 does not define clear. */
716 clearok (curscr
, TRUE
);
721 case DISASSEM_COMMAND
:
722 first_win
= (struct tui_win_info
*) (tui_source_windows ())->list
[0];
723 first_win
->generic
.width
+= width_diff
;
724 locator
->width
+= width_diff
;
725 /* Check for invalid heights. */
726 if (height_diff
== 0)
727 new_height
= first_win
->generic
.height
;
728 else if ((first_win
->generic
.height
+ split_diff
) >=
729 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
730 new_height
= screenheight
- MIN_CMD_WIN_HEIGHT
- 1;
731 else if ((first_win
->generic
.height
+ split_diff
) <= 0)
732 new_height
= MIN_WIN_HEIGHT
;
734 new_height
= first_win
->generic
.height
+ split_diff
;
736 locator
->origin
.y
= new_height
+ 1;
737 make_invisible_and_set_new_height (first_win
, new_height
);
738 TUI_CMD_WIN
->generic
.origin
.y
= locator
->origin
.y
+ 1;
739 TUI_CMD_WIN
->generic
.width
+= width_diff
;
740 new_height
= screenheight
- TUI_CMD_WIN
->generic
.origin
.y
;
741 make_invisible_and_set_new_height (TUI_CMD_WIN
, new_height
);
742 make_visible_with_new_height (first_win
);
743 make_visible_with_new_height (TUI_CMD_WIN
);
744 if (first_win
->generic
.content_size
<= 0)
745 tui_erase_source_content (first_win
, EMPTY_SOURCE_PROMPT
);
748 if (cur_layout
== SRC_DISASSEM_COMMAND
)
750 first_win
= TUI_SRC_WIN
;
751 first_win
->generic
.width
+= width_diff
;
752 second_win
= TUI_DISASM_WIN
;
753 second_win
->generic
.width
+= width_diff
;
757 first_win
= TUI_DATA_WIN
;
758 first_win
->generic
.width
+= width_diff
;
759 second_win
= (struct tui_win_info
*)
760 (tui_source_windows ())->list
[0];
761 second_win
->generic
.width
+= width_diff
;
763 /* Change the first window's height/width. */
764 /* Check for invalid heights. */
765 if (height_diff
== 0)
766 new_height
= first_win
->generic
.height
;
767 else if ((first_win
->generic
.height
+
768 second_win
->generic
.height
+ (split_diff
* 2)) >=
769 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
770 new_height
= (screenheight
- MIN_CMD_WIN_HEIGHT
- 1) / 2;
771 else if ((first_win
->generic
.height
+ split_diff
) <= 0)
772 new_height
= MIN_WIN_HEIGHT
;
774 new_height
= first_win
->generic
.height
+ split_diff
;
775 make_invisible_and_set_new_height (first_win
, new_height
);
777 locator
->width
+= width_diff
;
779 /* Change the second window's height/width. */
780 /* Check for invalid heights. */
781 if (height_diff
== 0)
782 new_height
= second_win
->generic
.height
;
783 else if ((first_win
->generic
.height
+
784 second_win
->generic
.height
+ (split_diff
* 2)) >=
785 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
787 new_height
= screenheight
- MIN_CMD_WIN_HEIGHT
- 1;
789 new_height
= (new_height
/ 2) + 1;
793 else if ((second_win
->generic
.height
+ split_diff
) <= 0)
794 new_height
= MIN_WIN_HEIGHT
;
796 new_height
= second_win
->generic
.height
+ split_diff
;
797 second_win
->generic
.origin
.y
= first_win
->generic
.height
- 1;
798 make_invisible_and_set_new_height (second_win
, new_height
);
800 /* Change the command window's height/width. */
801 TUI_CMD_WIN
->generic
.origin
.y
= locator
->origin
.y
+ 1;
802 make_invisible_and_set_new_height (TUI_CMD_WIN
,
803 TUI_CMD_WIN
->generic
.height
805 make_visible_with_new_height (first_win
);
806 make_visible_with_new_height (second_win
);
807 make_visible_with_new_height (TUI_CMD_WIN
);
808 if (first_win
->generic
.content_size
<= 0)
809 tui_erase_source_content (first_win
, EMPTY_SOURCE_PROMPT
);
810 if (second_win
->generic
.content_size
<= 0)
811 tui_erase_source_content (second_win
, EMPTY_SOURCE_PROMPT
);
814 /* Now remove all invisible windows, and their content so that
815 they get created again when called for with the new size. */
816 for (win_type
= SRC_WIN
; (win_type
< MAX_MAJOR_WINDOWS
); win_type
++)
818 if (win_type
!= CMD_WIN
819 && (tui_win_list
[win_type
] != NULL
)
820 && !tui_win_list
[win_type
]->generic
.is_visible
)
822 tui_free_window (tui_win_list
[win_type
]);
823 tui_win_list
[win_type
] = (struct tui_win_info
*) NULL
;
826 /* Turn keypad back on, unless focus is in the command
828 if (win_with_focus
!= TUI_CMD_WIN
)
829 keypad (TUI_CMD_WIN
->generic
.handle
, TRUE
);
834 /* Token for use by TUI's asynchronous SIGWINCH handler. */
835 static struct async_signal_handler
*tui_sigwinch_token
;
837 /* TUI's SIGWINCH signal handler. */
839 tui_sigwinch_handler (int signal
)
841 /* Set win_resized to TRUE and asynchronously invoke our resize callback. If
842 the callback is invoked while TUI is active then it ought to successfully
843 resize the screen, resetting win_resized to FALSE. Of course, if the
844 callback is invoked while TUI is inactive then it will do nothing; in that
845 case, win_resized will remain TRUE until we get a chance to synchronously
846 resize the screen from tui_enable(). */
847 mark_async_signal_handler (tui_sigwinch_token
);
848 tui_set_win_resized_to (TRUE
);
851 /* Callback for asynchronously resizing TUI following a SIGWINCH signal. */
853 tui_async_resize_screen (gdb_client_data arg
)
859 tui_refresh_all_win ();
860 tui_update_gdb_sizes ();
861 tui_set_win_resized_to (FALSE
);
862 tui_redisplay_readline ();
866 /* Initialize TUI's SIGWINCH signal handler. Note that the handler is not
867 uninstalled when we exit TUI, so the handler should not assume that TUI is
870 tui_initialize_win (void)
874 = create_async_signal_handler (tui_async_resize_screen
, NULL
);
877 #ifdef HAVE_SIGACTION
878 struct sigaction old_winch
;
880 memset (&old_winch
, 0, sizeof (old_winch
));
881 old_winch
.sa_handler
= &tui_sigwinch_handler
;
883 old_winch
.sa_flags
= SA_RESTART
;
885 sigaction (SIGWINCH
, &old_winch
, NULL
);
887 signal (SIGWINCH
, &tui_sigwinch_handler
);
894 /*************************
895 ** STATIC LOCAL FUNCTIONS
896 **************************/
900 tui_scroll_forward_command (char *arg
, int from_tty
)
902 int num_to_scroll
= 1;
903 struct tui_win_info
*win_to_scroll
;
905 /* Make sure the curses mode is enabled. */
907 if (arg
== (char *) NULL
)
908 parse_scrolling_args (arg
, &win_to_scroll
, (int *) NULL
);
910 parse_scrolling_args (arg
, &win_to_scroll
, &num_to_scroll
);
911 tui_scroll (FORWARD_SCROLL
, win_to_scroll
, num_to_scroll
);
916 tui_scroll_backward_command (char *arg
, int from_tty
)
918 int num_to_scroll
= 1;
919 struct tui_win_info
*win_to_scroll
;
921 /* Make sure the curses mode is enabled. */
923 if (arg
== (char *) NULL
)
924 parse_scrolling_args (arg
, &win_to_scroll
, (int *) NULL
);
926 parse_scrolling_args (arg
, &win_to_scroll
, &num_to_scroll
);
927 tui_scroll (BACKWARD_SCROLL
, win_to_scroll
, num_to_scroll
);
932 tui_scroll_left_command (char *arg
, int from_tty
)
935 struct tui_win_info
*win_to_scroll
;
937 /* Make sure the curses mode is enabled. */
939 parse_scrolling_args (arg
, &win_to_scroll
, &num_to_scroll
);
940 tui_scroll (LEFT_SCROLL
, win_to_scroll
, num_to_scroll
);
945 tui_scroll_right_command (char *arg
, int from_tty
)
948 struct tui_win_info
*win_to_scroll
;
950 /* Make sure the curses mode is enabled. */
952 parse_scrolling_args (arg
, &win_to_scroll
, &num_to_scroll
);
953 tui_scroll (RIGHT_SCROLL
, win_to_scroll
, num_to_scroll
);
957 /* Set focus to the window named by 'arg'. */
959 tui_set_focus (char *arg
, int from_tty
)
961 if (arg
!= (char *) NULL
)
963 char *buf_ptr
= (char *) xstrdup (arg
);
965 struct tui_win_info
*win_info
= (struct tui_win_info
*) NULL
;
967 for (i
= 0; (i
< strlen (buf_ptr
)); i
++)
968 buf_ptr
[i
] = toupper (arg
[i
]);
970 if (subset_compare (buf_ptr
, "NEXT"))
971 win_info
= tui_next_win (tui_win_with_focus ());
972 else if (subset_compare (buf_ptr
, "PREV"))
973 win_info
= tui_prev_win (tui_win_with_focus ());
975 win_info
= tui_partial_win_by_name (buf_ptr
);
977 if (win_info
== (struct tui_win_info
*) NULL
978 || !win_info
->generic
.is_visible
)
979 warning (_("Invalid window specified. \n\
980 The window name specified must be valid and visible.\n"));
983 tui_set_win_focus_to (win_info
);
984 keypad (TUI_CMD_WIN
->generic
.handle
, (win_info
!= TUI_CMD_WIN
));
987 if (TUI_DATA_WIN
&& TUI_DATA_WIN
->generic
.is_visible
)
988 tui_refresh_data_win ();
990 printf_filtered (_("Focus set to %s window.\n"),
991 tui_win_name ((struct tui_gen_win_info
*)
992 tui_win_with_focus ()));
995 warning (_("Incorrect Number of Arguments.\n%s"), FOCUS_USAGE
);
999 tui_set_focus_command (char *arg
, int from_tty
)
1001 /* Make sure the curses mode is enabled. */
1003 tui_set_focus (arg
, from_tty
);
1008 tui_all_windows_info (char *arg
, int from_tty
)
1011 struct tui_win_info
*win_with_focus
= tui_win_with_focus ();
1013 for (type
= SRC_WIN
; (type
< MAX_MAJOR_WINDOWS
); type
++)
1014 if (tui_win_list
[type
]
1015 && tui_win_list
[type
]->generic
.is_visible
)
1017 if (win_with_focus
== tui_win_list
[type
])
1018 printf_filtered (" %s\t(%d lines) <has focus>\n",
1019 tui_win_name (&tui_win_list
[type
]->generic
),
1020 tui_win_list
[type
]->generic
.height
);
1022 printf_filtered (" %s\t(%d lines)\n",
1023 tui_win_name (&tui_win_list
[type
]->generic
),
1024 tui_win_list
[type
]->generic
.height
);
1030 tui_refresh_all_command (char *arg
, int from_tty
)
1032 /* Make sure the curses mode is enabled. */
1035 tui_refresh_all_win ();
1039 /* Set the tab width of the specified window. */
1041 tui_set_tab_width_command (char *arg
, int from_tty
)
1043 /* Make sure the curses mode is enabled. */
1045 if (arg
!= (char *) NULL
)
1052 tui_set_default_tab_len (ts
);
1053 /* We don't really change the height of any windows, but
1054 calling these 2 functions causes a complete regeneration
1055 and redisplay of the window's contents, which will take
1056 the new tab width into account. */
1057 if (tui_win_list
[SRC_WIN
]
1058 && tui_win_list
[SRC_WIN
]->generic
.is_visible
)
1060 make_invisible_and_set_new_height (TUI_SRC_WIN
,
1061 TUI_SRC_WIN
->generic
.height
);
1062 make_visible_with_new_height (TUI_SRC_WIN
);
1064 if (tui_win_list
[DISASSEM_WIN
]
1065 && tui_win_list
[DISASSEM_WIN
]->generic
.is_visible
)
1067 make_invisible_and_set_new_height (TUI_DISASM_WIN
,
1068 TUI_DISASM_WIN
->generic
.height
);
1069 make_visible_with_new_height (TUI_DISASM_WIN
);
1073 warning (_("Tab widths greater than 0 must be specified."));
1078 /* Set the height of the specified window. */
1080 tui_set_win_height (char *arg
, int from_tty
)
1082 /* Make sure the curses mode is enabled. */
1084 if (arg
!= (char *) NULL
)
1086 char *buf
= xstrdup (arg
);
1087 char *buf_ptr
= buf
;
1088 char *wname
= (char *) NULL
;
1090 struct tui_win_info
*win_info
;
1093 buf_ptr
= strchr (buf_ptr
, ' ');
1094 if (buf_ptr
!= (char *) NULL
)
1096 *buf_ptr
= (char) 0;
1098 /* Validate the window name. */
1099 for (i
= 0; i
< strlen (wname
); i
++)
1100 wname
[i
] = toupper (wname
[i
]);
1101 win_info
= tui_partial_win_by_name (wname
);
1103 if (win_info
== (struct tui_win_info
*) NULL
1104 || !win_info
->generic
.is_visible
)
1105 warning (_("Invalid window specified. \n\
1106 The window name specified must be valid and visible.\n"));
1109 /* Process the size. */
1110 while (*(++buf_ptr
) == ' ')
1113 if (*buf_ptr
!= (char) 0)
1116 int fixed_size
= TRUE
;
1119 if (*buf_ptr
== '+' || *buf_ptr
== '-')
1121 if (*buf_ptr
== '-')
1126 input_no
= atoi (buf_ptr
);
1132 new_height
= input_no
;
1134 new_height
= win_info
->generic
.height
+ input_no
;
1136 /* Now change the window's height, and adjust
1137 all other windows around it. */
1138 if (tui_adjust_win_heights (win_info
,
1139 new_height
) == TUI_FAILURE
)
1140 warning (_("Invalid window height specified.\n%s"),
1143 tui_update_gdb_sizes ();
1146 warning (_("Invalid window height specified.\n%s"),
1152 printf_filtered (WIN_HEIGHT_USAGE
);
1154 if (buf
!= (char *) NULL
)
1158 printf_filtered (WIN_HEIGHT_USAGE
);
1161 /* Set the height of the specified window, with va_list. */
1163 tui_set_win_height_command (char *arg
, int from_tty
)
1165 /* Make sure the curses mode is enabled. */
1167 tui_set_win_height (arg
, from_tty
);
1171 /* XDB Compatibility command for setting the window height. This will
1172 increase or decrease the command window by the specified
1175 tui_xdb_set_win_height (char *arg
, int from_tty
)
1177 /* Make sure the curses mode is enabled. */
1179 if (arg
!= (char *) NULL
)
1181 int input_no
= atoi (arg
);
1184 { /* Add 1 for the locator. */
1185 int new_height
= tui_term_height () - (input_no
+ 1);
1187 if (!new_height_ok (tui_win_list
[CMD_WIN
], new_height
)
1188 || tui_adjust_win_heights (tui_win_list
[CMD_WIN
],
1189 new_height
) == TUI_FAILURE
)
1190 warning (_("Invalid window height specified.\n%s"),
1191 XDBWIN_HEIGHT_USAGE
);
1194 warning (_("Invalid window height specified.\n%s"),
1195 XDBWIN_HEIGHT_USAGE
);
1198 warning (_("Invalid window height specified.\n%s"), XDBWIN_HEIGHT_USAGE
);
1201 /* Set the height of the specified window, with va_list. */
1203 tui_xdb_set_win_height_command (char *arg
, int from_tty
)
1205 tui_xdb_set_win_height (arg
, from_tty
);
1209 /* Function to adjust all window heights around the primary. */
1210 static enum tui_status
1211 tui_adjust_win_heights (struct tui_win_info
*primary_win_info
,
1214 enum tui_status status
= TUI_FAILURE
;
1216 if (new_height_ok (primary_win_info
, new_height
))
1218 status
= TUI_SUCCESS
;
1219 if (new_height
!= primary_win_info
->generic
.height
)
1222 struct tui_win_info
*win_info
;
1223 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
1224 enum tui_layout_type cur_layout
= tui_current_layout ();
1226 diff
= (new_height
- primary_win_info
->generic
.height
) * (-1);
1227 if (cur_layout
== SRC_COMMAND
1228 || cur_layout
== DISASSEM_COMMAND
)
1230 struct tui_win_info
*src_win_info
;
1232 make_invisible_and_set_new_height (primary_win_info
, new_height
);
1233 if (primary_win_info
->generic
.type
== CMD_WIN
)
1235 win_info
= (tui_source_windows ())->list
[0];
1236 src_win_info
= win_info
;
1240 win_info
= tui_win_list
[CMD_WIN
];
1241 src_win_info
= primary_win_info
;
1243 make_invisible_and_set_new_height (win_info
,
1244 win_info
->generic
.height
+ diff
);
1245 TUI_CMD_WIN
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1246 make_visible_with_new_height (win_info
);
1247 make_visible_with_new_height (primary_win_info
);
1248 if (src_win_info
->generic
.content_size
<= 0)
1249 tui_erase_source_content (src_win_info
, EMPTY_SOURCE_PROMPT
);
1253 struct tui_win_info
*first_win
;
1254 struct tui_win_info
*second_win
;
1256 if (cur_layout
== SRC_DISASSEM_COMMAND
)
1258 first_win
= TUI_SRC_WIN
;
1259 second_win
= TUI_DISASM_WIN
;
1263 first_win
= TUI_DATA_WIN
;
1264 second_win
= (tui_source_windows ())->list
[0];
1266 if (primary_win_info
== TUI_CMD_WIN
)
1267 { /* Split the change in height accross the 1st & 2nd
1268 windows, adjusting them as well. */
1269 /* Subtract the locator. */
1270 int first_split_diff
= diff
/ 2;
1271 int second_split_diff
= first_split_diff
;
1275 if (first_win
->generic
.height
>
1276 second_win
->generic
.height
)
1284 second_split_diff
--;
1286 second_split_diff
++;
1289 /* Make sure that the minimum hieghts are
1291 while ((first_win
->generic
.height
+ first_split_diff
) < 3)
1294 second_split_diff
--;
1296 while ((second_win
->generic
.height
+ second_split_diff
) < 3)
1298 second_split_diff
++;
1301 make_invisible_and_set_new_height (
1303 first_win
->generic
.height
+ first_split_diff
);
1304 second_win
->generic
.origin
.y
= first_win
->generic
.height
- 1;
1305 make_invisible_and_set_new_height (second_win
,
1306 second_win
->generic
.height
1307 + second_split_diff
);
1308 TUI_CMD_WIN
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1309 make_invisible_and_set_new_height (TUI_CMD_WIN
, new_height
);
1313 if ((TUI_CMD_WIN
->generic
.height
+ diff
) < 1)
1314 { /* If there is no way to increase the command
1315 window take real estate from the 1st or 2nd
1317 if ((TUI_CMD_WIN
->generic
.height
+ diff
) < 1)
1321 for (i
= TUI_CMD_WIN
->generic
.height
+ diff
;
1323 if (primary_win_info
== first_win
)
1324 second_win
->generic
.height
--;
1326 first_win
->generic
.height
--;
1329 if (primary_win_info
== first_win
)
1330 make_invisible_and_set_new_height (first_win
, new_height
);
1332 make_invisible_and_set_new_height (
1334 first_win
->generic
.height
);
1335 second_win
->generic
.origin
.y
= first_win
->generic
.height
- 1;
1336 if (primary_win_info
== second_win
)
1337 make_invisible_and_set_new_height (second_win
, new_height
);
1339 make_invisible_and_set_new_height (
1340 second_win
, second_win
->generic
.height
);
1341 TUI_CMD_WIN
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1342 if ((TUI_CMD_WIN
->generic
.height
+ diff
) < 1)
1343 make_invisible_and_set_new_height (TUI_CMD_WIN
, 1);
1345 make_invisible_and_set_new_height (TUI_CMD_WIN
,
1346 TUI_CMD_WIN
->generic
.height
+ diff
);
1348 make_visible_with_new_height (TUI_CMD_WIN
);
1349 make_visible_with_new_height (second_win
);
1350 make_visible_with_new_height (first_win
);
1351 if (first_win
->generic
.content_size
<= 0)
1352 tui_erase_source_content (first_win
, EMPTY_SOURCE_PROMPT
);
1353 if (second_win
->generic
.content_size
<= 0)
1354 tui_erase_source_content (second_win
, EMPTY_SOURCE_PROMPT
);
1363 /* Function make the target window (and auxillary windows associated
1364 with the targer) invisible, and set the new height and
1367 make_invisible_and_set_new_height (struct tui_win_info
*win_info
,
1371 struct tui_gen_win_info
*gen_win_info
;
1373 tui_make_invisible (&win_info
->generic
);
1374 win_info
->generic
.height
= height
;
1376 win_info
->generic
.viewport_height
= height
- 1;
1378 win_info
->generic
.viewport_height
= height
;
1379 if (win_info
!= TUI_CMD_WIN
)
1380 win_info
->generic
.viewport_height
--;
1382 /* Now deal with the auxillary windows associated with win_info. */
1383 switch (win_info
->generic
.type
)
1387 gen_win_info
= win_info
->detail
.source_info
.execution_info
;
1388 tui_make_invisible (gen_win_info
);
1389 gen_win_info
->height
= height
;
1390 gen_win_info
->origin
.y
= win_info
->generic
.origin
.y
;
1392 gen_win_info
->viewport_height
= height
- 1;
1394 gen_win_info
->viewport_height
= height
;
1395 if (win_info
!= TUI_CMD_WIN
)
1396 gen_win_info
->viewport_height
--;
1398 if (tui_win_has_locator (win_info
))
1400 gen_win_info
= tui_locator_win_info_ptr ();
1401 tui_make_invisible (gen_win_info
);
1402 gen_win_info
->origin
.y
= win_info
->generic
.origin
.y
+ height
;
1406 /* Delete all data item windows. */
1407 for (i
= 0; i
< win_info
->generic
.content_size
; i
++)
1409 gen_win_info
= (struct tui_gen_win_info
*)
1410 &((struct tui_win_element
*)
1411 win_info
->generic
.content
[i
])->which_element
.data_window
;
1412 tui_delete_win (gen_win_info
->handle
);
1413 gen_win_info
->handle
= (WINDOW
*) NULL
;
1422 /* Function to make the windows with new heights visible. This means
1423 re-creating the windows' content since the window had to be
1424 destroyed to be made invisible. */
1426 make_visible_with_new_height (struct tui_win_info
*win_info
)
1430 tui_make_visible (&win_info
->generic
);
1431 tui_check_and_display_highlight_if_needed (win_info
);
1432 switch (win_info
->generic
.type
)
1436 tui_free_win_content (win_info
->detail
.source_info
.execution_info
);
1437 tui_make_visible (win_info
->detail
.source_info
.execution_info
);
1438 if (win_info
->generic
.content
!= NULL
)
1440 struct gdbarch
*gdbarch
= win_info
->detail
.source_info
.gdbarch
;
1441 struct tui_line_or_address line_or_addr
;
1442 struct symtab_and_line cursal
1443 = get_current_source_symtab_and_line ();
1445 line_or_addr
= win_info
->detail
.source_info
.start_line_or_addr
;
1446 tui_free_win_content (&win_info
->generic
);
1447 tui_update_source_window (win_info
, gdbarch
,
1448 cursal
.symtab
, line_or_addr
, TRUE
);
1450 else if (deprecated_safe_get_selected_frame () != NULL
)
1452 struct tui_line_or_address line
;
1453 struct symtab_and_line cursal
1454 = get_current_source_symtab_and_line ();
1455 struct frame_info
*frame
= deprecated_safe_get_selected_frame ();
1456 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1458 s
= find_pc_line_symtab (get_frame_pc (frame
));
1459 if (win_info
->generic
.type
== SRC_WIN
)
1461 line
.loa
= LOA_LINE
;
1462 line
.u
.line_no
= cursal
.line
;
1466 line
.loa
= LOA_ADDRESS
;
1467 find_line_pc (s
, cursal
.line
, &line
.u
.addr
);
1469 tui_update_source_window (win_info
, gdbarch
, s
, line
, TRUE
);
1471 if (tui_win_has_locator (win_info
))
1473 tui_make_visible (tui_locator_win_info_ptr ());
1474 tui_show_locator_content ();
1478 tui_display_all_data ();
1481 win_info
->detail
.command_info
.cur_line
= 0;
1482 win_info
->detail
.command_info
.curch
= 0;
1484 wresize (TUI_CMD_WIN
->generic
.handle
,
1485 TUI_CMD_WIN
->generic
.height
,
1486 TUI_CMD_WIN
->generic
.width
);
1488 mvwin (TUI_CMD_WIN
->generic
.handle
,
1489 TUI_CMD_WIN
->generic
.origin
.y
,
1490 TUI_CMD_WIN
->generic
.origin
.x
);
1491 wmove (win_info
->generic
.handle
,
1492 win_info
->detail
.command_info
.cur_line
,
1493 win_info
->detail
.command_info
.curch
);
1502 new_height_ok (struct tui_win_info
*primary_win_info
,
1505 int ok
= (new_height
< tui_term_height ());
1510 enum tui_layout_type cur_layout
= tui_current_layout ();
1512 diff
= (new_height
- primary_win_info
->generic
.height
) * (-1);
1513 if (cur_layout
== SRC_COMMAND
|| cur_layout
== DISASSEM_COMMAND
)
1515 ok
= ((primary_win_info
->generic
.type
== CMD_WIN
1516 && new_height
<= (tui_term_height () - 4)
1517 && new_height
>= MIN_CMD_WIN_HEIGHT
)
1518 || (primary_win_info
->generic
.type
!= CMD_WIN
1519 && new_height
<= (tui_term_height () - 2)
1520 && new_height
>= MIN_WIN_HEIGHT
));
1522 { /* Check the total height. */
1523 struct tui_win_info
*win_info
;
1525 if (primary_win_info
== TUI_CMD_WIN
)
1526 win_info
= (tui_source_windows ())->list
[0];
1528 win_info
= TUI_CMD_WIN
;
1530 (win_info
->generic
.height
+ diff
)) <= tui_term_height ());
1535 int cur_total_height
, total_height
, min_height
= 0;
1536 struct tui_win_info
*first_win
;
1537 struct tui_win_info
*second_win
;
1539 if (cur_layout
== SRC_DISASSEM_COMMAND
)
1541 first_win
= TUI_SRC_WIN
;
1542 second_win
= TUI_DISASM_WIN
;
1546 first_win
= TUI_DATA_WIN
;
1547 second_win
= (tui_source_windows ())->list
[0];
1549 /* We could simply add all the heights to obtain the same
1550 result but below is more explicit since we subtract 1 for
1551 the line that the first and second windows share, and add
1552 one for the locator. */
1553 total_height
= cur_total_height
=
1554 (first_win
->generic
.height
+ second_win
->generic
.height
- 1)
1555 + TUI_CMD_WIN
->generic
.height
+ 1; /* Locator. */
1556 if (primary_win_info
== TUI_CMD_WIN
)
1558 /* Locator included since first & second win share a line. */
1559 ok
= ((first_win
->generic
.height
+
1560 second_win
->generic
.height
+ diff
) >=
1561 (MIN_WIN_HEIGHT
* 2)
1562 && new_height
>= MIN_CMD_WIN_HEIGHT
);
1565 total_height
= new_height
+
1566 (first_win
->generic
.height
+
1567 second_win
->generic
.height
+ diff
);
1568 min_height
= MIN_CMD_WIN_HEIGHT
;
1573 min_height
= MIN_WIN_HEIGHT
;
1575 /* First see if we can increase/decrease the command
1576 window. And make sure that the command window is at
1578 ok
= ((TUI_CMD_WIN
->generic
.height
+ diff
) > 0);
1580 { /* Looks like we have to increase/decrease one of
1581 the other windows. */
1582 if (primary_win_info
== first_win
)
1583 ok
= (second_win
->generic
.height
+ diff
) >= min_height
;
1585 ok
= (first_win
->generic
.height
+ diff
) >= min_height
;
1589 if (primary_win_info
== first_win
)
1590 total_height
= new_height
+
1591 second_win
->generic
.height
+
1592 TUI_CMD_WIN
->generic
.height
+ diff
;
1594 total_height
= new_height
+
1595 first_win
->generic
.height
+
1596 TUI_CMD_WIN
->generic
.height
+ diff
;
1599 /* Now make sure that the proposed total height doesn't
1600 exceed the old total height. */
1602 ok
= (new_height
>= min_height
1603 && total_height
<= cur_total_height
);
1612 parse_scrolling_args (char *arg
,
1613 struct tui_win_info
**win_to_scroll
,
1618 *win_to_scroll
= tui_win_with_focus ();
1620 /* First set up the default window to scroll, in case there is no
1622 if (arg
!= (char *) NULL
)
1624 char *buf
, *buf_ptr
;
1626 /* Process the number of lines to scroll. */
1627 buf
= buf_ptr
= xstrdup (arg
);
1628 if (isdigit (*buf_ptr
))
1633 buf_ptr
= strchr (buf_ptr
, ' ');
1634 if (buf_ptr
!= (char *) NULL
)
1636 *buf_ptr
= (char) 0;
1638 *num_to_scroll
= atoi (num_str
);
1641 else if (num_to_scroll
)
1642 *num_to_scroll
= atoi (num_str
);
1645 /* Process the window name if one is specified. */
1646 if (buf_ptr
!= (char *) NULL
)
1651 if (*buf_ptr
== ' ')
1652 while (*(++buf_ptr
) == ' ')
1655 if (*buf_ptr
!= (char) 0)
1659 /* Validate the window name. */
1660 for (i
= 0; i
< strlen (wname
); i
++)
1661 wname
[i
] = toupper (wname
[i
]);
1666 *win_to_scroll
= tui_partial_win_by_name (wname
);
1668 if (*win_to_scroll
== (struct tui_win_info
*) NULL
1669 || !(*win_to_scroll
)->generic
.is_visible
)
1670 error (_("Invalid window specified. \n\
1671 The window name specified must be valid and visible.\n"));
1672 else if (*win_to_scroll
== TUI_CMD_WIN
)
1673 *win_to_scroll
= (tui_source_windows ())->list
[0];