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