Jspice3
provide.c File Reference
#include "spice.h"
#include "hlpdefs.h"
Include dependency graph for provide.c:

Go to the source code of this file.

Functions

void hlp_provide (topic *top)
 
void hlp_fixchildren (topic *top)
 
void hlp_killfamily (topic *top)
 

Variables

bool hlp_usex
 

Function Documentation

void hlp_fixchildren ( topic top)

Definition at line 75 of file provide.c.

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 }
struct topic * parent
Definition: hlpdefs.h:57
struct topic * lastborn
Definition: hlpdefs.h:58
Definition: hlpdefs.h:48
struct topic * sibling
Definition: hlpdefs.h:59
void hlp_killfamily ( topic top)

Definition at line 100 of file provide.c.

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_xkillwin()
void hlp_tkillwin()
void hlp_killfamily(topic *top)
Definition: provide.c:100
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
void hlp_provide ( topic top)

Definition at line 19 of file provide.c.

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 }
void hlp_fixchildren(topic *top)
Definition: provide.c:75
Definition: sced.h:172
bool hlp_tdisplay()
bool hlp_xdisplay()
int xposition
Definition: hlpdefs.h:55
struct topic * parent
Definition: hlpdefs.h:57
toplink * hlp_thandle()
topic * hlp_read()
void hlp_killfamily(topic *top)
Definition: provide.c:100
bool hlp_usex
Definition: provide.c:15
struct topic * lastborn
Definition: hlpdefs.h:58
Definition: hlpdefs.h:48
struct topic * sibling
Definition: hlpdefs.h:59
int yposition
Definition: hlpdefs.h:56

Variable Documentation

bool hlp_usex

Definition at line 15 of file provide.c.