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