Debian Codegraph @

utils/m-tx/mtx-src/uptext.c

raw
1 /* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */
2 /* From input file "uptext.pas" */
3
4
5 #include "p2c.h"
6
7
8 #define UPTEXT_G
9 #include "uptext.h"
10
11
12 #ifndef GLOBALS_H
13 #include "globals.h"
14 #endif
15
16 #ifndef STRINGS_H
17 #include "strings.h"
18 #endif
19
20 #ifndef MTXLINE_H
21 #include "mtxline.h"
22 #endif
23
24 #ifndef UTILITY_H
25 #include "utility.h"
26 #endif
27
28
29 typedef struct uptext_info {
30 short uptext, uptext_adjust, uptext_lcz;
31 Char uptext_font[256];
32 } uptext_info;
33
34
35 Static uptext_info U[maxvoices];
36
37
38 short uptextLineNo(short voice)
39 {
40 return (U[voice-1].uptext);
41 }
42
43
44 void setUptextLineNo(short voice, short lno)
45 {
46 U[voice-1].uptext = lno;
47 }
48
49
50 void clearUptext(void)
51 {
52 voice_index voice, FORLIM;
53
54 FORLIM = nvoices;
55 for (voice = 0; voice <= FORLIM - 1; voice++)
56 U[voice].uptext = 0;
57 }
58
59
60 void initUptext(void)
61 {
62 voice_index voice, FORLIM;
63 uptext_info *WITH;
64
65 FORLIM = nvoices;
66 for (voice = 0; voice <= FORLIM - 1; voice++) {
67 WITH = &U[voice];
68 WITH->uptext_adjust = 0;
69 WITH->uptext_lcz = 3;
70 *WITH->uptext_font = '\0';
71 }
72 }
73
74
75 Static void textTranslate(Char *uptext, Char *font)
76 {
77 short k;
78 Char STR1[256], STR2[256], STR3[256], STR4[256];
79 short FORLIM;
80
81 if (*uptext == '\0')
82 return;
83 do {
84 k = pos1('%', uptext);
85 if (k > 0) {
86 sprintf(STR4, "%s{\\mtxFlat}%s",
87 substr_(STR1, uptext, 1, k - 1),
88 substr_(STR3, uptext, k + 1, strlen(uptext) - k));
89 strcpy(uptext, STR4);
90 }
91 } while (k != 0);
92 do {
93 k = pos1('#', uptext);
94 if (k > 0) {
95 sprintf(STR2, "%s{\\mtxSharp}%s",
96 substr_(STR1, uptext, 1, k - 1),
97 substr_(STR4, uptext, k + 1, strlen(uptext) - k));
98 strcpy(uptext, STR2);
99 }
100 } while (k != 0);
101 switch (uptext[0]) {
102
103 case '<':
104 if (!strcmp(uptext, "<"))
105 strcpy(uptext, "\\mtxIcresc");
106 else if (!strcmp(uptext, "<."))
107 strcpy(uptext, "\\mtxTcresc");
108 else {
109 predelete(uptext, 1);
110 sprintf(uptext, "\\mtxCresc{%s}", strcpy(STR4, uptext));
111 }
112 break;
113
114 case '>':
115 if (!strcmp(uptext, ">"))
116 strcpy(uptext, "\\mtxIdecresc");
117 else if (!strcmp(uptext, ">."))
118 strcpy(uptext, "\\mtxTdecresc");
119 else {
120 predelete(uptext, 1);
121 sprintf(uptext, "\\mtxDecresc{%s}", strcpy(STR1, uptext));
122 }
123 break;
124
125 default:
126 FORLIM = strlen(uptext);
127 for (k = 0; k <= FORLIM - 1; k++) {
128 if (pos1(uptext[k], "mpfzrs~") == 0)
129 return;
130 }
131 break;
132 }
133 strcpy(font, "\\mtxPF");
134 }
135
136
137 #define default_ 10
138 #define under (-14)
139
140
141 /* Local variables for addUptext: */
142 struct LOC_addUptext {
143 short voice;
144 Char w[256];
145 short adj;
146 } ;
147
148 Local void adjustUptext(struct LOC_addUptext *LINK)
149 {
150 Char letter;
151 boolean force = false;
152 uptext_info *WITH1;
153
154 delete1(LINK->w, 1);
155 while (*LINK->w != '\0') {
156 /* p2c: uptext.pas: Note: Eliminated unused assignment statement [338] */
157 letter = LINK->w[0];
158 delete1(LINK->w, 1);
159 WITH1 = &U[LINK->voice-1];
160 switch (letter) {
161
162 case '<':
163 if (WITH1->uptext_lcz > 1)
164 WITH1->uptext_lcz--;
165 break;
166
167 case '>':
168 if (WITH1->uptext_lcz < 3)
169 WITH1->uptext_lcz++;
170 break;
171
172 case '^':
173 WITH1->uptext_adjust = 0;
174 break;
175
176 case 'v':
177 WITH1->uptext_adjust = under;
178 break;
179
180 case '=':
181 force = true;
182 break;
183
184 case '+':
185 case '-':
186 if (*LINK->w != '\0')
187 getNum(LINK->w, &LINK->adj);
188 else
189 LINK->adj = 0;
190 if (letter == '-')
191 LINK->adj = -LINK->adj;
192 if (force)
193 WITH1->uptext_adjust = LINK->adj;
194 else
195 WITH1->uptext_adjust += LINK->adj;
196 *LINK->w = '\0';
197 break;
198
199 default:
200 error3(LINK->voice, "Unknown uptext adjustment");
201 break;
202 }
203 }
204 strcpy(LINK->w, "!");
205 }
206
207
208 void addUptext(short voice_, boolean *no_uptext, Char *pretex)
209 {
210 struct LOC_addUptext V;
211 Char font[256];
212 static Char lcz[4] = "lcz";
213 uptext_info *WITH;
214 Char STR1[256], STR2[256], STR3[256];
215
216 V.voice = voice_;
217 WITH = &U[V.voice-1];
218 if (WITH->uptext == 0)
219 *no_uptext = true;
220 if (*no_uptext)
221 return;
222 do {
223 GetNextWord(V.w, P[WITH->uptext - 1], blank, dummy);
224 sprintf(STR1, "%c", barsym);
225 if (!strcmp(V.w, STR1) || *V.w == '\0')
226 *no_uptext = true;
227 sprintf(STR1, "%c", tilde);
228 if (!strcmp(V.w, STR1) || *no_uptext)
229 return;
230 if (V.w[0] == '!') {
231 strcpy(WITH->uptext_font, V.w);
232 WITH->uptext_font[0] = '\\';
233 }
234 if (V.w[0] == '@')
235 adjustUptext(&V);
236 } while (V.w[0] == '!'); /* ! is a kludge, will get me in trouble later */
237 strcpy(font, WITH->uptext_font);
238 textTranslate(V.w, font);
239 if (*font != '\0')
240 sprintf(V.w, "%s{%s}", font, strcpy(STR1, V.w));
241 switch (lcz[WITH->uptext_lcz - 1]) {
242
243 case 'l':
244 sprintf(V.w, "\\mtxLchar{%s}{%s}",
245 toString(STR1, default_ + WITH->uptext_adjust),
246 strcpy(STR3, V.w));
247 break;
248
249 case 'c':
250 sprintf(V.w, "\\mtxCchar{%s}{%s}",
251 toString(STR1, default_ + WITH->uptext_adjust),
252 strcpy(STR2, V.w));
253 break;
254
255 case 'z':
256 sprintf(V.w, "\\mtxZchar{%s}{%s}",
257 toString(STR1, default_ + WITH->uptext_adjust),
258 strcpy(STR3, V.w));
259 break;
260 }
261 strcat(pretex, V.w);
262 }
263
264 #undef default_
265 #undef under
266
267
268
269
270 /* End. */