Simplify tui_make_all_invisible
[deliverable/binutils-gdb.git] / gdb / tui / tui-layout.c
CommitLineData
f377b406 1/* TUI layout window management.
f33c6cbf 2
42a4f53d 3 Copyright (C) 1998-2019 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/>. */
c906108c
SS
21
22#include "defs.h"
957b8b5a 23#include "arch-utils.h"
c906108c
SS
24#include "command.h"
25#include "symtab.h"
26#include "frame.h"
52575520 27#include "source.h"
84b1e7c7 28#include <ctype.h>
c906108c 29
d7b2e967 30#include "tui/tui.h"
ce38393b 31#include "tui/tui-command.h"
d7b2e967 32#include "tui/tui-data.h"
d7b2e967
AC
33#include "tui/tui-wingeneral.h"
34#include "tui/tui-stack.h"
35#include "tui/tui-regs.h"
36#include "tui/tui-win.h"
37#include "tui/tui-winsource.h"
38#include "tui/tui-disasm.h"
2c0b251b 39#include "tui/tui-layout.h"
bfad4537 40#include "tui/tui-source.h"
6a83354a 41#include "gdb_curses.h"
96ec9981 42
c906108c
SS
43/*******************************
44** Static Local Decls
45********************************/
6ba8e26f 46static void show_layout (enum tui_layout_type);
6ba8e26f 47static void show_source_or_disasm_and_command (enum tui_layout_type);
6ba8e26f
AC
48static void show_source_command (void);
49static void show_disasm_command (void);
50static void show_source_disasm_command (void);
51static void show_data (enum tui_layout_type);
52static enum tui_layout_type next_layout (void);
53static enum tui_layout_type prev_layout (void);
0b39b52e 54static void tui_layout_command (const char *, int);
13274fc3 55static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *);
c906108c
SS
56
57
62cf57fe
TT
58static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;
59
60/* Accessor for the current layout. */
61enum tui_layout_type
62tui_current_layout (void)
63{
64 return current_layout;
65}
66
c906108c
SS
67/***************************************
68** DEFINITIONS
69***************************************/
70
c7037be1
SC
71/* Show the screen layout defined. */
72static void
6ba8e26f 73show_layout (enum tui_layout_type layout)
c906108c 74{
6ba8e26f 75 enum tui_layout_type cur_layout = tui_current_layout ();
c906108c 76
6ba8e26f 77 if (layout != cur_layout)
c906108c 78 {
ef5eab5a
MS
79 /* Since the new layout may cause changes in window size, we
80 should free the content and reallocate on next display of
81 source/asm. */
dd1abb8c 82 tui_clear_source_windows ();
3f3ffe54
TT
83 /* First make the current layout be invisible. */
84 tui_make_all_invisible ();
85 tui_locator_win_info_ptr ()->make_visible (false);
e5908723
MS
86 if (layout == SRC_DATA_COMMAND
87 || layout == DISASSEM_DATA_COMMAND)
c906108c 88 {
6ba8e26f 89 show_data (layout);
1ce3e844 90 tui_refresh_all ();
c906108c
SS
91 }
92 else
93 {
c906108c
SS
94 switch (layout)
95 {
1cc6d956 96 /* Now show the new layout. */
c906108c 97 case SRC_COMMAND:
6ba8e26f 98 show_source_command ();
6d012f14 99 tui_add_to_source_windows (TUI_SRC_WIN);
c906108c
SS
100 break;
101 case DISASSEM_COMMAND:
6ba8e26f 102 show_disasm_command ();
6d012f14 103 tui_add_to_source_windows (TUI_DISASM_WIN);
c906108c
SS
104 break;
105 case SRC_DISASSEM_COMMAND:
6ba8e26f 106 show_source_disasm_command ();
6d012f14
AC
107 tui_add_to_source_windows (TUI_SRC_WIN);
108 tui_add_to_source_windows (TUI_DISASM_WIN);
c906108c
SS
109 break;
110 default:
111 break;
112 }
113 }
114 }
bc712bbf 115}
c906108c
SS
116
117
080ce8c0 118/* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
7bd0be3a 119 SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND. */
b7fbad91 120void
7bd0be3a 121tui_set_layout (enum tui_layout_type layout_type)
c906108c 122{
b7fbad91 123 gdb_assert (layout_type != UNDEFINED_LAYOUT);
c906108c 124
b7fbad91
TT
125 enum tui_layout_type cur_layout = tui_current_layout ();
126 struct gdbarch *gdbarch;
127 CORE_ADDR addr;
128 struct tui_win_info *win_with_focus = tui_win_with_focus ();
c906108c 129
b7fbad91 130 extract_display_start_addr (&gdbarch, &addr);
c906108c 131
b7fbad91 132 enum tui_layout_type new_layout = layout_type;
c906108c 133
b7fbad91
TT
134 if (new_layout != cur_layout)
135 {
136 show_layout (new_layout);
ef5eab5a 137
b7fbad91
TT
138 /* Now determine where focus should be. */
139 if (win_with_focus != TUI_CMD_WIN)
140 {
141 switch (new_layout)
7bd0be3a 142 {
b7fbad91
TT
143 case SRC_COMMAND:
144 tui_set_win_focus_to (TUI_SRC_WIN);
b7fbad91
TT
145 break;
146 case DISASSEM_COMMAND:
147 /* The previous layout was not showing code.
148 This can happen if there is no source
149 available:
150
151 1. if the source file is in another dir OR
152 2. if target was compiled without -g
153 We still want to show the assembly though! */
154
155 tui_get_begin_asm_address (&gdbarch, &addr);
156 tui_set_win_focus_to (TUI_DISASM_WIN);
b7fbad91
TT
157 break;
158 case SRC_DISASSEM_COMMAND:
159 /* The previous layout was not showing code.
160 This can happen if there is no source
161 available:
162
163 1. if the source file is in another dir OR
164 2. if target was compiled without -g
165 We still want to show the assembly though! */
166
167 tui_get_begin_asm_address (&gdbarch, &addr);
168 if (win_with_focus == TUI_SRC_WIN)
169 tui_set_win_focus_to (TUI_SRC_WIN);
170 else
171 tui_set_win_focus_to (TUI_DISASM_WIN);
172 break;
173 case SRC_DATA_COMMAND:
174 if (win_with_focus != TUI_DATA_WIN)
175 tui_set_win_focus_to (TUI_SRC_WIN);
176 else
177 tui_set_win_focus_to (TUI_DATA_WIN);
b7fbad91
TT
178 break;
179 case DISASSEM_DATA_COMMAND:
180 /* The previous layout was not showing code.
181 This can happen if there is no source
182 available:
183
184 1. if the source file is in another dir OR
185 2. if target was compiled without -g
186 We still want to show the assembly though! */
187
188 tui_get_begin_asm_address (&gdbarch, &addr);
189 if (win_with_focus != TUI_DATA_WIN)
190 tui_set_win_focus_to (TUI_DISASM_WIN);
191 else
192 tui_set_win_focus_to (TUI_DATA_WIN);
b7fbad91
TT
193 break;
194 default:
195 break;
c906108c 196 }
c906108c 197 }
b7fbad91
TT
198 /*
199 * Now update the window content.
200 */
201 tui_update_source_windows_with_addr (gdbarch, addr);
202 if (new_layout == SRC_DATA_COMMAND
203 || new_layout == DISASSEM_DATA_COMMAND)
204 tui_show_registers (TUI_DATA_WIN->current_group);
c906108c 205 }
bc712bbf 206}
c906108c 207
080ce8c0
AC
208/* Add the specified window to the layout in a logical way. This
209 means setting up the most logical layout given the window to be
210 added. */
c906108c 211void
080ce8c0 212tui_add_win_to_layout (enum tui_win_type type)
c906108c 213{
6ba8e26f 214 enum tui_layout_type cur_layout = tui_current_layout ();
c906108c
SS
215
216 switch (type)
217 {
218 case SRC_WIN:
e5908723
MS
219 if (cur_layout != SRC_COMMAND
220 && cur_layout != SRC_DISASSEM_COMMAND
221 && cur_layout != SRC_DATA_COMMAND)
c906108c 222 {
dd1abb8c 223 tui_clear_source_windows_detail ();
6ba8e26f
AC
224 if (cur_layout == DISASSEM_DATA_COMMAND)
225 show_layout (SRC_DATA_COMMAND);
c906108c 226 else
6ba8e26f 227 show_layout (SRC_COMMAND);
c906108c
SS
228 }
229 break;
230 case DISASSEM_WIN:
e5908723
MS
231 if (cur_layout != DISASSEM_COMMAND
232 && cur_layout != SRC_DISASSEM_COMMAND
233 && cur_layout != DISASSEM_DATA_COMMAND)
c906108c 234 {
dd1abb8c 235 tui_clear_source_windows_detail ();
6ba8e26f
AC
236 if (cur_layout == SRC_DATA_COMMAND)
237 show_layout (DISASSEM_DATA_COMMAND);
c906108c 238 else
6ba8e26f 239 show_layout (DISASSEM_COMMAND);
c906108c
SS
240 }
241 break;
242 case DATA_WIN:
e5908723
MS
243 if (cur_layout != SRC_DATA_COMMAND
244 && cur_layout != DISASSEM_DATA_COMMAND)
c906108c 245 {
6ba8e26f
AC
246 if (cur_layout == DISASSEM_COMMAND)
247 show_layout (DISASSEM_DATA_COMMAND);
c906108c 248 else
6ba8e26f 249 show_layout (SRC_DATA_COMMAND);
c906108c
SS
250 }
251 break;
252 default:
253 break;
254 }
6ba8e26f 255}
c906108c
SS
256
257
6ba8e26f
AC
258/* Answer the height of a window. If it hasn't been created yet,
259 answer what the height of a window would be based upon its type and
260 the layout. */
c906108c 261int
08ef48c5
MS
262tui_default_win_height (enum tui_win_type type,
263 enum tui_layout_type layout)
c906108c
SS
264{
265 int h;
266
cafb3438 267 if (tui_win_list[type] != NULL)
cb2ce893 268 h = tui_win_list[type]->height;
c906108c
SS
269 else
270 {
271 switch (layout)
272 {
273 case SRC_COMMAND:
274 case DISASSEM_COMMAND:
6d012f14 275 if (TUI_CMD_WIN == NULL)
dd1abb8c 276 h = tui_term_height () / 2;
c906108c 277 else
cb2ce893 278 h = tui_term_height () - TUI_CMD_WIN->height;
c906108c
SS
279 break;
280 case SRC_DISASSEM_COMMAND:
281 case SRC_DATA_COMMAND:
282 case DISASSEM_DATA_COMMAND:
6d012f14 283 if (TUI_CMD_WIN == NULL)
dd1abb8c 284 h = tui_term_height () / 3;
c906108c 285 else
cb2ce893 286 h = (tui_term_height () - TUI_CMD_WIN->height) / 2;
c906108c
SS
287 break;
288 default:
289 h = 0;
290 break;
291 }
292 }
293
294 return h;
6ba8e26f 295}
c906108c
SS
296
297
080ce8c0
AC
298/* Answer the height of a window. If it hasn't been created yet,
299 answer what the height of a window would be based upon its type and
300 the layout. */
c906108c 301int
080ce8c0
AC
302tui_default_win_viewport_height (enum tui_win_type type,
303 enum tui_layout_type layout)
c906108c
SS
304{
305 int h;
306
6ba8e26f 307 h = tui_default_win_height (type, layout);
c906108c 308
6d012f14 309 if (tui_win_list[type] == TUI_CMD_WIN)
c906108c
SS
310 h -= 1;
311 else
312 h -= 2;
313
314 return h;
6ba8e26f 315}
c906108c 316
a0145030
AB
317/* Complete possible layout names. TEXT is the complete text entered so
318 far, WORD is the word currently being completed. */
319
eb3ff9a5 320static void
a0145030 321layout_completer (struct cmd_list_element *ignore,
eb3ff9a5 322 completion_tracker &tracker,
a0145030
AB
323 const char *text, const char *word)
324{
325 static const char *layout_names [] =
326 { "src", "asm", "split", "regs", "next", "prev", NULL };
327
eb3ff9a5 328 complete_on_enum (tracker, layout_names, text, word);
a0145030
AB
329}
330
6ba8e26f
AC
331/* Function to initialize gdb commands, for tui window layout
332 manipulation. */
2c0b251b 333
c906108c 334void
6ba8e26f 335_initialize_tui_layout (void)
c906108c 336{
a0145030
AB
337 struct cmd_list_element *cmd;
338
339 cmd = add_com ("layout", class_tui, tui_layout_command, _("\
1bedd215 340Change the layout of windows.\n\
bf212be1 341Usage: layout prev | next | LAYOUT-NAME\n\
c906108c
SS
342Layout names are:\n\
343 src : Displays source and command windows.\n\
344 asm : Displays disassembly and command windows.\n\
345 split : Displays source, disassembly and command windows.\n\
346 regs : Displays register window. If existing layout\n\
347 is source/command or assembly/command, the \n\
348 register window is displayed. If the\n\
349 source/assembly/command (split) is displayed, \n\
350 the register window is displayed with \n\
89549d7f 351 the window that has current logical focus."));
a0145030 352 set_cmd_completer (cmd, layout_completer);
41783295 353}
c906108c
SS
354
355
356/*************************
357** STATIC LOCAL FUNCTIONS
358**************************/
359
360
7bd0be3a
AB
361/* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, or
362 REGS. */
0379b883
TT
363static void
364tui_layout_command (const char *layout_name, int from_tty)
c906108c 365{
0379b883
TT
366 int i;
367 enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
368 enum tui_layout_type cur_layout = tui_current_layout ();
c906108c 369
0379b883
TT
370 if (layout_name == NULL)
371 error (_("Usage: layout prev | next | LAYOUT-NAME"));
c906108c 372
0379b883
TT
373 std::string copy = layout_name;
374 for (i = 0; i < copy.size (); i++)
375 copy[i] = toupper (copy[i]);
376 const char *buf_ptr = copy.c_str ();
c906108c 377
0379b883
TT
378 /* First check for ambiguous input. */
379 if (strlen (buf_ptr) <= 1 && *buf_ptr == 'S')
380 error (_("Ambiguous command input."));
c906108c 381
0379b883
TT
382 if (subset_compare (buf_ptr, "SRC"))
383 new_layout = SRC_COMMAND;
384 else if (subset_compare (buf_ptr, "ASM"))
385 new_layout = DISASSEM_COMMAND;
386 else if (subset_compare (buf_ptr, "SPLIT"))
387 new_layout = SRC_DISASSEM_COMMAND;
388 else if (subset_compare (buf_ptr, "REGS"))
389 {
390 if (cur_layout == SRC_COMMAND
391 || cur_layout == SRC_DATA_COMMAND)
392 new_layout = SRC_DATA_COMMAND;
393 else
394 new_layout = DISASSEM_DATA_COMMAND;
c906108c 395 }
0379b883
TT
396 else if (subset_compare (buf_ptr, "NEXT"))
397 new_layout = next_layout ();
398 else if (subset_compare (buf_ptr, "PREV"))
399 new_layout = prev_layout ();
c906108c 400 else
0379b883 401 error (_("Unrecognized layout: %s"), layout_name);
c906108c 402
0379b883
TT
403 /* Make sure the curses mode is enabled. */
404 tui_enable ();
405 tui_set_layout (new_layout);
e8b915dc 406}
c906108c
SS
407
408
13274fc3
UW
409static void
410extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
c906108c 411{
6ba8e26f 412 enum tui_layout_type cur_layout = tui_current_layout ();
957b8b5a 413 struct gdbarch *gdbarch = get_current_arch ();
c774cec6 414 CORE_ADDR addr;
84b1e7c7 415 CORE_ADDR pc;
52575520 416 struct symtab_and_line cursal = get_current_source_symtab_and_line ();
c906108c 417
6ba8e26f 418 switch (cur_layout)
c906108c
SS
419 {
420 case SRC_COMMAND:
421 case SRC_DATA_COMMAND:
e6e41501 422 gdbarch = TUI_SRC_WIN->gdbarch;
52575520 423 find_line_pc (cursal.symtab,
e6e41501 424 TUI_SRC_WIN->start_line_or_addr.u.line_no,
84b1e7c7 425 &pc);
c774cec6 426 addr = pc;
c906108c
SS
427 break;
428 case DISASSEM_COMMAND:
429 case SRC_DISASSEM_COMMAND:
430 case DISASSEM_DATA_COMMAND:
e6e41501
TT
431 gdbarch = TUI_DISASM_WIN->gdbarch;
432 addr = TUI_DISASM_WIN->start_line_or_addr.u.addr;
c906108c
SS
433 break;
434 default:
c774cec6 435 addr = 0;
c906108c
SS
436 break;
437 }
438
13274fc3
UW
439 *gdbarch_p = gdbarch;
440 *addr_p = addr;
6ba8e26f 441}
c906108c
SS
442
443
6ba8e26f 444/* Answer the previous layout to cycle to. */
2a8854a7 445static enum tui_layout_type
6ba8e26f 446next_layout (void)
c906108c 447{
570dc176 448 int new_layout;
c906108c 449
6ba8e26f
AC
450 new_layout = tui_current_layout ();
451 if (new_layout == UNDEFINED_LAYOUT)
452 new_layout = SRC_COMMAND;
c906108c
SS
453 else
454 {
6ba8e26f
AC
455 new_layout++;
456 if (new_layout == UNDEFINED_LAYOUT)
457 new_layout = SRC_COMMAND;
c906108c
SS
458 }
459
570dc176 460 return (enum tui_layout_type) new_layout;
6ba8e26f 461}
c906108c
SS
462
463
6ba8e26f 464/* Answer the next layout to cycle to. */
2a8854a7 465static enum tui_layout_type
6ba8e26f 466prev_layout (void)
c906108c 467{
570dc176 468 int new_layout;
c906108c 469
6ba8e26f
AC
470 new_layout = tui_current_layout ();
471 if (new_layout == SRC_COMMAND)
472 new_layout = DISASSEM_DATA_COMMAND;
c906108c
SS
473 else
474 {
6ba8e26f
AC
475 new_layout--;
476 if (new_layout == UNDEFINED_LAYOUT)
477 new_layout = DISASSEM_DATA_COMMAND;
c906108c
SS
478 }
479
570dc176 480 return (enum tui_layout_type) new_layout;
6ba8e26f 481}
c906108c 482
6ba8e26f 483/* Show the Source/Command layout. */
c906108c 484static void
6ba8e26f 485show_source_command (void)
c906108c 486{
6ba8e26f
AC
487 show_source_or_disasm_and_command (SRC_COMMAND);
488}
c906108c
SS
489
490
6ba8e26f 491/* Show the Dissassem/Command layout. */
c906108c 492static void
6ba8e26f 493show_disasm_command (void)
c906108c 494{
6ba8e26f
AC
495 show_source_or_disasm_and_command (DISASSEM_COMMAND);
496}
c906108c
SS
497
498
6ba8e26f 499/* Show the Source/Disassem/Command layout. */
c906108c 500static void
6ba8e26f 501show_source_disasm_command (void)
c906108c 502{
dd1abb8c 503 if (tui_current_layout () != SRC_DISASSEM_COMMAND)
c906108c 504 {
6ba8e26f 505 int cmd_height, src_height, asm_height;
c906108c 506
6d012f14 507 if (TUI_CMD_WIN != NULL)
cb2ce893 508 cmd_height = TUI_CMD_WIN->height;
c906108c 509 else
6ba8e26f 510 cmd_height = tui_term_height () / 3;
c906108c 511
6ba8e26f
AC
512 src_height = (tui_term_height () - cmd_height) / 2;
513 asm_height = tui_term_height () - (src_height + cmd_height);
c906108c 514
6d012f14 515 if (TUI_SRC_WIN == NULL)
f4e04977
TT
516 tui_win_list[SRC_WIN] = new tui_source_window ();
517 TUI_SRC_WIN->reset (src_height,
518 tui_term_width (),
519 0,
520 0);
4a38112d 521 TUI_SRC_WIN->make_visible (true);
f4e04977 522 TUI_SRC_WIN->m_has_locator = false;
c906108c 523
3add462f
TT
524 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
525 gdb_assert (locator != nullptr);
82432e10
TT
526
527 tui_show_source_content (TUI_SRC_WIN);
528 if (TUI_DISASM_WIN == NULL)
f4e04977
TT
529 tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
530 TUI_DISASM_WIN->reset (asm_height,
531 tui_term_width (),
532 0,
533 src_height - 1);
4a38112d 534 TUI_DISASM_WIN->make_visible (true);
f4e04977
TT
535 locator->reset (2 /* 1 */ ,
536 tui_term_width (),
537 0,
538 (src_height + asm_height) - 1);
e6e41501
TT
539 TUI_SRC_WIN->m_has_locator = false;
540 TUI_DISASM_WIN->m_has_locator = true;
4a38112d 541 locator->make_visible (true);
82432e10
TT
542 tui_show_locator_content ();
543 tui_show_source_content (TUI_DISASM_WIN);
544
545 if (TUI_CMD_WIN == NULL)
76d2be8e
TT
546 tui_win_list[CMD_WIN] = new tui_cmd_window ();
547 TUI_CMD_WIN->reset (cmd_height,
548 tui_term_width (),
549 0,
550 tui_term_height () - cmd_height);
551 /* FIXME tui_cmd_window won't recreate the handle on
552 make_visible, so we need this instead. */
553 tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW);
62cf57fe 554 current_layout = SRC_DISASSEM_COMMAND;
c906108c 555 }
6ba8e26f 556}
c906108c
SS
557
558
6ba8e26f
AC
559/* Show the Source/Data/Command or the Dissassembly/Data/Command
560 layout. */
c906108c 561static void
6ba8e26f 562show_data (enum tui_layout_type new_layout)
c906108c 563{
cb2ce893 564 int total_height = (tui_term_height () - TUI_CMD_WIN->height);
6ba8e26f
AC
565 int src_height, data_height;
566 enum tui_win_type win_type;
c906108c 567
3add462f
TT
568 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
569 gdb_assert (locator != nullptr);
c906108c 570
6ba8e26f
AC
571 data_height = total_height / 2;
572 src_height = total_height - data_height;
098f9ed4 573 if (tui_win_list[DATA_WIN] == nullptr)
09129226
TT
574 tui_win_list[DATA_WIN] = new tui_data_window ();
575 tui_win_list[DATA_WIN]->reset (data_height, tui_term_width (), 0, 0);
098f9ed4
TT
576 tui_win_list[DATA_WIN]->make_visible (true);
577
6ba8e26f
AC
578 if (new_layout == SRC_DATA_COMMAND)
579 win_type = SRC_WIN;
c906108c 580 else
6ba8e26f 581 win_type = DISASSEM_WIN;
e6e41501 582
6ba8e26f 583 if (tui_win_list[win_type] == NULL)
c906108c 584 {
6ba8e26f 585 if (win_type == SRC_WIN)
4a8a5e84 586 tui_win_list[win_type] = new tui_source_window ();
c906108c 587 else
4a8a5e84 588 tui_win_list[win_type] = new tui_disasm_window ();
c906108c 589 }
4a8a5e84
TT
590
591 tui_source_window_base *base
592 = (tui_source_window_base *) tui_win_list[win_type];
593 tui_win_list[win_type]->reset (src_height,
594 tui_term_width (),
595 0,
596 data_height - 1);
597 locator->reset (2 /* 1 */ ,
598 tui_term_width (),
599 0,
600 total_height - 1);
601 base->make_visible (true);
e6e41501 602 base->m_has_locator = true;
4a38112d 603 locator->make_visible (true);
47d3492a 604 tui_show_locator_content ();
4a8a5e84 605 tui_add_to_source_windows (base);
62cf57fe 606 current_layout = new_layout;
6ba8e26f 607}
c906108c 608
d6ba6a11 609void
1e0c09ba 610tui_gen_win_info::reset (int height_, int width_,
d6ba6a11 611 int origin_x_, int origin_y_)
c906108c 612{
d6ba6a11
TT
613 int h = height_;
614
d6ba6a11
TT
615 width = width_;
616 height = h;
c906108c
SS
617 if (h > 1)
618 {
d6ba6a11
TT
619 viewport_height = h - 1;
620 if (type != CMD_WIN)
621 viewport_height--;
c906108c
SS
622 }
623 else
d6ba6a11
TT
624 viewport_height = 1;
625 origin.x = origin_x_;
626 origin.y = origin_y_;
627}
c906108c 628
1cc6d956 629/* Show the Source/Command or the Disassem layout. */
c906108c 630static void
6ba8e26f 631show_source_or_disasm_and_command (enum tui_layout_type layout_type)
c906108c 632{
6ba8e26f 633 if (tui_current_layout () != layout_type)
c906108c 634 {
890b8bde 635 struct tui_source_window_base *win_info;
6ba8e26f 636 int src_height, cmd_height;
3add462f
TT
637 struct tui_locator_window *locator = tui_locator_win_info_ptr ();
638 gdb_assert (locator != nullptr);
c906108c 639
6d012f14 640 if (TUI_CMD_WIN != NULL)
cb2ce893 641 cmd_height = TUI_CMD_WIN->height;
c906108c 642 else
6ba8e26f
AC
643 cmd_height = tui_term_height () / 3;
644 src_height = tui_term_height () - cmd_height;
c906108c 645
6ba8e26f 646 if (layout_type == SRC_COMMAND)
c906108c 647 {
890b8bde
TT
648 if (tui_win_list[SRC_WIN] == nullptr)
649 tui_win_list[SRC_WIN] = new tui_source_window ();
650 win_info = TUI_SRC_WIN;
c906108c
SS
651 }
652 else
653 {
890b8bde
TT
654 if (tui_win_list[DISASSEM_WIN] == nullptr)
655 tui_win_list[DISASSEM_WIN] = new tui_disasm_window ();
656 win_info = TUI_DISASM_WIN;
c906108c 657 }
c906108c 658
890b8bde
TT
659 locator->reset (2 /* 1 */ ,
660 tui_term_width (),
661 0,
662 src_height - 1);
663 win_info->reset (src_height - 1,
664 tui_term_width (),
665 0,
666 0);
4a38112d 667 win_info->make_visible (true);
890b8bde
TT
668
669
670 win_info->m_has_locator = true;
4a38112d 671 locator->make_visible (true);
6a0ee02c 672 tui_show_locator_content ();
890b8bde 673 tui_show_source_content (win_info);
6a0ee02c
TT
674
675 if (TUI_CMD_WIN == NULL)
76d2be8e
TT
676 tui_win_list[CMD_WIN] = new tui_cmd_window ();
677 TUI_CMD_WIN->reset (cmd_height,
678 tui_term_width (),
679 0,
680 src_height);
681 /* FIXME tui_cmd_window won't recreate the handle on
682 make_visible, so we need this instead. */
683 tui_make_window (TUI_CMD_WIN, DONT_BOX_WINDOW);
62cf57fe 684 current_layout = layout_type;
c906108c 685 }
6ba8e26f 686}
This page took 2.000854 seconds and 4 git commands to generate.