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 *, enum tui_win_type, int, int, int, int);
55 static void _initAndMakeWin (void **, enum tui_win_type, int, int, int, int, int);
56 static void _showSourceOrDisassemAndCommand (enum tui_layout_type);
57 static void _makeSourceOrDisassemWindow (struct tui_win_info * *, enum tui_win_type, 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 (tui_win_list);
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 (TUI_SRC_WIN);
114 case DISASSEM_COMMAND:
115 _showDisassemCommand ();
116 tui_add_to_source_windows (TUI_DISASM_WIN);
118 case SRC_DISASSEM_COMMAND:
119 _showSourceDisassemCommand ();
120 tui_add_to_source_windows (TUI_SRC_WIN);
121 tui_add_to_source_windows (TUI_DISASM_WIN);
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 regs_display_type. */
137 tui_set_layout (enum tui_layout_type layoutType,
138 enum tui_register_display_type regs_display_type)
140 enum tui_status status = TUI_SUCCESS;
142 if (layoutType != UNDEFINED_LAYOUT || regs_display_type != 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 regs_display_type != 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 regs_display_type != TUI_UNDEFINED_REGS);
169 if (newLayout != curLayout || regs_display_type != TUI_UNDEFINED_REGS)
171 if (newLayout != curLayout)
173 showLayout (newLayout);
175 ** Now determine where focus should be
177 if (winWithFocus != TUI_CMD_WIN)
182 tui_set_win_focus_to (TUI_SRC_WIN);
183 layoutDef->display_mode = 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 (TUI_DISASM_WIN);
196 layoutDef->display_mode = 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 == TUI_SRC_WIN)
209 tui_set_win_focus_to (TUI_SRC_WIN);
211 tui_set_win_focus_to (TUI_DISASM_WIN);
212 layoutDef->split = TRUE;
214 case SRC_DATA_COMMAND:
215 if (winWithFocus != TUI_DATA_WIN)
216 tui_set_win_focus_to (TUI_SRC_WIN);
218 tui_set_win_focus_to (TUI_DATA_WIN);
219 layoutDef->display_mode = 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 != TUI_DATA_WIN)
232 tui_set_win_focus_to (TUI_DISASM_WIN);
234 tui_set_win_focus_to (TUI_DATA_WIN);
235 layoutDef->display_mode = 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->regs_display_type =
257 (regs_display_type == TUI_UNDEFINED_REGS ?
258 TUI_GENERAL_REGS : regs_display_type);
259 tui_show_registers (layoutDef->regs_display_type);
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 (enum tui_win_type type, enum tui_layout_type layout)
332 if (tui_win_list[type] != (struct tui_win_info *) NULL)
333 h = tui_win_list[type]->generic.height;
339 case DISASSEM_COMMAND:
340 if (TUI_CMD_WIN == NULL)
341 h = tui_term_height () / 2;
343 h = tui_term_height () - TUI_CMD_WIN->generic.height;
345 case SRC_DISASSEM_COMMAND:
346 case SRC_DATA_COMMAND:
347 case DISASSEM_DATA_COMMAND:
348 if (TUI_CMD_WIN == NULL)
349 h = tui_term_height () / 3;
351 h = (tui_term_height () - TUI_CMD_WIN->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 (tui_win_list[type] == TUI_CMD_WIN)
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 enum tui_status 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 (TUI_DATA_WIN->detail.data_display_info.regs_display_type !=
476 TUI_DATA_WIN->detail.data_display_info.regs_display_type !=
478 dpyType = TUI_SFLOAT_REGS;
481 TUI_DATA_WIN->detail.data_display_info.regs_display_type;
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;
490 else if (TUI_DATA_WIN)
492 if (TUI_DATA_WIN->detail.data_display_info.regs_display_type !=
495 TUI_DATA_WIN->detail.data_display_info.regs_display_type;
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 TUI_SRC_WIN->detail.source_info.start_line_or_addr.line_no,
545 case DISASSEM_COMMAND:
546 case SRC_DISASSEM_COMMAND:
547 case DISASSEM_DATA_COMMAND:
548 addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.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 (tui_win_list[layoutDef->display_mode]);
569 if (layoutDef->display_mode == SRC_WIN)
570 tui_set_layout (SRC_COMMAND, TUI_UNDEFINED_REGS);
572 tui_set_layout (DISASSEM_DATA_COMMAND, layoutDef->regs_display_type);
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->display_mode == SRC_WIN)
588 layoutDef->display_mode = DISASSEM_WIN;
590 layoutDef->display_mode = 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 ((void **) winInfoPtr,
684 (*winInfoPtr)->can_highlight = 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 ((void **) 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 (TUI_CMD_WIN != NULL)
771 cmdHeight = TUI_CMD_WIN->generic.height;
773 cmdHeight = tui_term_height () / 3;
775 srcHeight = (tui_term_height () - cmdHeight) / 2;
776 asmHeight = tui_term_height () - (srcHeight + cmdHeight);
778 if (TUI_SRC_WIN == NULL)
779 _makeSourceWindow (&TUI_SRC_WIN, srcHeight, 0);
782 _initGenWinInfo (&TUI_SRC_WIN->generic,
783 TUI_SRC_WIN->generic.type,
785 TUI_SRC_WIN->generic.width,
786 TUI_SRC_WIN->detail.source_info.execution_info->width,
788 TUI_SRC_WIN->can_highlight = TRUE;
789 _initGenWinInfo (TUI_SRC_WIN->detail.source_info.execution_info,
795 tui_make_visible (&TUI_SRC_WIN->generic);
796 tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info);
797 TUI_SRC_WIN->detail.source_info.has_locator = FALSE;;
799 if (TUI_SRC_WIN != NULL)
801 struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
803 tui_show_source_content (TUI_SRC_WIN);
804 if (TUI_DISASM_WIN == NULL)
806 _makeDisassemWindow (&TUI_DISASM_WIN, asmHeight, srcHeight - 1);
807 _initAndMakeWin ((void **) & locator,
812 (srcHeight + asmHeight) - 1,
817 _initGenWinInfo (locator,
822 (srcHeight + asmHeight) - 1);
823 TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
825 &TUI_DISASM_WIN->generic,
826 TUI_DISASM_WIN->generic.type,
828 TUI_DISASM_WIN->generic.width,
829 TUI_DISASM_WIN->detail.source_info.execution_info->width,
831 _initGenWinInfo (TUI_DISASM_WIN->detail.source_info.execution_info,
837 TUI_DISASM_WIN->can_highlight = TRUE;
838 tui_make_visible (&TUI_DISASM_WIN->generic);
839 tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
841 if (TUI_DISASM_WIN != NULL)
843 TUI_SRC_WIN->detail.source_info.has_locator = FALSE;
844 TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
845 tui_make_visible (locator);
846 tui_show_locator_content ();
847 tui_show_source_content (TUI_DISASM_WIN);
849 if (TUI_CMD_WIN == NULL)
850 _makeCommandWindow (&TUI_CMD_WIN,
852 tui_term_height () - cmdHeight);
855 _initGenWinInfo (&TUI_CMD_WIN->generic,
856 TUI_CMD_WIN->generic.type,
857 TUI_CMD_WIN->generic.height,
858 TUI_CMD_WIN->generic.width,
860 TUI_CMD_WIN->generic.origin.y);
861 TUI_CMD_WIN->can_highlight = FALSE;
862 tui_make_visible (&TUI_CMD_WIN->generic);
864 if (TUI_CMD_WIN != NULL)
865 tui_refresh_win (&TUI_CMD_WIN->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 () - TUI_CMD_WIN->generic.height);
883 int srcHeight, dataHeight;
884 enum tui_win_type winType;
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 (&TUI_DATA_WIN, dataHeight, 0);
893 TUI_DATA_WIN->can_highlight = TRUE;
894 if (newLayout == SRC_DATA_COMMAND)
897 winType = DISASSEM_WIN;
898 if (tui_win_list[winType] == NULL)
900 if (winType == SRC_WIN)
901 _makeSourceWindow (&tui_win_list[winType], srcHeight, dataHeight - 1);
903 _makeDisassemWindow (&tui_win_list[winType], srcHeight, dataHeight - 1);
904 _initAndMakeWin ((void **) & locator,
914 _initGenWinInfo (&tui_win_list[winType]->generic,
915 tui_win_list[winType]->generic.type,
917 tui_win_list[winType]->generic.width,
918 tui_win_list[winType]->detail.source_info.execution_info->width,
920 _initGenWinInfo (tui_win_list[winType]->detail.source_info.execution_info,
926 tui_make_visible (&tui_win_list[winType]->generic);
927 tui_make_visible (tui_win_list[winType]->detail.source_info.execution_info);
928 _initGenWinInfo (locator,
935 tui_win_list[winType]->detail.source_info.has_locator = TRUE;
936 tui_make_visible (locator);
937 tui_show_locator_content ();
938 tui_add_to_source_windows (tui_win_list[winType]);
939 tui_set_current_layout_to (newLayout);
945 ** _initGenWinInfo().
948 _initGenWinInfo (struct tui_gen_win_info * winInfo, enum tui_win_type type,
949 int height, int width, int originX, int originY)
953 winInfo->type = type;
954 winInfo->width = width;
958 winInfo->viewport_height = h - 1;
959 if (winInfo->type != CMD_WIN)
960 winInfo->viewport_height--;
963 winInfo->viewport_height = 1;
964 winInfo->origin.x = originX;
965 winInfo->origin.y = originY;
968 } /* _initGenWinInfo */
971 ** _initAndMakeWin().
974 _initAndMakeWin (void ** winInfoPtr, enum tui_win_type winType,
975 int height, int width, int originX, int originY, int boxIt)
977 void *opaqueWinInfo = *winInfoPtr;
978 struct tui_gen_win_info * generic;
980 if (opaqueWinInfo == NULL)
982 if (tui_win_is_auxillary (winType))
983 opaqueWinInfo = (void *) tui_alloc_generic_win_info ();
985 opaqueWinInfo = (void *) tui_alloc_win_info (winType);
987 if (tui_win_is_auxillary (winType))
988 generic = (struct tui_gen_win_info *) opaqueWinInfo;
990 generic = &((struct tui_win_info *) opaqueWinInfo)->generic;
992 if (opaqueWinInfo != NULL)
994 _initGenWinInfo (generic, winType, height, width, originX, originY);
995 if (!tui_win_is_auxillary (winType))
997 if (generic->type == CMD_WIN)
998 ((struct tui_win_info *) opaqueWinInfo)->can_highlight = FALSE;
1000 ((struct tui_win_info *) opaqueWinInfo)->can_highlight = TRUE;
1002 tui_make_window (generic, boxIt);
1004 *winInfoPtr = opaqueWinInfo;
1009 ** _makeSourceOrDisassemWindow().
1012 _makeSourceOrDisassemWindow (struct tui_win_info * * winInfoPtr, enum tui_win_type type,
1013 int height, int originY)
1015 struct tui_gen_win_info * execution_info = (struct tui_gen_win_info *) NULL;
1018 ** Create the exeuction info window.
1020 if (type == SRC_WIN)
1021 execution_info = tui_source_exec_info_win_ptr ();
1023 execution_info = tui_disassem_exec_info_win_ptr ();
1024 _initAndMakeWin ((void **) & execution_info,
1032 ** Now create the source window.
1034 _initAndMakeWin ((void **) winInfoPtr,
1037 tui_term_width () - execution_info->width,
1038 execution_info->width,
1042 (*winInfoPtr)->detail.source_info.execution_info = execution_info;
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 (TUI_CMD_WIN != NULL)
1062 cmdHeight = TUI_CMD_WIN->generic.height;
1064 cmdHeight = tui_term_height () / 3;
1065 srcHeight = tui_term_height () - cmdHeight;
1068 if (layoutType == SRC_COMMAND)
1069 winInfoPtr = &TUI_SRC_WIN;
1071 winInfoPtr = &TUI_DISASM_WIN;
1073 if ((*winInfoPtr) == NULL)
1075 if (layoutType == SRC_COMMAND)
1076 _makeSourceWindow (winInfoPtr, srcHeight - 1, 0);
1078 _makeDisassemWindow (winInfoPtr, srcHeight - 1, 0);
1079 _initAndMakeWin ((void **) & locator,
1089 _initGenWinInfo (locator,
1095 (*winInfoPtr)->detail.source_info.has_locator = TRUE;
1097 &(*winInfoPtr)->generic,
1098 (*winInfoPtr)->generic.type,
1100 (*winInfoPtr)->generic.width,
1101 (*winInfoPtr)->detail.source_info.execution_info->width,
1103 _initGenWinInfo ((*winInfoPtr)->detail.source_info.execution_info,
1109 (*winInfoPtr)->can_highlight = TRUE;
1110 tui_make_visible (&(*winInfoPtr)->generic);
1111 tui_make_visible ((*winInfoPtr)->detail.source_info.execution_info);
1113 if ((*winInfoPtr) != NULL)
1115 (*winInfoPtr)->detail.source_info.has_locator = TRUE;
1116 tui_make_visible (locator);
1117 tui_show_locator_content ();
1118 tui_show_source_content (*winInfoPtr);
1120 if (TUI_CMD_WIN == NULL)
1122 _makeCommandWindow (&TUI_CMD_WIN, cmdHeight, srcHeight);
1123 tui_refresh_win (&TUI_CMD_WIN->generic);
1127 _initGenWinInfo (&TUI_CMD_WIN->generic,
1128 TUI_CMD_WIN->generic.type,
1129 TUI_CMD_WIN->generic.height,
1130 TUI_CMD_WIN->generic.width,
1131 TUI_CMD_WIN->generic.origin.x,
1132 TUI_CMD_WIN->generic.origin.y);
1133 TUI_CMD_WIN->can_highlight = FALSE;
1134 tui_make_visible (&TUI_CMD_WIN->generic);
1137 tui_set_current_layout_to (layoutType);
1141 } /* _showSourceOrDisassemAndCommand */