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 /* Strings to display in the TUI status line. */
75 #define PROC_PREFIX "In: "
76 #define LINE_PREFIX "Line: "
77 #define PC_PREFIX "PC: "
78 #define SINGLE_KEY "(SingleKey)"
80 /* Minimum/Maximum length of some fields displayed in the TUI status line. */
81 #define MIN_LINE_WIDTH 4 /* Use at least 4 digits for line numbers. */
82 #define MIN_PROC_WIDTH 12
83 #define MAX_TARGET_WIDTH 10
84 #define MAX_PID_WIDTH 14
86 #define TUI_FLOAT_REGS_NAME "$FREGS"
87 #define TUI_FLOAT_REGS_NAME_LOWER "$fregs"
88 #define TUI_GENERAL_REGS_NAME "$GREGS"
89 #define TUI_GENERAL_REGS_NAME_LOWER "$gregs"
90 #define TUI_SPECIAL_REGS_NAME "$SREGS"
91 #define TUI_SPECIAL_REGS_NAME_LOWER "$sregs"
92 #define TUI_GENERAL_SPECIAL_REGS_NAME "$REGS"
93 #define TUI_GENERAL_SPECIAL_REGS_NAME_LOWER "$regs"
95 /* Scroll direction enum */
103 TuiScrollDirection
, *TuiScrollDirectionPtr
;
106 /* General list struct */
107 typedef struct _TuiList
112 TuiList
, *TuiListPtr
;
115 /* The kinds of layouts available */
120 SRC_DISASSEM_COMMAND
,
122 DISASSEM_DATA_COMMAND
,
125 TuiLayoutType
, *TuiLayoutTypePtr
;
127 /* Basic data types that can be displayed in the data window. */
128 typedef enum _TuiDataType
135 TuiDataType
, TuiDataTypePtr
;
137 /* Types of register displays */
138 typedef enum _TuiRegisterDisplayType
145 TUI_GENERAL_AND_SPECIAL_REGS
147 TuiRegisterDisplayType
, *TuiRegisterDisplayTypePtr
;
149 /* Structure describing source line or line address */
150 typedef union _TuiLineOrAddress
155 TuiLineOrAddress
, *TuiLineOrAddressPtr
;
157 /* Current Layout definition */
158 typedef struct _TuiLayoutDef
160 TuiWinType displayMode
;
162 TuiRegisterDisplayType regsDisplayType
;
163 TuiRegisterDisplayType floatRegsDisplayType
;
165 TuiLayoutDef
, *TuiLayoutDefPtr
;
167 /* Elements in the Source/Disassembly Window */
168 typedef struct _TuiSourceElement
171 TuiLineOrAddress lineOrAddr
;
175 TuiSourceElement
, *TuiSourceElementPtr
;
178 /* Elements in the data display window content */
179 typedef struct _TuiDataElement
182 int itemNo
; /* the register number, or data display number */
187 TuiDataElement
, *TuiDataElementPtr
;
190 /* Elements in the command window content */
191 typedef struct _TuiCommandElement
195 TuiCommandElement
, *TuiCommandElementPtr
;
198 #define MAX_LOCATOR_ELEMENT_LEN 100
200 /* Elements in the locator window content */
201 typedef struct _TuiLocatorElement
203 char fileName
[MAX_LOCATOR_ELEMENT_LEN
];
204 char procName
[MAX_LOCATOR_ELEMENT_LEN
];
208 TuiLocatorElement
, *TuiLocatorElementPtr
;
210 /* Flags to tell what kind of breakpoint is at current line. */
211 #define TUI_BP_ENABLED 0x01
212 #define TUI_BP_DISABLED 0x02
213 #define TUI_BP_HIT 0x04
214 #define TUI_BP_CONDITIONAL 0x08
215 #define TUI_BP_HARDWARE 0x10
217 /* Position of breakpoint markers in the exec info string. */
218 #define TUI_BP_HIT_POS 0
219 #define TUI_BP_BREAK_POS 1
220 #define TUI_EXEC_POS 2
221 #define TUI_EXECINFO_SIZE 4
223 typedef char TuiExecInfoContent
[TUI_EXECINFO_SIZE
];
225 /* An content element in a window */
228 TuiSourceElement source
; /* the source elements */
229 TuiGenWinInfo dataWindow
; /* data display elements */
230 TuiDataElement data
; /* elements of dataWindow */
231 TuiCommandElement command
; /* command elements */
232 TuiLocatorElement locator
; /* locator elements */
233 TuiExecInfoContent simpleString
; /* simple char based elements */
235 TuiWhichElement
, *TuiWhichElementPtr
;
237 typedef struct _TuiWinElement
240 TuiWhichElement whichElement
;
242 TuiWinElement
, *TuiWinElementPtr
;
245 /* This describes the content of the window. */
246 typedef TuiWinElementPtr
*TuiWinContent
;
249 /* This struct defines the specific information about a data display window */
250 typedef struct _TuiDataInfo
252 TuiWinContent dataContent
; /* start of data display content */
253 int dataContentCount
;
254 TuiWinContent regsContent
; /* start of regs display content */
255 int regsContentCount
;
256 TuiRegisterDisplayType regsDisplayType
;
258 int displayRegs
; /* Should regs be displayed at all? */
260 TuiDataInfo
, *TuiDataInfoPtr
;
263 typedef struct _TuiSourceInfo
265 int hasLocator
; /* Does locator belongs to this window? */
266 TuiGenWinInfoPtr executionInfo
; /* execution information window */
267 int horizontalOffset
; /* used for horizontal scroll */
268 TuiLineOrAddress startLineOrAddr
;
271 TuiSourceInfo
, *TuiSourceInfoPtr
;
274 typedef struct _TuiCommandInfo
276 int curLine
; /* The current line position */
277 int curch
; /* The current cursor position */
280 TuiCommandInfo
, *TuiCommandInfoPtr
;
283 /* This defines information about each logical window */
284 typedef struct _TuiWinInfo
286 TuiGenWinInfo generic
; /* general window information */
289 TuiSourceInfo sourceInfo
;
290 TuiDataInfo dataDisplayInfo
;
291 TuiCommandInfo commandInfo
;
295 int canHighlight
; /* Can this window ever be highlighted? */
296 int isHighlighted
; /* Is this window highlighted? */
298 TuiWinInfo
, *TuiWinInfoPtr
;
300 /* MACROS (prefixed with m_) */
303 #define m_genWinPtrIsNull(winInfo) \
304 ((winInfo) == (TuiGenWinInfoPtr)NULL)
305 #define m_genWinPtrNotNull(winInfo) \
306 ((winInfo) != (TuiGenWinInfoPtr)NULL)
307 #define m_winPtrIsNull(winInfo) \
308 ((winInfo) == (TuiWinInfoPtr)NULL)
309 #define m_winPtrNotNull(winInfo) \
310 ((winInfo) != (TuiWinInfoPtr)NULL)
312 #define m_winIsSourceType(type) \
313 (type == SRC_WIN || type == DISASSEM_WIN)
314 #define m_winIsAuxillary(winType) \
315 (winType > MAX_MAJOR_WINDOWS)
316 #define m_hasLocator(winInfo) \
317 ( ((winInfo) != (TuiWinInfoPtr)NULL) ? \
318 (winInfo->detail.sourceInfo.hasLocator) : \
321 #define m_setWinHighlightOn(winInfo) \
322 if ((winInfo) != (TuiWinInfoPtr)NULL) \
323 (winInfo)->isHighlighted = TRUE
324 #define m_setWinHighlightOff(winInfo) \
325 if ((winInfo) != (TuiWinInfoPtr)NULL) \
326 (winInfo)->isHighlighted = FALSE
330 extern TuiWinInfoPtr winList
[MAX_MAJOR_WINDOWS
];
333 #define srcWin winList[SRC_WIN]
334 #define disassemWin winList[DISASSEM_WIN]
335 #define dataWin winList[DATA_WIN]
336 #define cmdWin winList[CMD_WIN]
338 /* Data Manipulation Functions */
339 extern void initializeStaticData (void);
340 extern TuiGenWinInfoPtr
allocGenericWinInfo (void);
341 extern TuiWinInfoPtr
allocWinInfo (TuiWinType
);
342 extern void initGenericPart (TuiGenWinInfoPtr
);
343 extern void initWinInfo (TuiWinInfoPtr
);
344 extern TuiWinContent
allocContent (int, TuiWinType
);
345 extern int addContentElements (TuiGenWinInfoPtr
, int);
346 extern void initContentElement (TuiWinElementPtr
, TuiWinType
);
347 extern void freeWindow (TuiWinInfoPtr
);
348 extern void freeWinContent (TuiGenWinInfoPtr
);
349 extern void freeDataContent (TuiWinContent
, int);
350 extern void freeAllSourceWinsContent (void);
351 extern void tuiDelWindow (TuiWinInfoPtr
);
352 extern void tuiDelDataWindows (TuiWinContent
, int);
353 extern TuiWinInfoPtr
partialWinByName (char *);
354 extern char *winName (TuiGenWinInfoPtr
);
355 extern TuiLayoutType
currentLayout (void);
356 extern void setCurrentLayoutTo (TuiLayoutType
);
357 extern int termHeight (void);
358 extern void setTermHeightTo (int);
359 extern int termWidth (void);
360 extern void setTermWidthTo (int);
361 extern void setGenWinOrigin (TuiGenWinInfoPtr
, int, int);
362 extern TuiGenWinInfoPtr
locatorWinInfoPtr (void);
363 extern TuiGenWinInfoPtr
sourceExecInfoWinPtr (void);
364 extern TuiGenWinInfoPtr
disassemExecInfoWinPtr (void);
365 extern TuiListPtr
sourceWindows (void);
366 extern void clearSourceWindows (void);
367 extern void clearSourceWindowsDetail (void);
368 extern void clearWinDetail (TuiWinInfoPtr winInfo
);
369 extern void tuiAddToSourceWindows (TuiWinInfoPtr
);
370 extern int tuiDefaultTabLen (void);
371 extern void tuiSetDefaultTabLen (int);
372 extern TuiWinInfoPtr
tuiWinWithFocus (void);
373 extern void tuiSetWinWithFocus (TuiWinInfoPtr
);
374 extern TuiLayoutDefPtr
tuiLayoutDef (void);
375 extern int tuiWinResized (void);
376 extern void tuiSetWinResizedTo (int);
378 extern TuiWinInfoPtr
tuiNextWin (TuiWinInfoPtr
);
379 extern TuiWinInfoPtr
tuiPrevWin (TuiWinInfoPtr
);
381 extern void addToSourceWindows (TuiWinInfoPtr winInfo
);
383 #endif /* TUI_DATA_H */