Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/guisupport/dc.h @ 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 * dc.h - display contexts | |
7 */ | |
8 | |
9 #ifndef DC_H | |
10 #define DC_H | |
11 | |
12 class WindowConnector; // from wdata.h | |
13 #include "agstring.h" | |
14 #include "cint.h" | |
15 | |
16 struct wd { | |
17 const char *head_title_display; | |
18 const char *foot_title_display; | |
19 int refresh; /* increment to refresh */ | |
20 cint c_loc_doc; /* location of cursor on document */ | |
21 cint d_size; /* size of document */ | |
22 }; | |
23 | |
24 struct dc { | |
25 // Reference control | |
26 | |
27 int usage_count; | |
28 | |
29 class ref { | |
30 protected: | |
31 dc *window; | |
32 | |
33 public: | |
34 ref(void); | |
35 ref(dc *x); | |
36 ref(const ref &x); | |
37 | |
38 ref &operator =(const ref &x); | |
39 ref &operator =(dc *x); | |
40 ~ref(void); | |
41 | |
42 void discardData(void); | |
43 int exists(void) const { return window != NULL; } | |
44 | |
45 operator dc *(void) const; | |
46 dc *operator ->(void) const; | |
47 int operator ==(const ref &x) const { return window == x.window; } | |
48 int operator !=(const ref &x) const { return window != x.window; } | |
49 }; | |
50 | |
51 AgString head_title, foot_title; | |
52 AgString columnHeadTitle; | |
53 | |
54 dc *id; | |
55 | |
56 wd *des; /* describes desired window */ | |
57 WindowConnector *windowConnector; | |
58 | |
59 int *tab_stops; | |
60 | |
61 | |
62 unsigned syntax_dependent : 1; | |
63 | |
64 void init_dc(void); | |
65 void clear_data(void); | |
66 | |
67 dc(void); | |
68 | |
69 dc(const AgString head); | |
70 dc(const AgString head, const AgString foot); | |
71 dc(dc &x); | |
72 | |
73 virtual ~dc(); | |
74 | |
75 struct MenuOption { | |
76 const char *option_name; | |
77 void (dc:: * action)(); | |
78 int (dc:: * ok_action)(); | |
79 MenuOption() : option_name(0) {} | |
80 MenuOption(const char *name) : option_name(name) {} | |
81 virtual ~MenuOption() {} | |
82 virtual ref getAuxWindow(ref, unsigned) { return ref(); } | |
83 }; | |
84 | |
85 virtual AgString findHelpTopic(); | |
86 virtual MenuOption **getAuxWinMenu(void) { return NULL; } | |
87 virtual ref anomaly_trace(unsigned) { return ref(); } | |
88 virtual ref aux_trace(unsigned) { return ref(); } | |
89 virtual ref derive_rule(unsigned) { return ref(); } | |
90 virtual ref derive_token(unsigned) { return ref(); } | |
91 virtual ref expansion_chain(unsigned) { return ref(); } | |
92 virtual ref expansion_rules(unsigned) { return ref(); } | |
93 virtual ref keywords(unsigned) { return ref(); } | |
94 virtual ref partition_sets(unsigned) { return ref(); } | |
95 virtual ref previous_states(unsigned) { return ref(); } | |
96 virtual ref problem_states(unsigned) { return ref(); } | |
97 virtual ref productions(unsigned) { return ref(); } | |
98 | |
99 virtual ref reduction_states(unsigned) { return ref(); } | |
100 virtual ref reduction_trace(unsigned) { return ref(); } | |
101 virtual ref rule_context(unsigned) { return ref(); } | |
102 //virtual ref rule_stack(unsigned) { return ref(); } | |
103 virtual ref select_conflict(unsigned) { return ref(); } | |
104 virtual ref set_elements(unsigned) { return ref(); } | |
105 virtual ref state_definition(unsigned) { return ref(); } | |
106 virtual ref state_expansion(unsigned) { return ref(); } | |
107 virtual ref usage(unsigned) { return ref(); } | |
108 | |
109 virtual int derive_rule_ok(unsigned) { return 1; } | |
110 virtual int expansion_chain_ok(unsigned) { return 1; } | |
111 virtual int expansion_rules_ok(unsigned) { return 1; } | |
112 virtual int keywords_ok(unsigned) { return 1; } | |
113 virtual int previous_states_ok(unsigned) { return 1; } | |
114 virtual int productions_ok(unsigned) { return 1; } | |
115 | |
116 virtual int reduction_states_ok(unsigned) { return 1; } | |
117 virtual int rule_context_ok(unsigned) { return 1; } | |
118 virtual int set_elements_ok(unsigned) { return 1; } | |
119 virtual int state_expansion_ok(unsigned) { return 1; } | |
120 virtual int usage_ok(unsigned) { return 1; } | |
121 | |
122 void anomaly_trace() ; | |
123 void aux_trace() ; | |
124 void derive_rule() ; | |
125 void derive_token() ; | |
126 void expansion_chain() ; | |
127 void expansion_rules() ; | |
128 void keywords() ; | |
129 void partition_sets() ; | |
130 void previous_states() ; | |
131 void problem_states() ; | |
132 void productions() ; | |
133 | |
134 void reduction_states() ; | |
135 void reduction_trace() ; | |
136 void rule_context() ; | |
137 //void rule_stack() ; | |
138 void select_conflict() ; | |
139 void set_elements() ; | |
140 void state_definition() ; | |
141 void state_expansion() ; | |
142 void usage() ; | |
143 | |
144 int derive_rule_ok() ; | |
145 | |
146 int anomaly_trace_ok() { return 1; } | |
147 int aux_trace_ok() { return 1; } | |
148 int derive_token_ok() { return derive_rule_ok(); } | |
149 int expansion_chain_ok(); | |
150 int expansion_rules_ok(); | |
151 int keywords_ok() ; | |
152 int partition_sets_ok() { return 1; } | |
153 int previous_states_ok(); | |
154 int problem_states_ok() { return derive_rule_ok(); } | |
155 int productions_ok() ; | |
156 | |
157 int reduction_states_ok(); | |
158 int reduction_trace_ok() { return derive_rule_ok(); } | |
159 int rule_context_ok() ; | |
160 //int rule_stack_ok() { return 1; } | |
161 int select_conflict_ok() { return derive_rule_ok(); } | |
162 int set_elements_ok() ; | |
163 int state_definition_ok() { return 1; } | |
164 int state_expansion_ok(); | |
165 int usage_ok() ; | |
166 | |
167 struct AnomalyTraceOption : public MenuOption { | |
168 AnomalyTraceOption(void) : MenuOption("Keyword Anomaly Trace") { | |
169 ok_action = &dc::anomaly_trace_ok; | |
170 action = &dc::anomaly_trace; | |
171 } | |
172 virtual ~AnomalyTraceOption() {} | |
173 virtual ref getAuxWindow(ref d, unsigned ln) { | |
174 return d->anomaly_trace(ln); | |
175 } | |
176 }; | |
177 | |
178 struct AuxiliaryTraceOption : public MenuOption { | |
179 AuxiliaryTraceOption(void) : MenuOption("Auxiliary Trace") { | |
180 ok_action = &dc::aux_trace_ok; | |
181 action = &dc::aux_trace; | |
182 } | |
183 virtual ~AuxiliaryTraceOption() {} | |
184 virtual ref getAuxWindow(ref d, unsigned ln) { | |
185 return d->aux_trace(ln); | |
186 } | |
187 }; | |
188 | |
189 struct ConflictTraceOption : public MenuOption { | |
190 ConflictTraceOption(void) : MenuOption("Conflict Trace") { | |
191 ok_action = &dc::select_conflict_ok; | |
192 action = &dc::select_conflict; | |
193 } | |
194 virtual ~ConflictTraceOption() {} | |
195 virtual ref getAuxWindow(ref d, unsigned ln) { | |
196 return d->select_conflict(ln); | |
197 } | |
198 }; | |
199 | |
200 | |
201 struct ExpansionChainOption : public MenuOption { | |
202 ExpansionChainOption(void) : MenuOption("Expansion Chain") { | |
203 ok_action = &dc::expansion_chain_ok; | |
204 action = &dc::expansion_chain; | |
205 } | |
206 virtual ~ExpansionChainOption() {} | |
207 virtual ref getAuxWindow(ref d, unsigned ln) { | |
208 return d->expansion_chain(ln); | |
209 } | |
210 }; | |
211 | |
212 struct ExpansionRulesOption : public MenuOption { | |
213 ExpansionRulesOption(void) : MenuOption("Expansion Rules") { | |
214 ok_action = &dc::expansion_rules_ok; | |
215 action = &dc::expansion_rules; | |
216 } | |
217 virtual ~ExpansionRulesOption() {} | |
218 virtual ref getAuxWindow(ref d, unsigned ln) { | |
219 return d->expansion_rules(ln); | |
220 } | |
221 }; | |
222 | |
223 struct KeywordsOption : public MenuOption { | |
224 KeywordsOption(void) : MenuOption("Keywords") { | |
225 ok_action = &dc::keywords_ok; | |
226 action = &dc::keywords; | |
227 } | |
228 virtual ~KeywordsOption() {} | |
229 virtual ref getAuxWindow(ref d, unsigned ln) { | |
230 return d->keywords(ln); | |
231 } | |
232 }; | |
233 | |
234 struct PartitionSetsOption : public MenuOption { | |
235 PartitionSetsOption(void) : MenuOption("Partition Sets") { | |
236 ok_action = &dc::partition_sets_ok; | |
237 action = &dc::partition_sets; | |
238 } | |
239 virtual ~PartitionSetsOption() {} | |
240 virtual ref getAuxWindow(ref d, unsigned ln) { | |
241 return d->partition_sets(ln); | |
242 } | |
243 }; | |
244 | |
245 struct PreviousStatesOption : public MenuOption { | |
246 PreviousStatesOption(void) : MenuOption("Previous States") { | |
247 ok_action = &dc::previous_states_ok; | |
248 action = &dc::previous_states; | |
249 } | |
250 virtual ~PreviousStatesOption() {} | |
251 virtual ref getAuxWindow(ref d, unsigned ln) { | |
252 return d->previous_states(ln); | |
253 } | |
254 }; | |
255 | |
256 struct ProblemStatesOption : public MenuOption { | |
257 ProblemStatesOption(void) : MenuOption("Problem States") { | |
258 ok_action = &dc::problem_states_ok; | |
259 action = &dc::problem_states; | |
260 } | |
261 virtual ~ProblemStatesOption() {} | |
262 virtual ref getAuxWindow(ref d, unsigned ln) { | |
263 return d->problem_states(ln); | |
264 } | |
265 }; | |
266 | |
267 struct ProductionsOption : public MenuOption { | |
268 ProductionsOption(void) : MenuOption("Productions") { | |
269 ok_action = &dc::productions_ok; | |
270 action = &dc::productions; | |
271 } | |
272 virtual ~ProductionsOption() {} | |
273 virtual ref getAuxWindow(ref d, unsigned ln) { | |
274 return d->productions(ln); | |
275 } | |
276 }; | |
277 | |
278 struct ReductionStatesOption : public MenuOption { | |
279 ReductionStatesOption(void) : MenuOption("Reduction States") { | |
280 ok_action = &dc::reduction_states_ok; | |
281 action = &dc::reduction_states; | |
282 } | |
283 virtual ~ReductionStatesOption() {} | |
284 virtual ref getAuxWindow(ref d, unsigned ln) { | |
285 return d->reduction_states(ln); | |
286 } | |
287 }; | |
288 | |
289 struct ReductionTraceOption : public MenuOption { | |
290 ReductionTraceOption(void) : MenuOption("Reduction Trace") { | |
291 ok_action = &dc::reduction_trace_ok; | |
292 action = &dc::reduction_trace; | |
293 } | |
294 virtual ~ReductionTraceOption() {} | |
295 virtual ref getAuxWindow(ref d, unsigned ln) { | |
296 return d->reduction_trace(ln); | |
297 } | |
298 }; | |
299 | |
300 struct RuleContextOption : public MenuOption { | |
301 RuleContextOption(void) : MenuOption("Rule Context") { | |
302 ok_action = &dc::rule_context_ok; | |
303 action = &dc::rule_context; | |
304 } | |
305 virtual ~RuleContextOption() {} | |
306 virtual ref getAuxWindow(ref d, unsigned ln) { | |
307 return d->rule_context(ln); | |
308 } | |
309 }; | |
310 | |
311 struct RuleDerivationOption : public MenuOption { | |
312 RuleDerivationOption(void) : MenuOption("Rule Derivation") { | |
313 ok_action = &dc::derive_rule_ok; | |
314 action = &dc::derive_rule; | |
315 } | |
316 virtual ~RuleDerivationOption() {} | |
317 virtual ref getAuxWindow(ref d, unsigned ln) { | |
318 return d->derive_rule(ln); | |
319 } | |
320 }; | |
321 /* | |
322 struct RuleStackOption : public MenuOption { | |
323 RuleStackOption(void) : MenuOption("Rule Stack") { | |
324 ok_action = &dc::rule_stack_ok; | |
325 action = &dc::rule_stack; | |
326 } | |
327 virtual ~RuleStackOption() {} | |
328 virtual ref getAuxWindow(ref d, unsigned ln) { | |
329 return d->rule_stack(ln); | |
330 } | |
331 }; | |
332 */ | |
333 struct SetElementsOption : public MenuOption { | |
334 SetElementsOption(void) : MenuOption("Set Elements") { | |
335 ok_action = &dc::set_elements_ok; | |
336 action = &dc::set_elements; | |
337 } | |
338 virtual ~SetElementsOption() {} | |
339 virtual ref getAuxWindow(ref d, unsigned ln) { | |
340 return d->set_elements(ln); | |
341 } | |
342 }; | |
343 | |
344 struct StateDefinitionOption : public MenuOption { | |
345 StateDefinitionOption(void) : MenuOption("State Definition") { | |
346 ok_action = &dc::state_definition_ok; | |
347 action = &dc::state_definition; | |
348 } | |
349 virtual ~StateDefinitionOption() {} | |
350 virtual ref getAuxWindow(ref d, unsigned ln) { | |
351 return d->state_definition(ln); | |
352 } | |
353 }; | |
354 | |
355 struct StateExpansionOption : public MenuOption { | |
356 StateExpansionOption(void) : MenuOption("State Expansion") { | |
357 ok_action = &dc::state_expansion_ok; | |
358 action = &dc::state_expansion; | |
359 } | |
360 virtual ~StateExpansionOption() {} | |
361 virtual ref getAuxWindow(ref d, unsigned ln) { | |
362 return d->state_expansion(ln); | |
363 } | |
364 }; | |
365 | |
366 struct TokenDerivationOption : public MenuOption { | |
367 TokenDerivationOption(void) : MenuOption("Token Derivation") { | |
368 ok_action = &dc::derive_token_ok; | |
369 action = &dc::derive_token; | |
370 } | |
371 virtual ~TokenDerivationOption() {} | |
372 virtual ref getAuxWindow(ref d, unsigned ln) { | |
373 return d->derive_token(ln); | |
374 } | |
375 }; | |
376 | |
377 struct TokenUsageOption : public MenuOption { | |
378 TokenUsageOption(void): MenuOption("Token Usage") { | |
379 ok_action = &dc::usage_ok; | |
380 action = &dc::usage; | |
381 } | |
382 virtual ~TokenUsageOption() {} | |
383 virtual ref getAuxWindow(ref d, unsigned ln) { | |
384 return d->usage(ln); | |
385 } | |
386 }; | |
387 /* | |
388 static const char *help_gs_msg; | |
389 static const char *help_index_msg; | |
390 static const char *kbd_ref_msg; | |
391 static const char *mouse_ref_msg; | |
392 static const char *using_help_msg; | |
393 static const char *help_wn_msg; | |
394 */ | |
395 | |
396 static AnomalyTraceOption anomalyTraceOptionInstance; | |
397 static AuxiliaryTraceOption auxiliaryTraceOptionInstance; | |
398 static ConflictTraceOption conflictTraceOptionInstance; | |
399 static ExpansionChainOption expansionChainOptionInstance; | |
400 static ExpansionRulesOption expansionRulesOptionInstance; | |
401 static KeywordsOption keywordsOptionInstance; | |
402 static PartitionSetsOption partitionSetsOptionInstance; | |
403 static PreviousStatesOption previousStatesOptionInstance; | |
404 static ProblemStatesOption problemStatesOptionInstance; | |
405 static ProductionsOption productionsOptionInstance; | |
406 static ReductionStatesOption reductionStatesOptionInstance; | |
407 static ReductionTraceOption reductionTraceOptionInstance; | |
408 static RuleContextOption ruleContextOptionInstance; | |
409 static RuleDerivationOption ruleDerivationOptionInstance; | |
410 //static RuleStackOption ruleStackOptionInstance; | |
411 static SetElementsOption setElementsOptionInstance; | |
412 static StateDefinitionOption stateDefinitionOptionInstance; | |
413 static StateExpansionOption stateExpansionOptionInstance; | |
414 static TokenDerivationOption tokenDerivationOptionInstance; | |
415 static TokenUsageOption tokenUsageOptionInstance; | |
416 | |
417 virtual void getLine(unsigned) const; | |
418 virtual void synchCursor(unsigned) const {} | |
419 }; | |
420 | |
421 typedef dc::ref dc_ref; | |
422 | |
423 template <class T> | |
424 class DcRef : public dc::ref { | |
425 public: | |
426 DcRef(void);// {} | |
427 DcRef(T *x);// : dc::ref((dc *) x) {} | |
428 DcRef(const DcRef<T> &x);// : dc::ref(x) {} | |
429 DcRef(dc::ref x);// : dc::ref(x) {} | |
430 | |
431 operator T *() { return (T *) window; } | |
432 T *operator ->(void) | |
433 { return (T *) window; } | |
434 }; | |
435 | |
436 template <class T> | |
437 DcRef<T>::DcRef(void) {} | |
438 template <class T> | |
439 DcRef<T>::DcRef(T *x) : dc::ref((dc *) x) {} | |
440 template <class T> | |
441 DcRef<T>::DcRef(const DcRef<T> &x) : dc::ref(x) {} | |
442 template <class T> | |
443 DcRef<T>::DcRef(dc::ref x) : dc::ref(x) {} | |
444 | |
445 | |
446 #endif /* DC_H */ |