1 /* TUI layout window management.
3 Copyright (C) 1998-2013 Free Software Foundation, Inc.
5 Contributed by Hewlett-Packard Company.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "arch-utils.h"
31 #include "tui/tui-data.h"
32 #include "tui/tui-windata.h"
33 #include "tui/tui-wingeneral.h"
34 #include "tui/tui-stack.h"
35 #include "tui/tui-regs.h"
36 #include "tui/tui-win.h"
37 #include "tui/tui-winsource.h"
38 #include "tui/tui-disasm.h"
39 #include "tui/tui-layout.h"
41 #include "gdb_string.h"
42 #include "gdb_curses.h"
44 /*******************************
46 ********************************/
47 static void show_layout (enum tui_layout_type);
48 static void init_gen_win_info (struct tui_gen_win_info *,
51 static void *init_and_make_win (void *, enum tui_win_type,
52 int, int, int, int, int);
53 static void show_source_or_disasm_and_command (enum tui_layout_type);
54 static void make_source_or_disasm_window (struct tui_win_info **,
57 static void make_command_window (struct tui_win_info **, int, int);
58 static void make_source_window (struct tui_win_info **, int, int);
59 static void make_disasm_window (struct tui_win_info **, int, int);
60 static void make_data_window (struct tui_win_info **, int, int);
61 static void show_source_command (void);
62 static void show_disasm_command (void);
63 static void show_source_disasm_command (void);
64 static void show_data (enum tui_layout_type);
65 static enum tui_layout_type next_layout (void);
66 static enum tui_layout_type prev_layout (void);
67 static void tui_layout_command (char *, int);
68 static void tui_toggle_layout_command (char *, int);
69 static void tui_toggle_split_layout_command (char *, int);
70 static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *);
71 static void tui_handle_xdb_layout (struct tui_layout_def *);
74 /***************************************
76 ***************************************/
78 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
80 /* Show the screen layout defined. */
82 show_layout (enum tui_layout_type layout)
84 enum tui_layout_type cur_layout = tui_current_layout ();
86 if (layout != cur_layout)
88 /* Since the new layout may cause changes in window size, we
89 should free the content and reallocate on next display of
91 tui_free_all_source_wins_content ();
92 tui_clear_source_windows ();
93 if (layout == SRC_DATA_COMMAND
94 || layout == DISASSEM_DATA_COMMAND)
97 tui_refresh_all (tui_win_list);
101 /* First make the current layout be invisible. */
102 tui_make_all_invisible ();
103 tui_make_invisible (tui_locator_win_info_ptr ());
107 /* Now show the new layout. */
109 show_source_command ();
110 tui_add_to_source_windows (TUI_SRC_WIN);
112 case DISASSEM_COMMAND:
113 show_disasm_command ();
114 tui_add_to_source_windows (TUI_DISASM_WIN);
116 case SRC_DISASSEM_COMMAND:
117 show_source_disasm_command ();
118 tui_add_to_source_windows (TUI_SRC_WIN);
119 tui_add_to_source_windows (TUI_DISASM_WIN);
129 /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
130 SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
131 If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
132 UNDEFINED_LAYOUT, then the data window is populated according to
133 regs_display_type. */
135 tui_set_layout (enum tui_layout_type layout_type,
136 enum tui_register_display_type regs_display_type)
138 enum tui_status status = TUI_SUCCESS;
140 if (layout_type != UNDEFINED_LAYOUT
141 || regs_display_type != TUI_UNDEFINED_REGS)
143 enum tui_layout_type cur_layout = tui_current_layout (),
144 new_layout = UNDEFINED_LAYOUT;
145 int regs_populate = FALSE;
146 struct gdbarch *gdbarch;
148 struct tui_win_info *win_with_focus = tui_win_with_focus ();
149 struct tui_layout_def *layout_def = tui_layout_def ();
151 extract_display_start_addr (&gdbarch, &addr);
153 if (layout_type == UNDEFINED_LAYOUT
154 && regs_display_type != TUI_UNDEFINED_REGS)
156 if (cur_layout == SRC_DISASSEM_COMMAND)
157 new_layout = DISASSEM_DATA_COMMAND;
158 else if (cur_layout == SRC_COMMAND
159 || cur_layout == SRC_DATA_COMMAND)
160 new_layout = SRC_DATA_COMMAND;
161 else if (cur_layout == DISASSEM_COMMAND
162 || cur_layout == DISASSEM_DATA_COMMAND)
163 new_layout = DISASSEM_DATA_COMMAND;
166 new_layout = layout_type;
168 regs_populate = (new_layout == SRC_DATA_COMMAND
169 || new_layout == DISASSEM_DATA_COMMAND
170 || regs_display_type != TUI_UNDEFINED_REGS);
171 if (new_layout != cur_layout
172 || regs_display_type != TUI_UNDEFINED_REGS)
174 if (new_layout != cur_layout)
176 show_layout (new_layout);
178 /* Now determine where focus should be. */
179 if (win_with_focus != TUI_CMD_WIN)
184 tui_set_win_focus_to (TUI_SRC_WIN);
185 layout_def->display_mode = SRC_WIN;
186 layout_def->split = FALSE;
188 case DISASSEM_COMMAND:
189 /* The previous layout was not showing code.
190 This can happen if there is no source
193 1. if the source file is in another dir OR
194 2. if target was compiled without -g
195 We still want to show the assembly though! */
197 tui_get_begin_asm_address (&gdbarch, &addr);
198 tui_set_win_focus_to (TUI_DISASM_WIN);
199 layout_def->display_mode = DISASSEM_WIN;
200 layout_def->split = FALSE;
202 case SRC_DISASSEM_COMMAND:
203 /* The previous layout was not showing code.
204 This can happen if there is no source
207 1. if the source file is in another dir OR
208 2. if target was compiled without -g
209 We still want to show the assembly though! */
211 tui_get_begin_asm_address (&gdbarch, &addr);
212 if (win_with_focus == TUI_SRC_WIN)
213 tui_set_win_focus_to (TUI_SRC_WIN);
215 tui_set_win_focus_to (TUI_DISASM_WIN);
216 layout_def->split = TRUE;
218 case SRC_DATA_COMMAND:
219 if (win_with_focus != TUI_DATA_WIN)
220 tui_set_win_focus_to (TUI_SRC_WIN);
222 tui_set_win_focus_to (TUI_DATA_WIN);
223 layout_def->display_mode = SRC_WIN;
224 layout_def->split = FALSE;
226 case DISASSEM_DATA_COMMAND:
227 /* The previous layout was not showing code.
228 This can happen if there is no source
231 1. if the source file is in another dir OR
232 2. if target was compiled without -g
233 We still want to show the assembly though! */
235 tui_get_begin_asm_address (&gdbarch, &addr);
236 if (win_with_focus != TUI_DATA_WIN)
237 tui_set_win_focus_to (TUI_DISASM_WIN);
239 tui_set_win_focus_to (TUI_DATA_WIN);
240 layout_def->display_mode = DISASSEM_WIN;
241 layout_def->split = FALSE;
248 * Now update the window content.
251 && (new_layout == SRC_DATA_COMMAND
252 || new_layout == DISASSEM_DATA_COMMAND))
253 tui_display_all_data ();
255 tui_update_source_windows_with_addr (gdbarch, addr);
259 tui_show_registers (TUI_DATA_WIN->detail.data_display_info.current_group);
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 cur_layout = tui_current_layout ();
280 if (cur_layout != SRC_COMMAND
281 && cur_layout != SRC_DISASSEM_COMMAND
282 && cur_layout != SRC_DATA_COMMAND)
284 tui_clear_source_windows_detail ();
285 if (cur_layout == DISASSEM_DATA_COMMAND)
286 show_layout (SRC_DATA_COMMAND);
288 show_layout (SRC_COMMAND);
292 if (cur_layout != DISASSEM_COMMAND
293 && cur_layout != SRC_DISASSEM_COMMAND
294 && cur_layout != DISASSEM_DATA_COMMAND)
296 tui_clear_source_windows_detail ();
297 if (cur_layout == SRC_DATA_COMMAND)
298 show_layout (DISASSEM_DATA_COMMAND);
300 show_layout (DISASSEM_COMMAND);
304 if (cur_layout != SRC_DATA_COMMAND
305 && cur_layout != DISASSEM_DATA_COMMAND)
307 if (cur_layout == DISASSEM_COMMAND)
308 show_layout (DISASSEM_DATA_COMMAND);
310 show_layout (SRC_DATA_COMMAND);
319 /* Answer the height of a window. If it hasn't been created yet,
320 answer what the height of a window would be based upon its type and
323 tui_default_win_height (enum tui_win_type type,
324 enum tui_layout_type layout)
328 if (tui_win_list[type] != (struct tui_win_info *) NULL)
329 h = tui_win_list[type]->generic.height;
335 case DISASSEM_COMMAND:
336 if (TUI_CMD_WIN == NULL)
337 h = tui_term_height () / 2;
339 h = tui_term_height () - TUI_CMD_WIN->generic.height;
341 case SRC_DISASSEM_COMMAND:
342 case SRC_DATA_COMMAND:
343 case DISASSEM_DATA_COMMAND:
344 if (TUI_CMD_WIN == NULL)
345 h = tui_term_height () / 3;
347 h = (tui_term_height () - TUI_CMD_WIN->generic.height) / 2;
359 /* Answer the height of a window. If it hasn't been created yet,
360 answer what the height of a window would be based upon its type and
363 tui_default_win_viewport_height (enum tui_win_type type,
364 enum tui_layout_type layout)
368 h = tui_default_win_height (type, layout);
370 if (tui_win_list[type] == TUI_CMD_WIN)
379 /* Function to initialize gdb commands, for tui window layout
382 /* Provide a prototype to silence -Wmissing-prototypes. */
383 extern initialize_file_ftype _initialize_tui_layout;
386 _initialize_tui_layout (void)
388 add_com ("layout", class_tui, tui_layout_command, _("\
389 Change the layout of windows.\n\
390 Usage: layout prev | next | <layout_name> \n\
392 src : Displays source and command windows.\n\
393 asm : Displays disassembly and command windows.\n\
394 split : Displays source, disassembly and command windows.\n\
395 regs : Displays register window. If existing layout\n\
396 is source/command or assembly/command, the \n\
397 register window is displayed. If the\n\
398 source/assembly/command (split) is displayed, \n\
399 the register window is displayed with \n\
400 the window that has current logical focus.\n"));
403 add_com ("td", class_tui, tui_toggle_layout_command, _("\
404 Toggle between Source/Command and Disassembly/Command layouts.\n"));
405 add_com ("ts", class_tui, tui_toggle_split_layout_command, _("\
406 Toggle between Source/Command or Disassembly/Command and \n\
407 Source/Disassembly/Command layouts.\n"));
412 /*************************
413 ** STATIC LOCAL FUNCTIONS
414 **************************/
417 /* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
418 REGS, $REGS, $GREGS, $FREGS, $SREGS. */
420 tui_set_layout_for_display_command (const char *layout_name)
422 enum tui_status status = TUI_SUCCESS;
424 if (layout_name != (char *) NULL)
428 enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
429 enum tui_register_display_type dpy_type = TUI_UNDEFINED_REGS;
430 enum tui_layout_type cur_layout = tui_current_layout ();
432 buf_ptr = (char *) xstrdup (layout_name);
433 for (i = 0; (i < strlen (layout_name)); i++)
434 buf_ptr[i] = toupper (buf_ptr[i]);
436 /* First check for ambiguous input. */
437 if (strlen (buf_ptr) <= 1
438 && (*buf_ptr == 'S' || *buf_ptr == '$'))
440 warning (_("Ambiguous command input."));
441 status = TUI_FAILURE;
445 if (subset_compare (buf_ptr, "SRC"))
446 new_layout = SRC_COMMAND;
447 else if (subset_compare (buf_ptr, "ASM"))
448 new_layout = DISASSEM_COMMAND;
449 else if (subset_compare (buf_ptr, "SPLIT"))
450 new_layout = SRC_DISASSEM_COMMAND;
451 else if (subset_compare (buf_ptr, "REGS")
452 || subset_compare (buf_ptr, TUI_GENERAL_SPECIAL_REGS_NAME)
453 || subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME)
454 || subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME)
455 || subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
457 if (cur_layout == SRC_COMMAND
458 || cur_layout == SRC_DATA_COMMAND)
459 new_layout = SRC_DATA_COMMAND;
461 new_layout = DISASSEM_DATA_COMMAND;
463 /* Could ifdef out the following code. when compile with
464 -z, there are null pointer references that cause a
465 core dump if 'layout regs' is the first layout
466 command issued by the user. HP has asked us to hook
467 up this code. - edie epstein */
468 if (subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME))
470 if (TUI_DATA_WIN->detail.data_display_info.regs_display_type
472 && TUI_DATA_WIN->detail.data_display_info.regs_display_type
474 dpy_type = TUI_SFLOAT_REGS;
477 TUI_DATA_WIN->detail.data_display_info.regs_display_type;
479 else if (subset_compare (buf_ptr,
480 TUI_GENERAL_SPECIAL_REGS_NAME))
481 dpy_type = TUI_GENERAL_AND_SPECIAL_REGS;
482 else if (subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME))
483 dpy_type = TUI_GENERAL_REGS;
484 else if (subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
485 dpy_type = TUI_SPECIAL_REGS;
486 else if (TUI_DATA_WIN)
488 if (TUI_DATA_WIN->detail.data_display_info.regs_display_type
489 != TUI_UNDEFINED_REGS)
491 = TUI_DATA_WIN->detail.data_display_info.regs_display_type;
493 dpy_type = TUI_GENERAL_REGS;
496 /* End of potential ifdef.
499 /* If ifdefed out code above, then assume that the user
500 wishes to display the general purpose registers .
503 /* dpy_type = TUI_GENERAL_REGS; */
505 else if (subset_compare (buf_ptr, "NEXT"))
506 new_layout = next_layout ();
507 else if (subset_compare (buf_ptr, "PREV"))
508 new_layout = prev_layout ();
510 status = TUI_FAILURE;
512 tui_set_layout (new_layout, dpy_type);
517 status = TUI_FAILURE;
524 extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
526 enum tui_layout_type cur_layout = tui_current_layout ();
527 struct gdbarch *gdbarch = get_current_arch ();
530 struct symtab_and_line cursal = get_current_source_symtab_and_line ();
535 case SRC_DATA_COMMAND:
536 gdbarch = TUI_SRC_WIN->detail.source_info.gdbarch;
537 find_line_pc (cursal.symtab,
538 TUI_SRC_WIN->detail.source_info.start_line_or_addr.u.line_no,
542 case DISASSEM_COMMAND:
543 case SRC_DISASSEM_COMMAND:
544 case DISASSEM_DATA_COMMAND:
545 gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch;
546 addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr;
553 *gdbarch_p = gdbarch;
559 tui_handle_xdb_layout (struct tui_layout_def *layout_def)
561 if (layout_def->split)
563 tui_set_layout (SRC_DISASSEM_COMMAND, TUI_UNDEFINED_REGS);
564 tui_set_win_focus_to (tui_win_list[layout_def->display_mode]);
568 if (layout_def->display_mode == SRC_WIN)
569 tui_set_layout (SRC_COMMAND, TUI_UNDEFINED_REGS);
571 tui_set_layout (DISASSEM_DATA_COMMAND, layout_def->regs_display_type);
577 tui_toggle_layout_command (char *arg, int from_tty)
579 struct tui_layout_def *layout_def = tui_layout_def ();
581 /* Make sure the curses mode is enabled. */
583 if (layout_def->display_mode == SRC_WIN)
584 layout_def->display_mode = DISASSEM_WIN;
586 layout_def->display_mode = SRC_WIN;
588 if (!layout_def->split)
589 tui_handle_xdb_layout (layout_def);
594 tui_toggle_split_layout_command (char *arg, int from_tty)
596 struct tui_layout_def *layout_def = tui_layout_def ();
598 /* Make sure the curses mode is enabled. */
600 layout_def->split = (!layout_def->split);
601 tui_handle_xdb_layout (layout_def);
606 tui_layout_command (char *arg, int from_tty)
608 /* Make sure the curses mode is enabled. */
611 /* Switch to the selected layout. */
612 if (tui_set_layout_for_display_command (arg) != TUI_SUCCESS)
613 warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE);
617 /* Answer the previous layout to cycle to. */
618 static enum tui_layout_type
621 enum tui_layout_type new_layout;
623 new_layout = tui_current_layout ();
624 if (new_layout == UNDEFINED_LAYOUT)
625 new_layout = SRC_COMMAND;
629 if (new_layout == UNDEFINED_LAYOUT)
630 new_layout = SRC_COMMAND;
637 /* Answer the next layout to cycle to. */
638 static enum tui_layout_type
641 enum tui_layout_type new_layout;
643 new_layout = tui_current_layout ();
644 if (new_layout == SRC_COMMAND)
645 new_layout = DISASSEM_DATA_COMMAND;
649 if (new_layout == UNDEFINED_LAYOUT)
650 new_layout = DISASSEM_DATA_COMMAND;
659 make_command_window (struct tui_win_info **win_info_ptr,
660 int height, int origin_y)
662 *win_info_ptr = init_and_make_win (*win_info_ptr,
670 (*win_info_ptr)->can_highlight = FALSE;
674 /* make_source_window().
677 make_source_window (struct tui_win_info **win_info_ptr,
678 int height, int origin_y)
680 make_source_or_disasm_window (win_info_ptr, SRC_WIN, height, origin_y);
683 } /* make_source_window */
686 /* make_disasm_window().
689 make_disasm_window (struct tui_win_info **win_info_ptr,
690 int height, int origin_y)
692 make_source_or_disasm_window (win_info_ptr, DISASSEM_WIN, height, origin_y);
695 } /* make_disasm_window */
699 make_data_window (struct tui_win_info **win_info_ptr,
700 int height, int origin_y)
702 *win_info_ptr = init_and_make_win (*win_info_ptr,
713 /* Show the Source/Command layout. */
715 show_source_command (void)
717 show_source_or_disasm_and_command (SRC_COMMAND);
721 /* Show the Dissassem/Command layout. */
723 show_disasm_command (void)
725 show_source_or_disasm_and_command (DISASSEM_COMMAND);
729 /* Show the Source/Disassem/Command layout. */
731 show_source_disasm_command (void)
733 if (tui_current_layout () != SRC_DISASSEM_COMMAND)
735 int cmd_height, src_height, asm_height;
737 if (TUI_CMD_WIN != NULL)
738 cmd_height = TUI_CMD_WIN->generic.height;
740 cmd_height = tui_term_height () / 3;
742 src_height = (tui_term_height () - cmd_height) / 2;
743 asm_height = tui_term_height () - (src_height + cmd_height);
745 if (TUI_SRC_WIN == NULL)
746 make_source_window (&TUI_SRC_WIN, src_height, 0);
749 init_gen_win_info (&TUI_SRC_WIN->generic,
750 TUI_SRC_WIN->generic.type,
752 TUI_SRC_WIN->generic.width,
753 TUI_SRC_WIN->detail.source_info.execution_info->width,
755 TUI_SRC_WIN->can_highlight = TRUE;
756 init_gen_win_info (TUI_SRC_WIN->detail.source_info.execution_info,
762 tui_make_visible (&TUI_SRC_WIN->generic);
763 tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info);
764 TUI_SRC_WIN->detail.source_info.has_locator = FALSE;;
766 if (TUI_SRC_WIN != NULL)
768 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
770 tui_show_source_content (TUI_SRC_WIN);
771 if (TUI_DISASM_WIN == NULL)
773 make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1);
774 locator = init_and_make_win (locator,
779 (src_height + asm_height) - 1,
784 init_gen_win_info (locator,
789 (src_height + asm_height) - 1);
790 TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
791 init_gen_win_info (&TUI_DISASM_WIN->generic,
792 TUI_DISASM_WIN->generic.type,
794 TUI_DISASM_WIN->generic.width,
795 TUI_DISASM_WIN->detail.source_info.execution_info->width,
797 init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info,
803 TUI_DISASM_WIN->can_highlight = TRUE;
804 tui_make_visible (&TUI_DISASM_WIN->generic);
805 tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
807 if (TUI_DISASM_WIN != NULL)
809 TUI_SRC_WIN->detail.source_info.has_locator = FALSE;
810 TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
811 tui_make_visible (locator);
812 tui_show_locator_content ();
813 tui_show_source_content (TUI_DISASM_WIN);
815 if (TUI_CMD_WIN == NULL)
816 make_command_window (&TUI_CMD_WIN,
818 tui_term_height () - cmd_height);
821 init_gen_win_info (&TUI_CMD_WIN->generic,
822 TUI_CMD_WIN->generic.type,
823 TUI_CMD_WIN->generic.height,
824 TUI_CMD_WIN->generic.width,
826 TUI_CMD_WIN->generic.origin.y);
827 TUI_CMD_WIN->can_highlight = FALSE;
828 tui_make_visible (&TUI_CMD_WIN->generic);
830 if (TUI_CMD_WIN != NULL)
831 tui_refresh_win (&TUI_CMD_WIN->generic);
834 tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
839 /* Show the Source/Data/Command or the Dissassembly/Data/Command
842 show_data (enum tui_layout_type new_layout)
844 int total_height = (tui_term_height () - TUI_CMD_WIN->generic.height);
845 int src_height, data_height;
846 enum tui_win_type win_type;
847 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
850 data_height = total_height / 2;
851 src_height = total_height - data_height;
852 tui_make_all_invisible ();
853 tui_make_invisible (locator);
854 make_data_window (&TUI_DATA_WIN, data_height, 0);
855 TUI_DATA_WIN->can_highlight = TRUE;
856 if (new_layout == SRC_DATA_COMMAND)
859 win_type = DISASSEM_WIN;
860 if (tui_win_list[win_type] == NULL)
862 if (win_type == SRC_WIN)
863 make_source_window (&tui_win_list[win_type], src_height, data_height - 1);
865 make_disasm_window (&tui_win_list[win_type], src_height, data_height - 1);
866 locator = init_and_make_win (locator,
876 init_gen_win_info (&tui_win_list[win_type]->generic,
877 tui_win_list[win_type]->generic.type,
879 tui_win_list[win_type]->generic.width,
880 tui_win_list[win_type]->detail.source_info.execution_info->width,
882 init_gen_win_info (tui_win_list[win_type]->detail.source_info.execution_info,
888 tui_make_visible (&tui_win_list[win_type]->generic);
889 tui_make_visible (tui_win_list[win_type]->detail.source_info.execution_info);
890 init_gen_win_info (locator,
897 tui_win_list[win_type]->detail.source_info.has_locator = TRUE;
898 tui_make_visible (locator);
899 tui_show_locator_content ();
900 tui_add_to_source_windows (tui_win_list[win_type]);
901 tui_set_current_layout_to (new_layout);
904 /* init_gen_win_info().
907 init_gen_win_info (struct tui_gen_win_info *win_info,
908 enum tui_win_type type,
909 int height, int width,
910 int origin_x, int origin_y)
914 win_info->type = type;
915 win_info->width = width;
916 win_info->height = h;
919 win_info->viewport_height = h - 1;
920 if (win_info->type != CMD_WIN)
921 win_info->viewport_height--;
924 win_info->viewport_height = 1;
925 win_info->origin.x = origin_x;
926 win_info->origin.y = origin_y;
929 } /* init_gen_win_info */
931 /* init_and_make_win().
934 init_and_make_win (void *opaque_win_info,
935 enum tui_win_type win_type,
936 int height, int width,
937 int origin_x, int origin_y,
940 struct tui_gen_win_info *generic;
942 if (opaque_win_info == NULL)
944 if (tui_win_is_auxillary (win_type))
945 opaque_win_info = (void *) tui_alloc_generic_win_info ();
947 opaque_win_info = (void *) tui_alloc_win_info (win_type);
949 if (tui_win_is_auxillary (win_type))
950 generic = (struct tui_gen_win_info *) opaque_win_info;
952 generic = &((struct tui_win_info *) opaque_win_info)->generic;
954 if (opaque_win_info != NULL)
956 init_gen_win_info (generic, win_type, height, width, origin_x, origin_y);
957 if (!tui_win_is_auxillary (win_type))
959 if (generic->type == CMD_WIN)
960 ((struct tui_win_info *) opaque_win_info)->can_highlight = FALSE;
962 ((struct tui_win_info *) opaque_win_info)->can_highlight = TRUE;
964 tui_make_window (generic, box_it);
966 return opaque_win_info;
971 make_source_or_disasm_window (struct tui_win_info **win_info_ptr,
972 enum tui_win_type type,
973 int height, int origin_y)
975 struct tui_gen_win_info *execution_info = (struct tui_gen_win_info *) NULL;
977 /* Create the exeuction info window. */
979 execution_info = tui_source_exec_info_win_ptr ();
981 execution_info = tui_disassem_exec_info_win_ptr ();
982 execution_info = init_and_make_win (execution_info,
990 /* Now create the source window. */
991 *win_info_ptr = init_and_make_win (*win_info_ptr,
994 tui_term_width () - execution_info->width,
995 execution_info->width,
999 (*win_info_ptr)->detail.source_info.execution_info = execution_info;
1003 /* Show the Source/Command or the Disassem layout. */
1005 show_source_or_disasm_and_command (enum tui_layout_type layout_type)
1007 if (tui_current_layout () != layout_type)
1009 struct tui_win_info **win_info_ptr;
1010 int src_height, cmd_height;
1011 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
1013 if (TUI_CMD_WIN != NULL)
1014 cmd_height = TUI_CMD_WIN->generic.height;
1016 cmd_height = tui_term_height () / 3;
1017 src_height = tui_term_height () - cmd_height;
1019 if (layout_type == SRC_COMMAND)
1020 win_info_ptr = &TUI_SRC_WIN;
1022 win_info_ptr = &TUI_DISASM_WIN;
1024 if ((*win_info_ptr) == NULL)
1026 if (layout_type == SRC_COMMAND)
1027 make_source_window (win_info_ptr, src_height - 1, 0);
1029 make_disasm_window (win_info_ptr, src_height - 1, 0);
1030 locator = init_and_make_win (locator,
1040 init_gen_win_info (locator,
1046 (*win_info_ptr)->detail.source_info.has_locator = TRUE;
1047 init_gen_win_info (&(*win_info_ptr)->generic,
1048 (*win_info_ptr)->generic.type,
1050 (*win_info_ptr)->generic.width,
1051 (*win_info_ptr)->detail.source_info.execution_info->width,
1053 init_gen_win_info ((*win_info_ptr)->detail.source_info.execution_info,
1059 (*win_info_ptr)->can_highlight = TRUE;
1060 tui_make_visible (&(*win_info_ptr)->generic);
1061 tui_make_visible ((*win_info_ptr)->detail.source_info.execution_info);
1063 if ((*win_info_ptr) != NULL)
1065 (*win_info_ptr)->detail.source_info.has_locator = TRUE;
1066 tui_make_visible (locator);
1067 tui_show_locator_content ();
1068 tui_show_source_content (*win_info_ptr);
1070 if (TUI_CMD_WIN == NULL)
1072 make_command_window (&TUI_CMD_WIN, cmd_height, src_height);
1073 tui_refresh_win (&TUI_CMD_WIN->generic);
1077 init_gen_win_info (&TUI_CMD_WIN->generic,
1078 TUI_CMD_WIN->generic.type,
1079 TUI_CMD_WIN->generic.height,
1080 TUI_CMD_WIN->generic.width,
1081 TUI_CMD_WIN->generic.origin.x,
1082 TUI_CMD_WIN->generic.origin.y);
1083 TUI_CMD_WIN->can_highlight = FALSE;
1084 tui_make_visible (&TUI_CMD_WIN->generic);
1087 tui_set_current_layout_to (layout_type);