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