3 ** This module contains functions for manipulating the data
4 ** structures used by the TUI
11 /****************************
12 ** GLOBAL DECLARATIONS
13 ****************************/
14 TuiWinInfoPtr winList
[MAX_MAJOR_WINDOWS
];
16 /***************************
17 ** Private Definitions
18 ****************************/
24 /***************************
26 ****************************/
27 static char *_tuiNullStr
= TUI_NULL_STR
;
28 static char *_tuiBlankStr
= " ";
29 static char *_tuiLocationStr
= " >";
30 static char *_tuiBreakStr
= " * ";
31 static char *_tuiBreakLocationStr
= " *>";
32 static TuiLayoutType _currentLayout
= UNDEFINED_LAYOUT
;
33 static int _termHeight
, _termWidth
;
34 static int _historyLimit
= DEFAULT_HISTORY_COUNT
;
35 static TuiGenWinInfo _locator
;
36 static TuiGenWinInfo _execInfo
[2];
37 static TuiWinInfoPtr _srcWinList
[2];
38 static TuiList _sourceWindows
=
39 {(OpaqueList
) _srcWinList
, 0};
40 static int _defaultTabLen
= DEFAULT_TAB_LEN
;
41 static TuiWinInfoPtr _winWithFocus
= (TuiWinInfoPtr
) NULL
;
42 static TuiLayoutDef _layoutDef
=
43 {SRC_WIN
, /* displayMode */
45 TUI_UNDEFINED_REGS
, /* regsDisplayType */
46 TUI_SFLOAT_REGS
}; /* floatRegsDisplayType */
47 static int _winResized
= FALSE
;
50 /*********************************
51 ** Static function forward decls
52 **********************************/
53 static void freeContent (TuiWinContent
, int, TuiWinType
);
54 static void freeContentElements (TuiWinContent
, int, TuiWinType
);
58 /*********************************
60 **********************************/
62 /******************************************
63 ** ACCESSORS & MUTATORS FOR PRIVATE DATA
64 ******************************************/
68 ** Answer a whether the terminal window has been resized or not
82 ** tuiSetWinResized().
83 ** Set a whether the terminal window has been resized or not
90 tuiSetWinResizedTo (resized
)
94 _winResized
= resized
;
97 } /* tuiSetWinResizedTo */
102 ** Answer a pointer to the current layout definition
116 ** tuiWinWithFocus().
117 ** Answer the window with the logical focus
121 tuiWinWithFocus (void)
126 return _winWithFocus
;
127 } /* tuiWinWithFocus */
131 ** tuiSetWinWithFocus().
132 ** Set the window that has the logical focus
137 TuiWinInfoPtr winInfo
)
139 tuiSetWinWithFocus (winInfo
)
140 TuiWinInfoPtr winInfo
;
143 _winWithFocus
= winInfo
;
146 } /* tuiSetWinWithFocus */
150 ** tuiDefaultTabLen().
151 ** Answer the length in chars, of tabs
155 tuiDefaultTabLen (void)
160 return _defaultTabLen
;
161 } /* tuiDefaultTabLen */
165 ** tuiSetDefaultTabLen().
166 ** Set the length in chars, of tabs
170 tuiSetDefaultTabLen (
173 tuiSetDefaultTabLen (len
)
177 _defaultTabLen
= len
;
180 } /* tuiSetDefaultTabLen */
184 ** currentSourceWin()
185 ** Accessor for the current source window. Usually there is only
186 ** one source window (either source or disassembly), but both can
187 ** be displayed at the same time.
196 return &_sourceWindows
;
197 } /* currentSourceWindows */
201 ** clearSourceWindows()
202 ** Clear the list of source windows. Usually there is only one
203 ** source window (either source or disassembly), but both can be
204 ** displayed at the same time.
208 clearSourceWindows (void)
210 clearSourceWindows ()
213 _sourceWindows
.list
[0] = (Opaque
) NULL
;
214 _sourceWindows
.list
[1] = (Opaque
) NULL
;
215 _sourceWindows
.count
= 0;
218 } /* currentSourceWindows */
222 ** clearSourceWindowsDetail()
223 ** Clear the pertinant detail in the source windows.
227 clearSourceWindowsDetail (void)
229 clearSourceWindowsDetail ()
234 for (i
= 0; i
< (sourceWindows ())->count
; i
++)
235 clearWinDetail ((TuiWinInfoPtr
) (sourceWindows ())->list
[i
]);
238 } /* currentSourceWindows */
242 ** addSourceWindowToList().
243 ** Add a window to the list of source windows. Usually there is
244 ** only one source window (either source or disassembly), but
245 ** both can be displayed at the same time.
250 TuiWinInfoPtr winInfo
)
252 addToSourceWindows (winInfo
)
253 TuiWinInfoPtr winInfo
;
256 if (_sourceWindows
.count
< 2)
257 _sourceWindows
.list
[_sourceWindows
.count
++] = (Opaque
) winInfo
;
260 } /* addToSourceWindows */
265 ** Clear the pertinant detail in the windows.
270 TuiWinInfoPtr winInfo
)
272 clearWinDetail (winInfo
)
273 TuiWinInfoPtr winInfo
;
276 if (m_winPtrNotNull (winInfo
))
278 switch (winInfo
->generic
.type
)
282 winInfo
->detail
.sourceInfo
.startLineOrAddr
.addr
= (Opaque
) NULL
;
283 winInfo
->detail
.sourceInfo
.horizontalOffset
= 0;
286 winInfo
->detail
.commandInfo
.curLine
=
287 winInfo
->detail
.commandInfo
.curch
= 0;
290 winInfo
->detail
.dataDisplayInfo
.dataContent
=
291 (TuiWinContent
) NULL
;
292 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
293 winInfo
->detail
.dataDisplayInfo
.regsContent
=
294 (TuiWinContent
) NULL
;
295 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
296 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
298 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
299 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
307 } /* clearWinDetail */
312 ** Accessor for the blank string.
327 ** Accessor for the location string.
336 return _tuiLocationStr
;
342 ** Accessor for the break string.
356 ** breakLocationStr()
357 ** Accessor for the breakLocation string.
361 breakLocationStr (void)
366 return _tuiBreakLocationStr
;
367 } /* breakLocationStr */
372 ** Accessor for the null string.
386 ** sourceExecInfoPtr().
387 ** Accessor for the source execution info ptr.
391 sourceExecInfoWinPtr (void)
393 sourceExecInfoWinPtr ()
396 return &_execInfo
[0];
397 } /* sourceExecInfoWinPtr */
401 ** disassemExecInfoPtr().
402 ** Accessor for the disassem execution info ptr.
406 disassemExecInfoWinPtr (void)
408 disassemExecInfoWinPtr ()
411 return &_execInfo
[1];
412 } /* disassemExecInfoWinPtr */
416 ** locatorWinInfoPtr().
417 ** Accessor for the locator win info. Answers a pointer to the
418 ** static locator win info struct.
422 locatorWinInfoPtr (void)
428 } /* locatorWinInfoPtr */
433 ** Accessor for the history limit
442 return _historyLimit
;
447 ** setHistoryLimitTo().
448 ** Mutator for the history limit
455 setHistoryLimitTo (h
)
462 } /* setHistoryLimitTo */
466 ** Accessor for the termHeight
480 ** setTermHeightTo().
481 ** Mutator for the term height
495 } /* setTermHeightTo */
500 ** Accessor for the termWidth
515 ** Mutator for the termWidth
529 } /* setTermWidthTo */
534 ** Accessor for the current layout
543 return _currentLayout
;
544 } /* currentLayout */
548 ** setCurrentLayoutTo().
549 ** Mutator for the current layout
554 TuiLayoutType newLayout
)
556 setCurrentLayoutTo (newLayout
)
557 TuiLayoutType newLayout
;
560 _currentLayout
= newLayout
;
563 } /* setCurrentLayoutTo */
567 ** setGenWinOrigin().
568 ** Set the origin of the window
573 TuiGenWinInfoPtr winInfo
,
577 setGenWinOrigin (winInfo
, x
, y
)
578 TuiGenWinInfoPtr winInfo
;
583 winInfo
->origin
.x
= x
;
584 winInfo
->origin
.y
= y
;
587 } /* setGenWinOrigin */
590 /*****************************
591 ** OTHER PUBLIC FUNCTIONS
592 *****************************/
597 ** Answer the next window in the list, cycling back to the top
603 TuiWinInfoPtr curWin
)
606 TuiWinInfoPtr curWin
;
609 TuiWinType type
= curWin
->generic
.type
;
610 TuiWinInfoPtr nextWin
= (TuiWinInfoPtr
) NULL
;
612 if (curWin
->generic
.type
== CMD_WIN
)
615 type
= curWin
->generic
.type
+ 1;
616 while (type
!= curWin
->generic
.type
&& m_winPtrIsNull (nextWin
))
618 if (winList
[type
]->generic
.isVisible
)
619 nextWin
= winList
[type
];
635 ** Answer the prev window in the list, cycling back to the bottom
641 TuiWinInfoPtr curWin
)
644 TuiWinInfoPtr curWin
;
647 TuiWinType type
= curWin
->generic
.type
;
648 TuiWinInfoPtr prev
= (TuiWinInfoPtr
) NULL
;
650 if (curWin
->generic
.type
== SRC_WIN
)
653 type
= curWin
->generic
.type
- 1;
654 while (type
!= curWin
->generic
.type
&& m_winPtrIsNull (prev
))
656 if (winList
[type
]->generic
.isVisible
)
657 prev
= winList
[type
];
672 ** displayableWinContentOf().
673 ** Answer a the content at the location indicated by index. Note
674 ** that if this is a locator window, the string returned should be
679 displayableWinContentOf (
680 TuiGenWinInfoPtr winInfo
,
681 TuiWinElementPtr elementPtr
)
683 displayableWinContentOf (winInfo
, elementPtr
)
684 TuiGenWinInfoPtr winInfo
;
685 TuiWinElementPtr elementPtr
;
689 char *string
= nullStr ();
691 if (elementPtr
!= (TuiWinElementPtr
) NULL
|| winInfo
->type
== LOCATOR_WIN
)
694 ** Now convert the line to a displayable string
696 switch (winInfo
->type
)
700 string
= elementPtr
->whichElement
.source
.line
;
703 string
= elementPtr
->whichElement
.command
.line
;
706 if ((string
= (char *) xmalloc (
707 (termWidth () + 1) * sizeof (char))) == (char *) NULL
)
711 char lineNo
[50], pc
[50], buf
[50], *fname
, *pname
;
712 register int strSize
= termWidth (), i
, procWidth
, fileWidth
;
715 ** First determine the amount of file/proc name width
718 i
= strSize
- (PC_WIDTH
+ LINE_WIDTH
719 + 25 /* pc and line labels */
720 + strlen (FILE_PREFIX
) + 1 /* file label */
721 + 15 /* procedure label */ );
722 if (i
>= FILE_WIDTH
+ PROC_WIDTH
)
724 fileWidth
= FILE_WIDTH
;
725 procWidth
= PROC_WIDTH
;
730 procWidth
= i
- fileWidth
;
733 /* Now convert elements to string form */
734 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
735 *elementPtr
->whichElement
.locator
.fileName
!= (char) 0 &&
736 srcWin
->generic
.isVisible
)
737 fname
= elementPtr
->whichElement
.locator
.fileName
;
740 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
741 *elementPtr
->whichElement
.locator
.procName
!= (char) 0)
742 pname
= elementPtr
->whichElement
.locator
.procName
;
745 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
746 elementPtr
->whichElement
.locator
.lineNo
> 0)
747 sprintf (lineNo
, "%d",
748 elementPtr
->whichElement
.locator
.lineNo
);
750 strcpy (lineNo
, "??");
751 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
752 elementPtr
->whichElement
.locator
.addr
> (Opaque
) 0)
754 elementPtr
->whichElement
.locator
.addr
);
758 ** Now create the locator line from the string version
759 ** of the elements. We could use sprintf() here but
760 ** that wouldn't ensure that we don't overrun the size
761 ** of the allocated buffer. strcat_to_buf() will.
765 strcat_to_buf (string
, strSize
, " ");
766 strcat_to_buf (string
, strSize
, FILE_PREFIX
);
767 if (strlen (fname
) > fileWidth
)
769 strncpy (buf
, fname
, fileWidth
- 1);
770 buf
[fileWidth
- 1] = '*';
771 buf
[fileWidth
] = (char) 0;
775 strcat_to_buf (string
, strSize
, buf
);
776 /* procedure/class name */
777 sprintf (buf
, "%15s", PROC_PREFIX
);
778 strcat_to_buf (string
, strSize
, buf
);
779 if (strlen (pname
) > procWidth
)
781 strncpy (buf
, pname
, procWidth
- 1);
782 buf
[procWidth
- 1] = '*';
783 buf
[procWidth
] = (char) 0;
787 strcat_to_buf (string
, strSize
, buf
);
788 sprintf (buf
, "%10s", LINE_PREFIX
);
789 strcat_to_buf (string
, strSize
, buf
);
790 strcat_to_buf (string
, strSize
, lineNo
);
791 sprintf (buf
, "%10s", PC_PREFIX
);
792 strcat_to_buf (string
, strSize
, buf
);
793 strcat_to_buf (string
, strSize
, pc
);
794 for (i
= strlen (string
); i
< strSize
; i
++)
796 string
[strSize
] = (char) 0;
800 string
= elementPtr
->whichElement
.simpleString
;
807 } /* displayableWinContentOf */
812 ** Answer a the content at the location indicated by index
816 displayableWinContentAt (
817 TuiGenWinInfoPtr winInfo
,
820 displayableWinContentAt (winInfo
, index
)
821 TuiGenWinInfoPtr winInfo
;
825 return (displayableWinContentOf (winInfo
, (TuiWinElementPtr
) winInfo
->content
[index
]));
830 ** winElementHeight().
831 ** Answer the height of the element in lines
836 TuiGenWinInfoPtr winInfo
,
837 TuiWinElementPtr element
)
839 winElementHeight (winInfo
, element
)
840 TuiGenWinInfoPtr winInfo
;
841 TuiWinElementPtr element
;
846 if (winInfo
->type
== DATA_WIN
)
847 /* FOR NOW SAY IT IS ONLY ONE LINE HIGH */
853 } /* winElementHeight */
858 ** Answer the window represented by name
869 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
872 while (i
< MAX_MAJOR_WINDOWS
&& m_winPtrIsNull (winInfo
))
874 if (strcmp (name
, winName (&(winList
[i
]->generic
))) == 0)
875 winInfo
= winList
[i
];
884 ** partialWinByName().
885 ** Answer the window represented by name
892 partialWinByName (name
)
896 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
898 if (name
!= (char *) NULL
)
902 while (i
< MAX_MAJOR_WINDOWS
&& m_winPtrIsNull (winInfo
))
904 char *curName
= winName (&winList
[i
]->generic
);
905 if (strlen (name
) <= strlen (curName
) &&
906 strncmp (name
, curName
, strlen (name
)) == 0)
907 winInfo
= winList
[i
];
913 } /* partialWinByName */
918 ** Answer the name of the window
923 TuiGenWinInfoPtr winInfo
)
926 TuiGenWinInfoPtr winInfo
;
929 char *name
= (char *) NULL
;
931 switch (winInfo
->type
)
940 name
= DISASSEM_NAME
;
955 ** initializeStaticData
959 initializeStaticData (void)
961 initializeStaticData ()
964 initGenericPart (sourceExecInfoWinPtr ());
965 initGenericPart (disassemExecInfoWinPtr ());
966 initGenericPart (locatorWinInfoPtr ());
969 } /* initializeStaticData */
973 ** allocGenericWinInfo().
977 allocGenericWinInfo (void)
979 allocGenericWinInfo ()
982 TuiGenWinInfoPtr win
;
984 if ((win
= (TuiGenWinInfoPtr
) xmalloc (
985 sizeof (TuiGenWinInfoPtr
))) != (TuiGenWinInfoPtr
) NULL
)
986 initGenericPart (win
);
989 } /* allocGenericWinInfo */
993 ** initGenericPart().
998 TuiGenWinInfoPtr win
)
1000 initGenericPart (win
)
1001 TuiGenWinInfoPtr win
;
1008 win
->viewportHeight
=
1010 win
->lastVisibleLine
= 0;
1011 win
->handle
= (WINDOW
*) NULL
;
1012 win
->content
= (OpaquePtr
) NULL
;
1014 win
->isVisible
= FALSE
;
1017 } /* initGenericPart */
1021 ** initContentElement().
1025 initContentElement (
1026 TuiWinElementPtr element
,
1029 initContentElement (element
, type
)
1030 TuiWinElementPtr element
;
1034 element
->highlight
= FALSE
;
1039 element
->whichElement
.source
.line
= (char *) NULL
;
1040 element
->whichElement
.source
.lineOrAddr
.lineNo
= 0;
1041 element
->whichElement
.source
.isExecPoint
= FALSE
;
1042 element
->whichElement
.source
.hasBreak
= FALSE
;
1045 initGenericPart (&element
->whichElement
.dataWindow
);
1046 element
->whichElement
.dataWindow
.type
= DATA_ITEM_WIN
;
1047 ((TuiGenWinInfoPtr
) & element
->whichElement
.dataWindow
)->content
=
1048 (OpaquePtr
) allocContent (1, DATA_ITEM_WIN
);
1050 & element
->whichElement
.dataWindow
)->contentSize
= 1;
1053 element
->whichElement
.command
.line
= (char *) NULL
;
1056 element
->whichElement
.data
.name
= (char *) NULL
;
1057 element
->whichElement
.data
.type
= TUI_REGISTER
;
1058 element
->whichElement
.data
.itemNo
= UNDEFINED_ITEM
;
1059 element
->whichElement
.data
.value
= (Opaque
) NULL
;
1060 element
->whichElement
.data
.highlight
= FALSE
;
1063 element
->whichElement
.locator
.fileName
[0] =
1064 element
->whichElement
.locator
.procName
[0] = (char) 0;
1065 element
->whichElement
.locator
.lineNo
= 0;
1066 element
->whichElement
.locator
.addr
= 0;
1069 element
->whichElement
.simpleString
= blankStr ();
1075 } /* initContentElement */
1083 TuiWinInfoPtr winInfo
)
1085 initWinInfo (winInfo
)
1086 TuiWinInfoPtr winInfo
;
1089 initGenericPart (&winInfo
->generic
);
1090 winInfo
->canHighlight
=
1091 winInfo
->isHighlighted
= FALSE
;
1092 switch (winInfo
->generic
.type
)
1096 winInfo
->detail
.sourceInfo
.executionInfo
= (TuiGenWinInfoPtr
) NULL
;
1097 winInfo
->detail
.sourceInfo
.hasLocator
= FALSE
;
1098 winInfo
->detail
.sourceInfo
.horizontalOffset
= 0;
1099 winInfo
->detail
.sourceInfo
.startLineOrAddr
.addr
= (Opaque
) NULL
;
1102 winInfo
->detail
.dataDisplayInfo
.dataContent
= (TuiWinContent
) NULL
;
1103 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
1104 winInfo
->detail
.dataDisplayInfo
.regsContent
= (TuiWinContent
) NULL
;
1105 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
1106 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
1108 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
1109 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
1112 winInfo
->detail
.commandInfo
.curLine
= 0;
1113 winInfo
->detail
.commandInfo
.curch
= 0;
1116 winInfo
->detail
.opaque
= (Opaque
) NULL
;
1136 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
1138 winInfo
= (TuiWinInfoPtr
) xmalloc (sizeof (TuiWinInfo
));
1139 if (m_winPtrNotNull (winInfo
))
1141 winInfo
->generic
.type
= type
;
1142 initWinInfo (winInfo
);
1146 } /* allocWinInfo */
1151 ** Allocates the content and elements in a block.
1159 allocContent (numElements
, type
)
1164 TuiWinContent content
= (TuiWinContent
) NULL
;
1165 char *elementBlockPtr
= (char *) NULL
;
1168 if ((content
= (TuiWinContent
)
1169 xmalloc (sizeof (TuiWinElementPtr
) * numElements
)) != (TuiWinContent
) NULL
)
1171 ** All windows, except the data window, can allocate the elements
1172 ** in a chunk. The data window cannot because items can be
1173 ** added/removed from the data display by the user at any time.
1175 if (type
!= DATA_WIN
)
1177 if ((elementBlockPtr
= (char *)
1178 xmalloc (sizeof (TuiWinElement
) * numElements
)) != (char *) NULL
)
1180 for (i
= 0; i
< numElements
; i
++)
1182 content
[i
] = (TuiWinElementPtr
) elementBlockPtr
;
1183 initContentElement (content
[i
], type
);
1184 elementBlockPtr
+= sizeof (TuiWinElement
);
1189 tuiFree ((char *) content
);
1190 content
= (TuiWinContent
) NULL
;
1196 } /* allocContent */
1200 ** addContentElements().
1201 ** Adds the input number of elements to the windows's content. If
1202 ** no content has been allocated yet, allocContent() is called to
1203 ** do this. The index of the first element added is returned,
1204 ** unless there is a memory allocation error, in which case, (-1)
1209 addContentElements (
1210 TuiGenWinInfoPtr winInfo
,
1213 addContentElements (winInfo
, numElements
)
1214 TuiGenWinInfoPtr winInfo
;
1218 TuiWinElementPtr elementPtr
;
1221 if (winInfo
->content
== (OpaquePtr
) NULL
)
1223 winInfo
->content
= (OpaquePtr
) allocContent (numElements
, winInfo
->type
);
1227 indexStart
= winInfo
->contentSize
;
1228 if (winInfo
->content
!= (OpaquePtr
) NULL
)
1230 for (i
= indexStart
; (i
< numElements
+ indexStart
); i
++)
1232 if ((elementPtr
= (TuiWinElementPtr
)
1233 xmalloc (sizeof (TuiWinElement
))) != (TuiWinElementPtr
) NULL
)
1235 winInfo
->content
[i
] = (Opaque
) elementPtr
;
1236 initContentElement (elementPtr
, winInfo
->type
);
1237 winInfo
->contentSize
++;
1239 else /* things must be really hosed now! We ran out of memory!? */
1245 } /* addContentElements */
1250 ** Delete all curses windows associated with winInfo, leaving everything
1256 TuiWinInfoPtr winInfo
)
1258 tuiDelWindow (winInfo
)
1259 TuiWinInfoPtr winInfo
;
1264 TuiGenWinInfoPtr genericWin
;
1267 switch (winInfo
->generic
.type
)
1271 genericWin
= locatorWinInfoPtr ();
1272 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1274 tuiDelwin (genericWin
->handle
);
1275 genericWin
->handle
= (WINDOW
*) NULL
;
1276 genericWin
->isVisible
= FALSE
;
1278 genericWin
= winInfo
->detail
.sourceInfo
.executionInfo
;
1279 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1281 tuiDelwin (genericWin
->handle
);
1282 genericWin
->handle
= (WINDOW
*) NULL
;
1283 genericWin
->isVisible
= FALSE
;
1287 if (winInfo
->generic
.content
!= (OpaquePtr
) NULL
)
1292 winInfo
->detail
.dataDisplayInfo
.regsContent
,
1293 winInfo
->detail
.dataDisplayInfo
.regsContentCount
);
1295 winInfo
->detail
.dataDisplayInfo
.dataContent
,
1296 winInfo
->detail
.dataDisplayInfo
.dataContentCount
);
1302 if (winInfo
->generic
.handle
!= (WINDOW
*) NULL
)
1304 tuiDelwin (winInfo
->generic
.handle
);
1305 winInfo
->generic
.handle
= (WINDOW
*) NULL
;
1306 winInfo
->generic
.isVisible
= FALSE
;
1310 } /* tuiDelWindow */
1319 TuiWinInfoPtr winInfo
)
1321 freeWindow (winInfo
)
1322 TuiWinInfoPtr winInfo
;
1327 TuiGenWinInfoPtr genericWin
;
1330 switch (winInfo
->generic
.type
)
1334 genericWin
= locatorWinInfoPtr ();
1335 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1337 tuiDelwin (genericWin
->handle
);
1338 genericWin
->handle
= (WINDOW
*) NULL
;
1340 freeWinContent (genericWin
);
1341 genericWin
= winInfo
->detail
.sourceInfo
.executionInfo
;
1342 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1344 tuiDelwin (genericWin
->handle
);
1345 genericWin
->handle
= (WINDOW
*) NULL
;
1346 freeWinContent (genericWin
);
1350 if (winInfo
->generic
.content
!= (OpaquePtr
) NULL
)
1353 winInfo
->detail
.dataDisplayInfo
.regsContent
,
1354 winInfo
->detail
.dataDisplayInfo
.regsContentCount
);
1355 winInfo
->detail
.dataDisplayInfo
.regsContent
=
1356 (TuiWinContent
) NULL
;
1357 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
1359 winInfo
->detail
.dataDisplayInfo
.dataContent
,
1360 winInfo
->detail
.dataDisplayInfo
.dataContentCount
);
1361 winInfo
->detail
.dataDisplayInfo
.dataContent
=
1362 (TuiWinContent
) NULL
;
1363 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
1364 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
1366 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
1367 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
1368 winInfo
->generic
.content
= (OpaquePtr
) NULL
;
1369 winInfo
->generic
.contentSize
= 0;
1375 if (winInfo
->generic
.handle
!= (WINDOW
*) NULL
)
1377 tuiDelwin (winInfo
->generic
.handle
);
1378 winInfo
->generic
.handle
= (WINDOW
*) NULL
;
1379 freeWinContent (&winInfo
->generic
);
1388 ** freeAllSourceWinsContent().
1392 freeAllSourceWinsContent (void)
1394 freeAllSourceWinsContent ()
1399 for (i
= 0; i
< (sourceWindows ())->count
; i
++)
1401 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) (sourceWindows ())->list
[i
];
1403 if (m_winPtrNotNull (winInfo
))
1405 freeWinContent (&(winInfo
->generic
));
1406 freeWinContent (winInfo
->detail
.sourceInfo
.executionInfo
);
1411 } /* freeAllSourceWinsContent */
1415 ** freeWinContent().
1420 TuiGenWinInfoPtr winInfo
)
1422 freeWinContent (winInfo
)
1423 TuiGenWinInfoPtr winInfo
;
1426 if (winInfo
->content
!= (OpaquePtr
) NULL
)
1428 freeContent ((TuiWinContent
) winInfo
->content
,
1429 winInfo
->contentSize
,
1431 winInfo
->content
= (OpaquePtr
) NULL
;
1433 winInfo
->contentSize
= 0;
1436 } /* freeWinContent */
1440 ** freeAllWindows().
1444 freeAllWindows (void)
1449 TuiWinType type
= SRC_WIN
;
1451 for (; type
< MAX_MAJOR_WINDOWS
; type
++)
1452 if (m_winPtrNotNull (winList
[type
]) &&
1453 winList
[type
]->generic
.type
!= UNDEFINED_WIN
)
1454 freeWindow (winList
[type
]);
1456 } /* freeAllWindows */
1462 TuiWinContent content
,
1465 tuiDelDataWindows (content
, contentSize
)
1466 TuiWinContent content
;
1473 ** Remember that data window content elements are of type TuiGenWinInfoPtr,
1474 ** each of which whose single element is a data element.
1476 for (i
= 0; i
< contentSize
; i
++)
1478 TuiGenWinInfoPtr genericWin
= &content
[i
]->whichElement
.dataWindow
;
1480 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1482 tuiDelwin (genericWin
->handle
);
1483 genericWin
->handle
= (WINDOW
*) NULL
;
1484 genericWin
->isVisible
= FALSE
;
1489 } /* tuiDelDataWindows */
1495 TuiWinContent content
,
1498 freeDataContent (content
, contentSize
)
1499 TuiWinContent content
;
1506 ** Remember that data window content elements are of type TuiGenWinInfoPtr,
1507 ** each of which whose single element is a data element.
1509 for (i
= 0; i
< contentSize
; i
++)
1511 TuiGenWinInfoPtr genericWin
= &content
[i
]->whichElement
.dataWindow
;
1513 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1515 tuiDelwin (genericWin
->handle
);
1516 genericWin
->handle
= (WINDOW
*) NULL
;
1517 freeWinContent (genericWin
);
1520 freeContent (content
,
1525 } /* freeDataContent */
1528 /**********************************
1529 ** LOCAL STATIC FUNCTIONS **
1530 **********************************/
1539 TuiWinContent content
,
1543 freeContent (content
, contentSize
, winType
)
1544 TuiWinContent content
;
1549 if (content
!= (TuiWinContent
) NULL
)
1551 freeContentElements (content
, contentSize
, winType
);
1552 tuiFree ((char *) content
);
1560 ** freeContentElements().
1564 freeContentElements (
1565 TuiWinContent content
,
1569 freeContentElements (content
, contentSize
, type
)
1570 TuiWinContent content
;
1575 if (content
!= (TuiWinContent
) NULL
)
1579 if (type
== SRC_WIN
|| type
== DISASSEM_WIN
)
1581 /* free whole source block */
1582 if (content
[0]->whichElement
.source
.line
!= (char *) NULL
)
1583 tuiFree (content
[0]->whichElement
.source
.line
);
1587 for (i
= 0; i
< contentSize
; i
++)
1589 TuiWinElementPtr element
;
1591 element
= content
[i
];
1592 if (element
!= (TuiWinElementPtr
) NULL
)
1597 tuiFree ((char *) element
);
1601 ** Note that data elements are not allocated
1602 ** in a single block, but individually, as needed.
1604 if (element
->whichElement
.data
.type
!= TUI_REGISTER
)
1606 element
->whichElement
.data
.name
);
1607 tuiFree ((char *) element
->whichElement
.data
.value
);
1608 tuiFree ((char *) element
);
1611 tuiFree ((char *) element
->whichElement
.command
.line
);
1619 if (type
!= DATA_WIN
&& type
!= DATA_ITEM_WIN
)
1620 tuiFree ((char *) content
[0]); /* free the element block */
1624 } /* freeContentElements */