Remove tui_set_focus
[binutils-gdb.git] / gdb / tui / tui-win.c
1 /* TUI window generic functions.
2
3 Copyright (C) 1998-2019 Free Software Foundation, Inc.
4
5 Contributed by Hewlett-Packard Company.
6
7 This file is part of GDB.
8
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.
13
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.
18
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/>. */
21
22 /* This module contains procedures for handling tui window functions
23 like resize, scrolling, scrolling, changing focus, etc.
24
25 Author: Susan B. Macchia */
26
27 #include "defs.h"
28 #include "command.h"
29 #include "symtab.h"
30 #include "breakpoint.h"
31 #include "frame.h"
32 #include "cli/cli-cmds.h"
33 #include "top.h"
34 #include "source.h"
35 #include "event-loop.h"
36
37 #include "tui/tui.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"
48
49 #include "gdb_curses.h"
50 #include <ctype.h>
51 #include "readline/readline.h"
52
53 #include <signal.h>
54
55 /*******************************
56 ** Static Local Decls
57 ********************************/
58 static void make_invisible_and_set_new_height (struct tui_win_info *,
59 int);
60 static enum tui_status tui_adjust_win_heights (struct tui_win_info *,
61 int);
62 static int new_height_ok (struct tui_win_info *, int);
63 static void tui_set_tab_width_command (const char *, int);
64 static void tui_refresh_all_command (const char *, int);
65 static void tui_all_windows_info (const char *, int);
66 static void tui_scroll_forward_command (const char *, int);
67 static void tui_scroll_backward_command (const char *, int);
68 static void tui_scroll_left_command (const char *, int);
69 static void tui_scroll_right_command (const char *, int);
70 static void parse_scrolling_args (const char *,
71 struct tui_win_info **,
72 int *);
73
74
75 /***************************************
76 ** DEFINITIONS
77 ***************************************/
78 #define WIN_HEIGHT_USAGE "Usage: winheight WINDOW-NAME [+ | -] NUM-LINES\n"
79 #define FOCUS_USAGE "Usage: focus [WINDOW-NAME | next | prev]\n"
80
81 /***************************************
82 ** PUBLIC FUNCTIONS
83 ***************************************/
84
85 #ifndef ACS_LRCORNER
86 # define ACS_LRCORNER '+'
87 #endif
88 #ifndef ACS_LLCORNER
89 # define ACS_LLCORNER '+'
90 #endif
91 #ifndef ACS_ULCORNER
92 # define ACS_ULCORNER '+'
93 #endif
94 #ifndef ACS_URCORNER
95 # define ACS_URCORNER '+'
96 #endif
97 #ifndef ACS_HLINE
98 # define ACS_HLINE '-'
99 #endif
100 #ifndef ACS_VLINE
101 # define ACS_VLINE '|'
102 #endif
103
104 /* Possible values for tui-border-kind variable. */
105 static const char *const tui_border_kind_enums[] = {
106 "space",
107 "ascii",
108 "acs",
109 NULL
110 };
111
112 /* Possible values for tui-border-mode and tui-active-border-mode. */
113 static const char *const tui_border_mode_enums[] = {
114 "normal",
115 "standout",
116 "reverse",
117 "half",
118 "half-standout",
119 "bold",
120 "bold-standout",
121 NULL
122 };
123
124 struct tui_translate
125 {
126 const char *name;
127 int value;
128 };
129
130 /* Translation table for border-mode variables.
131 The list of values must be terminated by a NULL.
132 After the NULL value, an entry defines the default. */
133 struct tui_translate tui_border_mode_translate[] = {
134 { "normal", A_NORMAL },
135 { "standout", A_STANDOUT },
136 { "reverse", A_REVERSE },
137 { "half", A_DIM },
138 { "half-standout", A_DIM | A_STANDOUT },
139 { "bold", A_BOLD },
140 { "bold-standout", A_BOLD | A_STANDOUT },
141 { 0, 0 },
142 { "normal", A_NORMAL }
143 };
144
145 /* Translation tables for border-kind, one for each border
146 character (see wborder, border curses operations).
147 -1 is used to indicate the ACS because ACS characters
148 are determined at run time by curses (depends on terminal). */
149 struct tui_translate tui_border_kind_translate_vline[] = {
150 { "space", ' ' },
151 { "ascii", '|' },
152 { "acs", -1 },
153 { 0, 0 },
154 { "ascii", '|' }
155 };
156
157 struct tui_translate tui_border_kind_translate_hline[] = {
158 { "space", ' ' },
159 { "ascii", '-' },
160 { "acs", -1 },
161 { 0, 0 },
162 { "ascii", '-' }
163 };
164
165 struct tui_translate tui_border_kind_translate_ulcorner[] = {
166 { "space", ' ' },
167 { "ascii", '+' },
168 { "acs", -1 },
169 { 0, 0 },
170 { "ascii", '+' }
171 };
172
173 struct tui_translate tui_border_kind_translate_urcorner[] = {
174 { "space", ' ' },
175 { "ascii", '+' },
176 { "acs", -1 },
177 { 0, 0 },
178 { "ascii", '+' }
179 };
180
181 struct tui_translate tui_border_kind_translate_llcorner[] = {
182 { "space", ' ' },
183 { "ascii", '+' },
184 { "acs", -1 },
185 { 0, 0 },
186 { "ascii", '+' }
187 };
188
189 struct tui_translate tui_border_kind_translate_lrcorner[] = {
190 { "space", ' ' },
191 { "ascii", '+' },
192 { "acs", -1 },
193 { 0, 0 },
194 { "ascii", '+' }
195 };
196
197
198 /* Tui configuration variables controlled with set/show command. */
199 const char *tui_active_border_mode = "bold-standout";
200 static void
201 show_tui_active_border_mode (struct ui_file *file,
202 int from_tty,
203 struct cmd_list_element *c,
204 const char *value)
205 {
206 fprintf_filtered (file, _("\
207 The attribute mode to use for the active TUI window border is \"%s\".\n"),
208 value);
209 }
210
211 const char *tui_border_mode = "normal";
212 static void
213 show_tui_border_mode (struct ui_file *file,
214 int from_tty,
215 struct cmd_list_element *c,
216 const char *value)
217 {
218 fprintf_filtered (file, _("\
219 The attribute mode to use for the TUI window borders is \"%s\".\n"),
220 value);
221 }
222
223 const char *tui_border_kind = "acs";
224 static void
225 show_tui_border_kind (struct ui_file *file,
226 int from_tty,
227 struct cmd_list_element *c,
228 const char *value)
229 {
230 fprintf_filtered (file, _("The kind of border for TUI windows is \"%s\".\n"),
231 value);
232 }
233
234
235 /* Tui internal configuration variables. These variables are updated
236 by tui_update_variables to reflect the tui configuration
237 variables. */
238 chtype tui_border_vline;
239 chtype tui_border_hline;
240 chtype tui_border_ulcorner;
241 chtype tui_border_urcorner;
242 chtype tui_border_llcorner;
243 chtype tui_border_lrcorner;
244
245 int tui_border_attrs;
246 int tui_active_border_attrs;
247
248 /* Identify the item in the translation table.
249 When the item is not recognized, use the default entry. */
250 static struct tui_translate *
251 translate (const char *name, struct tui_translate *table)
252 {
253 while (table->name)
254 {
255 if (name && strcmp (table->name, name) == 0)
256 return table;
257 table++;
258 }
259
260 /* Not found, return default entry. */
261 table++;
262 return table;
263 }
264
265 /* Update the tui internal configuration according to gdb settings.
266 Returns 1 if the configuration has changed and the screen should
267 be redrawn. */
268 int
269 tui_update_variables (void)
270 {
271 int need_redraw = 0;
272 struct tui_translate *entry;
273
274 entry = translate (tui_border_mode, tui_border_mode_translate);
275 if (tui_border_attrs != entry->value)
276 {
277 tui_border_attrs = entry->value;
278 need_redraw = 1;
279 }
280 entry = translate (tui_active_border_mode, tui_border_mode_translate);
281 if (tui_active_border_attrs != entry->value)
282 {
283 tui_active_border_attrs = entry->value;
284 need_redraw = 1;
285 }
286
287 /* If one corner changes, all characters are changed.
288 Only check the first one. The ACS characters are determined at
289 run time by curses terminal management. */
290 entry = translate (tui_border_kind, tui_border_kind_translate_lrcorner);
291 if (tui_border_lrcorner != (chtype) entry->value)
292 {
293 tui_border_lrcorner = (entry->value < 0) ? ACS_LRCORNER : entry->value;
294 need_redraw = 1;
295 }
296 entry = translate (tui_border_kind, tui_border_kind_translate_llcorner);
297 tui_border_llcorner = (entry->value < 0) ? ACS_LLCORNER : entry->value;
298
299 entry = translate (tui_border_kind, tui_border_kind_translate_ulcorner);
300 tui_border_ulcorner = (entry->value < 0) ? ACS_ULCORNER : entry->value;
301
302 entry = translate (tui_border_kind, tui_border_kind_translate_urcorner);
303 tui_border_urcorner = (entry->value < 0) ? ACS_URCORNER : entry->value;
304
305 entry = translate (tui_border_kind, tui_border_kind_translate_hline);
306 tui_border_hline = (entry->value < 0) ? ACS_HLINE : entry->value;
307
308 entry = translate (tui_border_kind, tui_border_kind_translate_vline);
309 tui_border_vline = (entry->value < 0) ? ACS_VLINE : entry->value;
310
311 return need_redraw;
312 }
313
314 static void
315 set_tui_cmd (const char *args, int from_tty)
316 {
317 }
318
319 static void
320 show_tui_cmd (const char *args, int from_tty)
321 {
322 }
323
324 static struct cmd_list_element *tuilist;
325
326 static void
327 tui_command (const char *args, int from_tty)
328 {
329 printf_unfiltered (_("\"tui\" must be followed by the name of a "
330 "tui command.\n"));
331 help_list (tuilist, "tui ", all_commands, gdb_stdout);
332 }
333
334 struct cmd_list_element **
335 tui_get_cmd_list (void)
336 {
337 if (tuilist == 0)
338 add_prefix_cmd ("tui", class_tui, tui_command,
339 _("Text User Interface commands."),
340 &tuilist, "tui ", 0, &cmdlist);
341 return &tuilist;
342 }
343
344 /* The set_func hook of "set tui ..." commands that affect the window
345 borders on the TUI display. */
346 void
347 tui_set_var_cmd (const char *null_args,
348 int from_tty, struct cmd_list_element *c)
349 {
350 if (tui_update_variables () && tui_active)
351 tui_rehighlight_all ();
352 }
353
354 /* Generic window name completion function. Complete window name pointed
355 to by TEXT and WORD. If INCLUDE_NEXT_PREV_P is true then the special
356 window names 'next' and 'prev' will also be considered as possible
357 completions of the window name. */
358
359 static void
360 window_name_completer (completion_tracker &tracker,
361 int include_next_prev_p,
362 const char *text, const char *word)
363 {
364 std::vector<const char *> completion_name_vec;
365
366 for (tui_win_info *win_info : all_tui_windows ())
367 {
368 const char *completion_name = NULL;
369
370 /* We can't focus on an invisible window. */
371 if (!win_info->is_visible)
372 continue;
373
374 completion_name = win_info->name ();
375 gdb_assert (completion_name != NULL);
376 completion_name_vec.push_back (completion_name);
377 }
378
379 /* If no windows are considered visible then the TUI has not yet been
380 initialized. But still "focus src" and "focus cmd" will work because
381 invoking the focus command will entail initializing the TUI which sets the
382 default layout to SRC_COMMAND. */
383 if (completion_name_vec.empty ())
384 {
385 completion_name_vec.push_back (SRC_NAME);
386 completion_name_vec.push_back (CMD_NAME);
387 }
388
389 if (include_next_prev_p)
390 {
391 completion_name_vec.push_back ("next");
392 completion_name_vec.push_back ("prev");
393 }
394
395
396 completion_name_vec.push_back (NULL);
397 complete_on_enum (tracker, completion_name_vec.data (), text, word);
398 }
399
400 /* Complete possible window names to focus on. TEXT is the complete text
401 entered so far, WORD is the word currently being completed. */
402
403 static void
404 focus_completer (struct cmd_list_element *ignore,
405 completion_tracker &tracker,
406 const char *text, const char *word)
407 {
408 window_name_completer (tracker, 1, text, word);
409 }
410
411 /* Complete possible window names for winheight command. TEXT is the
412 complete text entered so far, WORD is the word currently being
413 completed. */
414
415 static void
416 winheight_completer (struct cmd_list_element *ignore,
417 completion_tracker &tracker,
418 const char *text, const char *word)
419 {
420 /* The first word is the window name. That we can complete. Subsequent
421 words can't be completed. */
422 if (word != text)
423 return;
424
425 window_name_completer (tracker, 0, text, word);
426 }
427
428 /* Update gdb's knowledge of the terminal size. */
429 void
430 tui_update_gdb_sizes (void)
431 {
432 int width, height;
433
434 if (tui_active)
435 {
436 width = TUI_CMD_WIN->width;
437 height = TUI_CMD_WIN->height;
438 }
439 else
440 {
441 width = tui_term_width ();
442 height = tui_term_height ();
443 }
444
445 set_screen_width_and_height (width, height);
446 }
447
448
449 /* Set the logical focus to win_info. */
450 void
451 tui_set_win_focus_to (struct tui_win_info *win_info)
452 {
453 if (win_info != NULL)
454 {
455 struct tui_win_info *win_with_focus = tui_win_with_focus ();
456
457 tui_unhighlight_win (win_with_focus);
458 tui_set_win_with_focus (win_info);
459 tui_highlight_win (win_info);
460 }
461 }
462
463
464 void
465 tui_win_info::forward_scroll (int num_to_scroll)
466 {
467 if (num_to_scroll == 0)
468 num_to_scroll = height - 3;
469
470 do_scroll_vertical (num_to_scroll);
471 }
472
473 void
474 tui_win_info::backward_scroll (int num_to_scroll)
475 {
476 if (num_to_scroll == 0)
477 num_to_scroll = height - 3;
478
479 do_scroll_vertical (-num_to_scroll);
480 }
481
482
483 void
484 tui_win_info::left_scroll (int num_to_scroll)
485 {
486 if (num_to_scroll == 0)
487 num_to_scroll = 1;
488
489 do_scroll_horizontal (num_to_scroll);
490 }
491
492
493 void
494 tui_win_info::right_scroll (int num_to_scroll)
495 {
496 if (num_to_scroll == 0)
497 num_to_scroll = 1;
498
499 do_scroll_horizontal (-num_to_scroll);
500 }
501
502
503 /* See tui-data.h. */
504
505 void
506 tui_source_window_base::refresh_all ()
507 {
508 tui_show_source_content (this);
509 tui_check_and_display_highlight_if_needed (this);
510 tui_erase_exec_info_content (this);
511 tui_update_exec_info (this);
512 }
513
514 void
515 tui_refresh_all_win (void)
516 {
517 clearok (curscr, TRUE);
518 tui_refresh_all ();
519 for (tui_win_info *win_info : all_tui_windows ())
520 {
521 if (win_info->is_visible)
522 win_info->refresh_all ();
523 }
524 tui_show_locator_content ();
525 }
526
527 void
528 tui_rehighlight_all (void)
529 {
530 for (tui_win_info *win_info : all_tui_windows ())
531 tui_check_and_display_highlight_if_needed (win_info);
532 }
533
534 /* Resize all the windows based on the terminal size. This function
535 gets called from within the readline SIGWINCH handler. */
536 void
537 tui_resize_all (void)
538 {
539 int height_diff, width_diff;
540 int screenheight, screenwidth;
541
542 rl_get_screen_size (&screenheight, &screenwidth);
543 width_diff = screenwidth - tui_term_width ();
544 height_diff = screenheight - tui_term_height ();
545 if (height_diff || width_diff)
546 {
547 enum tui_layout_type cur_layout = tui_current_layout ();
548 struct tui_win_info *win_with_focus = tui_win_with_focus ();
549 struct tui_win_info *first_win;
550 struct tui_win_info *second_win;
551 tui_source_window_base *src_win;
552 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
553 int win_type;
554 int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2;
555
556 #ifdef HAVE_RESIZE_TERM
557 resize_term (screenheight, screenwidth);
558 #endif
559 /* Turn keypad off while we resize. */
560 if (win_with_focus != TUI_CMD_WIN)
561 keypad (TUI_CMD_WIN->handle, FALSE);
562 tui_update_gdb_sizes ();
563 tui_set_term_height_to (screenheight);
564 tui_set_term_width_to (screenwidth);
565 if (cur_layout == SRC_DISASSEM_COMMAND
566 || cur_layout == SRC_DATA_COMMAND
567 || cur_layout == DISASSEM_DATA_COMMAND)
568 num_wins_displayed++;
569 split_diff = height_diff / num_wins_displayed;
570 cmd_split_diff = split_diff;
571 if (height_diff % num_wins_displayed)
572 {
573 if (height_diff < 0)
574 cmd_split_diff--;
575 else
576 cmd_split_diff++;
577 }
578 /* Now adjust each window. */
579 /* erase + clearok are used instead of a straightforward clear as
580 AIX 5.3 does not define clear. */
581 erase ();
582 clearok (curscr, TRUE);
583 refresh ();
584 switch (cur_layout)
585 {
586 case SRC_COMMAND:
587 case DISASSEM_COMMAND:
588 src_win = tui_source_windows ()[0];
589 first_win = src_win;
590 first_win->width += width_diff;
591 locator->width += width_diff;
592 /* Check for invalid heights. */
593 if (height_diff == 0)
594 new_height = first_win->height;
595 else if ((first_win->height + split_diff) >=
596 (screenheight - MIN_CMD_WIN_HEIGHT - 1))
597 new_height = screenheight - MIN_CMD_WIN_HEIGHT - 1;
598 else if ((first_win->height + split_diff) <= 0)
599 new_height = MIN_WIN_HEIGHT;
600 else
601 new_height = first_win->height + split_diff;
602
603 locator->origin.y = new_height + 1;
604 make_invisible_and_set_new_height (first_win, new_height);
605 TUI_CMD_WIN->origin.y = locator->origin.y + 1;
606 TUI_CMD_WIN->width += width_diff;
607 new_height = screenheight - TUI_CMD_WIN->origin.y;
608 make_invisible_and_set_new_height (TUI_CMD_WIN, new_height);
609 first_win->make_visible_with_new_height ();
610 TUI_CMD_WIN->make_visible_with_new_height ();
611 if (src_win->content.empty ())
612 tui_erase_source_content (src_win);
613 break;
614 default:
615 if (cur_layout == SRC_DISASSEM_COMMAND)
616 {
617 src_win = TUI_SRC_WIN;
618 first_win = src_win;
619 first_win->width += width_diff;
620 second_win = TUI_DISASM_WIN;
621 second_win->width += width_diff;
622 }
623 else
624 {
625 first_win = TUI_DATA_WIN;
626 first_win->width += width_diff;
627 src_win = tui_source_windows ()[0];
628 second_win = src_win;
629 second_win->width += width_diff;
630 }
631 /* Change the first window's height/width. */
632 /* Check for invalid heights. */
633 if (height_diff == 0)
634 new_height = first_win->height;
635 else if ((first_win->height +
636 second_win->height + (split_diff * 2)) >=
637 (screenheight - MIN_CMD_WIN_HEIGHT - 1))
638 new_height = (screenheight - MIN_CMD_WIN_HEIGHT - 1) / 2;
639 else if ((first_win->height + split_diff) <= 0)
640 new_height = MIN_WIN_HEIGHT;
641 else
642 new_height = first_win->height + split_diff;
643 make_invisible_and_set_new_height (first_win, new_height);
644
645 locator->width += width_diff;
646
647 /* Change the second window's height/width. */
648 /* Check for invalid heights. */
649 if (height_diff == 0)
650 new_height = second_win->height;
651 else if ((first_win->height +
652 second_win->height + (split_diff * 2)) >=
653 (screenheight - MIN_CMD_WIN_HEIGHT - 1))
654 {
655 new_height = screenheight - MIN_CMD_WIN_HEIGHT - 1;
656 if (new_height % 2)
657 new_height = (new_height / 2) + 1;
658 else
659 new_height /= 2;
660 }
661 else if ((second_win->height + split_diff) <= 0)
662 new_height = MIN_WIN_HEIGHT;
663 else
664 new_height = second_win->height + split_diff;
665 second_win->origin.y = first_win->height - 1;
666 make_invisible_and_set_new_height (second_win, new_height);
667
668 /* Change the command window's height/width. */
669 TUI_CMD_WIN->origin.y = locator->origin.y + 1;
670 make_invisible_and_set_new_height (TUI_CMD_WIN,
671 TUI_CMD_WIN->height
672 + cmd_split_diff);
673 first_win->make_visible_with_new_height ();
674 second_win->make_visible_with_new_height ();
675 TUI_CMD_WIN->make_visible_with_new_height ();
676 if (src_win->content.empty ())
677 tui_erase_source_content (src_win);
678 break;
679 }
680 /* Now remove all invisible windows, and their content so that
681 they get created again when called for with the new size. */
682 for (win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
683 {
684 if (win_type != CMD_WIN
685 && (tui_win_list[win_type] != NULL)
686 && !tui_win_list[win_type]->is_visible)
687 {
688 delete tui_win_list[win_type];
689 tui_win_list[win_type] = NULL;
690 }
691 }
692 /* Turn keypad back on, unless focus is in the command
693 window. */
694 if (win_with_focus != TUI_CMD_WIN)
695 keypad (TUI_CMD_WIN->handle, TRUE);
696 }
697 }
698
699 #ifdef SIGWINCH
700 /* Token for use by TUI's asynchronous SIGWINCH handler. */
701 static struct async_signal_handler *tui_sigwinch_token;
702
703 /* TUI's SIGWINCH signal handler. */
704 static void
705 tui_sigwinch_handler (int signal)
706 {
707 mark_async_signal_handler (tui_sigwinch_token);
708 tui_set_win_resized_to (TRUE);
709 }
710
711 /* Callback for asynchronously resizing TUI following a SIGWINCH signal. */
712 static void
713 tui_async_resize_screen (gdb_client_data arg)
714 {
715 rl_resize_terminal ();
716
717 if (!tui_active)
718 {
719 int screen_height, screen_width;
720
721 rl_get_screen_size (&screen_height, &screen_width);
722 set_screen_width_and_height (screen_width, screen_height);
723
724 /* win_resized is left set so that the next call to tui_enable()
725 resizes the TUI windows. */
726 }
727 else
728 {
729 tui_set_win_resized_to (FALSE);
730 tui_resize_all ();
731 tui_refresh_all_win ();
732 tui_update_gdb_sizes ();
733 tui_redisplay_readline ();
734 }
735 }
736 #endif
737
738 /* Initialize TUI's SIGWINCH signal handler. Note that the handler is not
739 uninstalled when we exit TUI, so the handler should not assume that TUI is
740 always active. */
741 void
742 tui_initialize_win (void)
743 {
744 #ifdef SIGWINCH
745 tui_sigwinch_token
746 = create_async_signal_handler (tui_async_resize_screen, NULL);
747
748 {
749 #ifdef HAVE_SIGACTION
750 struct sigaction old_winch;
751
752 memset (&old_winch, 0, sizeof (old_winch));
753 old_winch.sa_handler = &tui_sigwinch_handler;
754 #ifdef SA_RESTART
755 old_winch.sa_flags = SA_RESTART;
756 #endif
757 sigaction (SIGWINCH, &old_winch, NULL);
758 #else
759 signal (SIGWINCH, &tui_sigwinch_handler);
760 #endif
761 }
762 #endif
763 }
764
765
766 /*************************
767 ** STATIC LOCAL FUNCTIONS
768 **************************/
769
770
771 static void
772 tui_scroll_forward_command (const char *arg, int from_tty)
773 {
774 int num_to_scroll = 1;
775 struct tui_win_info *win_to_scroll;
776
777 /* Make sure the curses mode is enabled. */
778 tui_enable ();
779 if (arg == NULL)
780 parse_scrolling_args (arg, &win_to_scroll, NULL);
781 else
782 parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
783 win_to_scroll->forward_scroll (num_to_scroll);
784 }
785
786
787 static void
788 tui_scroll_backward_command (const char *arg, int from_tty)
789 {
790 int num_to_scroll = 1;
791 struct tui_win_info *win_to_scroll;
792
793 /* Make sure the curses mode is enabled. */
794 tui_enable ();
795 if (arg == NULL)
796 parse_scrolling_args (arg, &win_to_scroll, NULL);
797 else
798 parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
799 win_to_scroll->backward_scroll (num_to_scroll);
800 }
801
802
803 static void
804 tui_scroll_left_command (const char *arg, int from_tty)
805 {
806 int num_to_scroll;
807 struct tui_win_info *win_to_scroll;
808
809 /* Make sure the curses mode is enabled. */
810 tui_enable ();
811 parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
812 win_to_scroll->left_scroll (num_to_scroll);
813 }
814
815
816 static void
817 tui_scroll_right_command (const char *arg, int from_tty)
818 {
819 int num_to_scroll;
820 struct tui_win_info *win_to_scroll;
821
822 /* Make sure the curses mode is enabled. */
823 tui_enable ();
824 parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll);
825 win_to_scroll->right_scroll (num_to_scroll);
826 }
827
828
829 /* Set focus to the window named by 'arg'. */
830 static void
831 tui_set_focus_command (const char *arg, int from_tty)
832 {
833 tui_enable ();
834
835 if (arg != NULL)
836 {
837 char *buf_ptr = xstrdup (arg);
838 int i;
839 struct tui_win_info *win_info = NULL;
840
841 for (i = 0; (i < strlen (buf_ptr)); i++)
842 buf_ptr[i] = tolower (arg[i]);
843
844 if (subset_compare (buf_ptr, "next"))
845 win_info = tui_next_win (tui_win_with_focus ());
846 else if (subset_compare (buf_ptr, "prev"))
847 win_info = tui_prev_win (tui_win_with_focus ());
848 else
849 win_info = tui_partial_win_by_name (buf_ptr);
850
851 if (win_info == NULL || !win_info->is_visible)
852 warning (_("Invalid window specified. \n\
853 The window name specified must be valid and visible.\n"));
854 else
855 {
856 tui_set_win_focus_to (win_info);
857 keypad (TUI_CMD_WIN->handle, (win_info != TUI_CMD_WIN));
858 }
859
860 if (TUI_DATA_WIN && TUI_DATA_WIN->is_visible)
861 TUI_DATA_WIN->refresh_all ();
862 xfree (buf_ptr);
863 printf_filtered (_("Focus set to %s window.\n"),
864 tui_win_with_focus ()->name ());
865 }
866 else
867 warning (_("Incorrect Number of Arguments.\n%s"), FOCUS_USAGE);
868 }
869
870 static void
871 tui_all_windows_info (const char *arg, int from_tty)
872 {
873 struct tui_win_info *win_with_focus = tui_win_with_focus ();
874
875 for (tui_win_info *win_info : all_tui_windows ())
876 if (win_info->is_visible)
877 {
878 if (win_with_focus == win_info)
879 printf_filtered (" %s\t(%d lines) <has focus>\n",
880 win_info->name (),
881 win_info->height);
882 else
883 printf_filtered (" %s\t(%d lines)\n",
884 win_info->name (),
885 win_info->height);
886 }
887 }
888
889
890 static void
891 tui_refresh_all_command (const char *arg, int from_tty)
892 {
893 /* Make sure the curses mode is enabled. */
894 tui_enable ();
895
896 tui_refresh_all_win ();
897 }
898
899 /* The tab width that should be used by the TUI. */
900
901 unsigned int tui_tab_width = DEFAULT_TAB_LEN;
902
903 /* The tab width as set by the user. */
904
905 static unsigned int internal_tab_width = DEFAULT_TAB_LEN;
906
907 /* See tui-data.h. */
908
909 void
910 tui_source_window_base::update_tab_width ()
911 {
912 /* We don't really change the height of any windows, but
913 calling these 2 functions causes a complete regeneration
914 and redisplay of the window's contents, which will take
915 the new tab width into account. */
916 make_invisible_and_set_new_height (this, height);
917 make_visible_with_new_height ();
918 }
919
920 /* After the tab width is set, call this to update the relevant
921 windows. */
922
923 static void
924 update_tab_width ()
925 {
926 for (tui_win_info *win_info : all_tui_windows ())
927 {
928 if (win_info->is_visible)
929 win_info->update_tab_width ();
930 }
931 }
932
933 /* Callback for "set tui tab-width". */
934
935 static void
936 tui_set_tab_width (const char *ignore,
937 int from_tty, struct cmd_list_element *c)
938 {
939 if (internal_tab_width == 0)
940 {
941 internal_tab_width = tui_tab_width;
942 error (_("Tab width must not be 0"));
943 }
944
945 tui_tab_width = internal_tab_width;
946 update_tab_width ();
947 }
948
949 /* Callback for "show tui tab-width". */
950
951 static void
952 tui_show_tab_width (struct ui_file *file, int from_tty,
953 struct cmd_list_element *c, const char *value)
954 {
955 fprintf_filtered (gdb_stdout, _("TUI tab width is %s spaces.\n"), value);
956
957 }
958
959 /* Set the tab width of the specified window. */
960 static void
961 tui_set_tab_width_command (const char *arg, int from_tty)
962 {
963 /* Make sure the curses mode is enabled. */
964 tui_enable ();
965 if (arg != NULL)
966 {
967 int ts;
968
969 ts = atoi (arg);
970 if (ts <= 0)
971 warning (_("Tab widths greater than 0 must be specified."));
972 else
973 {
974 internal_tab_width = ts;
975 tui_tab_width = ts;
976
977 update_tab_width ();
978 }
979 }
980 }
981
982
983 /* Set the height of the specified window. */
984 static void
985 tui_set_win_height_command (const char *arg, int from_tty)
986 {
987 /* Make sure the curses mode is enabled. */
988 tui_enable ();
989 if (arg != NULL)
990 {
991 std::string copy = arg;
992 char *buf = &copy[0];
993 char *buf_ptr = buf;
994 char *wname = NULL;
995 int new_height, i;
996 struct tui_win_info *win_info;
997
998 wname = buf_ptr;
999 buf_ptr = strchr (buf_ptr, ' ');
1000 if (buf_ptr != NULL)
1001 {
1002 *buf_ptr = (char) 0;
1003
1004 /* Validate the window name. */
1005 for (i = 0; i < strlen (wname); i++)
1006 wname[i] = tolower (wname[i]);
1007 win_info = tui_partial_win_by_name (wname);
1008
1009 if (win_info == NULL || !win_info->is_visible)
1010 warning (_("Invalid window specified. \n\
1011 The window name specified must be valid and visible.\n"));
1012 else
1013 {
1014 /* Process the size. */
1015 while (*(++buf_ptr) == ' ')
1016 ;
1017
1018 if (*buf_ptr != (char) 0)
1019 {
1020 int negate = FALSE;
1021 int fixed_size = TRUE;
1022 int input_no;;
1023
1024 if (*buf_ptr == '+' || *buf_ptr == '-')
1025 {
1026 if (*buf_ptr == '-')
1027 negate = TRUE;
1028 fixed_size = FALSE;
1029 buf_ptr++;
1030 }
1031 input_no = atoi (buf_ptr);
1032 if (input_no > 0)
1033 {
1034 if (negate)
1035 input_no *= (-1);
1036 if (fixed_size)
1037 new_height = input_no;
1038 else
1039 new_height = win_info->height + input_no;
1040
1041 /* Now change the window's height, and adjust
1042 all other windows around it. */
1043 if (tui_adjust_win_heights (win_info,
1044 new_height) == TUI_FAILURE)
1045 warning (_("Invalid window height specified.\n%s"),
1046 WIN_HEIGHT_USAGE);
1047 else
1048 tui_update_gdb_sizes ();
1049 }
1050 else
1051 warning (_("Invalid window height specified.\n%s"),
1052 WIN_HEIGHT_USAGE);
1053 }
1054 }
1055 }
1056 else
1057 printf_filtered (WIN_HEIGHT_USAGE);
1058 }
1059 else
1060 printf_filtered (WIN_HEIGHT_USAGE);
1061 }
1062
1063 /* Function to adjust all window heights around the primary. */
1064 static enum tui_status
1065 tui_adjust_win_heights (struct tui_win_info *primary_win_info,
1066 int new_height)
1067 {
1068 enum tui_status status = TUI_FAILURE;
1069
1070 if (new_height_ok (primary_win_info, new_height))
1071 {
1072 status = TUI_SUCCESS;
1073 if (new_height != primary_win_info->height)
1074 {
1075 int diff;
1076 struct tui_win_info *win_info;
1077 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
1078 enum tui_layout_type cur_layout = tui_current_layout ();
1079
1080 diff = (new_height - primary_win_info->height) * (-1);
1081 if (cur_layout == SRC_COMMAND
1082 || cur_layout == DISASSEM_COMMAND)
1083 {
1084 struct tui_win_info *src_win_info;
1085
1086 make_invisible_and_set_new_height (primary_win_info, new_height);
1087 if (primary_win_info->type == CMD_WIN)
1088 {
1089 win_info = tui_source_windows ()[0];
1090 src_win_info = win_info;
1091 }
1092 else
1093 {
1094 win_info = tui_win_list[CMD_WIN];
1095 src_win_info = primary_win_info;
1096 }
1097 make_invisible_and_set_new_height (win_info,
1098 win_info->height + diff);
1099 TUI_CMD_WIN->origin.y = locator->origin.y + 1;
1100 win_info->make_visible_with_new_height ();
1101 primary_win_info->make_visible_with_new_height ();
1102 if ((src_win_info->type == SRC_WIN
1103 || src_win_info->type == DISASSEM_WIN))
1104 {
1105 tui_source_window_base *src_base
1106 = (tui_source_window_base *) src_win_info;
1107 if (src_base->content.empty ())
1108 tui_erase_source_content (src_base);
1109 }
1110 }
1111 else
1112 {
1113 struct tui_win_info *first_win;
1114 struct tui_source_window_base *second_win;
1115 tui_source_window_base *src1;
1116
1117 if (cur_layout == SRC_DISASSEM_COMMAND)
1118 {
1119 src1 = TUI_SRC_WIN;
1120 first_win = src1;
1121 second_win = TUI_DISASM_WIN;
1122 }
1123 else
1124 {
1125 src1 = nullptr;
1126 first_win = TUI_DATA_WIN;
1127 second_win = tui_source_windows ()[0];
1128 }
1129 if (primary_win_info == TUI_CMD_WIN)
1130 { /* Split the change in height accross the 1st & 2nd
1131 windows, adjusting them as well. */
1132 /* Subtract the locator. */
1133 int first_split_diff = diff / 2;
1134 int second_split_diff = first_split_diff;
1135
1136 if (diff % 2)
1137 {
1138 if (first_win->height >
1139 second_win->height)
1140 if (diff < 0)
1141 first_split_diff--;
1142 else
1143 first_split_diff++;
1144 else
1145 {
1146 if (diff < 0)
1147 second_split_diff--;
1148 else
1149 second_split_diff++;
1150 }
1151 }
1152 /* Make sure that the minimum hieghts are
1153 honored. */
1154 while ((first_win->height + first_split_diff) < 3)
1155 {
1156 first_split_diff++;
1157 second_split_diff--;
1158 }
1159 while ((second_win->height + second_split_diff) < 3)
1160 {
1161 second_split_diff++;
1162 first_split_diff--;
1163 }
1164 make_invisible_and_set_new_height (
1165 first_win,
1166 first_win->height + first_split_diff);
1167 second_win->origin.y = first_win->height - 1;
1168 make_invisible_and_set_new_height (second_win,
1169 second_win->height
1170 + second_split_diff);
1171 TUI_CMD_WIN->origin.y = locator->origin.y + 1;
1172 make_invisible_and_set_new_height (TUI_CMD_WIN, new_height);
1173 }
1174 else
1175 {
1176 if ((TUI_CMD_WIN->height + diff) < 1)
1177 { /* If there is no way to increase the command
1178 window take real estate from the 1st or 2nd
1179 window. */
1180 if ((TUI_CMD_WIN->height + diff) < 1)
1181 {
1182 int i;
1183
1184 for (i = TUI_CMD_WIN->height + diff;
1185 (i < 1); i++)
1186 if (primary_win_info == first_win)
1187 second_win->height--;
1188 else
1189 first_win->height--;
1190 }
1191 }
1192 if (primary_win_info == first_win)
1193 make_invisible_and_set_new_height (first_win, new_height);
1194 else
1195 make_invisible_and_set_new_height (
1196 first_win,
1197 first_win->height);
1198 second_win->origin.y = first_win->height - 1;
1199 if (primary_win_info == second_win)
1200 make_invisible_and_set_new_height (second_win, new_height);
1201 else
1202 make_invisible_and_set_new_height (
1203 second_win, second_win->height);
1204 TUI_CMD_WIN->origin.y = locator->origin.y + 1;
1205 if ((TUI_CMD_WIN->height + diff) < 1)
1206 make_invisible_and_set_new_height (TUI_CMD_WIN, 1);
1207 else
1208 make_invisible_and_set_new_height (TUI_CMD_WIN,
1209 TUI_CMD_WIN->height + diff);
1210 }
1211 TUI_CMD_WIN->make_visible_with_new_height ();
1212 second_win->make_visible_with_new_height ();
1213 first_win->make_visible_with_new_height ();
1214 if (src1 != nullptr && src1->content.empty ())
1215 tui_erase_source_content (src1);
1216 if (second_win->content.empty ())
1217 tui_erase_source_content (second_win);
1218 }
1219 }
1220 }
1221
1222 return status;
1223 }
1224
1225
1226 /* See tui-data.h. */
1227
1228 void
1229 tui_source_window_base::set_new_height (int height)
1230 {
1231 tui_make_invisible (execution_info);
1232 execution_info->height = height;
1233 execution_info->origin.y = origin.y;
1234 if (height > 1)
1235 execution_info->viewport_height = height - 1;
1236 else
1237 execution_info->viewport_height = height;
1238 execution_info->viewport_height--;
1239
1240 if (has_locator ())
1241 {
1242 tui_locator_window *gen_win_info = tui_locator_win_info_ptr ();
1243 tui_make_invisible (gen_win_info);
1244 gen_win_info->origin.y = origin.y + height;
1245 }
1246 }
1247
1248 /* See tui-data.h. */
1249
1250 void
1251 tui_data_window::set_new_height (int height)
1252 {
1253 /* Delete all data item windows. */
1254 for (auto &&win : regs_content)
1255 {
1256 tui_delete_win (win->handle);
1257 win->handle = NULL;
1258 }
1259 }
1260
1261 /* Function make the target window (and auxiliary windows associated
1262 with the targer) invisible, and set the new height and
1263 location. */
1264 static void
1265 make_invisible_and_set_new_height (struct tui_win_info *win_info,
1266 int height)
1267 {
1268 tui_make_invisible (win_info);
1269 win_info->height = height;
1270 if (height > 1)
1271 win_info->viewport_height = height - 1;
1272 else
1273 win_info->viewport_height = height;
1274 if (win_info != TUI_CMD_WIN)
1275 win_info->viewport_height--;
1276
1277 /* Now deal with the auxiliary windows associated with win_info. */
1278 win_info->set_new_height (height);
1279 }
1280
1281
1282 /* See tui-data.h. */
1283
1284 void
1285 tui_win_info::make_visible_with_new_height ()
1286 {
1287 make_visible (true);
1288 tui_check_and_display_highlight_if_needed (this);
1289 do_make_visible_with_new_height ();
1290 }
1291
1292 /* See tui-data.h. */
1293
1294 void
1295 tui_source_window_base::do_make_visible_with_new_height ()
1296 {
1297 tui_make_visible (execution_info);
1298 if (!content.empty ())
1299 {
1300 struct tui_line_or_address line_or_addr;
1301 struct symtab_and_line cursal
1302 = get_current_source_symtab_and_line ();
1303
1304 line_or_addr = start_line_or_addr;
1305 tui_update_source_window (this, gdbarch,
1306 cursal.symtab, line_or_addr, TRUE);
1307 }
1308 else if (deprecated_safe_get_selected_frame () != NULL)
1309 {
1310 struct tui_line_or_address line;
1311 struct symtab_and_line cursal
1312 = get_current_source_symtab_and_line ();
1313 struct frame_info *frame = deprecated_safe_get_selected_frame ();
1314 struct gdbarch *gdbarch = get_frame_arch (frame);
1315
1316 struct symtab *s = find_pc_line_symtab (get_frame_pc (frame));
1317 if (type == SRC_WIN)
1318 {
1319 line.loa = LOA_LINE;
1320 line.u.line_no = cursal.line;
1321 }
1322 else
1323 {
1324 line.loa = LOA_ADDRESS;
1325 find_line_pc (s, cursal.line, &line.u.addr);
1326 }
1327 tui_update_source_window (this, gdbarch, s, line, TRUE);
1328 }
1329 if (has_locator ())
1330 {
1331 tui_make_visible (tui_locator_win_info_ptr ());
1332 tui_show_locator_content ();
1333 }
1334 }
1335
1336 /* See tui-data.h. */
1337
1338 void
1339 tui_data_window::do_make_visible_with_new_height ()
1340 {
1341 display_all_data ();
1342 }
1343
1344 /* See tui-data.h. */
1345
1346 void
1347 tui_cmd_window::do_make_visible_with_new_height ()
1348 {
1349 #ifdef HAVE_WRESIZE
1350 wresize (handle, height, width);
1351 #endif
1352 mvwin (handle, origin.y, origin.x);
1353 wmove (handle, 0, 0);
1354 }
1355
1356 /* See tui-data.h. */
1357
1358 int
1359 tui_win_info::max_height () const
1360 {
1361 return tui_term_height () - 2;
1362 }
1363
1364 /* See tui-data.h. */
1365
1366 int
1367 tui_cmd_window::max_height () const
1368 {
1369 return tui_term_height () - 4;
1370 }
1371
1372 static int
1373 new_height_ok (struct tui_win_info *primary_win_info,
1374 int new_height)
1375 {
1376 int ok = (new_height < tui_term_height ());
1377
1378 if (ok)
1379 {
1380 int diff;
1381 enum tui_layout_type cur_layout = tui_current_layout ();
1382
1383 diff = (new_height - primary_win_info->height) * (-1);
1384 if (cur_layout == SRC_COMMAND || cur_layout == DISASSEM_COMMAND)
1385 {
1386 ok = (new_height <= primary_win_info->max_height ()
1387 && new_height >= MIN_CMD_WIN_HEIGHT);
1388 if (ok)
1389 { /* Check the total height. */
1390 struct tui_win_info *win_info;
1391
1392 if (primary_win_info == TUI_CMD_WIN)
1393 win_info = tui_source_windows ()[0];
1394 else
1395 win_info = TUI_CMD_WIN;
1396 ok = ((new_height +
1397 (win_info->height + diff)) <= tui_term_height ());
1398 }
1399 }
1400 else
1401 {
1402 int cur_total_height, total_height, min_height = 0;
1403 struct tui_win_info *first_win;
1404 struct tui_win_info *second_win;
1405
1406 if (cur_layout == SRC_DISASSEM_COMMAND)
1407 {
1408 first_win = TUI_SRC_WIN;
1409 second_win = TUI_DISASM_WIN;
1410 }
1411 else
1412 {
1413 first_win = TUI_DATA_WIN;
1414 second_win = tui_source_windows ()[0];
1415 }
1416 /* We could simply add all the heights to obtain the same
1417 result but below is more explicit since we subtract 1 for
1418 the line that the first and second windows share, and add
1419 one for the locator. */
1420 total_height = cur_total_height =
1421 (first_win->height + second_win->height - 1)
1422 + TUI_CMD_WIN->height + 1; /* Locator. */
1423 if (primary_win_info == TUI_CMD_WIN)
1424 {
1425 /* Locator included since first & second win share a line. */
1426 ok = ((first_win->height +
1427 second_win->height + diff) >=
1428 (MIN_WIN_HEIGHT * 2)
1429 && new_height >= MIN_CMD_WIN_HEIGHT);
1430 if (ok)
1431 {
1432 total_height = new_height +
1433 (first_win->height +
1434 second_win->height + diff);
1435 min_height = MIN_CMD_WIN_HEIGHT;
1436 }
1437 }
1438 else
1439 {
1440 min_height = MIN_WIN_HEIGHT;
1441
1442 /* First see if we can increase/decrease the command
1443 window. And make sure that the command window is at
1444 least 1 line. */
1445 ok = ((TUI_CMD_WIN->height + diff) > 0);
1446 if (!ok)
1447 { /* Looks like we have to increase/decrease one of
1448 the other windows. */
1449 if (primary_win_info == first_win)
1450 ok = (second_win->height + diff) >= min_height;
1451 else
1452 ok = (first_win->height + diff) >= min_height;
1453 }
1454 if (ok)
1455 {
1456 if (primary_win_info == first_win)
1457 total_height = new_height +
1458 second_win->height +
1459 TUI_CMD_WIN->height + diff;
1460 else
1461 total_height = new_height +
1462 first_win->height +
1463 TUI_CMD_WIN->height + diff;
1464 }
1465 }
1466 /* Now make sure that the proposed total height doesn't
1467 exceed the old total height. */
1468 if (ok)
1469 ok = (new_height >= min_height
1470 && total_height <= cur_total_height);
1471 }
1472 }
1473
1474 return ok;
1475 }
1476
1477
1478 static void
1479 parse_scrolling_args (const char *arg,
1480 struct tui_win_info **win_to_scroll,
1481 int *num_to_scroll)
1482 {
1483 if (num_to_scroll)
1484 *num_to_scroll = 0;
1485 *win_to_scroll = tui_win_with_focus ();
1486
1487 /* First set up the default window to scroll, in case there is no
1488 window name arg. */
1489 if (arg != NULL)
1490 {
1491 char *buf_ptr;
1492
1493 /* Process the number of lines to scroll. */
1494 std::string copy = arg;
1495 buf_ptr = &copy[0];
1496 if (isdigit (*buf_ptr))
1497 {
1498 char *num_str;
1499
1500 num_str = buf_ptr;
1501 buf_ptr = strchr (buf_ptr, ' ');
1502 if (buf_ptr != NULL)
1503 {
1504 *buf_ptr = (char) 0;
1505 if (num_to_scroll)
1506 *num_to_scroll = atoi (num_str);
1507 buf_ptr++;
1508 }
1509 else if (num_to_scroll)
1510 *num_to_scroll = atoi (num_str);
1511 }
1512
1513 /* Process the window name if one is specified. */
1514 if (buf_ptr != NULL)
1515 {
1516 const char *wname;
1517
1518 if (*buf_ptr == ' ')
1519 while (*(++buf_ptr) == ' ')
1520 ;
1521
1522 if (*buf_ptr != (char) 0)
1523 {
1524 /* Validate the window name. */
1525 for (char *p = buf_ptr; *p != '\0'; p++)
1526 *p = tolower (*p);
1527
1528 wname = buf_ptr;
1529 }
1530 else
1531 wname = "?";
1532
1533 *win_to_scroll = tui_partial_win_by_name (wname);
1534
1535 if (*win_to_scroll == NULL
1536 || !(*win_to_scroll)->is_visible)
1537 error (_("Invalid window specified. \n\
1538 The window name specified must be valid and visible.\n"));
1539 else if (*win_to_scroll == TUI_CMD_WIN)
1540 *win_to_scroll = tui_source_windows ()[0];
1541 }
1542 }
1543 }
1544
1545 /* Function to initialize gdb commands, for tui window
1546 manipulation. */
1547
1548 void
1549 _initialize_tui_win (void)
1550 {
1551 static struct cmd_list_element *tui_setlist;
1552 static struct cmd_list_element *tui_showlist;
1553 struct cmd_list_element *cmd;
1554
1555 /* Define the classes of commands.
1556 They will appear in the help list in the reverse of this order. */
1557 add_prefix_cmd ("tui", class_tui, set_tui_cmd,
1558 _("TUI configuration variables"),
1559 &tui_setlist, "set tui ",
1560 0 /* allow-unknown */, &setlist);
1561 add_prefix_cmd ("tui", class_tui, show_tui_cmd,
1562 _("TUI configuration variables"),
1563 &tui_showlist, "show tui ",
1564 0 /* allow-unknown */, &showlist);
1565
1566 add_com ("refresh", class_tui, tui_refresh_all_command,
1567 _("Refresh the terminal display."));
1568
1569 cmd = add_com ("tabset", class_tui, tui_set_tab_width_command, _("\
1570 Set the width (in characters) of tab stops.\n\
1571 Usage: tabset N"));
1572 deprecate_cmd (cmd, "set tui tab-width");
1573
1574 cmd = add_com ("winheight", class_tui, tui_set_win_height_command, _("\
1575 Set or modify the height of a specified window.\n"
1576 WIN_HEIGHT_USAGE
1577 "Window names are:\n\
1578 src : the source window\n\
1579 cmd : the command window\n\
1580 asm : the disassembly window\n\
1581 regs : the register display"));
1582 add_com_alias ("wh", "winheight", class_tui, 0);
1583 set_cmd_completer (cmd, winheight_completer);
1584 add_info ("win", tui_all_windows_info,
1585 _("List of all displayed windows."));
1586 cmd = add_com ("focus", class_tui, tui_set_focus_command, _("\
1587 Set focus to named window or next/prev window.\n"
1588 FOCUS_USAGE
1589 "Valid Window names are:\n\
1590 src : the source window\n\
1591 asm : the disassembly window\n\
1592 regs : the register display\n\
1593 cmd : the command window"));
1594 add_com_alias ("fs", "focus", class_tui, 0);
1595 set_cmd_completer (cmd, focus_completer);
1596 add_com ("+", class_tui, tui_scroll_forward_command, _("\
1597 Scroll window forward.\n\
1598 Usage: + [WIN] [N]"));
1599 add_com ("-", class_tui, tui_scroll_backward_command, _("\
1600 Scroll window backward.\n\
1601 Usage: - [WIN] [N]"));
1602 add_com ("<", class_tui, tui_scroll_left_command, _("\
1603 Scroll window text to the left.\n\
1604 Usage: < [WIN] [N]"));
1605 add_com (">", class_tui, tui_scroll_right_command, _("\
1606 Scroll window text to the right.\n\
1607 Usage: > [WIN] [N]"));
1608
1609 /* Define the tui control variables. */
1610 add_setshow_enum_cmd ("border-kind", no_class, tui_border_kind_enums,
1611 &tui_border_kind, _("\
1612 Set the kind of border for TUI windows."), _("\
1613 Show the kind of border for TUI windows."), _("\
1614 This variable controls the border of TUI windows:\n\
1615 space use a white space\n\
1616 ascii use ascii characters + - | for the border\n\
1617 acs use the Alternate Character Set"),
1618 tui_set_var_cmd,
1619 show_tui_border_kind,
1620 &tui_setlist, &tui_showlist);
1621
1622 add_setshow_enum_cmd ("border-mode", no_class, tui_border_mode_enums,
1623 &tui_border_mode, _("\
1624 Set the attribute mode to use for the TUI window borders."), _("\
1625 Show the attribute mode to use for the TUI window borders."), _("\
1626 This variable controls the attributes to use for the window borders:\n\
1627 normal normal display\n\
1628 standout use highlight mode of terminal\n\
1629 reverse use reverse video mode\n\
1630 half use half bright\n\
1631 half-standout use half bright and standout mode\n\
1632 bold use extra bright or bold\n\
1633 bold-standout use extra bright or bold with standout mode"),
1634 tui_set_var_cmd,
1635 show_tui_border_mode,
1636 &tui_setlist, &tui_showlist);
1637
1638 add_setshow_enum_cmd ("active-border-mode", no_class, tui_border_mode_enums,
1639 &tui_active_border_mode, _("\
1640 Set the attribute mode to use for the active TUI window border."), _("\
1641 Show the attribute mode to use for the active TUI window border."), _("\
1642 This variable controls the attributes to use for the active window border:\n\
1643 normal normal display\n\
1644 standout use highlight mode of terminal\n\
1645 reverse use reverse video mode\n\
1646 half use half bright\n\
1647 half-standout use half bright and standout mode\n\
1648 bold use extra bright or bold\n\
1649 bold-standout use extra bright or bold with standout mode"),
1650 tui_set_var_cmd,
1651 show_tui_active_border_mode,
1652 &tui_setlist, &tui_showlist);
1653
1654 add_setshow_zuinteger_cmd ("tab-width", no_class,
1655 &internal_tab_width, _("\
1656 Set the tab width, in characters, for the TUI."), _("\
1657 Show the tab witdh, in characters, for the TUI"), _("\
1658 This variable controls how many spaces are used to display a tab character."),
1659 tui_set_tab_width, tui_show_tab_width,
1660 &tui_setlist, &tui_showlist);
1661 }