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
|| 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
|| regs_display_type
!= TUI_UNDEFINED_REGS
)
142 enum tui_layout_type cur_layout
= tui_current_layout (), new_layout
= UNDEFINED_LAYOUT
;
143 int regs_populate
= FALSE
;
144 CORE_ADDR addr
= extract_display_start_addr ();
145 struct tui_win_info
*win_with_focus
= tui_win_with_focus ();
146 struct tui_layout_def
*layout_def
= tui_layout_def ();
149 if (layout_type
== UNDEFINED_LAYOUT
&&
150 regs_display_type
!= TUI_UNDEFINED_REGS
)
152 if (cur_layout
== SRC_DISASSEM_COMMAND
)
153 new_layout
= DISASSEM_DATA_COMMAND
;
154 else if (cur_layout
== SRC_COMMAND
|| cur_layout
== SRC_DATA_COMMAND
)
155 new_layout
= SRC_DATA_COMMAND
;
156 else if (cur_layout
== DISASSEM_COMMAND
||
157 cur_layout
== DISASSEM_DATA_COMMAND
)
158 new_layout
= DISASSEM_DATA_COMMAND
;
161 new_layout
= layout_type
;
163 regs_populate
= (new_layout
== SRC_DATA_COMMAND
||
164 new_layout
== DISASSEM_DATA_COMMAND
||
165 regs_display_type
!= TUI_UNDEFINED_REGS
);
166 if (new_layout
!= cur_layout
|| regs_display_type
!= TUI_UNDEFINED_REGS
)
168 if (new_layout
!= cur_layout
)
170 show_layout (new_layout
);
172 /* Now determine where focus should be. */
173 if (win_with_focus
!= TUI_CMD_WIN
)
178 tui_set_win_focus_to (TUI_SRC_WIN
);
179 layout_def
->display_mode
= SRC_WIN
;
180 layout_def
->split
= FALSE
;
182 case DISASSEM_COMMAND
:
183 /* The previous layout was not showing code.
184 This can happen if there is no source
187 1. if the source file is in another dir OR
188 2. if target was compiled without -g
189 We still want to show the assembly though! */
191 addr
= tui_get_begin_asm_address ();
192 tui_set_win_focus_to (TUI_DISASM_WIN
);
193 layout_def
->display_mode
= DISASSEM_WIN
;
194 layout_def
->split
= FALSE
;
196 case SRC_DISASSEM_COMMAND
:
197 /* The previous layout was not showing code.
198 This can happen if there is no source
201 1. if the source file is in another dir OR
202 2. if target was compiled without -g
203 We still want to show the assembly though! */
205 addr
= tui_get_begin_asm_address ();
206 if (win_with_focus
== TUI_SRC_WIN
)
207 tui_set_win_focus_to (TUI_SRC_WIN
);
209 tui_set_win_focus_to (TUI_DISASM_WIN
);
210 layout_def
->split
= TRUE
;
212 case SRC_DATA_COMMAND
:
213 if (win_with_focus
!= TUI_DATA_WIN
)
214 tui_set_win_focus_to (TUI_SRC_WIN
);
216 tui_set_win_focus_to (TUI_DATA_WIN
);
217 layout_def
->display_mode
= SRC_WIN
;
218 layout_def
->split
= FALSE
;
220 case DISASSEM_DATA_COMMAND
:
221 /* The previous layout was not showing code.
222 This can happen if there is no source
225 1. if the source file is in another dir OR
226 2. if target was compiled without -g
227 We still want to show the assembly though! */
229 addr
= tui_get_begin_asm_address ();
230 if (win_with_focus
!= TUI_DATA_WIN
)
231 tui_set_win_focus_to (TUI_DISASM_WIN
);
233 tui_set_win_focus_to (TUI_DATA_WIN
);
234 layout_def
->display_mode
= DISASSEM_WIN
;
235 layout_def
->split
= FALSE
;
242 * Now update the window content.
244 if (!regs_populate
&&
245 (new_layout
== SRC_DATA_COMMAND
||
246 new_layout
== DISASSEM_DATA_COMMAND
))
247 tui_display_all_data ();
249 tui_update_source_windows_with_addr (addr
);
253 tui_show_registers (TUI_DATA_WIN
->detail
.data_display_info
.current_group
);
258 status
= TUI_FAILURE
;
263 /* Add the specified window to the layout in a logical way. This
264 means setting up the most logical layout given the window to be
267 tui_add_win_to_layout (enum tui_win_type type
)
269 enum tui_layout_type cur_layout
= tui_current_layout ();
274 if (cur_layout
!= SRC_COMMAND
&&
275 cur_layout
!= SRC_DISASSEM_COMMAND
&&
276 cur_layout
!= SRC_DATA_COMMAND
)
278 tui_clear_source_windows_detail ();
279 if (cur_layout
== DISASSEM_DATA_COMMAND
)
280 show_layout (SRC_DATA_COMMAND
);
282 show_layout (SRC_COMMAND
);
286 if (cur_layout
!= DISASSEM_COMMAND
&&
287 cur_layout
!= SRC_DISASSEM_COMMAND
&&
288 cur_layout
!= DISASSEM_DATA_COMMAND
)
290 tui_clear_source_windows_detail ();
291 if (cur_layout
== SRC_DATA_COMMAND
)
292 show_layout (DISASSEM_DATA_COMMAND
);
294 show_layout (DISASSEM_COMMAND
);
298 if (cur_layout
!= SRC_DATA_COMMAND
&&
299 cur_layout
!= DISASSEM_DATA_COMMAND
)
301 if (cur_layout
== DISASSEM_COMMAND
)
302 show_layout (DISASSEM_DATA_COMMAND
);
304 show_layout (SRC_DATA_COMMAND
);
313 /* Answer the height of a window. If it hasn't been created yet,
314 answer what the height of a window would be based upon its type and
317 tui_default_win_height (enum tui_win_type type
,
318 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."));
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
452 -z, there are null pointer references that cause a
453 core dump if 'layout regs' is the first layout
454 command issued by the user. HP has asked us to hook
455 up this code. - edie epstein */
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
488 wishes to display the general purpose registers .
491 /* dpy_type = TUI_GENERAL_REGS; */
493 else if (subset_compare (buf_ptr
, "NEXT"))
494 new_layout
= next_layout ();
495 else if (subset_compare (buf_ptr
, "PREV"))
496 new_layout
= prev_layout ();
498 status
= TUI_FAILURE
;
500 tui_set_layout (new_layout
, dpy_type
);
505 status
= TUI_FAILURE
;
512 extract_display_start_addr (void)
514 enum tui_layout_type cur_layout
= tui_current_layout ();
517 struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
522 case SRC_DATA_COMMAND
:
523 find_line_pc (cursal
.symtab
,
524 TUI_SRC_WIN
->detail
.source_info
.start_line_or_addr
.u
.line_no
,
528 case DISASSEM_COMMAND
:
529 case SRC_DISASSEM_COMMAND
:
530 case DISASSEM_DATA_COMMAND
:
531 addr
= TUI_DISASM_WIN
->detail
.source_info
.start_line_or_addr
.u
.addr
;
543 tui_handle_xdb_layout (struct tui_layout_def
*layout_def
)
545 if (layout_def
->split
)
547 tui_set_layout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
548 tui_set_win_focus_to (tui_win_list
[layout_def
->display_mode
]);
552 if (layout_def
->display_mode
== SRC_WIN
)
553 tui_set_layout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
555 tui_set_layout (DISASSEM_DATA_COMMAND
, layout_def
->regs_display_type
);
561 tui_toggle_layout_command (char *arg
, int from_tty
)
563 struct tui_layout_def
*layout_def
= tui_layout_def ();
565 /* Make sure the curses mode is enabled. */
567 if (layout_def
->display_mode
== SRC_WIN
)
568 layout_def
->display_mode
= DISASSEM_WIN
;
570 layout_def
->display_mode
= SRC_WIN
;
572 if (!layout_def
->split
)
573 tui_handle_xdb_layout (layout_def
);
578 tui_toggle_split_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 layout_def
->split
= (!layout_def
->split
);
585 tui_handle_xdb_layout (layout_def
);
590 tui_layout_command (char *arg
, int from_tty
)
592 /* Make sure the curses mode is enabled. */
595 /* Switch to the selected layout. */
596 if (tui_set_layout_for_display_command (arg
) != TUI_SUCCESS
)
597 warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE
);
601 /* Answer the previous layout to cycle to. */
602 static enum tui_layout_type
605 enum tui_layout_type new_layout
;
607 new_layout
= tui_current_layout ();
608 if (new_layout
== UNDEFINED_LAYOUT
)
609 new_layout
= SRC_COMMAND
;
613 if (new_layout
== UNDEFINED_LAYOUT
)
614 new_layout
= SRC_COMMAND
;
621 /* Answer the next layout to cycle to. */
622 static enum tui_layout_type
625 enum tui_layout_type new_layout
;
627 new_layout
= tui_current_layout ();
628 if (new_layout
== SRC_COMMAND
)
629 new_layout
= DISASSEM_DATA_COMMAND
;
633 if (new_layout
== UNDEFINED_LAYOUT
)
634 new_layout
= DISASSEM_DATA_COMMAND
;
643 make_command_window (struct tui_win_info
**win_info_ptr
,
644 int height
, int origin_y
)
646 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
654 (*win_info_ptr
)->can_highlight
= FALSE
;
658 /* make_source_window().
661 make_source_window (struct tui_win_info
**win_info_ptr
,
662 int height
, int origin_y
)
664 make_source_or_disasm_window (win_info_ptr
, SRC_WIN
, height
, origin_y
);
667 } /* make_source_window */
670 /* make_disasm_window().
673 make_disasm_window (struct tui_win_info
**win_info_ptr
,
674 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
,
684 int height
, int origin_y
)
686 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
697 /* Show the Source/Command layout. */
699 show_source_command (void)
701 show_source_or_disasm_and_command (SRC_COMMAND
);
705 /* Show the Dissassem/Command layout. */
707 show_disasm_command (void)
709 show_source_or_disasm_and_command (DISASSEM_COMMAND
);
713 /* Show the Source/Disassem/Command layout. */
715 show_source_disasm_command (void)
717 if (tui_current_layout () != SRC_DISASSEM_COMMAND
)
719 int cmd_height
, src_height
, asm_height
;
721 if (TUI_CMD_WIN
!= NULL
)
722 cmd_height
= TUI_CMD_WIN
->generic
.height
;
724 cmd_height
= tui_term_height () / 3;
726 src_height
= (tui_term_height () - cmd_height
) / 2;
727 asm_height
= tui_term_height () - (src_height
+ cmd_height
);
729 if (TUI_SRC_WIN
== NULL
)
730 make_source_window (&TUI_SRC_WIN
, src_height
, 0);
733 init_gen_win_info (&TUI_SRC_WIN
->generic
,
734 TUI_SRC_WIN
->generic
.type
,
736 TUI_SRC_WIN
->generic
.width
,
737 TUI_SRC_WIN
->detail
.source_info
.execution_info
->width
,
739 TUI_SRC_WIN
->can_highlight
= TRUE
;
740 init_gen_win_info (TUI_SRC_WIN
->detail
.source_info
.execution_info
,
746 tui_make_visible (&TUI_SRC_WIN
->generic
);
747 tui_make_visible (TUI_SRC_WIN
->detail
.source_info
.execution_info
);
748 TUI_SRC_WIN
->detail
.source_info
.has_locator
= FALSE
;;
750 if (TUI_SRC_WIN
!= NULL
)
752 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
754 tui_show_source_content (TUI_SRC_WIN
);
755 if (TUI_DISASM_WIN
== NULL
)
757 make_disasm_window (&TUI_DISASM_WIN
, asm_height
, src_height
- 1);
758 locator
= init_and_make_win (locator
,
763 (src_height
+ asm_height
) - 1,
768 init_gen_win_info (locator
,
773 (src_height
+ asm_height
) - 1);
774 TUI_DISASM_WIN
->detail
.source_info
.has_locator
= TRUE
;
775 init_gen_win_info (&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 locator
= init_and_make_win (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
);
888 /* init_gen_win_info().
891 init_gen_win_info (struct tui_gen_win_info
*win_info
,
892 enum tui_win_type type
,
893 int height
, int width
,
894 int origin_x
, int origin_y
)
898 win_info
->type
= type
;
899 win_info
->width
= width
;
900 win_info
->height
= h
;
903 win_info
->viewport_height
= h
- 1;
904 if (win_info
->type
!= CMD_WIN
)
905 win_info
->viewport_height
--;
908 win_info
->viewport_height
= 1;
909 win_info
->origin
.x
= origin_x
;
910 win_info
->origin
.y
= origin_y
;
913 } /* init_gen_win_info */
915 /* init_and_make_win().
918 init_and_make_win (void *opaque_win_info
,
919 enum tui_win_type win_type
,
920 int height
, int width
,
921 int origin_x
, int origin_y
,
924 struct tui_gen_win_info
*generic
;
926 if (opaque_win_info
== NULL
)
928 if (tui_win_is_auxillary (win_type
))
929 opaque_win_info
= (void *) tui_alloc_generic_win_info ();
931 opaque_win_info
= (void *) tui_alloc_win_info (win_type
);
933 if (tui_win_is_auxillary (win_type
))
934 generic
= (struct tui_gen_win_info
*) opaque_win_info
;
936 generic
= &((struct tui_win_info
*) opaque_win_info
)->generic
;
938 if (opaque_win_info
!= NULL
)
940 init_gen_win_info (generic
, win_type
, height
, width
, origin_x
, origin_y
);
941 if (!tui_win_is_auxillary (win_type
))
943 if (generic
->type
== CMD_WIN
)
944 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= FALSE
;
946 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= TRUE
;
948 tui_make_window (generic
, box_it
);
950 return opaque_win_info
;
955 make_source_or_disasm_window (struct tui_win_info
**win_info_ptr
,
956 enum tui_win_type type
,
957 int height
, int origin_y
)
959 struct tui_gen_win_info
*execution_info
= (struct tui_gen_win_info
*) NULL
;
961 /* Create the exeuction info window. */
963 execution_info
= tui_source_exec_info_win_ptr ();
965 execution_info
= tui_disassem_exec_info_win_ptr ();
966 execution_info
= init_and_make_win (execution_info
,
974 /* Now create the source window. */
975 *win_info_ptr
= init_and_make_win (*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
;
1003 if (layout_type
== SRC_COMMAND
)
1004 win_info_ptr
= &TUI_SRC_WIN
;
1006 win_info_ptr
= &TUI_DISASM_WIN
;
1008 if ((*win_info_ptr
) == NULL
)
1010 if (layout_type
== SRC_COMMAND
)
1011 make_source_window (win_info_ptr
, src_height
- 1, 0);
1013 make_disasm_window (win_info_ptr
, src_height
- 1, 0);
1014 locator
= init_and_make_win (locator
,
1024 init_gen_win_info (locator
,
1030 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
1031 init_gen_win_info (&(*win_info_ptr
)->generic
,
1032 (*win_info_ptr
)->generic
.type
,
1034 (*win_info_ptr
)->generic
.width
,
1035 (*win_info_ptr
)->detail
.source_info
.execution_info
->width
,
1037 init_gen_win_info ((*win_info_ptr
)->detail
.source_info
.execution_info
,
1043 (*win_info_ptr
)->can_highlight
= TRUE
;
1044 tui_make_visible (&(*win_info_ptr
)->generic
);
1045 tui_make_visible ((*win_info_ptr
)->detail
.source_info
.execution_info
);
1047 if ((*win_info_ptr
) != NULL
)
1049 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
1050 tui_make_visible (locator
);
1051 tui_show_locator_content ();
1052 tui_show_source_content (*win_info_ptr
);
1054 if (TUI_CMD_WIN
== NULL
)
1056 make_command_window (&TUI_CMD_WIN
, cmd_height
, src_height
);
1057 tui_refresh_win (&TUI_CMD_WIN
->generic
);
1061 init_gen_win_info (&TUI_CMD_WIN
->generic
,
1062 TUI_CMD_WIN
->generic
.type
,
1063 TUI_CMD_WIN
->generic
.height
,
1064 TUI_CMD_WIN
->generic
.width
,
1065 TUI_CMD_WIN
->generic
.origin
.x
,
1066 TUI_CMD_WIN
->generic
.origin
.y
);
1067 TUI_CMD_WIN
->can_highlight
= FALSE
;
1068 tui_make_visible (&TUI_CMD_WIN
->generic
);
1071 tui_set_current_layout_to (layout_type
);