Jspice3
provide.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1986 Wayne A. Christopher
5  1992 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 /*
9  * Toss the help window up on the screen, and deal with the graph...
10  */
11 
12 #include "spice.h"
13 #include "hlpdefs.h"
14 
15 bool hlp_usex;
16 
17 
18 void
20 
21 topic *top;
22 {
23  toplink *res;
24  topic *parent, *newtop;
25 
26  if (!top)
27  return;
28 
29  top->xposition = top->yposition = 0;
30  if (hlp_usex) {
31  if (!hlp_xdisplay(top)) {
32  fprintf(stderr, "Couldn't open X display.\n");
33  }
34  /* X does this asynchronously */
35  return;
36  }
37 
38  if (!hlp_tdisplay(top)) {
39  fprintf(stderr, "Couldn't display text\n");
40  return;
41  }
42 
43  for (;;) {
44  res = hlp_thandle(&parent);
45  if (!res && !parent) {
46  /* No more windows. */
47  return;
48  }
49  if (res) {
50  /* Create a new window... */
51  if (!(newtop = hlp_read(res->keyword))) {
52  fprintf(stderr, "Internal error: bad link\n");
53  continue;
54  }
55  newtop->sibling = parent->lastborn;
56  parent->lastborn = newtop;
57  newtop->parent = parent;
58  newtop->xposition = parent->xposition + 50;
59  newtop->yposition = parent->yposition + 50;
60  if (!hlp_tdisplay(newtop)) {
61  fprintf(stderr, "Couldn't display\n");
62  return;
63  }
64  }
65  else {
66  /* Blow this one and its descendants away. */
67  hlp_fixchildren(parent);
68  hlp_killfamily(parent);
69  }
70  }
71 }
72 
73 
74 void
76 
77 topic *top;
78 {
79  topic *tp;
80  /* unlink top from the tree */
81 
82  if (top->parent) {
83  if (top->parent->lastborn == top)
84  top->parent->lastborn = top->sibling;
85  else {
86  for (tp = top->parent->lastborn;
87  tp->sibling; tp = tp->sibling)
88  if (tp->sibling == top)
89  break;
90  if (!tp->sibling) {
91  fprintf(stderr, "bah...\n");
92  }
93  tp->sibling = tp->sibling->sibling;
94  }
95  }
96 }
97 
98 
99 void
101 
102 topic *top;
103 {
104  topic *tp;
105 
106  for (tp = top->lastborn; tp; tp = tp->sibling)
107  hlp_killfamily(tp);
108  if (hlp_usex)
109  hlp_xkillwin(top);
110  else
111  hlp_tkillwin(top);
112  hlp_free(top);
113 }
void hlp_fixchildren(topic *top)
Definition: provide.c:75
void hlp_xkillwin()
Definition: sced.h:172
bool hlp_tdisplay()
bool hlp_xdisplay()
int xposition
Definition: hlpdefs.h:55
struct topic * parent
Definition: hlpdefs.h:57
void hlp_tkillwin()
toplink * hlp_thandle()
topic * hlp_read()
void hlp_killfamily(topic *top)
Definition: provide.c:100
void hlp_provide(topic *top)
Definition: provide.c:19
bool hlp_usex
Definition: provide.c:15
struct topic * lastborn
Definition: hlpdefs.h:58
Definition: hlpdefs.h:48
void hlp_free()
struct topic * sibling
Definition: hlpdefs.h:59
int yposition
Definition: hlpdefs.h:56