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