Commit | Line | Data |
---|---|---|
f377b406 SC |
1 | /* TUI data manipulation routines. |
2 | Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc. | |
3 | Contributed by Hewlett-Packard Company. | |
4 | ||
5 | This file is part of GDB. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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. */ | |
c906108c | 21 | |
4e8f7a8b DJ |
22 | /* If we need <curses.h>, we must include it before we get "bfd.h". */ |
23 | #include "config.h" | |
24 | #ifdef HAVE_NCURSES_H | |
25 | #include <ncurses.h> | |
26 | #else | |
27 | #ifdef HAVE_CURSES_H | |
28 | #include <curses.h> | |
29 | #endif | |
30 | #endif | |
31 | ||
c906108c SS |
32 | #include "defs.h" |
33 | #include "tui.h" | |
34 | #include "tuiData.h" | |
a4b99e53 | 35 | #include "tuiGeneralWin.h" |
c906108c SS |
36 | |
37 | /**************************** | |
38 | ** GLOBAL DECLARATIONS | |
39 | ****************************/ | |
40 | TuiWinInfoPtr winList[MAX_MAJOR_WINDOWS]; | |
41 | ||
42 | /*************************** | |
43 | ** Private Definitions | |
44 | ****************************/ | |
45 | #define FILE_WIDTH 30 | |
46 | #define PROC_WIDTH 40 | |
47 | #define LINE_WIDTH 4 | |
48 | #define PC_WIDTH 8 | |
49 | ||
50 | /*************************** | |
51 | ** Private data | |
52 | ****************************/ | |
53 | static char *_tuiNullStr = TUI_NULL_STR; | |
54 | static char *_tuiBlankStr = " "; | |
55 | static char *_tuiLocationStr = " >"; | |
56 | static char *_tuiBreakStr = " * "; | |
57 | static char *_tuiBreakLocationStr = " *>"; | |
58 | static TuiLayoutType _currentLayout = UNDEFINED_LAYOUT; | |
59 | static int _termHeight, _termWidth; | |
60 | static int _historyLimit = DEFAULT_HISTORY_COUNT; | |
61 | static TuiGenWinInfo _locator; | |
62 | static TuiGenWinInfo _execInfo[2]; | |
63 | static TuiWinInfoPtr _srcWinList[2]; | |
64 | static TuiList _sourceWindows = | |
65 | {(OpaqueList) _srcWinList, 0}; | |
66 | static int _defaultTabLen = DEFAULT_TAB_LEN; | |
67 | static TuiWinInfoPtr _winWithFocus = (TuiWinInfoPtr) NULL; | |
68 | static TuiLayoutDef _layoutDef = | |
69 | {SRC_WIN, /* displayMode */ | |
70 | FALSE, /* split */ | |
71 | TUI_UNDEFINED_REGS, /* regsDisplayType */ | |
72 | TUI_SFLOAT_REGS}; /* floatRegsDisplayType */ | |
73 | static int _winResized = FALSE; | |
74 | ||
75 | ||
76 | /********************************* | |
77 | ** Static function forward decls | |
78 | **********************************/ | |
a14ed312 KB |
79 | static void freeContent (TuiWinContent, int, TuiWinType); |
80 | static void freeContentElements (TuiWinContent, int, TuiWinType); | |
c906108c SS |
81 | |
82 | ||
83 | ||
84 | /********************************* | |
85 | ** PUBLIC FUNCTIONS | |
86 | **********************************/ | |
87 | ||
88 | /****************************************** | |
89 | ** ACCESSORS & MUTATORS FOR PRIVATE DATA | |
90 | ******************************************/ | |
91 | ||
92 | /* | |
c5aa993b JM |
93 | ** tuiWinResized(). |
94 | ** Answer a whether the terminal window has been resized or not | |
95 | */ | |
c906108c | 96 | int |
c906108c | 97 | tuiWinResized (void) |
c906108c SS |
98 | { |
99 | return _winResized; | |
100 | } /* tuiWinResized */ | |
101 | ||
102 | ||
103 | /* | |
c5aa993b JM |
104 | ** tuiSetWinResized(). |
105 | ** Set a whether the terminal window has been resized or not | |
106 | */ | |
c906108c | 107 | void |
eca6576c | 108 | tuiSetWinResizedTo (int resized) |
c906108c SS |
109 | { |
110 | _winResized = resized; | |
111 | ||
112 | return; | |
113 | } /* tuiSetWinResizedTo */ | |
114 | ||
115 | ||
116 | /* | |
c5aa993b JM |
117 | ** tuiLayoutDef(). |
118 | ** Answer a pointer to the current layout definition | |
119 | */ | |
c906108c | 120 | TuiLayoutDefPtr |
c906108c | 121 | tuiLayoutDef (void) |
c906108c SS |
122 | { |
123 | return &_layoutDef; | |
124 | } /* tuiLayoutDef */ | |
125 | ||
126 | ||
127 | /* | |
c5aa993b JM |
128 | ** tuiWinWithFocus(). |
129 | ** Answer the window with the logical focus | |
130 | */ | |
c906108c | 131 | TuiWinInfoPtr |
c906108c | 132 | tuiWinWithFocus (void) |
c906108c SS |
133 | { |
134 | return _winWithFocus; | |
135 | } /* tuiWinWithFocus */ | |
136 | ||
137 | ||
138 | /* | |
c5aa993b JM |
139 | ** tuiSetWinWithFocus(). |
140 | ** Set the window that has the logical focus | |
141 | */ | |
c906108c | 142 | void |
eca6576c | 143 | tuiSetWinWithFocus (TuiWinInfoPtr winInfo) |
c906108c SS |
144 | { |
145 | _winWithFocus = winInfo; | |
146 | ||
147 | return; | |
148 | } /* tuiSetWinWithFocus */ | |
149 | ||
150 | ||
151 | /* | |
c5aa993b JM |
152 | ** tuiDefaultTabLen(). |
153 | ** Answer the length in chars, of tabs | |
154 | */ | |
c906108c | 155 | int |
c906108c | 156 | tuiDefaultTabLen (void) |
c906108c SS |
157 | { |
158 | return _defaultTabLen; | |
159 | } /* tuiDefaultTabLen */ | |
160 | ||
161 | ||
162 | /* | |
c5aa993b JM |
163 | ** tuiSetDefaultTabLen(). |
164 | ** Set the length in chars, of tabs | |
165 | */ | |
c906108c | 166 | void |
eca6576c | 167 | tuiSetDefaultTabLen (int len) |
c906108c SS |
168 | { |
169 | _defaultTabLen = len; | |
170 | ||
171 | return; | |
172 | } /* tuiSetDefaultTabLen */ | |
173 | ||
174 | ||
175 | /* | |
c5aa993b JM |
176 | ** currentSourceWin() |
177 | ** Accessor for the current source window. Usually there is only | |
178 | ** one source window (either source or disassembly), but both can | |
179 | ** be displayed at the same time. | |
180 | */ | |
c906108c | 181 | TuiListPtr |
c906108c | 182 | sourceWindows (void) |
c906108c SS |
183 | { |
184 | return &_sourceWindows; | |
185 | } /* currentSourceWindows */ | |
186 | ||
187 | ||
188 | /* | |
c5aa993b JM |
189 | ** clearSourceWindows() |
190 | ** Clear the list of source windows. Usually there is only one | |
191 | ** source window (either source or disassembly), but both can be | |
192 | ** displayed at the same time. | |
193 | */ | |
c906108c | 194 | void |
c906108c | 195 | clearSourceWindows (void) |
c906108c SS |
196 | { |
197 | _sourceWindows.list[0] = (Opaque) NULL; | |
198 | _sourceWindows.list[1] = (Opaque) NULL; | |
199 | _sourceWindows.count = 0; | |
200 | ||
201 | return; | |
202 | } /* currentSourceWindows */ | |
203 | ||
204 | ||
205 | /* | |
c5aa993b JM |
206 | ** clearSourceWindowsDetail() |
207 | ** Clear the pertinant detail in the source windows. | |
208 | */ | |
c906108c | 209 | void |
c906108c | 210 | clearSourceWindowsDetail (void) |
c906108c SS |
211 | { |
212 | int i; | |
213 | ||
214 | for (i = 0; i < (sourceWindows ())->count; i++) | |
215 | clearWinDetail ((TuiWinInfoPtr) (sourceWindows ())->list[i]); | |
216 | ||
217 | return; | |
218 | } /* currentSourceWindows */ | |
219 | ||
220 | ||
221 | /* | |
c5aa993b JM |
222 | ** addSourceWindowToList(). |
223 | ** Add a window to the list of source windows. Usually there is | |
224 | ** only one source window (either source or disassembly), but | |
225 | ** both can be displayed at the same time. | |
226 | */ | |
c906108c | 227 | void |
eca6576c | 228 | addToSourceWindows (TuiWinInfoPtr winInfo) |
c906108c SS |
229 | { |
230 | if (_sourceWindows.count < 2) | |
231 | _sourceWindows.list[_sourceWindows.count++] = (Opaque) winInfo; | |
232 | ||
233 | return; | |
234 | } /* addToSourceWindows */ | |
235 | ||
236 | ||
237 | /* | |
c5aa993b JM |
238 | ** clearWinDetail() |
239 | ** Clear the pertinant detail in the windows. | |
240 | */ | |
c906108c | 241 | void |
eca6576c | 242 | clearWinDetail (TuiWinInfoPtr winInfo) |
c906108c SS |
243 | { |
244 | if (m_winPtrNotNull (winInfo)) | |
245 | { | |
246 | switch (winInfo->generic.type) | |
247 | { | |
248 | case SRC_WIN: | |
249 | case DISASSEM_WIN: | |
a4b99e53 | 250 | winInfo->detail.sourceInfo.startLineOrAddr.addr = 0; |
c906108c SS |
251 | winInfo->detail.sourceInfo.horizontalOffset = 0; |
252 | break; | |
253 | case CMD_WIN: | |
254 | winInfo->detail.commandInfo.curLine = | |
255 | winInfo->detail.commandInfo.curch = 0; | |
256 | break; | |
257 | case DATA_WIN: | |
258 | winInfo->detail.dataDisplayInfo.dataContent = | |
259 | (TuiWinContent) NULL; | |
260 | winInfo->detail.dataDisplayInfo.dataContentCount = 0; | |
261 | winInfo->detail.dataDisplayInfo.regsContent = | |
262 | (TuiWinContent) NULL; | |
263 | winInfo->detail.dataDisplayInfo.regsContentCount = 0; | |
264 | winInfo->detail.dataDisplayInfo.regsDisplayType = | |
265 | TUI_UNDEFINED_REGS; | |
266 | winInfo->detail.dataDisplayInfo.regsColumnCount = 1; | |
267 | winInfo->detail.dataDisplayInfo.displayRegs = FALSE; | |
268 | break; | |
269 | default: | |
270 | break; | |
271 | } | |
272 | } | |
273 | ||
274 | return; | |
275 | } /* clearWinDetail */ | |
276 | ||
277 | ||
278 | /* | |
c5aa993b JM |
279 | ** blankStr() |
280 | ** Accessor for the blank string. | |
281 | */ | |
c906108c | 282 | char * |
c906108c | 283 | blankStr (void) |
c906108c SS |
284 | { |
285 | return _tuiBlankStr; | |
286 | } /* blankStr */ | |
287 | ||
288 | ||
289 | /* | |
c5aa993b JM |
290 | ** locationStr() |
291 | ** Accessor for the location string. | |
292 | */ | |
c906108c | 293 | char * |
c906108c | 294 | locationStr (void) |
c906108c SS |
295 | { |
296 | return _tuiLocationStr; | |
297 | } /* locationStr */ | |
298 | ||
299 | ||
300 | /* | |
c5aa993b JM |
301 | ** breakStr() |
302 | ** Accessor for the break string. | |
303 | */ | |
c906108c | 304 | char * |
c906108c | 305 | breakStr (void) |
c906108c SS |
306 | { |
307 | return _tuiBreakStr; | |
308 | } /* breakStr */ | |
309 | ||
310 | ||
311 | /* | |
c5aa993b JM |
312 | ** breakLocationStr() |
313 | ** Accessor for the breakLocation string. | |
314 | */ | |
c906108c | 315 | char * |
c906108c | 316 | breakLocationStr (void) |
c906108c SS |
317 | { |
318 | return _tuiBreakLocationStr; | |
319 | } /* breakLocationStr */ | |
320 | ||
321 | ||
322 | /* | |
c5aa993b JM |
323 | ** nullStr() |
324 | ** Accessor for the null string. | |
325 | */ | |
c906108c | 326 | char * |
c906108c | 327 | nullStr (void) |
c906108c SS |
328 | { |
329 | return _tuiNullStr; | |
330 | } /* nullStr */ | |
331 | ||
332 | ||
333 | /* | |
c5aa993b JM |
334 | ** sourceExecInfoPtr(). |
335 | ** Accessor for the source execution info ptr. | |
336 | */ | |
c906108c | 337 | TuiGenWinInfoPtr |
c906108c | 338 | sourceExecInfoWinPtr (void) |
c906108c SS |
339 | { |
340 | return &_execInfo[0]; | |
341 | } /* sourceExecInfoWinPtr */ | |
342 | ||
343 | ||
344 | /* | |
c5aa993b JM |
345 | ** disassemExecInfoPtr(). |
346 | ** Accessor for the disassem execution info ptr. | |
347 | */ | |
c906108c | 348 | TuiGenWinInfoPtr |
c906108c | 349 | disassemExecInfoWinPtr (void) |
c906108c SS |
350 | { |
351 | return &_execInfo[1]; | |
352 | } /* disassemExecInfoWinPtr */ | |
353 | ||
354 | ||
355 | /* | |
c5aa993b JM |
356 | ** locatorWinInfoPtr(). |
357 | ** Accessor for the locator win info. Answers a pointer to the | |
358 | ** static locator win info struct. | |
359 | */ | |
c906108c | 360 | TuiGenWinInfoPtr |
c906108c | 361 | locatorWinInfoPtr (void) |
c906108c SS |
362 | { |
363 | return &_locator; | |
364 | } /* locatorWinInfoPtr */ | |
365 | ||
366 | ||
367 | /* | |
c5aa993b JM |
368 | ** historyLimit(). |
369 | ** Accessor for the history limit | |
370 | */ | |
c906108c | 371 | int |
c906108c | 372 | historyLimit (void) |
c906108c SS |
373 | { |
374 | return _historyLimit; | |
375 | } /* historyLimit */ | |
376 | ||
377 | ||
378 | /* | |
c5aa993b JM |
379 | ** setHistoryLimitTo(). |
380 | ** Mutator for the history limit | |
381 | */ | |
c906108c | 382 | void |
eca6576c | 383 | setHistoryLimitTo (int h) |
c906108c SS |
384 | { |
385 | _historyLimit = h; | |
386 | ||
387 | return; | |
388 | } /* setHistoryLimitTo */ | |
389 | ||
390 | /* | |
c5aa993b JM |
391 | ** termHeight(). |
392 | ** Accessor for the termHeight | |
393 | */ | |
c906108c | 394 | int |
c906108c | 395 | termHeight (void) |
c906108c SS |
396 | { |
397 | return _termHeight; | |
398 | } /* termHeight */ | |
399 | ||
400 | ||
401 | /* | |
c5aa993b JM |
402 | ** setTermHeightTo(). |
403 | ** Mutator for the term height | |
404 | */ | |
c906108c | 405 | void |
eca6576c | 406 | setTermHeightTo (int h) |
c906108c SS |
407 | { |
408 | _termHeight = h; | |
409 | ||
410 | return; | |
411 | } /* setTermHeightTo */ | |
412 | ||
413 | ||
414 | /* | |
c5aa993b JM |
415 | ** termWidth(). |
416 | ** Accessor for the termWidth | |
417 | */ | |
c906108c | 418 | int |
c906108c | 419 | termWidth (void) |
c906108c SS |
420 | { |
421 | return _termWidth; | |
422 | } /* termWidth */ | |
423 | ||
424 | ||
425 | /* | |
c5aa993b JM |
426 | ** setTermWidth(). |
427 | ** Mutator for the termWidth | |
428 | */ | |
c906108c | 429 | void |
eca6576c | 430 | setTermWidthTo (int w) |
c906108c SS |
431 | { |
432 | _termWidth = w; | |
433 | ||
434 | return; | |
435 | } /* setTermWidthTo */ | |
436 | ||
437 | ||
438 | /* | |
c5aa993b JM |
439 | ** currentLayout(). |
440 | ** Accessor for the current layout | |
441 | */ | |
c906108c | 442 | TuiLayoutType |
c906108c | 443 | currentLayout (void) |
c906108c SS |
444 | { |
445 | return _currentLayout; | |
446 | } /* currentLayout */ | |
447 | ||
448 | ||
449 | /* | |
c5aa993b JM |
450 | ** setCurrentLayoutTo(). |
451 | ** Mutator for the current layout | |
452 | */ | |
c906108c | 453 | void |
eca6576c | 454 | setCurrentLayoutTo (TuiLayoutType newLayout) |
c906108c SS |
455 | { |
456 | _currentLayout = newLayout; | |
457 | ||
458 | return; | |
459 | } /* setCurrentLayoutTo */ | |
460 | ||
461 | ||
462 | /* | |
c5aa993b JM |
463 | ** setGenWinOrigin(). |
464 | ** Set the origin of the window | |
465 | */ | |
c906108c | 466 | void |
eca6576c | 467 | setGenWinOrigin (TuiGenWinInfoPtr winInfo, int x, int y) |
c906108c SS |
468 | { |
469 | winInfo->origin.x = x; | |
470 | winInfo->origin.y = y; | |
471 | ||
472 | return; | |
473 | } /* setGenWinOrigin */ | |
474 | ||
475 | ||
476 | /***************************** | |
477 | ** OTHER PUBLIC FUNCTIONS | |
478 | *****************************/ | |
479 | ||
480 | ||
481 | /* | |
c5aa993b JM |
482 | ** tuiNextWin(). |
483 | ** Answer the next window in the list, cycling back to the top | |
484 | ** if necessary | |
485 | */ | |
c906108c | 486 | TuiWinInfoPtr |
eca6576c | 487 | tuiNextWin (TuiWinInfoPtr curWin) |
c906108c SS |
488 | { |
489 | TuiWinType type = curWin->generic.type; | |
490 | TuiWinInfoPtr nextWin = (TuiWinInfoPtr) NULL; | |
491 | ||
492 | if (curWin->generic.type == CMD_WIN) | |
493 | type = SRC_WIN; | |
494 | else | |
495 | type = curWin->generic.type + 1; | |
496 | while (type != curWin->generic.type && m_winPtrIsNull (nextWin)) | |
497 | { | |
a4b99e53 | 498 | if (winList[type] && winList[type]->generic.isVisible) |
c906108c SS |
499 | nextWin = winList[type]; |
500 | else | |
501 | { | |
502 | if (type == CMD_WIN) | |
503 | type = SRC_WIN; | |
504 | else | |
505 | type++; | |
506 | } | |
507 | } | |
508 | ||
509 | return nextWin; | |
510 | } /* tuiNextWin */ | |
511 | ||
512 | ||
513 | /* | |
c5aa993b JM |
514 | ** tuiPrevWin(). |
515 | ** Answer the prev window in the list, cycling back to the bottom | |
516 | ** if necessary | |
517 | */ | |
c906108c | 518 | TuiWinInfoPtr |
eca6576c | 519 | tuiPrevWin (TuiWinInfoPtr curWin) |
c906108c SS |
520 | { |
521 | TuiWinType type = curWin->generic.type; | |
522 | TuiWinInfoPtr prev = (TuiWinInfoPtr) NULL; | |
523 | ||
524 | if (curWin->generic.type == SRC_WIN) | |
525 | type = CMD_WIN; | |
526 | else | |
527 | type = curWin->generic.type - 1; | |
528 | while (type != curWin->generic.type && m_winPtrIsNull (prev)) | |
529 | { | |
530 | if (winList[type]->generic.isVisible) | |
531 | prev = winList[type]; | |
532 | else | |
533 | { | |
534 | if (type == SRC_WIN) | |
535 | type = CMD_WIN; | |
536 | else | |
537 | type--; | |
538 | } | |
539 | } | |
540 | ||
541 | return prev; | |
542 | } /* tuiPrevWin */ | |
543 | ||
544 | ||
545 | /* | |
c5aa993b JM |
546 | ** displayableWinContentOf(). |
547 | ** Answer a the content at the location indicated by index. Note | |
548 | ** that if this is a locator window, the string returned should be | |
549 | ** freed after use. | |
550 | */ | |
c906108c | 551 | char * |
eca6576c | 552 | displayableWinContentOf (TuiGenWinInfoPtr winInfo, TuiWinElementPtr elementPtr) |
c906108c SS |
553 | { |
554 | ||
555 | char *string = nullStr (); | |
556 | ||
557 | if (elementPtr != (TuiWinElementPtr) NULL || winInfo->type == LOCATOR_WIN) | |
558 | { | |
559 | /* | |
c5aa993b JM |
560 | ** Now convert the line to a displayable string |
561 | */ | |
c906108c SS |
562 | switch (winInfo->type) |
563 | { | |
564 | case SRC_WIN: | |
565 | case DISASSEM_WIN: | |
566 | string = elementPtr->whichElement.source.line; | |
567 | break; | |
568 | case CMD_WIN: | |
569 | string = elementPtr->whichElement.command.line; | |
570 | break; | |
571 | case LOCATOR_WIN: | |
572 | if ((string = (char *) xmalloc ( | |
573 | (termWidth () + 1) * sizeof (char))) == (char *) NULL) | |
574 | string = nullStr (); | |
575 | else | |
576 | { | |
577 | char lineNo[50], pc[50], buf[50], *fname, *pname; | |
578 | register int strSize = termWidth (), i, procWidth, fileWidth; | |
579 | ||
580 | /* | |
c5aa993b JM |
581 | ** First determine the amount of file/proc name width |
582 | ** we have available | |
583 | */ | |
c906108c SS |
584 | i = strSize - (PC_WIDTH + LINE_WIDTH |
585 | + 25 /* pc and line labels */ | |
c5aa993b | 586 | + strlen (FILE_PREFIX) + 1 /* file label */ |
c906108c SS |
587 | + 15 /* procedure label */ ); |
588 | if (i >= FILE_WIDTH + PROC_WIDTH) | |
589 | { | |
590 | fileWidth = FILE_WIDTH; | |
591 | procWidth = PROC_WIDTH; | |
592 | } | |
593 | else | |
594 | { | |
595 | fileWidth = i / 2; | |
596 | procWidth = i - fileWidth; | |
597 | } | |
598 | ||
599 | /* Now convert elements to string form */ | |
600 | if (elementPtr != (TuiWinElementPtr) NULL && | |
601 | *elementPtr->whichElement.locator.fileName != (char) 0 && | |
602 | srcWin->generic.isVisible) | |
603 | fname = elementPtr->whichElement.locator.fileName; | |
604 | else | |
605 | fname = "??"; | |
606 | if (elementPtr != (TuiWinElementPtr) NULL && | |
607 | *elementPtr->whichElement.locator.procName != (char) 0) | |
608 | pname = elementPtr->whichElement.locator.procName; | |
609 | else | |
610 | pname = "??"; | |
611 | if (elementPtr != (TuiWinElementPtr) NULL && | |
612 | elementPtr->whichElement.locator.lineNo > 0) | |
613 | sprintf (lineNo, "%d", | |
614 | elementPtr->whichElement.locator.lineNo); | |
615 | else | |
616 | strcpy (lineNo, "??"); | |
617 | if (elementPtr != (TuiWinElementPtr) NULL && | |
a4b99e53 SC |
618 | elementPtr->whichElement.locator.addr != 0) |
619 | sprintf (pc, "0x%lx", | |
620 | (long) elementPtr->whichElement.locator.addr); | |
c906108c SS |
621 | else |
622 | strcpy (pc, "??"); | |
623 | /* | |
c5aa993b JM |
624 | ** Now create the locator line from the string version |
625 | ** of the elements. We could use sprintf() here but | |
626 | ** that wouldn't ensure that we don't overrun the size | |
627 | ** of the allocated buffer. strcat_to_buf() will. | |
628 | */ | |
c906108c SS |
629 | *string = (char) 0; |
630 | /* Filename */ | |
631 | strcat_to_buf (string, strSize, " "); | |
632 | strcat_to_buf (string, strSize, FILE_PREFIX); | |
633 | if (strlen (fname) > fileWidth) | |
634 | { | |
635 | strncpy (buf, fname, fileWidth - 1); | |
636 | buf[fileWidth - 1] = '*'; | |
637 | buf[fileWidth] = (char) 0; | |
638 | } | |
639 | else | |
640 | strcpy (buf, fname); | |
641 | strcat_to_buf (string, strSize, buf); | |
642 | /* procedure/class name */ | |
643 | sprintf (buf, "%15s", PROC_PREFIX); | |
644 | strcat_to_buf (string, strSize, buf); | |
645 | if (strlen (pname) > procWidth) | |
646 | { | |
647 | strncpy (buf, pname, procWidth - 1); | |
648 | buf[procWidth - 1] = '*'; | |
649 | buf[procWidth] = (char) 0; | |
650 | } | |
651 | else | |
652 | strcpy (buf, pname); | |
653 | strcat_to_buf (string, strSize, buf); | |
654 | sprintf (buf, "%10s", LINE_PREFIX); | |
655 | strcat_to_buf (string, strSize, buf); | |
656 | strcat_to_buf (string, strSize, lineNo); | |
657 | sprintf (buf, "%10s", PC_PREFIX); | |
658 | strcat_to_buf (string, strSize, buf); | |
659 | strcat_to_buf (string, strSize, pc); | |
660 | for (i = strlen (string); i < strSize; i++) | |
661 | string[i] = ' '; | |
662 | string[strSize] = (char) 0; | |
663 | } | |
664 | break; | |
665 | case EXEC_INFO_WIN: | |
666 | string = elementPtr->whichElement.simpleString; | |
667 | break; | |
668 | default: | |
669 | break; | |
670 | } | |
671 | } | |
672 | return string; | |
673 | } /* displayableWinContentOf */ | |
674 | ||
675 | ||
676 | /* | |
c5aa993b JM |
677 | ** winContentAt(). |
678 | ** Answer a the content at the location indicated by index | |
679 | */ | |
c906108c | 680 | char * |
eca6576c | 681 | displayableWinContentAt (TuiGenWinInfoPtr winInfo, int index) |
c906108c SS |
682 | { |
683 | return (displayableWinContentOf (winInfo, (TuiWinElementPtr) winInfo->content[index])); | |
684 | } /* winContentAt */ | |
685 | ||
686 | ||
687 | /* | |
c5aa993b JM |
688 | ** winElementHeight(). |
689 | ** Answer the height of the element in lines | |
690 | */ | |
c906108c | 691 | int |
eca6576c | 692 | winElementHeight (TuiGenWinInfoPtr winInfo, TuiWinElementPtr element) |
c906108c SS |
693 | { |
694 | int h; | |
695 | ||
696 | if (winInfo->type == DATA_WIN) | |
697 | /* FOR NOW SAY IT IS ONLY ONE LINE HIGH */ | |
698 | h = 1; | |
699 | else | |
700 | h = 1; | |
701 | ||
702 | return h; | |
703 | } /* winElementHeight */ | |
704 | ||
705 | ||
706 | /* | |
c5aa993b JM |
707 | ** winByName(). |
708 | ** Answer the window represented by name | |
709 | */ | |
c906108c | 710 | TuiWinInfoPtr |
eca6576c | 711 | winByName (char *name) |
c906108c SS |
712 | { |
713 | TuiWinInfoPtr winInfo = (TuiWinInfoPtr) NULL; | |
714 | int i = 0; | |
715 | ||
716 | while (i < MAX_MAJOR_WINDOWS && m_winPtrIsNull (winInfo)) | |
717 | { | |
718 | if (strcmp (name, winName (&(winList[i]->generic))) == 0) | |
719 | winInfo = winList[i]; | |
720 | i++; | |
721 | } | |
722 | ||
723 | return winInfo; | |
724 | } /* winByName */ | |
725 | ||
726 | ||
727 | /* | |
c5aa993b JM |
728 | ** partialWinByName(). |
729 | ** Answer the window represented by name | |
730 | */ | |
c906108c | 731 | TuiWinInfoPtr |
eca6576c | 732 | partialWinByName (char *name) |
c906108c SS |
733 | { |
734 | TuiWinInfoPtr winInfo = (TuiWinInfoPtr) NULL; | |
735 | ||
736 | if (name != (char *) NULL) | |
737 | { | |
738 | int i = 0; | |
739 | ||
740 | while (i < MAX_MAJOR_WINDOWS && m_winPtrIsNull (winInfo)) | |
741 | { | |
a4b99e53 SC |
742 | if (winList[i] != 0) |
743 | { | |
744 | char *curName = winName (&winList[i]->generic); | |
745 | if (strlen (name) <= strlen (curName) && | |
746 | strncmp (name, curName, strlen (name)) == 0) | |
747 | winInfo = winList[i]; | |
748 | } | |
c906108c SS |
749 | i++; |
750 | } | |
751 | } | |
752 | ||
753 | return winInfo; | |
754 | } /* partialWinByName */ | |
755 | ||
756 | ||
757 | /* | |
c5aa993b JM |
758 | ** winName(). |
759 | ** Answer the name of the window | |
760 | */ | |
c906108c | 761 | char * |
eca6576c | 762 | winName (TuiGenWinInfoPtr winInfo) |
c906108c SS |
763 | { |
764 | char *name = (char *) NULL; | |
765 | ||
766 | switch (winInfo->type) | |
767 | { | |
768 | case SRC_WIN: | |
769 | name = SRC_NAME; | |
770 | break; | |
771 | case CMD_WIN: | |
772 | name = CMD_NAME; | |
773 | break; | |
774 | case DISASSEM_WIN: | |
775 | name = DISASSEM_NAME; | |
776 | break; | |
777 | case DATA_WIN: | |
778 | name = DATA_NAME; | |
779 | break; | |
780 | default: | |
781 | name = ""; | |
782 | break; | |
783 | } | |
784 | ||
785 | return name; | |
786 | } /* winName */ | |
787 | ||
788 | ||
789 | /* | |
c5aa993b JM |
790 | ** initializeStaticData |
791 | */ | |
c906108c | 792 | void |
c906108c | 793 | initializeStaticData (void) |
c906108c SS |
794 | { |
795 | initGenericPart (sourceExecInfoWinPtr ()); | |
796 | initGenericPart (disassemExecInfoWinPtr ()); | |
797 | initGenericPart (locatorWinInfoPtr ()); | |
798 | ||
799 | return; | |
800 | } /* initializeStaticData */ | |
801 | ||
802 | ||
803 | /* | |
c5aa993b JM |
804 | ** allocGenericWinInfo(). |
805 | */ | |
c906108c | 806 | TuiGenWinInfoPtr |
c906108c | 807 | allocGenericWinInfo (void) |
c906108c SS |
808 | { |
809 | TuiGenWinInfoPtr win; | |
810 | ||
811 | if ((win = (TuiGenWinInfoPtr) xmalloc ( | |
812 | sizeof (TuiGenWinInfoPtr))) != (TuiGenWinInfoPtr) NULL) | |
813 | initGenericPart (win); | |
814 | ||
815 | return win; | |
816 | } /* allocGenericWinInfo */ | |
817 | ||
818 | ||
819 | /* | |
c5aa993b JM |
820 | ** initGenericPart(). |
821 | */ | |
c906108c | 822 | void |
eca6576c | 823 | initGenericPart (TuiGenWinInfoPtr win) |
c906108c SS |
824 | { |
825 | win->width = | |
826 | win->height = | |
827 | win->origin.x = | |
828 | win->origin.y = | |
829 | win->viewportHeight = | |
830 | win->contentSize = | |
831 | win->lastVisibleLine = 0; | |
832 | win->handle = (WINDOW *) NULL; | |
833 | win->content = (OpaquePtr) NULL; | |
834 | win->contentInUse = | |
835 | win->isVisible = FALSE; | |
836 | ||
837 | return; | |
838 | } /* initGenericPart */ | |
839 | ||
840 | ||
841 | /* | |
c5aa993b JM |
842 | ** initContentElement(). |
843 | */ | |
c906108c | 844 | void |
eca6576c | 845 | initContentElement (TuiWinElementPtr element, TuiWinType type) |
c906108c SS |
846 | { |
847 | element->highlight = FALSE; | |
848 | switch (type) | |
849 | { | |
850 | case SRC_WIN: | |
851 | case DISASSEM_WIN: | |
852 | element->whichElement.source.line = (char *) NULL; | |
853 | element->whichElement.source.lineOrAddr.lineNo = 0; | |
854 | element->whichElement.source.isExecPoint = FALSE; | |
855 | element->whichElement.source.hasBreak = FALSE; | |
856 | break; | |
857 | case DATA_WIN: | |
858 | initGenericPart (&element->whichElement.dataWindow); | |
859 | element->whichElement.dataWindow.type = DATA_ITEM_WIN; | |
860 | ((TuiGenWinInfoPtr) & element->whichElement.dataWindow)->content = | |
861 | (OpaquePtr) allocContent (1, DATA_ITEM_WIN); | |
862 | ((TuiGenWinInfoPtr) | |
863 | & element->whichElement.dataWindow)->contentSize = 1; | |
864 | break; | |
865 | case CMD_WIN: | |
866 | element->whichElement.command.line = (char *) NULL; | |
867 | break; | |
868 | case DATA_ITEM_WIN: | |
869 | element->whichElement.data.name = (char *) NULL; | |
870 | element->whichElement.data.type = TUI_REGISTER; | |
871 | element->whichElement.data.itemNo = UNDEFINED_ITEM; | |
872 | element->whichElement.data.value = (Opaque) NULL; | |
873 | element->whichElement.data.highlight = FALSE; | |
874 | break; | |
875 | case LOCATOR_WIN: | |
876 | element->whichElement.locator.fileName[0] = | |
877 | element->whichElement.locator.procName[0] = (char) 0; | |
878 | element->whichElement.locator.lineNo = 0; | |
879 | element->whichElement.locator.addr = 0; | |
880 | break; | |
881 | case EXEC_INFO_WIN: | |
882 | element->whichElement.simpleString = blankStr (); | |
883 | break; | |
884 | default: | |
885 | break; | |
886 | } | |
887 | return; | |
888 | } /* initContentElement */ | |
889 | ||
890 | /* | |
c5aa993b JM |
891 | ** initWinInfo(). |
892 | */ | |
c906108c | 893 | void |
eca6576c | 894 | initWinInfo (TuiWinInfoPtr winInfo) |
c906108c SS |
895 | { |
896 | initGenericPart (&winInfo->generic); | |
897 | winInfo->canHighlight = | |
898 | winInfo->isHighlighted = FALSE; | |
899 | switch (winInfo->generic.type) | |
900 | { | |
901 | case SRC_WIN: | |
902 | case DISASSEM_WIN: | |
903 | winInfo->detail.sourceInfo.executionInfo = (TuiGenWinInfoPtr) NULL; | |
904 | winInfo->detail.sourceInfo.hasLocator = FALSE; | |
905 | winInfo->detail.sourceInfo.horizontalOffset = 0; | |
a4b99e53 | 906 | winInfo->detail.sourceInfo.startLineOrAddr.addr = 0; |
c906108c SS |
907 | break; |
908 | case DATA_WIN: | |
909 | winInfo->detail.dataDisplayInfo.dataContent = (TuiWinContent) NULL; | |
910 | winInfo->detail.dataDisplayInfo.dataContentCount = 0; | |
911 | winInfo->detail.dataDisplayInfo.regsContent = (TuiWinContent) NULL; | |
912 | winInfo->detail.dataDisplayInfo.regsContentCount = 0; | |
913 | winInfo->detail.dataDisplayInfo.regsDisplayType = | |
914 | TUI_UNDEFINED_REGS; | |
915 | winInfo->detail.dataDisplayInfo.regsColumnCount = 1; | |
916 | winInfo->detail.dataDisplayInfo.displayRegs = FALSE; | |
917 | break; | |
918 | case CMD_WIN: | |
919 | winInfo->detail.commandInfo.curLine = 0; | |
920 | winInfo->detail.commandInfo.curch = 0; | |
921 | break; | |
922 | default: | |
923 | winInfo->detail.opaque = (Opaque) NULL; | |
924 | break; | |
925 | } | |
926 | ||
927 | return; | |
928 | } /* initWinInfo */ | |
929 | ||
930 | ||
931 | /* | |
c5aa993b JM |
932 | ** allocWinInfo(). |
933 | */ | |
c906108c | 934 | TuiWinInfoPtr |
eca6576c | 935 | allocWinInfo (TuiWinType type) |
c906108c SS |
936 | { |
937 | TuiWinInfoPtr winInfo = (TuiWinInfoPtr) NULL; | |
938 | ||
939 | winInfo = (TuiWinInfoPtr) xmalloc (sizeof (TuiWinInfo)); | |
940 | if (m_winPtrNotNull (winInfo)) | |
941 | { | |
942 | winInfo->generic.type = type; | |
943 | initWinInfo (winInfo); | |
944 | } | |
945 | ||
946 | return winInfo; | |
947 | } /* allocWinInfo */ | |
948 | ||
949 | ||
950 | /* | |
c5aa993b JM |
951 | ** allocContent(). |
952 | ** Allocates the content and elements in a block. | |
953 | */ | |
c906108c | 954 | TuiWinContent |
eca6576c | 955 | allocContent (int numElements, TuiWinType type) |
c906108c SS |
956 | { |
957 | TuiWinContent content = (TuiWinContent) NULL; | |
958 | char *elementBlockPtr = (char *) NULL; | |
959 | int i; | |
960 | ||
961 | if ((content = (TuiWinContent) | |
962 | xmalloc (sizeof (TuiWinElementPtr) * numElements)) != (TuiWinContent) NULL) | |
963 | { /* | |
c5aa993b JM |
964 | ** All windows, except the data window, can allocate the elements |
965 | ** in a chunk. The data window cannot because items can be | |
966 | ** added/removed from the data display by the user at any time. | |
967 | */ | |
c906108c SS |
968 | if (type != DATA_WIN) |
969 | { | |
970 | if ((elementBlockPtr = (char *) | |
971 | xmalloc (sizeof (TuiWinElement) * numElements)) != (char *) NULL) | |
972 | { | |
973 | for (i = 0; i < numElements; i++) | |
974 | { | |
975 | content[i] = (TuiWinElementPtr) elementBlockPtr; | |
976 | initContentElement (content[i], type); | |
977 | elementBlockPtr += sizeof (TuiWinElement); | |
978 | } | |
979 | } | |
980 | else | |
981 | { | |
982 | tuiFree ((char *) content); | |
983 | content = (TuiWinContent) NULL; | |
984 | } | |
985 | } | |
986 | } | |
987 | ||
988 | return content; | |
989 | } /* allocContent */ | |
990 | ||
991 | ||
992 | /* | |
c5aa993b JM |
993 | ** addContentElements(). |
994 | ** Adds the input number of elements to the windows's content. If | |
995 | ** no content has been allocated yet, allocContent() is called to | |
996 | ** do this. The index of the first element added is returned, | |
997 | ** unless there is a memory allocation error, in which case, (-1) | |
998 | ** is returned. | |
999 | */ | |
c906108c | 1000 | int |
eca6576c | 1001 | addContentElements (TuiGenWinInfoPtr winInfo, int numElements) |
c906108c SS |
1002 | { |
1003 | TuiWinElementPtr elementPtr; | |
1004 | int i, indexStart; | |
1005 | ||
1006 | if (winInfo->content == (OpaquePtr) NULL) | |
1007 | { | |
1008 | winInfo->content = (OpaquePtr) allocContent (numElements, winInfo->type); | |
1009 | indexStart = 0; | |
1010 | } | |
1011 | else | |
1012 | indexStart = winInfo->contentSize; | |
1013 | if (winInfo->content != (OpaquePtr) NULL) | |
1014 | { | |
1015 | for (i = indexStart; (i < numElements + indexStart); i++) | |
1016 | { | |
1017 | if ((elementPtr = (TuiWinElementPtr) | |
1018 | xmalloc (sizeof (TuiWinElement))) != (TuiWinElementPtr) NULL) | |
1019 | { | |
1020 | winInfo->content[i] = (Opaque) elementPtr; | |
1021 | initContentElement (elementPtr, winInfo->type); | |
1022 | winInfo->contentSize++; | |
1023 | } | |
c5aa993b | 1024 | else /* things must be really hosed now! We ran out of memory!? */ |
c906108c SS |
1025 | return (-1); |
1026 | } | |
1027 | } | |
1028 | ||
1029 | return indexStart; | |
1030 | } /* addContentElements */ | |
1031 | ||
1032 | ||
1033 | /* | |
c5aa993b JM |
1034 | ** tuiDelWindow(). |
1035 | ** Delete all curses windows associated with winInfo, leaving everything | |
1036 | ** else in tact. | |
1037 | */ | |
c906108c | 1038 | void |
eca6576c | 1039 | tuiDelWindow (TuiWinInfoPtr winInfo) |
c906108c SS |
1040 | { |
1041 | Opaque detail; | |
1042 | int i; | |
1043 | TuiGenWinInfoPtr genericWin; | |
1044 | ||
1045 | ||
1046 | switch (winInfo->generic.type) | |
1047 | { | |
1048 | case SRC_WIN: | |
1049 | case DISASSEM_WIN: | |
1050 | genericWin = locatorWinInfoPtr (); | |
1051 | if (genericWin != (TuiGenWinInfoPtr) NULL) | |
1052 | { | |
1053 | tuiDelwin (genericWin->handle); | |
1054 | genericWin->handle = (WINDOW *) NULL; | |
1055 | genericWin->isVisible = FALSE; | |
1056 | } | |
1057 | genericWin = winInfo->detail.sourceInfo.executionInfo; | |
1058 | if (genericWin != (TuiGenWinInfoPtr) NULL) | |
1059 | { | |
1060 | tuiDelwin (genericWin->handle); | |
1061 | genericWin->handle = (WINDOW *) NULL; | |
1062 | genericWin->isVisible = FALSE; | |
1063 | } | |
1064 | break; | |
1065 | case DATA_WIN: | |
1066 | if (winInfo->generic.content != (OpaquePtr) NULL) | |
1067 | { | |
1068 | int i; | |
1069 | ||
1070 | tuiDelDataWindows ( | |
1071 | winInfo->detail.dataDisplayInfo.regsContent, | |
1072 | winInfo->detail.dataDisplayInfo.regsContentCount); | |
1073 | tuiDelDataWindows ( | |
1074 | winInfo->detail.dataDisplayInfo.dataContent, | |
1075 | winInfo->detail.dataDisplayInfo.dataContentCount); | |
1076 | } | |
1077 | break; | |
1078 | default: | |
1079 | break; | |
1080 | } | |
1081 | if (winInfo->generic.handle != (WINDOW *) NULL) | |
1082 | { | |
1083 | tuiDelwin (winInfo->generic.handle); | |
1084 | winInfo->generic.handle = (WINDOW *) NULL; | |
1085 | winInfo->generic.isVisible = FALSE; | |
1086 | } | |
1087 | ||
1088 | return; | |
1089 | } /* tuiDelWindow */ | |
1090 | ||
1091 | ||
1092 | /* | |
c5aa993b JM |
1093 | ** freeWindow(). |
1094 | */ | |
c906108c | 1095 | void |
eca6576c | 1096 | freeWindow (TuiWinInfoPtr winInfo) |
c906108c SS |
1097 | { |
1098 | Opaque detail; | |
1099 | int i; | |
1100 | TuiGenWinInfoPtr genericWin; | |
1101 | ||
1102 | ||
1103 | switch (winInfo->generic.type) | |
1104 | { | |
1105 | case SRC_WIN: | |
1106 | case DISASSEM_WIN: | |
1107 | genericWin = locatorWinInfoPtr (); | |
1108 | if (genericWin != (TuiGenWinInfoPtr) NULL) | |
1109 | { | |
1110 | tuiDelwin (genericWin->handle); | |
1111 | genericWin->handle = (WINDOW *) NULL; | |
1112 | } | |
1113 | freeWinContent (genericWin); | |
1114 | genericWin = winInfo->detail.sourceInfo.executionInfo; | |
1115 | if (genericWin != (TuiGenWinInfoPtr) NULL) | |
1116 | { | |
1117 | tuiDelwin (genericWin->handle); | |
1118 | genericWin->handle = (WINDOW *) NULL; | |
1119 | freeWinContent (genericWin); | |
1120 | } | |
1121 | break; | |
1122 | case DATA_WIN: | |
1123 | if (winInfo->generic.content != (OpaquePtr) NULL) | |
1124 | { | |
1125 | freeDataContent ( | |
1126 | winInfo->detail.dataDisplayInfo.regsContent, | |
1127 | winInfo->detail.dataDisplayInfo.regsContentCount); | |
1128 | winInfo->detail.dataDisplayInfo.regsContent = | |
1129 | (TuiWinContent) NULL; | |
1130 | winInfo->detail.dataDisplayInfo.regsContentCount = 0; | |
1131 | freeDataContent ( | |
1132 | winInfo->detail.dataDisplayInfo.dataContent, | |
1133 | winInfo->detail.dataDisplayInfo.dataContentCount); | |
1134 | winInfo->detail.dataDisplayInfo.dataContent = | |
1135 | (TuiWinContent) NULL; | |
1136 | winInfo->detail.dataDisplayInfo.dataContentCount = 0; | |
1137 | winInfo->detail.dataDisplayInfo.regsDisplayType = | |
1138 | TUI_UNDEFINED_REGS; | |
1139 | winInfo->detail.dataDisplayInfo.regsColumnCount = 1; | |
1140 | winInfo->detail.dataDisplayInfo.displayRegs = FALSE; | |
1141 | winInfo->generic.content = (OpaquePtr) NULL; | |
1142 | winInfo->generic.contentSize = 0; | |
1143 | } | |
1144 | break; | |
1145 | default: | |
1146 | break; | |
1147 | } | |
1148 | if (winInfo->generic.handle != (WINDOW *) NULL) | |
1149 | { | |
1150 | tuiDelwin (winInfo->generic.handle); | |
1151 | winInfo->generic.handle = (WINDOW *) NULL; | |
1152 | freeWinContent (&winInfo->generic); | |
1153 | } | |
b8c9b27d | 1154 | xfree (winInfo); |
c906108c SS |
1155 | |
1156 | return; | |
1157 | } /* freeWindow */ | |
1158 | ||
1159 | ||
1160 | /* | |
c5aa993b JM |
1161 | ** freeAllSourceWinsContent(). |
1162 | */ | |
c906108c | 1163 | void |
c906108c | 1164 | freeAllSourceWinsContent (void) |
c906108c SS |
1165 | { |
1166 | int i; | |
1167 | ||
1168 | for (i = 0; i < (sourceWindows ())->count; i++) | |
1169 | { | |
1170 | TuiWinInfoPtr winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[i]; | |
1171 | ||
1172 | if (m_winPtrNotNull (winInfo)) | |
1173 | { | |
1174 | freeWinContent (&(winInfo->generic)); | |
1175 | freeWinContent (winInfo->detail.sourceInfo.executionInfo); | |
1176 | } | |
1177 | } | |
1178 | ||
1179 | return; | |
1180 | } /* freeAllSourceWinsContent */ | |
1181 | ||
1182 | ||
1183 | /* | |
c5aa993b JM |
1184 | ** freeWinContent(). |
1185 | */ | |
c906108c | 1186 | void |
eca6576c | 1187 | freeWinContent (TuiGenWinInfoPtr winInfo) |
c906108c SS |
1188 | { |
1189 | if (winInfo->content != (OpaquePtr) NULL) | |
1190 | { | |
1191 | freeContent ((TuiWinContent) winInfo->content, | |
1192 | winInfo->contentSize, | |
1193 | winInfo->type); | |
1194 | winInfo->content = (OpaquePtr) NULL; | |
1195 | } | |
1196 | winInfo->contentSize = 0; | |
1197 | ||
1198 | return; | |
1199 | } /* freeWinContent */ | |
1200 | ||
1201 | ||
1202 | /* | |
c5aa993b JM |
1203 | ** freeAllWindows(). |
1204 | */ | |
c906108c | 1205 | void |
c906108c | 1206 | freeAllWindows (void) |
c906108c SS |
1207 | { |
1208 | TuiWinType type = SRC_WIN; | |
1209 | ||
1210 | for (; type < MAX_MAJOR_WINDOWS; type++) | |
1211 | if (m_winPtrNotNull (winList[type]) && | |
1212 | winList[type]->generic.type != UNDEFINED_WIN) | |
1213 | freeWindow (winList[type]); | |
1214 | return; | |
1215 | } /* freeAllWindows */ | |
1216 | ||
1217 | ||
1218 | void | |
eca6576c | 1219 | tuiDelDataWindows (TuiWinContent content, int contentSize) |
c906108c SS |
1220 | { |
1221 | int i; | |
1222 | ||
1223 | /* | |
c5aa993b JM |
1224 | ** Remember that data window content elements are of type TuiGenWinInfoPtr, |
1225 | ** each of which whose single element is a data element. | |
1226 | */ | |
c906108c SS |
1227 | for (i = 0; i < contentSize; i++) |
1228 | { | |
1229 | TuiGenWinInfoPtr genericWin = &content[i]->whichElement.dataWindow; | |
1230 | ||
1231 | if (genericWin != (TuiGenWinInfoPtr) NULL) | |
1232 | { | |
1233 | tuiDelwin (genericWin->handle); | |
1234 | genericWin->handle = (WINDOW *) NULL; | |
1235 | genericWin->isVisible = FALSE; | |
1236 | } | |
1237 | } | |
1238 | ||
1239 | return; | |
1240 | } /* tuiDelDataWindows */ | |
1241 | ||
1242 | ||
1243 | void | |
eca6576c | 1244 | freeDataContent (TuiWinContent content, int contentSize) |
c906108c SS |
1245 | { |
1246 | int i; | |
1247 | ||
1248 | /* | |
c5aa993b JM |
1249 | ** Remember that data window content elements are of type TuiGenWinInfoPtr, |
1250 | ** each of which whose single element is a data element. | |
1251 | */ | |
c906108c SS |
1252 | for (i = 0; i < contentSize; i++) |
1253 | { | |
1254 | TuiGenWinInfoPtr genericWin = &content[i]->whichElement.dataWindow; | |
1255 | ||
1256 | if (genericWin != (TuiGenWinInfoPtr) NULL) | |
1257 | { | |
1258 | tuiDelwin (genericWin->handle); | |
1259 | genericWin->handle = (WINDOW *) NULL; | |
1260 | freeWinContent (genericWin); | |
1261 | } | |
1262 | } | |
1263 | freeContent (content, | |
1264 | contentSize, | |
1265 | DATA_WIN); | |
1266 | ||
1267 | return; | |
1268 | } /* freeDataContent */ | |
1269 | ||
1270 | ||
1271 | /********************************** | |
1272 | ** LOCAL STATIC FUNCTIONS ** | |
1273 | **********************************/ | |
1274 | ||
1275 | ||
1276 | /* | |
c5aa993b JM |
1277 | ** freeContent(). |
1278 | */ | |
c906108c | 1279 | static void |
eca6576c | 1280 | freeContent (TuiWinContent content, int contentSize, TuiWinType winType) |
c906108c SS |
1281 | { |
1282 | if (content != (TuiWinContent) NULL) | |
1283 | { | |
1284 | freeContentElements (content, contentSize, winType); | |
1285 | tuiFree ((char *) content); | |
1286 | } | |
1287 | ||
1288 | return; | |
1289 | } /* freeContent */ | |
1290 | ||
1291 | ||
1292 | /* | |
c5aa993b JM |
1293 | ** freeContentElements(). |
1294 | */ | |
c906108c | 1295 | static void |
eca6576c | 1296 | freeContentElements (TuiWinContent content, int contentSize, TuiWinType type) |
c906108c SS |
1297 | { |
1298 | if (content != (TuiWinContent) NULL) | |
1299 | { | |
1300 | int i; | |
1301 | ||
1302 | if (type == SRC_WIN || type == DISASSEM_WIN) | |
1303 | { | |
1304 | /* free whole source block */ | |
1305 | if (content[0]->whichElement.source.line != (char *) NULL) | |
1306 | tuiFree (content[0]->whichElement.source.line); | |
1307 | } | |
1308 | else | |
1309 | { | |
1310 | for (i = 0; i < contentSize; i++) | |
1311 | { | |
1312 | TuiWinElementPtr element; | |
1313 | ||
1314 | element = content[i]; | |
1315 | if (element != (TuiWinElementPtr) NULL) | |
1316 | { | |
1317 | switch (type) | |
1318 | { | |
1319 | case DATA_WIN: | |
1320 | tuiFree ((char *) element); | |
1321 | break; | |
1322 | case DATA_ITEM_WIN: | |
1323 | /* | |
c5aa993b JM |
1324 | ** Note that data elements are not allocated |
1325 | ** in a single block, but individually, as needed. | |
1326 | */ | |
c906108c SS |
1327 | if (element->whichElement.data.type != TUI_REGISTER) |
1328 | tuiFree ((char *) | |
1329 | element->whichElement.data.name); | |
1330 | tuiFree ((char *) element->whichElement.data.value); | |
1331 | tuiFree ((char *) element); | |
1332 | break; | |
1333 | case CMD_WIN: | |
1334 | tuiFree ((char *) element->whichElement.command.line); | |
1335 | break; | |
1336 | default: | |
1337 | break; | |
1338 | } | |
1339 | } | |
1340 | } | |
1341 | } | |
1342 | if (type != DATA_WIN && type != DATA_ITEM_WIN) | |
1343 | tuiFree ((char *) content[0]); /* free the element block */ | |
1344 | } | |
1345 | ||
1346 | return; | |
1347 | } /* freeContentElements */ |