Debian Codegraph @

reports/pdesc.ll

raw
1 /*
2 * @progname pdesc.ll
3 * @version 4.3
4 * @author Wetmore, Manis, Jones, Eggert, Simms
5 * @category
6 * @output Text
7 * @description
8 *
9 * Produces indented descendant list with line wrapping at 78 columns
10 * (user-specifiable) while maintaining the indentation level. Enhancement
11 * from version 2 is the addition of user-specified maximum number of
12 * generations. Version 4 makes the page_width (not 1 less) the limit on
13 * character a shift inplacement. Also eliminated an extra space at the
14 * beginning of each line that was not controlled by a left_margin parameter.
15 *
16 * Code by Tom Wetmore, [email protected]
17 * With modifications by: Cliff Manis
18 * With modifications by: James P. Jones
19 * With modifications by: Jim Eggert (unknown spouse bugfix)
20 * With modifications by: Robert Simms (indented line wrap) Mar '96
21 * (max number of generations) Jun '97
22 * (line wrap cleaned up) 16 Feb 2000
23 * With modifications by: Vincent Broman (header cleanup) 2003-02
24 *
25 * This report works only with the LifeLines Genealogy program
26 *
27 * version one of this report was written by Tom Wetmore, in 1990.
28 *
29 * It will select and produce a descendant report for the person
30 * selected. Children of each spouse are printed below that spouse.
31 *
32 * Descendants report format, which print the date in long format.
33 *
34 * Output is an ASCII file.
35 */
36
37 global(page_size)
38 global(tab_size)
39 global(max_depth)
40 global(left_margin)
41
42 proc main () {
43 set(page_size, 78)
44 set(tab_size, 3) /* extra indentation upon line-wrap */
45 set(left_margin, 0)
46
47 getindi(indi)
48 getintmsg (max_depth, "Maximum number of generations")
49 set(skip, left_margin)
50 call pout(0, indi)
51
52 "===============================================" nl()
53 }
54
55 proc pout(gen, indi) {
56 set(skip, mul(4,gen))
57 col(add(skip, 1))
58 set(x, skip)
59 set(s, concat(d(add(gen, 1)), "--"))
60 s
61 set(x, add(x, tab_size))
62 set(skip, x)
63 call outp(indi, skip, x)
64 set(next, add(1, gen))
65 families(indi,fam,sp,num) {
66 set(skip, add(2,mul(4,gen)))
67 col(add(skip, 1))
68 set(x, skip)
69 "sp-"
70 /* Don't try to show a spouse name if none known */
71 if (sp) {
72 set(x, add(x, 4))
73 set(skip, x)
74 call outp(sp, skip, x)
75 } else {
76 "Unknown" nl()
77 }
78 if (lt(next,max_depth)) {
79 children(fam, child, no) {
80 call pout(next, child)
81 }
82 }
83 }
84 }
85
86 proc outp(indi, skip, x) {
87 set(s, concat(fullname(indi, 1, 1, 40),
88 " (",
89 long(birth(indi)),
90 " - ",
91 long(death(indi)),
92 ")"))
93 set(x, outline(s, add(tab_size, skip), x))
94 "\n"
95 }
96
97 func outline(text, skip, x) {
98 if (eq(x, 0)) {
99 col(add(skip, 1))
100 set(x, skip)
101 }
102 set(max, sub(page_size, x))
103 if (gt(strlen(text), max)) {
104 set(space, breakit(text, max))
105 if (eq(space, 0)) {
106 if (eq(x, skip)) {
107 set(text, strsave(text))
108 substring(text, 1, sub(max, 1)) "-"
109 set(x, 0)
110 set(text, substring(text, max, strlen(text)))
111 set(x, outline(text, skip, x))
112 } else {
113 set(x, 0)
114 set(x, outline(text, skip, x))
115 }
116 } else { /* space gt 0 */
117 set(text, strsave(text))
118 substring(text, 1, sub(space, 1))
119 set(x, 0)
120 set(text, strsave(substring(text, add(space, 1), strlen(text))))
121 while(eqstr(" ", substring(text, 1, 1))) { /* strip leading spaces */
122 set(text, strsave(substring(text, 2, strlen(text))))
123 }
124 set(x, outline(text, skip, x))
125 }
126 } else {
127 text
128 set(x, add(x, strlen(text)))
129 }
130 return(x)
131 }
132
133 func breakit(text, max) {
134 set(space, 0)
135 set(occ, 1)
136 set(next, index(text, " ", occ))
137 incr(occ)
138 while ( and(le(next, add(max, 1)), ne (next, 0))) {
139 set(space, next)
140 set(next, index(text, " ", occ))
141 incr(occ)
142 }
143 return(space)
144 }