📄 tui-data.c
字号:
/* TUI data manipulation routines. Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. This file is part of GDB. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#include "defs.h"#include "symtab.h"#include "tui/tui.h"#include "tui/tui-data.h"#include "tui/tui-wingeneral.h"#include "gdb_string.h"#include "gdb_curses.h"/****************************** GLOBAL DECLARATIONS****************************/struct tui_win_info *(tui_win_list[MAX_MAJOR_WINDOWS]);/***************************** Private data****************************/static enum tui_layout_type current_layout = UNDEFINED_LAYOUT;static int term_height, term_width;static struct tui_gen_win_info _locator;static struct tui_gen_win_info exec_info[2];static struct tui_win_info * src_win_list[2];static struct tui_list source_windows = {(void **) src_win_list, 0};static int default_tab_len = DEFAULT_TAB_LEN;static struct tui_win_info * win_with_focus = (struct tui_win_info *) NULL;static struct tui_layout_def layout_def ={SRC_WIN, /* DISPLAY_MODE */ FALSE, /* SPLIT */ TUI_UNDEFINED_REGS, /* REGS_DISPLAY_TYPE */ TUI_SFLOAT_REGS}; /* FLOAT_REGS_DISPLAY_TYPE */static int win_resized = FALSE;/*********************************** Static function forward decls**********************************/static void free_content (tui_win_content, int, enum tui_win_type);static void free_content_elements (tui_win_content, int, enum tui_win_type);/*********************************** PUBLIC FUNCTIONS**********************************/inttui_win_is_source_type (enum tui_win_type win_type){ return (win_type == SRC_WIN || win_type == DISASSEM_WIN);}inttui_win_is_auxillary (enum tui_win_type win_type){ return (win_type > MAX_MAJOR_WINDOWS);}inttui_win_has_locator (struct tui_win_info *win_info){ return (win_info != NULL \ && win_info->detail.source_info.has_locator);}voidtui_set_win_highlight (struct tui_win_info *win_info, int highlight){ if (win_info != NULL) win_info->is_highlighted = highlight;}/******************************************** ACCESSORS & MUTATORS FOR PRIVATE DATA******************************************//* Answer a whether the terminal window has been resized or not. */inttui_win_resized (void){ return win_resized;}/* Set a whether the terminal window has been resized or not. */voidtui_set_win_resized_to (int resized){ win_resized = resized;}/* Answer a pointer to the current layout definition. */struct tui_layout_def *tui_layout_def (void){ return &layout_def;}/* Answer the window with the logical focus. */struct tui_win_info *tui_win_with_focus (void){ return win_with_focus;}/* Set the window that has the logical focus. */voidtui_set_win_with_focus (struct tui_win_info * win_info){ win_with_focus = win_info;}/* Answer the length in chars, of tabs. */inttui_default_tab_len (void){ return default_tab_len;}/* Set the length in chars, of tabs. */voidtui_set_default_tab_len (int len){ default_tab_len = len;}/* Accessor for the current source window. Usually there is only one source window (either source or disassembly), but both can be displayed at the same time. */struct tui_list *tui_source_windows (void){ return &source_windows;}/* Clear the list of source windows. Usually there is only one source window (either source or disassembly), but both can be displayed at the same time. */voidtui_clear_source_windows (void){ source_windows.list[0] = NULL; source_windows.list[1] = NULL; source_windows.count = 0;}/* Clear the pertinant detail in the source windows. */voidtui_clear_source_windows_detail (void){ int i; for (i = 0; i < (tui_source_windows ())->count; i++) tui_clear_win_detail ((struct tui_win_info *) (tui_source_windows ())->list[i]);}/* Add a window to the list of source windows. Usually there is only one source window (either source or disassembly), but both can be displayed at the same time. */voidtui_add_to_source_windows (struct tui_win_info * win_info){ if (source_windows.count < 2) source_windows.list[source_windows.count++] = (void *) win_info;}/* Clear the pertinant detail in the windows. */voidtui_clear_win_detail (struct tui_win_info * win_info){ if (win_info != NULL) { switch (win_info->generic.type) { case SRC_WIN: case DISASSEM_WIN: win_info->detail.source_info.start_line_or_addr.addr = 0; win_info->detail.source_info.horizontal_offset = 0; break; case CMD_WIN: win_info->detail.command_info.cur_line = win_info->detail.command_info.curch = 0; break; case DATA_WIN: win_info->detail.data_display_info.data_content = (tui_win_content) NULL; win_info->detail.data_display_info.data_content_count = 0; win_info->detail.data_display_info.regs_content = (tui_win_content) NULL; win_info->detail.data_display_info.regs_content_count = 0; win_info->detail.data_display_info.regs_display_type = TUI_UNDEFINED_REGS; win_info->detail.data_display_info.regs_column_count = 1; win_info->detail.data_display_info.display_regs = FALSE; break; default: break; } }}/* Accessor for the source execution info ptr. */struct tui_gen_win_info *tui_source_exec_info_win_ptr (void){ return &exec_info[0];}/* Accessor for the disassem execution info ptr. */struct tui_gen_win_info *tui_disassem_exec_info_win_ptr (void){ return &exec_info[1];}/* Accessor for the locator win info. Answers a pointer to the static locator win info struct. */struct tui_gen_win_info *tui_locator_win_info_ptr (void){ return &_locator;}/* Accessor for the term_height. */inttui_term_height (void){ return term_height;}/* Mutator for the term height. */voidtui_set_term_height_to (int h){ term_height = h;}/* Accessor for the term_width. */inttui_term_width (void){ return term_width;}/* Mutator for the term_width. */voidtui_set_term_width_to (int w){ term_width = w;}/* Accessor for the current layout. */enum tui_layout_typetui_current_layout (void){ return current_layout;}/* Mutator for the current layout. */voidtui_set_current_layout_to (enum tui_layout_type new_layout){ current_layout = new_layout;}/* Set the origin of the window. */voidset_gen_win_origin (struct tui_gen_win_info * win_info, int x, int y){ win_info->origin.x = x; win_info->origin.y = y;}/******************************* OTHER PUBLIC FUNCTIONS*****************************//* Answer the next window in the list, cycling back to the top if necessary. */struct tui_win_info *tui_next_win (struct tui_win_info * cur_win){ enum tui_win_type type = cur_win->generic.type; struct tui_win_info * next_win = (struct tui_win_info *) NULL; if (cur_win->generic.type == CMD_WIN) type = SRC_WIN; else type = cur_win->generic.type + 1; while (type != cur_win->generic.type && (next_win == NULL)) { if (tui_win_list[type] && tui_win_list[type]->generic.is_visible) next_win = tui_win_list[type]; else { if (type == CMD_WIN) type = SRC_WIN; else type++; } } return next_win;}/* Answer the prev window in the list, cycling back to the bottom if necessary. */struct tui_win_info *tui_prev_win (struct tui_win_info * cur_win){ enum tui_win_type type = cur_win->generic.type; struct tui_win_info * prev = (struct tui_win_info *) NULL; if (cur_win->generic.type == SRC_WIN) type = CMD_WIN; else type = cur_win->generic.type - 1; while (type != cur_win->generic.type && (prev == NULL)) { if (tui_win_list[type]->generic.is_visible) prev = tui_win_list[type]; else { if (type == SRC_WIN) type = CMD_WIN; else type--; } } return prev;}/* Answer the window represented by name. */struct tui_win_info *tui_partial_win_by_name (char *name){ struct tui_win_info * win_info = (struct tui_win_info *) NULL; if (name != (char *) NULL) { int i = 0; while (i < MAX_MAJOR_WINDOWS && win_info == NULL) { if (tui_win_list[i] != 0) { char *cur_name = tui_win_name (&tui_win_list[i]->generic); if (strlen (name) <= strlen (cur_name) && strncmp (name, cur_name, strlen (name)) == 0) win_info = tui_win_list[i]; } i++; } } return win_info;}/* Answer the name of the window. */char *tui_win_name (struct tui_gen_win_info * win_info){ char *name = (char *) NULL; switch (win_info->type) { case SRC_WIN: name = SRC_NAME; break; case CMD_WIN: name = CMD_NAME; break; case DISASSEM_WIN: name = DISASSEM_NAME; break; case DATA_WIN: name = DATA_NAME; break; default: name = ""; break; } return name;}voidtui_initialize_static_data (void){ tui_init_generic_part (tui_source_exec_info_win_ptr ()); tui_init_generic_part (tui_disassem_exec_info_win_ptr ()); tui_init_generic_part (tui_locator_win_info_ptr ());}struct tui_gen_win_info *tui_alloc_generic_win_info (void){ struct tui_gen_win_info * win; if ((win = (struct tui_gen_win_info *) xmalloc ( sizeof (struct tui_gen_win_info *))) != (struct tui_gen_win_info *) NULL) tui_init_generic_part (win); return win;}voidtui_init_generic_part (struct tui_gen_win_info * win){ win->width = win->height =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -