File: provide.c

package info (click to toggle)
kic 2.4c-3
  • links: PTS, VCS
  • area: non-free
  • in suites: trixie
  • size: 2,320 kB
  • sloc: ansic: 37,457; sh: 3,317; makefile: 407; lisp: 109
file content (104 lines) | stat: -rw-r--r-- 2,795 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*************************************************************************
 *
 * Enhanced KIC layout editor - Stephen R. Whiteley, 1992
 *
 *************************************************************************
 * Original header:
 *
 * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group 
 *     faustus@cad.berkeley.edu, ucbvax!faustus
 * Permission is granted to modify and re-distribute this code in any manner
 * as long as this notice is preserved.  All standard disclaimers apply.
 *
 *************************************************************************/

#include "prefix.h"
#include "hlpdefs.h"

#if __STDC__
static void killfamily(topic*);
#else
static void killfamily();
#endif


void
hlp_provide(top)

topic *top;
{
    toplink *res;
    topic *parent, *newtop, *pa;

    if (top == NULL) return;

    top->xposition = top->yposition = 0;
    if (!hlp_tdisplay(top)) {
        err_printf("Couldn't display text\n");
        return;
    }
    
    for (;;) {
        res = hlp_thandle(&parent);
        if (!res && !parent) {
            /* No more windows. */
            killfamily(top);
            return;
        }
        if (res) {
            /* Create a new window... */
            if (!(newtop = hlp_read(res->keyword))) {
                err_printf("Internal error: bad link\n");
                continue;
            }
            newtop->next = parent->children;
            parent->children = newtop;
            newtop->parent = parent;
            newtop->xposition = parent->xposition + 50;
            newtop->yposition = parent->yposition + 50;
            if (!hlp_tdisplay(newtop)) {
                fprintf(cp_err, "Couldn't display\n"); 
                return; 
            }
        }
        else {
            /* Blow this one and its descendants away. */
            killfamily(parent);
            if (parent->parent) {
                if (parent->parent->children == parent)
                    parent->parent->children =
                            parent->next;
                else {
                    for (pa = parent->parent->children;
                            pa->next; pa = pa->next)
                        if (pa->next == parent)
                            break;
                    if (!pa->next) {
                        err_printf("bah...\n");
                    }
                    pa->next = pa->next->next;
                }
            }
            if (parent == top)
                return;
        }
    }
}

/* Note that this doesn't actually free the data structures, just gets
 * rid of the window.
 */

static void
killfamily(top)

topic *top;
{
    topic *ch;

    for (ch = top->children; ch; ch = ch->next)
        killfamily(ch);
    hlp_tkillwin(top);
    top->children = NULL;
    return;
}