1 /* TUI data manipulation routines.
2 Copyright 1998, 1999, 2000, 2001, 2002 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 */
45 char* title
; /* Window title to display. */
47 TuiGenWinInfo
, *TuiGenWinInfoPtr
;
49 /* Constant definitions */
50 #define DEFAULT_TAB_LEN 8
51 #define NO_SRC_STRING "[ No Source Available ]"
52 #define NO_DISASSEM_STRING "[ No Assembly Available ]"
53 #define NO_REGS_STRING "[ Register Values Unavailable ]"
54 #define NO_DATA_STRING "[ No Data Values Displayed ]"
55 #define MAX_CONTENT_COUNT 100
56 #define SRC_NAME "SRC"
57 #define CMD_NAME "CMD"
58 #define DATA_NAME "REGS"
59 #define DISASSEM_NAME "ASM"
60 #define TUI_NULL_STR ""
61 #define DEFAULT_HISTORY_COUNT 25
62 #define BOX_WINDOW TRUE
63 #define DONT_BOX_WINDOW FALSE
65 #define NO_HILITE FALSE
66 #define WITH_LOCATOR TRUE
67 #define NO_LOCATOR FALSE
68 #define EMPTY_SOURCE_PROMPT TRUE
69 #define NO_EMPTY_SOURCE_PROMPT FALSE
70 #define UNDEFINED_ITEM -1
71 #define MIN_WIN_HEIGHT 3
72 #define MIN_CMD_WIN_HEIGHT 3
74 #define FILE_PREFIX "File: "
75 #define PROC_PREFIX "Procedure: "
76 #define LINE_PREFIX "Line: "
77 #define PC_PREFIX "pc: "
79 #define TUI_FLOAT_REGS_NAME "$FREGS"
80 #define TUI_FLOAT_REGS_NAME_LOWER "$fregs"
81 #define TUI_GENERAL_REGS_NAME "$GREGS"
82 #define TUI_GENERAL_REGS_NAME_LOWER "$gregs"
83 #define TUI_SPECIAL_REGS_NAME "$SREGS"
84 #define TUI_SPECIAL_REGS_NAME_LOWER "$sregs"
85 #define TUI_GENERAL_SPECIAL_REGS_NAME "$REGS"
86 #define TUI_GENERAL_SPECIAL_REGS_NAME_LOWER "$regs"
88 /* Scroll direction enum */
96 TuiScrollDirection
, *TuiScrollDirectionPtr
;
99 /* General list struct */
100 typedef struct _TuiList
105 TuiList
, *TuiListPtr
;
108 /* The kinds of layouts available */
113 SRC_DISASSEM_COMMAND
,
115 DISASSEM_DATA_COMMAND
,
118 TuiLayoutType
, *TuiLayoutTypePtr
;
120 /* Basic data types that can be displayed in the data window. */
121 typedef enum _TuiDataType
128 TuiDataType
, TuiDataTypePtr
;
130 /* Types of register displays */
131 typedef enum _TuiRegisterDisplayType
138 TUI_GENERAL_AND_SPECIAL_REGS
140 TuiRegisterDisplayType
, *TuiRegisterDisplayTypePtr
;
142 /* Structure describing source line or line address */
143 typedef union _TuiLineOrAddress
148 TuiLineOrAddress
, *TuiLineOrAddressPtr
;
150 /* Current Layout definition */
151 typedef struct _TuiLayoutDef
153 TuiWinType displayMode
;
155 TuiRegisterDisplayType regsDisplayType
;
156 TuiRegisterDisplayType floatRegsDisplayType
;
158 TuiLayoutDef
, *TuiLayoutDefPtr
;
160 /* Elements in the Source/Disassembly Window */
161 typedef struct _TuiSourceElement
164 TuiLineOrAddress lineOrAddr
;
168 TuiSourceElement
, *TuiSourceElementPtr
;
171 /* Elements in the data display window content */
172 typedef struct _TuiDataElement
175 int itemNo
; /* the register number, or data display number */
180 TuiDataElement
, *TuiDataElementPtr
;
183 /* Elements in the command window content */
184 typedef struct _TuiCommandElement
188 TuiCommandElement
, *TuiCommandElementPtr
;
191 #define MAX_LOCATOR_ELEMENT_LEN 100
193 /* Elements in the locator window content */
194 typedef struct _TuiLocatorElement
196 char fileName
[MAX_LOCATOR_ELEMENT_LEN
];
197 char procName
[MAX_LOCATOR_ELEMENT_LEN
];
201 TuiLocatorElement
, *TuiLocatorElementPtr
;
204 /* An content element in a window */
207 TuiSourceElement source
; /* the source elements */
208 TuiGenWinInfo dataWindow
; /* data display elements */
209 TuiDataElement data
; /* elements of dataWindow */
210 TuiCommandElement command
; /* command elements */
211 TuiLocatorElement locator
; /* locator elements */
212 char *simpleString
; /* simple char based elements */
214 TuiWhichElement
, *TuiWhichElementPtr
;
216 typedef struct _TuiWinElement
219 TuiWhichElement whichElement
;
221 TuiWinElement
, *TuiWinElementPtr
;
224 /* This describes the content of the window. */
225 typedef TuiWinElementPtr
*TuiWinContent
;
228 /* This struct defines the specific information about a data display window */
229 typedef struct _TuiDataInfo
231 TuiWinContent dataContent
; /* start of data display content */
232 int dataContentCount
;
233 TuiWinContent regsContent
; /* start of regs display content */
234 int regsContentCount
;
235 TuiRegisterDisplayType regsDisplayType
;
237 int displayRegs
; /* Should regs be displayed at all? */
239 TuiDataInfo
, *TuiDataInfoPtr
;
242 typedef struct _TuiSourceInfo
244 int hasLocator
; /* Does locator belongs to this window? */
245 TuiGenWinInfoPtr executionInfo
; /* execution information window */
246 int horizontalOffset
; /* used for horizontal scroll */
247 TuiLineOrAddress startLineOrAddr
;
250 TuiSourceInfo
, *TuiSourceInfoPtr
;
253 typedef struct _TuiCommandInfo
255 int curLine
; /* The current line position */
256 int curch
; /* The current cursor position */
259 TuiCommandInfo
, *TuiCommandInfoPtr
;
262 /* This defines information about each logical window */
263 typedef struct _TuiWinInfo
265 TuiGenWinInfo generic
; /* general window information */
268 TuiSourceInfo sourceInfo
;
269 TuiDataInfo dataDisplayInfo
;
270 TuiCommandInfo commandInfo
;
274 int canHighlight
; /* Can this window ever be highlighted? */
275 int isHighlighted
; /* Is this window highlighted? */
277 TuiWinInfo
, *TuiWinInfoPtr
;
279 /* MACROS (prefixed with m_) */
282 #define m_genWinPtrIsNull(winInfo) \
283 ((winInfo) == (TuiGenWinInfoPtr)NULL)
284 #define m_genWinPtrNotNull(winInfo) \
285 ((winInfo) != (TuiGenWinInfoPtr)NULL)
286 #define m_winPtrIsNull(winInfo) \
287 ((winInfo) == (TuiWinInfoPtr)NULL)
288 #define m_winPtrNotNull(winInfo) \
289 ((winInfo) != (TuiWinInfoPtr)NULL)
291 #define m_winIsSourceType(type) \
292 (type == SRC_WIN || type == DISASSEM_WIN)
293 #define m_winIsAuxillary(winType) \
294 (winType > MAX_MAJOR_WINDOWS)
295 #define m_hasLocator(winInfo) \
296 ( ((winInfo) != (TuiWinInfoPtr)NULL) ? \
297 (winInfo->detail.sourceInfo.hasLocator) : \
300 #define m_setWinHighlightOn(winInfo) \
301 if ((winInfo) != (TuiWinInfoPtr)NULL) \
302 (winInfo)->isHighlighted = TRUE
303 #define m_setWinHighlightOff(winInfo) \
304 if ((winInfo) != (TuiWinInfoPtr)NULL) \
305 (winInfo)->isHighlighted = FALSE
309 extern TuiWinInfoPtr winList
[MAX_MAJOR_WINDOWS
];
310 extern int tui_version
;
313 #define srcWin winList[SRC_WIN]
314 #define disassemWin winList[DISASSEM_WIN]
315 #define dataWin winList[DATA_WIN]
316 #define cmdWin winList[CMD_WIN]
318 /* Data Manipulation Functions */
319 extern void initializeStaticData (void);
320 extern TuiGenWinInfoPtr
allocGenericWinInfo (void);
321 extern TuiWinInfoPtr
allocWinInfo (TuiWinType
);
322 extern void initGenericPart (TuiGenWinInfoPtr
);
323 extern void initWinInfo (TuiWinInfoPtr
);
324 extern TuiWinContent
allocContent (int, TuiWinType
);
325 extern int addContentElements (TuiGenWinInfoPtr
, int);
326 extern void initContentElement (TuiWinElementPtr
, TuiWinType
);
327 extern void freeWindow (TuiWinInfoPtr
);
328 extern void freeAllWindows (void);
329 extern void freeWinContent (TuiGenWinInfoPtr
);
330 extern void freeDataContent (TuiWinContent
, int);
331 extern void freeAllSourceWinsContent (void);
332 extern void tuiDelWindow (TuiWinInfoPtr
);
333 extern void tuiDelDataWindows (TuiWinContent
, int);
334 extern TuiWinInfoPtr
winByName (char *);
335 extern TuiWinInfoPtr
partialWinByName (char *);
336 extern char *winName (TuiGenWinInfoPtr
);
337 extern char *displayableWinContentOf (TuiGenWinInfoPtr
, TuiWinElementPtr
);
338 extern char *displayableWinContentAt (TuiGenWinInfoPtr
, int);
339 extern int winElementHeight (TuiGenWinInfoPtr
, TuiWinElementPtr
);
340 extern TuiLayoutType
currentLayout (void);
341 extern void setCurrentLayoutTo (TuiLayoutType
);
342 extern int termHeight (void);
343 extern void setTermHeightTo (int);
344 extern int termWidth (void);
345 extern void setTermWidthTo (int);
346 extern int historyLimit (void);
347 extern void setHistoryLimit (int);
348 extern void setGenWinOrigin (TuiGenWinInfoPtr
, int, int);
349 extern TuiGenWinInfoPtr
locatorWinInfoPtr (void);
350 extern TuiGenWinInfoPtr
sourceExecInfoWinPtr (void);
351 extern TuiGenWinInfoPtr
disassemExecInfoWinPtr (void);
352 extern char *nullStr (void);
353 extern char *blankStr (void);
354 extern char *locationStr (void);
355 extern char *breakStr (void);
356 extern char *breakLocationStr (void);
357 extern TuiListPtr
sourceWindows (void);
358 extern void clearSourceWindows (void);
359 extern void clearSourceWindowsDetail (void);
360 extern void clearWinDetail (TuiWinInfoPtr winInfo
);
361 extern void tuiAddToSourceWindows (TuiWinInfoPtr
);
362 extern int tuiDefaultTabLen (void);
363 extern void tuiSetDefaultTabLen (int);
364 extern TuiWinInfoPtr
tuiWinWithFocus (void);
365 extern void tuiSetWinWithFocus (TuiWinInfoPtr
);
366 extern TuiLayoutDefPtr
tuiLayoutDef (void);
367 extern int tuiWinResized (void);
368 extern void tuiSetWinResizedTo (int);
370 extern TuiWinInfoPtr
tuiNextWin (TuiWinInfoPtr
);
371 extern TuiWinInfoPtr
tuiPrevWin (TuiWinInfoPtr
);
373 extern void addToSourceWindows (TuiWinInfoPtr winInfo
);
375 #endif /* TUI_DATA_H */