1 /* TUI data manipulation routines.
2 Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Hewlett-Packard Company.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
25 #if defined (HAVE_NCURSES_H)
27 #elif defined (HAVE_CURSES_H)
31 /* Generic window information */
32 typedef struct _TuiGenWinInfo
34 WINDOW
*handle
; /* window handle */
35 TuiWinType type
; /* type of window */
36 int width
; /* window width */
37 int height
; /* window height */
38 TuiPoint origin
; /* origin of window */
39 OpaquePtr content
; /* content of window */
40 int contentSize
; /* Size of content (# of elements) */
41 int contentInUse
; /* Can it be used, or is it already used? */
42 int viewportHeight
; /* viewport height */
43 int lastVisibleLine
; /* index of last visible line */
44 int isVisible
; /* whether the window is visible or not */
46 TuiGenWinInfo
, *TuiGenWinInfoPtr
;
48 /* Constant definitions */
49 #define DEFAULT_TAB_LEN 8
50 #define NO_SRC_STRING "[ No Source Available ]"
51 #define NO_DISASSEM_STRING "[ No Assembly Available ]"
52 #define NO_REGS_STRING "[ Register Values Unavailable ]"
53 #define NO_DATA_STRING "[ No Data Values Displayed ]"
54 #define MAX_CONTENT_COUNT 100
55 #define SRC_NAME "SRC"
56 #define CMD_NAME "CMD"
57 #define DATA_NAME "REGS"
58 #define DISASSEM_NAME "ASM"
59 #define TUI_NULL_STR ""
60 #define DEFAULT_HISTORY_COUNT 25
61 #define BOX_WINDOW TRUE
62 #define DONT_BOX_WINDOW FALSE
64 #define NO_HILITE FALSE
65 #define WITH_LOCATOR TRUE
66 #define NO_LOCATOR FALSE
67 #define EMPTY_SOURCE_PROMPT TRUE
68 #define NO_EMPTY_SOURCE_PROMPT FALSE
69 #define UNDEFINED_ITEM -1
70 #define MIN_WIN_HEIGHT 3
71 #define MIN_CMD_WIN_HEIGHT 3
73 #define FILE_PREFIX "File: "
74 #define PROC_PREFIX "Procedure: "
75 #define LINE_PREFIX "Line: "
76 #define PC_PREFIX "pc: "
78 #define TUI_FLOAT_REGS_NAME "$FREGS"
79 #define TUI_FLOAT_REGS_NAME_LOWER "$fregs"
80 #define TUI_GENERAL_REGS_NAME "$GREGS"
81 #define TUI_GENERAL_REGS_NAME_LOWER "$gregs"
82 #define TUI_SPECIAL_REGS_NAME "$SREGS"
83 #define TUI_SPECIAL_REGS_NAME_LOWER "$sregs"
84 #define TUI_GENERAL_SPECIAL_REGS_NAME "$REGS"
85 #define TUI_GENERAL_SPECIAL_REGS_NAME_LOWER "$regs"
87 /* Scroll direction enum */
95 TuiScrollDirection
, *TuiScrollDirectionPtr
;
98 /* General list struct */
99 typedef struct _TuiList
104 TuiList
, *TuiListPtr
;
107 /* The kinds of layouts available */
112 SRC_DISASSEM_COMMAND
,
114 DISASSEM_DATA_COMMAND
,
117 TuiLayoutType
, *TuiLayoutTypePtr
;
119 /* Basic data types that can be displayed in the data window. */
120 typedef enum _TuiDataType
127 TuiDataType
, TuiDataTypePtr
;
129 /* Types of register displays */
130 typedef enum _TuiRegisterDisplayType
137 TUI_GENERAL_AND_SPECIAL_REGS
139 TuiRegisterDisplayType
, *TuiRegisterDisplayTypePtr
;
141 /* Structure describing source line or line address */
142 typedef union _TuiLineOrAddress
147 TuiLineOrAddress
, *TuiLineOrAddressPtr
;
149 /* Current Layout definition */
150 typedef struct _TuiLayoutDef
152 TuiWinType displayMode
;
154 TuiRegisterDisplayType regsDisplayType
;
155 TuiRegisterDisplayType floatRegsDisplayType
;
157 TuiLayoutDef
, *TuiLayoutDefPtr
;
159 /* Elements in the Source/Disassembly Window */
160 typedef struct _TuiSourceElement
163 TuiLineOrAddress lineOrAddr
;
167 TuiSourceElement
, *TuiSourceElementPtr
;
170 /* Elements in the data display window content */
171 typedef struct _TuiDataElement
174 int itemNo
; /* the register number, or data display number */
179 TuiDataElement
, *TuiDataElementPtr
;
182 /* Elements in the command window content */
183 typedef struct _TuiCommandElement
187 TuiCommandElement
, *TuiCommandElementPtr
;
190 #define MAX_LOCATOR_ELEMENT_LEN 100
192 /* Elements in the locator window content */
193 typedef struct _TuiLocatorElement
195 char fileName
[MAX_LOCATOR_ELEMENT_LEN
];
196 char procName
[MAX_LOCATOR_ELEMENT_LEN
];
200 TuiLocatorElement
, *TuiLocatorElementPtr
;
203 /* An content element in a window */
206 TuiSourceElement source
; /* the source elements */
207 TuiGenWinInfo dataWindow
; /* data display elements */
208 TuiDataElement data
; /* elements of dataWindow */
209 TuiCommandElement command
; /* command elements */
210 TuiLocatorElement locator
; /* locator elements */
211 char *simpleString
; /* simple char based elements */
213 TuiWhichElement
, *TuiWhichElementPtr
;
215 typedef struct _TuiWinElement
218 TuiWhichElement whichElement
;
220 TuiWinElement
, *TuiWinElementPtr
;
223 /* This describes the content of the window. */
224 typedef TuiWinElementPtr
*TuiWinContent
;
227 /* This struct defines the specific information about a data display window */
228 typedef struct _TuiDataInfo
230 TuiWinContent dataContent
; /* start of data display content */
231 int dataContentCount
;
232 TuiWinContent regsContent
; /* start of regs display content */
233 int regsContentCount
;
234 TuiRegisterDisplayType regsDisplayType
;
236 int displayRegs
; /* Should regs be displayed at all? */
238 TuiDataInfo
, *TuiDataInfoPtr
;
241 typedef struct _TuiSourceInfo
243 int hasLocator
; /* Does locator belongs to this window? */
244 TuiGenWinInfoPtr executionInfo
; /* execution information window */
245 int horizontalOffset
; /* used for horizontal scroll */
246 TuiLineOrAddress startLineOrAddr
;
248 TuiSourceInfo
, *TuiSourceInfoPtr
;
251 typedef struct _TuiCommandInfo
253 int curLine
; /* The current line position */
254 int curch
; /* The current cursor position */
257 TuiCommandInfo
, *TuiCommandInfoPtr
;
260 /* This defines information about each logical window */
261 typedef struct _TuiWinInfo
263 TuiGenWinInfo generic
; /* general window information */
266 TuiSourceInfo sourceInfo
;
267 TuiDataInfo dataDisplayInfo
;
268 TuiCommandInfo commandInfo
;
272 int canHighlight
; /* Can this window ever be highlighted? */
273 int isHighlighted
; /* Is this window highlighted? */
275 TuiWinInfo
, *TuiWinInfoPtr
;
277 /* MACROS (prefixed with m_) */
280 #define m_genWinPtrIsNull(winInfo) \
281 ((winInfo) == (TuiGenWinInfoPtr)NULL)
282 #define m_genWinPtrNotNull(winInfo) \
283 ((winInfo) != (TuiGenWinInfoPtr)NULL)
284 #define m_winPtrIsNull(winInfo) \
285 ((winInfo) == (TuiWinInfoPtr)NULL)
286 #define m_winPtrNotNull(winInfo) \
287 ((winInfo) != (TuiWinInfoPtr)NULL)
289 #define m_winIsSourceType(type) \
290 (type == SRC_WIN || type == DISASSEM_WIN)
291 #define m_winIsAuxillary(winType) \
292 (winType > MAX_MAJOR_WINDOWS)
293 #define m_hasLocator(winInfo) \
294 ( ((winInfo) != (TuiWinInfoPtr)NULL) ? \
295 (winInfo->detail.sourceInfo.hasLocator) : \
298 #define m_setWinHighlightOn(winInfo) \
299 if ((winInfo) != (TuiWinInfoPtr)NULL) \
300 (winInfo)->isHighlighted = TRUE
301 #define m_setWinHighlightOff(winInfo) \
302 if ((winInfo) != (TuiWinInfoPtr)NULL) \
303 (winInfo)->isHighlighted = FALSE
307 extern TuiWinInfoPtr winList
[MAX_MAJOR_WINDOWS
];
308 extern int tui_version
;
311 #define srcWin winList[SRC_WIN]
312 #define disassemWin winList[DISASSEM_WIN]
313 #define dataWin winList[DATA_WIN]
314 #define cmdWin winList[CMD_WIN]
316 /* Data Manipulation Functions */
317 extern void initializeStaticData (void);
318 extern TuiGenWinInfoPtr
allocGenericWinInfo (void);
319 extern TuiWinInfoPtr
allocWinInfo (TuiWinType
);
320 extern void initGenericPart (TuiGenWinInfoPtr
);
321 extern void initWinInfo (TuiWinInfoPtr
);
322 extern TuiWinContent
allocContent (int, TuiWinType
);
323 extern int addContentElements (TuiGenWinInfoPtr
, int);
324 extern void initContentElement (TuiWinElementPtr
, TuiWinType
);
325 extern void freeWindow (TuiWinInfoPtr
);
326 extern void freeAllWindows (void);
327 extern void freeWinContent (TuiGenWinInfoPtr
);
328 extern void freeDataContent (TuiWinContent
, int);
329 extern void freeAllSourceWinsContent (void);
330 extern void tuiDelWindow (TuiWinInfoPtr
);
331 extern void tuiDelDataWindows (TuiWinContent
, int);
332 extern TuiWinInfoPtr
winByName (char *);
333 extern TuiWinInfoPtr
partialWinByName (char *);
334 extern char *winName (TuiGenWinInfoPtr
);
335 extern char *displayableWinContentOf (TuiGenWinInfoPtr
, TuiWinElementPtr
);
336 extern char *displayableWinContentAt (TuiGenWinInfoPtr
, int);
337 extern int winElementHeight (TuiGenWinInfoPtr
, TuiWinElementPtr
);
338 extern TuiLayoutType
currentLayout (void);
339 extern void setCurrentLayoutTo (TuiLayoutType
);
340 extern int termHeight (void);
341 extern void setTermHeightTo (int);
342 extern int termWidth (void);
343 extern void setTermWidthTo (int);
344 extern int historyLimit (void);
345 extern void setHistoryLimit (int);
346 extern void setGenWinOrigin (TuiGenWinInfoPtr
, int, int);
347 extern TuiGenWinInfoPtr
locatorWinInfoPtr (void);
348 extern TuiGenWinInfoPtr
sourceExecInfoWinPtr (void);
349 extern TuiGenWinInfoPtr
disassemExecInfoWinPtr (void);
350 extern char *nullStr (void);
351 extern char *blankStr (void);
352 extern char *locationStr (void);
353 extern char *breakStr (void);
354 extern char *breakLocationStr (void);
355 extern TuiListPtr
sourceWindows (void);
356 extern void clearSourceWindows (void);
357 extern void clearSourceWindowsDetail (void);
358 extern void clearWinDetail (TuiWinInfoPtr winInfo
);
359 extern void tuiAddToSourceWindows (TuiWinInfoPtr
);
360 extern int tuiDefaultTabLen (void);
361 extern void tuiSetDefaultTabLen (int);
362 extern TuiWinInfoPtr
tuiWinWithFocus (void);
363 extern void tuiSetWinWithFocus (TuiWinInfoPtr
);
364 extern TuiLayoutDefPtr
tuiLayoutDef (void);
365 extern int tuiWinResized (void);
366 extern void tuiSetWinResizedTo (int);
368 extern TuiWinInfoPtr
tuiNextWin (TuiWinInfoPtr
);
369 extern TuiWinInfoPtr
tuiPrevWin (TuiWinInfoPtr
);
371 extern void addToSourceWindows (TuiWinInfoPtr winInfo
);
373 #endif /* TUI_DATA_H */