📄 tuidata.c
字号:
/* TUI data manipulation routines. Copyright 1998, 1999, 2000, 2001, 2002, 2003 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.h"#include "tuiData.h"#include "tuiGeneralWin.h"#ifdef HAVE_NCURSES_H #include <ncurses.h>#else#ifdef HAVE_CURSES_H#include <curses.h>#endif#endif/****************************** GLOBAL DECLARATIONS****************************/TuiWinInfoPtr winList[MAX_MAJOR_WINDOWS];/***************************** Private data****************************/static TuiLayoutType _currentLayout = UNDEFINED_LAYOUT;static int _termHeight, _termWidth;static TuiGenWinInfo _locator;static TuiGenWinInfo _execInfo[2];static TuiWinInfoPtr _srcWinList[2];static TuiList _sourceWindows ={(OpaqueList) _srcWinList, 0};static int _defaultTabLen = DEFAULT_TAB_LEN;static TuiWinInfoPtr _winWithFocus = (TuiWinInfoPtr) NULL;static TuiLayoutDef _layoutDef ={SRC_WIN, /* displayMode */ FALSE, /* split */ TUI_UNDEFINED_REGS, /* regsDisplayType */ TUI_SFLOAT_REGS}; /* floatRegsDisplayType */static int _winResized = FALSE;/*********************************** Static function forward decls**********************************/static void freeContent (TuiWinContent, int, TuiWinType);static void freeContentElements (TuiWinContent, int, TuiWinType);/*********************************** PUBLIC FUNCTIONS**********************************//******************************************** ACCESSORS & MUTATORS FOR PRIVATE DATA******************************************//* ** tuiWinResized(). ** Answer a whether the terminal window has been resized or not */inttuiWinResized (void){ return _winResized;} /* tuiWinResized *//* ** tuiSetWinResized(). ** Set a whether the terminal window has been resized or not */voidtuiSetWinResizedTo (int resized){ _winResized = resized; return;} /* tuiSetWinResizedTo *//* ** tuiLayoutDef(). ** Answer a pointer to the current layout definition */TuiLayoutDefPtrtuiLayoutDef (void){ return &_layoutDef;} /* tuiLayoutDef *//* ** tuiWinWithFocus(). ** Answer the window with the logical focus */TuiWinInfoPtrtuiWinWithFocus (void){ return _winWithFocus;} /* tuiWinWithFocus *//* ** tuiSetWinWithFocus(). ** Set the window that has the logical focus */voidtuiSetWinWithFocus (TuiWinInfoPtr winInfo){ _winWithFocus = winInfo; return;} /* tuiSetWinWithFocus *//* ** tuiDefaultTabLen(). ** Answer the length in chars, of tabs */inttuiDefaultTabLen (void){ return _defaultTabLen;} /* tuiDefaultTabLen *//* ** tuiSetDefaultTabLen(). ** Set the length in chars, of tabs */voidtuiSetDefaultTabLen (int len){ _defaultTabLen = len; return;} /* tuiSetDefaultTabLen *//* ** currentSourceWin() ** 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. */TuiListPtrsourceWindows (void){ return &_sourceWindows;} /* currentSourceWindows *//* ** clearSourceWindows() ** 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. */voidclearSourceWindows (void){ _sourceWindows.list[0] = (Opaque) NULL; _sourceWindows.list[1] = (Opaque) NULL; _sourceWindows.count = 0; return;} /* currentSourceWindows *//* ** clearSourceWindowsDetail() ** Clear the pertinant detail in the source windows. */voidclearSourceWindowsDetail (void){ int i; for (i = 0; i < (sourceWindows ())->count; i++) clearWinDetail ((TuiWinInfoPtr) (sourceWindows ())->list[i]); return;} /* currentSourceWindows *//* ** addSourceWindowToList(). ** 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. */voidaddToSourceWindows (TuiWinInfoPtr winInfo){ if (_sourceWindows.count < 2) _sourceWindows.list[_sourceWindows.count++] = (Opaque) winInfo; return;} /* addToSourceWindows *//* ** clearWinDetail() ** Clear the pertinant detail in the windows. */voidclearWinDetail (TuiWinInfoPtr winInfo){ if (m_winPtrNotNull (winInfo)) { switch (winInfo->generic.type) { case SRC_WIN: case DISASSEM_WIN: winInfo->detail.sourceInfo.startLineOrAddr.addr = 0; winInfo->detail.sourceInfo.horizontalOffset = 0; break; case CMD_WIN: winInfo->detail.commandInfo.curLine = winInfo->detail.commandInfo.curch = 0; break; case DATA_WIN: winInfo->detail.dataDisplayInfo.dataContent = (TuiWinContent) NULL; winInfo->detail.dataDisplayInfo.dataContentCount = 0; winInfo->detail.dataDisplayInfo.regsContent = (TuiWinContent) NULL; winInfo->detail.dataDisplayInfo.regsContentCount = 0; winInfo->detail.dataDisplayInfo.regsDisplayType = TUI_UNDEFINED_REGS; winInfo->detail.dataDisplayInfo.regsColumnCount = 1; winInfo->detail.dataDisplayInfo.displayRegs = FALSE; break; default: break; } } return;} /* clearWinDetail *//* ** sourceExecInfoPtr(). ** Accessor for the source execution info ptr. */TuiGenWinInfoPtrsourceExecInfoWinPtr (void){ return &_execInfo[0];} /* sourceExecInfoWinPtr *//* ** disassemExecInfoPtr(). ** Accessor for the disassem execution info ptr. */TuiGenWinInfoPtrdisassemExecInfoWinPtr (void){ return &_execInfo[1];} /* disassemExecInfoWinPtr *//* ** locatorWinInfoPtr(). ** Accessor for the locator win info. Answers a pointer to the ** static locator win info struct. */TuiGenWinInfoPtrlocatorWinInfoPtr (void){ return &_locator;} /* locatorWinInfoPtr *//* ** termHeight(). ** Accessor for the termHeight */inttermHeight (void){ return _termHeight;} /* termHeight *//* ** setTermHeightTo(). ** Mutator for the term height */voidsetTermHeightTo (int h){ _termHeight = h; return;} /* setTermHeightTo *//* ** termWidth(). ** Accessor for the termWidth */inttermWidth (void){ return _termWidth;} /* termWidth *//* ** setTermWidth(). ** Mutator for the termWidth */voidsetTermWidthTo (int w){ _termWidth = w; return;} /* setTermWidthTo *//* ** currentLayout(). ** Accessor for the current layout */TuiLayoutTypecurrentLayout (void){ return _currentLayout;} /* currentLayout *//* ** setCurrentLayoutTo(). ** Mutator for the current layout */voidsetCurrentLayoutTo (TuiLayoutType newLayout){ _currentLayout = newLayout; return;} /* setCurrentLayoutTo *//* ** setGenWinOrigin(). ** Set the origin of the window */voidsetGenWinOrigin (TuiGenWinInfoPtr winInfo, int x, int y){ winInfo->origin.x = x; winInfo->origin.y = y; return;} /* setGenWinOrigin *//******************************* OTHER PUBLIC FUNCTIONS*****************************//* ** tuiNextWin(). ** Answer the next window in the list, cycling back to the top ** if necessary */TuiWinInfoPtrtuiNextWin (TuiWinInfoPtr curWin){ TuiWinType type = curWin->generic.type; TuiWinInfoPtr nextWin = (TuiWinInfoPtr) NULL; if (curWin->generic.type == CMD_WIN) type = SRC_WIN; else type = curWin->generic.type + 1; while (type != curWin->generic.type && m_winPtrIsNull (nextWin)) { if (winList[type] && winList[type]->generic.isVisible) nextWin = winList[type]; else { if (type == CMD_WIN) type = SRC_WIN; else type++; } } return nextWin;} /* tuiNextWin *//* ** tuiPrevWin(). ** Answer the prev window in the list, cycling back to the bottom ** if necessary */TuiWinInfoPtrtuiPrevWin (TuiWinInfoPtr curWin){ TuiWinType type = curWin->generic.type; TuiWinInfoPtr prev = (TuiWinInfoPtr) NULL; if (curWin->generic.type == SRC_WIN) type = CMD_WIN; else type = curWin->generic.type - 1; while (type != curWin->generic.type && m_winPtrIsNull (prev)) { if (winList[type]->generic.isVisible) prev = winList[type]; else { if (type == SRC_WIN) type = CMD_WIN; else type--; } } return prev;}/* ** partialWinByName(). ** Answer the window represented by name */TuiWinInfoPtrpartialWinByName (char *name){ TuiWinInfoPtr winInfo = (TuiWinInfoPtr) NULL; if (name != (char *) NULL) { int i = 0; while (i < MAX_MAJOR_WINDOWS && m_winPtrIsNull (winInfo)) { if (winList[i] != 0) { char *curName = winName (&winList[i]->generic); if (strlen (name) <= strlen (curName) && strncmp (name, curName, strlen (name)) == 0) winInfo = winList[i]; } i++; } } return winInfo;} /* partialWinByName *//* ** winName(). ** Answer the name of the window */char *winName (TuiGenWinInfoPtr winInfo){ char *name = (char *) NULL; switch (winInfo->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;} /* winName *//* ** initializeStaticData */voidinitializeStaticData (void){ initGenericPart (sourceExecInfoWinPtr ()); initGenericPart (disassemExecInfoWinPtr ()); initGenericPart (locatorWinInfoPtr ()); return;} /* initializeStaticData */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -