]>
Commit | Line | Data |
---|---|---|
f377b406 | 1 | /* TUI layout window management. |
f33c6cbf | 2 | |
8acc9f48 | 3 | Copyright (C) 1998-2013 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" | |
32 | #include "tui/tui-windata.h" | |
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" |
c906108c | 40 | |
88289b6e | 41 | #include "gdb_string.h" |
6a83354a | 42 | #include "gdb_curses.h" |
96ec9981 | 43 | |
c906108c SS |
44 | /******************************* |
45 | ** Static Local Decls | |
46 | ********************************/ | |
6ba8e26f | 47 | static void show_layout (enum tui_layout_type); |
08ef48c5 MS |
48 | static void init_gen_win_info (struct tui_gen_win_info *, |
49 | enum tui_win_type, | |
50 | int, int, int, int); | |
51 | static void *init_and_make_win (void *, enum tui_win_type, | |
52 | int, int, int, int, int); | |
6ba8e26f | 53 | static void show_source_or_disasm_and_command (enum tui_layout_type); |
08ef48c5 MS |
54 | static void make_source_or_disasm_window (struct tui_win_info **, |
55 | enum tui_win_type, | |
56 | int, int); | |
5b6fe301 MS |
57 | static void make_command_window (struct tui_win_info **, int, int); |
58 | static void make_source_window (struct tui_win_info **, int, int); | |
59 | static void make_disasm_window (struct tui_win_info **, int, int); | |
60 | static void make_data_window (struct tui_win_info **, int, int); | |
6ba8e26f AC |
61 | static void show_source_command (void); |
62 | static void show_disasm_command (void); | |
63 | static void show_source_disasm_command (void); | |
64 | static void show_data (enum tui_layout_type); | |
65 | static enum tui_layout_type next_layout (void); | |
66 | static enum tui_layout_type prev_layout (void); | |
67 | static void tui_layout_command (char *, int); | |
68 | static void tui_toggle_layout_command (char *, int); | |
69 | static void tui_toggle_split_layout_command (char *, int); | |
13274fc3 | 70 | static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *); |
6ba8e26f | 71 | static void tui_handle_xdb_layout (struct tui_layout_def *); |
c906108c SS |
72 | |
73 | ||
74 | /*************************************** | |
75 | ** DEFINITIONS | |
76 | ***************************************/ | |
77 | ||
78 | #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n" | |
79 | ||
c7037be1 SC |
80 | /* Show the screen layout defined. */ |
81 | static void | |
6ba8e26f | 82 | show_layout (enum tui_layout_type layout) |
c906108c | 83 | { |
6ba8e26f | 84 | enum tui_layout_type cur_layout = tui_current_layout (); |
c906108c | 85 | |
6ba8e26f | 86 | if (layout != cur_layout) |
c906108c | 87 | { |
ef5eab5a MS |
88 | /* Since the new layout may cause changes in window size, we |
89 | should free the content and reallocate on next display of | |
90 | source/asm. */ | |
dd1abb8c AC |
91 | tui_free_all_source_wins_content (); |
92 | tui_clear_source_windows (); | |
e5908723 MS |
93 | if (layout == SRC_DATA_COMMAND |
94 | || layout == DISASSEM_DATA_COMMAND) | |
c906108c | 95 | { |
6ba8e26f | 96 | show_data (layout); |
6d012f14 | 97 | tui_refresh_all (tui_win_list); |
c906108c SS |
98 | } |
99 | else | |
100 | { | |
1cc6d956 | 101 | /* First make the current layout be invisible. */ |
ec7d9e56 | 102 | tui_make_all_invisible (); |
dd1abb8c | 103 | tui_make_invisible (tui_locator_win_info_ptr ()); |
c906108c SS |
104 | |
105 | switch (layout) | |
106 | { | |
1cc6d956 | 107 | /* Now show the new layout. */ |
c906108c | 108 | case SRC_COMMAND: |
6ba8e26f | 109 | show_source_command (); |
6d012f14 | 110 | tui_add_to_source_windows (TUI_SRC_WIN); |
c906108c SS |
111 | break; |
112 | case DISASSEM_COMMAND: | |
6ba8e26f | 113 | show_disasm_command (); |
6d012f14 | 114 | tui_add_to_source_windows (TUI_DISASM_WIN); |
c906108c SS |
115 | break; |
116 | case SRC_DISASSEM_COMMAND: | |
6ba8e26f | 117 | show_source_disasm_command (); |
6d012f14 AC |
118 | tui_add_to_source_windows (TUI_SRC_WIN); |
119 | tui_add_to_source_windows (TUI_DISASM_WIN); | |
c906108c SS |
120 | break; |
121 | default: | |
122 | break; | |
123 | } | |
124 | } | |
125 | } | |
bc712bbf | 126 | } |
c906108c SS |
127 | |
128 | ||
080ce8c0 AC |
129 | /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND, |
130 | SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND. | |
131 | If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or | |
132 | UNDEFINED_LAYOUT, then the data window is populated according to | |
6d012f14 | 133 | regs_display_type. */ |
080ce8c0 | 134 | enum tui_status |
6ba8e26f | 135 | tui_set_layout (enum tui_layout_type layout_type, |
6d012f14 | 136 | enum tui_register_display_type regs_display_type) |
c906108c | 137 | { |
22940a24 | 138 | enum tui_status status = TUI_SUCCESS; |
c906108c | 139 | |
e5908723 MS |
140 | if (layout_type != UNDEFINED_LAYOUT |
141 | || regs_display_type != TUI_UNDEFINED_REGS) | |
c906108c | 142 | { |
e5908723 MS |
143 | enum tui_layout_type cur_layout = tui_current_layout (), |
144 | new_layout = UNDEFINED_LAYOUT; | |
6ba8e26f | 145 | int regs_populate = FALSE; |
13274fc3 UW |
146 | struct gdbarch *gdbarch; |
147 | CORE_ADDR addr; | |
5b6fe301 MS |
148 | struct tui_win_info *win_with_focus = tui_win_with_focus (); |
149 | struct tui_layout_def *layout_def = tui_layout_def (); | |
c906108c | 150 | |
13274fc3 | 151 | extract_display_start_addr (&gdbarch, &addr); |
c906108c | 152 | |
e5908723 MS |
153 | if (layout_type == UNDEFINED_LAYOUT |
154 | && regs_display_type != TUI_UNDEFINED_REGS) | |
c906108c | 155 | { |
6ba8e26f AC |
156 | if (cur_layout == SRC_DISASSEM_COMMAND) |
157 | new_layout = DISASSEM_DATA_COMMAND; | |
e5908723 MS |
158 | else if (cur_layout == SRC_COMMAND |
159 | || cur_layout == SRC_DATA_COMMAND) | |
6ba8e26f | 160 | new_layout = SRC_DATA_COMMAND; |
e5908723 MS |
161 | else if (cur_layout == DISASSEM_COMMAND |
162 | || cur_layout == DISASSEM_DATA_COMMAND) | |
6ba8e26f | 163 | new_layout = DISASSEM_DATA_COMMAND; |
c906108c SS |
164 | } |
165 | else | |
6ba8e26f | 166 | new_layout = layout_type; |
c906108c | 167 | |
e5908723 MS |
168 | regs_populate = (new_layout == SRC_DATA_COMMAND |
169 | || new_layout == DISASSEM_DATA_COMMAND | |
170 | || regs_display_type != TUI_UNDEFINED_REGS); | |
171 | if (new_layout != cur_layout | |
172 | || regs_display_type != TUI_UNDEFINED_REGS) | |
c906108c | 173 | { |
6ba8e26f | 174 | if (new_layout != cur_layout) |
c906108c | 175 | { |
6ba8e26f | 176 | show_layout (new_layout); |
ef5eab5a MS |
177 | |
178 | /* Now determine where focus should be. */ | |
6ba8e26f | 179 | if (win_with_focus != TUI_CMD_WIN) |
c906108c | 180 | { |
6ba8e26f | 181 | switch (new_layout) |
c906108c SS |
182 | { |
183 | case SRC_COMMAND: | |
6d012f14 | 184 | tui_set_win_focus_to (TUI_SRC_WIN); |
6ba8e26f AC |
185 | layout_def->display_mode = SRC_WIN; |
186 | layout_def->split = FALSE; | |
c906108c SS |
187 | break; |
188 | case DISASSEM_COMMAND: | |
ef5eab5a MS |
189 | /* The previous layout was not showing code. |
190 | This can happen if there is no source | |
191 | available: | |
192 | ||
193 | 1. if the source file is in another dir OR | |
194 | 2. if target was compiled without -g | |
195 | We still want to show the assembly though! */ | |
196 | ||
13274fc3 | 197 | tui_get_begin_asm_address (&gdbarch, &addr); |
6d012f14 | 198 | tui_set_win_focus_to (TUI_DISASM_WIN); |
6ba8e26f AC |
199 | layout_def->display_mode = DISASSEM_WIN; |
200 | layout_def->split = FALSE; | |
c906108c SS |
201 | break; |
202 | case SRC_DISASSEM_COMMAND: | |
ef5eab5a MS |
203 | /* The previous layout was not showing code. |
204 | This can happen if there is no source | |
205 | available: | |
206 | ||
207 | 1. if the source file is in another dir OR | |
208 | 2. if target was compiled without -g | |
209 | We still want to show the assembly though! */ | |
210 | ||
13274fc3 | 211 | tui_get_begin_asm_address (&gdbarch, &addr); |
6ba8e26f | 212 | if (win_with_focus == TUI_SRC_WIN) |
6d012f14 | 213 | tui_set_win_focus_to (TUI_SRC_WIN); |
c906108c | 214 | else |
6d012f14 | 215 | tui_set_win_focus_to (TUI_DISASM_WIN); |
6ba8e26f | 216 | layout_def->split = TRUE; |
c906108c SS |
217 | break; |
218 | case SRC_DATA_COMMAND: | |
6ba8e26f | 219 | if (win_with_focus != TUI_DATA_WIN) |
6d012f14 | 220 | tui_set_win_focus_to (TUI_SRC_WIN); |
c906108c | 221 | else |
6d012f14 | 222 | tui_set_win_focus_to (TUI_DATA_WIN); |
6ba8e26f AC |
223 | layout_def->display_mode = SRC_WIN; |
224 | layout_def->split = FALSE; | |
c906108c SS |
225 | break; |
226 | case DISASSEM_DATA_COMMAND: | |
ef5eab5a MS |
227 | /* The previous layout was not showing code. |
228 | This can happen if there is no source | |
229 | available: | |
230 | ||
231 | 1. if the source file is in another dir OR | |
232 | 2. if target was compiled without -g | |
233 | We still want to show the assembly though! */ | |
234 | ||
13274fc3 | 235 | tui_get_begin_asm_address (&gdbarch, &addr); |
6ba8e26f | 236 | if (win_with_focus != TUI_DATA_WIN) |
6d012f14 | 237 | tui_set_win_focus_to (TUI_DISASM_WIN); |
c906108c | 238 | else |
6d012f14 | 239 | tui_set_win_focus_to (TUI_DATA_WIN); |
6ba8e26f AC |
240 | layout_def->display_mode = DISASSEM_WIN; |
241 | layout_def->split = FALSE; | |
c906108c SS |
242 | break; |
243 | default: | |
244 | break; | |
245 | } | |
246 | } | |
c906108c | 247 | /* |
3e40160c | 248 | * Now update the window content. |
c5aa993b | 249 | */ |
e5908723 MS |
250 | if (!regs_populate |
251 | && (new_layout == SRC_DATA_COMMAND | |
252 | || new_layout == DISASSEM_DATA_COMMAND)) | |
edae1ccf | 253 | tui_display_all_data (); |
c906108c | 254 | |
13274fc3 | 255 | tui_update_source_windows_with_addr (gdbarch, addr); |
c906108c | 256 | } |
6ba8e26f | 257 | if (regs_populate) |
c906108c | 258 | { |
10f59415 | 259 | tui_show_registers (TUI_DATA_WIN->detail.data_display_info.current_group); |
c906108c SS |
260 | } |
261 | } | |
262 | } | |
263 | else | |
264 | status = TUI_FAILURE; | |
265 | ||
266 | return status; | |
bc712bbf | 267 | } |
c906108c | 268 | |
080ce8c0 AC |
269 | /* Add the specified window to the layout in a logical way. This |
270 | means setting up the most logical layout given the window to be | |
271 | added. */ | |
c906108c | 272 | void |
080ce8c0 | 273 | tui_add_win_to_layout (enum tui_win_type type) |
c906108c | 274 | { |
6ba8e26f | 275 | enum tui_layout_type cur_layout = tui_current_layout (); |
c906108c SS |
276 | |
277 | switch (type) | |
278 | { | |
279 | case SRC_WIN: | |
e5908723 MS |
280 | if (cur_layout != SRC_COMMAND |
281 | && cur_layout != SRC_DISASSEM_COMMAND | |
282 | && cur_layout != SRC_DATA_COMMAND) | |
c906108c | 283 | { |
dd1abb8c | 284 | tui_clear_source_windows_detail (); |
6ba8e26f AC |
285 | if (cur_layout == DISASSEM_DATA_COMMAND) |
286 | show_layout (SRC_DATA_COMMAND); | |
c906108c | 287 | else |
6ba8e26f | 288 | show_layout (SRC_COMMAND); |
c906108c SS |
289 | } |
290 | break; | |
291 | case DISASSEM_WIN: | |
e5908723 MS |
292 | if (cur_layout != DISASSEM_COMMAND |
293 | && cur_layout != SRC_DISASSEM_COMMAND | |
294 | && cur_layout != DISASSEM_DATA_COMMAND) | |
c906108c | 295 | { |
dd1abb8c | 296 | tui_clear_source_windows_detail (); |
6ba8e26f AC |
297 | if (cur_layout == SRC_DATA_COMMAND) |
298 | show_layout (DISASSEM_DATA_COMMAND); | |
c906108c | 299 | else |
6ba8e26f | 300 | show_layout (DISASSEM_COMMAND); |
c906108c SS |
301 | } |
302 | break; | |
303 | case DATA_WIN: | |
e5908723 MS |
304 | if (cur_layout != SRC_DATA_COMMAND |
305 | && cur_layout != DISASSEM_DATA_COMMAND) | |
c906108c | 306 | { |
6ba8e26f AC |
307 | if (cur_layout == DISASSEM_COMMAND) |
308 | show_layout (DISASSEM_DATA_COMMAND); | |
c906108c | 309 | else |
6ba8e26f | 310 | show_layout (SRC_DATA_COMMAND); |
c906108c SS |
311 | } |
312 | break; | |
313 | default: | |
314 | break; | |
315 | } | |
6ba8e26f | 316 | } |
c906108c SS |
317 | |
318 | ||
6ba8e26f AC |
319 | /* Answer the height of a window. If it hasn't been created yet, |
320 | answer what the height of a window would be based upon its type and | |
321 | the layout. */ | |
c906108c | 322 | int |
08ef48c5 MS |
323 | tui_default_win_height (enum tui_win_type type, |
324 | enum tui_layout_type layout) | |
c906108c SS |
325 | { |
326 | int h; | |
327 | ||
6d012f14 AC |
328 | if (tui_win_list[type] != (struct tui_win_info *) NULL) |
329 | h = tui_win_list[type]->generic.height; | |
c906108c SS |
330 | else |
331 | { | |
332 | switch (layout) | |
333 | { | |
334 | case SRC_COMMAND: | |
335 | case DISASSEM_COMMAND: | |
6d012f14 | 336 | if (TUI_CMD_WIN == NULL) |
dd1abb8c | 337 | h = tui_term_height () / 2; |
c906108c | 338 | else |
6d012f14 | 339 | h = tui_term_height () - TUI_CMD_WIN->generic.height; |
c906108c SS |
340 | break; |
341 | case SRC_DISASSEM_COMMAND: | |
342 | case SRC_DATA_COMMAND: | |
343 | case DISASSEM_DATA_COMMAND: | |
6d012f14 | 344 | if (TUI_CMD_WIN == NULL) |
dd1abb8c | 345 | h = tui_term_height () / 3; |
c906108c | 346 | else |
6d012f14 | 347 | h = (tui_term_height () - TUI_CMD_WIN->generic.height) / 2; |
c906108c SS |
348 | break; |
349 | default: | |
350 | h = 0; | |
351 | break; | |
352 | } | |
353 | } | |
354 | ||
355 | return h; | |
6ba8e26f | 356 | } |
c906108c SS |
357 | |
358 | ||
080ce8c0 AC |
359 | /* Answer the height of a window. If it hasn't been created yet, |
360 | answer what the height of a window would be based upon its type and | |
361 | the layout. */ | |
c906108c | 362 | int |
080ce8c0 AC |
363 | tui_default_win_viewport_height (enum tui_win_type type, |
364 | enum tui_layout_type layout) | |
c906108c SS |
365 | { |
366 | int h; | |
367 | ||
6ba8e26f | 368 | h = tui_default_win_height (type, layout); |
c906108c | 369 | |
6d012f14 | 370 | if (tui_win_list[type] == TUI_CMD_WIN) |
c906108c SS |
371 | h -= 1; |
372 | else | |
373 | h -= 2; | |
374 | ||
375 | return h; | |
6ba8e26f | 376 | } |
c906108c SS |
377 | |
378 | ||
6ba8e26f AC |
379 | /* Function to initialize gdb commands, for tui window layout |
380 | manipulation. */ | |
2c0b251b PA |
381 | |
382 | /* Provide a prototype to silence -Wmissing-prototypes. */ | |
383 | extern initialize_file_ftype _initialize_tui_layout; | |
384 | ||
c906108c | 385 | void |
6ba8e26f | 386 | _initialize_tui_layout (void) |
c906108c | 387 | { |
1bedd215 AC |
388 | add_com ("layout", class_tui, tui_layout_command, _("\ |
389 | Change the layout of windows.\n\ | |
c906108c SS |
390 | Usage: layout prev | next | <layout_name> \n\ |
391 | Layout names are:\n\ | |
392 | src : Displays source and command windows.\n\ | |
393 | asm : Displays disassembly and command windows.\n\ | |
394 | split : Displays source, disassembly and command windows.\n\ | |
395 | regs : Displays register window. If existing layout\n\ | |
396 | is source/command or assembly/command, the \n\ | |
397 | register window is displayed. If the\n\ | |
398 | source/assembly/command (split) is displayed, \n\ | |
399 | the register window is displayed with \n\ | |
1bedd215 | 400 | the window that has current logical focus.\n")); |
41783295 SC |
401 | if (xdb_commands) |
402 | { | |
1bedd215 AC |
403 | add_com ("td", class_tui, tui_toggle_layout_command, _("\ |
404 | Toggle between Source/Command and Disassembly/Command layouts.\n")); | |
405 | add_com ("ts", class_tui, tui_toggle_split_layout_command, _("\ | |
406 | Toggle between Source/Command or Disassembly/Command and \n\ | |
407 | Source/Disassembly/Command layouts.\n")); | |
c906108c | 408 | } |
41783295 | 409 | } |
c906108c SS |
410 | |
411 | ||
412 | /************************* | |
413 | ** STATIC LOCAL FUNCTIONS | |
414 | **************************/ | |
415 | ||
416 | ||
6ba8e26f AC |
417 | /* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, |
418 | REGS, $REGS, $GREGS, $FREGS, $SREGS. */ | |
22940a24 | 419 | enum tui_status |
6ba8e26f | 420 | tui_set_layout_for_display_command (const char *layout_name) |
c906108c | 421 | { |
22940a24 | 422 | enum tui_status status = TUI_SUCCESS; |
c906108c | 423 | |
6ba8e26f | 424 | if (layout_name != (char *) NULL) |
c906108c | 425 | { |
d02c80cd AC |
426 | int i; |
427 | char *buf_ptr; | |
6ba8e26f AC |
428 | enum tui_layout_type new_layout = UNDEFINED_LAYOUT; |
429 | enum tui_register_display_type dpy_type = TUI_UNDEFINED_REGS; | |
430 | enum tui_layout_type cur_layout = tui_current_layout (); | |
c906108c | 431 | |
6ba8e26f AC |
432 | buf_ptr = (char *) xstrdup (layout_name); |
433 | for (i = 0; (i < strlen (layout_name)); i++) | |
434 | buf_ptr[i] = toupper (buf_ptr[i]); | |
c906108c | 435 | |
1cc6d956 | 436 | /* First check for ambiguous input. */ |
e5908723 MS |
437 | if (strlen (buf_ptr) <= 1 |
438 | && (*buf_ptr == 'S' || *buf_ptr == '$')) | |
c906108c | 439 | { |
8a3fe4f8 | 440 | warning (_("Ambiguous command input.")); |
c906108c SS |
441 | status = TUI_FAILURE; |
442 | } | |
443 | else | |
444 | { | |
6ba8e26f AC |
445 | if (subset_compare (buf_ptr, "SRC")) |
446 | new_layout = SRC_COMMAND; | |
447 | else if (subset_compare (buf_ptr, "ASM")) | |
448 | new_layout = DISASSEM_COMMAND; | |
449 | else if (subset_compare (buf_ptr, "SPLIT")) | |
450 | new_layout = SRC_DISASSEM_COMMAND; | |
e5908723 MS |
451 | else if (subset_compare (buf_ptr, "REGS") |
452 | || subset_compare (buf_ptr, TUI_GENERAL_SPECIAL_REGS_NAME) | |
453 | || subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME) | |
454 | || subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME) | |
455 | || subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME)) | |
c906108c | 456 | { |
e5908723 MS |
457 | if (cur_layout == SRC_COMMAND |
458 | || cur_layout == SRC_DATA_COMMAND) | |
6ba8e26f | 459 | new_layout = SRC_DATA_COMMAND; |
c906108c | 460 | else |
6ba8e26f | 461 | new_layout = DISASSEM_DATA_COMMAND; |
c906108c | 462 | |
1cc6d956 MS |
463 | /* Could ifdef out the following code. when compile with |
464 | -z, there are null pointer references that cause a | |
465 | core dump if 'layout regs' is the first layout | |
466 | command issued by the user. HP has asked us to hook | |
467 | up this code. - edie epstein */ | |
6ba8e26f | 468 | if (subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME)) |
c906108c | 469 | { |
9a2b4c1b MS |
470 | if (TUI_DATA_WIN->detail.data_display_info.regs_display_type |
471 | != TUI_SFLOAT_REGS | |
472 | && TUI_DATA_WIN->detail.data_display_info.regs_display_type | |
473 | != TUI_DFLOAT_REGS) | |
6ba8e26f | 474 | dpy_type = TUI_SFLOAT_REGS; |
c906108c | 475 | else |
6ba8e26f | 476 | dpy_type = |
6d012f14 | 477 | TUI_DATA_WIN->detail.data_display_info.regs_display_type; |
c906108c | 478 | } |
6ba8e26f | 479 | else if (subset_compare (buf_ptr, |
c906108c | 480 | TUI_GENERAL_SPECIAL_REGS_NAME)) |
6ba8e26f AC |
481 | dpy_type = TUI_GENERAL_AND_SPECIAL_REGS; |
482 | else if (subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME)) | |
483 | dpy_type = TUI_GENERAL_REGS; | |
484 | else if (subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME)) | |
485 | dpy_type = TUI_SPECIAL_REGS; | |
6d012f14 | 486 | else if (TUI_DATA_WIN) |
c906108c | 487 | { |
9a2b4c1b MS |
488 | if (TUI_DATA_WIN->detail.data_display_info.regs_display_type |
489 | != TUI_UNDEFINED_REGS) | |
a743e542 MS |
490 | dpy_type |
491 | = TUI_DATA_WIN->detail.data_display_info.regs_display_type; | |
c906108c | 492 | else |
6ba8e26f | 493 | dpy_type = TUI_GENERAL_REGS; |
c906108c SS |
494 | } |
495 | ||
1cc6d956 MS |
496 | /* End of potential ifdef. |
497 | */ | |
c906108c | 498 | |
1cc6d956 MS |
499 | /* If ifdefed out code above, then assume that the user |
500 | wishes to display the general purpose registers . | |
501 | */ | |
c906108c | 502 | |
1cc6d956 | 503 | /* dpy_type = TUI_GENERAL_REGS; */ |
c906108c | 504 | } |
6ba8e26f AC |
505 | else if (subset_compare (buf_ptr, "NEXT")) |
506 | new_layout = next_layout (); | |
507 | else if (subset_compare (buf_ptr, "PREV")) | |
508 | new_layout = prev_layout (); | |
c906108c SS |
509 | else |
510 | status = TUI_FAILURE; | |
c906108c | 511 | |
6ba8e26f | 512 | tui_set_layout (new_layout, dpy_type); |
c906108c | 513 | } |
3e40160c | 514 | xfree (buf_ptr); |
c906108c SS |
515 | } |
516 | else | |
517 | status = TUI_FAILURE; | |
518 | ||
519 | return status; | |
e8b915dc | 520 | } |
c906108c SS |
521 | |
522 | ||
13274fc3 UW |
523 | static void |
524 | extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p) | |
c906108c | 525 | { |
6ba8e26f | 526 | enum tui_layout_type cur_layout = tui_current_layout (); |
957b8b5a | 527 | struct gdbarch *gdbarch = get_current_arch (); |
c774cec6 | 528 | CORE_ADDR addr; |
84b1e7c7 | 529 | CORE_ADDR pc; |
52575520 | 530 | struct symtab_and_line cursal = get_current_source_symtab_and_line (); |
c906108c | 531 | |
6ba8e26f | 532 | switch (cur_layout) |
c906108c SS |
533 | { |
534 | case SRC_COMMAND: | |
535 | case SRC_DATA_COMMAND: | |
13274fc3 | 536 | gdbarch = TUI_SRC_WIN->detail.source_info.gdbarch; |
52575520 | 537 | find_line_pc (cursal.symtab, |
362c05fe | 538 | TUI_SRC_WIN->detail.source_info.start_line_or_addr.u.line_no, |
84b1e7c7 | 539 | &pc); |
c774cec6 | 540 | addr = pc; |
c906108c SS |
541 | break; |
542 | case DISASSEM_COMMAND: | |
543 | case SRC_DISASSEM_COMMAND: | |
544 | case DISASSEM_DATA_COMMAND: | |
13274fc3 | 545 | gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch; |
362c05fe | 546 | addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr; |
c906108c SS |
547 | break; |
548 | default: | |
c774cec6 | 549 | addr = 0; |
c906108c SS |
550 | break; |
551 | } | |
552 | ||
13274fc3 UW |
553 | *gdbarch_p = gdbarch; |
554 | *addr_p = addr; | |
6ba8e26f | 555 | } |
c906108c SS |
556 | |
557 | ||
558 | static void | |
5b6fe301 | 559 | tui_handle_xdb_layout (struct tui_layout_def *layout_def) |
c906108c | 560 | { |
6ba8e26f | 561 | if (layout_def->split) |
c906108c | 562 | { |
080ce8c0 | 563 | tui_set_layout (SRC_DISASSEM_COMMAND, TUI_UNDEFINED_REGS); |
6ba8e26f | 564 | tui_set_win_focus_to (tui_win_list[layout_def->display_mode]); |
c906108c SS |
565 | } |
566 | else | |
567 | { | |
6ba8e26f | 568 | if (layout_def->display_mode == SRC_WIN) |
080ce8c0 | 569 | tui_set_layout (SRC_COMMAND, TUI_UNDEFINED_REGS); |
c906108c | 570 | else |
6ba8e26f | 571 | tui_set_layout (DISASSEM_DATA_COMMAND, layout_def->regs_display_type); |
c906108c | 572 | } |
6ba8e26f | 573 | } |
c906108c SS |
574 | |
575 | ||
576 | static void | |
6ba8e26f | 577 | tui_toggle_layout_command (char *arg, int from_tty) |
c906108c | 578 | { |
5b6fe301 | 579 | struct tui_layout_def *layout_def = tui_layout_def (); |
c906108c | 580 | |
19eb139b SC |
581 | /* Make sure the curses mode is enabled. */ |
582 | tui_enable (); | |
6ba8e26f AC |
583 | if (layout_def->display_mode == SRC_WIN) |
584 | layout_def->display_mode = DISASSEM_WIN; | |
c906108c | 585 | else |
6ba8e26f | 586 | layout_def->display_mode = SRC_WIN; |
c906108c | 587 | |
6ba8e26f AC |
588 | if (!layout_def->split) |
589 | tui_handle_xdb_layout (layout_def); | |
e8b915dc | 590 | } |
c906108c SS |
591 | |
592 | ||
593 | static void | |
6ba8e26f | 594 | tui_toggle_split_layout_command (char *arg, int from_tty) |
c906108c | 595 | { |
5b6fe301 | 596 | struct tui_layout_def *layout_def = tui_layout_def (); |
c906108c | 597 | |
19eb139b SC |
598 | /* Make sure the curses mode is enabled. */ |
599 | tui_enable (); | |
6ba8e26f AC |
600 | layout_def->split = (!layout_def->split); |
601 | tui_handle_xdb_layout (layout_def); | |
e8b915dc | 602 | } |
c906108c SS |
603 | |
604 | ||
605 | static void | |
6ba8e26f | 606 | tui_layout_command (char *arg, int from_tty) |
c906108c | 607 | { |
19eb139b SC |
608 | /* Make sure the curses mode is enabled. */ |
609 | tui_enable (); | |
610 | ||
611 | /* Switch to the selected layout. */ | |
080ce8c0 | 612 | if (tui_set_layout_for_display_command (arg) != TUI_SUCCESS) |
8a3fe4f8 | 613 | warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE); |
c906108c | 614 | |
e8b915dc | 615 | } |
c906108c | 616 | |
6ba8e26f | 617 | /* Answer the previous layout to cycle to. */ |
2a8854a7 | 618 | static enum tui_layout_type |
6ba8e26f | 619 | next_layout (void) |
c906108c | 620 | { |
6ba8e26f | 621 | enum tui_layout_type new_layout; |
c906108c | 622 | |
6ba8e26f AC |
623 | new_layout = tui_current_layout (); |
624 | if (new_layout == UNDEFINED_LAYOUT) | |
625 | new_layout = SRC_COMMAND; | |
c906108c SS |
626 | else |
627 | { | |
6ba8e26f AC |
628 | new_layout++; |
629 | if (new_layout == UNDEFINED_LAYOUT) | |
630 | new_layout = SRC_COMMAND; | |
c906108c SS |
631 | } |
632 | ||
6ba8e26f AC |
633 | return new_layout; |
634 | } | |
c906108c SS |
635 | |
636 | ||
6ba8e26f | 637 | /* Answer the next layout to cycle to. */ |
2a8854a7 | 638 | static enum tui_layout_type |
6ba8e26f | 639 | prev_layout (void) |
c906108c | 640 | { |
6ba8e26f | 641 | enum tui_layout_type new_layout; |
c906108c | 642 | |
6ba8e26f AC |
643 | new_layout = tui_current_layout (); |
644 | if (new_layout == SRC_COMMAND) | |
645 | new_layout = DISASSEM_DATA_COMMAND; | |
c906108c SS |
646 | else |
647 | { | |
6ba8e26f AC |
648 | new_layout--; |
649 | if (new_layout == UNDEFINED_LAYOUT) | |
650 | new_layout = DISASSEM_DATA_COMMAND; | |
c906108c SS |
651 | } |
652 | ||
6ba8e26f AC |
653 | return new_layout; |
654 | } | |
c906108c SS |
655 | |
656 | ||
657 | ||
c906108c | 658 | static void |
08ef48c5 MS |
659 | make_command_window (struct tui_win_info **win_info_ptr, |
660 | int height, int origin_y) | |
c906108c | 661 | { |
d5d6fca5 DJ |
662 | *win_info_ptr = init_and_make_win (*win_info_ptr, |
663 | CMD_WIN, | |
664 | height, | |
665 | tui_term_width (), | |
666 | 0, | |
667 | origin_y, | |
668 | DONT_BOX_WINDOW); | |
c906108c | 669 | |
6ba8e26f AC |
670 | (*win_info_ptr)->can_highlight = FALSE; |
671 | } | |
c906108c SS |
672 | |
673 | ||
ef5eab5a | 674 | /* make_source_window(). |
c5aa993b | 675 | */ |
c906108c | 676 | static void |
08ef48c5 MS |
677 | make_source_window (struct tui_win_info **win_info_ptr, |
678 | int height, int origin_y) | |
c906108c | 679 | { |
6ba8e26f | 680 | make_source_or_disasm_window (win_info_ptr, SRC_WIN, height, origin_y); |
c906108c SS |
681 | |
682 | return; | |
6ba8e26f | 683 | } /* make_source_window */ |
c906108c SS |
684 | |
685 | ||
ef5eab5a | 686 | /* make_disasm_window(). |
c5aa993b | 687 | */ |
c906108c | 688 | static void |
08ef48c5 MS |
689 | make_disasm_window (struct tui_win_info **win_info_ptr, |
690 | int height, int origin_y) | |
c906108c | 691 | { |
6ba8e26f | 692 | make_source_or_disasm_window (win_info_ptr, DISASSEM_WIN, height, origin_y); |
c906108c SS |
693 | |
694 | return; | |
6ba8e26f | 695 | } /* make_disasm_window */ |
c906108c SS |
696 | |
697 | ||
c906108c | 698 | static void |
08ef48c5 MS |
699 | make_data_window (struct tui_win_info **win_info_ptr, |
700 | int height, int origin_y) | |
c906108c | 701 | { |
d5d6fca5 DJ |
702 | *win_info_ptr = init_and_make_win (*win_info_ptr, |
703 | DATA_WIN, | |
704 | height, | |
705 | tui_term_width (), | |
706 | 0, | |
707 | origin_y, | |
708 | BOX_WINDOW); | |
6ba8e26f | 709 | } |
c906108c SS |
710 | |
711 | ||
712 | ||
6ba8e26f | 713 | /* Show the Source/Command layout. */ |
c906108c | 714 | static void |
6ba8e26f | 715 | show_source_command (void) |
c906108c | 716 | { |
6ba8e26f AC |
717 | show_source_or_disasm_and_command (SRC_COMMAND); |
718 | } | |
c906108c SS |
719 | |
720 | ||
6ba8e26f | 721 | /* Show the Dissassem/Command layout. */ |
c906108c | 722 | static void |
6ba8e26f | 723 | show_disasm_command (void) |
c906108c | 724 | { |
6ba8e26f AC |
725 | show_source_or_disasm_and_command (DISASSEM_COMMAND); |
726 | } | |
c906108c SS |
727 | |
728 | ||
6ba8e26f | 729 | /* Show the Source/Disassem/Command layout. */ |
c906108c | 730 | static void |
6ba8e26f | 731 | show_source_disasm_command (void) |
c906108c | 732 | { |
dd1abb8c | 733 | if (tui_current_layout () != SRC_DISASSEM_COMMAND) |
c906108c | 734 | { |
6ba8e26f | 735 | int cmd_height, src_height, asm_height; |
c906108c | 736 | |
6d012f14 | 737 | if (TUI_CMD_WIN != NULL) |
6ba8e26f | 738 | cmd_height = TUI_CMD_WIN->generic.height; |
c906108c | 739 | else |
6ba8e26f | 740 | cmd_height = tui_term_height () / 3; |
c906108c | 741 | |
6ba8e26f AC |
742 | src_height = (tui_term_height () - cmd_height) / 2; |
743 | asm_height = tui_term_height () - (src_height + cmd_height); | |
c906108c | 744 | |
6d012f14 | 745 | if (TUI_SRC_WIN == NULL) |
6ba8e26f | 746 | make_source_window (&TUI_SRC_WIN, src_height, 0); |
c906108c SS |
747 | else |
748 | { | |
6ba8e26f | 749 | init_gen_win_info (&TUI_SRC_WIN->generic, |
08ef48c5 MS |
750 | TUI_SRC_WIN->generic.type, |
751 | src_height, | |
752 | TUI_SRC_WIN->generic.width, | |
753 | TUI_SRC_WIN->detail.source_info.execution_info->width, | |
754 | 0); | |
6d012f14 | 755 | TUI_SRC_WIN->can_highlight = TRUE; |
6ba8e26f | 756 | init_gen_win_info (TUI_SRC_WIN->detail.source_info.execution_info, |
08ef48c5 MS |
757 | EXEC_INFO_WIN, |
758 | src_height, | |
759 | 3, | |
760 | 0, | |
761 | 0); | |
6d012f14 AC |
762 | tui_make_visible (&TUI_SRC_WIN->generic); |
763 | tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info); | |
764 | TUI_SRC_WIN->detail.source_info.has_locator = FALSE;; | |
c906108c | 765 | } |
6d012f14 | 766 | if (TUI_SRC_WIN != NULL) |
c906108c | 767 | { |
5b6fe301 | 768 | struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); |
c906108c | 769 | |
6d012f14 AC |
770 | tui_show_source_content (TUI_SRC_WIN); |
771 | if (TUI_DISASM_WIN == NULL) | |
c906108c | 772 | { |
6ba8e26f | 773 | make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1); |
d5d6fca5 DJ |
774 | locator = init_and_make_win (locator, |
775 | LOCATOR_WIN, | |
776 | 2 /* 1 */ , | |
777 | tui_term_width (), | |
778 | 0, | |
779 | (src_height + asm_height) - 1, | |
780 | DONT_BOX_WINDOW); | |
c906108c SS |
781 | } |
782 | else | |
783 | { | |
6ba8e26f | 784 | init_gen_win_info (locator, |
08ef48c5 MS |
785 | LOCATOR_WIN, |
786 | 2 /* 1 */ , | |
787 | tui_term_width (), | |
788 | 0, | |
789 | (src_height + asm_height) - 1); | |
6d012f14 | 790 | TUI_DISASM_WIN->detail.source_info.has_locator = TRUE; |
08ef48c5 MS |
791 | init_gen_win_info (&TUI_DISASM_WIN->generic, |
792 | TUI_DISASM_WIN->generic.type, | |
793 | asm_height, | |
794 | TUI_DISASM_WIN->generic.width, | |
795 | TUI_DISASM_WIN->detail.source_info.execution_info->width, | |
796 | src_height - 1); | |
6ba8e26f | 797 | init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info, |
08ef48c5 MS |
798 | EXEC_INFO_WIN, |
799 | asm_height, | |
800 | 3, | |
801 | 0, | |
802 | src_height - 1); | |
6d012f14 AC |
803 | TUI_DISASM_WIN->can_highlight = TRUE; |
804 | tui_make_visible (&TUI_DISASM_WIN->generic); | |
805 | tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info); | |
c906108c | 806 | } |
6d012f14 | 807 | if (TUI_DISASM_WIN != NULL) |
c906108c | 808 | { |
6d012f14 AC |
809 | TUI_SRC_WIN->detail.source_info.has_locator = FALSE; |
810 | TUI_DISASM_WIN->detail.source_info.has_locator = TRUE; | |
ec7d9e56 | 811 | tui_make_visible (locator); |
47d3492a | 812 | tui_show_locator_content (); |
6d012f14 | 813 | tui_show_source_content (TUI_DISASM_WIN); |
c906108c | 814 | |
6d012f14 | 815 | if (TUI_CMD_WIN == NULL) |
6ba8e26f | 816 | make_command_window (&TUI_CMD_WIN, |
08ef48c5 MS |
817 | cmd_height, |
818 | tui_term_height () - cmd_height); | |
c906108c SS |
819 | else |
820 | { | |
6ba8e26f | 821 | init_gen_win_info (&TUI_CMD_WIN->generic, |
08ef48c5 MS |
822 | TUI_CMD_WIN->generic.type, |
823 | TUI_CMD_WIN->generic.height, | |
824 | TUI_CMD_WIN->generic.width, | |
825 | 0, | |
826 | TUI_CMD_WIN->generic.origin.y); | |
6d012f14 AC |
827 | TUI_CMD_WIN->can_highlight = FALSE; |
828 | tui_make_visible (&TUI_CMD_WIN->generic); | |
c906108c | 829 | } |
6d012f14 AC |
830 | if (TUI_CMD_WIN != NULL) |
831 | tui_refresh_win (&TUI_CMD_WIN->generic); | |
c906108c SS |
832 | } |
833 | } | |
dd1abb8c | 834 | tui_set_current_layout_to (SRC_DISASSEM_COMMAND); |
c906108c | 835 | } |
6ba8e26f | 836 | } |
c906108c SS |
837 | |
838 | ||
6ba8e26f AC |
839 | /* Show the Source/Data/Command or the Dissassembly/Data/Command |
840 | layout. */ | |
c906108c | 841 | static void |
6ba8e26f | 842 | show_data (enum tui_layout_type new_layout) |
c906108c | 843 | { |
6ba8e26f AC |
844 | int total_height = (tui_term_height () - TUI_CMD_WIN->generic.height); |
845 | int src_height, data_height; | |
846 | enum tui_win_type win_type; | |
5b6fe301 | 847 | struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); |
c906108c SS |
848 | |
849 | ||
6ba8e26f AC |
850 | data_height = total_height / 2; |
851 | src_height = total_height - data_height; | |
ec7d9e56 AC |
852 | tui_make_all_invisible (); |
853 | tui_make_invisible (locator); | |
6ba8e26f | 854 | make_data_window (&TUI_DATA_WIN, data_height, 0); |
6d012f14 | 855 | TUI_DATA_WIN->can_highlight = TRUE; |
6ba8e26f AC |
856 | if (new_layout == SRC_DATA_COMMAND) |
857 | win_type = SRC_WIN; | |
c906108c | 858 | else |
6ba8e26f AC |
859 | win_type = DISASSEM_WIN; |
860 | if (tui_win_list[win_type] == NULL) | |
c906108c | 861 | { |
6ba8e26f AC |
862 | if (win_type == SRC_WIN) |
863 | make_source_window (&tui_win_list[win_type], src_height, data_height - 1); | |
c906108c | 864 | else |
6ba8e26f | 865 | make_disasm_window (&tui_win_list[win_type], src_height, data_height - 1); |
d5d6fca5 DJ |
866 | locator = init_and_make_win (locator, |
867 | LOCATOR_WIN, | |
868 | 2 /* 1 */ , | |
869 | tui_term_width (), | |
870 | 0, | |
871 | total_height - 1, | |
872 | DONT_BOX_WINDOW); | |
c906108c SS |
873 | } |
874 | else | |
875 | { | |
6ba8e26f | 876 | init_gen_win_info (&tui_win_list[win_type]->generic, |
08ef48c5 MS |
877 | tui_win_list[win_type]->generic.type, |
878 | src_height, | |
879 | tui_win_list[win_type]->generic.width, | |
880 | tui_win_list[win_type]->detail.source_info.execution_info->width, | |
881 | data_height - 1); | |
6ba8e26f | 882 | init_gen_win_info (tui_win_list[win_type]->detail.source_info.execution_info, |
08ef48c5 MS |
883 | EXEC_INFO_WIN, |
884 | src_height, | |
885 | 3, | |
886 | 0, | |
887 | data_height - 1); | |
6ba8e26f AC |
888 | tui_make_visible (&tui_win_list[win_type]->generic); |
889 | tui_make_visible (tui_win_list[win_type]->detail.source_info.execution_info); | |
890 | init_gen_win_info (locator, | |
08ef48c5 MS |
891 | LOCATOR_WIN, |
892 | 2 /* 1 */ , | |
893 | tui_term_width (), | |
894 | 0, | |
895 | total_height - 1); | |
c906108c | 896 | } |
6ba8e26f | 897 | tui_win_list[win_type]->detail.source_info.has_locator = TRUE; |
ec7d9e56 | 898 | tui_make_visible (locator); |
47d3492a | 899 | tui_show_locator_content (); |
6ba8e26f AC |
900 | tui_add_to_source_windows (tui_win_list[win_type]); |
901 | tui_set_current_layout_to (new_layout); | |
902 | } | |
c906108c | 903 | |
ef5eab5a | 904 | /* init_gen_win_info(). |
c5aa993b | 905 | */ |
c906108c | 906 | static void |
08ef48c5 MS |
907 | init_gen_win_info (struct tui_gen_win_info *win_info, |
908 | enum tui_win_type type, | |
909 | int height, int width, | |
910 | int origin_x, int origin_y) | |
c906108c SS |
911 | { |
912 | int h = height; | |
913 | ||
6ba8e26f AC |
914 | win_info->type = type; |
915 | win_info->width = width; | |
916 | win_info->height = h; | |
c906108c SS |
917 | if (h > 1) |
918 | { | |
6ba8e26f AC |
919 | win_info->viewport_height = h - 1; |
920 | if (win_info->type != CMD_WIN) | |
921 | win_info->viewport_height--; | |
c906108c SS |
922 | } |
923 | else | |
6ba8e26f AC |
924 | win_info->viewport_height = 1; |
925 | win_info->origin.x = origin_x; | |
926 | win_info->origin.y = origin_y; | |
c906108c SS |
927 | |
928 | return; | |
6ba8e26f | 929 | } /* init_gen_win_info */ |
c906108c | 930 | |
ef5eab5a | 931 | /* init_and_make_win(). |
c5aa993b | 932 | */ |
d5d6fca5 | 933 | static void * |
08ef48c5 MS |
934 | init_and_make_win (void *opaque_win_info, |
935 | enum tui_win_type win_type, | |
936 | int height, int width, | |
937 | int origin_x, int origin_y, | |
d5d6fca5 | 938 | int box_it) |
c906108c | 939 | { |
5b6fe301 | 940 | struct tui_gen_win_info *generic; |
c906108c | 941 | |
6ba8e26f | 942 | if (opaque_win_info == NULL) |
c906108c | 943 | { |
6ba8e26f AC |
944 | if (tui_win_is_auxillary (win_type)) |
945 | opaque_win_info = (void *) tui_alloc_generic_win_info (); | |
c906108c | 946 | else |
6ba8e26f | 947 | opaque_win_info = (void *) tui_alloc_win_info (win_type); |
c906108c | 948 | } |
6ba8e26f AC |
949 | if (tui_win_is_auxillary (win_type)) |
950 | generic = (struct tui_gen_win_info *) opaque_win_info; | |
c906108c | 951 | else |
6ba8e26f | 952 | generic = &((struct tui_win_info *) opaque_win_info)->generic; |
c906108c | 953 | |
6ba8e26f | 954 | if (opaque_win_info != NULL) |
c906108c | 955 | { |
6ba8e26f AC |
956 | init_gen_win_info (generic, win_type, height, width, origin_x, origin_y); |
957 | if (!tui_win_is_auxillary (win_type)) | |
c906108c SS |
958 | { |
959 | if (generic->type == CMD_WIN) | |
6ba8e26f | 960 | ((struct tui_win_info *) opaque_win_info)->can_highlight = FALSE; |
c906108c | 961 | else |
6ba8e26f | 962 | ((struct tui_win_info *) opaque_win_info)->can_highlight = TRUE; |
c906108c | 963 | } |
6ba8e26f | 964 | tui_make_window (generic, box_it); |
c906108c | 965 | } |
d5d6fca5 | 966 | return opaque_win_info; |
bc712bbf | 967 | } |
c906108c SS |
968 | |
969 | ||
c906108c | 970 | static void |
08ef48c5 MS |
971 | make_source_or_disasm_window (struct tui_win_info **win_info_ptr, |
972 | enum tui_win_type type, | |
973 | int height, int origin_y) | |
c906108c | 974 | { |
5b6fe301 | 975 | struct tui_gen_win_info *execution_info = (struct tui_gen_win_info *) NULL; |
c906108c | 976 | |
ef5eab5a | 977 | /* Create the exeuction info window. */ |
c906108c | 978 | if (type == SRC_WIN) |
6d012f14 | 979 | execution_info = tui_source_exec_info_win_ptr (); |
c906108c | 980 | else |
6d012f14 | 981 | execution_info = tui_disassem_exec_info_win_ptr (); |
d5d6fca5 DJ |
982 | execution_info = init_and_make_win (execution_info, |
983 | EXEC_INFO_WIN, | |
984 | height, | |
985 | 3, | |
986 | 0, | |
987 | origin_y, | |
988 | DONT_BOX_WINDOW); | |
ef5eab5a MS |
989 | |
990 | /* Now create the source window. */ | |
d5d6fca5 DJ |
991 | *win_info_ptr = init_and_make_win (*win_info_ptr, |
992 | type, | |
993 | height, | |
994 | tui_term_width () - execution_info->width, | |
995 | execution_info->width, | |
996 | origin_y, | |
997 | BOX_WINDOW); | |
c906108c | 998 | |
6ba8e26f AC |
999 | (*win_info_ptr)->detail.source_info.execution_info = execution_info; |
1000 | } | |
c906108c SS |
1001 | |
1002 | ||
1cc6d956 | 1003 | /* Show the Source/Command or the Disassem layout. */ |
c906108c | 1004 | static void |
6ba8e26f | 1005 | show_source_or_disasm_and_command (enum tui_layout_type layout_type) |
c906108c | 1006 | { |
6ba8e26f | 1007 | if (tui_current_layout () != layout_type) |
c906108c | 1008 | { |
5b6fe301 | 1009 | struct tui_win_info **win_info_ptr; |
6ba8e26f | 1010 | int src_height, cmd_height; |
5b6fe301 | 1011 | struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); |
c906108c | 1012 | |
6d012f14 | 1013 | if (TUI_CMD_WIN != NULL) |
6ba8e26f | 1014 | cmd_height = TUI_CMD_WIN->generic.height; |
c906108c | 1015 | else |
6ba8e26f AC |
1016 | cmd_height = tui_term_height () / 3; |
1017 | src_height = tui_term_height () - cmd_height; | |
c906108c | 1018 | |
6ba8e26f AC |
1019 | if (layout_type == SRC_COMMAND) |
1020 | win_info_ptr = &TUI_SRC_WIN; | |
c906108c | 1021 | else |
6ba8e26f | 1022 | win_info_ptr = &TUI_DISASM_WIN; |
c906108c | 1023 | |
6ba8e26f | 1024 | if ((*win_info_ptr) == NULL) |
c906108c | 1025 | { |
6ba8e26f AC |
1026 | if (layout_type == SRC_COMMAND) |
1027 | make_source_window (win_info_ptr, src_height - 1, 0); | |
c906108c | 1028 | else |
6ba8e26f | 1029 | make_disasm_window (win_info_ptr, src_height - 1, 0); |
d5d6fca5 DJ |
1030 | locator = init_and_make_win (locator, |
1031 | LOCATOR_WIN, | |
1032 | 2 /* 1 */ , | |
1033 | tui_term_width (), | |
1034 | 0, | |
1035 | src_height - 1, | |
1036 | DONT_BOX_WINDOW); | |
c906108c SS |
1037 | } |
1038 | else | |
1039 | { | |
6ba8e26f | 1040 | init_gen_win_info (locator, |
08ef48c5 MS |
1041 | LOCATOR_WIN, |
1042 | 2 /* 1 */ , | |
1043 | tui_term_width (), | |
1044 | 0, | |
1045 | src_height - 1); | |
6ba8e26f | 1046 | (*win_info_ptr)->detail.source_info.has_locator = TRUE; |
08ef48c5 MS |
1047 | init_gen_win_info (&(*win_info_ptr)->generic, |
1048 | (*win_info_ptr)->generic.type, | |
1049 | src_height - 1, | |
1050 | (*win_info_ptr)->generic.width, | |
1051 | (*win_info_ptr)->detail.source_info.execution_info->width, | |
1052 | 0); | |
6ba8e26f | 1053 | init_gen_win_info ((*win_info_ptr)->detail.source_info.execution_info, |
08ef48c5 MS |
1054 | EXEC_INFO_WIN, |
1055 | src_height - 1, | |
1056 | 3, | |
1057 | 0, | |
1058 | 0); | |
6ba8e26f AC |
1059 | (*win_info_ptr)->can_highlight = TRUE; |
1060 | tui_make_visible (&(*win_info_ptr)->generic); | |
1061 | tui_make_visible ((*win_info_ptr)->detail.source_info.execution_info); | |
c906108c | 1062 | } |
6ba8e26f | 1063 | if ((*win_info_ptr) != NULL) |
c906108c | 1064 | { |
6ba8e26f | 1065 | (*win_info_ptr)->detail.source_info.has_locator = TRUE; |
ec7d9e56 | 1066 | tui_make_visible (locator); |
47d3492a | 1067 | tui_show_locator_content (); |
6ba8e26f | 1068 | tui_show_source_content (*win_info_ptr); |
c906108c | 1069 | |
6d012f14 | 1070 | if (TUI_CMD_WIN == NULL) |
c906108c | 1071 | { |
6ba8e26f | 1072 | make_command_window (&TUI_CMD_WIN, cmd_height, src_height); |
6d012f14 | 1073 | tui_refresh_win (&TUI_CMD_WIN->generic); |
c906108c SS |
1074 | } |
1075 | else | |
1076 | { | |
6ba8e26f | 1077 | init_gen_win_info (&TUI_CMD_WIN->generic, |
08ef48c5 MS |
1078 | TUI_CMD_WIN->generic.type, |
1079 | TUI_CMD_WIN->generic.height, | |
1080 | TUI_CMD_WIN->generic.width, | |
1081 | TUI_CMD_WIN->generic.origin.x, | |
1082 | TUI_CMD_WIN->generic.origin.y); | |
6d012f14 AC |
1083 | TUI_CMD_WIN->can_highlight = FALSE; |
1084 | tui_make_visible (&TUI_CMD_WIN->generic); | |
c906108c SS |
1085 | } |
1086 | } | |
6ba8e26f | 1087 | tui_set_current_layout_to (layout_type); |
c906108c | 1088 | } |
6ba8e26f | 1089 | } |