gdb: Remove register class specific layout names.
[deliverable/binutils-gdb.git] / gdb / tui / tui-layout.c
1 /* TUI layout window management.
2
3 Copyright (C) 1998-2015 Free Software Foundation, Inc.
4
5 Contributed by Hewlett-Packard Company.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22 #include "defs.h"
23 #include "arch-utils.h"
24 #include "command.h"
25 #include "symtab.h"
26 #include "frame.h"
27 #include "source.h"
28 #include <ctype.h>
29
30 #include "tui/tui.h"
31 #include "tui/tui-data.h"
32 #include "tui/tui-windata.h"
33 #include "tui/tui-wingeneral.h"
34 #include "tui/tui-stack.h"
35 #include "tui/tui-regs.h"
36 #include "tui/tui-win.h"
37 #include "tui/tui-winsource.h"
38 #include "tui/tui-disasm.h"
39 #include "tui/tui-layout.h"
40 #include "gdb_curses.h"
41
42 /*******************************
43 ** Static Local Decls
44 ********************************/
45 static void show_layout (enum tui_layout_type);
46 static void init_gen_win_info (struct tui_gen_win_info *,
47 enum tui_win_type,
48 int, int, int, int);
49 static void *init_and_make_win (void *, enum tui_win_type,
50 int, int, int, int, int);
51 static void show_source_or_disasm_and_command (enum tui_layout_type);
52 static void make_source_or_disasm_window (struct tui_win_info **,
53 enum tui_win_type,
54 int, int);
55 static void make_command_window (struct tui_win_info **, int, int);
56 static void make_source_window (struct tui_win_info **, int, int);
57 static void make_disasm_window (struct tui_win_info **, int, int);
58 static void make_data_window (struct tui_win_info **, int, int);
59 static void show_source_command (void);
60 static void show_disasm_command (void);
61 static void show_source_disasm_command (void);
62 static void show_data (enum tui_layout_type);
63 static enum tui_layout_type next_layout (void);
64 static enum tui_layout_type prev_layout (void);
65 static void tui_layout_command (char *, int);
66 static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *);
67
68
69 /***************************************
70 ** DEFINITIONS
71 ***************************************/
72
73 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
74
75 /* Show the screen layout defined. */
76 static void
77 show_layout (enum tui_layout_type layout)
78 {
79 enum tui_layout_type cur_layout = tui_current_layout ();
80
81 if (layout != cur_layout)
82 {
83 /* Since the new layout may cause changes in window size, we
84 should free the content and reallocate on next display of
85 source/asm. */
86 tui_free_all_source_wins_content ();
87 tui_clear_source_windows ();
88 if (layout == SRC_DATA_COMMAND
89 || layout == DISASSEM_DATA_COMMAND)
90 {
91 show_data (layout);
92 tui_refresh_all (tui_win_list);
93 }
94 else
95 {
96 /* First make the current layout be invisible. */
97 tui_make_all_invisible ();
98 tui_make_invisible (tui_locator_win_info_ptr ());
99
100 switch (layout)
101 {
102 /* Now show the new layout. */
103 case SRC_COMMAND:
104 show_source_command ();
105 tui_add_to_source_windows (TUI_SRC_WIN);
106 break;
107 case DISASSEM_COMMAND:
108 show_disasm_command ();
109 tui_add_to_source_windows (TUI_DISASM_WIN);
110 break;
111 case SRC_DISASSEM_COMMAND:
112 show_source_disasm_command ();
113 tui_add_to_source_windows (TUI_SRC_WIN);
114 tui_add_to_source_windows (TUI_DISASM_WIN);
115 break;
116 default:
117 break;
118 }
119 }
120 }
121 }
122
123
124 /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
125 SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND. */
126 enum tui_status
127 tui_set_layout (enum tui_layout_type layout_type)
128 {
129 enum tui_status status = TUI_SUCCESS;
130
131 if (layout_type != UNDEFINED_LAYOUT)
132 {
133 enum tui_layout_type cur_layout = tui_current_layout (),
134 new_layout = UNDEFINED_LAYOUT;
135 int regs_populate = FALSE;
136 struct gdbarch *gdbarch;
137 CORE_ADDR addr;
138 struct tui_win_info *win_with_focus = tui_win_with_focus ();
139 struct tui_layout_def *layout_def = tui_layout_def ();
140
141 extract_display_start_addr (&gdbarch, &addr);
142
143 new_layout = layout_type;
144
145 regs_populate = (new_layout == SRC_DATA_COMMAND
146 || new_layout == DISASSEM_DATA_COMMAND);
147 if (new_layout != cur_layout)
148 {
149 show_layout (new_layout);
150
151 /* Now determine where focus should be. */
152 if (win_with_focus != TUI_CMD_WIN)
153 {
154 switch (new_layout)
155 {
156 case SRC_COMMAND:
157 tui_set_win_focus_to (TUI_SRC_WIN);
158 layout_def->display_mode = SRC_WIN;
159 layout_def->split = FALSE;
160 break;
161 case DISASSEM_COMMAND:
162 /* The previous layout was not showing code.
163 This can happen if there is no source
164 available:
165
166 1. if the source file is in another dir OR
167 2. if target was compiled without -g
168 We still want to show the assembly though! */
169
170 tui_get_begin_asm_address (&gdbarch, &addr);
171 tui_set_win_focus_to (TUI_DISASM_WIN);
172 layout_def->display_mode = DISASSEM_WIN;
173 layout_def->split = FALSE;
174 break;
175 case SRC_DISASSEM_COMMAND:
176 /* The previous layout was not showing code.
177 This can happen if there is no source
178 available:
179
180 1. if the source file is in another dir OR
181 2. if target was compiled without -g
182 We still want to show the assembly though! */
183
184 tui_get_begin_asm_address (&gdbarch, &addr);
185 if (win_with_focus == TUI_SRC_WIN)
186 tui_set_win_focus_to (TUI_SRC_WIN);
187 else
188 tui_set_win_focus_to (TUI_DISASM_WIN);
189 layout_def->split = TRUE;
190 break;
191 case SRC_DATA_COMMAND:
192 if (win_with_focus != TUI_DATA_WIN)
193 tui_set_win_focus_to (TUI_SRC_WIN);
194 else
195 tui_set_win_focus_to (TUI_DATA_WIN);
196 layout_def->display_mode = SRC_WIN;
197 layout_def->split = FALSE;
198 break;
199 case DISASSEM_DATA_COMMAND:
200 /* The previous layout was not showing code.
201 This can happen if there is no source
202 available:
203
204 1. if the source file is in another dir OR
205 2. if target was compiled without -g
206 We still want to show the assembly though! */
207
208 tui_get_begin_asm_address (&gdbarch, &addr);
209 if (win_with_focus != TUI_DATA_WIN)
210 tui_set_win_focus_to (TUI_DISASM_WIN);
211 else
212 tui_set_win_focus_to (TUI_DATA_WIN);
213 layout_def->display_mode = DISASSEM_WIN;
214 layout_def->split = FALSE;
215 break;
216 default:
217 break;
218 }
219 }
220 /*
221 * Now update the window content.
222 */
223 if (!regs_populate
224 && (new_layout == SRC_DATA_COMMAND
225 || new_layout == DISASSEM_DATA_COMMAND))
226 tui_display_all_data ();
227
228 tui_update_source_windows_with_addr (gdbarch, addr);
229
230 if (regs_populate)
231 {
232 struct reggroup *group =
233 TUI_DATA_WIN->detail.data_display_info.current_group;
234 tui_show_registers (group);
235 }
236 }
237 }
238 else
239 status = TUI_FAILURE;
240
241 return status;
242 }
243
244 /* Add the specified window to the layout in a logical way. This
245 means setting up the most logical layout given the window to be
246 added. */
247 void
248 tui_add_win_to_layout (enum tui_win_type type)
249 {
250 enum tui_layout_type cur_layout = tui_current_layout ();
251
252 switch (type)
253 {
254 case SRC_WIN:
255 if (cur_layout != SRC_COMMAND
256 && cur_layout != SRC_DISASSEM_COMMAND
257 && cur_layout != SRC_DATA_COMMAND)
258 {
259 tui_clear_source_windows_detail ();
260 if (cur_layout == DISASSEM_DATA_COMMAND)
261 show_layout (SRC_DATA_COMMAND);
262 else
263 show_layout (SRC_COMMAND);
264 }
265 break;
266 case DISASSEM_WIN:
267 if (cur_layout != DISASSEM_COMMAND
268 && cur_layout != SRC_DISASSEM_COMMAND
269 && cur_layout != DISASSEM_DATA_COMMAND)
270 {
271 tui_clear_source_windows_detail ();
272 if (cur_layout == SRC_DATA_COMMAND)
273 show_layout (DISASSEM_DATA_COMMAND);
274 else
275 show_layout (DISASSEM_COMMAND);
276 }
277 break;
278 case DATA_WIN:
279 if (cur_layout != SRC_DATA_COMMAND
280 && cur_layout != DISASSEM_DATA_COMMAND)
281 {
282 if (cur_layout == DISASSEM_COMMAND)
283 show_layout (DISASSEM_DATA_COMMAND);
284 else
285 show_layout (SRC_DATA_COMMAND);
286 }
287 break;
288 default:
289 break;
290 }
291 }
292
293
294 /* Answer the height of a window. If it hasn't been created yet,
295 answer what the height of a window would be based upon its type and
296 the layout. */
297 int
298 tui_default_win_height (enum tui_win_type type,
299 enum tui_layout_type layout)
300 {
301 int h;
302
303 if (tui_win_list[type] != (struct tui_win_info *) NULL)
304 h = tui_win_list[type]->generic.height;
305 else
306 {
307 switch (layout)
308 {
309 case SRC_COMMAND:
310 case DISASSEM_COMMAND:
311 if (TUI_CMD_WIN == NULL)
312 h = tui_term_height () / 2;
313 else
314 h = tui_term_height () - TUI_CMD_WIN->generic.height;
315 break;
316 case SRC_DISASSEM_COMMAND:
317 case SRC_DATA_COMMAND:
318 case DISASSEM_DATA_COMMAND:
319 if (TUI_CMD_WIN == NULL)
320 h = tui_term_height () / 3;
321 else
322 h = (tui_term_height () - TUI_CMD_WIN->generic.height) / 2;
323 break;
324 default:
325 h = 0;
326 break;
327 }
328 }
329
330 return h;
331 }
332
333
334 /* Answer the height of a window. If it hasn't been created yet,
335 answer what the height of a window would be based upon its type and
336 the layout. */
337 int
338 tui_default_win_viewport_height (enum tui_win_type type,
339 enum tui_layout_type layout)
340 {
341 int h;
342
343 h = tui_default_win_height (type, layout);
344
345 if (tui_win_list[type] == TUI_CMD_WIN)
346 h -= 1;
347 else
348 h -= 2;
349
350 return h;
351 }
352
353 /* Function to initialize gdb commands, for tui window layout
354 manipulation. */
355
356 /* Provide a prototype to silence -Wmissing-prototypes. */
357 extern initialize_file_ftype _initialize_tui_layout;
358
359 void
360 _initialize_tui_layout (void)
361 {
362 add_com ("layout", class_tui, tui_layout_command, _("\
363 Change the layout of windows.\n\
364 Usage: layout prev | next | <layout_name> \n\
365 Layout names are:\n\
366 src : Displays source and command windows.\n\
367 asm : Displays disassembly and command windows.\n\
368 split : Displays source, disassembly and command windows.\n\
369 regs : Displays register window. If existing layout\n\
370 is source/command or assembly/command, the \n\
371 register window is displayed. If the\n\
372 source/assembly/command (split) is displayed, \n\
373 the register window is displayed with \n\
374 the window that has current logical focus.\n"));
375 }
376
377
378 /*************************
379 ** STATIC LOCAL FUNCTIONS
380 **************************/
381
382
383 /* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, or
384 REGS. */
385 enum tui_status
386 tui_set_layout_by_name (const char *layout_name)
387 {
388 enum tui_status status = TUI_SUCCESS;
389
390 if (layout_name != (char *) NULL)
391 {
392 int i;
393 char *buf_ptr;
394 enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
395 enum tui_layout_type cur_layout = tui_current_layout ();
396
397 buf_ptr = (char *) xstrdup (layout_name);
398 for (i = 0; (i < strlen (layout_name)); i++)
399 buf_ptr[i] = toupper (buf_ptr[i]);
400
401 /* First check for ambiguous input. */
402 if (strlen (buf_ptr) <= 1 && *buf_ptr == 'S')
403 {
404 warning (_("Ambiguous command input."));
405 status = TUI_FAILURE;
406 }
407 else
408 {
409 if (subset_compare (buf_ptr, "SRC"))
410 new_layout = SRC_COMMAND;
411 else if (subset_compare (buf_ptr, "ASM"))
412 new_layout = DISASSEM_COMMAND;
413 else if (subset_compare (buf_ptr, "SPLIT"))
414 new_layout = SRC_DISASSEM_COMMAND;
415 else if (subset_compare (buf_ptr, "REGS"))
416 {
417 if (cur_layout == SRC_COMMAND
418 || cur_layout == SRC_DATA_COMMAND)
419 new_layout = SRC_DATA_COMMAND;
420 else
421 new_layout = DISASSEM_DATA_COMMAND;
422 }
423 else if (subset_compare (buf_ptr, "NEXT"))
424 new_layout = next_layout ();
425 else if (subset_compare (buf_ptr, "PREV"))
426 new_layout = prev_layout ();
427 else
428 status = TUI_FAILURE;
429
430 tui_set_layout (new_layout);
431 }
432 xfree (buf_ptr);
433 }
434 else
435 status = TUI_FAILURE;
436
437 return status;
438 }
439
440
441 static void
442 extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
443 {
444 enum tui_layout_type cur_layout = tui_current_layout ();
445 struct gdbarch *gdbarch = get_current_arch ();
446 CORE_ADDR addr;
447 CORE_ADDR pc;
448 struct symtab_and_line cursal = get_current_source_symtab_and_line ();
449
450 switch (cur_layout)
451 {
452 case SRC_COMMAND:
453 case SRC_DATA_COMMAND:
454 gdbarch = TUI_SRC_WIN->detail.source_info.gdbarch;
455 find_line_pc (cursal.symtab,
456 TUI_SRC_WIN->detail.source_info.start_line_or_addr.u.line_no,
457 &pc);
458 addr = pc;
459 break;
460 case DISASSEM_COMMAND:
461 case SRC_DISASSEM_COMMAND:
462 case DISASSEM_DATA_COMMAND:
463 gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch;
464 addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr;
465 break;
466 default:
467 addr = 0;
468 break;
469 }
470
471 *gdbarch_p = gdbarch;
472 *addr_p = addr;
473 }
474
475
476 static void
477 tui_layout_command (char *arg, int from_tty)
478 {
479 /* Make sure the curses mode is enabled. */
480 tui_enable ();
481
482 /* Switch to the selected layout. */
483 if (tui_set_layout_by_name (arg) != TUI_SUCCESS)
484 warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE);
485
486 }
487
488 /* Answer the previous layout to cycle to. */
489 static enum tui_layout_type
490 next_layout (void)
491 {
492 int new_layout;
493
494 new_layout = tui_current_layout ();
495 if (new_layout == UNDEFINED_LAYOUT)
496 new_layout = SRC_COMMAND;
497 else
498 {
499 new_layout++;
500 if (new_layout == UNDEFINED_LAYOUT)
501 new_layout = SRC_COMMAND;
502 }
503
504 return (enum tui_layout_type) new_layout;
505 }
506
507
508 /* Answer the next layout to cycle to. */
509 static enum tui_layout_type
510 prev_layout (void)
511 {
512 int new_layout;
513
514 new_layout = tui_current_layout ();
515 if (new_layout == SRC_COMMAND)
516 new_layout = DISASSEM_DATA_COMMAND;
517 else
518 {
519 new_layout--;
520 if (new_layout == UNDEFINED_LAYOUT)
521 new_layout = DISASSEM_DATA_COMMAND;
522 }
523
524 return (enum tui_layout_type) new_layout;
525 }
526
527
528
529 static void
530 make_command_window (struct tui_win_info **win_info_ptr,
531 int height, int origin_y)
532 {
533 *win_info_ptr = init_and_make_win (*win_info_ptr,
534 CMD_WIN,
535 height,
536 tui_term_width (),
537 0,
538 origin_y,
539 DONT_BOX_WINDOW);
540
541 (*win_info_ptr)->can_highlight = FALSE;
542 }
543
544
545 /* make_source_window().
546 */
547 static void
548 make_source_window (struct tui_win_info **win_info_ptr,
549 int height, int origin_y)
550 {
551 make_source_or_disasm_window (win_info_ptr, SRC_WIN, height, origin_y);
552
553 return;
554 } /* make_source_window */
555
556
557 /* make_disasm_window().
558 */
559 static void
560 make_disasm_window (struct tui_win_info **win_info_ptr,
561 int height, int origin_y)
562 {
563 make_source_or_disasm_window (win_info_ptr, DISASSEM_WIN, height, origin_y);
564
565 return;
566 } /* make_disasm_window */
567
568
569 static void
570 make_data_window (struct tui_win_info **win_info_ptr,
571 int height, int origin_y)
572 {
573 *win_info_ptr = init_and_make_win (*win_info_ptr,
574 DATA_WIN,
575 height,
576 tui_term_width (),
577 0,
578 origin_y,
579 BOX_WINDOW);
580 }
581
582
583
584 /* Show the Source/Command layout. */
585 static void
586 show_source_command (void)
587 {
588 show_source_or_disasm_and_command (SRC_COMMAND);
589 }
590
591
592 /* Show the Dissassem/Command layout. */
593 static void
594 show_disasm_command (void)
595 {
596 show_source_or_disasm_and_command (DISASSEM_COMMAND);
597 }
598
599
600 /* Show the Source/Disassem/Command layout. */
601 static void
602 show_source_disasm_command (void)
603 {
604 if (tui_current_layout () != SRC_DISASSEM_COMMAND)
605 {
606 int cmd_height, src_height, asm_height;
607
608 if (TUI_CMD_WIN != NULL)
609 cmd_height = TUI_CMD_WIN->generic.height;
610 else
611 cmd_height = tui_term_height () / 3;
612
613 src_height = (tui_term_height () - cmd_height) / 2;
614 asm_height = tui_term_height () - (src_height + cmd_height);
615
616 if (TUI_SRC_WIN == NULL)
617 make_source_window (&TUI_SRC_WIN, src_height, 0);
618 else
619 {
620 init_gen_win_info (&TUI_SRC_WIN->generic,
621 TUI_SRC_WIN->generic.type,
622 src_height,
623 TUI_SRC_WIN->generic.width,
624 TUI_SRC_WIN->detail.source_info.execution_info->width,
625 0);
626 TUI_SRC_WIN->can_highlight = TRUE;
627 init_gen_win_info (TUI_SRC_WIN->detail.source_info.execution_info,
628 EXEC_INFO_WIN,
629 src_height,
630 3,
631 0,
632 0);
633 tui_make_visible (&TUI_SRC_WIN->generic);
634 tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info);
635 TUI_SRC_WIN->detail.source_info.has_locator = FALSE;;
636 }
637 if (TUI_SRC_WIN != NULL)
638 {
639 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
640
641 tui_show_source_content (TUI_SRC_WIN);
642 if (TUI_DISASM_WIN == NULL)
643 {
644 make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1);
645 locator = init_and_make_win (locator,
646 LOCATOR_WIN,
647 2 /* 1 */ ,
648 tui_term_width (),
649 0,
650 (src_height + asm_height) - 1,
651 DONT_BOX_WINDOW);
652 }
653 else
654 {
655 init_gen_win_info (locator,
656 LOCATOR_WIN,
657 2 /* 1 */ ,
658 tui_term_width (),
659 0,
660 (src_height + asm_height) - 1);
661 TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
662 init_gen_win_info (&TUI_DISASM_WIN->generic,
663 TUI_DISASM_WIN->generic.type,
664 asm_height,
665 TUI_DISASM_WIN->generic.width,
666 TUI_DISASM_WIN->detail.source_info.execution_info->width,
667 src_height - 1);
668 init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info,
669 EXEC_INFO_WIN,
670 asm_height,
671 3,
672 0,
673 src_height - 1);
674 TUI_DISASM_WIN->can_highlight = TRUE;
675 tui_make_visible (&TUI_DISASM_WIN->generic);
676 tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
677 }
678 if (TUI_DISASM_WIN != NULL)
679 {
680 TUI_SRC_WIN->detail.source_info.has_locator = FALSE;
681 TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
682 tui_make_visible (locator);
683 tui_show_locator_content ();
684 tui_show_source_content (TUI_DISASM_WIN);
685
686 if (TUI_CMD_WIN == NULL)
687 make_command_window (&TUI_CMD_WIN,
688 cmd_height,
689 tui_term_height () - cmd_height);
690 else
691 {
692 init_gen_win_info (&TUI_CMD_WIN->generic,
693 TUI_CMD_WIN->generic.type,
694 TUI_CMD_WIN->generic.height,
695 TUI_CMD_WIN->generic.width,
696 0,
697 TUI_CMD_WIN->generic.origin.y);
698 TUI_CMD_WIN->can_highlight = FALSE;
699 tui_make_visible (&TUI_CMD_WIN->generic);
700 }
701 if (TUI_CMD_WIN != NULL)
702 tui_refresh_win (&TUI_CMD_WIN->generic);
703 }
704 }
705 tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
706 }
707 }
708
709
710 /* Show the Source/Data/Command or the Dissassembly/Data/Command
711 layout. */
712 static void
713 show_data (enum tui_layout_type new_layout)
714 {
715 int total_height = (tui_term_height () - TUI_CMD_WIN->generic.height);
716 int src_height, data_height;
717 enum tui_win_type win_type;
718 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
719
720
721 data_height = total_height / 2;
722 src_height = total_height - data_height;
723 tui_make_all_invisible ();
724 tui_make_invisible (locator);
725 make_data_window (&TUI_DATA_WIN, data_height, 0);
726 TUI_DATA_WIN->can_highlight = TRUE;
727 if (new_layout == SRC_DATA_COMMAND)
728 win_type = SRC_WIN;
729 else
730 win_type = DISASSEM_WIN;
731 if (tui_win_list[win_type] == NULL)
732 {
733 if (win_type == SRC_WIN)
734 make_source_window (&tui_win_list[win_type], src_height, data_height - 1);
735 else
736 make_disasm_window (&tui_win_list[win_type], src_height, data_height - 1);
737 locator = init_and_make_win (locator,
738 LOCATOR_WIN,
739 2 /* 1 */ ,
740 tui_term_width (),
741 0,
742 total_height - 1,
743 DONT_BOX_WINDOW);
744 }
745 else
746 {
747 init_gen_win_info (&tui_win_list[win_type]->generic,
748 tui_win_list[win_type]->generic.type,
749 src_height,
750 tui_win_list[win_type]->generic.width,
751 tui_win_list[win_type]->detail.source_info.execution_info->width,
752 data_height - 1);
753 init_gen_win_info (tui_win_list[win_type]->detail.source_info.execution_info,
754 EXEC_INFO_WIN,
755 src_height,
756 3,
757 0,
758 data_height - 1);
759 tui_make_visible (&tui_win_list[win_type]->generic);
760 tui_make_visible (tui_win_list[win_type]->detail.source_info.execution_info);
761 init_gen_win_info (locator,
762 LOCATOR_WIN,
763 2 /* 1 */ ,
764 tui_term_width (),
765 0,
766 total_height - 1);
767 }
768 tui_win_list[win_type]->detail.source_info.has_locator = TRUE;
769 tui_make_visible (locator);
770 tui_show_locator_content ();
771 tui_add_to_source_windows (tui_win_list[win_type]);
772 tui_set_current_layout_to (new_layout);
773 }
774
775 /* init_gen_win_info().
776 */
777 static void
778 init_gen_win_info (struct tui_gen_win_info *win_info,
779 enum tui_win_type type,
780 int height, int width,
781 int origin_x, int origin_y)
782 {
783 int h = height;
784
785 win_info->type = type;
786 win_info->width = width;
787 win_info->height = h;
788 if (h > 1)
789 {
790 win_info->viewport_height = h - 1;
791 if (win_info->type != CMD_WIN)
792 win_info->viewport_height--;
793 }
794 else
795 win_info->viewport_height = 1;
796 win_info->origin.x = origin_x;
797 win_info->origin.y = origin_y;
798
799 return;
800 } /* init_gen_win_info */
801
802 /* init_and_make_win().
803 */
804 static void *
805 init_and_make_win (void *opaque_win_info,
806 enum tui_win_type win_type,
807 int height, int width,
808 int origin_x, int origin_y,
809 int box_it)
810 {
811 struct tui_gen_win_info *generic;
812
813 if (opaque_win_info == NULL)
814 {
815 if (tui_win_is_auxillary (win_type))
816 opaque_win_info = (void *) tui_alloc_generic_win_info ();
817 else
818 opaque_win_info = (void *) tui_alloc_win_info (win_type);
819 }
820 if (tui_win_is_auxillary (win_type))
821 generic = (struct tui_gen_win_info *) opaque_win_info;
822 else
823 generic = &((struct tui_win_info *) opaque_win_info)->generic;
824
825 if (opaque_win_info != NULL)
826 {
827 init_gen_win_info (generic, win_type, height, width, origin_x, origin_y);
828 if (!tui_win_is_auxillary (win_type))
829 {
830 if (generic->type == CMD_WIN)
831 ((struct tui_win_info *) opaque_win_info)->can_highlight = FALSE;
832 else
833 ((struct tui_win_info *) opaque_win_info)->can_highlight = TRUE;
834 }
835 tui_make_window (generic, box_it);
836 }
837 return opaque_win_info;
838 }
839
840
841 static void
842 make_source_or_disasm_window (struct tui_win_info **win_info_ptr,
843 enum tui_win_type type,
844 int height, int origin_y)
845 {
846 struct tui_gen_win_info *execution_info = (struct tui_gen_win_info *) NULL;
847
848 /* Create the exeuction info window. */
849 if (type == SRC_WIN)
850 execution_info = tui_source_exec_info_win_ptr ();
851 else
852 execution_info = tui_disassem_exec_info_win_ptr ();
853 execution_info = init_and_make_win (execution_info,
854 EXEC_INFO_WIN,
855 height,
856 3,
857 0,
858 origin_y,
859 DONT_BOX_WINDOW);
860
861 /* Now create the source window. */
862 *win_info_ptr = init_and_make_win (*win_info_ptr,
863 type,
864 height,
865 tui_term_width () - execution_info->width,
866 execution_info->width,
867 origin_y,
868 BOX_WINDOW);
869
870 (*win_info_ptr)->detail.source_info.execution_info = execution_info;
871 }
872
873
874 /* Show the Source/Command or the Disassem layout. */
875 static void
876 show_source_or_disasm_and_command (enum tui_layout_type layout_type)
877 {
878 if (tui_current_layout () != layout_type)
879 {
880 struct tui_win_info **win_info_ptr;
881 int src_height, cmd_height;
882 struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
883
884 if (TUI_CMD_WIN != NULL)
885 cmd_height = TUI_CMD_WIN->generic.height;
886 else
887 cmd_height = tui_term_height () / 3;
888 src_height = tui_term_height () - cmd_height;
889
890 if (layout_type == SRC_COMMAND)
891 win_info_ptr = &TUI_SRC_WIN;
892 else
893 win_info_ptr = &TUI_DISASM_WIN;
894
895 if ((*win_info_ptr) == NULL)
896 {
897 if (layout_type == SRC_COMMAND)
898 make_source_window (win_info_ptr, src_height - 1, 0);
899 else
900 make_disasm_window (win_info_ptr, src_height - 1, 0);
901 locator = init_and_make_win (locator,
902 LOCATOR_WIN,
903 2 /* 1 */ ,
904 tui_term_width (),
905 0,
906 src_height - 1,
907 DONT_BOX_WINDOW);
908 }
909 else
910 {
911 init_gen_win_info (locator,
912 LOCATOR_WIN,
913 2 /* 1 */ ,
914 tui_term_width (),
915 0,
916 src_height - 1);
917 (*win_info_ptr)->detail.source_info.has_locator = TRUE;
918 init_gen_win_info (&(*win_info_ptr)->generic,
919 (*win_info_ptr)->generic.type,
920 src_height - 1,
921 (*win_info_ptr)->generic.width,
922 (*win_info_ptr)->detail.source_info.execution_info->width,
923 0);
924 init_gen_win_info ((*win_info_ptr)->detail.source_info.execution_info,
925 EXEC_INFO_WIN,
926 src_height - 1,
927 3,
928 0,
929 0);
930 (*win_info_ptr)->can_highlight = TRUE;
931 tui_make_visible (&(*win_info_ptr)->generic);
932 tui_make_visible ((*win_info_ptr)->detail.source_info.execution_info);
933 }
934 if ((*win_info_ptr) != NULL)
935 {
936 (*win_info_ptr)->detail.source_info.has_locator = TRUE;
937 tui_make_visible (locator);
938 tui_show_locator_content ();
939 tui_show_source_content (*win_info_ptr);
940
941 if (TUI_CMD_WIN == NULL)
942 {
943 make_command_window (&TUI_CMD_WIN, cmd_height, src_height);
944 tui_refresh_win (&TUI_CMD_WIN->generic);
945 }
946 else
947 {
948 init_gen_win_info (&TUI_CMD_WIN->generic,
949 TUI_CMD_WIN->generic.type,
950 TUI_CMD_WIN->generic.height,
951 TUI_CMD_WIN->generic.width,
952 TUI_CMD_WIN->generic.origin.x,
953 TUI_CMD_WIN->generic.origin.y);
954 TUI_CMD_WIN->can_highlight = FALSE;
955 tui_make_visible (&TUI_CMD_WIN->generic);
956 }
957 }
958 tui_set_current_layout_to (layout_type);
959 }
960 }
This page took 0.074493 seconds and 4 git commands to generate.