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