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