1 /* TUI window generic functions.
3 Copyright (C) 1998-2018 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 (const char *, int);
65 static void tui_refresh_all_command (const char *, int);
66 static void tui_set_win_height_command (const char *, int);
67 static void tui_all_windows_info (const char *, int);
68 static void tui_set_focus_command (const char *, int);
69 static void tui_scroll_forward_command (const char *, int);
70 static void tui_scroll_backward_command (const char *, int);
71 static void tui_scroll_left_command (const char *, int);
72 static void tui_scroll_right_command (const char *, int);
73 static void parse_scrolling_args (const char *,
74 struct tui_win_info
**,
78 /***************************************
80 ***************************************/
81 #define WIN_HEIGHT_USAGE "Usage: winheight WINDOW-NAME [+ | -] NUM-LINES\n"
82 #define FOCUS_USAGE "Usage: focus [WINDOW-NAME | next | prev]\n"
84 /***************************************
86 ***************************************/
89 # define ACS_LRCORNER '+'
92 # define ACS_LLCORNER '+'
95 # define ACS_ULCORNER '+'
98 # define ACS_URCORNER '+'
101 # define ACS_HLINE '-'
104 # define ACS_VLINE '|'
107 /* Possible values for tui-border-kind variable. */
108 static const char *const tui_border_kind_enums
[] = {
115 /* Possible values for tui-border-mode and tui-active-border-mode. */
116 static const char *const tui_border_mode_enums
[] = {
133 /* Translation table for border-mode variables.
134 The list of values must be terminated by a NULL.
135 After the NULL value, an entry defines the default. */
136 struct tui_translate tui_border_mode_translate
[] = {
137 { "normal", A_NORMAL
},
138 { "standout", A_STANDOUT
},
139 { "reverse", A_REVERSE
},
141 { "half-standout", A_DIM
| A_STANDOUT
},
143 { "bold-standout", A_BOLD
| A_STANDOUT
},
145 { "normal", A_NORMAL
}
148 /* Translation tables for border-kind, one for each border
149 character (see wborder, border curses operations).
150 -1 is used to indicate the ACS because ACS characters
151 are determined at run time by curses (depends on terminal). */
152 struct tui_translate tui_border_kind_translate_vline
[] = {
160 struct tui_translate tui_border_kind_translate_hline
[] = {
168 struct tui_translate tui_border_kind_translate_ulcorner
[] = {
176 struct tui_translate tui_border_kind_translate_urcorner
[] = {
184 struct tui_translate tui_border_kind_translate_llcorner
[] = {
192 struct tui_translate tui_border_kind_translate_lrcorner
[] = {
201 /* Tui configuration variables controlled with set/show command. */
202 const char *tui_active_border_mode
= "bold-standout";
204 show_tui_active_border_mode (struct ui_file
*file
,
206 struct cmd_list_element
*c
,
209 fprintf_filtered (file
, _("\
210 The attribute mode to use for the active TUI window border is \"%s\".\n"),
214 const char *tui_border_mode
= "normal";
216 show_tui_border_mode (struct ui_file
*file
,
218 struct cmd_list_element
*c
,
221 fprintf_filtered (file
, _("\
222 The attribute mode to use for the TUI window borders is \"%s\".\n"),
226 const char *tui_border_kind
= "acs";
228 show_tui_border_kind (struct ui_file
*file
,
230 struct cmd_list_element
*c
,
233 fprintf_filtered (file
, _("The kind of border for TUI windows is \"%s\".\n"),
238 /* Tui internal configuration variables. These variables are updated
239 by tui_update_variables to reflect the tui configuration
241 chtype tui_border_vline
;
242 chtype tui_border_hline
;
243 chtype tui_border_ulcorner
;
244 chtype tui_border_urcorner
;
245 chtype tui_border_llcorner
;
246 chtype tui_border_lrcorner
;
248 int tui_border_attrs
;
249 int tui_active_border_attrs
;
251 /* Identify the item in the translation table.
252 When the item is not recognized, use the default entry. */
253 static struct tui_translate
*
254 translate (const char *name
, struct tui_translate
*table
)
258 if (name
&& strcmp (table
->name
, name
) == 0)
263 /* Not found, return default entry. */
268 /* Update the tui internal configuration according to gdb settings.
269 Returns 1 if the configuration has changed and the screen should
272 tui_update_variables (void)
275 struct tui_translate
*entry
;
277 entry
= translate (tui_border_mode
, tui_border_mode_translate
);
278 if (tui_border_attrs
!= entry
->value
)
280 tui_border_attrs
= entry
->value
;
283 entry
= translate (tui_active_border_mode
, tui_border_mode_translate
);
284 if (tui_active_border_attrs
!= entry
->value
)
286 tui_active_border_attrs
= entry
->value
;
290 /* If one corner changes, all characters are changed.
291 Only check the first one. The ACS characters are determined at
292 run time by curses terminal management. */
293 entry
= translate (tui_border_kind
, tui_border_kind_translate_lrcorner
);
294 if (tui_border_lrcorner
!= (chtype
) entry
->value
)
296 tui_border_lrcorner
= (entry
->value
< 0) ? ACS_LRCORNER
: entry
->value
;
299 entry
= translate (tui_border_kind
, tui_border_kind_translate_llcorner
);
300 tui_border_llcorner
= (entry
->value
< 0) ? ACS_LLCORNER
: entry
->value
;
302 entry
= translate (tui_border_kind
, tui_border_kind_translate_ulcorner
);
303 tui_border_ulcorner
= (entry
->value
< 0) ? ACS_ULCORNER
: entry
->value
;
305 entry
= translate (tui_border_kind
, tui_border_kind_translate_urcorner
);
306 tui_border_urcorner
= (entry
->value
< 0) ? ACS_URCORNER
: entry
->value
;
308 entry
= translate (tui_border_kind
, tui_border_kind_translate_hline
);
309 tui_border_hline
= (entry
->value
< 0) ? ACS_HLINE
: entry
->value
;
311 entry
= translate (tui_border_kind
, tui_border_kind_translate_vline
);
312 tui_border_vline
= (entry
->value
< 0) ? ACS_VLINE
: entry
->value
;
318 set_tui_cmd (const char *args
, int from_tty
)
323 show_tui_cmd (const char *args
, int from_tty
)
327 static struct cmd_list_element
*tuilist
;
330 tui_command (const char *args
, int from_tty
)
332 printf_unfiltered (_("\"tui\" must be followed by the name of a "
334 help_list (tuilist
, "tui ", all_commands
, gdb_stdout
);
337 struct cmd_list_element
**
338 tui_get_cmd_list (void)
341 add_prefix_cmd ("tui", class_tui
, tui_command
,
342 _("Text User Interface commands."),
343 &tuilist
, "tui ", 0, &cmdlist
);
347 /* The set_func hook of "set tui ..." commands that affect the window
348 borders on the TUI display. */
350 tui_set_var_cmd (const char *null_args
,
351 int from_tty
, struct cmd_list_element
*c
)
353 if (tui_update_variables () && tui_active
)
354 tui_rehighlight_all ();
357 /* Generic window name completion function. Complete window name pointed
358 to by TEXT and WORD. If INCLUDE_NEXT_PREV_P is true then the special
359 window names 'next' and 'prev' will also be considered as possible
360 completions of the window name. */
363 window_name_completer (completion_tracker
&tracker
,
364 int include_next_prev_p
,
365 const char *text
, const char *word
)
367 std::vector
<const char *> completion_name_vec
;
370 for (win_type
= SRC_WIN
; win_type
< MAX_MAJOR_WINDOWS
; win_type
++)
372 const char *completion_name
= NULL
;
374 /* We can't focus on an invisible window. */
375 if (tui_win_list
[win_type
] == NULL
376 || !tui_win_list
[win_type
]->generic
.is_visible
)
379 completion_name
= tui_win_name (&tui_win_list
[win_type
]->generic
);
380 gdb_assert (completion_name
!= NULL
);
381 completion_name_vec
.push_back (completion_name
);
384 /* If no windows are considered visible then the TUI has not yet been
385 initialized. But still "focus src" and "focus cmd" will work because
386 invoking the focus command will entail initializing the TUI which sets the
387 default layout to SRC_COMMAND. */
388 if (completion_name_vec
.empty ())
390 completion_name_vec
.push_back (SRC_NAME
);
391 completion_name_vec
.push_back (CMD_NAME
);
394 if (include_next_prev_p
)
396 completion_name_vec
.push_back ("next");
397 completion_name_vec
.push_back ("prev");
401 completion_name_vec
.push_back (NULL
);
402 complete_on_enum (tracker
, completion_name_vec
.data (), text
, word
);
405 /* Complete possible window names to focus on. TEXT is the complete text
406 entered so far, WORD is the word currently being completed. */
409 focus_completer (struct cmd_list_element
*ignore
,
410 completion_tracker
&tracker
,
411 const char *text
, const char *word
)
413 window_name_completer (tracker
, 1, text
, word
);
416 /* Complete possible window names for winheight command. TEXT is the
417 complete text entered so far, WORD is the word currently being
421 winheight_completer (struct cmd_list_element
*ignore
,
422 completion_tracker
&tracker
,
423 const char *text
, const char *word
)
425 /* The first word is the window name. That we can complete. Subsequent
426 words can't be completed. */
430 window_name_completer (tracker
, 0, text
, word
);
433 /* Function to initialize gdb commands, for tui window
437 _initialize_tui_win (void)
439 static struct cmd_list_element
*tui_setlist
;
440 static struct cmd_list_element
*tui_showlist
;
441 struct cmd_list_element
*cmd
;
443 /* Define the classes of commands.
444 They will appear in the help list in the reverse of this order. */
445 add_prefix_cmd ("tui", class_tui
, set_tui_cmd
,
446 _("TUI configuration variables"),
447 &tui_setlist
, "set tui ",
448 0 /* allow-unknown */, &setlist
);
449 add_prefix_cmd ("tui", class_tui
, show_tui_cmd
,
450 _("TUI configuration variables"),
451 &tui_showlist
, "show tui ",
452 0 /* allow-unknown */, &showlist
);
454 add_com ("refresh", class_tui
, tui_refresh_all_command
,
455 _("Refresh the terminal display.\n"));
456 add_com ("tabset", class_tui
, tui_set_tab_width_command
, _("\
457 Set the width (in characters) of tab stops.\n\
458 Usage: tabset N\n"));
459 cmd
= add_com ("winheight", class_tui
, tui_set_win_height_command
, _("\
460 Set or modify the height of a specified window.\n"
462 "Window names are:\n\
463 src : the source window\n\
464 cmd : the command window\n\
465 asm : the disassembly window\n\
466 regs : the register display\n"));
467 add_com_alias ("wh", "winheight", class_tui
, 0);
468 set_cmd_completer (cmd
, winheight_completer
);
469 add_info ("win", tui_all_windows_info
,
470 _("List of all displayed windows.\n"));
471 cmd
= add_com ("focus", class_tui
, tui_set_focus_command
, _("\
472 Set focus to named window or next/prev window.\n"
474 "Valid Window names are:\n\
475 src : the source window\n\
476 asm : the disassembly window\n\
477 regs : the register display\n\
478 cmd : the command window\n"));
479 add_com_alias ("fs", "focus", class_tui
, 0);
480 set_cmd_completer (cmd
, focus_completer
);
481 add_com ("+", class_tui
, tui_scroll_forward_command
, _("\
482 Scroll window forward.\n\
483 Usage: + [WIN] [N]\n"));
484 add_com ("-", class_tui
, tui_scroll_backward_command
, _("\
485 Scroll window backward.\n\
486 Usage: - [WIN] [N]\n"));
487 add_com ("<", class_tui
, tui_scroll_left_command
, _("\
488 Scroll window text to the left.\n\
489 Usage: < [WIN] [N]\n"));
490 add_com (">", class_tui
, tui_scroll_right_command
, _("\
491 Scroll window text to the right.\n\
492 Usage: > [WIN] [N]\n"));
494 /* Define the tui control variables. */
495 add_setshow_enum_cmd ("border-kind", no_class
, tui_border_kind_enums
,
496 &tui_border_kind
, _("\
497 Set the kind of border for TUI windows."), _("\
498 Show the kind of border for TUI windows."), _("\
499 This variable controls the border of TUI windows:\n\
500 space use a white space\n\
501 ascii use ascii characters + - | for the border\n\
502 acs use the Alternate Character Set"),
504 show_tui_border_kind
,
505 &tui_setlist
, &tui_showlist
);
507 add_setshow_enum_cmd ("border-mode", no_class
, tui_border_mode_enums
,
508 &tui_border_mode
, _("\
509 Set the attribute mode to use for the TUI window borders."), _("\
510 Show the attribute mode to use for the TUI window borders."), _("\
511 This variable controls the attributes to use for the window borders:\n\
512 normal normal display\n\
513 standout use highlight mode of terminal\n\
514 reverse use reverse video mode\n\
515 half use half bright\n\
516 half-standout use half bright and standout mode\n\
517 bold use extra bright or bold\n\
518 bold-standout use extra bright or bold with standout mode"),
520 show_tui_border_mode
,
521 &tui_setlist
, &tui_showlist
);
523 add_setshow_enum_cmd ("active-border-mode", no_class
, tui_border_mode_enums
,
524 &tui_active_border_mode
, _("\
525 Set the attribute mode to use for the active TUI window border."), _("\
526 Show the attribute mode to use for the active TUI window border."), _("\
527 This variable controls the attributes to use for the active window border:\n\
528 normal normal display\n\
529 standout use highlight mode of terminal\n\
530 reverse use reverse video mode\n\
531 half use half bright\n\
532 half-standout use half bright and standout mode\n\
533 bold use extra bright or bold\n\
534 bold-standout use extra bright or bold with standout mode"),
536 show_tui_active_border_mode
,
537 &tui_setlist
, &tui_showlist
);
540 /* Update gdb's knowledge of the terminal size. */
542 tui_update_gdb_sizes (void)
548 width
= TUI_CMD_WIN
->generic
.width
;
549 height
= TUI_CMD_WIN
->generic
.height
;
553 width
= tui_term_width ();
554 height
= tui_term_height ();
557 set_screen_width_and_height (width
, height
);
561 /* Set the logical focus to win_info. */
563 tui_set_win_focus_to (struct tui_win_info
*win_info
)
565 if (win_info
!= NULL
)
567 struct tui_win_info
*win_with_focus
= tui_win_with_focus ();
569 if (win_with_focus
!= NULL
570 && win_with_focus
->generic
.type
!= CMD_WIN
)
571 tui_unhighlight_win (win_with_focus
);
572 tui_set_win_with_focus (win_info
);
573 if (win_info
->generic
.type
!= CMD_WIN
)
574 tui_highlight_win (win_info
);
580 tui_scroll_forward (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)
588 _num_to_scroll
= win_to_scroll
->generic
.height
- 3;
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
593 command window do nothing since the term should handle
595 if (win_to_scroll
== TUI_SRC_WIN
)
596 tui_vertical_source_scroll (FORWARD_SCROLL
, _num_to_scroll
);
597 else if (win_to_scroll
== TUI_DISASM_WIN
)
598 tui_vertical_disassem_scroll (FORWARD_SCROLL
, _num_to_scroll
);
599 else if (win_to_scroll
== TUI_DATA_WIN
)
600 tui_vertical_data_scroll (FORWARD_SCROLL
, _num_to_scroll
);
605 tui_scroll_backward (struct tui_win_info
*win_to_scroll
,
608 if (win_to_scroll
!= TUI_CMD_WIN
)
610 int _num_to_scroll
= num_to_scroll
;
612 if (num_to_scroll
== 0)
613 _num_to_scroll
= win_to_scroll
->generic
.height
- 3;
615 /* If we are scrolling the source or disassembly window, do a
616 "psuedo" scroll since not all of the source is in memory,
617 only what is in the viewport. If win_to_scroll is the
618 command window do nothing since the term should handle
620 if (win_to_scroll
== TUI_SRC_WIN
)
621 tui_vertical_source_scroll (BACKWARD_SCROLL
, _num_to_scroll
);
622 else if (win_to_scroll
== TUI_DISASM_WIN
)
623 tui_vertical_disassem_scroll (BACKWARD_SCROLL
, _num_to_scroll
);
624 else if (win_to_scroll
== TUI_DATA_WIN
)
625 tui_vertical_data_scroll (BACKWARD_SCROLL
, _num_to_scroll
);
631 tui_scroll_left (struct tui_win_info
*win_to_scroll
,
634 if (win_to_scroll
!= TUI_CMD_WIN
)
636 int _num_to_scroll
= num_to_scroll
;
638 if (_num_to_scroll
== 0)
641 /* If we are scrolling the source or disassembly window, do a
642 "psuedo" scroll since not all of the source is in memory,
643 only what is in the viewport. If win_to_scroll is the command
644 window do nothing since the term should handle it. */
645 if (win_to_scroll
== TUI_SRC_WIN
646 || win_to_scroll
== TUI_DISASM_WIN
)
647 tui_horizontal_source_scroll (win_to_scroll
, LEFT_SCROLL
,
654 tui_scroll_right (struct tui_win_info
*win_to_scroll
,
657 if (win_to_scroll
!= TUI_CMD_WIN
)
659 int _num_to_scroll
= num_to_scroll
;
661 if (_num_to_scroll
== 0)
664 /* If we are scrolling the source or disassembly window, do a
665 "psuedo" scroll since not all of the source is in memory,
666 only what is in the viewport. If win_to_scroll is the command
667 window do nothing since the term should handle it. */
668 if (win_to_scroll
== TUI_SRC_WIN
669 || win_to_scroll
== TUI_DISASM_WIN
)
670 tui_horizontal_source_scroll (win_to_scroll
, RIGHT_SCROLL
,
676 /* Scroll a window. Arguments are passed through a va_list. */
678 tui_scroll (enum tui_scroll_direction direction
,
679 struct tui_win_info
*win_to_scroll
,
685 tui_scroll_forward (win_to_scroll
, num_to_scroll
);
687 case BACKWARD_SCROLL
:
688 tui_scroll_backward (win_to_scroll
, num_to_scroll
);
691 tui_scroll_left (win_to_scroll
, num_to_scroll
);
694 tui_scroll_right (win_to_scroll
, num_to_scroll
);
703 tui_refresh_all_win (void)
707 clearok (curscr
, TRUE
);
708 tui_refresh_all (tui_win_list
);
709 for (type
= SRC_WIN
; type
< MAX_MAJOR_WINDOWS
; type
++)
711 if (tui_win_list
[type
]
712 && tui_win_list
[type
]->generic
.is_visible
)
718 tui_show_source_content (tui_win_list
[type
]);
719 tui_check_and_display_highlight_if_needed (tui_win_list
[type
]);
720 tui_erase_exec_info_content (tui_win_list
[type
]);
721 tui_update_exec_info (tui_win_list
[type
]);
724 tui_refresh_data_win ();
731 tui_show_locator_content ();
735 tui_rehighlight_all (void)
739 for (type
= SRC_WIN
; type
< MAX_MAJOR_WINDOWS
; type
++)
740 tui_check_and_display_highlight_if_needed (tui_win_list
[type
]);
743 /* Resize all the windows based on the terminal size. This function
744 gets called from within the readline sinwinch handler. */
746 tui_resize_all (void)
748 int height_diff
, width_diff
;
749 int screenheight
, screenwidth
;
751 rl_get_screen_size (&screenheight
, &screenwidth
);
752 width_diff
= screenwidth
- tui_term_width ();
753 height_diff
= screenheight
- tui_term_height ();
754 if (height_diff
|| width_diff
)
756 enum tui_layout_type cur_layout
= tui_current_layout ();
757 struct tui_win_info
*win_with_focus
= tui_win_with_focus ();
758 struct tui_win_info
*first_win
;
759 struct tui_win_info
*second_win
;
760 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
762 int new_height
, split_diff
, cmd_split_diff
, num_wins_displayed
= 2;
764 #ifdef HAVE_RESIZE_TERM
765 resize_term (screenheight
, screenwidth
);
767 /* Turn keypad off while we resize. */
768 if (win_with_focus
!= TUI_CMD_WIN
)
769 keypad (TUI_CMD_WIN
->generic
.handle
, FALSE
);
770 tui_update_gdb_sizes ();
771 tui_set_term_height_to (screenheight
);
772 tui_set_term_width_to (screenwidth
);
773 if (cur_layout
== SRC_DISASSEM_COMMAND
774 || cur_layout
== SRC_DATA_COMMAND
775 || cur_layout
== DISASSEM_DATA_COMMAND
)
776 num_wins_displayed
++;
777 split_diff
= height_diff
/ num_wins_displayed
;
778 cmd_split_diff
= split_diff
;
779 if (height_diff
% num_wins_displayed
)
786 /* Now adjust each window. */
787 /* erase + clearok are used instead of a straightforward clear as
788 AIX 5.3 does not define clear. */
790 clearok (curscr
, TRUE
);
795 case DISASSEM_COMMAND
:
796 first_win
= tui_source_windows ()->list
[0];
797 first_win
->generic
.width
+= width_diff
;
798 locator
->width
+= width_diff
;
799 /* Check for invalid heights. */
800 if (height_diff
== 0)
801 new_height
= first_win
->generic
.height
;
802 else if ((first_win
->generic
.height
+ split_diff
) >=
803 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
804 new_height
= screenheight
- MIN_CMD_WIN_HEIGHT
- 1;
805 else if ((first_win
->generic
.height
+ split_diff
) <= 0)
806 new_height
= MIN_WIN_HEIGHT
;
808 new_height
= first_win
->generic
.height
+ split_diff
;
810 locator
->origin
.y
= new_height
+ 1;
811 make_invisible_and_set_new_height (first_win
, new_height
);
812 TUI_CMD_WIN
->generic
.origin
.y
= locator
->origin
.y
+ 1;
813 TUI_CMD_WIN
->generic
.width
+= width_diff
;
814 new_height
= screenheight
- TUI_CMD_WIN
->generic
.origin
.y
;
815 make_invisible_and_set_new_height (TUI_CMD_WIN
, new_height
);
816 make_visible_with_new_height (first_win
);
817 make_visible_with_new_height (TUI_CMD_WIN
);
818 if (first_win
->generic
.content_size
<= 0)
819 tui_erase_source_content (first_win
, EMPTY_SOURCE_PROMPT
);
822 if (cur_layout
== SRC_DISASSEM_COMMAND
)
824 first_win
= TUI_SRC_WIN
;
825 first_win
->generic
.width
+= width_diff
;
826 second_win
= TUI_DISASM_WIN
;
827 second_win
->generic
.width
+= width_diff
;
831 first_win
= TUI_DATA_WIN
;
832 first_win
->generic
.width
+= width_diff
;
833 second_win
= tui_source_windows ()->list
[0];
834 second_win
->generic
.width
+= width_diff
;
836 /* Change the first window's height/width. */
837 /* Check for invalid heights. */
838 if (height_diff
== 0)
839 new_height
= first_win
->generic
.height
;
840 else if ((first_win
->generic
.height
+
841 second_win
->generic
.height
+ (split_diff
* 2)) >=
842 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
843 new_height
= (screenheight
- MIN_CMD_WIN_HEIGHT
- 1) / 2;
844 else if ((first_win
->generic
.height
+ split_diff
) <= 0)
845 new_height
= MIN_WIN_HEIGHT
;
847 new_height
= first_win
->generic
.height
+ split_diff
;
848 make_invisible_and_set_new_height (first_win
, new_height
);
850 locator
->width
+= width_diff
;
852 /* Change the second window's height/width. */
853 /* Check for invalid heights. */
854 if (height_diff
== 0)
855 new_height
= second_win
->generic
.height
;
856 else if ((first_win
->generic
.height
+
857 second_win
->generic
.height
+ (split_diff
* 2)) >=
858 (screenheight
- MIN_CMD_WIN_HEIGHT
- 1))
860 new_height
= screenheight
- MIN_CMD_WIN_HEIGHT
- 1;
862 new_height
= (new_height
/ 2) + 1;
866 else if ((second_win
->generic
.height
+ split_diff
) <= 0)
867 new_height
= MIN_WIN_HEIGHT
;
869 new_height
= second_win
->generic
.height
+ split_diff
;
870 second_win
->generic
.origin
.y
= first_win
->generic
.height
- 1;
871 make_invisible_and_set_new_height (second_win
, new_height
);
873 /* Change the command window's height/width. */
874 TUI_CMD_WIN
->generic
.origin
.y
= locator
->origin
.y
+ 1;
875 make_invisible_and_set_new_height (TUI_CMD_WIN
,
876 TUI_CMD_WIN
->generic
.height
878 make_visible_with_new_height (first_win
);
879 make_visible_with_new_height (second_win
);
880 make_visible_with_new_height (TUI_CMD_WIN
);
881 if (first_win
->generic
.content_size
<= 0)
882 tui_erase_source_content (first_win
, EMPTY_SOURCE_PROMPT
);
883 if (second_win
->generic
.content_size
<= 0)
884 tui_erase_source_content (second_win
, EMPTY_SOURCE_PROMPT
);
887 /* Now remove all invisible windows, and their content so that
888 they get created again when called for with the new size. */
889 for (win_type
= SRC_WIN
; (win_type
< MAX_MAJOR_WINDOWS
); win_type
++)
891 if (win_type
!= CMD_WIN
892 && (tui_win_list
[win_type
] != NULL
)
893 && !tui_win_list
[win_type
]->generic
.is_visible
)
895 tui_free_window (tui_win_list
[win_type
]);
896 tui_win_list
[win_type
] = NULL
;
899 /* Turn keypad back on, unless focus is in the command
901 if (win_with_focus
!= TUI_CMD_WIN
)
902 keypad (TUI_CMD_WIN
->generic
.handle
, TRUE
);
907 /* Token for use by TUI's asynchronous SIGWINCH handler. */
908 static struct async_signal_handler
*tui_sigwinch_token
;
910 /* TUI's SIGWINCH signal handler. */
912 tui_sigwinch_handler (int signal
)
914 mark_async_signal_handler (tui_sigwinch_token
);
915 tui_set_win_resized_to (TRUE
);
918 /* Callback for asynchronously resizing TUI following a SIGWINCH signal. */
920 tui_async_resize_screen (gdb_client_data arg
)
922 rl_resize_terminal ();
926 int screen_height
, screen_width
;
928 rl_get_screen_size (&screen_height
, &screen_width
);
929 set_screen_width_and_height (screen_width
, screen_height
);
931 /* win_resized is left set so that the next call to tui_enable()
932 resizes the TUI windows. */
936 tui_set_win_resized_to (FALSE
);
938 tui_refresh_all_win ();
939 tui_update_gdb_sizes ();
940 tui_redisplay_readline ();
945 /* Initialize TUI's SIGWINCH signal handler. Note that the handler is not
946 uninstalled when we exit TUI, so the handler should not assume that TUI is
949 tui_initialize_win (void)
953 = create_async_signal_handler (tui_async_resize_screen
, NULL
);
956 #ifdef HAVE_SIGACTION
957 struct sigaction old_winch
;
959 memset (&old_winch
, 0, sizeof (old_winch
));
960 old_winch
.sa_handler
= &tui_sigwinch_handler
;
962 old_winch
.sa_flags
= SA_RESTART
;
964 sigaction (SIGWINCH
, &old_winch
, NULL
);
966 signal (SIGWINCH
, &tui_sigwinch_handler
);
973 /*************************
974 ** STATIC LOCAL FUNCTIONS
975 **************************/
979 tui_scroll_forward_command (const char *arg
, int from_tty
)
981 int num_to_scroll
= 1;
982 struct tui_win_info
*win_to_scroll
;
984 /* Make sure the curses mode is enabled. */
987 parse_scrolling_args (arg
, &win_to_scroll
, (int *) NULL
);
989 parse_scrolling_args (arg
, &win_to_scroll
, &num_to_scroll
);
990 tui_scroll (FORWARD_SCROLL
, win_to_scroll
, num_to_scroll
);
995 tui_scroll_backward_command (const char *arg
, int from_tty
)
997 int num_to_scroll
= 1;
998 struct tui_win_info
*win_to_scroll
;
1000 /* Make sure the curses mode is enabled. */
1003 parse_scrolling_args (arg
, &win_to_scroll
, (int *) NULL
);
1005 parse_scrolling_args (arg
, &win_to_scroll
, &num_to_scroll
);
1006 tui_scroll (BACKWARD_SCROLL
, win_to_scroll
, num_to_scroll
);
1011 tui_scroll_left_command (const char *arg
, int from_tty
)
1014 struct tui_win_info
*win_to_scroll
;
1016 /* Make sure the curses mode is enabled. */
1018 parse_scrolling_args (arg
, &win_to_scroll
, &num_to_scroll
);
1019 tui_scroll (LEFT_SCROLL
, win_to_scroll
, num_to_scroll
);
1024 tui_scroll_right_command (const char *arg
, int from_tty
)
1027 struct tui_win_info
*win_to_scroll
;
1029 /* Make sure the curses mode is enabled. */
1031 parse_scrolling_args (arg
, &win_to_scroll
, &num_to_scroll
);
1032 tui_scroll (RIGHT_SCROLL
, win_to_scroll
, num_to_scroll
);
1036 /* Set focus to the window named by 'arg'. */
1038 tui_set_focus (const char *arg
, int from_tty
)
1042 char *buf_ptr
= xstrdup (arg
);
1044 struct tui_win_info
*win_info
= NULL
;
1046 for (i
= 0; (i
< strlen (buf_ptr
)); i
++)
1047 buf_ptr
[i
] = tolower (arg
[i
]);
1049 if (subset_compare (buf_ptr
, "next"))
1050 win_info
= tui_next_win (tui_win_with_focus ());
1051 else if (subset_compare (buf_ptr
, "prev"))
1052 win_info
= tui_prev_win (tui_win_with_focus ());
1054 win_info
= tui_partial_win_by_name (buf_ptr
);
1056 if (win_info
== (struct tui_win_info
*) NULL
1057 || !win_info
->generic
.is_visible
)
1058 warning (_("Invalid window specified. \n\
1059 The window name specified must be valid and visible.\n"));
1062 tui_set_win_focus_to (win_info
);
1063 keypad (TUI_CMD_WIN
->generic
.handle
, (win_info
!= TUI_CMD_WIN
));
1066 if (TUI_DATA_WIN
&& TUI_DATA_WIN
->generic
.is_visible
)
1067 tui_refresh_data_win ();
1069 printf_filtered (_("Focus set to %s window.\n"),
1070 tui_win_name (&tui_win_with_focus ()->generic
));
1073 warning (_("Incorrect Number of Arguments.\n%s"), FOCUS_USAGE
);
1077 tui_set_focus_command (const char *arg
, int from_tty
)
1079 /* Make sure the curses mode is enabled. */
1081 tui_set_focus (arg
, from_tty
);
1086 tui_all_windows_info (const char *arg
, int from_tty
)
1089 struct tui_win_info
*win_with_focus
= tui_win_with_focus ();
1091 for (type
= SRC_WIN
; (type
< MAX_MAJOR_WINDOWS
); type
++)
1092 if (tui_win_list
[type
]
1093 && tui_win_list
[type
]->generic
.is_visible
)
1095 if (win_with_focus
== tui_win_list
[type
])
1096 printf_filtered (" %s\t(%d lines) <has focus>\n",
1097 tui_win_name (&tui_win_list
[type
]->generic
),
1098 tui_win_list
[type
]->generic
.height
);
1100 printf_filtered (" %s\t(%d lines)\n",
1101 tui_win_name (&tui_win_list
[type
]->generic
),
1102 tui_win_list
[type
]->generic
.height
);
1108 tui_refresh_all_command (const char *arg
, int from_tty
)
1110 /* Make sure the curses mode is enabled. */
1113 tui_refresh_all_win ();
1117 /* Set the tab width of the specified window. */
1119 tui_set_tab_width_command (const char *arg
, int from_tty
)
1121 /* Make sure the curses mode is enabled. */
1130 tui_set_default_tab_len (ts
);
1131 /* We don't really change the height of any windows, but
1132 calling these 2 functions causes a complete regeneration
1133 and redisplay of the window's contents, which will take
1134 the new tab width into account. */
1135 if (tui_win_list
[SRC_WIN
]
1136 && tui_win_list
[SRC_WIN
]->generic
.is_visible
)
1138 make_invisible_and_set_new_height (TUI_SRC_WIN
,
1139 TUI_SRC_WIN
->generic
.height
);
1140 make_visible_with_new_height (TUI_SRC_WIN
);
1142 if (tui_win_list
[DISASSEM_WIN
]
1143 && tui_win_list
[DISASSEM_WIN
]->generic
.is_visible
)
1145 make_invisible_and_set_new_height (TUI_DISASM_WIN
,
1146 TUI_DISASM_WIN
->generic
.height
);
1147 make_visible_with_new_height (TUI_DISASM_WIN
);
1151 warning (_("Tab widths greater than 0 must be specified."));
1156 /* Set the height of the specified window. */
1158 tui_set_win_height (const char *arg
, int from_tty
)
1160 /* Make sure the curses mode is enabled. */
1164 std::string copy
= arg
;
1165 char *buf
= ©
[0];
1166 char *buf_ptr
= buf
;
1169 struct tui_win_info
*win_info
;
1172 buf_ptr
= strchr (buf_ptr
, ' ');
1173 if (buf_ptr
!= NULL
)
1175 *buf_ptr
= (char) 0;
1177 /* Validate the window name. */
1178 for (i
= 0; i
< strlen (wname
); i
++)
1179 wname
[i
] = tolower (wname
[i
]);
1180 win_info
= tui_partial_win_by_name (wname
);
1182 if (win_info
== (struct tui_win_info
*) NULL
1183 || !win_info
->generic
.is_visible
)
1184 warning (_("Invalid window specified. \n\
1185 The window name specified must be valid and visible.\n"));
1188 /* Process the size. */
1189 while (*(++buf_ptr
) == ' ')
1192 if (*buf_ptr
!= (char) 0)
1195 int fixed_size
= TRUE
;
1198 if (*buf_ptr
== '+' || *buf_ptr
== '-')
1200 if (*buf_ptr
== '-')
1205 input_no
= atoi (buf_ptr
);
1211 new_height
= input_no
;
1213 new_height
= win_info
->generic
.height
+ input_no
;
1215 /* Now change the window's height, and adjust
1216 all other windows around it. */
1217 if (tui_adjust_win_heights (win_info
,
1218 new_height
) == TUI_FAILURE
)
1219 warning (_("Invalid window height specified.\n%s"),
1222 tui_update_gdb_sizes ();
1225 warning (_("Invalid window height specified.\n%s"),
1231 printf_filtered (WIN_HEIGHT_USAGE
);
1234 printf_filtered (WIN_HEIGHT_USAGE
);
1237 /* Set the height of the specified window, with va_list. */
1239 tui_set_win_height_command (const char *arg
, int from_tty
)
1241 /* Make sure the curses mode is enabled. */
1243 tui_set_win_height (arg
, from_tty
);
1246 /* Function to adjust all window heights around the primary. */
1247 static enum tui_status
1248 tui_adjust_win_heights (struct tui_win_info
*primary_win_info
,
1251 enum tui_status status
= TUI_FAILURE
;
1253 if (new_height_ok (primary_win_info
, new_height
))
1255 status
= TUI_SUCCESS
;
1256 if (new_height
!= primary_win_info
->generic
.height
)
1259 struct tui_win_info
*win_info
;
1260 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
1261 enum tui_layout_type cur_layout
= tui_current_layout ();
1263 diff
= (new_height
- primary_win_info
->generic
.height
) * (-1);
1264 if (cur_layout
== SRC_COMMAND
1265 || cur_layout
== DISASSEM_COMMAND
)
1267 struct tui_win_info
*src_win_info
;
1269 make_invisible_and_set_new_height (primary_win_info
, new_height
);
1270 if (primary_win_info
->generic
.type
== CMD_WIN
)
1272 win_info
= (tui_source_windows ())->list
[0];
1273 src_win_info
= win_info
;
1277 win_info
= tui_win_list
[CMD_WIN
];
1278 src_win_info
= primary_win_info
;
1280 make_invisible_and_set_new_height (win_info
,
1281 win_info
->generic
.height
+ diff
);
1282 TUI_CMD_WIN
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1283 make_visible_with_new_height (win_info
);
1284 make_visible_with_new_height (primary_win_info
);
1285 if (src_win_info
->generic
.content_size
<= 0)
1286 tui_erase_source_content (src_win_info
, EMPTY_SOURCE_PROMPT
);
1290 struct tui_win_info
*first_win
;
1291 struct tui_win_info
*second_win
;
1293 if (cur_layout
== SRC_DISASSEM_COMMAND
)
1295 first_win
= TUI_SRC_WIN
;
1296 second_win
= TUI_DISASM_WIN
;
1300 first_win
= TUI_DATA_WIN
;
1301 second_win
= (tui_source_windows ())->list
[0];
1303 if (primary_win_info
== TUI_CMD_WIN
)
1304 { /* Split the change in height accross the 1st & 2nd
1305 windows, adjusting them as well. */
1306 /* Subtract the locator. */
1307 int first_split_diff
= diff
/ 2;
1308 int second_split_diff
= first_split_diff
;
1312 if (first_win
->generic
.height
>
1313 second_win
->generic
.height
)
1321 second_split_diff
--;
1323 second_split_diff
++;
1326 /* Make sure that the minimum hieghts are
1328 while ((first_win
->generic
.height
+ first_split_diff
) < 3)
1331 second_split_diff
--;
1333 while ((second_win
->generic
.height
+ second_split_diff
) < 3)
1335 second_split_diff
++;
1338 make_invisible_and_set_new_height (
1340 first_win
->generic
.height
+ first_split_diff
);
1341 second_win
->generic
.origin
.y
= first_win
->generic
.height
- 1;
1342 make_invisible_and_set_new_height (second_win
,
1343 second_win
->generic
.height
1344 + second_split_diff
);
1345 TUI_CMD_WIN
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1346 make_invisible_and_set_new_height (TUI_CMD_WIN
, new_height
);
1350 if ((TUI_CMD_WIN
->generic
.height
+ diff
) < 1)
1351 { /* If there is no way to increase the command
1352 window take real estate from the 1st or 2nd
1354 if ((TUI_CMD_WIN
->generic
.height
+ diff
) < 1)
1358 for (i
= TUI_CMD_WIN
->generic
.height
+ diff
;
1360 if (primary_win_info
== first_win
)
1361 second_win
->generic
.height
--;
1363 first_win
->generic
.height
--;
1366 if (primary_win_info
== first_win
)
1367 make_invisible_and_set_new_height (first_win
, new_height
);
1369 make_invisible_and_set_new_height (
1371 first_win
->generic
.height
);
1372 second_win
->generic
.origin
.y
= first_win
->generic
.height
- 1;
1373 if (primary_win_info
== second_win
)
1374 make_invisible_and_set_new_height (second_win
, new_height
);
1376 make_invisible_and_set_new_height (
1377 second_win
, second_win
->generic
.height
);
1378 TUI_CMD_WIN
->generic
.origin
.y
= locator
->origin
.y
+ 1;
1379 if ((TUI_CMD_WIN
->generic
.height
+ diff
) < 1)
1380 make_invisible_and_set_new_height (TUI_CMD_WIN
, 1);
1382 make_invisible_and_set_new_height (TUI_CMD_WIN
,
1383 TUI_CMD_WIN
->generic
.height
+ diff
);
1385 make_visible_with_new_height (TUI_CMD_WIN
);
1386 make_visible_with_new_height (second_win
);
1387 make_visible_with_new_height (first_win
);
1388 if (first_win
->generic
.content_size
<= 0)
1389 tui_erase_source_content (first_win
, EMPTY_SOURCE_PROMPT
);
1390 if (second_win
->generic
.content_size
<= 0)
1391 tui_erase_source_content (second_win
, EMPTY_SOURCE_PROMPT
);
1400 /* Function make the target window (and auxillary windows associated
1401 with the targer) invisible, and set the new height and
1404 make_invisible_and_set_new_height (struct tui_win_info
*win_info
,
1408 struct tui_gen_win_info
*gen_win_info
;
1410 tui_make_invisible (&win_info
->generic
);
1411 win_info
->generic
.height
= height
;
1413 win_info
->generic
.viewport_height
= height
- 1;
1415 win_info
->generic
.viewport_height
= height
;
1416 if (win_info
!= TUI_CMD_WIN
)
1417 win_info
->generic
.viewport_height
--;
1419 /* Now deal with the auxillary windows associated with win_info. */
1420 switch (win_info
->generic
.type
)
1424 gen_win_info
= win_info
->detail
.source_info
.execution_info
;
1425 tui_make_invisible (gen_win_info
);
1426 gen_win_info
->height
= height
;
1427 gen_win_info
->origin
.y
= win_info
->generic
.origin
.y
;
1429 gen_win_info
->viewport_height
= height
- 1;
1431 gen_win_info
->viewport_height
= height
;
1432 if (win_info
!= TUI_CMD_WIN
)
1433 gen_win_info
->viewport_height
--;
1435 if (tui_win_has_locator (win_info
))
1437 gen_win_info
= tui_locator_win_info_ptr ();
1438 tui_make_invisible (gen_win_info
);
1439 gen_win_info
->origin
.y
= win_info
->generic
.origin
.y
+ height
;
1443 /* Delete all data item windows. */
1444 for (i
= 0; i
< win_info
->generic
.content_size
; i
++)
1447 = &win_info
->generic
.content
[i
]->which_element
.data_window
;
1448 tui_delete_win (gen_win_info
->handle
);
1449 gen_win_info
->handle
= NULL
;
1458 /* Function to make the windows with new heights visible. This means
1459 re-creating the windows' content since the window had to be
1460 destroyed to be made invisible. */
1462 make_visible_with_new_height (struct tui_win_info
*win_info
)
1466 tui_make_visible (&win_info
->generic
);
1467 tui_check_and_display_highlight_if_needed (win_info
);
1468 switch (win_info
->generic
.type
)
1472 tui_free_win_content (win_info
->detail
.source_info
.execution_info
);
1473 tui_make_visible (win_info
->detail
.source_info
.execution_info
);
1474 if (win_info
->generic
.content
!= NULL
)
1476 struct gdbarch
*gdbarch
= win_info
->detail
.source_info
.gdbarch
;
1477 struct tui_line_or_address line_or_addr
;
1478 struct symtab_and_line cursal
1479 = get_current_source_symtab_and_line ();
1481 line_or_addr
= win_info
->detail
.source_info
.start_line_or_addr
;
1482 tui_free_win_content (&win_info
->generic
);
1483 tui_update_source_window (win_info
, gdbarch
,
1484 cursal
.symtab
, line_or_addr
, TRUE
);
1486 else if (deprecated_safe_get_selected_frame () != NULL
)
1488 struct tui_line_or_address line
;
1489 struct symtab_and_line cursal
1490 = get_current_source_symtab_and_line ();
1491 struct frame_info
*frame
= deprecated_safe_get_selected_frame ();
1492 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1494 s
= find_pc_line_symtab (get_frame_pc (frame
));
1495 if (win_info
->generic
.type
== SRC_WIN
)
1497 line
.loa
= LOA_LINE
;
1498 line
.u
.line_no
= cursal
.line
;
1502 line
.loa
= LOA_ADDRESS
;
1503 find_line_pc (s
, cursal
.line
, &line
.u
.addr
);
1505 tui_update_source_window (win_info
, gdbarch
, s
, line
, TRUE
);
1507 if (tui_win_has_locator (win_info
))
1509 tui_make_visible (tui_locator_win_info_ptr ());
1510 tui_show_locator_content ();
1514 tui_display_all_data ();
1518 wresize (TUI_CMD_WIN
->generic
.handle
,
1519 TUI_CMD_WIN
->generic
.height
,
1520 TUI_CMD_WIN
->generic
.width
);
1522 mvwin (TUI_CMD_WIN
->generic
.handle
,
1523 TUI_CMD_WIN
->generic
.origin
.y
,
1524 TUI_CMD_WIN
->generic
.origin
.x
);
1525 wmove (win_info
->generic
.handle
, 0, 0);
1534 new_height_ok (struct tui_win_info
*primary_win_info
,
1537 int ok
= (new_height
< tui_term_height ());
1542 enum tui_layout_type cur_layout
= tui_current_layout ();
1544 diff
= (new_height
- primary_win_info
->generic
.height
) * (-1);
1545 if (cur_layout
== SRC_COMMAND
|| cur_layout
== DISASSEM_COMMAND
)
1547 ok
= ((primary_win_info
->generic
.type
== CMD_WIN
1548 && new_height
<= (tui_term_height () - 4)
1549 && new_height
>= MIN_CMD_WIN_HEIGHT
)
1550 || (primary_win_info
->generic
.type
!= CMD_WIN
1551 && new_height
<= (tui_term_height () - 2)
1552 && new_height
>= MIN_WIN_HEIGHT
));
1554 { /* Check the total height. */
1555 struct tui_win_info
*win_info
;
1557 if (primary_win_info
== TUI_CMD_WIN
)
1558 win_info
= (tui_source_windows ())->list
[0];
1560 win_info
= TUI_CMD_WIN
;
1562 (win_info
->generic
.height
+ diff
)) <= tui_term_height ());
1567 int cur_total_height
, total_height
, min_height
= 0;
1568 struct tui_win_info
*first_win
;
1569 struct tui_win_info
*second_win
;
1571 if (cur_layout
== SRC_DISASSEM_COMMAND
)
1573 first_win
= TUI_SRC_WIN
;
1574 second_win
= TUI_DISASM_WIN
;
1578 first_win
= TUI_DATA_WIN
;
1579 second_win
= (tui_source_windows ())->list
[0];
1581 /* We could simply add all the heights to obtain the same
1582 result but below is more explicit since we subtract 1 for
1583 the line that the first and second windows share, and add
1584 one for the locator. */
1585 total_height
= cur_total_height
=
1586 (first_win
->generic
.height
+ second_win
->generic
.height
- 1)
1587 + TUI_CMD_WIN
->generic
.height
+ 1; /* Locator. */
1588 if (primary_win_info
== TUI_CMD_WIN
)
1590 /* Locator included since first & second win share a line. */
1591 ok
= ((first_win
->generic
.height
+
1592 second_win
->generic
.height
+ diff
) >=
1593 (MIN_WIN_HEIGHT
* 2)
1594 && new_height
>= MIN_CMD_WIN_HEIGHT
);
1597 total_height
= new_height
+
1598 (first_win
->generic
.height
+
1599 second_win
->generic
.height
+ diff
);
1600 min_height
= MIN_CMD_WIN_HEIGHT
;
1605 min_height
= MIN_WIN_HEIGHT
;
1607 /* First see if we can increase/decrease the command
1608 window. And make sure that the command window is at
1610 ok
= ((TUI_CMD_WIN
->generic
.height
+ diff
) > 0);
1612 { /* Looks like we have to increase/decrease one of
1613 the other windows. */
1614 if (primary_win_info
== first_win
)
1615 ok
= (second_win
->generic
.height
+ diff
) >= min_height
;
1617 ok
= (first_win
->generic
.height
+ diff
) >= min_height
;
1621 if (primary_win_info
== first_win
)
1622 total_height
= new_height
+
1623 second_win
->generic
.height
+
1624 TUI_CMD_WIN
->generic
.height
+ diff
;
1626 total_height
= new_height
+
1627 first_win
->generic
.height
+
1628 TUI_CMD_WIN
->generic
.height
+ diff
;
1631 /* Now make sure that the proposed total height doesn't
1632 exceed the old total height. */
1634 ok
= (new_height
>= min_height
1635 && total_height
<= cur_total_height
);
1644 parse_scrolling_args (const char *arg
,
1645 struct tui_win_info
**win_to_scroll
,
1650 *win_to_scroll
= tui_win_with_focus ();
1652 /* First set up the default window to scroll, in case there is no
1658 /* Process the number of lines to scroll. */
1659 std::string copy
= arg
;
1661 if (isdigit (*buf_ptr
))
1666 buf_ptr
= strchr (buf_ptr
, ' ');
1667 if (buf_ptr
!= NULL
)
1669 *buf_ptr
= (char) 0;
1671 *num_to_scroll
= atoi (num_str
);
1674 else if (num_to_scroll
)
1675 *num_to_scroll
= atoi (num_str
);
1678 /* Process the window name if one is specified. */
1679 if (buf_ptr
!= NULL
)
1683 if (*buf_ptr
== ' ')
1684 while (*(++buf_ptr
) == ' ')
1687 if (*buf_ptr
!= (char) 0)
1689 /* Validate the window name. */
1690 for (char *p
= buf_ptr
; *p
!= '\0'; p
++)
1698 *win_to_scroll
= tui_partial_win_by_name (wname
);
1700 if (*win_to_scroll
== (struct tui_win_info
*) NULL
1701 || !(*win_to_scroll
)->generic
.is_visible
)
1702 error (_("Invalid window specified. \n\
1703 The window name specified must be valid and visible.\n"));
1704 else if (*win_to_scroll
== TUI_CMD_WIN
)
1705 *win_to_scroll
= (tui_source_windows ())->list
[0];