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