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
93 ** tuiSetWinResized().
94 ** Set a whether the terminal window has been resized or not
97 tuiSetWinResizedTo (int resized
)
99 _winResized
= resized
;
102 } /* tuiSetWinResizedTo */
107 ** Answer a pointer to the current layout definition
117 ** tuiWinWithFocus().
118 ** Answer the window with the logical focus
121 tuiWinWithFocus (void)
123 return _winWithFocus
;
124 } /* tuiWinWithFocus */
128 ** tuiSetWinWithFocus().
129 ** Set the window that has the logical focus
132 tuiSetWinWithFocus (TuiWinInfoPtr winInfo
)
134 _winWithFocus
= winInfo
;
137 } /* tuiSetWinWithFocus */
141 ** tuiDefaultTabLen().
142 ** Answer the length in chars, of tabs
145 tuiDefaultTabLen (void)
147 return _defaultTabLen
;
148 } /* tuiDefaultTabLen */
152 ** tuiSetDefaultTabLen().
153 ** Set the length in chars, of tabs
156 tuiSetDefaultTabLen (int len
)
158 _defaultTabLen
= len
;
161 } /* tuiSetDefaultTabLen */
165 ** currentSourceWin()
166 ** Accessor for the current source window. Usually there is only
167 ** one source window (either source or disassembly), but both can
168 ** be displayed at the same time.
173 return &_sourceWindows
;
174 } /* currentSourceWindows */
178 ** clearSourceWindows()
179 ** Clear the list of source windows. Usually there is only one
180 ** source window (either source or disassembly), but both can be
181 ** displayed at the same time.
184 clearSourceWindows (void)
186 _sourceWindows
.list
[0] = (Opaque
) NULL
;
187 _sourceWindows
.list
[1] = (Opaque
) NULL
;
188 _sourceWindows
.count
= 0;
191 } /* currentSourceWindows */
195 ** clearSourceWindowsDetail()
196 ** Clear the pertinant detail in the source windows.
199 clearSourceWindowsDetail (void)
203 for (i
= 0; i
< (sourceWindows ())->count
; i
++)
204 clearWinDetail ((TuiWinInfoPtr
) (sourceWindows ())->list
[i
]);
207 } /* currentSourceWindows */
211 ** addSourceWindowToList().
212 ** Add a window to the list of source windows. Usually there is
213 ** only one source window (either source or disassembly), but
214 ** both can be displayed at the same time.
217 addToSourceWindows (TuiWinInfoPtr winInfo
)
219 if (_sourceWindows
.count
< 2)
220 _sourceWindows
.list
[_sourceWindows
.count
++] = (Opaque
) winInfo
;
223 } /* addToSourceWindows */
228 ** Clear the pertinant detail in the windows.
231 clearWinDetail (TuiWinInfoPtr winInfo
)
233 if (m_winPtrNotNull (winInfo
))
235 switch (winInfo
->generic
.type
)
239 winInfo
->detail
.sourceInfo
.startLineOrAddr
.addr
= (Opaque
) NULL
;
240 winInfo
->detail
.sourceInfo
.horizontalOffset
= 0;
243 winInfo
->detail
.commandInfo
.curLine
=
244 winInfo
->detail
.commandInfo
.curch
= 0;
247 winInfo
->detail
.dataDisplayInfo
.dataContent
=
248 (TuiWinContent
) NULL
;
249 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
250 winInfo
->detail
.dataDisplayInfo
.regsContent
=
251 (TuiWinContent
) NULL
;
252 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
253 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
255 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
256 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
264 } /* clearWinDetail */
269 ** Accessor for the blank string.
280 ** Accessor for the location string.
285 return _tuiLocationStr
;
291 ** Accessor for the break string.
301 ** breakLocationStr()
302 ** Accessor for the breakLocation string.
305 breakLocationStr (void)
307 return _tuiBreakLocationStr
;
308 } /* breakLocationStr */
313 ** Accessor for the null string.
323 ** sourceExecInfoPtr().
324 ** Accessor for the source execution info ptr.
327 sourceExecInfoWinPtr (void)
329 return &_execInfo
[0];
330 } /* sourceExecInfoWinPtr */
334 ** disassemExecInfoPtr().
335 ** Accessor for the disassem execution info ptr.
338 disassemExecInfoWinPtr (void)
340 return &_execInfo
[1];
341 } /* disassemExecInfoWinPtr */
345 ** locatorWinInfoPtr().
346 ** Accessor for the locator win info. Answers a pointer to the
347 ** static locator win info struct.
350 locatorWinInfoPtr (void)
353 } /* locatorWinInfoPtr */
358 ** Accessor for the history limit
363 return _historyLimit
;
368 ** setHistoryLimitTo().
369 ** Mutator for the history limit
372 setHistoryLimitTo (int h
)
377 } /* setHistoryLimitTo */
381 ** Accessor for the termHeight
391 ** setTermHeightTo().
392 ** Mutator for the term height
395 setTermHeightTo (int h
)
400 } /* setTermHeightTo */
405 ** Accessor for the termWidth
416 ** Mutator for the termWidth
419 setTermWidthTo (int w
)
424 } /* setTermWidthTo */
429 ** Accessor for the current layout
434 return _currentLayout
;
435 } /* currentLayout */
439 ** setCurrentLayoutTo().
440 ** Mutator for the current layout
443 setCurrentLayoutTo (TuiLayoutType newLayout
)
445 _currentLayout
= newLayout
;
448 } /* setCurrentLayoutTo */
452 ** setGenWinOrigin().
453 ** Set the origin of the window
456 setGenWinOrigin (TuiGenWinInfoPtr winInfo
, int x
, int y
)
458 winInfo
->origin
.x
= x
;
459 winInfo
->origin
.y
= y
;
462 } /* setGenWinOrigin */
465 /*****************************
466 ** OTHER PUBLIC FUNCTIONS
467 *****************************/
472 ** Answer the next window in the list, cycling back to the top
476 tuiNextWin (TuiWinInfoPtr curWin
)
478 TuiWinType type
= curWin
->generic
.type
;
479 TuiWinInfoPtr nextWin
= (TuiWinInfoPtr
) NULL
;
481 if (curWin
->generic
.type
== CMD_WIN
)
484 type
= curWin
->generic
.type
+ 1;
485 while (type
!= curWin
->generic
.type
&& m_winPtrIsNull (nextWin
))
487 if (winList
[type
]->generic
.isVisible
)
488 nextWin
= winList
[type
];
504 ** Answer the prev window in the list, cycling back to the bottom
508 tuiPrevWin (TuiWinInfoPtr curWin
)
510 TuiWinType type
= curWin
->generic
.type
;
511 TuiWinInfoPtr prev
= (TuiWinInfoPtr
) NULL
;
513 if (curWin
->generic
.type
== SRC_WIN
)
516 type
= curWin
->generic
.type
- 1;
517 while (type
!= curWin
->generic
.type
&& m_winPtrIsNull (prev
))
519 if (winList
[type
]->generic
.isVisible
)
520 prev
= winList
[type
];
535 ** displayableWinContentOf().
536 ** Answer a the content at the location indicated by index. Note
537 ** that if this is a locator window, the string returned should be
541 displayableWinContentOf (TuiGenWinInfoPtr winInfo
, TuiWinElementPtr elementPtr
)
544 char *string
= nullStr ();
546 if (elementPtr
!= (TuiWinElementPtr
) NULL
|| winInfo
->type
== LOCATOR_WIN
)
549 ** Now convert the line to a displayable string
551 switch (winInfo
->type
)
555 string
= elementPtr
->whichElement
.source
.line
;
558 string
= elementPtr
->whichElement
.command
.line
;
561 if ((string
= (char *) xmalloc (
562 (termWidth () + 1) * sizeof (char))) == (char *) NULL
)
566 char lineNo
[50], pc
[50], buf
[50], *fname
, *pname
;
567 register int strSize
= termWidth (), i
, procWidth
, fileWidth
;
570 ** First determine the amount of file/proc name width
573 i
= strSize
- (PC_WIDTH
+ LINE_WIDTH
574 + 25 /* pc and line labels */
575 + strlen (FILE_PREFIX
) + 1 /* file label */
576 + 15 /* procedure label */ );
577 if (i
>= FILE_WIDTH
+ PROC_WIDTH
)
579 fileWidth
= FILE_WIDTH
;
580 procWidth
= PROC_WIDTH
;
585 procWidth
= i
- fileWidth
;
588 /* Now convert elements to string form */
589 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
590 *elementPtr
->whichElement
.locator
.fileName
!= (char) 0 &&
591 srcWin
->generic
.isVisible
)
592 fname
= elementPtr
->whichElement
.locator
.fileName
;
595 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
596 *elementPtr
->whichElement
.locator
.procName
!= (char) 0)
597 pname
= elementPtr
->whichElement
.locator
.procName
;
600 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
601 elementPtr
->whichElement
.locator
.lineNo
> 0)
602 sprintf (lineNo
, "%d",
603 elementPtr
->whichElement
.locator
.lineNo
);
605 strcpy (lineNo
, "??");
606 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
607 elementPtr
->whichElement
.locator
.addr
> (Opaque
) 0)
609 elementPtr
->whichElement
.locator
.addr
);
613 ** Now create the locator line from the string version
614 ** of the elements. We could use sprintf() here but
615 ** that wouldn't ensure that we don't overrun the size
616 ** of the allocated buffer. strcat_to_buf() will.
620 strcat_to_buf (string
, strSize
, " ");
621 strcat_to_buf (string
, strSize
, FILE_PREFIX
);
622 if (strlen (fname
) > fileWidth
)
624 strncpy (buf
, fname
, fileWidth
- 1);
625 buf
[fileWidth
- 1] = '*';
626 buf
[fileWidth
] = (char) 0;
630 strcat_to_buf (string
, strSize
, buf
);
631 /* procedure/class name */
632 sprintf (buf
, "%15s", PROC_PREFIX
);
633 strcat_to_buf (string
, strSize
, buf
);
634 if (strlen (pname
) > procWidth
)
636 strncpy (buf
, pname
, procWidth
- 1);
637 buf
[procWidth
- 1] = '*';
638 buf
[procWidth
] = (char) 0;
642 strcat_to_buf (string
, strSize
, buf
);
643 sprintf (buf
, "%10s", LINE_PREFIX
);
644 strcat_to_buf (string
, strSize
, buf
);
645 strcat_to_buf (string
, strSize
, lineNo
);
646 sprintf (buf
, "%10s", PC_PREFIX
);
647 strcat_to_buf (string
, strSize
, buf
);
648 strcat_to_buf (string
, strSize
, pc
);
649 for (i
= strlen (string
); i
< strSize
; i
++)
651 string
[strSize
] = (char) 0;
655 string
= elementPtr
->whichElement
.simpleString
;
662 } /* displayableWinContentOf */
667 ** Answer a the content at the location indicated by index
670 displayableWinContentAt (TuiGenWinInfoPtr winInfo
, int index
)
672 return (displayableWinContentOf (winInfo
, (TuiWinElementPtr
) winInfo
->content
[index
]));
677 ** winElementHeight().
678 ** Answer the height of the element in lines
681 winElementHeight (TuiGenWinInfoPtr winInfo
, TuiWinElementPtr element
)
685 if (winInfo
->type
== DATA_WIN
)
686 /* FOR NOW SAY IT IS ONLY ONE LINE HIGH */
692 } /* winElementHeight */
697 ** Answer the window represented by name
700 winByName (char *name
)
702 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
705 while (i
< MAX_MAJOR_WINDOWS
&& m_winPtrIsNull (winInfo
))
707 if (strcmp (name
, winName (&(winList
[i
]->generic
))) == 0)
708 winInfo
= winList
[i
];
717 ** partialWinByName().
718 ** Answer the window represented by name
721 partialWinByName (char *name
)
723 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
725 if (name
!= (char *) NULL
)
729 while (i
< MAX_MAJOR_WINDOWS
&& m_winPtrIsNull (winInfo
))
731 char *curName
= winName (&winList
[i
]->generic
);
732 if (strlen (name
) <= strlen (curName
) &&
733 strncmp (name
, curName
, strlen (name
)) == 0)
734 winInfo
= winList
[i
];
740 } /* partialWinByName */
745 ** Answer the name of the window
748 winName (TuiGenWinInfoPtr winInfo
)
750 char *name
= (char *) NULL
;
752 switch (winInfo
->type
)
761 name
= DISASSEM_NAME
;
776 ** initializeStaticData
779 initializeStaticData (void)
781 initGenericPart (sourceExecInfoWinPtr ());
782 initGenericPart (disassemExecInfoWinPtr ());
783 initGenericPart (locatorWinInfoPtr ());
786 } /* initializeStaticData */
790 ** allocGenericWinInfo().
793 allocGenericWinInfo (void)
795 TuiGenWinInfoPtr win
;
797 if ((win
= (TuiGenWinInfoPtr
) xmalloc (
798 sizeof (TuiGenWinInfoPtr
))) != (TuiGenWinInfoPtr
) NULL
)
799 initGenericPart (win
);
802 } /* allocGenericWinInfo */
806 ** initGenericPart().
809 initGenericPart (TuiGenWinInfoPtr win
)
815 win
->viewportHeight
=
817 win
->lastVisibleLine
= 0;
818 win
->handle
= (WINDOW
*) NULL
;
819 win
->content
= (OpaquePtr
) NULL
;
821 win
->isVisible
= FALSE
;
824 } /* initGenericPart */
828 ** initContentElement().
831 initContentElement (TuiWinElementPtr element
, TuiWinType type
)
833 element
->highlight
= FALSE
;
838 element
->whichElement
.source
.line
= (char *) NULL
;
839 element
->whichElement
.source
.lineOrAddr
.lineNo
= 0;
840 element
->whichElement
.source
.isExecPoint
= FALSE
;
841 element
->whichElement
.source
.hasBreak
= FALSE
;
844 initGenericPart (&element
->whichElement
.dataWindow
);
845 element
->whichElement
.dataWindow
.type
= DATA_ITEM_WIN
;
846 ((TuiGenWinInfoPtr
) & element
->whichElement
.dataWindow
)->content
=
847 (OpaquePtr
) allocContent (1, DATA_ITEM_WIN
);
849 & element
->whichElement
.dataWindow
)->contentSize
= 1;
852 element
->whichElement
.command
.line
= (char *) NULL
;
855 element
->whichElement
.data
.name
= (char *) NULL
;
856 element
->whichElement
.data
.type
= TUI_REGISTER
;
857 element
->whichElement
.data
.itemNo
= UNDEFINED_ITEM
;
858 element
->whichElement
.data
.value
= (Opaque
) NULL
;
859 element
->whichElement
.data
.highlight
= FALSE
;
862 element
->whichElement
.locator
.fileName
[0] =
863 element
->whichElement
.locator
.procName
[0] = (char) 0;
864 element
->whichElement
.locator
.lineNo
= 0;
865 element
->whichElement
.locator
.addr
= 0;
868 element
->whichElement
.simpleString
= blankStr ();
874 } /* initContentElement */
880 initWinInfo (TuiWinInfoPtr winInfo
)
882 initGenericPart (&winInfo
->generic
);
883 winInfo
->canHighlight
=
884 winInfo
->isHighlighted
= FALSE
;
885 switch (winInfo
->generic
.type
)
889 winInfo
->detail
.sourceInfo
.executionInfo
= (TuiGenWinInfoPtr
) NULL
;
890 winInfo
->detail
.sourceInfo
.hasLocator
= FALSE
;
891 winInfo
->detail
.sourceInfo
.horizontalOffset
= 0;
892 winInfo
->detail
.sourceInfo
.startLineOrAddr
.addr
= (Opaque
) NULL
;
895 winInfo
->detail
.dataDisplayInfo
.dataContent
= (TuiWinContent
) NULL
;
896 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
897 winInfo
->detail
.dataDisplayInfo
.regsContent
= (TuiWinContent
) NULL
;
898 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
899 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
901 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
902 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
905 winInfo
->detail
.commandInfo
.curLine
= 0;
906 winInfo
->detail
.commandInfo
.curch
= 0;
909 winInfo
->detail
.opaque
= (Opaque
) NULL
;
921 allocWinInfo (TuiWinType type
)
923 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
925 winInfo
= (TuiWinInfoPtr
) xmalloc (sizeof (TuiWinInfo
));
926 if (m_winPtrNotNull (winInfo
))
928 winInfo
->generic
.type
= type
;
929 initWinInfo (winInfo
);
938 ** Allocates the content and elements in a block.
941 allocContent (int numElements
, TuiWinType type
)
943 TuiWinContent content
= (TuiWinContent
) NULL
;
944 char *elementBlockPtr
= (char *) NULL
;
947 if ((content
= (TuiWinContent
)
948 xmalloc (sizeof (TuiWinElementPtr
) * numElements
)) != (TuiWinContent
) NULL
)
950 ** All windows, except the data window, can allocate the elements
951 ** in a chunk. The data window cannot because items can be
952 ** added/removed from the data display by the user at any time.
954 if (type
!= DATA_WIN
)
956 if ((elementBlockPtr
= (char *)
957 xmalloc (sizeof (TuiWinElement
) * numElements
)) != (char *) NULL
)
959 for (i
= 0; i
< numElements
; i
++)
961 content
[i
] = (TuiWinElementPtr
) elementBlockPtr
;
962 initContentElement (content
[i
], type
);
963 elementBlockPtr
+= sizeof (TuiWinElement
);
968 tuiFree ((char *) content
);
969 content
= (TuiWinContent
) NULL
;
979 ** addContentElements().
980 ** Adds the input number of elements to the windows's content. If
981 ** no content has been allocated yet, allocContent() is called to
982 ** do this. The index of the first element added is returned,
983 ** unless there is a memory allocation error, in which case, (-1)
987 addContentElements (TuiGenWinInfoPtr winInfo
, int numElements
)
989 TuiWinElementPtr elementPtr
;
992 if (winInfo
->content
== (OpaquePtr
) NULL
)
994 winInfo
->content
= (OpaquePtr
) allocContent (numElements
, winInfo
->type
);
998 indexStart
= winInfo
->contentSize
;
999 if (winInfo
->content
!= (OpaquePtr
) NULL
)
1001 for (i
= indexStart
; (i
< numElements
+ indexStart
); i
++)
1003 if ((elementPtr
= (TuiWinElementPtr
)
1004 xmalloc (sizeof (TuiWinElement
))) != (TuiWinElementPtr
) NULL
)
1006 winInfo
->content
[i
] = (Opaque
) elementPtr
;
1007 initContentElement (elementPtr
, winInfo
->type
);
1008 winInfo
->contentSize
++;
1010 else /* things must be really hosed now! We ran out of memory!? */
1016 } /* addContentElements */
1021 ** Delete all curses windows associated with winInfo, leaving everything
1025 tuiDelWindow (TuiWinInfoPtr winInfo
)
1029 TuiGenWinInfoPtr genericWin
;
1032 switch (winInfo
->generic
.type
)
1036 genericWin
= locatorWinInfoPtr ();
1037 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1039 tuiDelwin (genericWin
->handle
);
1040 genericWin
->handle
= (WINDOW
*) NULL
;
1041 genericWin
->isVisible
= FALSE
;
1043 genericWin
= winInfo
->detail
.sourceInfo
.executionInfo
;
1044 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1046 tuiDelwin (genericWin
->handle
);
1047 genericWin
->handle
= (WINDOW
*) NULL
;
1048 genericWin
->isVisible
= FALSE
;
1052 if (winInfo
->generic
.content
!= (OpaquePtr
) NULL
)
1057 winInfo
->detail
.dataDisplayInfo
.regsContent
,
1058 winInfo
->detail
.dataDisplayInfo
.regsContentCount
);
1060 winInfo
->detail
.dataDisplayInfo
.dataContent
,
1061 winInfo
->detail
.dataDisplayInfo
.dataContentCount
);
1067 if (winInfo
->generic
.handle
!= (WINDOW
*) NULL
)
1069 tuiDelwin (winInfo
->generic
.handle
);
1070 winInfo
->generic
.handle
= (WINDOW
*) NULL
;
1071 winInfo
->generic
.isVisible
= FALSE
;
1075 } /* tuiDelWindow */
1082 freeWindow (TuiWinInfoPtr winInfo
)
1086 TuiGenWinInfoPtr genericWin
;
1089 switch (winInfo
->generic
.type
)
1093 genericWin
= locatorWinInfoPtr ();
1094 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1096 tuiDelwin (genericWin
->handle
);
1097 genericWin
->handle
= (WINDOW
*) NULL
;
1099 freeWinContent (genericWin
);
1100 genericWin
= winInfo
->detail
.sourceInfo
.executionInfo
;
1101 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1103 tuiDelwin (genericWin
->handle
);
1104 genericWin
->handle
= (WINDOW
*) NULL
;
1105 freeWinContent (genericWin
);
1109 if (winInfo
->generic
.content
!= (OpaquePtr
) NULL
)
1112 winInfo
->detail
.dataDisplayInfo
.regsContent
,
1113 winInfo
->detail
.dataDisplayInfo
.regsContentCount
);
1114 winInfo
->detail
.dataDisplayInfo
.regsContent
=
1115 (TuiWinContent
) NULL
;
1116 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
1118 winInfo
->detail
.dataDisplayInfo
.dataContent
,
1119 winInfo
->detail
.dataDisplayInfo
.dataContentCount
);
1120 winInfo
->detail
.dataDisplayInfo
.dataContent
=
1121 (TuiWinContent
) NULL
;
1122 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
1123 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
1125 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
1126 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
1127 winInfo
->generic
.content
= (OpaquePtr
) NULL
;
1128 winInfo
->generic
.contentSize
= 0;
1134 if (winInfo
->generic
.handle
!= (WINDOW
*) NULL
)
1136 tuiDelwin (winInfo
->generic
.handle
);
1137 winInfo
->generic
.handle
= (WINDOW
*) NULL
;
1138 freeWinContent (&winInfo
->generic
);
1147 ** freeAllSourceWinsContent().
1150 freeAllSourceWinsContent (void)
1154 for (i
= 0; i
< (sourceWindows ())->count
; i
++)
1156 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) (sourceWindows ())->list
[i
];
1158 if (m_winPtrNotNull (winInfo
))
1160 freeWinContent (&(winInfo
->generic
));
1161 freeWinContent (winInfo
->detail
.sourceInfo
.executionInfo
);
1166 } /* freeAllSourceWinsContent */
1170 ** freeWinContent().
1173 freeWinContent (TuiGenWinInfoPtr winInfo
)
1175 if (winInfo
->content
!= (OpaquePtr
) NULL
)
1177 freeContent ((TuiWinContent
) winInfo
->content
,
1178 winInfo
->contentSize
,
1180 winInfo
->content
= (OpaquePtr
) NULL
;
1182 winInfo
->contentSize
= 0;
1185 } /* freeWinContent */
1189 ** freeAllWindows().
1192 freeAllWindows (void)
1194 TuiWinType type
= SRC_WIN
;
1196 for (; type
< MAX_MAJOR_WINDOWS
; type
++)
1197 if (m_winPtrNotNull (winList
[type
]) &&
1198 winList
[type
]->generic
.type
!= UNDEFINED_WIN
)
1199 freeWindow (winList
[type
]);
1201 } /* freeAllWindows */
1205 tuiDelDataWindows (TuiWinContent content
, int contentSize
)
1210 ** Remember that data window content elements are of type TuiGenWinInfoPtr,
1211 ** each of which whose single element is a data element.
1213 for (i
= 0; i
< contentSize
; i
++)
1215 TuiGenWinInfoPtr genericWin
= &content
[i
]->whichElement
.dataWindow
;
1217 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1219 tuiDelwin (genericWin
->handle
);
1220 genericWin
->handle
= (WINDOW
*) NULL
;
1221 genericWin
->isVisible
= FALSE
;
1226 } /* tuiDelDataWindows */
1230 freeDataContent (TuiWinContent content
, int contentSize
)
1235 ** Remember that data window content elements are of type TuiGenWinInfoPtr,
1236 ** each of which whose single element is a data element.
1238 for (i
= 0; i
< contentSize
; i
++)
1240 TuiGenWinInfoPtr genericWin
= &content
[i
]->whichElement
.dataWindow
;
1242 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1244 tuiDelwin (genericWin
->handle
);
1245 genericWin
->handle
= (WINDOW
*) NULL
;
1246 freeWinContent (genericWin
);
1249 freeContent (content
,
1254 } /* freeDataContent */
1257 /**********************************
1258 ** LOCAL STATIC FUNCTIONS **
1259 **********************************/
1266 freeContent (TuiWinContent content
, int contentSize
, TuiWinType winType
)
1268 if (content
!= (TuiWinContent
) NULL
)
1270 freeContentElements (content
, contentSize
, winType
);
1271 tuiFree ((char *) content
);
1279 ** freeContentElements().
1282 freeContentElements (TuiWinContent content
, int contentSize
, TuiWinType type
)
1284 if (content
!= (TuiWinContent
) NULL
)
1288 if (type
== SRC_WIN
|| type
== DISASSEM_WIN
)
1290 /* free whole source block */
1291 if (content
[0]->whichElement
.source
.line
!= (char *) NULL
)
1292 tuiFree (content
[0]->whichElement
.source
.line
);
1296 for (i
= 0; i
< contentSize
; i
++)
1298 TuiWinElementPtr element
;
1300 element
= content
[i
];
1301 if (element
!= (TuiWinElementPtr
) NULL
)
1306 tuiFree ((char *) element
);
1310 ** Note that data elements are not allocated
1311 ** in a single block, but individually, as needed.
1313 if (element
->whichElement
.data
.type
!= TUI_REGISTER
)
1315 element
->whichElement
.data
.name
);
1316 tuiFree ((char *) element
->whichElement
.data
.value
);
1317 tuiFree ((char *) element
);
1320 tuiFree ((char *) element
->whichElement
.command
.line
);
1328 if (type
!= DATA_WIN
&& type
!= DATA_ITEM_WIN
)
1329 tuiFree ((char *) content
[0]); /* free the element block */
1333 } /* freeContentElements */