2
{ Insert and translate uptext }
8
function uptextLineNo(voice: integer): integer;
9
procedure setUptextLineNo(voice, lno: integer);
10
procedure addUptext(voice: integer; var no_uptext: boolean;
13
implementation uses globals, strings, mtxline, utility;
15
type uptext_info = record
16
uptext, uptext_adjust, uptext_lcz: integer;
20
var U: array[voice_index] of uptext_info;
22
function uptextLineNo(voice: integer): integer;
23
begin uptextLineNo := U[voice].uptext; end;
25
procedure setUptextLineNo(voice, lno: integer);
26
begin U[voice].uptext := lno; end;
28
procedure clearUptext;
29
var voice: voice_index;
30
begin for voice:=1 to nvoices do U[voice].uptext:=0; end;
33
var voice: voice_index;
34
begin for voice:=1 to nvoices do with U[voice] do
36
uptext_adjust:=0; uptext_lcz:=3; uptext_font:='';
40
procedure textTranslate(var uptext, font: string);
43
if uptext='' then exit;
44
repeat k := pos1('%',uptext);
46
substr(uptext,1,k-1)+'{\mtxFlat}'+substr(uptext,k+1,length(uptext)-k);
48
repeat k := pos1('#',uptext);
50
substr(uptext,1,k-1)+'{\mtxSharp}'+substr(uptext,k+1,length(uptext)-k);
53
'<': if uptext='<' then uptext:='\mtxIcresc'
54
else if uptext='<.' then uptext:='\mtxTcresc'
56
predelete(uptext,1); uptext:='\mtxCresc{'+uptext+'}'
58
'>': if uptext='>' then uptext:='\mtxIdecresc'
59
else if uptext='>.' then uptext:='\mtxTdecresc'
61
predelete(uptext,1); uptext:='\mtxDecresc{'+uptext+'}'
63
else for k:=1 to length(uptext) do if pos1(uptext[k],'mpfzrs~')=0 then exit;
68
procedure addUptext(voice: integer; var no_uptext: boolean;
72
const default = 10; under = -14;
73
lcz: string[3] = 'lcz';
74
procedure adjustUptext;
77
begin delete1(w,1); force:=false;
78
while w<>'' do with U[voice] do
79
begin letter:=w[1]; delete1(w,1); with U[voice] do
81
'<': if uptext_lcz>1 then dec(uptext_lcz);
82
'>': if uptext_lcz<3 then inc(uptext_lcz);
83
'^': uptext_adjust:=0;
84
'v': uptext_adjust:=under;
86
'+','-': begin if w<>'' then getNum(w,adj) else adj:=0;
87
if letter = '-' then adj := -adj;
88
if force then uptext_adjust := adj else inc(uptext_adjust,adj);
91
else error3(voice,'Unknown uptext adjustment');
98
with U[voice] do begin
99
if uptext=0 then no_uptext := true;
100
if no_uptext then exit;
102
w := GetNextWord(P[uptext],blank,dummy);
103
if (w=barsym) or (w='') then no_uptext:=true;
104
if (w=tilde) or no_uptext then exit;
105
if w[1]='!' then begin uptext_font:=w; uptext_font[1]:='\'; end;
106
if w[1]='@' then adjustUptext;
107
until w[1]<>'!'; { ! is a kludge, will get me in trouble later }
108
font:=uptext_font; textTranslate(w,font);
109
if font<>'' then w:=font+'{'+w+'}';
110
case lcz[uptext_lcz] of
111
'l': w:='\mtxLchar{' + toString(default+uptext_adjust) + '}{' + w + '}';
112
'c': w:='\mtxCchar{' + toString(default+uptext_adjust) + '}{' + w + '}';
113
'z': w:='\mtxZchar{' + toString(default+uptext_adjust) + '}{' + w + '}';