1 /* TUI layout window management.
3 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007
4 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 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., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, 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 *,
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 CORE_ADDR extract_display_start_addr (void);
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 CORE_ADDR addr = extract_display_start_addr ();
148 struct tui_win_info *win_with_focus = tui_win_with_focus ();
149 struct tui_layout_def *layout_def = tui_layout_def ();
152 if (layout_type == UNDEFINED_LAYOUT
153 && regs_display_type != TUI_UNDEFINED_REGS)
155 if (cur_layout == SRC_DISASSEM_COMMAND)
156 new_layout = DISASSEM_DATA_COMMAND;
157 else if (cur_layout == SRC_COMMAND
158 || cur_layout == SRC_DATA_COMMAND)
159 new_layout = SRC_DATA_COMMAND;
160 else if (cur_layout == DISASSEM_COMMAND
161 || cur_layout == DISASSEM_DATA_COMMAND)
162 new_layout = DISASSEM_DATA_COMMAND;
165 new_layout = layout_type;
167 regs_populate = (new_layout == SRC_DATA_COMMAND
168 || new_layout == DISASSEM_DATA_COMMAND
169 || regs_display_type != TUI_UNDEFINED_REGS);
170 if (new_layout != cur_layout
171 || regs_display_type != TUI_UNDEFINED_REGS)
173 if (new_layout != cur_layout)
175 show_layout (new_layout);
177 /* Now determine where focus should be. */
178 if (win_with_focus != TUI_CMD_WIN)
183 tui_set_win_focus_to (TUI_SRC_WIN);
184 layout_def->display_mode = SRC_WIN;
185 layout_def->split = FALSE;
187 case DISASSEM_COMMAND:
188 /* The previous layout was not showing code.
189 This can happen if there is no source
192 1. if the source file is in another dir OR
193 2. if target was compiled without -g
194 We still want to show the assembly though! */
196 addr = tui_get_begin_asm_address ();
197 tui_set_win_focus_to (TUI_DISASM_WIN);
198 layout_def->display_mode = DISASSEM_WIN;
199 layout_def->split = FALSE;
201 case SRC_DISASSEM_COMMAND:
202 /* The previous layout was not showing code.
203 This can happen if there is no source
206 1. if the source file is in another dir OR
207 2. if target was compiled without -g
208 We still want to show the assembly though! */
210 addr = tui_get_begin_asm_address ();
211 if (win_with_focus == TUI_SRC_WIN)
212 tui_set_win_focus_to (TUI_SRC_WIN);
214 tui_set_win_focus_to (TUI_DISASM_WIN);
215 layout_def->split = TRUE;
217 case SRC_DATA_COMMAND:
218 if (win_with_focus != TUI_DATA_WIN)
219 tui_set_win_focus_to (TUI_SRC_WIN);
221 tui_set_win_focus_to (TUI_DATA_WIN);
222 layout_def->display_mode = SRC_WIN;
223 layout_def->split = FALSE;
225 case DISASSEM_DATA_COMMAND:
226 /* The previous layout was not showing code.
227 This can happen if there is no source
230 1. if the source file is in another dir OR
231 2. if target was compiled without -g
232 We still want to show the assembly though! */
234 addr = tui_get_begin_asm_address ();
235 if (win_with_focus != TUI_DATA_WIN)
236 tui_set_win_focus_to (TUI_DISASM_WIN);
238 tui_set_win_focus_to (TUI_DATA_WIN);
239 layout_def->display_mode = DISASSEM_WIN;
240 layout_def->split = FALSE;
247 * Now update the window content.
250 && (new_layout == SRC_DATA_COMMAND
251 || new_layout == DISASSEM_DATA_COMMAND))
252 tui_display_all_data ();
254 tui_update_source_windows_with_addr (addr);
258 tui_show_registers (TUI_DATA_WIN->detail.data_display_info.current_group);
263 status = TUI_FAILURE;
268 /* Add the specified window to the layout in a logical way. This
269 means setting up the most logical layout given the window to be
272 tui_add_win_to_layout (enum tui_win_type type)
274 enum tui_layout_type cur_layout = tui_current_layout ();
279 if (cur_layout != SRC_COMMAND
280 && cur_layout != SRC_DISASSEM_COMMAND
281 && cur_layout != SRC_DATA_COMMAND)
283 tui_clear_source_windows_detail ();
284 if (cur_layout == DISASSEM_DATA_COMMAND)
285 show_layout (SRC_DATA_COMMAND);
287 show_layout (SRC_COMMAND);
291 if (cur_layout != DISASSEM_COMMAND
292 && cur_layout != SRC_DISASSEM_COMMAND
293 && cur_layout != DISASSEM_DATA_COMMAND)
295 tui_clear_source_windows_detail ();
296 if (cur_layout == SRC_DATA_COMMAND)
297 show_layout (DISASSEM_DATA_COMMAND);
299 show_layout (DISASSEM_COMMAND);
303 if (cur_layout != SRC_DATA_COMMAND
304 && cur_layout != DISASSEM_DATA_COMMAND)
306 if (cur_layout == DISASSEM_COMMAND)
307 show_layout (DISASSEM_DATA_COMMAND);
309 show_layout (SRC_DATA_COMMAND);
318 /* Answer the height of a window. If it hasn't been created yet,
319 answer what the height of a window would be based upon its type and
322 tui_default_win_height (enum tui_win_type type,
323 enum tui_layout_type layout)
327 if (tui_win_list[type] != (struct tui_win_info *) NULL)
328 h = tui_win_list[type]->generic.height;
334 case DISASSEM_COMMAND:
335 if (TUI_CMD_WIN == NULL)
336 h = tui_term_height () / 2;
338 h = tui_term_height () - TUI_CMD_WIN->generic.height;
340 case SRC_DISASSEM_COMMAND:
341 case SRC_DATA_COMMAND:
342 case DISASSEM_DATA_COMMAND:
343 if (TUI_CMD_WIN == NULL)
344 h = tui_term_height () / 3;
346 h = (tui_term_height () - TUI_CMD_WIN->generic.height) / 2;
358 /* Answer the height of a window. If it hasn't been created yet,
359 answer what the height of a window would be based upon its type and
362 tui_default_win_viewport_height (enum tui_win_type type,
363 enum tui_layout_type layout)
367 h = tui_default_win_height (type, layout);
369 if (tui_win_list[type] == TUI_CMD_WIN)
378 /* Function to initialize gdb commands, for tui window layout
381 _initialize_tui_layout (void)
383 add_com ("layout", class_tui, tui_layout_command, _("\
384 Change the layout of windows.\n\
385 Usage: layout prev | next | <layout_name> \n\
387 src : Displays source and command windows.\n\
388 asm : Displays disassembly and command windows.\n\
389 split : Displays source, disassembly and command windows.\n\
390 regs : Displays register window. If existing layout\n\
391 is source/command or assembly/command, the \n\
392 register window is displayed. If the\n\
393 source/assembly/command (split) is displayed, \n\
394 the register window is displayed with \n\
395 the window that has current logical focus.\n"));
398 add_com ("td", class_tui, tui_toggle_layout_command, _("\
399 Toggle between Source/Command and Disassembly/Command layouts.\n"));
400 add_com ("ts", class_tui, tui_toggle_split_layout_command, _("\
401 Toggle between Source/Command or Disassembly/Command and \n\
402 Source/Disassembly/Command layouts.\n"));
407 /*************************
408 ** STATIC LOCAL FUNCTIONS
409 **************************/
412 /* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
413 REGS, $REGS, $GREGS, $FREGS, $SREGS. */
415 tui_set_layout_for_display_command (const char *layout_name)
417 enum tui_status status = TUI_SUCCESS;
419 if (layout_name != (char *) NULL)
423 enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
424 enum tui_register_display_type dpy_type = TUI_UNDEFINED_REGS;
425 enum tui_layout_type cur_layout = tui_current_layout ();
427 buf_ptr = (char *) xstrdup (layout_name);
428 for (i = 0; (i < strlen (layout_name)); i++)
429 buf_ptr[i] = toupper (buf_ptr[i]);
431 /* First check for ambiguous input. */
432 if (strlen (buf_ptr) <= 1
433 && (*buf_ptr == 'S' || *buf_ptr == '$'))
435 warning (_("Ambiguous command input."));
436 status = TUI_FAILURE;
440 if (subset_compare (buf_ptr, "SRC"))
441 new_layout = SRC_COMMAND;
442 else if (subset_compare (buf_ptr, "ASM"))
443 new_layout = DISASSEM_COMMAND;
444 else if (subset_compare (buf_ptr, "SPLIT"))
445 new_layout = SRC_DISASSEM_COMMAND;
446 else if (subset_compare (buf_ptr, "REGS")
447 || subset_compare (buf_ptr, TUI_GENERAL_SPECIAL_REGS_NAME)
448 || subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME)
449 || subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME)
450 || subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
452 if (cur_layout == SRC_COMMAND
453 || cur_layout == SRC_DATA_COMMAND)
454 new_layout = SRC_DATA_COMMAND;
456 new_layout = DISASSEM_DATA_COMMAND;
458 /* Could ifdef out the following code. when compile with
459 -z, there are null pointer references that cause a
460 core dump if 'layout regs' is the first layout
461 command issued by the user. HP has asked us to hook
462 up this code. - edie epstein */
463 if (subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME))
465 if (TUI_DATA_WIN->detail.data_display_info.regs_display_type != TUI_SFLOAT_REGS
466 && TUI_DATA_WIN->detail.data_display_info.regs_display_type != TUI_DFLOAT_REGS)
467 dpy_type = TUI_SFLOAT_REGS;
470 TUI_DATA_WIN->detail.data_display_info.regs_display_type;
472 else if (subset_compare (buf_ptr,
473 TUI_GENERAL_SPECIAL_REGS_NAME))
474 dpy_type = TUI_GENERAL_AND_SPECIAL_REGS;
475 else if (subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME))
476 dpy_type = TUI_GENERAL_REGS;
477 else if (subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
478 dpy_type = TUI_SPECIAL_REGS;
479 else if (TUI_DATA_WIN)
481 if (TUI_DATA_WIN->detail.data_display_info.regs_display_type !=
484 TUI_DATA_WIN->detail.data_display_info.regs_display_type;
486 dpy_type = TUI_GENERAL_REGS;
489 /* End of potential ifdef.
492 /* If ifdefed out code above, then assume that the user
493 wishes to display the general purpose registers .
496 /* dpy_type = TUI_GENERAL_REGS; */
498 else if (subset_compare (buf_ptr, "NEXT"))
499 new_layout = next_layout ();
500 else if (subset_compare (buf_ptr, "PREV"))
501 new_layout = prev_layout ();
503 status = TUI_FAILURE;
505 tui_set_layout (new_layout, dpy_type);
510 status = TUI_FAILURE;
517 extract_display_start_addr (void)
519 enum tui_layout_type cur_layout = tui_current_layout ();
522 struct symtab_and_line cursal = get_current_source_symtab_and_line ();
527 case SRC_DATA_COMMAND:
528 find_line_pc (cursal.symtab,
529 TUI_SRC_WIN->detail.source_info.start_line_or_addr.u.line_no,
533 case DISASSEM_COMMAND:
534 case SRC_DISASSEM_COMMAND:
535 case DISASSEM_DATA_COMMAND:
536 addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr;
548 tui_handle_xdb_layout (struct tui_layout_def *layout_def)
550 if (layout_def->split)
552 tui_set_layout (SRC_DISASSEM_COMMAND, TUI_UNDEFINED_REGS);
553 tui_set_win_focus_to (tui_win_list[layout_def->display_mode]);
557 if (layout_def->display_mode == SRC_WIN)
558 tui_set_layout (SRC_COMMAND, TUI_UNDEFINED_REGS);
560 tui_set_layout (DISASSEM_DATA_COMMAND, layout_def->regs_display_type);
566 tui_toggle_layout_command (char *arg, int from_tty)
568 struct tui_layout_def *layout_def = tui_layout_def ();
570 /* Make sure the curses mode is enabled. */
572 if (layout_def->display_mode == SRC_WIN)
573 layout_def->display_mode = DISASSEM_WIN;
575 layout_def->display_mode = SRC_WIN;
577 if (!layout_def->split)
578 tui_handle_xdb_layout (layout_def);
583 tui_toggle_split_layout_command (char *arg, int from_tty)
585 struct tui_layout_def *layout_def = tui_layout_def ();
587 /* Make sure the curses mode is enabled. */
589 layout_def->split = (!layout_def->split);
590 tui_handle_xdb_layout (layout_def);
595 tui_layout_command (char *arg, int from_tty)
597 /* Make sure the curses mode is enabled. */
600 /* Switch to the selected layout. */
601 if (tui_set_layout_for_display_command (arg) != TUI_SUCCESS)
602 warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE);
606 /* Answer the previous layout to cycle to. */
607 static enum tui_layout_type
610 enum tui_layout_type new_layout;
612 new_layout = tui_current_layout ();
613 if (new_layout == UNDEFINED_LAYOUT)
614 new_layout = SRC_COMMAND;
618 if (new_layout == UNDEFINED_LAYOUT)
619 new_layout = SRC_COMMAND;
626 /* Answer the next layout to cycle to. */
627 static enum tui_layout_type
630 enum tui_layout_type new_layout;
632 new_layout = tui_current_layout ();
633 if (new_layout == SRC_COMMAND)
634 new_layout = DISASSEM_DATA_COMMAND;
638 if (new_layout == UNDEFINED_LAYOUT)
639 new_layout = DISASSEM_DATA_COMMAND;
648 make_command_window (struct tui_win_info **win_info_ptr,
649 int height, int origin_y)
651 *win_info_ptr = init_and_make_win (*win_info_ptr,
659 (*win_info_ptr)->can_highlight = FALSE;
663 /* make_source_window().
666 make_source_window (struct tui_win_info **win_info_ptr,
667 int height, int origin_y)
669 make_source_or_disasm_window (win_info_ptr, SRC_WIN, height, origin_y);
672 } /* make_source_window */
675 /* make_disasm_window().
678 make_disasm_window (struct tui_win_info **win_info_ptr,
679 int height, int origin_y)
681 make_source_or_disasm_window (win_info_ptr, DISASSEM_WIN, height, origin_y);
684 } /* make_disasm_window */
688 make_data_window (struct tui_win_info **win_info_ptr,
689 int height, int origin_y)
691 *win_info_ptr = init_and_make_win (*win_info_ptr,
702 /* Show the Source/Command layout. */
704 show_source_command (void)
706 show_source_or_disasm_and_command (SRC_COMMAND);
710 /* Show the Dissassem/Command layout. */
712 show_disasm_command (void)
714 show_source_or_disasm_and_command (DISASSEM_COMMAND);
718 /* Show the Source/Disassem/Command layout. */
720 show_source_disasm_command (void)
722 if (tui_current_layout () != SRC_DISASSEM_COMMAND)
724 int cmd_height, src_height, asm_height;
726 if (TUI_CMD_WIN != NULL)
727 cmd_height = TUI_CMD_WIN->generic.height;
729 cmd_height = tui_term_height () / 3;
731 src_height = (tui_term_height () - cmd_height) / 2;
732 asm_height = tui_term_height () - (src_height + cmd_height);
734 if (TUI_SRC_WIN == NULL)
735 make_source_window (&TUI_SRC_WIN, src_height, 0);
738 init_gen_win_info (&TUI_SRC_WIN->generic,
739 TUI_SRC_WIN->generic.type,
741 TUI_SRC_WIN->generic.width,
742 TUI_SRC_WIN->detail.source_info.execution_info->width,
744 TUI_SRC_WIN->can_highlight = TRUE;
745 init_gen_win_info (TUI_SRC_WIN->detail.source_info.execution_info,
751 tui_make_visible (&TUI_SRC_WIN->generic);
752 tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info);
753 TUI_SRC_WIN->detail.source_info.has_locator = FALSE;;
755 if (TUI_SRC_WIN != NULL)
757 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
759 tui_show_source_content (TUI_SRC_WIN);
760 if (TUI_DISASM_WIN == NULL)
762 make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1);
763 locator = init_and_make_win (locator,
768 (src_height + asm_height) - 1,
773 init_gen_win_info (locator,
778 (src_height + asm_height) - 1);
779 TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
780 init_gen_win_info (&TUI_DISASM_WIN->generic,
781 TUI_DISASM_WIN->generic.type,
783 TUI_DISASM_WIN->generic.width,
784 TUI_DISASM_WIN->detail.source_info.execution_info->width,
786 init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info,
792 TUI_DISASM_WIN->can_highlight = TRUE;
793 tui_make_visible (&TUI_DISASM_WIN->generic);
794 tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
796 if (TUI_DISASM_WIN != NULL)
798 TUI_SRC_WIN->detail.source_info.has_locator = FALSE;
799 TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
800 tui_make_visible (locator);
801 tui_show_locator_content ();
802 tui_show_source_content (TUI_DISASM_WIN);
804 if (TUI_CMD_WIN == NULL)
805 make_command_window (&TUI_CMD_WIN,
807 tui_term_height () - cmd_height);
810 init_gen_win_info (&TUI_CMD_WIN->generic,
811 TUI_CMD_WIN->generic.type,
812 TUI_CMD_WIN->generic.height,
813 TUI_CMD_WIN->generic.width,
815 TUI_CMD_WIN->generic.origin.y);
816 TUI_CMD_WIN->can_highlight = FALSE;
817 tui_make_visible (&TUI_CMD_WIN->generic);
819 if (TUI_CMD_WIN != NULL)
820 tui_refresh_win (&TUI_CMD_WIN->generic);
823 tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
828 /* Show the Source/Data/Command or the Dissassembly/Data/Command
831 show_data (enum tui_layout_type new_layout)
833 int total_height = (tui_term_height () - TUI_CMD_WIN->generic.height);
834 int src_height, data_height;
835 enum tui_win_type win_type;
836 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
839 data_height = total_height / 2;
840 src_height = total_height - data_height;
841 tui_make_all_invisible ();
842 tui_make_invisible (locator);
843 make_data_window (&TUI_DATA_WIN, data_height, 0);
844 TUI_DATA_WIN->can_highlight = TRUE;
845 if (new_layout == SRC_DATA_COMMAND)
848 win_type = DISASSEM_WIN;
849 if (tui_win_list[win_type] == NULL)
851 if (win_type == SRC_WIN)
852 make_source_window (&tui_win_list[win_type], src_height, data_height - 1);
854 make_disasm_window (&tui_win_list[win_type], src_height, data_height - 1);
855 locator = init_and_make_win (locator,
865 init_gen_win_info (&tui_win_list[win_type]->generic,
866 tui_win_list[win_type]->generic.type,
868 tui_win_list[win_type]->generic.width,
869 tui_win_list[win_type]->detail.source_info.execution_info->width,
871 init_gen_win_info (tui_win_list[win_type]->detail.source_info.execution_info,
877 tui_make_visible (&tui_win_list[win_type]->generic);
878 tui_make_visible (tui_win_list[win_type]->detail.source_info.execution_info);
879 init_gen_win_info (locator,
886 tui_win_list[win_type]->detail.source_info.has_locator = TRUE;
887 tui_make_visible (locator);
888 tui_show_locator_content ();
889 tui_add_to_source_windows (tui_win_list[win_type]);
890 tui_set_current_layout_to (new_layout);
893 /* init_gen_win_info().
896 init_gen_win_info (struct tui_gen_win_info *win_info,
897 enum tui_win_type type,
898 int height, int width,
899 int origin_x, int origin_y)
903 win_info->type = type;
904 win_info->width = width;
905 win_info->height = h;
908 win_info->viewport_height = h - 1;
909 if (win_info->type != CMD_WIN)
910 win_info->viewport_height--;
913 win_info->viewport_height = 1;
914 win_info->origin.x = origin_x;
915 win_info->origin.y = origin_y;
918 } /* init_gen_win_info */
920 /* init_and_make_win().
923 init_and_make_win (void *opaque_win_info,
924 enum tui_win_type win_type,
925 int height, int width,
926 int origin_x, int origin_y,
929 struct tui_gen_win_info *generic;
931 if (opaque_win_info == NULL)
933 if (tui_win_is_auxillary (win_type))
934 opaque_win_info = (void *) tui_alloc_generic_win_info ();
936 opaque_win_info = (void *) tui_alloc_win_info (win_type);
938 if (tui_win_is_auxillary (win_type))
939 generic = (struct tui_gen_win_info *) opaque_win_info;
941 generic = &((struct tui_win_info *) opaque_win_info)->generic;
943 if (opaque_win_info != NULL)
945 init_gen_win_info (generic, win_type, height, width, origin_x, origin_y);
946 if (!tui_win_is_auxillary (win_type))
948 if (generic->type == CMD_WIN)
949 ((struct tui_win_info *) opaque_win_info)->can_highlight = FALSE;
951 ((struct tui_win_info *) opaque_win_info)->can_highlight = TRUE;
953 tui_make_window (generic, box_it);
955 return opaque_win_info;
960 make_source_or_disasm_window (struct tui_win_info **win_info_ptr,
961 enum tui_win_type type,
962 int height, int origin_y)
964 struct tui_gen_win_info *execution_info = (struct tui_gen_win_info *) NULL;
966 /* Create the exeuction info window. */
968 execution_info = tui_source_exec_info_win_ptr ();
970 execution_info = tui_disassem_exec_info_win_ptr ();
971 execution_info = init_and_make_win (execution_info,
979 /* Now create the source window. */
980 *win_info_ptr = init_and_make_win (*win_info_ptr,
983 tui_term_width () - execution_info->width,
984 execution_info->width,
988 (*win_info_ptr)->detail.source_info.execution_info = execution_info;
992 /* Show the Source/Command or the Disassem layout. */
994 show_source_or_disasm_and_command (enum tui_layout_type layout_type)
996 if (tui_current_layout () != layout_type)
998 struct tui_win_info **win_info_ptr;
999 int src_height, cmd_height;
1000 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
1002 if (TUI_CMD_WIN != NULL)
1003 cmd_height = TUI_CMD_WIN->generic.height;
1005 cmd_height = tui_term_height () / 3;
1006 src_height = tui_term_height () - cmd_height;
1008 if (layout_type == SRC_COMMAND)
1009 win_info_ptr = &TUI_SRC_WIN;
1011 win_info_ptr = &TUI_DISASM_WIN;
1013 if ((*win_info_ptr) == NULL)
1015 if (layout_type == SRC_COMMAND)
1016 make_source_window (win_info_ptr, src_height - 1, 0);
1018 make_disasm_window (win_info_ptr, src_height - 1, 0);
1019 locator = init_and_make_win (locator,
1029 init_gen_win_info (locator,
1035 (*win_info_ptr)->detail.source_info.has_locator = TRUE;
1036 init_gen_win_info (&(*win_info_ptr)->generic,
1037 (*win_info_ptr)->generic.type,
1039 (*win_info_ptr)->generic.width,
1040 (*win_info_ptr)->detail.source_info.execution_info->width,
1042 init_gen_win_info ((*win_info_ptr)->detail.source_info.execution_info,
1048 (*win_info_ptr)->can_highlight = TRUE;
1049 tui_make_visible (&(*win_info_ptr)->generic);
1050 tui_make_visible ((*win_info_ptr)->detail.source_info.execution_info);
1052 if ((*win_info_ptr) != NULL)
1054 (*win_info_ptr)->detail.source_info.has_locator = TRUE;
1055 tui_make_visible (locator);
1056 tui_show_locator_content ();
1057 tui_show_source_content (*win_info_ptr);
1059 if (TUI_CMD_WIN == NULL)
1061 make_command_window (&TUI_CMD_WIN, cmd_height, src_height);
1062 tui_refresh_win (&TUI_CMD_WIN->generic);
1066 init_gen_win_info (&TUI_CMD_WIN->generic,
1067 TUI_CMD_WIN->generic.type,
1068 TUI_CMD_WIN->generic.height,
1069 TUI_CMD_WIN->generic.width,
1070 TUI_CMD_WIN->generic.origin.x,
1071 TUI_CMD_WIN->generic.origin.y);
1072 TUI_CMD_WIN->can_highlight = FALSE;
1073 tui_make_visible (&TUI_CMD_WIN->generic);
1076 tui_set_current_layout_to (layout_type);