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. */
26 /****************************
27 ** GLOBAL DECLARATIONS
28 ****************************/
29 TuiWinInfoPtr winList
[MAX_MAJOR_WINDOWS
];
31 /***************************
32 ** Private Definitions
33 ****************************/
39 /***************************
41 ****************************/
42 static char *_tuiNullStr
= TUI_NULL_STR
;
43 static char *_tuiBlankStr
= " ";
44 static char *_tuiLocationStr
= " >";
45 static char *_tuiBreakStr
= " * ";
46 static char *_tuiBreakLocationStr
= " *>";
47 static TuiLayoutType _currentLayout
= UNDEFINED_LAYOUT
;
48 static int _termHeight
, _termWidth
;
49 static int _historyLimit
= DEFAULT_HISTORY_COUNT
;
50 static TuiGenWinInfo _locator
;
51 static TuiGenWinInfo _execInfo
[2];
52 static TuiWinInfoPtr _srcWinList
[2];
53 static TuiList _sourceWindows
=
54 {(OpaqueList
) _srcWinList
, 0};
55 static int _defaultTabLen
= DEFAULT_TAB_LEN
;
56 static TuiWinInfoPtr _winWithFocus
= (TuiWinInfoPtr
) NULL
;
57 static TuiLayoutDef _layoutDef
=
58 {SRC_WIN
, /* displayMode */
60 TUI_UNDEFINED_REGS
, /* regsDisplayType */
61 TUI_SFLOAT_REGS
}; /* floatRegsDisplayType */
62 static int _winResized
= FALSE
;
65 /*********************************
66 ** Static function forward decls
67 **********************************/
68 static void freeContent (TuiWinContent
, int, TuiWinType
);
69 static void freeContentElements (TuiWinContent
, int, TuiWinType
);
73 /*********************************
75 **********************************/
77 /******************************************
78 ** ACCESSORS & MUTATORS FOR PRIVATE DATA
79 ******************************************/
83 ** Answer a whether the terminal window has been resized or not
97 ** tuiSetWinResized().
98 ** Set a whether the terminal window has been resized or not
105 tuiSetWinResizedTo (resized
)
109 _winResized
= resized
;
112 } /* tuiSetWinResizedTo */
117 ** Answer a pointer to the current layout definition
131 ** tuiWinWithFocus().
132 ** Answer the window with the logical focus
136 tuiWinWithFocus (void)
141 return _winWithFocus
;
142 } /* tuiWinWithFocus */
146 ** tuiSetWinWithFocus().
147 ** Set the window that has the logical focus
152 TuiWinInfoPtr winInfo
)
154 tuiSetWinWithFocus (winInfo
)
155 TuiWinInfoPtr winInfo
;
158 _winWithFocus
= winInfo
;
161 } /* tuiSetWinWithFocus */
165 ** tuiDefaultTabLen().
166 ** Answer the length in chars, of tabs
170 tuiDefaultTabLen (void)
175 return _defaultTabLen
;
176 } /* tuiDefaultTabLen */
180 ** tuiSetDefaultTabLen().
181 ** Set the length in chars, of tabs
185 tuiSetDefaultTabLen (
188 tuiSetDefaultTabLen (len
)
192 _defaultTabLen
= len
;
195 } /* tuiSetDefaultTabLen */
199 ** currentSourceWin()
200 ** Accessor for the current source window. Usually there is only
201 ** one source window (either source or disassembly), but both can
202 ** be displayed at the same time.
211 return &_sourceWindows
;
212 } /* currentSourceWindows */
216 ** clearSourceWindows()
217 ** Clear the list of source windows. Usually there is only one
218 ** source window (either source or disassembly), but both can be
219 ** displayed at the same time.
223 clearSourceWindows (void)
225 clearSourceWindows ()
228 _sourceWindows
.list
[0] = (Opaque
) NULL
;
229 _sourceWindows
.list
[1] = (Opaque
) NULL
;
230 _sourceWindows
.count
= 0;
233 } /* currentSourceWindows */
237 ** clearSourceWindowsDetail()
238 ** Clear the pertinant detail in the source windows.
242 clearSourceWindowsDetail (void)
244 clearSourceWindowsDetail ()
249 for (i
= 0; i
< (sourceWindows ())->count
; i
++)
250 clearWinDetail ((TuiWinInfoPtr
) (sourceWindows ())->list
[i
]);
253 } /* currentSourceWindows */
257 ** addSourceWindowToList().
258 ** Add a window to the list of source windows. Usually there is
259 ** only one source window (either source or disassembly), but
260 ** both can be displayed at the same time.
265 TuiWinInfoPtr winInfo
)
267 addToSourceWindows (winInfo
)
268 TuiWinInfoPtr winInfo
;
271 if (_sourceWindows
.count
< 2)
272 _sourceWindows
.list
[_sourceWindows
.count
++] = (Opaque
) winInfo
;
275 } /* addToSourceWindows */
280 ** Clear the pertinant detail in the windows.
285 TuiWinInfoPtr winInfo
)
287 clearWinDetail (winInfo
)
288 TuiWinInfoPtr winInfo
;
291 if (m_winPtrNotNull (winInfo
))
293 switch (winInfo
->generic
.type
)
297 winInfo
->detail
.sourceInfo
.startLineOrAddr
.addr
= (Opaque
) NULL
;
298 winInfo
->detail
.sourceInfo
.horizontalOffset
= 0;
301 winInfo
->detail
.commandInfo
.curLine
=
302 winInfo
->detail
.commandInfo
.curch
= 0;
305 winInfo
->detail
.dataDisplayInfo
.dataContent
=
306 (TuiWinContent
) NULL
;
307 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
308 winInfo
->detail
.dataDisplayInfo
.regsContent
=
309 (TuiWinContent
) NULL
;
310 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
311 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
313 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
314 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
322 } /* clearWinDetail */
327 ** Accessor for the blank string.
342 ** Accessor for the location string.
351 return _tuiLocationStr
;
357 ** Accessor for the break string.
371 ** breakLocationStr()
372 ** Accessor for the breakLocation string.
376 breakLocationStr (void)
381 return _tuiBreakLocationStr
;
382 } /* breakLocationStr */
387 ** Accessor for the null string.
401 ** sourceExecInfoPtr().
402 ** Accessor for the source execution info ptr.
406 sourceExecInfoWinPtr (void)
408 sourceExecInfoWinPtr ()
411 return &_execInfo
[0];
412 } /* sourceExecInfoWinPtr */
416 ** disassemExecInfoPtr().
417 ** Accessor for the disassem execution info ptr.
421 disassemExecInfoWinPtr (void)
423 disassemExecInfoWinPtr ()
426 return &_execInfo
[1];
427 } /* disassemExecInfoWinPtr */
431 ** locatorWinInfoPtr().
432 ** Accessor for the locator win info. Answers a pointer to the
433 ** static locator win info struct.
437 locatorWinInfoPtr (void)
443 } /* locatorWinInfoPtr */
448 ** Accessor for the history limit
457 return _historyLimit
;
462 ** setHistoryLimitTo().
463 ** Mutator for the history limit
470 setHistoryLimitTo (h
)
477 } /* setHistoryLimitTo */
481 ** Accessor for the termHeight
495 ** setTermHeightTo().
496 ** Mutator for the term height
510 } /* setTermHeightTo */
515 ** Accessor for the termWidth
530 ** Mutator for the termWidth
544 } /* setTermWidthTo */
549 ** Accessor for the current layout
558 return _currentLayout
;
559 } /* currentLayout */
563 ** setCurrentLayoutTo().
564 ** Mutator for the current layout
569 TuiLayoutType newLayout
)
571 setCurrentLayoutTo (newLayout
)
572 TuiLayoutType newLayout
;
575 _currentLayout
= newLayout
;
578 } /* setCurrentLayoutTo */
582 ** setGenWinOrigin().
583 ** Set the origin of the window
588 TuiGenWinInfoPtr winInfo
,
592 setGenWinOrigin (winInfo
, x
, y
)
593 TuiGenWinInfoPtr winInfo
;
598 winInfo
->origin
.x
= x
;
599 winInfo
->origin
.y
= y
;
602 } /* setGenWinOrigin */
605 /*****************************
606 ** OTHER PUBLIC FUNCTIONS
607 *****************************/
612 ** Answer the next window in the list, cycling back to the top
618 TuiWinInfoPtr curWin
)
621 TuiWinInfoPtr curWin
;
624 TuiWinType type
= curWin
->generic
.type
;
625 TuiWinInfoPtr nextWin
= (TuiWinInfoPtr
) NULL
;
627 if (curWin
->generic
.type
== CMD_WIN
)
630 type
= curWin
->generic
.type
+ 1;
631 while (type
!= curWin
->generic
.type
&& m_winPtrIsNull (nextWin
))
633 if (winList
[type
]->generic
.isVisible
)
634 nextWin
= winList
[type
];
650 ** Answer the prev window in the list, cycling back to the bottom
656 TuiWinInfoPtr curWin
)
659 TuiWinInfoPtr curWin
;
662 TuiWinType type
= curWin
->generic
.type
;
663 TuiWinInfoPtr prev
= (TuiWinInfoPtr
) NULL
;
665 if (curWin
->generic
.type
== SRC_WIN
)
668 type
= curWin
->generic
.type
- 1;
669 while (type
!= curWin
->generic
.type
&& m_winPtrIsNull (prev
))
671 if (winList
[type
]->generic
.isVisible
)
672 prev
= winList
[type
];
687 ** displayableWinContentOf().
688 ** Answer a the content at the location indicated by index. Note
689 ** that if this is a locator window, the string returned should be
694 displayableWinContentOf (
695 TuiGenWinInfoPtr winInfo
,
696 TuiWinElementPtr elementPtr
)
698 displayableWinContentOf (winInfo
, elementPtr
)
699 TuiGenWinInfoPtr winInfo
;
700 TuiWinElementPtr elementPtr
;
704 char *string
= nullStr ();
706 if (elementPtr
!= (TuiWinElementPtr
) NULL
|| winInfo
->type
== LOCATOR_WIN
)
709 ** Now convert the line to a displayable string
711 switch (winInfo
->type
)
715 string
= elementPtr
->whichElement
.source
.line
;
718 string
= elementPtr
->whichElement
.command
.line
;
721 if ((string
= (char *) xmalloc (
722 (termWidth () + 1) * sizeof (char))) == (char *) NULL
)
726 char lineNo
[50], pc
[50], buf
[50], *fname
, *pname
;
727 register int strSize
= termWidth (), i
, procWidth
, fileWidth
;
730 ** First determine the amount of file/proc name width
733 i
= strSize
- (PC_WIDTH
+ LINE_WIDTH
734 + 25 /* pc and line labels */
735 + strlen (FILE_PREFIX
) + 1 /* file label */
736 + 15 /* procedure label */ );
737 if (i
>= FILE_WIDTH
+ PROC_WIDTH
)
739 fileWidth
= FILE_WIDTH
;
740 procWidth
= PROC_WIDTH
;
745 procWidth
= i
- fileWidth
;
748 /* Now convert elements to string form */
749 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
750 *elementPtr
->whichElement
.locator
.fileName
!= (char) 0 &&
751 srcWin
->generic
.isVisible
)
752 fname
= elementPtr
->whichElement
.locator
.fileName
;
755 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
756 *elementPtr
->whichElement
.locator
.procName
!= (char) 0)
757 pname
= elementPtr
->whichElement
.locator
.procName
;
760 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
761 elementPtr
->whichElement
.locator
.lineNo
> 0)
762 sprintf (lineNo
, "%d",
763 elementPtr
->whichElement
.locator
.lineNo
);
765 strcpy (lineNo
, "??");
766 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
767 elementPtr
->whichElement
.locator
.addr
> (Opaque
) 0)
769 elementPtr
->whichElement
.locator
.addr
);
773 ** Now create the locator line from the string version
774 ** of the elements. We could use sprintf() here but
775 ** that wouldn't ensure that we don't overrun the size
776 ** of the allocated buffer. strcat_to_buf() will.
780 strcat_to_buf (string
, strSize
, " ");
781 strcat_to_buf (string
, strSize
, FILE_PREFIX
);
782 if (strlen (fname
) > fileWidth
)
784 strncpy (buf
, fname
, fileWidth
- 1);
785 buf
[fileWidth
- 1] = '*';
786 buf
[fileWidth
] = (char) 0;
790 strcat_to_buf (string
, strSize
, buf
);
791 /* procedure/class name */
792 sprintf (buf
, "%15s", PROC_PREFIX
);
793 strcat_to_buf (string
, strSize
, buf
);
794 if (strlen (pname
) > procWidth
)
796 strncpy (buf
, pname
, procWidth
- 1);
797 buf
[procWidth
- 1] = '*';
798 buf
[procWidth
] = (char) 0;
802 strcat_to_buf (string
, strSize
, buf
);
803 sprintf (buf
, "%10s", LINE_PREFIX
);
804 strcat_to_buf (string
, strSize
, buf
);
805 strcat_to_buf (string
, strSize
, lineNo
);
806 sprintf (buf
, "%10s", PC_PREFIX
);
807 strcat_to_buf (string
, strSize
, buf
);
808 strcat_to_buf (string
, strSize
, pc
);
809 for (i
= strlen (string
); i
< strSize
; i
++)
811 string
[strSize
] = (char) 0;
815 string
= elementPtr
->whichElement
.simpleString
;
822 } /* displayableWinContentOf */
827 ** Answer a the content at the location indicated by index
831 displayableWinContentAt (
832 TuiGenWinInfoPtr winInfo
,
835 displayableWinContentAt (winInfo
, index
)
836 TuiGenWinInfoPtr winInfo
;
840 return (displayableWinContentOf (winInfo
, (TuiWinElementPtr
) winInfo
->content
[index
]));
845 ** winElementHeight().
846 ** Answer the height of the element in lines
851 TuiGenWinInfoPtr winInfo
,
852 TuiWinElementPtr element
)
854 winElementHeight (winInfo
, element
)
855 TuiGenWinInfoPtr winInfo
;
856 TuiWinElementPtr element
;
861 if (winInfo
->type
== DATA_WIN
)
862 /* FOR NOW SAY IT IS ONLY ONE LINE HIGH */
868 } /* winElementHeight */
873 ** Answer the window represented by name
884 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
887 while (i
< MAX_MAJOR_WINDOWS
&& m_winPtrIsNull (winInfo
))
889 if (strcmp (name
, winName (&(winList
[i
]->generic
))) == 0)
890 winInfo
= winList
[i
];
899 ** partialWinByName().
900 ** Answer the window represented by name
907 partialWinByName (name
)
911 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
913 if (name
!= (char *) NULL
)
917 while (i
< MAX_MAJOR_WINDOWS
&& m_winPtrIsNull (winInfo
))
919 char *curName
= winName (&winList
[i
]->generic
);
920 if (strlen (name
) <= strlen (curName
) &&
921 strncmp (name
, curName
, strlen (name
)) == 0)
922 winInfo
= winList
[i
];
928 } /* partialWinByName */
933 ** Answer the name of the window
938 TuiGenWinInfoPtr winInfo
)
941 TuiGenWinInfoPtr winInfo
;
944 char *name
= (char *) NULL
;
946 switch (winInfo
->type
)
955 name
= DISASSEM_NAME
;
970 ** initializeStaticData
974 initializeStaticData (void)
976 initializeStaticData ()
979 initGenericPart (sourceExecInfoWinPtr ());
980 initGenericPart (disassemExecInfoWinPtr ());
981 initGenericPart (locatorWinInfoPtr ());
984 } /* initializeStaticData */
988 ** allocGenericWinInfo().
992 allocGenericWinInfo (void)
994 allocGenericWinInfo ()
997 TuiGenWinInfoPtr win
;
999 if ((win
= (TuiGenWinInfoPtr
) xmalloc (
1000 sizeof (TuiGenWinInfoPtr
))) != (TuiGenWinInfoPtr
) NULL
)
1001 initGenericPart (win
);
1004 } /* allocGenericWinInfo */
1008 ** initGenericPart().
1013 TuiGenWinInfoPtr win
)
1015 initGenericPart (win
)
1016 TuiGenWinInfoPtr win
;
1023 win
->viewportHeight
=
1025 win
->lastVisibleLine
= 0;
1026 win
->handle
= (WINDOW
*) NULL
;
1027 win
->content
= (OpaquePtr
) NULL
;
1029 win
->isVisible
= FALSE
;
1032 } /* initGenericPart */
1036 ** initContentElement().
1040 initContentElement (
1041 TuiWinElementPtr element
,
1044 initContentElement (element
, type
)
1045 TuiWinElementPtr element
;
1049 element
->highlight
= FALSE
;
1054 element
->whichElement
.source
.line
= (char *) NULL
;
1055 element
->whichElement
.source
.lineOrAddr
.lineNo
= 0;
1056 element
->whichElement
.source
.isExecPoint
= FALSE
;
1057 element
->whichElement
.source
.hasBreak
= FALSE
;
1060 initGenericPart (&element
->whichElement
.dataWindow
);
1061 element
->whichElement
.dataWindow
.type
= DATA_ITEM_WIN
;
1062 ((TuiGenWinInfoPtr
) & element
->whichElement
.dataWindow
)->content
=
1063 (OpaquePtr
) allocContent (1, DATA_ITEM_WIN
);
1065 & element
->whichElement
.dataWindow
)->contentSize
= 1;
1068 element
->whichElement
.command
.line
= (char *) NULL
;
1071 element
->whichElement
.data
.name
= (char *) NULL
;
1072 element
->whichElement
.data
.type
= TUI_REGISTER
;
1073 element
->whichElement
.data
.itemNo
= UNDEFINED_ITEM
;
1074 element
->whichElement
.data
.value
= (Opaque
) NULL
;
1075 element
->whichElement
.data
.highlight
= FALSE
;
1078 element
->whichElement
.locator
.fileName
[0] =
1079 element
->whichElement
.locator
.procName
[0] = (char) 0;
1080 element
->whichElement
.locator
.lineNo
= 0;
1081 element
->whichElement
.locator
.addr
= 0;
1084 element
->whichElement
.simpleString
= blankStr ();
1090 } /* initContentElement */
1098 TuiWinInfoPtr winInfo
)
1100 initWinInfo (winInfo
)
1101 TuiWinInfoPtr winInfo
;
1104 initGenericPart (&winInfo
->generic
);
1105 winInfo
->canHighlight
=
1106 winInfo
->isHighlighted
= FALSE
;
1107 switch (winInfo
->generic
.type
)
1111 winInfo
->detail
.sourceInfo
.executionInfo
= (TuiGenWinInfoPtr
) NULL
;
1112 winInfo
->detail
.sourceInfo
.hasLocator
= FALSE
;
1113 winInfo
->detail
.sourceInfo
.horizontalOffset
= 0;
1114 winInfo
->detail
.sourceInfo
.startLineOrAddr
.addr
= (Opaque
) NULL
;
1117 winInfo
->detail
.dataDisplayInfo
.dataContent
= (TuiWinContent
) NULL
;
1118 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
1119 winInfo
->detail
.dataDisplayInfo
.regsContent
= (TuiWinContent
) NULL
;
1120 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
1121 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
1123 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
1124 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
1127 winInfo
->detail
.commandInfo
.curLine
= 0;
1128 winInfo
->detail
.commandInfo
.curch
= 0;
1131 winInfo
->detail
.opaque
= (Opaque
) NULL
;
1151 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
1153 winInfo
= (TuiWinInfoPtr
) xmalloc (sizeof (TuiWinInfo
));
1154 if (m_winPtrNotNull (winInfo
))
1156 winInfo
->generic
.type
= type
;
1157 initWinInfo (winInfo
);
1161 } /* allocWinInfo */
1166 ** Allocates the content and elements in a block.
1174 allocContent (numElements
, type
)
1179 TuiWinContent content
= (TuiWinContent
) NULL
;
1180 char *elementBlockPtr
= (char *) NULL
;
1183 if ((content
= (TuiWinContent
)
1184 xmalloc (sizeof (TuiWinElementPtr
) * numElements
)) != (TuiWinContent
) NULL
)
1186 ** All windows, except the data window, can allocate the elements
1187 ** in a chunk. The data window cannot because items can be
1188 ** added/removed from the data display by the user at any time.
1190 if (type
!= DATA_WIN
)
1192 if ((elementBlockPtr
= (char *)
1193 xmalloc (sizeof (TuiWinElement
) * numElements
)) != (char *) NULL
)
1195 for (i
= 0; i
< numElements
; i
++)
1197 content
[i
] = (TuiWinElementPtr
) elementBlockPtr
;
1198 initContentElement (content
[i
], type
);
1199 elementBlockPtr
+= sizeof (TuiWinElement
);
1204 tuiFree ((char *) content
);
1205 content
= (TuiWinContent
) NULL
;
1211 } /* allocContent */
1215 ** addContentElements().
1216 ** Adds the input number of elements to the windows's content. If
1217 ** no content has been allocated yet, allocContent() is called to
1218 ** do this. The index of the first element added is returned,
1219 ** unless there is a memory allocation error, in which case, (-1)
1224 addContentElements (
1225 TuiGenWinInfoPtr winInfo
,
1228 addContentElements (winInfo
, numElements
)
1229 TuiGenWinInfoPtr winInfo
;
1233 TuiWinElementPtr elementPtr
;
1236 if (winInfo
->content
== (OpaquePtr
) NULL
)
1238 winInfo
->content
= (OpaquePtr
) allocContent (numElements
, winInfo
->type
);
1242 indexStart
= winInfo
->contentSize
;
1243 if (winInfo
->content
!= (OpaquePtr
) NULL
)
1245 for (i
= indexStart
; (i
< numElements
+ indexStart
); i
++)
1247 if ((elementPtr
= (TuiWinElementPtr
)
1248 xmalloc (sizeof (TuiWinElement
))) != (TuiWinElementPtr
) NULL
)
1250 winInfo
->content
[i
] = (Opaque
) elementPtr
;
1251 initContentElement (elementPtr
, winInfo
->type
);
1252 winInfo
->contentSize
++;
1254 else /* things must be really hosed now! We ran out of memory!? */
1260 } /* addContentElements */
1265 ** Delete all curses windows associated with winInfo, leaving everything
1271 TuiWinInfoPtr winInfo
)
1273 tuiDelWindow (winInfo
)
1274 TuiWinInfoPtr winInfo
;
1279 TuiGenWinInfoPtr genericWin
;
1282 switch (winInfo
->generic
.type
)
1286 genericWin
= locatorWinInfoPtr ();
1287 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1289 tuiDelwin (genericWin
->handle
);
1290 genericWin
->handle
= (WINDOW
*) NULL
;
1291 genericWin
->isVisible
= FALSE
;
1293 genericWin
= winInfo
->detail
.sourceInfo
.executionInfo
;
1294 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1296 tuiDelwin (genericWin
->handle
);
1297 genericWin
->handle
= (WINDOW
*) NULL
;
1298 genericWin
->isVisible
= FALSE
;
1302 if (winInfo
->generic
.content
!= (OpaquePtr
) NULL
)
1307 winInfo
->detail
.dataDisplayInfo
.regsContent
,
1308 winInfo
->detail
.dataDisplayInfo
.regsContentCount
);
1310 winInfo
->detail
.dataDisplayInfo
.dataContent
,
1311 winInfo
->detail
.dataDisplayInfo
.dataContentCount
);
1317 if (winInfo
->generic
.handle
!= (WINDOW
*) NULL
)
1319 tuiDelwin (winInfo
->generic
.handle
);
1320 winInfo
->generic
.handle
= (WINDOW
*) NULL
;
1321 winInfo
->generic
.isVisible
= FALSE
;
1325 } /* tuiDelWindow */
1334 TuiWinInfoPtr winInfo
)
1336 freeWindow (winInfo
)
1337 TuiWinInfoPtr winInfo
;
1342 TuiGenWinInfoPtr genericWin
;
1345 switch (winInfo
->generic
.type
)
1349 genericWin
= locatorWinInfoPtr ();
1350 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1352 tuiDelwin (genericWin
->handle
);
1353 genericWin
->handle
= (WINDOW
*) NULL
;
1355 freeWinContent (genericWin
);
1356 genericWin
= winInfo
->detail
.sourceInfo
.executionInfo
;
1357 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1359 tuiDelwin (genericWin
->handle
);
1360 genericWin
->handle
= (WINDOW
*) NULL
;
1361 freeWinContent (genericWin
);
1365 if (winInfo
->generic
.content
!= (OpaquePtr
) NULL
)
1368 winInfo
->detail
.dataDisplayInfo
.regsContent
,
1369 winInfo
->detail
.dataDisplayInfo
.regsContentCount
);
1370 winInfo
->detail
.dataDisplayInfo
.regsContent
=
1371 (TuiWinContent
) NULL
;
1372 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
1374 winInfo
->detail
.dataDisplayInfo
.dataContent
,
1375 winInfo
->detail
.dataDisplayInfo
.dataContentCount
);
1376 winInfo
->detail
.dataDisplayInfo
.dataContent
=
1377 (TuiWinContent
) NULL
;
1378 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
1379 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
1381 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
1382 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
1383 winInfo
->generic
.content
= (OpaquePtr
) NULL
;
1384 winInfo
->generic
.contentSize
= 0;
1390 if (winInfo
->generic
.handle
!= (WINDOW
*) NULL
)
1392 tuiDelwin (winInfo
->generic
.handle
);
1393 winInfo
->generic
.handle
= (WINDOW
*) NULL
;
1394 freeWinContent (&winInfo
->generic
);
1403 ** freeAllSourceWinsContent().
1407 freeAllSourceWinsContent (void)
1409 freeAllSourceWinsContent ()
1414 for (i
= 0; i
< (sourceWindows ())->count
; i
++)
1416 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) (sourceWindows ())->list
[i
];
1418 if (m_winPtrNotNull (winInfo
))
1420 freeWinContent (&(winInfo
->generic
));
1421 freeWinContent (winInfo
->detail
.sourceInfo
.executionInfo
);
1426 } /* freeAllSourceWinsContent */
1430 ** freeWinContent().
1435 TuiGenWinInfoPtr winInfo
)
1437 freeWinContent (winInfo
)
1438 TuiGenWinInfoPtr winInfo
;
1441 if (winInfo
->content
!= (OpaquePtr
) NULL
)
1443 freeContent ((TuiWinContent
) winInfo
->content
,
1444 winInfo
->contentSize
,
1446 winInfo
->content
= (OpaquePtr
) NULL
;
1448 winInfo
->contentSize
= 0;
1451 } /* freeWinContent */
1455 ** freeAllWindows().
1459 freeAllWindows (void)
1464 TuiWinType type
= SRC_WIN
;
1466 for (; type
< MAX_MAJOR_WINDOWS
; type
++)
1467 if (m_winPtrNotNull (winList
[type
]) &&
1468 winList
[type
]->generic
.type
!= UNDEFINED_WIN
)
1469 freeWindow (winList
[type
]);
1471 } /* freeAllWindows */
1477 TuiWinContent content
,
1480 tuiDelDataWindows (content
, contentSize
)
1481 TuiWinContent content
;
1488 ** Remember that data window content elements are of type TuiGenWinInfoPtr,
1489 ** each of which whose single element is a data element.
1491 for (i
= 0; i
< contentSize
; i
++)
1493 TuiGenWinInfoPtr genericWin
= &content
[i
]->whichElement
.dataWindow
;
1495 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1497 tuiDelwin (genericWin
->handle
);
1498 genericWin
->handle
= (WINDOW
*) NULL
;
1499 genericWin
->isVisible
= FALSE
;
1504 } /* tuiDelDataWindows */
1510 TuiWinContent content
,
1513 freeDataContent (content
, contentSize
)
1514 TuiWinContent content
;
1521 ** Remember that data window content elements are of type TuiGenWinInfoPtr,
1522 ** each of which whose single element is a data element.
1524 for (i
= 0; i
< contentSize
; i
++)
1526 TuiGenWinInfoPtr genericWin
= &content
[i
]->whichElement
.dataWindow
;
1528 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1530 tuiDelwin (genericWin
->handle
);
1531 genericWin
->handle
= (WINDOW
*) NULL
;
1532 freeWinContent (genericWin
);
1535 freeContent (content
,
1540 } /* freeDataContent */
1543 /**********************************
1544 ** LOCAL STATIC FUNCTIONS **
1545 **********************************/
1554 TuiWinContent content
,
1558 freeContent (content
, contentSize
, winType
)
1559 TuiWinContent content
;
1564 if (content
!= (TuiWinContent
) NULL
)
1566 freeContentElements (content
, contentSize
, winType
);
1567 tuiFree ((char *) content
);
1575 ** freeContentElements().
1579 freeContentElements (
1580 TuiWinContent content
,
1584 freeContentElements (content
, contentSize
, type
)
1585 TuiWinContent content
;
1590 if (content
!= (TuiWinContent
) NULL
)
1594 if (type
== SRC_WIN
|| type
== DISASSEM_WIN
)
1596 /* free whole source block */
1597 if (content
[0]->whichElement
.source
.line
!= (char *) NULL
)
1598 tuiFree (content
[0]->whichElement
.source
.line
);
1602 for (i
= 0; i
< contentSize
; i
++)
1604 TuiWinElementPtr element
;
1606 element
= content
[i
];
1607 if (element
!= (TuiWinElementPtr
) NULL
)
1612 tuiFree ((char *) element
);
1616 ** Note that data elements are not allocated
1617 ** in a single block, but individually, as needed.
1619 if (element
->whichElement
.data
.type
!= TUI_REGISTER
)
1621 element
->whichElement
.data
.name
);
1622 tuiFree ((char *) element
->whichElement
.data
.value
);
1623 tuiFree ((char *) element
);
1626 tuiFree ((char *) element
->whichElement
.command
.line
);
1634 if (type
!= DATA_WIN
&& type
!= DATA_ITEM_WIN
)
1635 tuiFree ((char *) content
[0]); /* free the element block */
1639 } /* freeContentElements */