1 /* TUI layout window management.
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
6 Contributed by Hewlett-Packard Company.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
33 #include "tui/tui-data.h"
34 #include "tui/tui-windata.h"
35 #include "tui/tui-wingeneral.h"
36 #include "tui/tui-stack.h"
37 #include "tui/tui-regs.h"
38 #include "tui/tui-win.h"
39 #include "tui/tui-winsource.h"
40 #include "tui/tui-disasm.h"
50 /*******************************
52 ********************************/
53 static void show_layout (enum tui_layout_type
);
54 static void init_gen_win_info (struct tui_gen_win_info
*, enum tui_win_type
, int, int, int, int);
55 static void init_and_make_win (void **, enum tui_win_type
, int, int, int, int, int);
56 static void show_source_or_disasm_and_command (enum tui_layout_type
);
57 static void make_source_or_disasm_window (struct tui_win_info
* *, enum tui_win_type
, int, int);
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
)
90 ** Since the new layout may cause changes in window size, we
91 ** should free the content and reallocate on next display of
94 tui_free_all_source_wins_content ();
95 tui_clear_source_windows ();
96 if (layout
== SRC_DATA_COMMAND
|| layout
== DISASSEM_DATA_COMMAND
)
99 tui_refresh_all (tui_win_list
);
103 /* First make the current layout be invisible */
104 tui_make_all_invisible ();
105 tui_make_invisible (tui_locator_win_info_ptr ());
109 /* Now show the new layout */
111 show_source_command ();
112 tui_add_to_source_windows (TUI_SRC_WIN
);
114 case DISASSEM_COMMAND
:
115 show_disasm_command ();
116 tui_add_to_source_windows (TUI_DISASM_WIN
);
118 case SRC_DISASSEM_COMMAND
:
119 show_source_disasm_command ();
120 tui_add_to_source_windows (TUI_SRC_WIN
);
121 tui_add_to_source_windows (TUI_DISASM_WIN
);
131 /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
132 SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
133 If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
134 UNDEFINED_LAYOUT, then the data window is populated according to
135 regs_display_type. */
137 tui_set_layout (enum tui_layout_type layout_type
,
138 enum tui_register_display_type regs_display_type
)
140 enum tui_status status
= TUI_SUCCESS
;
142 if (layout_type
!= UNDEFINED_LAYOUT
|| regs_display_type
!= TUI_UNDEFINED_REGS
)
144 enum tui_layout_type cur_layout
= tui_current_layout (), new_layout
= UNDEFINED_LAYOUT
;
145 int regs_populate
= FALSE
;
146 CORE_ADDR addr
= extract_display_start_addr ();
147 struct tui_win_info
* new_win_with_focus
= (struct tui_win_info
*) NULL
;
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
|| cur_layout
== SRC_DATA_COMMAND
)
158 new_layout
= SRC_DATA_COMMAND
;
159 else if (cur_layout
== DISASSEM_COMMAND
||
160 cur_layout
== DISASSEM_DATA_COMMAND
)
161 new_layout
= DISASSEM_DATA_COMMAND
;
164 new_layout
= layout_type
;
166 regs_populate
= (new_layout
== SRC_DATA_COMMAND
||
167 new_layout
== DISASSEM_DATA_COMMAND
||
168 regs_display_type
!= TUI_UNDEFINED_REGS
);
169 if (new_layout
!= cur_layout
|| regs_display_type
!= TUI_UNDEFINED_REGS
)
171 if (new_layout
!= cur_layout
)
173 show_layout (new_layout
);
175 ** Now determine where focus should be
177 if (win_with_focus
!= TUI_CMD_WIN
)
182 tui_set_win_focus_to (TUI_SRC_WIN
);
183 layout_def
->display_mode
= SRC_WIN
;
184 layout_def
->split
= FALSE
;
186 case DISASSEM_COMMAND
:
187 /* the previous layout was not showing
188 ** code. this can happen if there is no
190 ** 1. if the source file is in another dir OR
191 ** 2. if target was compiled without -g
192 ** We still want to show the assembly though!
194 addr
= tui_get_begin_asm_address ();
195 tui_set_win_focus_to (TUI_DISASM_WIN
);
196 layout_def
->display_mode
= DISASSEM_WIN
;
197 layout_def
->split
= FALSE
;
199 case SRC_DISASSEM_COMMAND
:
200 /* the previous layout was not showing
201 ** code. this can happen if there is no
203 ** 1. if the source file is in another dir OR
204 ** 2. if target was compiled without -g
205 ** We still want to show the assembly though!
207 addr
= tui_get_begin_asm_address ();
208 if (win_with_focus
== TUI_SRC_WIN
)
209 tui_set_win_focus_to (TUI_SRC_WIN
);
211 tui_set_win_focus_to (TUI_DISASM_WIN
);
212 layout_def
->split
= TRUE
;
214 case SRC_DATA_COMMAND
:
215 if (win_with_focus
!= TUI_DATA_WIN
)
216 tui_set_win_focus_to (TUI_SRC_WIN
);
218 tui_set_win_focus_to (TUI_DATA_WIN
);
219 layout_def
->display_mode
= SRC_WIN
;
220 layout_def
->split
= FALSE
;
222 case DISASSEM_DATA_COMMAND
:
223 /* the previous layout was not showing
224 ** code. this can happen if there is no
226 ** 1. if the source file is in another dir OR
227 ** 2. if target was compiled without -g
228 ** We still want to show the assembly though!
230 addr
= tui_get_begin_asm_address ();
231 if (win_with_focus
!= TUI_DATA_WIN
)
232 tui_set_win_focus_to (TUI_DISASM_WIN
);
234 tui_set_win_focus_to (TUI_DATA_WIN
);
235 layout_def
->display_mode
= DISASSEM_WIN
;
236 layout_def
->split
= FALSE
;
242 if (new_win_with_focus
!= (struct tui_win_info
*) NULL
)
243 tui_set_win_focus_to (new_win_with_focus
);
245 ** Now update the window content
247 if (!regs_populate
&&
248 (new_layout
== SRC_DATA_COMMAND
||
249 new_layout
== DISASSEM_DATA_COMMAND
))
250 tui_display_all_data ();
252 tui_update_source_windows_with_addr (addr
);
256 layout_def
->regs_display_type
=
257 (regs_display_type
== TUI_UNDEFINED_REGS
?
258 TUI_GENERAL_REGS
: regs_display_type
);
259 tui_show_registers (layout_def
->regs_display_type
);
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
, 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
)
422 register char *buf_ptr
;
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 && (*buf_ptr
== 'S' || *buf_ptr
== '$'))
434 warning ("Ambiguous command input.\n");
435 status
= TUI_FAILURE
;
439 if (subset_compare (buf_ptr
, "SRC"))
440 new_layout
= SRC_COMMAND
;
441 else if (subset_compare (buf_ptr
, "ASM"))
442 new_layout
= DISASSEM_COMMAND
;
443 else if (subset_compare (buf_ptr
, "SPLIT"))
444 new_layout
= SRC_DISASSEM_COMMAND
;
445 else if (subset_compare (buf_ptr
, "REGS") ||
446 subset_compare (buf_ptr
, TUI_GENERAL_SPECIAL_REGS_NAME
) ||
447 subset_compare (buf_ptr
, TUI_GENERAL_REGS_NAME
) ||
448 subset_compare (buf_ptr
, TUI_FLOAT_REGS_NAME
) ||
449 subset_compare (buf_ptr
, TUI_SPECIAL_REGS_NAME
))
451 if (cur_layout
== SRC_COMMAND
|| cur_layout
== SRC_DATA_COMMAND
)
452 new_layout
= SRC_DATA_COMMAND
;
454 new_layout
= DISASSEM_DATA_COMMAND
;
456 /* could ifdef out the following code. when compile with -z, there are null
457 pointer references that cause a core dump if 'layout regs' is the first
458 layout command issued by the user. HP has asked us to hook up this code
461 if (subset_compare (buf_ptr
, TUI_FLOAT_REGS_NAME
))
463 if (TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
!=
465 TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
!=
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 wishes to display the
493 general purpose registers
496 /* dpy_type = TUI_GENERAL_REGS;
499 else if (subset_compare (buf_ptr
, "NEXT"))
500 new_layout
= next_layout ();
501 else if (subset_compare (buf_ptr
, "PREV"))
502 new_layout
= prev_layout ();
504 status
= TUI_FAILURE
;
507 tui_set_layout (new_layout
, dpy_type
);
511 status
= TUI_FAILURE
;
518 extract_display_start_addr (void)
520 enum tui_layout_type cur_layout
= tui_current_layout ();
523 struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
528 case SRC_DATA_COMMAND
:
529 find_line_pc (cursal
.symtab
,
530 TUI_SRC_WIN
->detail
.source_info
.start_line_or_addr
.line_no
,
534 case DISASSEM_COMMAND
:
535 case SRC_DISASSEM_COMMAND
:
536 case DISASSEM_DATA_COMMAND
:
537 addr
= TUI_DISASM_WIN
->detail
.source_info
.start_line_or_addr
.addr
;
549 tui_handle_xdb_layout (struct tui_layout_def
* layout_def
)
551 if (layout_def
->split
)
553 tui_set_layout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
554 tui_set_win_focus_to (tui_win_list
[layout_def
->display_mode
]);
558 if (layout_def
->display_mode
== SRC_WIN
)
559 tui_set_layout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
561 tui_set_layout (DISASSEM_DATA_COMMAND
, layout_def
->regs_display_type
);
567 tui_toggle_layout_command (char *arg
, int from_tty
)
569 struct tui_layout_def
* layout_def
= tui_layout_def ();
571 /* Make sure the curses mode is enabled. */
573 if (layout_def
->display_mode
== SRC_WIN
)
574 layout_def
->display_mode
= DISASSEM_WIN
;
576 layout_def
->display_mode
= SRC_WIN
;
578 if (!layout_def
->split
)
579 tui_handle_xdb_layout (layout_def
);
584 tui_toggle_split_layout_command (char *arg
, int from_tty
)
586 struct tui_layout_def
* layout_def
= tui_layout_def ();
588 /* Make sure the curses mode is enabled. */
590 layout_def
->split
= (!layout_def
->split
);
591 tui_handle_xdb_layout (layout_def
);
596 tui_layout_command (char *arg
, int from_tty
)
598 /* Make sure the curses mode is enabled. */
601 /* Switch to the selected layout. */
602 if (tui_set_layout_for_display_command (arg
) != TUI_SUCCESS
)
603 warning ("Invalid layout specified.\n%s", LAYOUT_USAGE
);
607 /* Answer the previous layout to cycle to. */
608 static enum tui_layout_type
611 enum tui_layout_type new_layout
;
613 new_layout
= tui_current_layout ();
614 if (new_layout
== UNDEFINED_LAYOUT
)
615 new_layout
= SRC_COMMAND
;
619 if (new_layout
== UNDEFINED_LAYOUT
)
620 new_layout
= SRC_COMMAND
;
627 /* Answer the next layout to cycle to. */
628 static enum tui_layout_type
631 enum tui_layout_type new_layout
;
633 new_layout
= tui_current_layout ();
634 if (new_layout
== SRC_COMMAND
)
635 new_layout
= DISASSEM_DATA_COMMAND
;
639 if (new_layout
== UNDEFINED_LAYOUT
)
640 new_layout
= DISASSEM_DATA_COMMAND
;
649 make_command_window (struct tui_win_info
* * win_info_ptr
, int height
, int origin_y
)
651 init_and_make_win ((void **) win_info_ptr
,
659 (*win_info_ptr
)->can_highlight
= FALSE
;
664 ** make_source_window().
667 make_source_window (struct tui_win_info
* * win_info_ptr
, int height
, int origin_y
)
669 make_source_or_disasm_window (win_info_ptr
, SRC_WIN
, height
, origin_y
);
672 } /* make_source_window */
676 ** make_disasm_window().
679 make_disasm_window (struct tui_win_info
* * win_info_ptr
, 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
, int height
, int origin_y
)
690 init_and_make_win ((void **) win_info_ptr
,
701 /* Show the Source/Command layout. */
703 show_source_command (void)
705 show_source_or_disasm_and_command (SRC_COMMAND
);
709 /* Show the Dissassem/Command layout. */
711 show_disasm_command (void)
713 show_source_or_disasm_and_command (DISASSEM_COMMAND
);
717 /* Show the Source/Disassem/Command layout. */
719 show_source_disasm_command (void)
721 if (tui_current_layout () != SRC_DISASSEM_COMMAND
)
723 int cmd_height
, src_height
, asm_height
;
725 if (TUI_CMD_WIN
!= NULL
)
726 cmd_height
= TUI_CMD_WIN
->generic
.height
;
728 cmd_height
= tui_term_height () / 3;
730 src_height
= (tui_term_height () - cmd_height
) / 2;
731 asm_height
= tui_term_height () - (src_height
+ cmd_height
);
733 if (TUI_SRC_WIN
== NULL
)
734 make_source_window (&TUI_SRC_WIN
, src_height
, 0);
737 init_gen_win_info (&TUI_SRC_WIN
->generic
,
738 TUI_SRC_WIN
->generic
.type
,
740 TUI_SRC_WIN
->generic
.width
,
741 TUI_SRC_WIN
->detail
.source_info
.execution_info
->width
,
743 TUI_SRC_WIN
->can_highlight
= TRUE
;
744 init_gen_win_info (TUI_SRC_WIN
->detail
.source_info
.execution_info
,
750 tui_make_visible (&TUI_SRC_WIN
->generic
);
751 tui_make_visible (TUI_SRC_WIN
->detail
.source_info
.execution_info
);
752 TUI_SRC_WIN
->detail
.source_info
.has_locator
= FALSE
;;
754 if (TUI_SRC_WIN
!= NULL
)
756 struct tui_gen_win_info
* locator
= tui_locator_win_info_ptr ();
758 tui_show_source_content (TUI_SRC_WIN
);
759 if (TUI_DISASM_WIN
== NULL
)
761 make_disasm_window (&TUI_DISASM_WIN
, asm_height
, src_height
- 1);
762 init_and_make_win ((void **) & locator
,
767 (src_height
+ asm_height
) - 1,
772 init_gen_win_info (locator
,
777 (src_height
+ asm_height
) - 1);
778 TUI_DISASM_WIN
->detail
.source_info
.has_locator
= TRUE
;
780 &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 init_and_make_win ((void **) & 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
);
894 ** init_gen_win_info().
897 init_gen_win_info (struct tui_gen_win_info
* win_info
, enum tui_win_type type
,
898 int height
, int width
, int origin_x
, int origin_y
)
902 win_info
->type
= type
;
903 win_info
->width
= width
;
904 win_info
->height
= h
;
907 win_info
->viewport_height
= h
- 1;
908 if (win_info
->type
!= CMD_WIN
)
909 win_info
->viewport_height
--;
912 win_info
->viewport_height
= 1;
913 win_info
->origin
.x
= origin_x
;
914 win_info
->origin
.y
= origin_y
;
917 } /* init_gen_win_info */
920 ** init_and_make_win().
923 init_and_make_win (void ** win_info_ptr
, enum tui_win_type win_type
,
924 int height
, int width
, int origin_x
, int origin_y
, int box_it
)
926 void *opaque_win_info
= *win_info_ptr
;
927 struct tui_gen_win_info
* generic
;
929 if (opaque_win_info
== NULL
)
931 if (tui_win_is_auxillary (win_type
))
932 opaque_win_info
= (void *) tui_alloc_generic_win_info ();
934 opaque_win_info
= (void *) tui_alloc_win_info (win_type
);
936 if (tui_win_is_auxillary (win_type
))
937 generic
= (struct tui_gen_win_info
*) opaque_win_info
;
939 generic
= &((struct tui_win_info
*) opaque_win_info
)->generic
;
941 if (opaque_win_info
!= NULL
)
943 init_gen_win_info (generic
, win_type
, height
, width
, origin_x
, origin_y
);
944 if (!tui_win_is_auxillary (win_type
))
946 if (generic
->type
== CMD_WIN
)
947 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= FALSE
;
949 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= TRUE
;
951 tui_make_window (generic
, box_it
);
953 *win_info_ptr
= opaque_win_info
;
958 make_source_or_disasm_window (struct tui_win_info
* * win_info_ptr
, enum tui_win_type type
,
959 int height
, int origin_y
)
961 struct tui_gen_win_info
* execution_info
= (struct tui_gen_win_info
*) NULL
;
964 ** Create the exeuction info window.
967 execution_info
= tui_source_exec_info_win_ptr ();
969 execution_info
= tui_disassem_exec_info_win_ptr ();
970 init_and_make_win ((void **) & execution_info
,
978 ** Now create the source window.
980 init_and_make_win ((void **) 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
;
1009 if (layout_type
== SRC_COMMAND
)
1010 win_info_ptr
= &TUI_SRC_WIN
;
1012 win_info_ptr
= &TUI_DISASM_WIN
;
1014 if ((*win_info_ptr
) == NULL
)
1016 if (layout_type
== SRC_COMMAND
)
1017 make_source_window (win_info_ptr
, src_height
- 1, 0);
1019 make_disasm_window (win_info_ptr
, src_height
- 1, 0);
1020 init_and_make_win ((void **) & locator
,
1030 init_gen_win_info (locator
,
1036 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
1038 &(*win_info_ptr
)->generic
,
1039 (*win_info_ptr
)->generic
.type
,
1041 (*win_info_ptr
)->generic
.width
,
1042 (*win_info_ptr
)->detail
.source_info
.execution_info
->width
,
1044 init_gen_win_info ((*win_info_ptr
)->detail
.source_info
.execution_info
,
1050 (*win_info_ptr
)->can_highlight
= TRUE
;
1051 tui_make_visible (&(*win_info_ptr
)->generic
);
1052 tui_make_visible ((*win_info_ptr
)->detail
.source_info
.execution_info
);
1054 if ((*win_info_ptr
) != NULL
)
1056 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
1057 tui_make_visible (locator
);
1058 tui_show_locator_content ();
1059 tui_show_source_content (*win_info_ptr
);
1061 if (TUI_CMD_WIN
== NULL
)
1063 make_command_window (&TUI_CMD_WIN
, cmd_height
, src_height
);
1064 tui_refresh_win (&TUI_CMD_WIN
->generic
);
1068 init_gen_win_info (&TUI_CMD_WIN
->generic
,
1069 TUI_CMD_WIN
->generic
.type
,
1070 TUI_CMD_WIN
->generic
.height
,
1071 TUI_CMD_WIN
->generic
.width
,
1072 TUI_CMD_WIN
->generic
.origin
.x
,
1073 TUI_CMD_WIN
->generic
.origin
.y
);
1074 TUI_CMD_WIN
->can_highlight
= FALSE
;
1075 tui_make_visible (&TUI_CMD_WIN
->generic
);
1078 tui_set_current_layout_to (layout_type
);