Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/guisupport/brt.cpp @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /* | |
2 * AnaGram, A System for Syntax Directed Programming | |
3 * Copyright 1993-2002 Parsifal Software. All Rights Reserved. | |
4 * See the file COPYING for license and usage terms. | |
5 * | |
6 * brt.cpp | |
7 */ | |
8 | |
9 #include "assert.h" | |
10 #include "brt.h" | |
11 #include "configparam.h" | |
12 #include "dc.h" | |
13 #include "dict.h" | |
14 #include "help.h" | |
15 #include "stacks.h" | |
16 | |
17 //#define INCLUDE_LOGGING | |
18 #include "log.h" | |
19 | |
20 | |
21 help_index_dc::help_index_dc(void) | |
22 : dc("Help Topics") | |
23 { | |
24 LOGSECTION("help_index_dc::help_index_dc"); | |
25 | |
26 unsigned ntopics = helpindex_num(); | |
27 LOGV(ntopics); | |
28 | |
29 unsigned dw = 0; | |
30 for (unsigned i=0; i<ntopics; i++) { | |
31 unsigned sw = strlen(helpindex_get(i)); | |
32 if (sw > dw) { | |
33 dw = sw; | |
34 } | |
35 } | |
36 | |
37 des->d_size = cint(dw, ntopics); | |
38 | |
39 syntax_dependent = 0; | |
40 LOGS("All done"); | |
41 } | |
42 | |
43 AgString help_index_dc::findHelpTopic(void) { | |
44 return helpindex_get(des->c_loc_doc.y); | |
45 } | |
46 | |
47 void help_index_dc::getLine(unsigned ln) const { | |
48 const char *s = helpindex_get(ln); | |
49 sss(s); | |
50 } | |
51 | |
52 static int param_table_tabs[3] = {24,0}; | |
53 | |
54 void param_table_dc::getLine(unsigned ln) const { | |
55 LOGSECTION("param_table_dc::getLine"); | |
56 ConfigParam ¶m = *ConfigParam::table[ln]; | |
57 LOGV(ln) LCV(param.name); | |
58 ssprintf("%s\t%s", param.name, param.asString().pointer()); | |
59 //sss(ConfigParam::table[ln]->asString().pointer()); | |
60 } | |
61 | |
62 param_table_dc::param_table_dc(void) | |
63 : dc("Configuration Parameters") | |
64 { | |
65 LOGSECTION("param_table_dc::param_table_dc"); | |
66 | |
67 int n = ConfigParam::paramCount; | |
68 int i = 1; | |
69 int sl, cw; | |
70 | |
71 cw = 0; | |
72 while (i < n) { | |
73 sl = strlen(ConfigParam::table[i++]->asString().pointer()); | |
74 if (sl > cw) { | |
75 cw = sl; | |
76 } | |
77 } | |
78 | |
79 param_table_tabs[0] = cw + 2; | |
80 tab_stops = param_table_tabs; | |
81 columnHeadTitle = "Parameter\tValue"; | |
82 | |
83 des->d_size = cint(2*cw + 1, n); | |
84 syntax_dependent = 1; | |
85 } | |
86 | |
87 AgString param_table_dc::findHelpTopic(void) { | |
88 LOGSECTION("param_table_dc::findHelpTopic"); | |
89 int i; | |
90 int length; | |
91 | |
92 getLine(des->c_loc_doc.y); | |
93 LOGV(des->c_loc_doc.y) LCV(string_base); | |
94 length = strlen(string_base); | |
95 for (i = 0; string_base[i] == ' '; i++); | |
96 //title = &string_base[i]; | |
97 for (i = length; string_base[--i] != '\t'; ) { | |
98 /* Nothing to do */ | |
99 } | |
100 | |
101 string_base[i] = 0; | |
102 AgString topic = string_base; | |
103 rcs(); | |
104 LOGV(topic); | |
105 return topic; | |
106 } | |
107 | |
108 | |
109 | |
110 // text_window_dc | |
111 | |
112 void text_window_dc::getLine(unsigned ln) const { | |
113 char *ptr = text.pointer(); | |
114 unsigned k = 0; | |
115 char c; | |
116 assert(text.exists()); | |
117 while (k < ln) { | |
118 ptr = 1+strchr(ptr, '\n'); | |
119 k++; | |
120 } | |
121 ics(); | |
122 while (1) { | |
123 c = *ptr++; | |
124 if (c == '\n' || c== 0) { | |
125 break; | |
126 } | |
127 acs(c); | |
128 } | |
129 } | |
130 | |
131 text_window_dc::text_window_dc(AgString title, AgString text_arg) | |
132 : dc(title) | |
133 { | |
134 int dw, dp; | |
135 char *p, *base = text_arg.pointer(); | |
136 | |
137 text = text_arg; | |
138 dw = 0; | |
139 dp = 0; | |
140 while (1) { | |
141 int w; | |
142 | |
143 p = strchr(base, '\n'); | |
144 if (p == NULL) { | |
145 break; | |
146 } | |
147 dp++; | |
148 w = (int)(p - base); | |
149 if (w > dw) { | |
150 dw = w; | |
151 } | |
152 base = p+1; | |
153 } | |
154 des->d_size = cint(dw, dp); | |
155 syntax_dependent = 0; | |
156 } | |
157 |