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