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 tui_gen_win_info
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 tui_list
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 tui_data_type
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 tui_line_or_address
158 TuiLineOrAddress
, *TuiLineOrAddressPtr
;
160 /* Current Layout definition */
161 typedef struct tui_layout_def
163 TuiWinType displayMode
;
165 TuiRegisterDisplayType regsDisplayType
;
166 TuiRegisterDisplayType floatRegsDisplayType
;
168 TuiLayoutDef
, *TuiLayoutDefPtr
;
170 /* Elements in the Source/Disassembly Window */
171 typedef struct tui_source_element
174 TuiLineOrAddress lineOrAddr
;
178 TuiSourceElement
, *TuiSourceElementPtr
;
181 /* Elements in the data display window content */
182 typedef struct tui_data_element
185 int itemNo
; /* the register number, or data display number */
190 TuiDataElement
, *TuiDataElementPtr
;
193 /* Elements in the command window content */
194 typedef struct tui_command_element
198 TuiCommandElement
, *TuiCommandElementPtr
;
201 #define MAX_LOCATOR_ELEMENT_LEN 100
203 /* Elements in the locator window content */
204 typedef struct tui_locator_element
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 */
229 typedef union tui_which_element
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 tui_win_element
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 tui_data_info
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 tui_source_info
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 tui_command_info
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 tui_win_info
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 tui_initialize_static_data (void);
343 extern struct tui_gen_win_info
*tui_alloc_generic_win_info (void);
344 extern struct tui_win_info
*tui_alloc_win_info (TuiWinType
);
345 extern void tui_init_generic_part (struct tui_gen_win_info
*);
346 extern void tui_init_win_info (struct tui_win_info
*);
347 extern TuiWinContent
tui_alloc_content (int, enum tui_win_type
);
348 extern int tui_add_content_elements (struct tui_gen_win_info
*, int);
349 extern void tui_init_content_element (struct tui_win_element
*, enum tui_win_type
);
350 extern void tui_free_window (struct tui_win_info
*);
351 extern void tui_free_win_content (struct tui_gen_win_info
*);
352 extern void tui_free_data_content (TuiWinContent
, int);
353 extern void tui_free_all_source_wins_content (void);
354 extern void tui_del_window (struct tui_win_info
*);
355 extern void tui_del_data_windows (TuiWinContent
, int);
356 extern struct tui_win_info
*tui_partial_win_by_name (char *);
357 extern char *tui_win_name (struct tui_gen_win_info
*);
358 extern TuiLayoutType
tui_current_layout (void);
359 extern void tui_set_current_layout_to (TuiLayoutType
);
360 extern int tui_term_height (void);
361 extern void tui_set_term_height_to (int);
362 extern int tui_term_width (void);
363 extern void tui_set_term_width_to (int);
364 extern void tui_set_gen_win_origin (struct tui_gen_win_info
*, int, int);
365 extern struct tui_gen_win_info
*tui_locator_win_info_ptr (void);
366 extern struct tui_gen_win_info
*tui_source_exec_info_win_ptr (void);
367 extern struct tui_gen_win_info
*tui_disassem_exec_info_win_ptr (void);
368 extern TuiListPtr
tui_source_windows (void);
369 extern void tui_clear_source_windows (void);
370 extern void tui_clear_source_windows_detail (void);
371 extern void tui_clear_win_detail (struct tui_win_info
* winInfo
);
372 extern void tui_add_to_source_windows (struct tui_win_info
*);
373 extern int tui_default_tab_len (void);
374 extern void tui_set_default_tab_len (int);
375 extern struct tui_win_info
*tui_win_with_focus (void);
376 extern void tui_set_win_with_focus (struct tui_win_info
*);
377 extern TuiLayoutDefPtr
tui_layout_def (void);
378 extern int tui_win_resized (void);
379 extern void tui_set_win_resized_to (int);
381 extern struct tui_win_info
*tui_next_win (struct tui_win_info
*);
382 extern struct tui_win_info
*tui_prev_win (struct tui_win_info
*);
384 extern void tui_add_to_source_windows (struct tui_win_info
* winInfo
);
386 #endif /* TUI_DATA_H */