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
******************************************************************************/
13
#include "concater.hpp"
15
/******************************************************************************
16
* Typesetting deactivated trees
17
******************************************************************************/
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));
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));
34
concater_rep::typeset_inactive (
35
string type, tree t, path ip, int pos1, int pos2)
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));
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])));
55
if (i<pos2) for (j=start; j<end; j++)
56
a[j]->b->relocate (decorate_left (ip), true);
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));
66
concater_rep::typeset_inactive_symbol (tree t, path ip) {
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));
80
concater_rep::typeset_inactive_latex (tree t, path ip) {
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));
93
concater_rep::typeset_inactive_hybrid (tree t, path ip) {
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);
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));
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));
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;
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"; }
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));
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));
150
concater_rep::typeset_inactive_compound (tree t, path ip) {
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));
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));
173
concater_rep::typeset_inactive_action (string type, tree t, path ip) {
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])));
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));
199
concater_rep::typeset_inactive_string (string s, path ip) {
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));
209
concater_rep::typeset_unknown (string which, tree t, path ip, bool flag) {
213
marker (descend (ip, 0));
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])));
227
if (N(t) == 0) ghost (">", descend (ip, 1));
228
else ghost (">", descend (descend (ip, i-1), right_index (t[i-1])));
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));