1 /* TUI layout window management.
3 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009,
4 2010, 2011 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>. */
24 #include "arch-utils.h"
32 #include "tui/tui-data.h"
33 #include "tui/tui-windata.h"
34 #include "tui/tui-wingeneral.h"
35 #include "tui/tui-stack.h"
36 #include "tui/tui-regs.h"
37 #include "tui/tui-win.h"
38 #include "tui/tui-winsource.h"
39 #include "tui/tui-disasm.h"
40 #include "tui/tui-layout.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 *,
52 static void *init_and_make_win (void *, enum tui_win_type,
53 int, int, int, int, int);
54 static void show_source_or_disasm_and_command (enum tui_layout_type);
55 static void make_source_or_disasm_window (struct tui_win_info **,
58 static void make_command_window (struct tui_win_info **, int, int);
59 static void make_source_window (struct tui_win_info **, int, int);
60 static void make_disasm_window (struct tui_win_info **, int, int);
61 static void make_data_window (struct tui_win_info **, int, int);
62 static void show_source_command (void);
63 static void show_disasm_command (void);
64 static void show_source_disasm_command (void);
65 static void show_data (enum tui_layout_type);
66 static enum tui_layout_type next_layout (void);
67 static enum tui_layout_type prev_layout (void);
68 static void tui_layout_command (char *, int);
69 static void tui_toggle_layout_command (char *, int);
70 static void tui_toggle_split_layout_command (char *, int);
71 static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *);
72 static void tui_handle_xdb_layout (struct tui_layout_def *);
75 /***************************************
77 ***************************************/
79 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
81 /* Show the screen layout defined. */
83 show_layout (enum tui_layout_type layout)
85 enum tui_layout_type cur_layout = tui_current_layout ();
87 if (layout != cur_layout)
89 /* Since the new layout may cause changes in window size, we
90 should free the content and reallocate on next display of
92 tui_free_all_source_wins_content ();
93 tui_clear_source_windows ();
94 if (layout == SRC_DATA_COMMAND
95 || layout == DISASSEM_DATA_COMMAND)
98 tui_refresh_all (tui_win_list);
102 /* First make the current layout be invisible. */
103 tui_make_all_invisible ();
104 tui_make_invisible (tui_locator_win_info_ptr ());
108 /* Now show the new layout. */
110 show_source_command ();
111 tui_add_to_source_windows (TUI_SRC_WIN);
113 case DISASSEM_COMMAND:
114 show_disasm_command ();
115 tui_add_to_source_windows (TUI_DISASM_WIN);
117 case SRC_DISASSEM_COMMAND:
118 show_source_disasm_command ();
119 tui_add_to_source_windows (TUI_SRC_WIN);
120 tui_add_to_source_windows (TUI_DISASM_WIN);
130 /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
131 SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
132 If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
133 UNDEFINED_LAYOUT, then the data window is populated according to
134 regs_display_type. */
136 tui_set_layout (enum tui_layout_type layout_type,
137 enum tui_register_display_type regs_display_type)
139 enum tui_status status = TUI_SUCCESS;
141 if (layout_type != UNDEFINED_LAYOUT
142 || regs_display_type != TUI_UNDEFINED_REGS)
144 enum tui_layout_type cur_layout = tui_current_layout (),
145 new_layout = UNDEFINED_LAYOUT;
146 int regs_populate = FALSE;
147 struct gdbarch *gdbarch;
149 struct tui_win_info *win_with_focus = tui_win_with_focus ();
150 struct tui_layout_def *layout_def = tui_layout_def ();
152 extract_display_start_addr (&gdbarch, &addr);
154 if (layout_type == UNDEFINED_LAYOUT
155 && regs_display_type != TUI_UNDEFINED_REGS)
157 if (cur_layout == SRC_DISASSEM_COMMAND)
158 new_layout = DISASSEM_DATA_COMMAND;
159 else if (cur_layout == SRC_COMMAND
160 || cur_layout == SRC_DATA_COMMAND)
161 new_layout = SRC_DATA_COMMAND;
162 else if (cur_layout == DISASSEM_COMMAND
163 || cur_layout == DISASSEM_DATA_COMMAND)
164 new_layout = DISASSEM_DATA_COMMAND;
167 new_layout = layout_type;
169 regs_populate = (new_layout == SRC_DATA_COMMAND
170 || new_layout == DISASSEM_DATA_COMMAND
171 || regs_display_type != TUI_UNDEFINED_REGS);
172 if (new_layout != cur_layout
173 || regs_display_type != TUI_UNDEFINED_REGS)
175 if (new_layout != cur_layout)
177 show_layout (new_layout);
179 /* Now determine where focus should be. */
180 if (win_with_focus != TUI_CMD_WIN)
185 tui_set_win_focus_to (TUI_SRC_WIN);
186 layout_def->display_mode = SRC_WIN;
187 layout_def->split = FALSE;
189 case DISASSEM_COMMAND:
190 /* The previous layout was not showing code.
191 This can happen if there is no source
194 1. if the source file is in another dir OR
195 2. if target was compiled without -g
196 We still want to show the assembly though! */
198 tui_get_begin_asm_address (&gdbarch, &addr);
199 tui_set_win_focus_to (TUI_DISASM_WIN);
200 layout_def->display_mode = DISASSEM_WIN;
201 layout_def->split = FALSE;
203 case SRC_DISASSEM_COMMAND:
204 /* The previous layout was not showing code.
205 This can happen if there is no source
208 1. if the source file is in another dir OR
209 2. if target was compiled without -g
210 We still want to show the assembly though! */
212 tui_get_begin_asm_address (&gdbarch, &addr);
213 if (win_with_focus == TUI_SRC_WIN)
214 tui_set_win_focus_to (TUI_SRC_WIN);
216 tui_set_win_focus_to (TUI_DISASM_WIN);
217 layout_def->split = TRUE;
219 case SRC_DATA_COMMAND:
220 if (win_with_focus != TUI_DATA_WIN)
221 tui_set_win_focus_to (TUI_SRC_WIN);
223 tui_set_win_focus_to (TUI_DATA_WIN);
224 layout_def->display_mode = SRC_WIN;
225 layout_def->split = FALSE;
227 case DISASSEM_DATA_COMMAND:
228 /* The previous layout was not showing code.
229 This can happen if there is no source
232 1. if the source file is in another dir OR
233 2. if target was compiled without -g
234 We still want to show the assembly though! */
236 tui_get_begin_asm_address (&gdbarch, &addr);
237 if (win_with_focus != TUI_DATA_WIN)
238 tui_set_win_focus_to (TUI_DISASM_WIN);
240 tui_set_win_focus_to (TUI_DATA_WIN);
241 layout_def->display_mode = DISASSEM_WIN;
242 layout_def->split = FALSE;
249 * Now update the window content.
252 && (new_layout == SRC_DATA_COMMAND
253 || new_layout == DISASSEM_DATA_COMMAND))
254 tui_display_all_data ();
256 tui_update_source_windows_with_addr (gdbarch, addr);
260 tui_show_registers (TUI_DATA_WIN->detail.data_display_info.current_group);
265 status = TUI_FAILURE;
270 /* Add the specified window to the layout in a logical way. This
271 means setting up the most logical layout given the window to be
274 tui_add_win_to_layout (enum tui_win_type type)
276 enum tui_layout_type cur_layout = tui_current_layout ();
281 if (cur_layout != SRC_COMMAND
282 && cur_layout != SRC_DISASSEM_COMMAND
283 && cur_layout != SRC_DATA_COMMAND)
285 tui_clear_source_windows_detail ();
286 if (cur_layout == DISASSEM_DATA_COMMAND)
287 show_layout (SRC_DATA_COMMAND);
289 show_layout (SRC_COMMAND);
293 if (cur_layout != DISASSEM_COMMAND
294 && cur_layout != SRC_DISASSEM_COMMAND
295 && cur_layout != DISASSEM_DATA_COMMAND)
297 tui_clear_source_windows_detail ();
298 if (cur_layout == SRC_DATA_COMMAND)
299 show_layout (DISASSEM_DATA_COMMAND);
301 show_layout (DISASSEM_COMMAND);
305 if (cur_layout != SRC_DATA_COMMAND
306 && cur_layout != DISASSEM_DATA_COMMAND)
308 if (cur_layout == DISASSEM_COMMAND)
309 show_layout (DISASSEM_DATA_COMMAND);
311 show_layout (SRC_DATA_COMMAND);
320 /* Answer the height of a window. If it hasn't been created yet,
321 answer what the height of a window would be based upon its type and
324 tui_default_win_height (enum tui_win_type type,
325 enum tui_layout_type layout)
329 if (tui_win_list[type] != (struct tui_win_info *) NULL)
330 h = tui_win_list[type]->generic.height;
336 case DISASSEM_COMMAND:
337 if (TUI_CMD_WIN == NULL)
338 h = tui_term_height () / 2;
340 h = tui_term_height () - TUI_CMD_WIN->generic.height;
342 case SRC_DISASSEM_COMMAND:
343 case SRC_DATA_COMMAND:
344 case DISASSEM_DATA_COMMAND:
345 if (TUI_CMD_WIN == NULL)
346 h = tui_term_height () / 3;
348 h = (tui_term_height () - TUI_CMD_WIN->generic.height) / 2;
360 /* Answer the height of a window. If it hasn't been created yet,
361 answer what the height of a window would be based upon its type and
364 tui_default_win_viewport_height (enum tui_win_type type,
365 enum tui_layout_type layout)
369 h = tui_default_win_height (type, layout);
371 if (tui_win_list[type] == TUI_CMD_WIN)
380 /* Function to initialize gdb commands, for tui window layout
383 /* Provide a prototype to silence -Wmissing-prototypes. */
384 extern initialize_file_ftype _initialize_tui_layout;
387 _initialize_tui_layout (void)
389 add_com ("layout", class_tui, tui_layout_command, _("\
390 Change the layout of windows.\n\
391 Usage: layout prev | next | <layout_name> \n\
393 src : Displays source and command windows.\n\
394 asm : Displays disassembly and command windows.\n\
395 split : Displays source, disassembly and command windows.\n\
396 regs : Displays register window. If existing layout\n\
397 is source/command or assembly/command, the \n\
398 register window is displayed. If the\n\
399 source/assembly/command (split) is displayed, \n\
400 the register window is displayed with \n\
401 the window that has current logical focus.\n"));
404 add_com ("td", class_tui, tui_toggle_layout_command, _("\
405 Toggle between Source/Command and Disassembly/Command layouts.\n"));
406 add_com ("ts", class_tui, tui_toggle_split_layout_command, _("\
407 Toggle between Source/Command or Disassembly/Command and \n\
408 Source/Disassembly/Command layouts.\n"));
413 /*************************
414 ** STATIC LOCAL FUNCTIONS
415 **************************/
418 /* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
419 REGS, $REGS, $GREGS, $FREGS, $SREGS. */
421 tui_set_layout_for_display_command (const char *layout_name)
423 enum tui_status status = TUI_SUCCESS;
425 if (layout_name != (char *) NULL)
429 enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
430 enum tui_register_display_type dpy_type = TUI_UNDEFINED_REGS;
431 enum tui_layout_type cur_layout = tui_current_layout ();
433 buf_ptr = (char *) xstrdup (layout_name);
434 for (i = 0; (i < strlen (layout_name)); i++)
435 buf_ptr[i] = toupper (buf_ptr[i]);
437 /* First check for ambiguous input. */
438 if (strlen (buf_ptr) <= 1
439 && (*buf_ptr == 'S' || *buf_ptr == '$'))
441 warning (_("Ambiguous command input."));
442 status = TUI_FAILURE;
446 if (subset_compare (buf_ptr, "SRC"))
447 new_layout = SRC_COMMAND;
448 else if (subset_compare (buf_ptr, "ASM"))
449 new_layout = DISASSEM_COMMAND;
450 else if (subset_compare (buf_ptr, "SPLIT"))
451 new_layout = SRC_DISASSEM_COMMAND;
452 else if (subset_compare (buf_ptr, "REGS")
453 || subset_compare (buf_ptr, TUI_GENERAL_SPECIAL_REGS_NAME)
454 || subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME)
455 || subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME)
456 || subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
458 if (cur_layout == SRC_COMMAND
459 || cur_layout == SRC_DATA_COMMAND)
460 new_layout = SRC_DATA_COMMAND;
462 new_layout = DISASSEM_DATA_COMMAND;
464 /* Could ifdef out the following code. when compile with
465 -z, there are null pointer references that cause a
466 core dump if 'layout regs' is the first layout
467 command issued by the user. HP has asked us to hook
468 up this code. - edie epstein */
469 if (subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME))
471 if (TUI_DATA_WIN->detail.data_display_info.regs_display_type
473 && TUI_DATA_WIN->detail.data_display_info.regs_display_type
475 dpy_type = TUI_SFLOAT_REGS;
478 TUI_DATA_WIN->detail.data_display_info.regs_display_type;
480 else if (subset_compare (buf_ptr,
481 TUI_GENERAL_SPECIAL_REGS_NAME))
482 dpy_type = TUI_GENERAL_AND_SPECIAL_REGS;
483 else if (subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME))
484 dpy_type = TUI_GENERAL_REGS;
485 else if (subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
486 dpy_type = TUI_SPECIAL_REGS;
487 else if (TUI_DATA_WIN)
489 if (TUI_DATA_WIN->detail.data_display_info.regs_display_type
490 != TUI_UNDEFINED_REGS)
492 TUI_DATA_WIN->detail.data_display_info.regs_display_type;
494 dpy_type = TUI_GENERAL_REGS;
497 /* End of potential ifdef.
500 /* If ifdefed out code above, then assume that the user
501 wishes to display the general purpose registers .
504 /* dpy_type = TUI_GENERAL_REGS; */
506 else if (subset_compare (buf_ptr, "NEXT"))
507 new_layout = next_layout ();
508 else if (subset_compare (buf_ptr, "PREV"))
509 new_layout = prev_layout ();
511 status = TUI_FAILURE;
513 tui_set_layout (new_layout, dpy_type);
518 status = TUI_FAILURE;
525 extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
527 enum tui_layout_type cur_layout = tui_current_layout ();
528 struct gdbarch *gdbarch = get_current_arch ();
531 struct symtab_and_line cursal = get_current_source_symtab_and_line ();
536 case SRC_DATA_COMMAND:
537 gdbarch = TUI_SRC_WIN->detail.source_info.gdbarch;
538 find_line_pc (cursal.symtab,
539 TUI_SRC_WIN->detail.source_info.start_line_or_addr.u.line_no,
543 case DISASSEM_COMMAND:
544 case SRC_DISASSEM_COMMAND:
545 case DISASSEM_DATA_COMMAND:
546 gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch;
547 addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr;
554 *gdbarch_p = gdbarch;
560 tui_handle_xdb_layout (struct tui_layout_def *layout_def)
562 if (layout_def->split)
564 tui_set_layout (SRC_DISASSEM_COMMAND, TUI_UNDEFINED_REGS);
565 tui_set_win_focus_to (tui_win_list[layout_def->display_mode]);
569 if (layout_def->display_mode == SRC_WIN)
570 tui_set_layout (SRC_COMMAND, TUI_UNDEFINED_REGS);
572 tui_set_layout (DISASSEM_DATA_COMMAND, layout_def->regs_display_type);
578 tui_toggle_layout_command (char *arg, int from_tty)
580 struct tui_layout_def *layout_def = tui_layout_def ();
582 /* Make sure the curses mode is enabled. */
584 if (layout_def->display_mode == SRC_WIN)
585 layout_def->display_mode = DISASSEM_WIN;
587 layout_def->display_mode = SRC_WIN;
589 if (!layout_def->split)
590 tui_handle_xdb_layout (layout_def);
595 tui_toggle_split_layout_command (char *arg, int from_tty)
597 struct tui_layout_def *layout_def = tui_layout_def ();
599 /* Make sure the curses mode is enabled. */
601 layout_def->split = (!layout_def->split);
602 tui_handle_xdb_layout (layout_def);
607 tui_layout_command (char *arg, int from_tty)
609 /* Make sure the curses mode is enabled. */
612 /* Switch to the selected layout. */
613 if (tui_set_layout_for_display_command (arg) != TUI_SUCCESS)
614 warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE);
618 /* Answer the previous layout to cycle to. */
619 static enum tui_layout_type
622 enum tui_layout_type new_layout;
624 new_layout = tui_current_layout ();
625 if (new_layout == UNDEFINED_LAYOUT)
626 new_layout = SRC_COMMAND;
630 if (new_layout == UNDEFINED_LAYOUT)
631 new_layout = SRC_COMMAND;
638 /* Answer the next layout to cycle to. */
639 static enum tui_layout_type
642 enum tui_layout_type new_layout;
644 new_layout = tui_current_layout ();
645 if (new_layout == SRC_COMMAND)
646 new_layout = DISASSEM_DATA_COMMAND;
650 if (new_layout == UNDEFINED_LAYOUT)
651 new_layout = DISASSEM_DATA_COMMAND;
660 make_command_window (struct tui_win_info **win_info_ptr,
661 int height, int origin_y)
663 *win_info_ptr = init_and_make_win (*win_info_ptr,
671 (*win_info_ptr)->can_highlight = FALSE;
675 /* make_source_window().
678 make_source_window (struct tui_win_info **win_info_ptr,
679 int height, int origin_y)
681 make_source_or_disasm_window (win_info_ptr, SRC_WIN, height, origin_y);
684 } /* make_source_window */
687 /* make_disasm_window().
690 make_disasm_window (struct tui_win_info **win_info_ptr,
691 int height, int origin_y)
693 make_source_or_disasm_window (win_info_ptr, DISASSEM_WIN, height, origin_y);
696 } /* make_disasm_window */
700 make_data_window (struct tui_win_info **win_info_ptr,
701 int height, int origin_y)
703 *win_info_ptr = init_and_make_win (*win_info_ptr,
714 /* Show the Source/Command layout. */
716 show_source_command (void)
718 show_source_or_disasm_and_command (SRC_COMMAND);
722 /* Show the Dissassem/Command layout. */
724 show_disasm_command (void)
726 show_source_or_disasm_and_command (DISASSEM_COMMAND);
730 /* Show the Source/Disassem/Command layout. */
732 show_source_disasm_command (void)
734 if (tui_current_layout () != SRC_DISASSEM_COMMAND)
736 int cmd_height, src_height, asm_height;
738 if (TUI_CMD_WIN != NULL)
739 cmd_height = TUI_CMD_WIN->generic.height;
741 cmd_height = tui_term_height () / 3;
743 src_height = (tui_term_height () - cmd_height) / 2;
744 asm_height = tui_term_height () - (src_height + cmd_height);
746 if (TUI_SRC_WIN == NULL)
747 make_source_window (&TUI_SRC_WIN, src_height, 0);
750 init_gen_win_info (&TUI_SRC_WIN->generic,
751 TUI_SRC_WIN->generic.type,
753 TUI_SRC_WIN->generic.width,
754 TUI_SRC_WIN->detail.source_info.execution_info->width,
756 TUI_SRC_WIN->can_highlight = TRUE;
757 init_gen_win_info (TUI_SRC_WIN->detail.source_info.execution_info,
763 tui_make_visible (&TUI_SRC_WIN->generic);
764 tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info);
765 TUI_SRC_WIN->detail.source_info.has_locator = FALSE;;
767 if (TUI_SRC_WIN != NULL)
769 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
771 tui_show_source_content (TUI_SRC_WIN);
772 if (TUI_DISASM_WIN == NULL)
774 make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1);
775 locator = init_and_make_win (locator,
780 (src_height + asm_height) - 1,
785 init_gen_win_info (locator,
790 (src_height + asm_height) - 1);
791 TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
792 init_gen_win_info (&TUI_DISASM_WIN->generic,
793 TUI_DISASM_WIN->generic.type,
795 TUI_DISASM_WIN->generic.width,
796 TUI_DISASM_WIN->detail.source_info.execution_info->width,
798 init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info,
804 TUI_DISASM_WIN->can_highlight = TRUE;
805 tui_make_visible (&TUI_DISASM_WIN->generic);
806 tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
808 if (TUI_DISASM_WIN != NULL)
810 TUI_SRC_WIN->detail.source_info.has_locator = FALSE;
811 TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
812 tui_make_visible (locator);
813 tui_show_locator_content ();
814 tui_show_source_content (TUI_DISASM_WIN);
816 if (TUI_CMD_WIN == NULL)
817 make_command_window (&TUI_CMD_WIN,
819 tui_term_height () - cmd_height);
822 init_gen_win_info (&TUI_CMD_WIN->generic,
823 TUI_CMD_WIN->generic.type,
824 TUI_CMD_WIN->generic.height,
825 TUI_CMD_WIN->generic.width,
827 TUI_CMD_WIN->generic.origin.y);
828 TUI_CMD_WIN->can_highlight = FALSE;
829 tui_make_visible (&TUI_CMD_WIN->generic);
831 if (TUI_CMD_WIN != NULL)
832 tui_refresh_win (&TUI_CMD_WIN->generic);
835 tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
840 /* Show the Source/Data/Command or the Dissassembly/Data/Command
843 show_data (enum tui_layout_type new_layout)
845 int total_height = (tui_term_height () - TUI_CMD_WIN->generic.height);
846 int src_height, data_height;
847 enum tui_win_type win_type;
848 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
851 data_height = total_height / 2;
852 src_height = total_height - data_height;
853 tui_make_all_invisible ();
854 tui_make_invisible (locator);
855 make_data_window (&TUI_DATA_WIN, data_height, 0);
856 TUI_DATA_WIN->can_highlight = TRUE;
857 if (new_layout == SRC_DATA_COMMAND)
860 win_type = DISASSEM_WIN;
861 if (tui_win_list[win_type] == NULL)
863 if (win_type == SRC_WIN)
864 make_source_window (&tui_win_list[win_type], src_height, data_height - 1);
866 make_disasm_window (&tui_win_list[win_type], src_height, data_height - 1);
867 locator = init_and_make_win (locator,
877 init_gen_win_info (&tui_win_list[win_type]->generic,
878 tui_win_list[win_type]->generic.type,
880 tui_win_list[win_type]->generic.width,
881 tui_win_list[win_type]->detail.source_info.execution_info->width,
883 init_gen_win_info (tui_win_list[win_type]->detail.source_info.execution_info,
889 tui_make_visible (&tui_win_list[win_type]->generic);
890 tui_make_visible (tui_win_list[win_type]->detail.source_info.execution_info);
891 init_gen_win_info (locator,
898 tui_win_list[win_type]->detail.source_info.has_locator = TRUE;
899 tui_make_visible (locator);
900 tui_show_locator_content ();
901 tui_add_to_source_windows (tui_win_list[win_type]);
902 tui_set_current_layout_to (new_layout);
905 /* init_gen_win_info().
908 init_gen_win_info (struct tui_gen_win_info *win_info,
909 enum tui_win_type type,
910 int height, int width,
911 int origin_x, int origin_y)
915 win_info->type = type;
916 win_info->width = width;
917 win_info->height = h;
920 win_info->viewport_height = h - 1;
921 if (win_info->type != CMD_WIN)
922 win_info->viewport_height--;
925 win_info->viewport_height = 1;
926 win_info->origin.x = origin_x;
927 win_info->origin.y = origin_y;
930 } /* init_gen_win_info */
932 /* init_and_make_win().
935 init_and_make_win (void *opaque_win_info,
936 enum tui_win_type win_type,
937 int height, int width,
938 int origin_x, int origin_y,
941 struct tui_gen_win_info *generic;
943 if (opaque_win_info == NULL)
945 if (tui_win_is_auxillary (win_type))
946 opaque_win_info = (void *) tui_alloc_generic_win_info ();
948 opaque_win_info = (void *) tui_alloc_win_info (win_type);
950 if (tui_win_is_auxillary (win_type))
951 generic = (struct tui_gen_win_info *) opaque_win_info;
953 generic = &((struct tui_win_info *) opaque_win_info)->generic;
955 if (opaque_win_info != NULL)
957 init_gen_win_info (generic, win_type, height, width, origin_x, origin_y);
958 if (!tui_win_is_auxillary (win_type))
960 if (generic->type == CMD_WIN)
961 ((struct tui_win_info *) opaque_win_info)->can_highlight = FALSE;
963 ((struct tui_win_info *) opaque_win_info)->can_highlight = TRUE;
965 tui_make_window (generic, box_it);
967 return opaque_win_info;
972 make_source_or_disasm_window (struct tui_win_info **win_info_ptr,
973 enum tui_win_type type,
974 int height, int origin_y)
976 struct tui_gen_win_info *execution_info = (struct tui_gen_win_info *) NULL;
978 /* Create the exeuction info window. */
980 execution_info = tui_source_exec_info_win_ptr ();
982 execution_info = tui_disassem_exec_info_win_ptr ();
983 execution_info = init_and_make_win (execution_info,
991 /* Now create the source window. */
992 *win_info_ptr = init_and_make_win (*win_info_ptr,
995 tui_term_width () - execution_info->width,
996 execution_info->width,
1000 (*win_info_ptr)->detail.source_info.execution_info = execution_info;
1004 /* Show the Source/Command or the Disassem layout. */
1006 show_source_or_disasm_and_command (enum tui_layout_type layout_type)
1008 if (tui_current_layout () != layout_type)
1010 struct tui_win_info **win_info_ptr;
1011 int src_height, cmd_height;
1012 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
1014 if (TUI_CMD_WIN != NULL)
1015 cmd_height = TUI_CMD_WIN->generic.height;
1017 cmd_height = tui_term_height () / 3;
1018 src_height = tui_term_height () - cmd_height;
1020 if (layout_type == SRC_COMMAND)
1021 win_info_ptr = &TUI_SRC_WIN;
1023 win_info_ptr = &TUI_DISASM_WIN;
1025 if ((*win_info_ptr) == NULL)
1027 if (layout_type == SRC_COMMAND)
1028 make_source_window (win_info_ptr, src_height - 1, 0);
1030 make_disasm_window (win_info_ptr, src_height - 1, 0);
1031 locator = init_and_make_win (locator,
1041 init_gen_win_info (locator,
1047 (*win_info_ptr)->detail.source_info.has_locator = TRUE;
1048 init_gen_win_info (&(*win_info_ptr)->generic,
1049 (*win_info_ptr)->generic.type,
1051 (*win_info_ptr)->generic.width,
1052 (*win_info_ptr)->detail.source_info.execution_info->width,
1054 init_gen_win_info ((*win_info_ptr)->detail.source_info.execution_info,
1060 (*win_info_ptr)->can_highlight = TRUE;
1061 tui_make_visible (&(*win_info_ptr)->generic);
1062 tui_make_visible ((*win_info_ptr)->detail.source_info.execution_info);
1064 if ((*win_info_ptr) != NULL)
1066 (*win_info_ptr)->detail.source_info.has_locator = TRUE;
1067 tui_make_visible (locator);
1068 tui_show_locator_content ();
1069 tui_show_source_content (*win_info_ptr);
1071 if (TUI_CMD_WIN == NULL)
1073 make_command_window (&TUI_CMD_WIN, cmd_height, src_height);
1074 tui_refresh_win (&TUI_CMD_WIN->generic);
1078 init_gen_win_info (&TUI_CMD_WIN->generic,
1079 TUI_CMD_WIN->generic.type,
1080 TUI_CMD_WIN->generic.height,
1081 TUI_CMD_WIN->generic.width,
1082 TUI_CMD_WIN->generic.origin.x,
1083 TUI_CMD_WIN->generic.origin.y);
1084 TUI_CMD_WIN->can_highlight = FALSE;
1085 tui_make_visible (&TUI_CMD_WIN->generic);
1088 tui_set_current_layout_to (layout_type);