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