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"
42 #include "gdb_string.h"
43 #include "gdb_curses.h"
45 /*******************************
47 ********************************/
48 static void show_layout (enum tui_layout_type);
49 static void init_gen_win_info (struct tui_gen_win_info *, enum tui_win_type, int, int, int, int);
50 static void init_and_make_win (void **, enum tui_win_type, int, int, int, int, int);
51 static void show_source_or_disasm_and_command (enum tui_layout_type);
52 static void make_source_or_disasm_window (struct tui_win_info * *, enum tui_win_type, int, int);
53 static void make_command_window (struct tui_win_info * *, int, int);
54 static void make_source_window (struct tui_win_info * *, int, int);
55 static void make_disasm_window (struct tui_win_info * *, int, int);
56 static void make_data_window (struct tui_win_info * *, int, int);
57 static void show_source_command (void);
58 static void show_disasm_command (void);
59 static void show_source_disasm_command (void);
60 static void show_data (enum tui_layout_type);
61 static enum tui_layout_type next_layout (void);
62 static enum tui_layout_type prev_layout (void);
63 static void tui_layout_command (char *, int);
64 static void tui_toggle_layout_command (char *, int);
65 static void tui_toggle_split_layout_command (char *, int);
66 static CORE_ADDR extract_display_start_addr (void);
67 static void tui_handle_xdb_layout (struct tui_layout_def *);
70 /***************************************
72 ***************************************/
74 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
76 /* Show the screen layout defined. */
78 show_layout (enum tui_layout_type layout)
80 enum tui_layout_type cur_layout = tui_current_layout ();
82 if (layout != cur_layout)
85 ** Since the new layout may cause changes in window size, we
86 ** should free the content and reallocate on next display of
89 tui_free_all_source_wins_content ();
90 tui_clear_source_windows ();
91 if (layout == SRC_DATA_COMMAND || layout == DISASSEM_DATA_COMMAND)
94 tui_refresh_all (tui_win_list);
98 /* First make the current layout be invisible */
99 tui_make_all_invisible ();
100 tui_make_invisible (tui_locator_win_info_ptr ());
104 /* Now show the new layout */
106 show_source_command ();
107 tui_add_to_source_windows (TUI_SRC_WIN);
109 case DISASSEM_COMMAND:
110 show_disasm_command ();
111 tui_add_to_source_windows (TUI_DISASM_WIN);
113 case SRC_DISASSEM_COMMAND:
114 show_source_disasm_command ();
115 tui_add_to_source_windows (TUI_SRC_WIN);
116 tui_add_to_source_windows (TUI_DISASM_WIN);
126 /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
127 SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
128 If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
129 UNDEFINED_LAYOUT, then the data window is populated according to
130 regs_display_type. */
132 tui_set_layout (enum tui_layout_type layout_type,
133 enum tui_register_display_type regs_display_type)
135 enum tui_status status = TUI_SUCCESS;
137 if (layout_type != UNDEFINED_LAYOUT || regs_display_type != TUI_UNDEFINED_REGS)
139 enum tui_layout_type cur_layout = tui_current_layout (), new_layout = UNDEFINED_LAYOUT;
140 int regs_populate = FALSE;
141 CORE_ADDR addr = extract_display_start_addr ();
142 struct tui_win_info * new_win_with_focus = (struct tui_win_info *) NULL;
143 struct tui_win_info * win_with_focus = tui_win_with_focus ();
144 struct tui_layout_def * layout_def = tui_layout_def ();
147 if (layout_type == UNDEFINED_LAYOUT &&
148 regs_display_type != TUI_UNDEFINED_REGS)
150 if (cur_layout == SRC_DISASSEM_COMMAND)
151 new_layout = DISASSEM_DATA_COMMAND;
152 else if (cur_layout == SRC_COMMAND || cur_layout == SRC_DATA_COMMAND)
153 new_layout = SRC_DATA_COMMAND;
154 else if (cur_layout == DISASSEM_COMMAND ||
155 cur_layout == DISASSEM_DATA_COMMAND)
156 new_layout = DISASSEM_DATA_COMMAND;
159 new_layout = layout_type;
161 regs_populate = (new_layout == SRC_DATA_COMMAND ||
162 new_layout == DISASSEM_DATA_COMMAND ||
163 regs_display_type != TUI_UNDEFINED_REGS);
164 if (new_layout != cur_layout || regs_display_type != TUI_UNDEFINED_REGS)
166 if (new_layout != cur_layout)
168 show_layout (new_layout);
170 ** Now determine where focus should be
172 if (win_with_focus != TUI_CMD_WIN)
177 tui_set_win_focus_to (TUI_SRC_WIN);
178 layout_def->display_mode = SRC_WIN;
179 layout_def->split = FALSE;
181 case DISASSEM_COMMAND:
182 /* the previous layout was not showing
183 ** code. this can happen if there is no
185 ** 1. if the source file is in another dir OR
186 ** 2. if target was compiled without -g
187 ** We still want to show the assembly though!
189 addr = tui_get_begin_asm_address ();
190 tui_set_win_focus_to (TUI_DISASM_WIN);
191 layout_def->display_mode = DISASSEM_WIN;
192 layout_def->split = FALSE;
194 case SRC_DISASSEM_COMMAND:
195 /* the previous layout was not showing
196 ** code. this can happen if there is no
198 ** 1. if the source file is in another dir OR
199 ** 2. if target was compiled without -g
200 ** We still want to show the assembly though!
202 addr = tui_get_begin_asm_address ();
203 if (win_with_focus == TUI_SRC_WIN)
204 tui_set_win_focus_to (TUI_SRC_WIN);
206 tui_set_win_focus_to (TUI_DISASM_WIN);
207 layout_def->split = TRUE;
209 case SRC_DATA_COMMAND:
210 if (win_with_focus != TUI_DATA_WIN)
211 tui_set_win_focus_to (TUI_SRC_WIN);
213 tui_set_win_focus_to (TUI_DATA_WIN);
214 layout_def->display_mode = SRC_WIN;
215 layout_def->split = FALSE;
217 case DISASSEM_DATA_COMMAND:
218 /* the previous layout was not showing
219 ** code. this can happen if there is no
221 ** 1. if the source file is in another dir OR
222 ** 2. if target was compiled without -g
223 ** We still want to show the assembly though!
225 addr = tui_get_begin_asm_address ();
226 if (win_with_focus != TUI_DATA_WIN)
227 tui_set_win_focus_to (TUI_DISASM_WIN);
229 tui_set_win_focus_to (TUI_DATA_WIN);
230 layout_def->display_mode = DISASSEM_WIN;
231 layout_def->split = FALSE;
237 if (new_win_with_focus != (struct tui_win_info *) NULL)
238 tui_set_win_focus_to (new_win_with_focus);
240 ** Now update the window content
242 if (!regs_populate &&
243 (new_layout == SRC_DATA_COMMAND ||
244 new_layout == DISASSEM_DATA_COMMAND))
245 tui_display_all_data ();
247 tui_update_source_windows_with_addr (addr);
251 layout_def->regs_display_type =
252 (regs_display_type == TUI_UNDEFINED_REGS ?
253 TUI_GENERAL_REGS : regs_display_type);
254 tui_show_registers (layout_def->regs_display_type);
259 status = TUI_FAILURE;
264 /* Add the specified window to the layout in a logical way. This
265 means setting up the most logical layout given the window to be
268 tui_add_win_to_layout (enum tui_win_type type)
270 enum tui_layout_type cur_layout = tui_current_layout ();
275 if (cur_layout != SRC_COMMAND &&
276 cur_layout != SRC_DISASSEM_COMMAND &&
277 cur_layout != SRC_DATA_COMMAND)
279 tui_clear_source_windows_detail ();
280 if (cur_layout == DISASSEM_DATA_COMMAND)
281 show_layout (SRC_DATA_COMMAND);
283 show_layout (SRC_COMMAND);
287 if (cur_layout != DISASSEM_COMMAND &&
288 cur_layout != SRC_DISASSEM_COMMAND &&
289 cur_layout != DISASSEM_DATA_COMMAND)
291 tui_clear_source_windows_detail ();
292 if (cur_layout == SRC_DATA_COMMAND)
293 show_layout (DISASSEM_DATA_COMMAND);
295 show_layout (DISASSEM_COMMAND);
299 if (cur_layout != SRC_DATA_COMMAND &&
300 cur_layout != DISASSEM_DATA_COMMAND)
302 if (cur_layout == DISASSEM_COMMAND)
303 show_layout (DISASSEM_DATA_COMMAND);
305 show_layout (SRC_DATA_COMMAND);
314 /* Answer the height of a window. If it hasn't been created yet,
315 answer what the height of a window would be based upon its type and
318 tui_default_win_height (enum tui_win_type type, enum tui_layout_type layout)
322 if (tui_win_list[type] != (struct tui_win_info *) NULL)
323 h = tui_win_list[type]->generic.height;
329 case DISASSEM_COMMAND:
330 if (TUI_CMD_WIN == NULL)
331 h = tui_term_height () / 2;
333 h = tui_term_height () - TUI_CMD_WIN->generic.height;
335 case SRC_DISASSEM_COMMAND:
336 case SRC_DATA_COMMAND:
337 case DISASSEM_DATA_COMMAND:
338 if (TUI_CMD_WIN == NULL)
339 h = tui_term_height () / 3;
341 h = (tui_term_height () - TUI_CMD_WIN->generic.height) / 2;
353 /* Answer the height of a window. If it hasn't been created yet,
354 answer what the height of a window would be based upon its type and
357 tui_default_win_viewport_height (enum tui_win_type type,
358 enum tui_layout_type layout)
362 h = tui_default_win_height (type, layout);
364 if (tui_win_list[type] == TUI_CMD_WIN)
373 /* Function to initialize gdb commands, for tui window layout
376 _initialize_tui_layout (void)
378 add_com ("layout", class_tui, tui_layout_command,
379 "Change the layout of windows.\n\
380 Usage: layout prev | next | <layout_name> \n\
382 src : Displays source and command windows.\n\
383 asm : Displays disassembly and command windows.\n\
384 split : Displays source, disassembly and command windows.\n\
385 regs : Displays register window. If existing layout\n\
386 is source/command or assembly/command, the \n\
387 register window is displayed. If the\n\
388 source/assembly/command (split) is displayed, \n\
389 the register window is displayed with \n\
390 the window that has current logical focus.\n");
393 add_com ("td", class_tui, tui_toggle_layout_command,
394 "Toggle between Source/Command and Disassembly/Command layouts.\n");
395 add_com ("ts", class_tui, tui_toggle_split_layout_command,
396 "Toggle between Source/Command or Disassembly/Command and \n\
397 Source/Disassembly/Command layouts.\n");
402 /*************************
403 ** STATIC LOCAL FUNCTIONS
404 **************************/
407 /* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
408 REGS, $REGS, $GREGS, $FREGS, $SREGS. */
410 tui_set_layout_for_display_command (const char *layout_name)
412 enum tui_status status = TUI_SUCCESS;
414 if (layout_name != (char *) NULL)
418 enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
419 enum tui_register_display_type dpy_type = TUI_UNDEFINED_REGS;
420 enum tui_layout_type cur_layout = tui_current_layout ();
422 buf_ptr = (char *) xstrdup (layout_name);
423 for (i = 0; (i < strlen (layout_name)); i++)
424 buf_ptr[i] = toupper (buf_ptr[i]);
426 /* First check for ambiguous input */
427 if (strlen (buf_ptr) <= 1 && (*buf_ptr == 'S' || *buf_ptr == '$'))
429 warning ("Ambiguous command input.\n");
430 status = TUI_FAILURE;
434 if (subset_compare (buf_ptr, "SRC"))
435 new_layout = SRC_COMMAND;
436 else if (subset_compare (buf_ptr, "ASM"))
437 new_layout = DISASSEM_COMMAND;
438 else if (subset_compare (buf_ptr, "SPLIT"))
439 new_layout = SRC_DISASSEM_COMMAND;
440 else if (subset_compare (buf_ptr, "REGS") ||
441 subset_compare (buf_ptr, TUI_GENERAL_SPECIAL_REGS_NAME) ||
442 subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME) ||
443 subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME) ||
444 subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
446 if (cur_layout == SRC_COMMAND || cur_layout == SRC_DATA_COMMAND)
447 new_layout = SRC_DATA_COMMAND;
449 new_layout = DISASSEM_DATA_COMMAND;
451 /* could ifdef out the following code. when compile with -z, there are null
452 pointer references that cause a core dump if 'layout regs' is the first
453 layout command issued by the user. HP has asked us to hook up this code
456 if (subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME))
458 if (TUI_DATA_WIN->detail.data_display_info.regs_display_type !=
460 TUI_DATA_WIN->detail.data_display_info.regs_display_type !=
462 dpy_type = TUI_SFLOAT_REGS;
465 TUI_DATA_WIN->detail.data_display_info.regs_display_type;
467 else if (subset_compare (buf_ptr,
468 TUI_GENERAL_SPECIAL_REGS_NAME))
469 dpy_type = TUI_GENERAL_AND_SPECIAL_REGS;
470 else if (subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME))
471 dpy_type = TUI_GENERAL_REGS;
472 else if (subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
473 dpy_type = TUI_SPECIAL_REGS;
474 else if (TUI_DATA_WIN)
476 if (TUI_DATA_WIN->detail.data_display_info.regs_display_type !=
479 TUI_DATA_WIN->detail.data_display_info.regs_display_type;
481 dpy_type = TUI_GENERAL_REGS;
484 /* end of potential ifdef
487 /* if ifdefed out code above, then assume that the user wishes to display the
488 general purpose registers
491 /* dpy_type = TUI_GENERAL_REGS;
494 else if (subset_compare (buf_ptr, "NEXT"))
495 new_layout = next_layout ();
496 else if (subset_compare (buf_ptr, "PREV"))
497 new_layout = prev_layout ();
499 status = TUI_FAILURE;
502 tui_set_layout (new_layout, dpy_type);
506 status = TUI_FAILURE;
513 extract_display_start_addr (void)
515 enum tui_layout_type cur_layout = tui_current_layout ();
518 struct symtab_and_line cursal = get_current_source_symtab_and_line ();
523 case SRC_DATA_COMMAND:
524 find_line_pc (cursal.symtab,
525 TUI_SRC_WIN->detail.source_info.start_line_or_addr.line_no,
529 case DISASSEM_COMMAND:
530 case SRC_DISASSEM_COMMAND:
531 case DISASSEM_DATA_COMMAND:
532 addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.addr;
544 tui_handle_xdb_layout (struct tui_layout_def * layout_def)
546 if (layout_def->split)
548 tui_set_layout (SRC_DISASSEM_COMMAND, TUI_UNDEFINED_REGS);
549 tui_set_win_focus_to (tui_win_list[layout_def->display_mode]);
553 if (layout_def->display_mode == SRC_WIN)
554 tui_set_layout (SRC_COMMAND, TUI_UNDEFINED_REGS);
556 tui_set_layout (DISASSEM_DATA_COMMAND, layout_def->regs_display_type);
562 tui_toggle_layout_command (char *arg, int from_tty)
564 struct tui_layout_def * layout_def = tui_layout_def ();
566 /* Make sure the curses mode is enabled. */
568 if (layout_def->display_mode == SRC_WIN)
569 layout_def->display_mode = DISASSEM_WIN;
571 layout_def->display_mode = SRC_WIN;
573 if (!layout_def->split)
574 tui_handle_xdb_layout (layout_def);
579 tui_toggle_split_layout_command (char *arg, int from_tty)
581 struct tui_layout_def * layout_def = tui_layout_def ();
583 /* Make sure the curses mode is enabled. */
585 layout_def->split = (!layout_def->split);
586 tui_handle_xdb_layout (layout_def);
591 tui_layout_command (char *arg, int from_tty)
593 /* Make sure the curses mode is enabled. */
596 /* Switch to the selected layout. */
597 if (tui_set_layout_for_display_command (arg) != TUI_SUCCESS)
598 warning ("Invalid layout specified.\n%s", LAYOUT_USAGE);
602 /* Answer the previous layout to cycle to. */
603 static enum tui_layout_type
606 enum tui_layout_type new_layout;
608 new_layout = tui_current_layout ();
609 if (new_layout == UNDEFINED_LAYOUT)
610 new_layout = SRC_COMMAND;
614 if (new_layout == UNDEFINED_LAYOUT)
615 new_layout = SRC_COMMAND;
622 /* Answer the next layout to cycle to. */
623 static enum tui_layout_type
626 enum tui_layout_type new_layout;
628 new_layout = tui_current_layout ();
629 if (new_layout == SRC_COMMAND)
630 new_layout = DISASSEM_DATA_COMMAND;
634 if (new_layout == UNDEFINED_LAYOUT)
635 new_layout = DISASSEM_DATA_COMMAND;
644 make_command_window (struct tui_win_info * * win_info_ptr, int height, int origin_y)
646 init_and_make_win ((void **) win_info_ptr,
654 (*win_info_ptr)->can_highlight = FALSE;
659 ** make_source_window().
662 make_source_window (struct tui_win_info * * win_info_ptr, int height, int origin_y)
664 make_source_or_disasm_window (win_info_ptr, SRC_WIN, height, origin_y);
667 } /* make_source_window */
671 ** make_disasm_window().
674 make_disasm_window (struct tui_win_info * * win_info_ptr, int height, int origin_y)
676 make_source_or_disasm_window (win_info_ptr, DISASSEM_WIN, height, origin_y);
679 } /* make_disasm_window */
683 make_data_window (struct tui_win_info * * win_info_ptr, int height, int origin_y)
685 init_and_make_win ((void **) win_info_ptr,
696 /* Show the Source/Command layout. */
698 show_source_command (void)
700 show_source_or_disasm_and_command (SRC_COMMAND);
704 /* Show the Dissassem/Command layout. */
706 show_disasm_command (void)
708 show_source_or_disasm_and_command (DISASSEM_COMMAND);
712 /* Show the Source/Disassem/Command layout. */
714 show_source_disasm_command (void)
716 if (tui_current_layout () != SRC_DISASSEM_COMMAND)
718 int cmd_height, src_height, asm_height;
720 if (TUI_CMD_WIN != NULL)
721 cmd_height = TUI_CMD_WIN->generic.height;
723 cmd_height = tui_term_height () / 3;
725 src_height = (tui_term_height () - cmd_height) / 2;
726 asm_height = tui_term_height () - (src_height + cmd_height);
728 if (TUI_SRC_WIN == NULL)
729 make_source_window (&TUI_SRC_WIN, src_height, 0);
732 init_gen_win_info (&TUI_SRC_WIN->generic,
733 TUI_SRC_WIN->generic.type,
735 TUI_SRC_WIN->generic.width,
736 TUI_SRC_WIN->detail.source_info.execution_info->width,
738 TUI_SRC_WIN->can_highlight = TRUE;
739 init_gen_win_info (TUI_SRC_WIN->detail.source_info.execution_info,
745 tui_make_visible (&TUI_SRC_WIN->generic);
746 tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info);
747 TUI_SRC_WIN->detail.source_info.has_locator = FALSE;;
749 if (TUI_SRC_WIN != NULL)
751 struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
753 tui_show_source_content (TUI_SRC_WIN);
754 if (TUI_DISASM_WIN == NULL)
756 make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1);
757 init_and_make_win ((void **) & locator,
762 (src_height + asm_height) - 1,
767 init_gen_win_info (locator,
772 (src_height + asm_height) - 1);
773 TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
775 &TUI_DISASM_WIN->generic,
776 TUI_DISASM_WIN->generic.type,
778 TUI_DISASM_WIN->generic.width,
779 TUI_DISASM_WIN->detail.source_info.execution_info->width,
781 init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info,
787 TUI_DISASM_WIN->can_highlight = TRUE;
788 tui_make_visible (&TUI_DISASM_WIN->generic);
789 tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
791 if (TUI_DISASM_WIN != NULL)
793 TUI_SRC_WIN->detail.source_info.has_locator = FALSE;
794 TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
795 tui_make_visible (locator);
796 tui_show_locator_content ();
797 tui_show_source_content (TUI_DISASM_WIN);
799 if (TUI_CMD_WIN == NULL)
800 make_command_window (&TUI_CMD_WIN,
802 tui_term_height () - cmd_height);
805 init_gen_win_info (&TUI_CMD_WIN->generic,
806 TUI_CMD_WIN->generic.type,
807 TUI_CMD_WIN->generic.height,
808 TUI_CMD_WIN->generic.width,
810 TUI_CMD_WIN->generic.origin.y);
811 TUI_CMD_WIN->can_highlight = FALSE;
812 tui_make_visible (&TUI_CMD_WIN->generic);
814 if (TUI_CMD_WIN != NULL)
815 tui_refresh_win (&TUI_CMD_WIN->generic);
818 tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
823 /* Show the Source/Data/Command or the Dissassembly/Data/Command
826 show_data (enum tui_layout_type new_layout)
828 int total_height = (tui_term_height () - TUI_CMD_WIN->generic.height);
829 int src_height, data_height;
830 enum tui_win_type win_type;
831 struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
834 data_height = total_height / 2;
835 src_height = total_height - data_height;
836 tui_make_all_invisible ();
837 tui_make_invisible (locator);
838 make_data_window (&TUI_DATA_WIN, data_height, 0);
839 TUI_DATA_WIN->can_highlight = TRUE;
840 if (new_layout == SRC_DATA_COMMAND)
843 win_type = DISASSEM_WIN;
844 if (tui_win_list[win_type] == NULL)
846 if (win_type == SRC_WIN)
847 make_source_window (&tui_win_list[win_type], src_height, data_height - 1);
849 make_disasm_window (&tui_win_list[win_type], src_height, data_height - 1);
850 init_and_make_win ((void **) & locator,
860 init_gen_win_info (&tui_win_list[win_type]->generic,
861 tui_win_list[win_type]->generic.type,
863 tui_win_list[win_type]->generic.width,
864 tui_win_list[win_type]->detail.source_info.execution_info->width,
866 init_gen_win_info (tui_win_list[win_type]->detail.source_info.execution_info,
872 tui_make_visible (&tui_win_list[win_type]->generic);
873 tui_make_visible (tui_win_list[win_type]->detail.source_info.execution_info);
874 init_gen_win_info (locator,
881 tui_win_list[win_type]->detail.source_info.has_locator = TRUE;
882 tui_make_visible (locator);
883 tui_show_locator_content ();
884 tui_add_to_source_windows (tui_win_list[win_type]);
885 tui_set_current_layout_to (new_layout);
889 ** init_gen_win_info().
892 init_gen_win_info (struct tui_gen_win_info * win_info, enum tui_win_type type,
893 int height, int width, int origin_x, int origin_y)
897 win_info->type = type;
898 win_info->width = width;
899 win_info->height = h;
902 win_info->viewport_height = h - 1;
903 if (win_info->type != CMD_WIN)
904 win_info->viewport_height--;
907 win_info->viewport_height = 1;
908 win_info->origin.x = origin_x;
909 win_info->origin.y = origin_y;
912 } /* init_gen_win_info */
915 ** init_and_make_win().
918 init_and_make_win (void ** win_info_ptr, enum tui_win_type win_type,
919 int height, int width, int origin_x, int origin_y, int box_it)
921 void *opaque_win_info = *win_info_ptr;
922 struct tui_gen_win_info * generic;
924 if (opaque_win_info == NULL)
926 if (tui_win_is_auxillary (win_type))
927 opaque_win_info = (void *) tui_alloc_generic_win_info ();
929 opaque_win_info = (void *) tui_alloc_win_info (win_type);
931 if (tui_win_is_auxillary (win_type))
932 generic = (struct tui_gen_win_info *) opaque_win_info;
934 generic = &((struct tui_win_info *) opaque_win_info)->generic;
936 if (opaque_win_info != NULL)
938 init_gen_win_info (generic, win_type, height, width, origin_x, origin_y);
939 if (!tui_win_is_auxillary (win_type))
941 if (generic->type == CMD_WIN)
942 ((struct tui_win_info *) opaque_win_info)->can_highlight = FALSE;
944 ((struct tui_win_info *) opaque_win_info)->can_highlight = TRUE;
946 tui_make_window (generic, box_it);
948 *win_info_ptr = opaque_win_info;
953 make_source_or_disasm_window (struct tui_win_info * * win_info_ptr, enum tui_win_type type,
954 int height, int origin_y)
956 struct tui_gen_win_info * execution_info = (struct tui_gen_win_info *) NULL;
959 ** Create the exeuction info window.
962 execution_info = tui_source_exec_info_win_ptr ();
964 execution_info = tui_disassem_exec_info_win_ptr ();
965 init_and_make_win ((void **) & execution_info,
973 ** Now create the source window.
975 init_and_make_win ((void **) win_info_ptr,
978 tui_term_width () - execution_info->width,
979 execution_info->width,
983 (*win_info_ptr)->detail.source_info.execution_info = execution_info;
987 /* Show the Source/Command or the Disassem layout. */
989 show_source_or_disasm_and_command (enum tui_layout_type layout_type)
991 if (tui_current_layout () != layout_type)
993 struct tui_win_info * *win_info_ptr;
994 int src_height, cmd_height;
995 struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
997 if (TUI_CMD_WIN != NULL)
998 cmd_height = TUI_CMD_WIN->generic.height;
1000 cmd_height = tui_term_height () / 3;
1001 src_height = tui_term_height () - cmd_height;
1004 if (layout_type == SRC_COMMAND)
1005 win_info_ptr = &TUI_SRC_WIN;
1007 win_info_ptr = &TUI_DISASM_WIN;
1009 if ((*win_info_ptr) == NULL)
1011 if (layout_type == SRC_COMMAND)
1012 make_source_window (win_info_ptr, src_height - 1, 0);
1014 make_disasm_window (win_info_ptr, src_height - 1, 0);
1015 init_and_make_win ((void **) & locator,
1025 init_gen_win_info (locator,
1031 (*win_info_ptr)->detail.source_info.has_locator = TRUE;
1033 &(*win_info_ptr)->generic,
1034 (*win_info_ptr)->generic.type,
1036 (*win_info_ptr)->generic.width,
1037 (*win_info_ptr)->detail.source_info.execution_info->width,
1039 init_gen_win_info ((*win_info_ptr)->detail.source_info.execution_info,
1045 (*win_info_ptr)->can_highlight = TRUE;
1046 tui_make_visible (&(*win_info_ptr)->generic);
1047 tui_make_visible ((*win_info_ptr)->detail.source_info.execution_info);
1049 if ((*win_info_ptr) != NULL)
1051 (*win_info_ptr)->detail.source_info.has_locator = TRUE;
1052 tui_make_visible (locator);
1053 tui_show_locator_content ();
1054 tui_show_source_content (*win_info_ptr);
1056 if (TUI_CMD_WIN == NULL)
1058 make_command_window (&TUI_CMD_WIN, cmd_height, src_height);
1059 tui_refresh_win (&TUI_CMD_WIN->generic);
1063 init_gen_win_info (&TUI_CMD_WIN->generic,
1064 TUI_CMD_WIN->generic.type,
1065 TUI_CMD_WIN->generic.height,
1066 TUI_CMD_WIN->generic.width,
1067 TUI_CMD_WIN->generic.origin.x,
1068 TUI_CMD_WIN->generic.origin.y);
1069 TUI_CMD_WIN->can_highlight = FALSE;
1070 tui_make_visible (&TUI_CMD_WIN->generic);
1073 tui_set_current_layout_to (layout_type);