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