~ubuntu-branches/ubuntu/hardy/texmacs/hardy

« back to all changes in this revision

Viewing changes to src/Typeset/Concat/concat_inactive.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ralf Treinen
  • Date: 2004-04-19 20:34:00 UTC
  • Revision ID: james.westby@ubuntu.com-20040419203400-g4e34ih0315wcn8v
Tags: upstream-1.0.3-R2
ImportĀ upstreamĀ versionĀ 1.0.3-R2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/******************************************************************************
 
3
* MODULE     : concat_inactive.cpp
 
4
* DESCRIPTION: Typesetting of inactive markup
 
5
* COPYRIGHT  : (C) 1999  Joris van der Hoeven
 
6
*******************************************************************************
 
7
* This software falls under the GNU general public license and comes WITHOUT
 
8
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
 
9
* If you don't have this file, write to the Free Software Foundation, Inc.,
 
10
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
11
******************************************************************************/
 
12
 
 
13
#include "concater.hpp"
 
14
 
 
15
/******************************************************************************
 
16
* Typesetting deactivated trees
 
17
******************************************************************************/
 
18
 
 
19
void
 
20
concater_rep::typeset_inactive (tree t, path ip) { 
 
21
  marker (descend (ip, 0));
 
22
  typeset (t[0], descend (ip, 0), false);
 
23
  marker (descend (ip, 1));
 
24
}
 
25
 
 
26
void
 
27
concater_rep::typeset_eval_args (tree t, path ip) { 
 
28
  marker (descend (ip, 0));
 
29
  typeset (env->exec (t), decorate_right (ip), false);
 
30
  marker (descend (ip, 1));
 
31
}
 
32
 
 
33
void
 
34
concater_rep::typeset_inactive (
 
35
  string type, tree t, path ip, int pos1, int pos2)
 
36
{
 
37
  int i, j;
 
38
  tree old_col;
 
39
  penalty_min (0);
 
40
  marker (descend (ip, 0));
 
41
  ghost ("<", descend (ip, 0));
 
42
  ghost (type, descend (ip, 0));
 
43
  for (i=0; i<N(t); i++) {
 
44
    print (space (0, 0, env->fn->spc->max));
 
45
    int start= N(a);
 
46
    print (space (0, 0, env->fn->spc->max));
 
47
    ghost ("|", descend (descend (ip, i), 0));
 
48
    print (space (0, 0, env->fn->spc->max));
 
49
    if (i<N(t)-1) penalty_min (0);
 
50
    if (i<pos1) old_col= env->local_begin (COLOR, "dark green");
 
51
    typeset (t[i], descend (ip, i));
 
52
    if (i<pos1) env->local_end (COLOR, old_col);
 
53
    // ghost ("}", descend (descend (ip, i), right_index (t[i])));
 
54
    int end= N(a);
 
55
    if (i<pos2) for (j=start; j<end; j++)
 
56
      a[j]->b->relocate (decorate_left (ip), true);
 
57
  }
 
58
  if (i<=pos2) ghost (">", descend (ip, 1));
 
59
  else ghost (">", descend (descend (ip, i-1), right_index (t[i-1])));
 
60
  marker (descend (ip, 1));
 
61
  print (space (0, 0, env->fn->spc->max));
 
62
  penalty_min (0);
 
63
}
 
64
 
 
65
void
 
66
concater_rep::typeset_inactive_symbol (tree t, path ip) {
 
67
  penalty_min (0);
 
68
  marker (descend (ip, 0));
 
69
  ghost ("<", descend (ip, 0));
 
70
  tree old_col= env->local_begin (COLOR, "blue");
 
71
  typeset (t[0], descend (ip, 0));
 
72
  env->local_end (COLOR, old_col);
 
73
  ghost (">", descend (ip, 1));
 
74
  marker (descend (ip, 1));
 
75
  print (space (0, 0, env->fn->spc->max));
 
76
  penalty_min (0);
 
77
}
 
78
 
 
79
void
 
80
concater_rep::typeset_inactive_latex (tree t, path ip) {
 
81
  penalty_min (0);
 
82
  marker (descend (ip, 0));
 
83
  ghost ("\\", descend (ip, 0));
 
84
  tree old_col= env->local_begin (COLOR, "dark green");
 
85
  typeset (t[0], descend (ip, 0));
 
86
  env->local_end (COLOR, old_col);
 
87
  marker (descend (ip, 1));
 
88
  print (space (0, 0, env->fn->spc->max));
 
89
  penalty_min (0);
 
90
}
 
91
 
 
92
void
 
93
concater_rep::typeset_inactive_hybrid (tree t, path ip) {
 
94
  penalty_min (0);
 
95
  marker (descend (ip, 0));
 
96
  ghost ("<", descend (ip, 0));
 
97
  ghost ("\\", descend (ip, 0));
 
98
  tree old_col= env->local_begin (COLOR, "dark green");
 
99
  typeset (t[0], descend (ip, 0));
 
100
  env->local_end (COLOR, old_col);
 
101
  if (N(t) == 2) {
 
102
    print (space (0, 0, env->fn->spc->max));
 
103
    ghost ("|", descend (descend (ip, 1), 0));
 
104
    print (space (0, 0, env->fn->spc->max));
 
105
    typeset (t[1], descend (ip, 1));
 
106
  }
 
107
  if (N(t) == 0) ghost (">", descend (ip, 1));
 
108
  else ghost (">", descend (descend (ip, N(t)-1), right_index (t[N(t)-1])));
 
109
  marker (descend (ip, 1));
 
110
  print (space (0, 0, env->fn->spc->max));
 
111
  penalty_min (0);
 
112
}
 
113
 
 
114
void
 
115
concater_rep::typeset_inactive_specific (tree t, path ip) {
 
116
  bool flag= (t[0] != "texmacs") && (t[0] != "screen") && (t[0] != "printer");
 
117
  string mode, var, value;
 
118
  if (flag) {
 
119
    mode= env->get_string (MODE);
 
120
    if (mode == "text") { var=FONT_FAMILY; value="tt"; }
 
121
    else if (mode == "math") { var=MATH_FONT_FAMILY; value="mt"; }
 
122
    else { var=PROG_FONT_FAMILY; value="tt"; }
 
123
  }
 
124
 
 
125
  penalty_min (0);
 
126
  marker (descend (ip, 0));
 
127
  ghost ("<", descend (ip, 0));
 
128
  tree old_col= env->local_begin (COLOR, "dark green");
 
129
  ghost ("specific", descend (ip, 0));
 
130
  env->local_end (COLOR, old_col);
 
131
  print (space (0, 0, env->fn->spc->max));
 
132
  ghost ("|", descend (descend (ip, 0), 0));
 
133
  print (space (0, 0, env->fn->spc->max));
 
134
  typeset (t[0], descend (ip, 0));
 
135
  print (space (0, 0, env->fn->spc->max));
 
136
  ghost ("|", descend (descend (ip, 1), 0));
 
137
  print (space (0, 0, env->fn->spc->max));
 
138
  tree old;
 
139
  if (flag) old= env->local_begin (var, value);
 
140
  typeset (t[1], descend (ip, 1));
 
141
  if (flag) env->local_end (var, old);
 
142
  if (N(t) == 0) ghost (">", descend (ip, 1));
 
143
  else ghost (">", descend (descend (ip, N(t)-1), right_index (t[N(t)-1])));
 
144
  marker (descend (ip, 1));
 
145
  print (space (0, 0, env->fn->spc->max));
 
146
  penalty_min (0);
 
147
}
 
148
 
 
149
void
 
150
concater_rep::typeset_inactive_compound (tree t, path ip) {
 
151
  int i;
 
152
  penalty_min (0);
 
153
  marker (descend (ip, 0));
 
154
  ghost ("<", descend (descend (ip, 0), 0));
 
155
  tree old_col= env->local_begin (COLOR, "dark green");
 
156
  typeset (t[0], descend (ip, 0));
 
157
  env->local_end (COLOR, old_col);
 
158
  for (i=1; i<N(t); i++) {
 
159
    print (space (0, 0, env->fn->spc->max));
 
160
    ghost ("|", descend (descend (ip, i), 0));
 
161
    print (space (0, 0, env->fn->spc->max));
 
162
    if (i<N(t)-1) penalty_min (0);
 
163
    typeset (t[i], descend (ip, i));
 
164
  }
 
165
  ghost (">", N(t) == 0? descend (ip, 1):
 
166
                         descend (descend (ip, i-1), right_index (t[i-1])));
 
167
  marker (descend (ip, 1));
 
168
  print (space (0, 0, env->fn->spc->max));
 
169
  penalty_min (0);
 
170
}
 
171
 
 
172
void
 
173
concater_rep::typeset_inactive_action (string type, tree t, path ip) {
 
174
  int i, n= N(t);
 
175
  tree old_tf;
 
176
  penalty_min (0);
 
177
  marker (descend (ip, 0));
 
178
  ghost ("<", descend (ip, 0));
 
179
  ghost (type, descend (ip, 0));
 
180
  for (i=0; i<n; i++) {
 
181
    print (space (0, 0, env->fn->spc->max));
 
182
    print (space (0, 0, env->fn->spc->max));
 
183
    ghost ("|", descend (descend (ip, i), 0));
 
184
    print (space (0, 0, env->fn->spc->max));
 
185
    if (i< (n-1)) penalty_min (0);
 
186
    if (i==(n-1)) old_tf= env->local_begin (FONT_FAMILY, "tt");
 
187
    typeset (t[i], descend (ip, i));
 
188
    if (i==(n-1)) env->local_end (FONT_FAMILY, old_tf);
 
189
    // ghost ("}", descend (descend (ip, i), right_index (t[i])));
 
190
  }
 
191
  if (N(t) == 0) ghost (">", descend (ip, 1));
 
192
  else ghost (">", descend (descend (ip, i-1), right_index (t[i-1])));
 
193
  marker (descend (ip, 1));
 
194
  print (space (0, 0, env->fn->spc->max));
 
195
  penalty_min (0);
 
196
}
 
197
 
 
198
void
 
199
concater_rep::typeset_inactive_string (string s, path ip) {
 
200
  penalty_min (0);
 
201
  marker (descend (ip, 0));
 
202
  ghost (s, descend (ip, 1));
 
203
  marker (descend (ip, 1));
 
204
  print (space (0, 0, env->fn->spc->max));
 
205
  penalty_min (0);
 
206
}
 
207
 
 
208
void
 
209
concater_rep::typeset_unknown (string which, tree t, path ip, bool flag) {
 
210
  int i;
 
211
  tree old_col;
 
212
  penalty_min (0);
 
213
  marker (descend (ip, 0));
 
214
  int start= N(a);
 
215
  ghost ("<", descend (ip, 0));
 
216
  ghost (which, descend (ip, 0), env->dis->red);
 
217
  for (i= (flag? 1: 0); i<N(t); i++) {
 
218
    print (space (0, 0, env->fn->spc->max));
 
219
    ghost ("|", descend (descend (ip, i), 0));
 
220
    print (space (0, 0, env->fn->spc->max));
 
221
    if (i<N(t)-1) penalty_min (0);
 
222
    if (i==0) old_col= env->local_begin (COLOR, "red");
 
223
    typeset (t[i], descend (ip, i));
 
224
    if (i==0) env->local_end (COLOR, old_col);
 
225
    // ghost ("}", descend (descend (ip, i), right_index (t[i])));
 
226
  }
 
227
  if (N(t) == 0) ghost (">", descend (ip, 1));
 
228
  else ghost (">", descend (descend (ip, i-1), right_index (t[i-1])));
 
229
  int end= N(a);
 
230
  for (i=start; i<end; i++)
 
231
    a[i]->b->relocate (decorate_right (ip), true);
 
232
  marker (descend (ip, 1));
 
233
  print (space (0, 0, env->fn->spc->max));
 
234
  penalty_min (0);
 
235
}