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