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