1 /* TUI layout window management.
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
6 Contributed by Hewlett-Packard Company.
8 This file is part of GDB.
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.
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.
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. */
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"
50 /*******************************
52 ********************************/
53 static void showLayout (enum tui_layout_type
);
54 static void _initGenWinInfo (struct tui_gen_win_info
*, TuiWinType
, int, int, int, int);
55 static void _initAndMakeWin (Opaque
*, TuiWinType
, int, int, int, int, int);
56 static void _showSourceOrDisassemAndCommand (enum tui_layout_type
);
57 static void _makeSourceOrDisassemWindow (struct tui_win_info
* *, TuiWinType
, int, int);
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);
62 static void _showSourceCommand (void);
63 static void _showDisassemCommand (void);
64 static void _showSourceDisassemCommand (void);
65 static void _showData (enum tui_layout_type
);
66 static enum tui_layout_type
_nextLayout (void);
67 static enum tui_layout_type
_prevLayout (void);
68 static void _tuiLayout_command (char *, int);
69 static void _tuiToggleLayout_command (char *, int);
70 static void _tuiToggleSplitLayout_command (char *, int);
71 static CORE_ADDR
_extractDisplayStartAddr (void);
72 static void _tuiHandleXDBLayout (struct tui_layout_def
*);
75 /***************************************
77 ***************************************/
79 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
81 /* Show the screen layout defined. */
83 showLayout (enum tui_layout_type layout
)
85 enum tui_layout_type curLayout
= tui_current_layout ();
87 if (layout
!= curLayout
)
90 ** Since the new layout may cause changes in window size, we
91 ** should free the content and reallocate on next display of
94 tui_free_all_source_wins_content ();
95 tui_clear_source_windows ();
96 if (layout
== SRC_DATA_COMMAND
|| layout
== DISASSEM_DATA_COMMAND
)
99 tui_refresh_all (winList
);
103 /* First make the current layout be invisible */
104 tui_make_all_invisible ();
105 tui_make_invisible (tui_locator_win_info_ptr ());
109 /* Now show the new layout */
111 _showSourceCommand ();
112 tui_add_to_source_windows (srcWin
);
114 case DISASSEM_COMMAND
:
115 _showDisassemCommand ();
116 tui_add_to_source_windows (disassemWin
);
118 case SRC_DISASSEM_COMMAND
:
119 _showSourceDisassemCommand ();
120 tui_add_to_source_windows (srcWin
);
121 tui_add_to_source_windows (disassemWin
);
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
137 tui_set_layout (enum tui_layout_type layoutType
,
138 enum tui_register_display_type regsDisplayType
)
140 TuiStatus status
= TUI_SUCCESS
;
142 if (layoutType
!= UNDEFINED_LAYOUT
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
144 enum tui_layout_type curLayout
= tui_current_layout (), newLayout
= UNDEFINED_LAYOUT
;
145 int regsPopulate
= FALSE
;
146 CORE_ADDR addr
= _extractDisplayStartAddr ();
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 ();
152 if (layoutType
== UNDEFINED_LAYOUT
&&
153 regsDisplayType
!= TUI_UNDEFINED_REGS
)
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
;
164 newLayout
= layoutType
;
166 regsPopulate
= (newLayout
== SRC_DATA_COMMAND
||
167 newLayout
== DISASSEM_DATA_COMMAND
||
168 regsDisplayType
!= TUI_UNDEFINED_REGS
);
169 if (newLayout
!= curLayout
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
171 if (newLayout
!= curLayout
)
173 showLayout (newLayout
);
175 ** Now determine where focus should be
177 if (winWithFocus
!= cmdWin
)
182 tui_set_win_focus_to (srcWin
);
183 layoutDef
->displayMode
= SRC_WIN
;
184 layoutDef
->split
= FALSE
;
186 case DISASSEM_COMMAND
:
187 /* the previous layout was not showing
188 ** code. this can happen if there is no
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!
194 addr
= tui_get_begin_asm_address ();
195 tui_set_win_focus_to (disassemWin
);
196 layoutDef
->displayMode
= DISASSEM_WIN
;
197 layoutDef
->split
= FALSE
;
199 case SRC_DISASSEM_COMMAND
:
200 /* the previous layout was not showing
201 ** code. this can happen if there is no
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!
207 addr
= tui_get_begin_asm_address ();
208 if (winWithFocus
== srcWin
)
209 tui_set_win_focus_to (srcWin
);
211 tui_set_win_focus_to (disassemWin
);
212 layoutDef
->split
= TRUE
;
214 case SRC_DATA_COMMAND
:
215 if (winWithFocus
!= dataWin
)
216 tui_set_win_focus_to (srcWin
);
218 tui_set_win_focus_to (dataWin
);
219 layoutDef
->displayMode
= SRC_WIN
;
220 layoutDef
->split
= FALSE
;
222 case DISASSEM_DATA_COMMAND
:
223 /* the previous layout was not showing
224 ** code. this can happen if there is no
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!
230 addr
= tui_get_begin_asm_address ();
231 if (winWithFocus
!= dataWin
)
232 tui_set_win_focus_to (disassemWin
);
234 tui_set_win_focus_to (dataWin
);
235 layoutDef
->displayMode
= DISASSEM_WIN
;
236 layoutDef
->split
= FALSE
;
242 if (newWinWithFocus
!= (struct tui_win_info
*) NULL
)
243 tui_set_win_focus_to (newWinWithFocus
);
245 ** Now update the window content
248 (newLayout
== SRC_DATA_COMMAND
||
249 newLayout
== DISASSEM_DATA_COMMAND
))
250 tui_display_all_data ();
252 tui_update_source_windows_with_addr (addr
);
256 layoutDef
->regsDisplayType
=
257 (regsDisplayType
== TUI_UNDEFINED_REGS
?
258 TUI_GENERAL_REGS
: regsDisplayType
);
259 tui_show_registers (layoutDef
->regsDisplayType
);
264 status
= TUI_FAILURE
;
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
273 tui_add_win_to_layout (enum tui_win_type type
)
275 enum tui_layout_type curLayout
= tui_current_layout ();
280 if (curLayout
!= SRC_COMMAND
&&
281 curLayout
!= SRC_DISASSEM_COMMAND
&&
282 curLayout
!= SRC_DATA_COMMAND
)
284 tui_clear_source_windows_detail ();
285 if (curLayout
== DISASSEM_DATA_COMMAND
)
286 showLayout (SRC_DATA_COMMAND
);
288 showLayout (SRC_COMMAND
);
292 if (curLayout
!= DISASSEM_COMMAND
&&
293 curLayout
!= SRC_DISASSEM_COMMAND
&&
294 curLayout
!= DISASSEM_DATA_COMMAND
)
296 tui_clear_source_windows_detail ();
297 if (curLayout
== SRC_DATA_COMMAND
)
298 showLayout (DISASSEM_DATA_COMMAND
);
300 showLayout (DISASSEM_COMMAND
);
304 if (curLayout
!= SRC_DATA_COMMAND
&&
305 curLayout
!= DISASSEM_DATA_COMMAND
)
307 if (curLayout
== DISASSEM_COMMAND
)
308 showLayout (DISASSEM_DATA_COMMAND
);
310 showLayout (SRC_DATA_COMMAND
);
318 } /* tuiAddWinToLayout */
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.
328 tuiDefaultWinHeight (TuiWinType type
, enum tui_layout_type layout
)
332 if (winList
[type
] != (struct tui_win_info
*) NULL
)
333 h
= winList
[type
]->generic
.height
;
339 case DISASSEM_COMMAND
:
340 if (m_winPtrIsNull (cmdWin
))
341 h
= tui_term_height () / 2;
343 h
= tui_term_height () - cmdWin
->generic
.height
;
345 case SRC_DISASSEM_COMMAND
:
346 case SRC_DATA_COMMAND
:
347 case DISASSEM_DATA_COMMAND
:
348 if (m_winPtrIsNull (cmdWin
))
349 h
= tui_term_height () / 3;
351 h
= (tui_term_height () - cmdWin
->generic
.height
) / 2;
360 } /* tuiDefaultWinHeight */
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
367 tui_default_win_viewport_height (enum tui_win_type type
,
368 enum tui_layout_type layout
)
372 h
= tuiDefaultWinHeight (type
, layout
);
374 if (winList
[type
] == cmdWin
)
380 } /* tuiDefaultWinViewportHeight */
384 ** _initialize_tuiLayout().
385 ** Function to initialize gdb commands, for tui window layout
389 _initialize_tuiLayout (void)
391 add_com ("layout", class_tui
, _tuiLayout_command
,
392 "Change the layout of windows.\n\
393 Usage: layout prev | next | <layout_name> \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");
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\
410 Source/Disassembly/Command layouts.\n");
415 /*************************
416 ** STATIC LOCAL FUNCTIONS
417 **************************/
422 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
423 ** $REGS, $GREGS, $FREGS, $SREGS.
426 tui_set_layout_for_display_command (const char *layoutName
)
428 TuiStatus status
= TUI_SUCCESS
;
430 if (layoutName
!= (char *) NULL
)
433 register char *bufPtr
;
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 ();
438 bufPtr
= (char *) xstrdup (layoutName
);
439 for (i
= 0; (i
< strlen (layoutName
)); i
++)
440 bufPtr
[i
] = toupper (bufPtr
[i
]);
442 /* First check for ambiguous input */
443 if (strlen (bufPtr
) <= 1 && (*bufPtr
== 'S' || *bufPtr
== '$'))
445 warning ("Ambiguous command input.\n");
446 status
= TUI_FAILURE
;
450 if (subset_compare (bufPtr
, "SRC"))
451 newLayout
= SRC_COMMAND
;
452 else if (subset_compare (bufPtr
, "ASM"))
453 newLayout
= DISASSEM_COMMAND
;
454 else if (subset_compare (bufPtr
, "SPLIT"))
455 newLayout
= SRC_DISASSEM_COMMAND
;
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
))
462 if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
463 newLayout
= SRC_DATA_COMMAND
;
465 newLayout
= DISASSEM_DATA_COMMAND
;
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
472 if (subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
))
474 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
476 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
478 dpyType
= TUI_SFLOAT_REGS
;
481 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
483 else if (subset_compare (bufPtr
,
484 TUI_GENERAL_SPECIAL_REGS_NAME
))
485 dpyType
= TUI_GENERAL_AND_SPECIAL_REGS
;
486 else if (subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
))
487 dpyType
= TUI_GENERAL_REGS
;
488 else if (subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
489 dpyType
= TUI_SPECIAL_REGS
;
492 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
495 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
497 dpyType
= TUI_GENERAL_REGS
;
500 /* end of potential ifdef
503 /* if ifdefed out code above, then assume that the user wishes to display the
504 general purpose registers
507 /* dpyType = TUI_GENERAL_REGS;
510 else if (subset_compare (bufPtr
, "NEXT"))
511 newLayout
= _nextLayout ();
512 else if (subset_compare (bufPtr
, "PREV"))
513 newLayout
= _prevLayout ();
515 status
= TUI_FAILURE
;
518 tui_set_layout (newLayout
, dpyType
);
522 status
= TUI_FAILURE
;
529 _extractDisplayStartAddr (void)
531 enum tui_layout_type curLayout
= tui_current_layout ();
534 struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
539 case SRC_DATA_COMMAND
:
540 find_line_pc (cursal
.symtab
,
541 srcWin
->detail
.sourceInfo
.startLineOrAddr
.lineNo
,
545 case DISASSEM_COMMAND
:
546 case SRC_DISASSEM_COMMAND
:
547 case DISASSEM_DATA_COMMAND
:
548 addr
= disassemWin
->detail
.sourceInfo
.startLineOrAddr
.addr
;
556 } /* _extractDisplayStartAddr */
560 _tuiHandleXDBLayout (struct tui_layout_def
* layoutDef
)
562 if (layoutDef
->split
)
564 tui_set_layout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
565 tui_set_win_focus_to (winList
[layoutDef
->displayMode
]);
569 if (layoutDef
->displayMode
== SRC_WIN
)
570 tui_set_layout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
572 tui_set_layout (DISASSEM_DATA_COMMAND
, layoutDef
->regsDisplayType
);
577 } /* _tuiHandleXDBLayout */
581 _tuiToggleLayout_command (char *arg
, int fromTTY
)
583 struct tui_layout_def
* layoutDef
= tui_layout_def ();
585 /* Make sure the curses mode is enabled. */
587 if (layoutDef
->displayMode
== SRC_WIN
)
588 layoutDef
->displayMode
= DISASSEM_WIN
;
590 layoutDef
->displayMode
= SRC_WIN
;
592 if (!layoutDef
->split
)
593 _tuiHandleXDBLayout (layoutDef
);
599 _tuiToggleSplitLayout_command (char *arg
, int fromTTY
)
601 struct tui_layout_def
* layoutDef
= tui_layout_def ();
603 /* Make sure the curses mode is enabled. */
605 layoutDef
->split
= (!layoutDef
->split
);
606 _tuiHandleXDBLayout (layoutDef
);
612 _tuiLayout_command (char *arg
, int fromTTY
)
614 /* Make sure the curses mode is enabled. */
617 /* Switch to the selected layout. */
618 if (tui_set_layout_for_display_command (arg
) != TUI_SUCCESS
)
619 warning ("Invalid layout specified.\n%s", LAYOUT_USAGE
);
625 ** Answer the previous layout to cycle to.
627 static enum tui_layout_type
630 enum tui_layout_type newLayout
;
632 newLayout
= tui_current_layout ();
633 if (newLayout
== UNDEFINED_LAYOUT
)
634 newLayout
= SRC_COMMAND
;
638 if (newLayout
== UNDEFINED_LAYOUT
)
639 newLayout
= SRC_COMMAND
;
648 ** Answer the next layout to cycle to.
650 static enum tui_layout_type
653 enum tui_layout_type newLayout
;
655 newLayout
= tui_current_layout ();
656 if (newLayout
== SRC_COMMAND
)
657 newLayout
= DISASSEM_DATA_COMMAND
;
661 if (newLayout
== UNDEFINED_LAYOUT
)
662 newLayout
= DISASSEM_DATA_COMMAND
;
671 ** _makeCommandWindow().
674 _makeCommandWindow (struct tui_win_info
* * winInfoPtr
, int height
, int originY
)
676 _initAndMakeWin ((Opaque
*) winInfoPtr
,
684 (*winInfoPtr
)->canHighlight
= FALSE
;
687 } /* _makeCommandWindow */
691 ** _makeSourceWindow().
694 _makeSourceWindow (struct tui_win_info
* * winInfoPtr
, int height
, int originY
)
696 _makeSourceOrDisassemWindow (winInfoPtr
, SRC_WIN
, height
, originY
);
699 } /* _makeSourceWindow */
703 ** _makeDisassemWindow().
706 _makeDisassemWindow (struct tui_win_info
* * winInfoPtr
, int height
, int originY
)
708 _makeSourceOrDisassemWindow (winInfoPtr
, DISASSEM_WIN
, height
, originY
);
711 } /* _makeDisassemWindow */
715 ** _makeDataWindow().
718 _makeDataWindow (struct tui_win_info
* * winInfoPtr
, int height
, int originY
)
720 _initAndMakeWin ((Opaque
*) winInfoPtr
,
729 } /* _makeDataWindow */
734 ** _showSourceCommand().
735 ** Show the Source/Command layout
738 _showSourceCommand (void)
740 _showSourceOrDisassemAndCommand (SRC_COMMAND
);
743 } /* _showSourceCommand */
747 ** _showDisassemCommand().
748 ** Show the Dissassem/Command layout
751 _showDisassemCommand (void)
753 _showSourceOrDisassemAndCommand (DISASSEM_COMMAND
);
756 } /* _showDisassemCommand */
760 ** _showSourceDisassemCommand().
761 ** Show the Source/Disassem/Command layout
764 _showSourceDisassemCommand (void)
766 if (tui_current_layout () != SRC_DISASSEM_COMMAND
)
768 int cmdHeight
, srcHeight
, asmHeight
;
770 if (m_winPtrNotNull (cmdWin
))
771 cmdHeight
= cmdWin
->generic
.height
;
773 cmdHeight
= tui_term_height () / 3;
775 srcHeight
= (tui_term_height () - cmdHeight
) / 2;
776 asmHeight
= tui_term_height () - (srcHeight
+ cmdHeight
);
778 if (m_winPtrIsNull (srcWin
))
779 _makeSourceWindow (&srcWin
, srcHeight
, 0);
782 _initGenWinInfo (&srcWin
->generic
,
783 srcWin
->generic
.type
,
785 srcWin
->generic
.width
,
786 srcWin
->detail
.sourceInfo
.executionInfo
->width
,
788 srcWin
->canHighlight
= TRUE
;
789 _initGenWinInfo (srcWin
->detail
.sourceInfo
.executionInfo
,
795 tui_make_visible (&srcWin
->generic
);
796 tui_make_visible (srcWin
->detail
.sourceInfo
.executionInfo
);
797 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;;
799 if (m_winPtrNotNull (srcWin
))
801 struct tui_gen_win_info
* locator
= tui_locator_win_info_ptr ();
803 tui_show_source_content (srcWin
);
804 if (m_winPtrIsNull (disassemWin
))
806 _makeDisassemWindow (&disassemWin
, asmHeight
, srcHeight
- 1);
807 _initAndMakeWin ((Opaque
*) & locator
,
812 (srcHeight
+ asmHeight
) - 1,
817 _initGenWinInfo (locator
,
822 (srcHeight
+ asmHeight
) - 1);
823 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
825 &disassemWin
->generic
,
826 disassemWin
->generic
.type
,
828 disassemWin
->generic
.width
,
829 disassemWin
->detail
.sourceInfo
.executionInfo
->width
,
831 _initGenWinInfo (disassemWin
->detail
.sourceInfo
.executionInfo
,
837 disassemWin
->canHighlight
= TRUE
;
838 tui_make_visible (&disassemWin
->generic
);
839 tui_make_visible (disassemWin
->detail
.sourceInfo
.executionInfo
);
841 if (m_winPtrNotNull (disassemWin
))
843 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;
844 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
845 tui_make_visible (locator
);
846 tui_show_locator_content ();
847 tui_show_source_content (disassemWin
);
849 if (m_winPtrIsNull (cmdWin
))
850 _makeCommandWindow (&cmdWin
,
852 tui_term_height () - cmdHeight
);
855 _initGenWinInfo (&cmdWin
->generic
,
856 cmdWin
->generic
.type
,
857 cmdWin
->generic
.height
,
858 cmdWin
->generic
.width
,
860 cmdWin
->generic
.origin
.y
);
861 cmdWin
->canHighlight
= FALSE
;
862 tui_make_visible (&cmdWin
->generic
);
864 if (m_winPtrNotNull (cmdWin
))
865 tui_refresh_win (&cmdWin
->generic
);
868 tui_set_current_layout_to (SRC_DISASSEM_COMMAND
);
872 } /* _showSourceDisassemCommand */
877 ** Show the Source/Data/Command or the Dissassembly/Data/Command layout
880 _showData (enum tui_layout_type newLayout
)
882 int totalHeight
= (tui_term_height () - cmdWin
->generic
.height
);
883 int srcHeight
, dataHeight
;
885 struct tui_gen_win_info
* locator
= tui_locator_win_info_ptr ();
888 dataHeight
= totalHeight
/ 2;
889 srcHeight
= totalHeight
- dataHeight
;
890 tui_make_all_invisible ();
891 tui_make_invisible (locator
);
892 _makeDataWindow (&dataWin
, dataHeight
, 0);
893 dataWin
->canHighlight
= TRUE
;
894 if (newLayout
== SRC_DATA_COMMAND
)
897 winType
= DISASSEM_WIN
;
898 if (m_winPtrIsNull (winList
[winType
]))
900 if (winType
== SRC_WIN
)
901 _makeSourceWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
903 _makeDisassemWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
904 _initAndMakeWin ((Opaque
*) & locator
,
914 _initGenWinInfo (&winList
[winType
]->generic
,
915 winList
[winType
]->generic
.type
,
917 winList
[winType
]->generic
.width
,
918 winList
[winType
]->detail
.sourceInfo
.executionInfo
->width
,
920 _initGenWinInfo (winList
[winType
]->detail
.sourceInfo
.executionInfo
,
926 tui_make_visible (&winList
[winType
]->generic
);
927 tui_make_visible (winList
[winType
]->detail
.sourceInfo
.executionInfo
);
928 _initGenWinInfo (locator
,
935 winList
[winType
]->detail
.sourceInfo
.hasLocator
= TRUE
;
936 tui_make_visible (locator
);
937 tui_show_locator_content ();
938 tui_add_to_source_windows (winList
[winType
]);
939 tui_set_current_layout_to (newLayout
);
945 ** _initGenWinInfo().
948 _initGenWinInfo (struct tui_gen_win_info
* winInfo
, TuiWinType type
,
949 int height
, int width
, int originX
, int originY
)
953 winInfo
->type
= type
;
954 winInfo
->width
= width
;
958 winInfo
->viewportHeight
= h
- 1;
959 if (winInfo
->type
!= CMD_WIN
)
960 winInfo
->viewportHeight
--;
963 winInfo
->viewportHeight
= 1;
964 winInfo
->origin
.x
= originX
;
965 winInfo
->origin
.y
= originY
;
968 } /* _initGenWinInfo */
971 ** _initAndMakeWin().
974 _initAndMakeWin (Opaque
* winInfoPtr
, TuiWinType winType
,
975 int height
, int width
, int originX
, int originY
, int boxIt
)
977 Opaque opaqueWinInfo
= *winInfoPtr
;
978 struct tui_gen_win_info
* generic
;
980 if (opaqueWinInfo
== (Opaque
) NULL
)
982 if (m_winIsAuxillary (winType
))
983 opaqueWinInfo
= (Opaque
) tui_alloc_generic_win_info ();
985 opaqueWinInfo
= (Opaque
) tui_alloc_win_info (winType
);
987 if (m_winIsAuxillary (winType
))
988 generic
= (struct tui_gen_win_info
*) opaqueWinInfo
;
990 generic
= &((struct tui_win_info
*) opaqueWinInfo
)->generic
;
992 if (opaqueWinInfo
!= (Opaque
) NULL
)
994 _initGenWinInfo (generic
, winType
, height
, width
, originX
, originY
);
995 if (!m_winIsAuxillary (winType
))
997 if (generic
->type
== CMD_WIN
)
998 ((struct tui_win_info
*) opaqueWinInfo
)->canHighlight
= FALSE
;
1000 ((struct tui_win_info
*) opaqueWinInfo
)->canHighlight
= TRUE
;
1002 tui_make_window (generic
, boxIt
);
1004 *winInfoPtr
= opaqueWinInfo
;
1009 ** _makeSourceOrDisassemWindow().
1012 _makeSourceOrDisassemWindow (struct tui_win_info
* * winInfoPtr
, TuiWinType type
,
1013 int height
, int originY
)
1015 struct tui_gen_win_info
* executionInfo
= (struct tui_gen_win_info
*) NULL
;
1018 ** Create the exeuction info window.
1020 if (type
== SRC_WIN
)
1021 executionInfo
= tui_source_exec_info_win_ptr ();
1023 executionInfo
= tui_disassem_exec_info_win_ptr ();
1024 _initAndMakeWin ((Opaque
*) & executionInfo
,
1032 ** Now create the source window.
1034 _initAndMakeWin ((Opaque
*) winInfoPtr
,
1037 tui_term_width () - executionInfo
->width
,
1038 executionInfo
->width
,
1042 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
= executionInfo
;
1045 } /* _makeSourceOrDisassemWindow */
1049 ** _showSourceOrDisassemAndCommand().
1050 ** Show the Source/Command or the Disassem layout
1053 _showSourceOrDisassemAndCommand (enum tui_layout_type layoutType
)
1055 if (tui_current_layout () != layoutType
)
1057 struct tui_win_info
* *winInfoPtr
;
1058 int srcHeight
, cmdHeight
;
1059 struct tui_gen_win_info
* locator
= tui_locator_win_info_ptr ();
1061 if (m_winPtrNotNull (cmdWin
))
1062 cmdHeight
= cmdWin
->generic
.height
;
1064 cmdHeight
= tui_term_height () / 3;
1065 srcHeight
= tui_term_height () - cmdHeight
;
1068 if (layoutType
== SRC_COMMAND
)
1069 winInfoPtr
= &srcWin
;
1071 winInfoPtr
= &disassemWin
;
1073 if (m_winPtrIsNull (*winInfoPtr
))
1075 if (layoutType
== SRC_COMMAND
)
1076 _makeSourceWindow (winInfoPtr
, srcHeight
- 1, 0);
1078 _makeDisassemWindow (winInfoPtr
, srcHeight
- 1, 0);
1079 _initAndMakeWin ((Opaque
*) & locator
,
1089 _initGenWinInfo (locator
,
1095 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1097 &(*winInfoPtr
)->generic
,
1098 (*winInfoPtr
)->generic
.type
,
1100 (*winInfoPtr
)->generic
.width
,
1101 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
->width
,
1103 _initGenWinInfo ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
,
1109 (*winInfoPtr
)->canHighlight
= TRUE
;
1110 tui_make_visible (&(*winInfoPtr
)->generic
);
1111 tui_make_visible ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
);
1113 if (m_winPtrNotNull (*winInfoPtr
))
1115 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1116 tui_make_visible (locator
);
1117 tui_show_locator_content ();
1118 tui_show_source_content (*winInfoPtr
);
1120 if (m_winPtrIsNull (cmdWin
))
1122 _makeCommandWindow (&cmdWin
, cmdHeight
, srcHeight
);
1123 tui_refresh_win (&cmdWin
->generic
);
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
;
1134 tui_make_visible (&cmdWin
->generic
);
1137 tui_set_current_layout_to (layoutType
);
1141 } /* _showSourceOrDisassemAndCommand */