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