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. */
25 #include "tuiGeneralWin.h"
27 /****************************
28 ** GLOBAL DECLARATIONS
29 ****************************/
30 TuiWinInfoPtr winList
[MAX_MAJOR_WINDOWS
];
32 /***************************
33 ** Private Definitions
34 ****************************/
40 /***************************
42 ****************************/
43 static char *_tuiNullStr
= TUI_NULL_STR
;
44 static char *_tuiBlankStr
= " ";
45 static char *_tuiLocationStr
= " >";
46 static char *_tuiBreakStr
= " * ";
47 static char *_tuiBreakLocationStr
= " *>";
48 static TuiLayoutType _currentLayout
= UNDEFINED_LAYOUT
;
49 static int _termHeight
, _termWidth
;
50 static int _historyLimit
= DEFAULT_HISTORY_COUNT
;
51 static TuiGenWinInfo _locator
;
52 static TuiGenWinInfo _execInfo
[2];
53 static TuiWinInfoPtr _srcWinList
[2];
54 static TuiList _sourceWindows
=
55 {(OpaqueList
) _srcWinList
, 0};
56 static int _defaultTabLen
= DEFAULT_TAB_LEN
;
57 static TuiWinInfoPtr _winWithFocus
= (TuiWinInfoPtr
) NULL
;
58 static TuiLayoutDef _layoutDef
=
59 {SRC_WIN
, /* displayMode */
61 TUI_UNDEFINED_REGS
, /* regsDisplayType */
62 TUI_SFLOAT_REGS
}; /* floatRegsDisplayType */
63 static int _winResized
= FALSE
;
66 /*********************************
67 ** Static function forward decls
68 **********************************/
69 static void freeContent (TuiWinContent
, int, TuiWinType
);
70 static void freeContentElements (TuiWinContent
, int, TuiWinType
);
74 /*********************************
76 **********************************/
78 /******************************************
79 ** ACCESSORS & MUTATORS FOR PRIVATE DATA
80 ******************************************/
84 ** Answer a whether the terminal window has been resized or not
94 ** tuiSetWinResized().
95 ** Set a whether the terminal window has been resized or not
98 tuiSetWinResizedTo (int resized
)
100 _winResized
= resized
;
103 } /* tuiSetWinResizedTo */
108 ** Answer a pointer to the current layout definition
118 ** tuiWinWithFocus().
119 ** Answer the window with the logical focus
122 tuiWinWithFocus (void)
124 return _winWithFocus
;
125 } /* tuiWinWithFocus */
129 ** tuiSetWinWithFocus().
130 ** Set the window that has the logical focus
133 tuiSetWinWithFocus (TuiWinInfoPtr winInfo
)
135 _winWithFocus
= winInfo
;
138 } /* tuiSetWinWithFocus */
142 ** tuiDefaultTabLen().
143 ** Answer the length in chars, of tabs
146 tuiDefaultTabLen (void)
148 return _defaultTabLen
;
149 } /* tuiDefaultTabLen */
153 ** tuiSetDefaultTabLen().
154 ** Set the length in chars, of tabs
157 tuiSetDefaultTabLen (int len
)
159 _defaultTabLen
= len
;
162 } /* tuiSetDefaultTabLen */
166 ** currentSourceWin()
167 ** Accessor for the current source window. Usually there is only
168 ** one source window (either source or disassembly), but both can
169 ** be displayed at the same time.
174 return &_sourceWindows
;
175 } /* currentSourceWindows */
179 ** clearSourceWindows()
180 ** Clear the list of source windows. Usually there is only one
181 ** source window (either source or disassembly), but both can be
182 ** displayed at the same time.
185 clearSourceWindows (void)
187 _sourceWindows
.list
[0] = (Opaque
) NULL
;
188 _sourceWindows
.list
[1] = (Opaque
) NULL
;
189 _sourceWindows
.count
= 0;
192 } /* currentSourceWindows */
196 ** clearSourceWindowsDetail()
197 ** Clear the pertinant detail in the source windows.
200 clearSourceWindowsDetail (void)
204 for (i
= 0; i
< (sourceWindows ())->count
; i
++)
205 clearWinDetail ((TuiWinInfoPtr
) (sourceWindows ())->list
[i
]);
208 } /* currentSourceWindows */
212 ** addSourceWindowToList().
213 ** Add a window to the list of source windows. Usually there is
214 ** only one source window (either source or disassembly), but
215 ** both can be displayed at the same time.
218 addToSourceWindows (TuiWinInfoPtr winInfo
)
220 if (_sourceWindows
.count
< 2)
221 _sourceWindows
.list
[_sourceWindows
.count
++] = (Opaque
) winInfo
;
224 } /* addToSourceWindows */
229 ** Clear the pertinant detail in the windows.
232 clearWinDetail (TuiWinInfoPtr winInfo
)
234 if (m_winPtrNotNull (winInfo
))
236 switch (winInfo
->generic
.type
)
240 winInfo
->detail
.sourceInfo
.startLineOrAddr
.addr
= 0;
241 winInfo
->detail
.sourceInfo
.horizontalOffset
= 0;
244 winInfo
->detail
.commandInfo
.curLine
=
245 winInfo
->detail
.commandInfo
.curch
= 0;
248 winInfo
->detail
.dataDisplayInfo
.dataContent
=
249 (TuiWinContent
) NULL
;
250 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
251 winInfo
->detail
.dataDisplayInfo
.regsContent
=
252 (TuiWinContent
) NULL
;
253 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
254 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
256 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
257 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
265 } /* clearWinDetail */
270 ** Accessor for the blank string.
281 ** Accessor for the location string.
286 return _tuiLocationStr
;
292 ** Accessor for the break string.
302 ** breakLocationStr()
303 ** Accessor for the breakLocation string.
306 breakLocationStr (void)
308 return _tuiBreakLocationStr
;
309 } /* breakLocationStr */
314 ** Accessor for the null string.
324 ** sourceExecInfoPtr().
325 ** Accessor for the source execution info ptr.
328 sourceExecInfoWinPtr (void)
330 return &_execInfo
[0];
331 } /* sourceExecInfoWinPtr */
335 ** disassemExecInfoPtr().
336 ** Accessor for the disassem execution info ptr.
339 disassemExecInfoWinPtr (void)
341 return &_execInfo
[1];
342 } /* disassemExecInfoWinPtr */
346 ** locatorWinInfoPtr().
347 ** Accessor for the locator win info. Answers a pointer to the
348 ** static locator win info struct.
351 locatorWinInfoPtr (void)
354 } /* locatorWinInfoPtr */
359 ** Accessor for the history limit
364 return _historyLimit
;
369 ** setHistoryLimitTo().
370 ** Mutator for the history limit
373 setHistoryLimitTo (int h
)
378 } /* setHistoryLimitTo */
382 ** Accessor for the termHeight
392 ** setTermHeightTo().
393 ** Mutator for the term height
396 setTermHeightTo (int h
)
401 } /* setTermHeightTo */
406 ** Accessor for the termWidth
417 ** Mutator for the termWidth
420 setTermWidthTo (int w
)
425 } /* setTermWidthTo */
430 ** Accessor for the current layout
435 return _currentLayout
;
436 } /* currentLayout */
440 ** setCurrentLayoutTo().
441 ** Mutator for the current layout
444 setCurrentLayoutTo (TuiLayoutType newLayout
)
446 _currentLayout
= newLayout
;
449 } /* setCurrentLayoutTo */
453 ** setGenWinOrigin().
454 ** Set the origin of the window
457 setGenWinOrigin (TuiGenWinInfoPtr winInfo
, int x
, int y
)
459 winInfo
->origin
.x
= x
;
460 winInfo
->origin
.y
= y
;
463 } /* setGenWinOrigin */
466 /*****************************
467 ** OTHER PUBLIC FUNCTIONS
468 *****************************/
473 ** Answer the next window in the list, cycling back to the top
477 tuiNextWin (TuiWinInfoPtr curWin
)
479 TuiWinType type
= curWin
->generic
.type
;
480 TuiWinInfoPtr nextWin
= (TuiWinInfoPtr
) NULL
;
482 if (curWin
->generic
.type
== CMD_WIN
)
485 type
= curWin
->generic
.type
+ 1;
486 while (type
!= curWin
->generic
.type
&& m_winPtrIsNull (nextWin
))
488 if (winList
[type
] && winList
[type
]->generic
.isVisible
)
489 nextWin
= winList
[type
];
505 ** Answer the prev window in the list, cycling back to the bottom
509 tuiPrevWin (TuiWinInfoPtr curWin
)
511 TuiWinType type
= curWin
->generic
.type
;
512 TuiWinInfoPtr prev
= (TuiWinInfoPtr
) NULL
;
514 if (curWin
->generic
.type
== SRC_WIN
)
517 type
= curWin
->generic
.type
- 1;
518 while (type
!= curWin
->generic
.type
&& m_winPtrIsNull (prev
))
520 if (winList
[type
]->generic
.isVisible
)
521 prev
= winList
[type
];
536 ** displayableWinContentOf().
537 ** Answer a the content at the location indicated by index. Note
538 ** that if this is a locator window, the string returned should be
542 displayableWinContentOf (TuiGenWinInfoPtr winInfo
, TuiWinElementPtr elementPtr
)
545 char *string
= nullStr ();
547 if (elementPtr
!= (TuiWinElementPtr
) NULL
|| winInfo
->type
== LOCATOR_WIN
)
550 ** Now convert the line to a displayable string
552 switch (winInfo
->type
)
556 string
= elementPtr
->whichElement
.source
.line
;
559 string
= elementPtr
->whichElement
.command
.line
;
562 if ((string
= (char *) xmalloc (
563 (termWidth () + 1) * sizeof (char))) == (char *) NULL
)
567 char lineNo
[50], pc
[50], buf
[50], *fname
, *pname
;
568 register int strSize
= termWidth (), i
, procWidth
, fileWidth
;
571 ** First determine the amount of file/proc name width
574 i
= strSize
- (PC_WIDTH
+ LINE_WIDTH
575 + 25 /* pc and line labels */
576 + strlen (FILE_PREFIX
) + 1 /* file label */
577 + 15 /* procedure label */ );
578 if (i
>= FILE_WIDTH
+ PROC_WIDTH
)
580 fileWidth
= FILE_WIDTH
;
581 procWidth
= PROC_WIDTH
;
586 procWidth
= i
- fileWidth
;
589 /* Now convert elements to string form */
590 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
591 *elementPtr
->whichElement
.locator
.fileName
!= (char) 0 &&
592 srcWin
->generic
.isVisible
)
593 fname
= elementPtr
->whichElement
.locator
.fileName
;
596 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
597 *elementPtr
->whichElement
.locator
.procName
!= (char) 0)
598 pname
= elementPtr
->whichElement
.locator
.procName
;
601 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
602 elementPtr
->whichElement
.locator
.lineNo
> 0)
603 sprintf (lineNo
, "%d",
604 elementPtr
->whichElement
.locator
.lineNo
);
606 strcpy (lineNo
, "??");
607 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
608 elementPtr
->whichElement
.locator
.addr
!= 0)
609 sprintf (pc
, "0x%lx",
610 (long) elementPtr
->whichElement
.locator
.addr
);
614 ** Now create the locator line from the string version
615 ** of the elements. We could use sprintf() here but
616 ** that wouldn't ensure that we don't overrun the size
617 ** of the allocated buffer. strcat_to_buf() will.
621 strcat_to_buf (string
, strSize
, " ");
622 strcat_to_buf (string
, strSize
, FILE_PREFIX
);
623 if (strlen (fname
) > fileWidth
)
625 strncpy (buf
, fname
, fileWidth
- 1);
626 buf
[fileWidth
- 1] = '*';
627 buf
[fileWidth
] = (char) 0;
631 strcat_to_buf (string
, strSize
, buf
);
632 /* procedure/class name */
633 sprintf (buf
, "%15s", PROC_PREFIX
);
634 strcat_to_buf (string
, strSize
, buf
);
635 if (strlen (pname
) > procWidth
)
637 strncpy (buf
, pname
, procWidth
- 1);
638 buf
[procWidth
- 1] = '*';
639 buf
[procWidth
] = (char) 0;
643 strcat_to_buf (string
, strSize
, buf
);
644 sprintf (buf
, "%10s", LINE_PREFIX
);
645 strcat_to_buf (string
, strSize
, buf
);
646 strcat_to_buf (string
, strSize
, lineNo
);
647 sprintf (buf
, "%10s", PC_PREFIX
);
648 strcat_to_buf (string
, strSize
, buf
);
649 strcat_to_buf (string
, strSize
, pc
);
650 for (i
= strlen (string
); i
< strSize
; i
++)
652 string
[strSize
] = (char) 0;
656 string
= elementPtr
->whichElement
.simpleString
;
663 } /* displayableWinContentOf */
668 ** Answer a the content at the location indicated by index
671 displayableWinContentAt (TuiGenWinInfoPtr winInfo
, int index
)
673 return (displayableWinContentOf (winInfo
, (TuiWinElementPtr
) winInfo
->content
[index
]));
678 ** winElementHeight().
679 ** Answer the height of the element in lines
682 winElementHeight (TuiGenWinInfoPtr winInfo
, TuiWinElementPtr element
)
686 if (winInfo
->type
== DATA_WIN
)
687 /* FOR NOW SAY IT IS ONLY ONE LINE HIGH */
693 } /* winElementHeight */
698 ** Answer the window represented by name
701 winByName (char *name
)
703 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
706 while (i
< MAX_MAJOR_WINDOWS
&& m_winPtrIsNull (winInfo
))
708 if (strcmp (name
, winName (&(winList
[i
]->generic
))) == 0)
709 winInfo
= winList
[i
];
718 ** partialWinByName().
719 ** Answer the window represented by name
722 partialWinByName (char *name
)
724 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
726 if (name
!= (char *) NULL
)
730 while (i
< MAX_MAJOR_WINDOWS
&& m_winPtrIsNull (winInfo
))
734 char *curName
= winName (&winList
[i
]->generic
);
735 if (strlen (name
) <= strlen (curName
) &&
736 strncmp (name
, curName
, strlen (name
)) == 0)
737 winInfo
= winList
[i
];
744 } /* partialWinByName */
749 ** Answer the name of the window
752 winName (TuiGenWinInfoPtr winInfo
)
754 char *name
= (char *) NULL
;
756 switch (winInfo
->type
)
765 name
= DISASSEM_NAME
;
780 ** initializeStaticData
783 initializeStaticData (void)
785 initGenericPart (sourceExecInfoWinPtr ());
786 initGenericPart (disassemExecInfoWinPtr ());
787 initGenericPart (locatorWinInfoPtr ());
790 } /* initializeStaticData */
794 ** allocGenericWinInfo().
797 allocGenericWinInfo (void)
799 TuiGenWinInfoPtr win
;
801 if ((win
= (TuiGenWinInfoPtr
) xmalloc (
802 sizeof (TuiGenWinInfoPtr
))) != (TuiGenWinInfoPtr
) NULL
)
803 initGenericPart (win
);
806 } /* allocGenericWinInfo */
810 ** initGenericPart().
813 initGenericPart (TuiGenWinInfoPtr win
)
819 win
->viewportHeight
=
821 win
->lastVisibleLine
= 0;
822 win
->handle
= (WINDOW
*) NULL
;
823 win
->content
= (OpaquePtr
) NULL
;
825 win
->isVisible
= FALSE
;
828 } /* initGenericPart */
832 ** initContentElement().
835 initContentElement (TuiWinElementPtr element
, TuiWinType type
)
837 element
->highlight
= FALSE
;
842 element
->whichElement
.source
.line
= (char *) NULL
;
843 element
->whichElement
.source
.lineOrAddr
.lineNo
= 0;
844 element
->whichElement
.source
.isExecPoint
= FALSE
;
845 element
->whichElement
.source
.hasBreak
= FALSE
;
848 initGenericPart (&element
->whichElement
.dataWindow
);
849 element
->whichElement
.dataWindow
.type
= DATA_ITEM_WIN
;
850 ((TuiGenWinInfoPtr
) & element
->whichElement
.dataWindow
)->content
=
851 (OpaquePtr
) allocContent (1, DATA_ITEM_WIN
);
853 & element
->whichElement
.dataWindow
)->contentSize
= 1;
856 element
->whichElement
.command
.line
= (char *) NULL
;
859 element
->whichElement
.data
.name
= (char *) NULL
;
860 element
->whichElement
.data
.type
= TUI_REGISTER
;
861 element
->whichElement
.data
.itemNo
= UNDEFINED_ITEM
;
862 element
->whichElement
.data
.value
= (Opaque
) NULL
;
863 element
->whichElement
.data
.highlight
= FALSE
;
866 element
->whichElement
.locator
.fileName
[0] =
867 element
->whichElement
.locator
.procName
[0] = (char) 0;
868 element
->whichElement
.locator
.lineNo
= 0;
869 element
->whichElement
.locator
.addr
= 0;
872 element
->whichElement
.simpleString
= blankStr ();
878 } /* initContentElement */
884 initWinInfo (TuiWinInfoPtr winInfo
)
886 initGenericPart (&winInfo
->generic
);
887 winInfo
->canHighlight
=
888 winInfo
->isHighlighted
= FALSE
;
889 switch (winInfo
->generic
.type
)
893 winInfo
->detail
.sourceInfo
.executionInfo
= (TuiGenWinInfoPtr
) NULL
;
894 winInfo
->detail
.sourceInfo
.hasLocator
= FALSE
;
895 winInfo
->detail
.sourceInfo
.horizontalOffset
= 0;
896 winInfo
->detail
.sourceInfo
.startLineOrAddr
.addr
= 0;
899 winInfo
->detail
.dataDisplayInfo
.dataContent
= (TuiWinContent
) NULL
;
900 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
901 winInfo
->detail
.dataDisplayInfo
.regsContent
= (TuiWinContent
) NULL
;
902 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
903 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
905 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
906 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
909 winInfo
->detail
.commandInfo
.curLine
= 0;
910 winInfo
->detail
.commandInfo
.curch
= 0;
913 winInfo
->detail
.opaque
= (Opaque
) NULL
;
925 allocWinInfo (TuiWinType type
)
927 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
929 winInfo
= (TuiWinInfoPtr
) xmalloc (sizeof (TuiWinInfo
));
930 if (m_winPtrNotNull (winInfo
))
932 winInfo
->generic
.type
= type
;
933 initWinInfo (winInfo
);
942 ** Allocates the content and elements in a block.
945 allocContent (int numElements
, TuiWinType type
)
947 TuiWinContent content
= (TuiWinContent
) NULL
;
948 char *elementBlockPtr
= (char *) NULL
;
951 if ((content
= (TuiWinContent
)
952 xmalloc (sizeof (TuiWinElementPtr
) * numElements
)) != (TuiWinContent
) NULL
)
954 ** All windows, except the data window, can allocate the elements
955 ** in a chunk. The data window cannot because items can be
956 ** added/removed from the data display by the user at any time.
958 if (type
!= DATA_WIN
)
960 if ((elementBlockPtr
= (char *)
961 xmalloc (sizeof (TuiWinElement
) * numElements
)) != (char *) NULL
)
963 for (i
= 0; i
< numElements
; i
++)
965 content
[i
] = (TuiWinElementPtr
) elementBlockPtr
;
966 initContentElement (content
[i
], type
);
967 elementBlockPtr
+= sizeof (TuiWinElement
);
972 tuiFree ((char *) content
);
973 content
= (TuiWinContent
) NULL
;
983 ** addContentElements().
984 ** Adds the input number of elements to the windows's content. If
985 ** no content has been allocated yet, allocContent() is called to
986 ** do this. The index of the first element added is returned,
987 ** unless there is a memory allocation error, in which case, (-1)
991 addContentElements (TuiGenWinInfoPtr winInfo
, int numElements
)
993 TuiWinElementPtr elementPtr
;
996 if (winInfo
->content
== (OpaquePtr
) NULL
)
998 winInfo
->content
= (OpaquePtr
) allocContent (numElements
, winInfo
->type
);
1002 indexStart
= winInfo
->contentSize
;
1003 if (winInfo
->content
!= (OpaquePtr
) NULL
)
1005 for (i
= indexStart
; (i
< numElements
+ indexStart
); i
++)
1007 if ((elementPtr
= (TuiWinElementPtr
)
1008 xmalloc (sizeof (TuiWinElement
))) != (TuiWinElementPtr
) NULL
)
1010 winInfo
->content
[i
] = (Opaque
) elementPtr
;
1011 initContentElement (elementPtr
, winInfo
->type
);
1012 winInfo
->contentSize
++;
1014 else /* things must be really hosed now! We ran out of memory!? */
1020 } /* addContentElements */
1025 ** Delete all curses windows associated with winInfo, leaving everything
1029 tuiDelWindow (TuiWinInfoPtr winInfo
)
1033 TuiGenWinInfoPtr genericWin
;
1036 switch (winInfo
->generic
.type
)
1040 genericWin
= locatorWinInfoPtr ();
1041 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1043 tuiDelwin (genericWin
->handle
);
1044 genericWin
->handle
= (WINDOW
*) NULL
;
1045 genericWin
->isVisible
= FALSE
;
1047 genericWin
= winInfo
->detail
.sourceInfo
.executionInfo
;
1048 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1050 tuiDelwin (genericWin
->handle
);
1051 genericWin
->handle
= (WINDOW
*) NULL
;
1052 genericWin
->isVisible
= FALSE
;
1056 if (winInfo
->generic
.content
!= (OpaquePtr
) NULL
)
1061 winInfo
->detail
.dataDisplayInfo
.regsContent
,
1062 winInfo
->detail
.dataDisplayInfo
.regsContentCount
);
1064 winInfo
->detail
.dataDisplayInfo
.dataContent
,
1065 winInfo
->detail
.dataDisplayInfo
.dataContentCount
);
1071 if (winInfo
->generic
.handle
!= (WINDOW
*) NULL
)
1073 tuiDelwin (winInfo
->generic
.handle
);
1074 winInfo
->generic
.handle
= (WINDOW
*) NULL
;
1075 winInfo
->generic
.isVisible
= FALSE
;
1079 } /* tuiDelWindow */
1086 freeWindow (TuiWinInfoPtr winInfo
)
1090 TuiGenWinInfoPtr genericWin
;
1093 switch (winInfo
->generic
.type
)
1097 genericWin
= locatorWinInfoPtr ();
1098 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1100 tuiDelwin (genericWin
->handle
);
1101 genericWin
->handle
= (WINDOW
*) NULL
;
1103 freeWinContent (genericWin
);
1104 genericWin
= winInfo
->detail
.sourceInfo
.executionInfo
;
1105 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1107 tuiDelwin (genericWin
->handle
);
1108 genericWin
->handle
= (WINDOW
*) NULL
;
1109 freeWinContent (genericWin
);
1113 if (winInfo
->generic
.content
!= (OpaquePtr
) NULL
)
1116 winInfo
->detail
.dataDisplayInfo
.regsContent
,
1117 winInfo
->detail
.dataDisplayInfo
.regsContentCount
);
1118 winInfo
->detail
.dataDisplayInfo
.regsContent
=
1119 (TuiWinContent
) NULL
;
1120 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
1122 winInfo
->detail
.dataDisplayInfo
.dataContent
,
1123 winInfo
->detail
.dataDisplayInfo
.dataContentCount
);
1124 winInfo
->detail
.dataDisplayInfo
.dataContent
=
1125 (TuiWinContent
) NULL
;
1126 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
1127 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
1129 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
1130 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
1131 winInfo
->generic
.content
= (OpaquePtr
) NULL
;
1132 winInfo
->generic
.contentSize
= 0;
1138 if (winInfo
->generic
.handle
!= (WINDOW
*) NULL
)
1140 tuiDelwin (winInfo
->generic
.handle
);
1141 winInfo
->generic
.handle
= (WINDOW
*) NULL
;
1142 freeWinContent (&winInfo
->generic
);
1151 ** freeAllSourceWinsContent().
1154 freeAllSourceWinsContent (void)
1158 for (i
= 0; i
< (sourceWindows ())->count
; i
++)
1160 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) (sourceWindows ())->list
[i
];
1162 if (m_winPtrNotNull (winInfo
))
1164 freeWinContent (&(winInfo
->generic
));
1165 freeWinContent (winInfo
->detail
.sourceInfo
.executionInfo
);
1170 } /* freeAllSourceWinsContent */
1174 ** freeWinContent().
1177 freeWinContent (TuiGenWinInfoPtr winInfo
)
1179 if (winInfo
->content
!= (OpaquePtr
) NULL
)
1181 freeContent ((TuiWinContent
) winInfo
->content
,
1182 winInfo
->contentSize
,
1184 winInfo
->content
= (OpaquePtr
) NULL
;
1186 winInfo
->contentSize
= 0;
1189 } /* freeWinContent */
1193 ** freeAllWindows().
1196 freeAllWindows (void)
1198 TuiWinType type
= SRC_WIN
;
1200 for (; type
< MAX_MAJOR_WINDOWS
; type
++)
1201 if (m_winPtrNotNull (winList
[type
]) &&
1202 winList
[type
]->generic
.type
!= UNDEFINED_WIN
)
1203 freeWindow (winList
[type
]);
1205 } /* freeAllWindows */
1209 tuiDelDataWindows (TuiWinContent content
, int contentSize
)
1214 ** Remember that data window content elements are of type TuiGenWinInfoPtr,
1215 ** each of which whose single element is a data element.
1217 for (i
= 0; i
< contentSize
; i
++)
1219 TuiGenWinInfoPtr genericWin
= &content
[i
]->whichElement
.dataWindow
;
1221 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1223 tuiDelwin (genericWin
->handle
);
1224 genericWin
->handle
= (WINDOW
*) NULL
;
1225 genericWin
->isVisible
= FALSE
;
1230 } /* tuiDelDataWindows */
1234 freeDataContent (TuiWinContent content
, int contentSize
)
1239 ** Remember that data window content elements are of type TuiGenWinInfoPtr,
1240 ** each of which whose single element is a data element.
1242 for (i
= 0; i
< contentSize
; i
++)
1244 TuiGenWinInfoPtr genericWin
= &content
[i
]->whichElement
.dataWindow
;
1246 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1248 tuiDelwin (genericWin
->handle
);
1249 genericWin
->handle
= (WINDOW
*) NULL
;
1250 freeWinContent (genericWin
);
1253 freeContent (content
,
1258 } /* freeDataContent */
1261 /**********************************
1262 ** LOCAL STATIC FUNCTIONS **
1263 **********************************/
1270 freeContent (TuiWinContent content
, int contentSize
, TuiWinType winType
)
1272 if (content
!= (TuiWinContent
) NULL
)
1274 freeContentElements (content
, contentSize
, winType
);
1275 tuiFree ((char *) content
);
1283 ** freeContentElements().
1286 freeContentElements (TuiWinContent content
, int contentSize
, TuiWinType type
)
1288 if (content
!= (TuiWinContent
) NULL
)
1292 if (type
== SRC_WIN
|| type
== DISASSEM_WIN
)
1294 /* free whole source block */
1295 if (content
[0]->whichElement
.source
.line
!= (char *) NULL
)
1296 tuiFree (content
[0]->whichElement
.source
.line
);
1300 for (i
= 0; i
< contentSize
; i
++)
1302 TuiWinElementPtr element
;
1304 element
= content
[i
];
1305 if (element
!= (TuiWinElementPtr
) NULL
)
1310 tuiFree ((char *) element
);
1314 ** Note that data elements are not allocated
1315 ** in a single block, but individually, as needed.
1317 if (element
->whichElement
.data
.type
!= TUI_REGISTER
)
1319 element
->whichElement
.data
.name
);
1320 tuiFree ((char *) element
->whichElement
.data
.value
);
1321 tuiFree ((char *) element
);
1324 tuiFree ((char *) element
->whichElement
.command
.line
);
1332 if (type
!= DATA_WIN
&& type
!= DATA_ITEM_WIN
)
1333 tuiFree ((char *) content
[0]); /* free the element block */
1337 } /* freeContentElements */