1 /* TUI data manipulation routines.
3 Copyright 1998, 1999, 2000, 2001, 2002, 2004 Free Software
6 Contributed by Hewlett-Packard Company.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
28 #if defined (HAVE_NCURSES_H)
30 #elif defined (HAVE_CURSES_H)
34 /* Generic window information */
35 typedef struct _TuiGenWinInfo
37 WINDOW
*handle
; /* window handle */
38 TuiWinType type
; /* type of window */
39 int width
; /* window width */
40 int height
; /* window height */
41 TuiPoint origin
; /* origin of window */
42 OpaquePtr content
; /* content of window */
43 int contentSize
; /* Size of content (# of elements) */
44 int contentInUse
; /* Can it be used, or is it already used? */
45 int viewportHeight
; /* viewport height */
46 int lastVisibleLine
; /* index of last visible line */
47 int isVisible
; /* whether the window is visible or not */
48 char* title
; /* Window title to display. */
50 TuiGenWinInfo
, *TuiGenWinInfoPtr
;
52 /* Constant definitions */
53 #define DEFAULT_TAB_LEN 8
54 #define NO_SRC_STRING "[ No Source Available ]"
55 #define NO_DISASSEM_STRING "[ No Assembly Available ]"
56 #define NO_REGS_STRING "[ Register Values Unavailable ]"
57 #define NO_DATA_STRING "[ No Data Values Displayed ]"
58 #define MAX_CONTENT_COUNT 100
59 #define SRC_NAME "SRC"
60 #define CMD_NAME "CMD"
61 #define DATA_NAME "REGS"
62 #define DISASSEM_NAME "ASM"
63 #define TUI_NULL_STR ""
64 #define DEFAULT_HISTORY_COUNT 25
65 #define BOX_WINDOW TRUE
66 #define DONT_BOX_WINDOW FALSE
68 #define NO_HILITE FALSE
69 #define WITH_LOCATOR TRUE
70 #define NO_LOCATOR FALSE
71 #define EMPTY_SOURCE_PROMPT TRUE
72 #define NO_EMPTY_SOURCE_PROMPT FALSE
73 #define UNDEFINED_ITEM -1
74 #define MIN_WIN_HEIGHT 3
75 #define MIN_CMD_WIN_HEIGHT 3
77 /* Strings to display in the TUI status line. */
78 #define PROC_PREFIX "In: "
79 #define LINE_PREFIX "Line: "
80 #define PC_PREFIX "PC: "
81 #define SINGLE_KEY "(SingleKey)"
83 /* Minimum/Maximum length of some fields displayed in the TUI status line. */
84 #define MIN_LINE_WIDTH 4 /* Use at least 4 digits for line numbers. */
85 #define MIN_PROC_WIDTH 12
86 #define MAX_TARGET_WIDTH 10
87 #define MAX_PID_WIDTH 14
89 #define TUI_FLOAT_REGS_NAME "$FREGS"
90 #define TUI_FLOAT_REGS_NAME_LOWER "$fregs"
91 #define TUI_GENERAL_REGS_NAME "$GREGS"
92 #define TUI_GENERAL_REGS_NAME_LOWER "$gregs"
93 #define TUI_SPECIAL_REGS_NAME "$SREGS"
94 #define TUI_SPECIAL_REGS_NAME_LOWER "$sregs"
95 #define TUI_GENERAL_SPECIAL_REGS_NAME "$REGS"
96 #define TUI_GENERAL_SPECIAL_REGS_NAME_LOWER "$regs"
98 /* Scroll direction enum */
99 typedef enum tui_scroll_direction
106 TuiScrollDirection
, *TuiScrollDirectionPtr
;
109 /* General list struct */
110 typedef struct _TuiList
115 TuiList
, *TuiListPtr
;
118 /* The kinds of layouts available */
119 typedef enum tui_layout_type
123 SRC_DISASSEM_COMMAND
,
125 DISASSEM_DATA_COMMAND
,
128 TuiLayoutType
, *TuiLayoutTypePtr
;
130 /* Basic data types that can be displayed in the data window. */
131 typedef enum _TuiDataType
138 TuiDataType
, TuiDataTypePtr
;
140 /* Types of register displays */
141 typedef enum tui_register_display_type
148 TUI_GENERAL_AND_SPECIAL_REGS
150 TuiRegisterDisplayType
, *TuiRegisterDisplayTypePtr
;
152 /* Structure describing source line or line address */
153 typedef union _TuiLineOrAddress
158 TuiLineOrAddress
, *TuiLineOrAddressPtr
;
160 /* Current Layout definition */
161 typedef struct _TuiLayoutDef
163 TuiWinType displayMode
;
165 TuiRegisterDisplayType regsDisplayType
;
166 TuiRegisterDisplayType floatRegsDisplayType
;
168 TuiLayoutDef
, *TuiLayoutDefPtr
;
170 /* Elements in the Source/Disassembly Window */
171 typedef struct _TuiSourceElement
174 TuiLineOrAddress lineOrAddr
;
178 TuiSourceElement
, *TuiSourceElementPtr
;
181 /* Elements in the data display window content */
182 typedef struct _TuiDataElement
185 int itemNo
; /* the register number, or data display number */
190 TuiDataElement
, *TuiDataElementPtr
;
193 /* Elements in the command window content */
194 typedef struct _TuiCommandElement
198 TuiCommandElement
, *TuiCommandElementPtr
;
201 #define MAX_LOCATOR_ELEMENT_LEN 100
203 /* Elements in the locator window content */
204 typedef struct _TuiLocatorElement
206 char fileName
[MAX_LOCATOR_ELEMENT_LEN
];
207 char procName
[MAX_LOCATOR_ELEMENT_LEN
];
211 TuiLocatorElement
, *TuiLocatorElementPtr
;
213 /* Flags to tell what kind of breakpoint is at current line. */
214 #define TUI_BP_ENABLED 0x01
215 #define TUI_BP_DISABLED 0x02
216 #define TUI_BP_HIT 0x04
217 #define TUI_BP_CONDITIONAL 0x08
218 #define TUI_BP_HARDWARE 0x10
220 /* Position of breakpoint markers in the exec info string. */
221 #define TUI_BP_HIT_POS 0
222 #define TUI_BP_BREAK_POS 1
223 #define TUI_EXEC_POS 2
224 #define TUI_EXECINFO_SIZE 4
226 typedef char TuiExecInfoContent
[TUI_EXECINFO_SIZE
];
228 /* An content element in a window */
231 TuiSourceElement source
; /* the source elements */
232 TuiGenWinInfo dataWindow
; /* data display elements */
233 TuiDataElement data
; /* elements of dataWindow */
234 TuiCommandElement command
; /* command elements */
235 TuiLocatorElement locator
; /* locator elements */
236 TuiExecInfoContent simpleString
; /* simple char based elements */
238 TuiWhichElement
, *TuiWhichElementPtr
;
240 typedef struct _TuiWinElement
243 TuiWhichElement whichElement
;
245 TuiWinElement
, *TuiWinElementPtr
;
248 /* This describes the content of the window. */
249 typedef TuiWinElementPtr
*TuiWinContent
;
252 /* This struct defines the specific information about a data display window */
253 typedef struct _TuiDataInfo
255 TuiWinContent dataContent
; /* start of data display content */
256 int dataContentCount
;
257 TuiWinContent regsContent
; /* start of regs display content */
258 int regsContentCount
;
259 TuiRegisterDisplayType regsDisplayType
;
261 int displayRegs
; /* Should regs be displayed at all? */
263 TuiDataInfo
, *TuiDataInfoPtr
;
266 typedef struct _TuiSourceInfo
268 int hasLocator
; /* Does locator belongs to this window? */
269 TuiGenWinInfoPtr executionInfo
; /* execution information window */
270 int horizontalOffset
; /* used for horizontal scroll */
271 TuiLineOrAddress startLineOrAddr
;
274 TuiSourceInfo
, *TuiSourceInfoPtr
;
277 typedef struct _TuiCommandInfo
279 int curLine
; /* The current line position */
280 int curch
; /* The current cursor position */
283 TuiCommandInfo
, *TuiCommandInfoPtr
;
286 /* This defines information about each logical window */
287 typedef struct _TuiWinInfo
289 TuiGenWinInfo generic
; /* general window information */
292 TuiSourceInfo sourceInfo
;
293 TuiDataInfo dataDisplayInfo
;
294 TuiCommandInfo commandInfo
;
298 int canHighlight
; /* Can this window ever be highlighted? */
299 int isHighlighted
; /* Is this window highlighted? */
301 TuiWinInfo
, *TuiWinInfoPtr
;
303 /* MACROS (prefixed with m_) */
306 #define m_genWinPtrIsNull(winInfo) \
307 ((winInfo) == (TuiGenWinInfoPtr)NULL)
308 #define m_genWinPtrNotNull(winInfo) \
309 ((winInfo) != (TuiGenWinInfoPtr)NULL)
310 #define m_winPtrIsNull(winInfo) \
311 ((winInfo) == (TuiWinInfoPtr)NULL)
312 #define m_winPtrNotNull(winInfo) \
313 ((winInfo) != (TuiWinInfoPtr)NULL)
315 #define m_winIsSourceType(type) \
316 (type == SRC_WIN || type == DISASSEM_WIN)
317 #define m_winIsAuxillary(winType) \
318 (winType > MAX_MAJOR_WINDOWS)
319 #define m_hasLocator(winInfo) \
320 ( ((winInfo) != (TuiWinInfoPtr)NULL) ? \
321 (winInfo->detail.sourceInfo.hasLocator) : \
324 #define m_setWinHighlightOn(winInfo) \
325 if ((winInfo) != (TuiWinInfoPtr)NULL) \
326 (winInfo)->isHighlighted = TRUE
327 #define m_setWinHighlightOff(winInfo) \
328 if ((winInfo) != (TuiWinInfoPtr)NULL) \
329 (winInfo)->isHighlighted = FALSE
333 extern TuiWinInfoPtr winList
[MAX_MAJOR_WINDOWS
];
336 #define srcWin winList[SRC_WIN]
337 #define disassemWin winList[DISASSEM_WIN]
338 #define dataWin winList[DATA_WIN]
339 #define cmdWin winList[CMD_WIN]
341 /* Data Manipulation Functions */
342 extern void initializeStaticData (void);
343 extern TuiGenWinInfoPtr
allocGenericWinInfo (void);
344 extern TuiWinInfoPtr
allocWinInfo (TuiWinType
);
345 extern void initGenericPart (TuiGenWinInfoPtr
);
346 extern void initWinInfo (TuiWinInfoPtr
);
347 extern TuiWinContent
allocContent (int, TuiWinType
);
348 extern int addContentElements (TuiGenWinInfoPtr
, int);
349 extern void initContentElement (TuiWinElementPtr
, TuiWinType
);
350 extern void freeWindow (TuiWinInfoPtr
);
351 extern void freeWinContent (TuiGenWinInfoPtr
);
352 extern void freeDataContent (TuiWinContent
, int);
353 extern void freeAllSourceWinsContent (void);
354 extern void tuiDelWindow (TuiWinInfoPtr
);
355 extern void tuiDelDataWindows (TuiWinContent
, int);
356 extern TuiWinInfoPtr
partialWinByName (char *);
357 extern char *winName (TuiGenWinInfoPtr
);
358 extern TuiLayoutType
currentLayout (void);
359 extern void setCurrentLayoutTo (TuiLayoutType
);
360 extern int termHeight (void);
361 extern void setTermHeightTo (int);
362 extern int termWidth (void);
363 extern void setTermWidthTo (int);
364 extern void setGenWinOrigin (TuiGenWinInfoPtr
, int, int);
365 extern TuiGenWinInfoPtr
locatorWinInfoPtr (void);
366 extern TuiGenWinInfoPtr
sourceExecInfoWinPtr (void);
367 extern TuiGenWinInfoPtr
disassemExecInfoWinPtr (void);
368 extern TuiListPtr
sourceWindows (void);
369 extern void clearSourceWindows (void);
370 extern void clearSourceWindowsDetail (void);
371 extern void clearWinDetail (TuiWinInfoPtr winInfo
);
372 extern void tuiAddToSourceWindows (TuiWinInfoPtr
);
373 extern int tuiDefaultTabLen (void);
374 extern void tuiSetDefaultTabLen (int);
375 extern TuiWinInfoPtr
tuiWinWithFocus (void);
376 extern void tuiSetWinWithFocus (TuiWinInfoPtr
);
377 extern TuiLayoutDefPtr
tuiLayoutDef (void);
378 extern int tuiWinResized (void);
379 extern void tuiSetWinResizedTo (int);
381 extern TuiWinInfoPtr
tuiNextWin (TuiWinInfoPtr
);
382 extern TuiWinInfoPtr
tuiPrevWin (TuiWinInfoPtr
);
384 extern void addToSourceWindows (TuiWinInfoPtr winInfo
);
386 #endif /* TUI_DATA_H */