1 /* TUI data manipulation routines.
3 Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation,
6 Contributed by Hewlett-Packard Company.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
25 /* FIXME: cagney/2002-02-28: The GDB coding standard indicates that
26 "defs.h" should be included first. Unfortunatly some systems
27 (currently Debian GNU/Linux) include the <stdbool.h> via <curses.h>
28 and they clash with "bfd.h"'s definiton of true/false. The correct
29 fix is to remove true/false from "bfd.h", however, until that
30 happens, hack around it by including "config.h" and <curses.h>
45 #include "tuiGeneralWin.h"
47 /****************************
48 ** GLOBAL DECLARATIONS
49 ****************************/
50 TuiWinInfoPtr winList
[MAX_MAJOR_WINDOWS
];
52 /***************************
53 ** Private Definitions
54 ****************************/
60 /***************************
62 ****************************/
63 static char *_tuiNullStr
= TUI_NULL_STR
;
64 static char *_tuiBlankStr
= " ";
65 static char *_tuiLocationStr
= " >";
66 static char *_tuiBreakStr
= " * ";
67 static char *_tuiBreakLocationStr
= " *>";
68 static TuiLayoutType _currentLayout
= UNDEFINED_LAYOUT
;
69 static int _termHeight
, _termWidth
;
70 static int _historyLimit
= DEFAULT_HISTORY_COUNT
;
71 static TuiGenWinInfo _locator
;
72 static TuiGenWinInfo _execInfo
[2];
73 static TuiWinInfoPtr _srcWinList
[2];
74 static TuiList _sourceWindows
=
75 {(OpaqueList
) _srcWinList
, 0};
76 static int _defaultTabLen
= DEFAULT_TAB_LEN
;
77 static TuiWinInfoPtr _winWithFocus
= (TuiWinInfoPtr
) NULL
;
78 static TuiLayoutDef _layoutDef
=
79 {SRC_WIN
, /* displayMode */
81 TUI_UNDEFINED_REGS
, /* regsDisplayType */
82 TUI_SFLOAT_REGS
}; /* floatRegsDisplayType */
83 static int _winResized
= FALSE
;
86 /*********************************
87 ** Static function forward decls
88 **********************************/
89 static void freeContent (TuiWinContent
, int, TuiWinType
);
90 static void freeContentElements (TuiWinContent
, int, TuiWinType
);
94 /*********************************
96 **********************************/
98 /******************************************
99 ** ACCESSORS & MUTATORS FOR PRIVATE DATA
100 ******************************************/
104 ** Answer a whether the terminal window has been resized or not
110 } /* tuiWinResized */
114 ** tuiSetWinResized().
115 ** Set a whether the terminal window has been resized or not
118 tuiSetWinResizedTo (int resized
)
120 _winResized
= resized
;
123 } /* tuiSetWinResizedTo */
128 ** Answer a pointer to the current layout definition
138 ** tuiWinWithFocus().
139 ** Answer the window with the logical focus
142 tuiWinWithFocus (void)
144 return _winWithFocus
;
145 } /* tuiWinWithFocus */
149 ** tuiSetWinWithFocus().
150 ** Set the window that has the logical focus
153 tuiSetWinWithFocus (TuiWinInfoPtr winInfo
)
155 _winWithFocus
= winInfo
;
158 } /* tuiSetWinWithFocus */
162 ** tuiDefaultTabLen().
163 ** Answer the length in chars, of tabs
166 tuiDefaultTabLen (void)
168 return _defaultTabLen
;
169 } /* tuiDefaultTabLen */
173 ** tuiSetDefaultTabLen().
174 ** Set the length in chars, of tabs
177 tuiSetDefaultTabLen (int len
)
179 _defaultTabLen
= len
;
182 } /* tuiSetDefaultTabLen */
186 ** currentSourceWin()
187 ** Accessor for the current source window. Usually there is only
188 ** one source window (either source or disassembly), but both can
189 ** be displayed at the same time.
194 return &_sourceWindows
;
195 } /* currentSourceWindows */
199 ** clearSourceWindows()
200 ** Clear the list of source windows. Usually there is only one
201 ** source window (either source or disassembly), but both can be
202 ** displayed at the same time.
205 clearSourceWindows (void)
207 _sourceWindows
.list
[0] = (Opaque
) NULL
;
208 _sourceWindows
.list
[1] = (Opaque
) NULL
;
209 _sourceWindows
.count
= 0;
212 } /* currentSourceWindows */
216 ** clearSourceWindowsDetail()
217 ** Clear the pertinant detail in the source windows.
220 clearSourceWindowsDetail (void)
224 for (i
= 0; i
< (sourceWindows ())->count
; i
++)
225 clearWinDetail ((TuiWinInfoPtr
) (sourceWindows ())->list
[i
]);
228 } /* currentSourceWindows */
232 ** addSourceWindowToList().
233 ** Add a window to the list of source windows. Usually there is
234 ** only one source window (either source or disassembly), but
235 ** both can be displayed at the same time.
238 addToSourceWindows (TuiWinInfoPtr winInfo
)
240 if (_sourceWindows
.count
< 2)
241 _sourceWindows
.list
[_sourceWindows
.count
++] = (Opaque
) winInfo
;
244 } /* addToSourceWindows */
249 ** Clear the pertinant detail in the windows.
252 clearWinDetail (TuiWinInfoPtr winInfo
)
254 if (m_winPtrNotNull (winInfo
))
256 switch (winInfo
->generic
.type
)
260 winInfo
->detail
.sourceInfo
.startLineOrAddr
.addr
= 0;
261 winInfo
->detail
.sourceInfo
.horizontalOffset
= 0;
264 winInfo
->detail
.commandInfo
.curLine
=
265 winInfo
->detail
.commandInfo
.curch
= 0;
268 winInfo
->detail
.dataDisplayInfo
.dataContent
=
269 (TuiWinContent
) NULL
;
270 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
271 winInfo
->detail
.dataDisplayInfo
.regsContent
=
272 (TuiWinContent
) NULL
;
273 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
274 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
276 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
277 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
285 } /* clearWinDetail */
290 ** Accessor for the blank string.
301 ** Accessor for the location string.
306 return _tuiLocationStr
;
312 ** Accessor for the break string.
322 ** breakLocationStr()
323 ** Accessor for the breakLocation string.
326 breakLocationStr (void)
328 return _tuiBreakLocationStr
;
329 } /* breakLocationStr */
334 ** Accessor for the null string.
344 ** sourceExecInfoPtr().
345 ** Accessor for the source execution info ptr.
348 sourceExecInfoWinPtr (void)
350 return &_execInfo
[0];
351 } /* sourceExecInfoWinPtr */
355 ** disassemExecInfoPtr().
356 ** Accessor for the disassem execution info ptr.
359 disassemExecInfoWinPtr (void)
361 return &_execInfo
[1];
362 } /* disassemExecInfoWinPtr */
366 ** locatorWinInfoPtr().
367 ** Accessor for the locator win info. Answers a pointer to the
368 ** static locator win info struct.
371 locatorWinInfoPtr (void)
374 } /* locatorWinInfoPtr */
379 ** Accessor for the history limit
384 return _historyLimit
;
389 ** setHistoryLimitTo().
390 ** Mutator for the history limit
393 setHistoryLimitTo (int h
)
398 } /* setHistoryLimitTo */
402 ** Accessor for the termHeight
412 ** setTermHeightTo().
413 ** Mutator for the term height
416 setTermHeightTo (int h
)
421 } /* setTermHeightTo */
426 ** Accessor for the termWidth
437 ** Mutator for the termWidth
440 setTermWidthTo (int w
)
445 } /* setTermWidthTo */
450 ** Accessor for the current layout
455 return _currentLayout
;
456 } /* currentLayout */
460 ** setCurrentLayoutTo().
461 ** Mutator for the current layout
464 setCurrentLayoutTo (TuiLayoutType newLayout
)
466 _currentLayout
= newLayout
;
469 } /* setCurrentLayoutTo */
473 ** setGenWinOrigin().
474 ** Set the origin of the window
477 setGenWinOrigin (TuiGenWinInfoPtr winInfo
, int x
, int y
)
479 winInfo
->origin
.x
= x
;
480 winInfo
->origin
.y
= y
;
483 } /* setGenWinOrigin */
486 /*****************************
487 ** OTHER PUBLIC FUNCTIONS
488 *****************************/
493 ** Answer the next window in the list, cycling back to the top
497 tuiNextWin (TuiWinInfoPtr curWin
)
499 TuiWinType type
= curWin
->generic
.type
;
500 TuiWinInfoPtr nextWin
= (TuiWinInfoPtr
) NULL
;
502 if (curWin
->generic
.type
== CMD_WIN
)
505 type
= curWin
->generic
.type
+ 1;
506 while (type
!= curWin
->generic
.type
&& m_winPtrIsNull (nextWin
))
508 if (winList
[type
] && winList
[type
]->generic
.isVisible
)
509 nextWin
= winList
[type
];
525 ** Answer the prev window in the list, cycling back to the bottom
529 tuiPrevWin (TuiWinInfoPtr curWin
)
531 TuiWinType type
= curWin
->generic
.type
;
532 TuiWinInfoPtr prev
= (TuiWinInfoPtr
) NULL
;
534 if (curWin
->generic
.type
== SRC_WIN
)
537 type
= curWin
->generic
.type
- 1;
538 while (type
!= curWin
->generic
.type
&& m_winPtrIsNull (prev
))
540 if (winList
[type
]->generic
.isVisible
)
541 prev
= winList
[type
];
556 ** displayableWinContentOf().
557 ** Answer a the content at the location indicated by index. Note
558 ** that if this is a locator window, the string returned should be
562 displayableWinContentOf (TuiGenWinInfoPtr winInfo
, TuiWinElementPtr elementPtr
)
565 char *string
= nullStr ();
567 if (elementPtr
!= (TuiWinElementPtr
) NULL
|| winInfo
->type
== LOCATOR_WIN
)
570 ** Now convert the line to a displayable string
572 switch (winInfo
->type
)
576 string
= elementPtr
->whichElement
.source
.line
;
579 string
= elementPtr
->whichElement
.command
.line
;
582 if ((string
= (char *) xmalloc (
583 (termWidth () + 1) * sizeof (char))) == (char *) NULL
)
587 char lineNo
[50], pc
[50], buf
[50], *fname
, *pname
;
588 register int strSize
= termWidth (), i
, procWidth
, fileWidth
;
591 ** First determine the amount of file/proc name width
594 i
= strSize
- (PC_WIDTH
+ LINE_WIDTH
595 + 25 /* pc and line labels */
596 + strlen (FILE_PREFIX
) + 1 /* file label */
597 + 15 /* procedure label */ );
598 if (i
>= FILE_WIDTH
+ PROC_WIDTH
)
600 fileWidth
= FILE_WIDTH
;
601 procWidth
= PROC_WIDTH
;
606 procWidth
= i
- fileWidth
;
609 /* Now convert elements to string form */
610 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
611 *elementPtr
->whichElement
.locator
.fileName
!= (char) 0 &&
612 srcWin
->generic
.isVisible
)
613 fname
= elementPtr
->whichElement
.locator
.fileName
;
616 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
617 *elementPtr
->whichElement
.locator
.procName
!= (char) 0)
618 pname
= elementPtr
->whichElement
.locator
.procName
;
621 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
622 elementPtr
->whichElement
.locator
.lineNo
> 0)
623 sprintf (lineNo
, "%d",
624 elementPtr
->whichElement
.locator
.lineNo
);
626 strcpy (lineNo
, "??");
627 if (elementPtr
!= (TuiWinElementPtr
) NULL
&&
628 elementPtr
->whichElement
.locator
.addr
!= 0)
629 sprintf (pc
, "0x%lx",
630 (long) elementPtr
->whichElement
.locator
.addr
);
634 ** Now create the locator line from the string version
635 ** of the elements. We could use sprintf() here but
636 ** that wouldn't ensure that we don't overrun the size
637 ** of the allocated buffer. strcat_to_buf() will.
641 strcat_to_buf (string
, strSize
, " ");
642 strcat_to_buf (string
, strSize
, FILE_PREFIX
);
643 if (strlen (fname
) > fileWidth
)
645 strncpy (buf
, fname
, fileWidth
- 1);
646 buf
[fileWidth
- 1] = '*';
647 buf
[fileWidth
] = (char) 0;
651 strcat_to_buf (string
, strSize
, buf
);
652 /* procedure/class name */
653 sprintf (buf
, "%15s", PROC_PREFIX
);
654 strcat_to_buf (string
, strSize
, buf
);
655 if (strlen (pname
) > procWidth
)
657 strncpy (buf
, pname
, procWidth
- 1);
658 buf
[procWidth
- 1] = '*';
659 buf
[procWidth
] = (char) 0;
663 strcat_to_buf (string
, strSize
, buf
);
664 sprintf (buf
, "%10s", LINE_PREFIX
);
665 strcat_to_buf (string
, strSize
, buf
);
666 strcat_to_buf (string
, strSize
, lineNo
);
667 sprintf (buf
, "%10s", PC_PREFIX
);
668 strcat_to_buf (string
, strSize
, buf
);
669 strcat_to_buf (string
, strSize
, pc
);
670 for (i
= strlen (string
); i
< strSize
; i
++)
672 string
[strSize
] = (char) 0;
676 string
= elementPtr
->whichElement
.simpleString
;
683 } /* displayableWinContentOf */
688 ** Answer a the content at the location indicated by index
691 displayableWinContentAt (TuiGenWinInfoPtr winInfo
, int index
)
693 return (displayableWinContentOf (winInfo
, (TuiWinElementPtr
) winInfo
->content
[index
]));
698 ** winElementHeight().
699 ** Answer the height of the element in lines
702 winElementHeight (TuiGenWinInfoPtr winInfo
, TuiWinElementPtr element
)
706 if (winInfo
->type
== DATA_WIN
)
707 /* FOR NOW SAY IT IS ONLY ONE LINE HIGH */
713 } /* winElementHeight */
718 ** Answer the window represented by name
721 winByName (char *name
)
723 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
726 while (i
< MAX_MAJOR_WINDOWS
&& m_winPtrIsNull (winInfo
))
728 if (strcmp (name
, winName (&(winList
[i
]->generic
))) == 0)
729 winInfo
= winList
[i
];
738 ** partialWinByName().
739 ** Answer the window represented by name
742 partialWinByName (char *name
)
744 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
746 if (name
!= (char *) NULL
)
750 while (i
< MAX_MAJOR_WINDOWS
&& m_winPtrIsNull (winInfo
))
754 char *curName
= winName (&winList
[i
]->generic
);
755 if (strlen (name
) <= strlen (curName
) &&
756 strncmp (name
, curName
, strlen (name
)) == 0)
757 winInfo
= winList
[i
];
764 } /* partialWinByName */
769 ** Answer the name of the window
772 winName (TuiGenWinInfoPtr winInfo
)
774 char *name
= (char *) NULL
;
776 switch (winInfo
->type
)
785 name
= DISASSEM_NAME
;
800 ** initializeStaticData
803 initializeStaticData (void)
805 initGenericPart (sourceExecInfoWinPtr ());
806 initGenericPart (disassemExecInfoWinPtr ());
807 initGenericPart (locatorWinInfoPtr ());
810 } /* initializeStaticData */
814 ** allocGenericWinInfo().
817 allocGenericWinInfo (void)
819 TuiGenWinInfoPtr win
;
821 if ((win
= (TuiGenWinInfoPtr
) xmalloc (
822 sizeof (TuiGenWinInfoPtr
))) != (TuiGenWinInfoPtr
) NULL
)
823 initGenericPart (win
);
826 } /* allocGenericWinInfo */
830 ** initGenericPart().
833 initGenericPart (TuiGenWinInfoPtr win
)
839 win
->viewportHeight
=
841 win
->lastVisibleLine
= 0;
842 win
->handle
= (WINDOW
*) NULL
;
843 win
->content
= (OpaquePtr
) NULL
;
845 win
->isVisible
= FALSE
;
851 ** initContentElement().
854 initContentElement (TuiWinElementPtr element
, TuiWinType type
)
856 element
->highlight
= FALSE
;
861 element
->whichElement
.source
.line
= (char *) NULL
;
862 element
->whichElement
.source
.lineOrAddr
.lineNo
= 0;
863 element
->whichElement
.source
.isExecPoint
= FALSE
;
864 element
->whichElement
.source
.hasBreak
= FALSE
;
867 initGenericPart (&element
->whichElement
.dataWindow
);
868 element
->whichElement
.dataWindow
.type
= DATA_ITEM_WIN
;
869 ((TuiGenWinInfoPtr
) & element
->whichElement
.dataWindow
)->content
=
870 (OpaquePtr
) allocContent (1, DATA_ITEM_WIN
);
872 & element
->whichElement
.dataWindow
)->contentSize
= 1;
875 element
->whichElement
.command
.line
= (char *) NULL
;
878 element
->whichElement
.data
.name
= (char *) NULL
;
879 element
->whichElement
.data
.type
= TUI_REGISTER
;
880 element
->whichElement
.data
.itemNo
= UNDEFINED_ITEM
;
881 element
->whichElement
.data
.value
= (Opaque
) NULL
;
882 element
->whichElement
.data
.highlight
= FALSE
;
885 element
->whichElement
.locator
.fileName
[0] =
886 element
->whichElement
.locator
.procName
[0] = (char) 0;
887 element
->whichElement
.locator
.lineNo
= 0;
888 element
->whichElement
.locator
.addr
= 0;
891 memset(element
->whichElement
.simpleString
, ' ',
892 sizeof(element
->whichElement
.simpleString
));
898 } /* initContentElement */
904 initWinInfo (TuiWinInfoPtr winInfo
)
906 initGenericPart (&winInfo
->generic
);
907 winInfo
->canHighlight
=
908 winInfo
->isHighlighted
= FALSE
;
909 switch (winInfo
->generic
.type
)
913 winInfo
->detail
.sourceInfo
.executionInfo
= (TuiGenWinInfoPtr
) NULL
;
914 winInfo
->detail
.sourceInfo
.hasLocator
= FALSE
;
915 winInfo
->detail
.sourceInfo
.horizontalOffset
= 0;
916 winInfo
->detail
.sourceInfo
.startLineOrAddr
.addr
= 0;
917 winInfo
->detail
.sourceInfo
.filename
= 0;
920 winInfo
->detail
.dataDisplayInfo
.dataContent
= (TuiWinContent
) NULL
;
921 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
922 winInfo
->detail
.dataDisplayInfo
.regsContent
= (TuiWinContent
) NULL
;
923 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
924 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
926 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
927 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
930 winInfo
->detail
.commandInfo
.curLine
= 0;
931 winInfo
->detail
.commandInfo
.curch
= 0;
934 winInfo
->detail
.opaque
= (Opaque
) NULL
;
946 allocWinInfo (TuiWinType type
)
948 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) NULL
;
950 winInfo
= (TuiWinInfoPtr
) xmalloc (sizeof (TuiWinInfo
));
951 if (m_winPtrNotNull (winInfo
))
953 winInfo
->generic
.type
= type
;
954 initWinInfo (winInfo
);
963 ** Allocates the content and elements in a block.
966 allocContent (int numElements
, TuiWinType type
)
968 TuiWinContent content
= (TuiWinContent
) NULL
;
969 char *elementBlockPtr
= (char *) NULL
;
972 if ((content
= (TuiWinContent
)
973 xmalloc (sizeof (TuiWinElementPtr
) * numElements
)) != (TuiWinContent
) NULL
)
975 ** All windows, except the data window, can allocate the elements
976 ** in a chunk. The data window cannot because items can be
977 ** added/removed from the data display by the user at any time.
979 if (type
!= DATA_WIN
)
981 if ((elementBlockPtr
= (char *)
982 xmalloc (sizeof (TuiWinElement
) * numElements
)) != (char *) NULL
)
984 for (i
= 0; i
< numElements
; i
++)
986 content
[i
] = (TuiWinElementPtr
) elementBlockPtr
;
987 initContentElement (content
[i
], type
);
988 elementBlockPtr
+= sizeof (TuiWinElement
);
993 tuiFree ((char *) content
);
994 content
= (TuiWinContent
) NULL
;
1000 } /* allocContent */
1004 ** addContentElements().
1005 ** Adds the input number of elements to the windows's content. If
1006 ** no content has been allocated yet, allocContent() is called to
1007 ** do this. The index of the first element added is returned,
1008 ** unless there is a memory allocation error, in which case, (-1)
1012 addContentElements (TuiGenWinInfoPtr winInfo
, int numElements
)
1014 TuiWinElementPtr elementPtr
;
1017 if (winInfo
->content
== (OpaquePtr
) NULL
)
1019 winInfo
->content
= (OpaquePtr
) allocContent (numElements
, winInfo
->type
);
1023 indexStart
= winInfo
->contentSize
;
1024 if (winInfo
->content
!= (OpaquePtr
) NULL
)
1026 for (i
= indexStart
; (i
< numElements
+ indexStart
); i
++)
1028 if ((elementPtr
= (TuiWinElementPtr
)
1029 xmalloc (sizeof (TuiWinElement
))) != (TuiWinElementPtr
) NULL
)
1031 winInfo
->content
[i
] = (Opaque
) elementPtr
;
1032 initContentElement (elementPtr
, winInfo
->type
);
1033 winInfo
->contentSize
++;
1035 else /* things must be really hosed now! We ran out of memory!? */
1041 } /* addContentElements */
1044 /* Delete all curses windows associated with winInfo, leaving everything
1047 tuiDelWindow (TuiWinInfoPtr winInfo
)
1049 TuiGenWinInfoPtr genericWin
;
1051 switch (winInfo
->generic
.type
)
1055 genericWin
= locatorWinInfoPtr ();
1056 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1058 tuiDelwin (genericWin
->handle
);
1059 genericWin
->handle
= (WINDOW
*) NULL
;
1060 genericWin
->isVisible
= FALSE
;
1062 if (winInfo
->detail
.sourceInfo
.filename
)
1064 xfree (winInfo
->detail
.sourceInfo
.filename
);
1065 winInfo
->detail
.sourceInfo
.filename
= 0;
1067 genericWin
= winInfo
->detail
.sourceInfo
.executionInfo
;
1068 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1070 tuiDelwin (genericWin
->handle
);
1071 genericWin
->handle
= (WINDOW
*) NULL
;
1072 genericWin
->isVisible
= FALSE
;
1076 if (winInfo
->generic
.content
!= (OpaquePtr
) NULL
)
1078 tuiDelDataWindows (winInfo
->detail
.dataDisplayInfo
.regsContent
,
1079 winInfo
->detail
.dataDisplayInfo
.regsContentCount
);
1080 tuiDelDataWindows (winInfo
->detail
.dataDisplayInfo
.dataContent
,
1081 winInfo
->detail
.dataDisplayInfo
.dataContentCount
);
1087 if (winInfo
->generic
.handle
!= (WINDOW
*) NULL
)
1089 tuiDelwin (winInfo
->generic
.handle
);
1090 winInfo
->generic
.handle
= (WINDOW
*) NULL
;
1091 winInfo
->generic
.isVisible
= FALSE
;
1100 freeWindow (TuiWinInfoPtr winInfo
)
1102 TuiGenWinInfoPtr genericWin
;
1104 switch (winInfo
->generic
.type
)
1108 genericWin
= locatorWinInfoPtr ();
1109 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1111 tuiDelwin (genericWin
->handle
);
1112 genericWin
->handle
= (WINDOW
*) NULL
;
1114 freeWinContent (genericWin
);
1115 if (winInfo
->detail
.sourceInfo
.filename
)
1117 xfree (winInfo
->detail
.sourceInfo
.filename
);
1118 winInfo
->detail
.sourceInfo
.filename
= 0;
1120 genericWin
= winInfo
->detail
.sourceInfo
.executionInfo
;
1121 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1123 tuiDelwin (genericWin
->handle
);
1124 genericWin
->handle
= (WINDOW
*) NULL
;
1125 freeWinContent (genericWin
);
1129 if (winInfo
->generic
.content
!= (OpaquePtr
) NULL
)
1132 winInfo
->detail
.dataDisplayInfo
.regsContent
,
1133 winInfo
->detail
.dataDisplayInfo
.regsContentCount
);
1134 winInfo
->detail
.dataDisplayInfo
.regsContent
=
1135 (TuiWinContent
) NULL
;
1136 winInfo
->detail
.dataDisplayInfo
.regsContentCount
= 0;
1138 winInfo
->detail
.dataDisplayInfo
.dataContent
,
1139 winInfo
->detail
.dataDisplayInfo
.dataContentCount
);
1140 winInfo
->detail
.dataDisplayInfo
.dataContent
=
1141 (TuiWinContent
) NULL
;
1142 winInfo
->detail
.dataDisplayInfo
.dataContentCount
= 0;
1143 winInfo
->detail
.dataDisplayInfo
.regsDisplayType
=
1145 winInfo
->detail
.dataDisplayInfo
.regsColumnCount
= 1;
1146 winInfo
->detail
.dataDisplayInfo
.displayRegs
= FALSE
;
1147 winInfo
->generic
.content
= (OpaquePtr
) NULL
;
1148 winInfo
->generic
.contentSize
= 0;
1154 if (winInfo
->generic
.handle
!= (WINDOW
*) NULL
)
1156 tuiDelwin (winInfo
->generic
.handle
);
1157 winInfo
->generic
.handle
= (WINDOW
*) NULL
;
1158 freeWinContent (&winInfo
->generic
);
1160 if (winInfo
->generic
.title
)
1161 xfree (winInfo
->generic
.title
);
1167 ** freeAllSourceWinsContent().
1170 freeAllSourceWinsContent (void)
1174 for (i
= 0; i
< (sourceWindows ())->count
; i
++)
1176 TuiWinInfoPtr winInfo
= (TuiWinInfoPtr
) (sourceWindows ())->list
[i
];
1178 if (m_winPtrNotNull (winInfo
))
1180 freeWinContent (&(winInfo
->generic
));
1181 freeWinContent (winInfo
->detail
.sourceInfo
.executionInfo
);
1186 } /* freeAllSourceWinsContent */
1190 ** freeWinContent().
1193 freeWinContent (TuiGenWinInfoPtr winInfo
)
1195 if (winInfo
->content
!= (OpaquePtr
) NULL
)
1197 freeContent ((TuiWinContent
) winInfo
->content
,
1198 winInfo
->contentSize
,
1200 winInfo
->content
= (OpaquePtr
) NULL
;
1202 winInfo
->contentSize
= 0;
1205 } /* freeWinContent */
1209 ** freeAllWindows().
1212 freeAllWindows (void)
1214 TuiWinType type
= SRC_WIN
;
1216 for (; type
< MAX_MAJOR_WINDOWS
; type
++)
1217 if (m_winPtrNotNull (winList
[type
]) &&
1218 winList
[type
]->generic
.type
!= UNDEFINED_WIN
)
1219 freeWindow (winList
[type
]);
1221 } /* freeAllWindows */
1225 tuiDelDataWindows (TuiWinContent content
, int contentSize
)
1230 ** Remember that data window content elements are of type TuiGenWinInfoPtr,
1231 ** each of which whose single element is a data element.
1233 for (i
= 0; i
< contentSize
; i
++)
1235 TuiGenWinInfoPtr genericWin
= &content
[i
]->whichElement
.dataWindow
;
1237 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1239 tuiDelwin (genericWin
->handle
);
1240 genericWin
->handle
= (WINDOW
*) NULL
;
1241 genericWin
->isVisible
= FALSE
;
1246 } /* tuiDelDataWindows */
1250 freeDataContent (TuiWinContent content
, int contentSize
)
1255 ** Remember that data window content elements are of type TuiGenWinInfoPtr,
1256 ** each of which whose single element is a data element.
1258 for (i
= 0; i
< contentSize
; i
++)
1260 TuiGenWinInfoPtr genericWin
= &content
[i
]->whichElement
.dataWindow
;
1262 if (genericWin
!= (TuiGenWinInfoPtr
) NULL
)
1264 tuiDelwin (genericWin
->handle
);
1265 genericWin
->handle
= (WINDOW
*) NULL
;
1266 freeWinContent (genericWin
);
1269 freeContent (content
,
1274 } /* freeDataContent */
1277 /**********************************
1278 ** LOCAL STATIC FUNCTIONS **
1279 **********************************/
1286 freeContent (TuiWinContent content
, int contentSize
, TuiWinType winType
)
1288 if (content
!= (TuiWinContent
) NULL
)
1290 freeContentElements (content
, contentSize
, winType
);
1291 tuiFree ((char *) content
);
1299 ** freeContentElements().
1302 freeContentElements (TuiWinContent content
, int contentSize
, TuiWinType type
)
1304 if (content
!= (TuiWinContent
) NULL
)
1308 if (type
== SRC_WIN
|| type
== DISASSEM_WIN
)
1310 /* free whole source block */
1311 if (content
[0]->whichElement
.source
.line
!= (char *) NULL
)
1312 tuiFree (content
[0]->whichElement
.source
.line
);
1316 for (i
= 0; i
< contentSize
; i
++)
1318 TuiWinElementPtr element
;
1320 element
= content
[i
];
1321 if (element
!= (TuiWinElementPtr
) NULL
)
1326 tuiFree ((char *) element
);
1330 ** Note that data elements are not allocated
1331 ** in a single block, but individually, as needed.
1333 if (element
->whichElement
.data
.type
!= TUI_REGISTER
)
1335 element
->whichElement
.data
.name
);
1336 tuiFree ((char *) element
->whichElement
.data
.value
);
1337 tuiFree ((char *) element
);
1340 tuiFree ((char *) element
->whichElement
.command
.line
);
1348 if (type
!= DATA_WIN
&& type
!= DATA_ITEM_WIN
)
1349 tuiFree ((char *) content
[0]); /* free the element block */
1353 } /* freeContentElements */