Commit | Line | Data |
---|---|---|
f377b406 | 1 | /* TUI window generic functions. |
f33c6cbf | 2 | |
b811d2c2 | 3 | Copyright (C) 1998-2020 Free Software Foundation, Inc. |
f33c6cbf | 4 | |
f377b406 | 5 | Contributed by Hewlett-Packard Company. |
c906108c | 6 | |
f377b406 SC |
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 | |
a9762ec7 | 11 | the Free Software Foundation; either version 3 of the License, or |
f377b406 SC |
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 | |
a9762ec7 | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
f377b406 SC |
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 */ | |
c906108c | 26 | |
c906108c SS |
27 | #include "defs.h" |
28 | #include "command.h" | |
29 | #include "symtab.h" | |
30 | #include "breakpoint.h" | |
31 | #include "frame.h" | |
41783295 | 32 | #include "cli/cli-cmds.h" |
a2a7af0c | 33 | #include "cli/cli-style.h" |
3e752b04 | 34 | #include "top.h" |
52575520 | 35 | #include "source.h" |
c4ef48c6 | 36 | #include "event-loop.h" |
45e42163 | 37 | #include "gdbcmd.h" |
c906108c | 38 | |
d7b2e967 | 39 | #include "tui/tui.h" |
c4ef48c6 | 40 | #include "tui/tui-io.h" |
ce38393b | 41 | #include "tui/tui-command.h" |
d7b2e967 | 42 | #include "tui/tui-data.h" |
3df505f6 | 43 | #include "tui/tui-layout.h" |
d7b2e967 AC |
44 | #include "tui/tui-wingeneral.h" |
45 | #include "tui/tui-stack.h" | |
46 | #include "tui/tui-regs.h" | |
47 | #include "tui/tui-disasm.h" | |
48 | #include "tui/tui-source.h" | |
49 | #include "tui/tui-winsource.h" | |
2c0b251b | 50 | #include "tui/tui-win.h" |
c906108c | 51 | |
6a83354a | 52 | #include "gdb_curses.h" |
96ec9981 | 53 | #include <ctype.h> |
dbda9972 | 54 | #include "readline/readline.h" |
9f6ad286 | 55 | #include "gdbsupport/gdb_string_view.h" |
96ec9981 | 56 | |
9612b5ec UW |
57 | #include <signal.h> |
58 | ||
0b39b52e TT |
59 | static void tui_set_tab_width_command (const char *, int); |
60 | static void tui_refresh_all_command (const char *, int); | |
1d12d88f | 61 | static void tui_all_windows_info (const char *, int); |
0b39b52e TT |
62 | static void tui_scroll_forward_command (const char *, int); |
63 | static void tui_scroll_backward_command (const char *, int); | |
64 | static void tui_scroll_left_command (const char *, int); | |
65 | static void tui_scroll_right_command (const char *, int); | |
66 | static void parse_scrolling_args (const char *, | |
08ef48c5 MS |
67 | struct tui_win_info **, |
68 | int *); | |
c906108c SS |
69 | |
70 | ||
17aae570 SC |
71 | #ifndef ACS_LRCORNER |
72 | # define ACS_LRCORNER '+' | |
73 | #endif | |
74 | #ifndef ACS_LLCORNER | |
75 | # define ACS_LLCORNER '+' | |
76 | #endif | |
77 | #ifndef ACS_ULCORNER | |
78 | # define ACS_ULCORNER '+' | |
79 | #endif | |
80 | #ifndef ACS_URCORNER | |
81 | # define ACS_URCORNER '+' | |
82 | #endif | |
83 | #ifndef ACS_HLINE | |
84 | # define ACS_HLINE '-' | |
85 | #endif | |
86 | #ifndef ACS_VLINE | |
87 | # define ACS_VLINE '|' | |
88 | #endif | |
89 | ||
af101512 | 90 | /* Possible values for tui-border-kind variable. */ |
40478521 | 91 | static const char *const tui_border_kind_enums[] = { |
af101512 SC |
92 | "space", |
93 | "ascii", | |
94 | "acs", | |
95 | NULL | |
96 | }; | |
97 | ||
98 | /* Possible values for tui-border-mode and tui-active-border-mode. */ | |
40478521 | 99 | static const char *const tui_border_mode_enums[] = { |
af101512 SC |
100 | "normal", |
101 | "standout", | |
102 | "reverse", | |
103 | "half", | |
104 | "half-standout", | |
105 | "bold", | |
106 | "bold-standout", | |
107 | NULL | |
108 | }; | |
109 | ||
110 | struct tui_translate | |
111 | { | |
112 | const char *name; | |
113 | int value; | |
114 | }; | |
115 | ||
116 | /* Translation table for border-mode variables. | |
117 | The list of values must be terminated by a NULL. | |
118 | After the NULL value, an entry defines the default. */ | |
3d34df0a | 119 | static struct tui_translate tui_border_mode_translate[] = { |
af101512 SC |
120 | { "normal", A_NORMAL }, |
121 | { "standout", A_STANDOUT }, | |
122 | { "reverse", A_REVERSE }, | |
123 | { "half", A_DIM }, | |
124 | { "half-standout", A_DIM | A_STANDOUT }, | |
125 | { "bold", A_BOLD }, | |
126 | { "bold-standout", A_BOLD | A_STANDOUT }, | |
127 | { 0, 0 }, | |
128 | { "normal", A_NORMAL } | |
129 | }; | |
130 | ||
131 | /* Translation tables for border-kind, one for each border | |
132 | character (see wborder, border curses operations). | |
133 | -1 is used to indicate the ACS because ACS characters | |
134 | are determined at run time by curses (depends on terminal). */ | |
3d34df0a | 135 | static struct tui_translate tui_border_kind_translate_vline[] = { |
af101512 SC |
136 | { "space", ' ' }, |
137 | { "ascii", '|' }, | |
138 | { "acs", -1 }, | |
139 | { 0, 0 }, | |
140 | { "ascii", '|' } | |
141 | }; | |
142 | ||
3d34df0a | 143 | static struct tui_translate tui_border_kind_translate_hline[] = { |
af101512 SC |
144 | { "space", ' ' }, |
145 | { "ascii", '-' }, | |
146 | { "acs", -1 }, | |
147 | { 0, 0 }, | |
148 | { "ascii", '-' } | |
149 | }; | |
150 | ||
3d34df0a | 151 | static struct tui_translate tui_border_kind_translate_ulcorner[] = { |
af101512 SC |
152 | { "space", ' ' }, |
153 | { "ascii", '+' }, | |
154 | { "acs", -1 }, | |
155 | { 0, 0 }, | |
156 | { "ascii", '+' } | |
157 | }; | |
158 | ||
3d34df0a | 159 | static struct tui_translate tui_border_kind_translate_urcorner[] = { |
af101512 SC |
160 | { "space", ' ' }, |
161 | { "ascii", '+' }, | |
162 | { "acs", -1 }, | |
163 | { 0, 0 }, | |
164 | { "ascii", '+' } | |
165 | }; | |
166 | ||
3d34df0a | 167 | static struct tui_translate tui_border_kind_translate_llcorner[] = { |
af101512 SC |
168 | { "space", ' ' }, |
169 | { "ascii", '+' }, | |
170 | { "acs", -1 }, | |
171 | { 0, 0 }, | |
172 | { "ascii", '+' } | |
173 | }; | |
174 | ||
3d34df0a | 175 | static struct tui_translate tui_border_kind_translate_lrcorner[] = { |
af101512 SC |
176 | { "space", ' ' }, |
177 | { "ascii", '+' }, | |
178 | { "acs", -1 }, | |
179 | { 0, 0 }, | |
180 | { "ascii", '+' } | |
181 | }; | |
182 | ||
183 | ||
184 | /* Tui configuration variables controlled with set/show command. */ | |
3d34df0a | 185 | static const char *tui_active_border_mode = "bold-standout"; |
920d2a44 | 186 | static void |
08ef48c5 MS |
187 | show_tui_active_border_mode (struct ui_file *file, |
188 | int from_tty, | |
189 | struct cmd_list_element *c, | |
190 | const char *value) | |
920d2a44 AC |
191 | { |
192 | fprintf_filtered (file, _("\ | |
193 | The attribute mode to use for the active TUI window border is \"%s\".\n"), | |
194 | value); | |
195 | } | |
196 | ||
3d34df0a | 197 | static const char *tui_border_mode = "normal"; |
920d2a44 | 198 | static void |
08ef48c5 MS |
199 | show_tui_border_mode (struct ui_file *file, |
200 | int from_tty, | |
201 | struct cmd_list_element *c, | |
202 | const char *value) | |
920d2a44 AC |
203 | { |
204 | fprintf_filtered (file, _("\ | |
205 | The attribute mode to use for the TUI window borders is \"%s\".\n"), | |
206 | value); | |
207 | } | |
208 | ||
3d34df0a | 209 | static const char *tui_border_kind = "acs"; |
920d2a44 | 210 | static void |
08ef48c5 MS |
211 | show_tui_border_kind (struct ui_file *file, |
212 | int from_tty, | |
213 | struct cmd_list_element *c, | |
214 | const char *value) | |
920d2a44 AC |
215 | { |
216 | fprintf_filtered (file, _("The kind of border for TUI windows is \"%s\".\n"), | |
217 | value); | |
218 | } | |
219 | ||
af101512 | 220 | |
1cc6d956 MS |
221 | /* Tui internal configuration variables. These variables are updated |
222 | by tui_update_variables to reflect the tui configuration | |
af101512 SC |
223 | variables. */ |
224 | chtype tui_border_vline; | |
225 | chtype tui_border_hline; | |
226 | chtype tui_border_ulcorner; | |
227 | chtype tui_border_urcorner; | |
228 | chtype tui_border_llcorner; | |
229 | chtype tui_border_lrcorner; | |
230 | ||
231 | int tui_border_attrs; | |
232 | int tui_active_border_attrs; | |
233 | ||
234 | /* Identify the item in the translation table. | |
235 | When the item is not recognized, use the default entry. */ | |
236 | static struct tui_translate * | |
237 | translate (const char *name, struct tui_translate *table) | |
238 | { | |
239 | while (table->name) | |
240 | { | |
241 | if (name && strcmp (table->name, name) == 0) | |
242 | return table; | |
243 | table++; | |
244 | } | |
245 | ||
246 | /* Not found, return default entry. */ | |
247 | table++; | |
248 | return table; | |
249 | } | |
250 | ||
251 | /* Update the tui internal configuration according to gdb settings. | |
252 | Returns 1 if the configuration has changed and the screen should | |
253 | be redrawn. */ | |
87d557ae TT |
254 | bool |
255 | tui_update_variables () | |
af101512 | 256 | { |
87d557ae | 257 | bool need_redraw = false; |
af101512 SC |
258 | struct tui_translate *entry; |
259 | ||
260 | entry = translate (tui_border_mode, tui_border_mode_translate); | |
261 | if (tui_border_attrs != entry->value) | |
262 | { | |
263 | tui_border_attrs = entry->value; | |
87d557ae | 264 | need_redraw = true; |
af101512 SC |
265 | } |
266 | entry = translate (tui_active_border_mode, tui_border_mode_translate); | |
267 | if (tui_active_border_attrs != entry->value) | |
268 | { | |
269 | tui_active_border_attrs = entry->value; | |
87d557ae | 270 | need_redraw = true; |
af101512 SC |
271 | } |
272 | ||
273 | /* If one corner changes, all characters are changed. | |
274 | Only check the first one. The ACS characters are determined at | |
275 | run time by curses terminal management. */ | |
276 | entry = translate (tui_border_kind, tui_border_kind_translate_lrcorner); | |
277 | if (tui_border_lrcorner != (chtype) entry->value) | |
278 | { | |
279 | tui_border_lrcorner = (entry->value < 0) ? ACS_LRCORNER : entry->value; | |
87d557ae | 280 | need_redraw = true; |
af101512 SC |
281 | } |
282 | entry = translate (tui_border_kind, tui_border_kind_translate_llcorner); | |
283 | tui_border_llcorner = (entry->value < 0) ? ACS_LLCORNER : entry->value; | |
284 | ||
285 | entry = translate (tui_border_kind, tui_border_kind_translate_ulcorner); | |
286 | tui_border_ulcorner = (entry->value < 0) ? ACS_ULCORNER : entry->value; | |
287 | ||
288 | entry = translate (tui_border_kind, tui_border_kind_translate_urcorner); | |
289 | tui_border_urcorner = (entry->value < 0) ? ACS_URCORNER : entry->value; | |
290 | ||
291 | entry = translate (tui_border_kind, tui_border_kind_translate_hline); | |
292 | tui_border_hline = (entry->value < 0) ? ACS_HLINE : entry->value; | |
293 | ||
294 | entry = translate (tui_border_kind, tui_border_kind_translate_vline); | |
295 | tui_border_vline = (entry->value < 0) ? ACS_VLINE : entry->value; | |
296 | ||
297 | return need_redraw; | |
298 | } | |
299 | ||
c9684879 | 300 | static void |
981a3fb3 | 301 | set_tui_cmd (const char *args, int from_tty) |
c9684879 SC |
302 | { |
303 | } | |
304 | ||
305 | static void | |
981a3fb3 | 306 | show_tui_cmd (const char *args, int from_tty) |
c9684879 SC |
307 | { |
308 | } | |
af101512 | 309 | |
10f59415 SC |
310 | static struct cmd_list_element *tuilist; |
311 | ||
312 | static void | |
981a3fb3 | 313 | tui_command (const char *args, int from_tty) |
10f59415 | 314 | { |
a3f17187 AC |
315 | printf_unfiltered (_("\"tui\" must be followed by the name of a " |
316 | "tui command.\n")); | |
635c7e8a | 317 | help_list (tuilist, "tui ", all_commands, gdb_stdout); |
10f59415 SC |
318 | } |
319 | ||
320 | struct cmd_list_element ** | |
da745b36 | 321 | tui_get_cmd_list (void) |
10f59415 SC |
322 | { |
323 | if (tuilist == 0) | |
324 | add_prefix_cmd ("tui", class_tui, tui_command, | |
1bedd215 | 325 | _("Text User Interface commands."), |
10f59415 SC |
326 | &tuilist, "tui ", 0, &cmdlist); |
327 | return &tuilist; | |
328 | } | |
329 | ||
6cdb25f4 EZ |
330 | /* The set_func hook of "set tui ..." commands that affect the window |
331 | borders on the TUI display. */ | |
3b5c1d49 SM |
332 | |
333 | static void | |
eb4c3f4a TT |
334 | tui_set_var_cmd (const char *null_args, |
335 | int from_tty, struct cmd_list_element *c) | |
6cdb25f4 EZ |
336 | { |
337 | if (tui_update_variables () && tui_active) | |
338 | tui_rehighlight_all (); | |
339 | } | |
340 | ||
45e42163 TT |
341 | \f |
342 | ||
343 | /* True if TUI resizes should print a message. This is used by the | |
344 | test suite. */ | |
345 | ||
346 | static bool resize_message; | |
347 | ||
348 | static void | |
349 | show_tui_resize_message (struct ui_file *file, int from_tty, | |
350 | struct cmd_list_element *c, const char *value) | |
351 | { | |
352 | fprintf_filtered (file, _("TUI resize messaging is %s.\n"), value); | |
353 | } | |
354 | ||
355 | \f | |
356 | ||
97605e61 AB |
357 | /* Generic window name completion function. Complete window name pointed |
358 | to by TEXT and WORD. If INCLUDE_NEXT_PREV_P is true then the special | |
359 | window names 'next' and 'prev' will also be considered as possible | |
360 | completions of the window name. */ | |
2e52ae68 | 361 | |
eb3ff9a5 PA |
362 | static void |
363 | window_name_completer (completion_tracker &tracker, | |
364 | int include_next_prev_p, | |
97605e61 | 365 | const char *text, const char *word) |
2e52ae68 | 366 | { |
625ad440 | 367 | std::vector<const char *> completion_name_vec; |
2e52ae68 | 368 | |
1ce3e844 | 369 | for (tui_win_info *win_info : all_tui_windows ()) |
2e52ae68 PP |
370 | { |
371 | const char *completion_name = NULL; | |
372 | ||
373 | /* We can't focus on an invisible window. */ | |
2d83e710 | 374 | if (!win_info->is_visible ()) |
2e52ae68 PP |
375 | continue; |
376 | ||
1ce3e844 | 377 | completion_name = win_info->name (); |
150375dc | 378 | gdb_assert (completion_name != NULL); |
625ad440 | 379 | completion_name_vec.push_back (completion_name); |
2e52ae68 PP |
380 | } |
381 | ||
382 | /* If no windows are considered visible then the TUI has not yet been | |
383 | initialized. But still "focus src" and "focus cmd" will work because | |
384 | invoking the focus command will entail initializing the TUI which sets the | |
416eb92d | 385 | default layout to "src". */ |
625ad440 | 386 | if (completion_name_vec.empty ()) |
2e52ae68 | 387 | { |
625ad440 SM |
388 | completion_name_vec.push_back (SRC_NAME); |
389 | completion_name_vec.push_back (CMD_NAME); | |
2e52ae68 PP |
390 | } |
391 | ||
97605e61 AB |
392 | if (include_next_prev_p) |
393 | { | |
625ad440 SM |
394 | completion_name_vec.push_back ("next"); |
395 | completion_name_vec.push_back ("prev"); | |
97605e61 | 396 | } |
2e52ae68 | 397 | |
2e52ae68 | 398 | |
625ad440 SM |
399 | completion_name_vec.push_back (NULL); |
400 | complete_on_enum (tracker, completion_name_vec.data (), text, word); | |
2e52ae68 PP |
401 | } |
402 | ||
97605e61 AB |
403 | /* Complete possible window names to focus on. TEXT is the complete text |
404 | entered so far, WORD is the word currently being completed. */ | |
405 | ||
eb3ff9a5 | 406 | static void |
97605e61 | 407 | focus_completer (struct cmd_list_element *ignore, |
eb3ff9a5 PA |
408 | completion_tracker &tracker, |
409 | const char *text, const char *word) | |
97605e61 | 410 | { |
eb3ff9a5 | 411 | window_name_completer (tracker, 1, text, word); |
97605e61 AB |
412 | } |
413 | ||
414 | /* Complete possible window names for winheight command. TEXT is the | |
415 | complete text entered so far, WORD is the word currently being | |
416 | completed. */ | |
417 | ||
eb3ff9a5 | 418 | static void |
97605e61 | 419 | winheight_completer (struct cmd_list_element *ignore, |
eb3ff9a5 | 420 | completion_tracker &tracker, |
97605e61 AB |
421 | const char *text, const char *word) |
422 | { | |
423 | /* The first word is the window name. That we can complete. Subsequent | |
424 | words can't be completed. */ | |
425 | if (word != text) | |
eb3ff9a5 | 426 | return; |
97605e61 | 427 | |
eb3ff9a5 | 428 | window_name_completer (tracker, 0, text, word); |
97605e61 AB |
429 | } |
430 | ||
3e752b04 SC |
431 | /* Update gdb's knowledge of the terminal size. */ |
432 | void | |
d02c80cd | 433 | tui_update_gdb_sizes (void) |
3e752b04 | 434 | { |
d6e5e7f7 PP |
435 | int width, height; |
436 | ||
437 | if (tui_active) | |
438 | { | |
cb2ce893 TT |
439 | width = TUI_CMD_WIN->width; |
440 | height = TUI_CMD_WIN->height; | |
d6e5e7f7 PP |
441 | } |
442 | else | |
443 | { | |
444 | width = tui_term_width (); | |
445 | height = tui_term_height (); | |
446 | } | |
447 | ||
448 | set_screen_width_and_height (width, height); | |
3e752b04 SC |
449 | } |
450 | ||
c906108c | 451 | |
c906108c | 452 | void |
13446e05 | 453 | tui_win_info::forward_scroll (int num_to_scroll) |
c906108c | 454 | { |
13446e05 | 455 | if (num_to_scroll == 0) |
cb2ce893 | 456 | num_to_scroll = height - 3; |
c906108c | 457 | |
c3bd716f | 458 | do_scroll_vertical (num_to_scroll); |
a21fcd8f | 459 | } |
c906108c | 460 | |
c906108c | 461 | void |
13446e05 | 462 | tui_win_info::backward_scroll (int num_to_scroll) |
c906108c | 463 | { |
13446e05 | 464 | if (num_to_scroll == 0) |
cb2ce893 | 465 | num_to_scroll = height - 3; |
13446e05 | 466 | |
c3bd716f | 467 | do_scroll_vertical (-num_to_scroll); |
a21fcd8f | 468 | } |
c906108c SS |
469 | |
470 | ||
c906108c | 471 | void |
13446e05 | 472 | tui_win_info::left_scroll (int num_to_scroll) |
c906108c | 473 | { |
13446e05 TT |
474 | if (num_to_scroll == 0) |
475 | num_to_scroll = 1; | |
476 | ||
c3bd716f | 477 | do_scroll_horizontal (num_to_scroll); |
a21fcd8f | 478 | } |
c906108c SS |
479 | |
480 | ||
c906108c | 481 | void |
13446e05 | 482 | tui_win_info::right_scroll (int num_to_scroll) |
c906108c | 483 | { |
13446e05 TT |
484 | if (num_to_scroll == 0) |
485 | num_to_scroll = 1; | |
486 | ||
c3bd716f | 487 | do_scroll_horizontal (-num_to_scroll); |
e8b915dc | 488 | } |
c906108c SS |
489 | |
490 | ||
c906108c | 491 | void |
a21fcd8f | 492 | tui_refresh_all_win (void) |
c906108c | 493 | { |
3e266828 | 494 | clearok (curscr, TRUE); |
1ce3e844 | 495 | tui_refresh_all (); |
bc712bbf | 496 | } |
c906108c | 497 | |
6cdb25f4 EZ |
498 | void |
499 | tui_rehighlight_all (void) | |
500 | { | |
1ce3e844 | 501 | for (tui_win_info *win_info : all_tui_windows ()) |
b4ef5aeb | 502 | win_info->check_and_display_highlight_if_needed (); |
6cdb25f4 | 503 | } |
c906108c | 504 | |
b021a221 | 505 | /* Resize all the windows based on the terminal size. This function |
ae2b5380 | 506 | gets called from within the readline SIGWINCH handler. */ |
c906108c | 507 | void |
6ba8e26f | 508 | tui_resize_all (void) |
c906108c | 509 | { |
6ba8e26f | 510 | int height_diff, width_diff; |
9255ee31 | 511 | int screenheight, screenwidth; |
c906108c | 512 | |
9255ee31 | 513 | rl_get_screen_size (&screenheight, &screenwidth); |
6ba8e26f AC |
514 | width_diff = screenwidth - tui_term_width (); |
515 | height_diff = screenheight - tui_term_height (); | |
516 | if (height_diff || width_diff) | |
c906108c | 517 | { |
5b6fe301 | 518 | struct tui_win_info *win_with_focus = tui_win_with_focus (); |
c906108c | 519 | |
10f59415 SC |
520 | #ifdef HAVE_RESIZE_TERM |
521 | resize_term (screenheight, screenwidth); | |
522 | #endif | |
1cc6d956 | 523 | /* Turn keypad off while we resize. */ |
6ba8e26f | 524 | if (win_with_focus != TUI_CMD_WIN) |
7523da63 | 525 | keypad (TUI_CMD_WIN->handle.get (), FALSE); |
3e752b04 | 526 | tui_update_gdb_sizes (); |
dd1abb8c AC |
527 | tui_set_term_height_to (screenheight); |
528 | tui_set_term_width_to (screenwidth); | |
3d979945 | 529 | |
c366c1f0 TT |
530 | /* erase + clearok are used instead of a straightforward clear as |
531 | AIX 5.3 does not define clear. */ | |
532 | erase (); | |
533 | clearok (curscr, TRUE); | |
3d979945 | 534 | tui_apply_current_layout (); |
1cc6d956 MS |
535 | /* Turn keypad back on, unless focus is in the command |
536 | window. */ | |
6ba8e26f | 537 | if (win_with_focus != TUI_CMD_WIN) |
7523da63 | 538 | keypad (TUI_CMD_WIN->handle.get (), TRUE); |
c906108c | 539 | } |
6ba8e26f | 540 | } |
c906108c | 541 | |
2c0b251b | 542 | #ifdef SIGWINCH |
c4ef48c6 PP |
543 | /* Token for use by TUI's asynchronous SIGWINCH handler. */ |
544 | static struct async_signal_handler *tui_sigwinch_token; | |
545 | ||
546 | /* TUI's SIGWINCH signal handler. */ | |
2c0b251b | 547 | static void |
6ba8e26f | 548 | tui_sigwinch_handler (int signal) |
c906108c | 549 | { |
c4ef48c6 | 550 | mark_async_signal_handler (tui_sigwinch_token); |
9abd8a65 | 551 | tui_set_win_resized_to (true); |
6ba8e26f | 552 | } |
c4ef48c6 PP |
553 | |
554 | /* Callback for asynchronously resizing TUI following a SIGWINCH signal. */ | |
555 | static void | |
556 | tui_async_resize_screen (gdb_client_data arg) | |
557 | { | |
a88d0bb3 PP |
558 | rl_resize_terminal (); |
559 | ||
c4ef48c6 | 560 | if (!tui_active) |
a88d0bb3 PP |
561 | { |
562 | int screen_height, screen_width; | |
c4ef48c6 | 563 | |
a88d0bb3 PP |
564 | rl_get_screen_size (&screen_height, &screen_width); |
565 | set_screen_width_and_height (screen_width, screen_height); | |
566 | ||
567 | /* win_resized is left set so that the next call to tui_enable() | |
568 | resizes the TUI windows. */ | |
569 | } | |
570 | else | |
571 | { | |
9abd8a65 | 572 | tui_set_win_resized_to (false); |
a88d0bb3 PP |
573 | tui_resize_all (); |
574 | tui_refresh_all_win (); | |
575 | tui_update_gdb_sizes (); | |
45e42163 TT |
576 | if (resize_message) |
577 | { | |
578 | static int count; | |
579 | printf_unfiltered ("@@ resize done %d, size = %dx%d\n", count, | |
580 | tui_term_width (), tui_term_height ()); | |
581 | ++count; | |
582 | } | |
a88d0bb3 PP |
583 | tui_redisplay_readline (); |
584 | } | |
c4ef48c6 | 585 | } |
2c0b251b | 586 | #endif |
c906108c | 587 | |
c4ef48c6 PP |
588 | /* Initialize TUI's SIGWINCH signal handler. Note that the handler is not |
589 | uninstalled when we exit TUI, so the handler should not assume that TUI is | |
590 | always active. */ | |
9612b5ec UW |
591 | void |
592 | tui_initialize_win (void) | |
593 | { | |
594 | #ifdef SIGWINCH | |
c4ef48c6 PP |
595 | tui_sigwinch_token |
596 | = create_async_signal_handler (tui_async_resize_screen, NULL); | |
597 | ||
598 | { | |
9612b5ec | 599 | #ifdef HAVE_SIGACTION |
c4ef48c6 | 600 | struct sigaction old_winch; |
1c5313c5 | 601 | |
c4ef48c6 PP |
602 | memset (&old_winch, 0, sizeof (old_winch)); |
603 | old_winch.sa_handler = &tui_sigwinch_handler; | |
a344fc09 | 604 | #ifdef SA_RESTART |
c4ef48c6 | 605 | old_winch.sa_flags = SA_RESTART; |
a344fc09 | 606 | #endif |
c4ef48c6 | 607 | sigaction (SIGWINCH, &old_winch, NULL); |
9612b5ec | 608 | #else |
c4ef48c6 | 609 | signal (SIGWINCH, &tui_sigwinch_handler); |
9612b5ec | 610 | #endif |
c4ef48c6 | 611 | } |
9612b5ec UW |
612 | #endif |
613 | } | |
c906108c SS |
614 | |
615 | ||
c906108c | 616 | static void |
0b39b52e | 617 | tui_scroll_forward_command (const char *arg, int from_tty) |
c906108c | 618 | { |
6ba8e26f | 619 | int num_to_scroll = 1; |
5b6fe301 | 620 | struct tui_win_info *win_to_scroll; |
c906108c | 621 | |
1854bb21 SC |
622 | /* Make sure the curses mode is enabled. */ |
623 | tui_enable (); | |
63a33118 | 624 | if (arg == NULL) |
cafb3438 | 625 | parse_scrolling_args (arg, &win_to_scroll, NULL); |
c906108c | 626 | else |
6ba8e26f | 627 | parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); |
13446e05 | 628 | win_to_scroll->forward_scroll (num_to_scroll); |
e8b915dc | 629 | } |
c906108c SS |
630 | |
631 | ||
c906108c | 632 | static void |
0b39b52e | 633 | tui_scroll_backward_command (const char *arg, int from_tty) |
c906108c | 634 | { |
6ba8e26f | 635 | int num_to_scroll = 1; |
5b6fe301 | 636 | struct tui_win_info *win_to_scroll; |
c906108c | 637 | |
1854bb21 SC |
638 | /* Make sure the curses mode is enabled. */ |
639 | tui_enable (); | |
63a33118 | 640 | if (arg == NULL) |
cafb3438 | 641 | parse_scrolling_args (arg, &win_to_scroll, NULL); |
c906108c | 642 | else |
6ba8e26f | 643 | parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); |
13446e05 | 644 | win_to_scroll->backward_scroll (num_to_scroll); |
e8b915dc | 645 | } |
c906108c SS |
646 | |
647 | ||
c906108c | 648 | static void |
0b39b52e | 649 | tui_scroll_left_command (const char *arg, int from_tty) |
c906108c | 650 | { |
6ba8e26f | 651 | int num_to_scroll; |
5b6fe301 | 652 | struct tui_win_info *win_to_scroll; |
c906108c | 653 | |
1854bb21 SC |
654 | /* Make sure the curses mode is enabled. */ |
655 | tui_enable (); | |
6ba8e26f | 656 | parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); |
13446e05 | 657 | win_to_scroll->left_scroll (num_to_scroll); |
e8b915dc | 658 | } |
c906108c SS |
659 | |
660 | ||
c906108c | 661 | static void |
0b39b52e | 662 | tui_scroll_right_command (const char *arg, int from_tty) |
c906108c | 663 | { |
6ba8e26f | 664 | int num_to_scroll; |
5b6fe301 | 665 | struct tui_win_info *win_to_scroll; |
c906108c | 666 | |
1854bb21 SC |
667 | /* Make sure the curses mode is enabled. */ |
668 | tui_enable (); | |
6ba8e26f | 669 | parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); |
13446e05 | 670 | win_to_scroll->right_scroll (num_to_scroll); |
e8b915dc | 671 | } |
c906108c SS |
672 | |
673 | ||
9f6ad286 TT |
674 | /* Answer the window represented by name. */ |
675 | static struct tui_win_info * | |
676 | tui_partial_win_by_name (gdb::string_view name) | |
677 | { | |
e098d18c TT |
678 | struct tui_win_info *best = nullptr; |
679 | ||
9f6ad286 TT |
680 | if (name != NULL) |
681 | { | |
682 | for (tui_win_info *item : all_tui_windows ()) | |
683 | { | |
684 | const char *cur_name = item->name (); | |
685 | ||
e098d18c | 686 | if (name == cur_name) |
9f6ad286 | 687 | return item; |
e098d18c TT |
688 | if (startswith (cur_name, name)) |
689 | { | |
690 | if (best != nullptr) | |
691 | error (_("Window name \"%*s\" is ambiguous"), | |
692 | (int) name.size (), name.data ()); | |
693 | best = item; | |
694 | } | |
9f6ad286 TT |
695 | } |
696 | } | |
697 | ||
e098d18c | 698 | return best; |
9f6ad286 TT |
699 | } |
700 | ||
6ba8e26f | 701 | /* Set focus to the window named by 'arg'. */ |
c906108c | 702 | static void |
01aeb396 | 703 | tui_set_focus_command (const char *arg, int from_tty) |
c906108c | 704 | { |
01aeb396 TT |
705 | tui_enable (); |
706 | ||
ca793b96 TT |
707 | if (arg == NULL) |
708 | error_no_arg (_("name of window to focus")); | |
c906108c | 709 | |
ca793b96 | 710 | struct tui_win_info *win_info = NULL; |
c906108c | 711 | |
ca793b96 TT |
712 | if (subset_compare (arg, "next")) |
713 | win_info = tui_next_win (tui_win_with_focus ()); | |
714 | else if (subset_compare (arg, "prev")) | |
715 | win_info = tui_prev_win (tui_win_with_focus ()); | |
c906108c | 716 | else |
ca793b96 TT |
717 | win_info = tui_partial_win_by_name (arg); |
718 | ||
719 | if (win_info == NULL) | |
720 | error (_("Unrecognized window name \"%s\""), arg); | |
721 | if (!win_info->is_visible ()) | |
722 | error (_("Window \"%s\" is not visible"), arg); | |
723 | ||
724 | tui_set_win_focus_to (win_info); | |
725 | keypad (TUI_CMD_WIN->handle.get (), win_info != TUI_CMD_WIN); | |
726 | printf_filtered (_("Focus set to %s window.\n"), | |
727 | tui_win_with_focus ()->name ()); | |
6ba8e26f | 728 | } |
c906108c | 729 | |
c906108c | 730 | static void |
1d12d88f | 731 | tui_all_windows_info (const char *arg, int from_tty) |
c906108c | 732 | { |
82e3b564 TT |
733 | if (!tui_active) |
734 | { | |
735 | printf_filtered (_("The TUI is not active.\n")); | |
736 | return; | |
737 | } | |
738 | ||
5b6fe301 | 739 | struct tui_win_info *win_with_focus = tui_win_with_focus (); |
25a2915e TT |
740 | struct ui_out *uiout = current_uiout; |
741 | ||
742 | ui_out_emit_table table_emitter (uiout, 3, -1, "tui-windows"); | |
743 | uiout->table_header (10, ui_left, "name", "Name"); | |
744 | uiout->table_header (5, ui_right, "lines", "Lines"); | |
745 | uiout->table_header (10, ui_left, "focus", "Focus"); | |
746 | uiout->table_body (); | |
c906108c | 747 | |
1ce3e844 | 748 | for (tui_win_info *win_info : all_tui_windows ()) |
2d83e710 | 749 | if (win_info->is_visible ()) |
c906108c | 750 | { |
25a2915e TT |
751 | ui_out_emit_tuple tuple_emitter (uiout, nullptr); |
752 | ||
753 | uiout->field_string ("name", win_info->name ()); | |
754 | uiout->field_signed ("lines", win_info->height); | |
1ce3e844 | 755 | if (win_with_focus == win_info) |
25a2915e | 756 | uiout->field_string ("focus", _("(has focus)")); |
c906108c | 757 | else |
25a2915e TT |
758 | uiout->field_skip ("focus"); |
759 | uiout->text ("\n"); | |
c906108c | 760 | } |
6ba8e26f | 761 | } |
c906108c SS |
762 | |
763 | ||
c906108c | 764 | static void |
0b39b52e | 765 | tui_refresh_all_command (const char *arg, int from_tty) |
c906108c | 766 | { |
1854bb21 SC |
767 | /* Make sure the curses mode is enabled. */ |
768 | tui_enable (); | |
769 | ||
a21fcd8f | 770 | tui_refresh_all_win (); |
c906108c SS |
771 | } |
772 | ||
7806cea7 TT |
773 | /* The tab width that should be used by the TUI. */ |
774 | ||
775 | unsigned int tui_tab_width = DEFAULT_TAB_LEN; | |
776 | ||
777 | /* The tab width as set by the user. */ | |
778 | ||
779 | static unsigned int internal_tab_width = DEFAULT_TAB_LEN; | |
780 | ||
d83f1fe6 TT |
781 | /* After the tab width is set, call this to update the relevant |
782 | windows. */ | |
783 | ||
784 | static void | |
785 | update_tab_width () | |
786 | { | |
1ce3e844 | 787 | for (tui_win_info *win_info : all_tui_windows ()) |
7806cea7 | 788 | { |
2d83e710 | 789 | if (win_info->is_visible ()) |
1ce3e844 | 790 | win_info->update_tab_width (); |
7806cea7 TT |
791 | } |
792 | } | |
793 | ||
794 | /* Callback for "set tui tab-width". */ | |
795 | ||
796 | static void | |
797 | tui_set_tab_width (const char *ignore, | |
798 | int from_tty, struct cmd_list_element *c) | |
799 | { | |
800 | if (internal_tab_width == 0) | |
801 | { | |
802 | internal_tab_width = tui_tab_width; | |
803 | error (_("Tab width must not be 0")); | |
804 | } | |
805 | ||
806 | tui_tab_width = internal_tab_width; | |
807 | update_tab_width (); | |
808 | } | |
809 | ||
810 | /* Callback for "show tui tab-width". */ | |
811 | ||
812 | static void | |
813 | tui_show_tab_width (struct ui_file *file, int from_tty, | |
814 | struct cmd_list_element *c, const char *value) | |
815 | { | |
816 | fprintf_filtered (gdb_stdout, _("TUI tab width is %s spaces.\n"), value); | |
817 | ||
818 | } | |
c906108c | 819 | |
d1da6b01 TT |
820 | /* See tui-win.h. */ |
821 | ||
822 | bool compact_source = false; | |
823 | ||
824 | /* Callback for "set tui compact-source". */ | |
825 | ||
826 | static void | |
827 | tui_set_compact_source (const char *ignore, int from_tty, | |
828 | struct cmd_list_element *c) | |
829 | { | |
830 | if (TUI_SRC_WIN != nullptr) | |
831 | TUI_SRC_WIN->refill (); | |
832 | } | |
833 | ||
834 | /* Callback for "show tui compact-source". */ | |
835 | ||
836 | static void | |
837 | tui_show_compact_source (struct ui_file *file, int from_tty, | |
838 | struct cmd_list_element *c, const char *value) | |
839 | { | |
840 | printf_filtered (_("TUI source window compactness is %s.\n"), value); | |
841 | } | |
842 | ||
c54da50d | 843 | /* Set the tab width of the specified window. */ |
c906108c | 844 | static void |
0b39b52e | 845 | tui_set_tab_width_command (const char *arg, int from_tty) |
c906108c | 846 | { |
1854bb21 SC |
847 | /* Make sure the curses mode is enabled. */ |
848 | tui_enable (); | |
63a33118 | 849 | if (arg != NULL) |
c906108c SS |
850 | { |
851 | int ts; | |
852 | ||
853 | ts = atoi (arg); | |
7806cea7 TT |
854 | if (ts <= 0) |
855 | warning (_("Tab widths greater than 0 must be specified.")); | |
856 | else | |
cb86fcc1 | 857 | { |
7806cea7 TT |
858 | internal_tab_width = ts; |
859 | tui_tab_width = ts; | |
860 | ||
861 | update_tab_width (); | |
cb86fcc1 | 862 | } |
c906108c | 863 | } |
6ba8e26f | 864 | } |
c906108c SS |
865 | |
866 | ||
1cc6d956 | 867 | /* Set the height of the specified window. */ |
c906108c | 868 | static void |
4dde7b34 | 869 | tui_set_win_height_command (const char *arg, int from_tty) |
c906108c | 870 | { |
1854bb21 SC |
871 | /* Make sure the curses mode is enabled. */ |
872 | tui_enable (); | |
ca793b96 TT |
873 | if (arg == NULL) |
874 | error_no_arg (_("name of window")); | |
c906108c | 875 | |
ca793b96 TT |
876 | const char *buf = arg; |
877 | const char *buf_ptr = buf; | |
878 | int new_height; | |
879 | struct tui_win_info *win_info; | |
c906108c | 880 | |
ca793b96 | 881 | buf_ptr = skip_to_space (buf_ptr); |
78e8cb91 | 882 | |
ca793b96 TT |
883 | /* Validate the window name. */ |
884 | gdb::string_view wname (buf, buf_ptr - buf); | |
885 | win_info = tui_partial_win_by_name (wname); | |
78e8cb91 | 886 | |
ca793b96 TT |
887 | if (win_info == NULL) |
888 | error (_("Unrecognized window name \"%s\""), arg); | |
889 | if (!win_info->is_visible ()) | |
890 | error (_("Window \"%s\" is not visible"), arg); | |
891 | ||
892 | /* Process the size. */ | |
893 | buf_ptr = skip_spaces (buf_ptr); | |
894 | ||
895 | if (*buf_ptr != '\0') | |
896 | { | |
897 | bool negate = false; | |
898 | bool fixed_size = true; | |
899 | int input_no;; | |
900 | ||
901 | if (*buf_ptr == '+' || *buf_ptr == '-') | |
902 | { | |
903 | if (*buf_ptr == '-') | |
904 | negate = true; | |
905 | fixed_size = false; | |
906 | buf_ptr++; | |
907 | } | |
908 | input_no = atoi (buf_ptr); | |
909 | if (input_no > 0) | |
910 | { | |
911 | if (negate) | |
912 | input_no *= (-1); | |
913 | if (fixed_size) | |
914 | new_height = input_no; | |
915 | else | |
916 | new_height = win_info->height + input_no; | |
917 | ||
918 | /* Now change the window's height, and adjust | |
919 | all other windows around it. */ | |
920 | tui_adjust_window_height (win_info, new_height); | |
921 | tui_update_gdb_sizes (); | |
c906108c SS |
922 | } |
923 | else | |
ca793b96 | 924 | error (_("Invalid window height specified")); |
c906108c | 925 | } |
6ba8e26f | 926 | } |
c906108c | 927 | |
5fcee43a | 928 | /* See tui-data.h. */ |
c906108c | 929 | |
8903bd8a TT |
930 | int |
931 | tui_win_info::max_height () const | |
932 | { | |
933 | return tui_term_height () - 2; | |
934 | } | |
935 | ||
7c043ba6 TT |
936 | /* See tui-data.h. */ |
937 | ||
938 | int | |
939 | tui_gen_win_info::max_width () const | |
940 | { | |
941 | return tui_term_width () - 2; | |
942 | } | |
943 | ||
c906108c | 944 | static void |
0b39b52e | 945 | parse_scrolling_args (const char *arg, |
08ef48c5 | 946 | struct tui_win_info **win_to_scroll, |
6ba8e26f | 947 | int *num_to_scroll) |
c906108c | 948 | { |
6ba8e26f AC |
949 | if (num_to_scroll) |
950 | *num_to_scroll = 0; | |
951 | *win_to_scroll = tui_win_with_focus (); | |
c906108c | 952 | |
ef5eab5a MS |
953 | /* First set up the default window to scroll, in case there is no |
954 | window name arg. */ | |
63a33118 | 955 | if (arg != NULL) |
c906108c | 956 | { |
f71c8822 | 957 | char *buf_ptr; |
c906108c | 958 | |
1cc6d956 | 959 | /* Process the number of lines to scroll. */ |
f71c8822 TT |
960 | std::string copy = arg; |
961 | buf_ptr = ©[0]; | |
6ba8e26f | 962 | if (isdigit (*buf_ptr)) |
c906108c | 963 | { |
6ba8e26f | 964 | char *num_str; |
c906108c | 965 | |
6ba8e26f AC |
966 | num_str = buf_ptr; |
967 | buf_ptr = strchr (buf_ptr, ' '); | |
63a33118 | 968 | if (buf_ptr != NULL) |
c906108c | 969 | { |
78e8cb91 | 970 | *buf_ptr = '\0'; |
6ba8e26f AC |
971 | if (num_to_scroll) |
972 | *num_to_scroll = atoi (num_str); | |
973 | buf_ptr++; | |
c906108c | 974 | } |
6ba8e26f AC |
975 | else if (num_to_scroll) |
976 | *num_to_scroll = atoi (num_str); | |
c906108c SS |
977 | } |
978 | ||
1cc6d956 | 979 | /* Process the window name if one is specified. */ |
63a33118 | 980 | if (buf_ptr != NULL) |
c906108c | 981 | { |
a121b7c1 | 982 | const char *wname; |
c906108c | 983 | |
78e8cb91 | 984 | wname = skip_spaces (buf_ptr); |
c906108c | 985 | |
78e8cb91 | 986 | if (*wname != '\0') |
c709a7c2 | 987 | { |
78e8cb91 TT |
988 | *win_to_scroll = tui_partial_win_by_name (wname); |
989 | ||
990 | if (*win_to_scroll == NULL) | |
991 | error (_("Unrecognized window `%s'"), wname); | |
992 | if (!(*win_to_scroll)->is_visible ()) | |
993 | error (_("Window is not visible")); | |
994 | else if (*win_to_scroll == TUI_CMD_WIN) | |
995 | *win_to_scroll = *(tui_source_windows ().begin ()); | |
c709a7c2 | 996 | } |
c906108c | 997 | } |
c906108c | 998 | } |
6ba8e26f | 999 | } |
7806cea7 TT |
1000 | |
1001 | /* Function to initialize gdb commands, for tui window | |
1002 | manipulation. */ | |
1003 | ||
6c265988 | 1004 | void _initialize_tui_win (); |
7806cea7 | 1005 | void |
6c265988 | 1006 | _initialize_tui_win () |
7806cea7 TT |
1007 | { |
1008 | static struct cmd_list_element *tui_setlist; | |
1009 | static struct cmd_list_element *tui_showlist; | |
1010 | struct cmd_list_element *cmd; | |
1011 | ||
1012 | /* Define the classes of commands. | |
1013 | They will appear in the help list in the reverse of this order. */ | |
1014 | add_prefix_cmd ("tui", class_tui, set_tui_cmd, | |
590042fc | 1015 | _("TUI configuration variables."), |
7806cea7 TT |
1016 | &tui_setlist, "set tui ", |
1017 | 0 /* allow-unknown */, &setlist); | |
1018 | add_prefix_cmd ("tui", class_tui, show_tui_cmd, | |
590042fc | 1019 | _("TUI configuration variables."), |
7806cea7 TT |
1020 | &tui_showlist, "show tui ", |
1021 | 0 /* allow-unknown */, &showlist); | |
1022 | ||
1023 | add_com ("refresh", class_tui, tui_refresh_all_command, | |
89549d7f | 1024 | _("Refresh the terminal display.")); |
7806cea7 TT |
1025 | |
1026 | cmd = add_com ("tabset", class_tui, tui_set_tab_width_command, _("\ | |
1027 | Set the width (in characters) of tab stops.\n\ | |
89549d7f | 1028 | Usage: tabset N")); |
7806cea7 TT |
1029 | deprecate_cmd (cmd, "set tui tab-width"); |
1030 | ||
1031 | cmd = add_com ("winheight", class_tui, tui_set_win_height_command, _("\ | |
ca793b96 TT |
1032 | Set or modify the height of a specified window.\n\ |
1033 | Usage: winheight WINDOW-NAME [+ | -] NUM-LINES\n\ | |
1034 | Use \"info win\" to see the names of the windows currently being displayed.")); | |
7806cea7 TT |
1035 | add_com_alias ("wh", "winheight", class_tui, 0); |
1036 | set_cmd_completer (cmd, winheight_completer); | |
1037 | add_info ("win", tui_all_windows_info, | |
283be8bf TT |
1038 | _("List of all displayed windows.\n\ |
1039 | Usage: info win")); | |
7806cea7 | 1040 | cmd = add_com ("focus", class_tui, tui_set_focus_command, _("\ |
ca793b96 TT |
1041 | Set focus to named window or next/prev window.\n\ |
1042 | Usage: focus [WINDOW-NAME | next | prev]\n\ | |
1043 | Use \"info win\" to see the names of the windows currently being displayed.")); | |
7806cea7 TT |
1044 | add_com_alias ("fs", "focus", class_tui, 0); |
1045 | set_cmd_completer (cmd, focus_completer); | |
1046 | add_com ("+", class_tui, tui_scroll_forward_command, _("\ | |
1047 | Scroll window forward.\n\ | |
7a27a45b AB |
1048 | Usage: + [N] [WIN]\n\ |
1049 | Scroll window WIN N lines forwards. Both WIN and N are optional, N\n\ | |
1050 | defaults to 1, and WIN defaults to the currently focused window.")); | |
7806cea7 TT |
1051 | add_com ("-", class_tui, tui_scroll_backward_command, _("\ |
1052 | Scroll window backward.\n\ | |
7a27a45b AB |
1053 | Usage: - [N] [WIN]\n\ |
1054 | Scroll window WIN N lines backwards. Both WIN and N are optional, N\n\ | |
1055 | defaults to 1, and WIN defaults to the currently focused window.")); | |
7806cea7 TT |
1056 | add_com ("<", class_tui, tui_scroll_left_command, _("\ |
1057 | Scroll window text to the left.\n\ | |
7a27a45b AB |
1058 | Usage: < [N] [WIN]\n\ |
1059 | Scroll window WIN N characters left. Both WIN and N are optional, N\n\ | |
1060 | defaults to 1, and WIN defaults to the currently focused window.")); | |
7806cea7 TT |
1061 | add_com (">", class_tui, tui_scroll_right_command, _("\ |
1062 | Scroll window text to the right.\n\ | |
7a27a45b AB |
1063 | Usage: > [N] [WIN]\n\ |
1064 | Scroll window WIN N characters right. Both WIN and N are optional, N\n\ | |
1065 | defaults to 1, and WIN defaults to the currently focused window.")); | |
7806cea7 TT |
1066 | |
1067 | /* Define the tui control variables. */ | |
1068 | add_setshow_enum_cmd ("border-kind", no_class, tui_border_kind_enums, | |
1069 | &tui_border_kind, _("\ | |
1070 | Set the kind of border for TUI windows."), _("\ | |
1071 | Show the kind of border for TUI windows."), _("\ | |
1072 | This variable controls the border of TUI windows:\n\ | |
89549d7f TT |
1073 | space use a white space\n\ |
1074 | ascii use ascii characters + - | for the border\n\ | |
1075 | acs use the Alternate Character Set"), | |
7806cea7 TT |
1076 | tui_set_var_cmd, |
1077 | show_tui_border_kind, | |
1078 | &tui_setlist, &tui_showlist); | |
1079 | ||
1080 | add_setshow_enum_cmd ("border-mode", no_class, tui_border_mode_enums, | |
1081 | &tui_border_mode, _("\ | |
1082 | Set the attribute mode to use for the TUI window borders."), _("\ | |
1083 | Show the attribute mode to use for the TUI window borders."), _("\ | |
1084 | This variable controls the attributes to use for the window borders:\n\ | |
89549d7f TT |
1085 | normal normal display\n\ |
1086 | standout use highlight mode of terminal\n\ | |
1087 | reverse use reverse video mode\n\ | |
1088 | half use half bright\n\ | |
1089 | half-standout use half bright and standout mode\n\ | |
1090 | bold use extra bright or bold\n\ | |
1091 | bold-standout use extra bright or bold with standout mode"), | |
7806cea7 TT |
1092 | tui_set_var_cmd, |
1093 | show_tui_border_mode, | |
1094 | &tui_setlist, &tui_showlist); | |
1095 | ||
1096 | add_setshow_enum_cmd ("active-border-mode", no_class, tui_border_mode_enums, | |
1097 | &tui_active_border_mode, _("\ | |
1098 | Set the attribute mode to use for the active TUI window border."), _("\ | |
1099 | Show the attribute mode to use for the active TUI window border."), _("\ | |
1100 | This variable controls the attributes to use for the active window border:\n\ | |
89549d7f TT |
1101 | normal normal display\n\ |
1102 | standout use highlight mode of terminal\n\ | |
1103 | reverse use reverse video mode\n\ | |
1104 | half use half bright\n\ | |
1105 | half-standout use half bright and standout mode\n\ | |
1106 | bold use extra bright or bold\n\ | |
1107 | bold-standout use extra bright or bold with standout mode"), | |
7806cea7 TT |
1108 | tui_set_var_cmd, |
1109 | show_tui_active_border_mode, | |
1110 | &tui_setlist, &tui_showlist); | |
1111 | ||
1112 | add_setshow_zuinteger_cmd ("tab-width", no_class, | |
1113 | &internal_tab_width, _("\ | |
1114 | Set the tab width, in characters, for the TUI."), _("\ | |
590042fc | 1115 | Show the tab witdh, in characters, for the TUI."), _("\ |
7806cea7 TT |
1116 | This variable controls how many spaces are used to display a tab character."), |
1117 | tui_set_tab_width, tui_show_tab_width, | |
1118 | &tui_setlist, &tui_showlist); | |
45e42163 TT |
1119 | |
1120 | add_setshow_boolean_cmd ("tui-resize-message", class_maintenance, | |
1121 | &resize_message, _("\ | |
1122 | Set TUI resize messaging."), _("\ | |
1123 | Show TUI resize messaging."), _("\ | |
1124 | When enabled GDB will print a message when the terminal is resized."), | |
1125 | nullptr, | |
1126 | show_tui_resize_message, | |
1127 | &maintenance_set_cmdlist, | |
1128 | &maintenance_show_cmdlist); | |
d1da6b01 TT |
1129 | |
1130 | add_setshow_boolean_cmd ("compact-source", class_tui, | |
1131 | &compact_source, _("\ | |
1132 | Set whether the TUI source window is compact."), _("\ | |
1133 | Show whether the TUI source window is compact."), _("\ | |
1134 | This variable controls whether the TUI source window is shown\n\ | |
1135 | in a compact form. The compact form puts the source closer to\n\ | |
1136 | the line numbers and uses less horizontal space."), | |
1137 | tui_set_compact_source, tui_show_compact_source, | |
1138 | &tui_setlist, &tui_showlist); | |
a2a7af0c TT |
1139 | |
1140 | tui_border_style.changed.attach (tui_rehighlight_all); | |
1141 | tui_active_border_style.changed.attach (tui_rehighlight_all); | |
7806cea7 | 1142 | } |