summaryrefslogtreecommitdiff
path: root/systems/tex-extensions/clasen/math/radical.ch
blob: 757652cecd3c8d9a37c386b21e2076e54d2451de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
@x
primitive("radical",radical,0);@/
@!@:radical_}{\.{\\radical} primitive@>
@y
primitive("radical",radical,0);@/
@!@:radical_}{\.{\\radical} primitive@>
primitive("genradical",radical,1);@/
@!@:genradical_}{\.{\\genradical} primitive@>
@z

@x
radical: print_esc("radical");
@y
radical: if chr_code=0 then print_esc("radical") else print_esc("genradical");
@z

@x
@d radical_noad_size=5 {number of |mem| words in a radical noad}
@y
@d radical_noad_size=6 {number of |mem| words in a radical noad}
@d is_null_delimiter(#) == 
  ((mem[#].qqqq.b0=0) and (mem[#].qqqq.b1=min_quarterword) and 
   (mem[#].qqqq.b2=0) and (mem[#].qqqq.b3=min_quarterword))
@z
@x
radical_noad: begin print_esc("radical"); print_delimiter(left_delimiter(p));
  end;
@y
radical_noad: if subtype(p)=normal then begin
    print_esc("radical"); print_delimiter(left_delimiter(p));
  end else begin
    print_esc("genradical"); print_delimiter(left_delimiter(p));
    print_delimiter(right_delimiter(p));
  end;
@z

@x
procedure make_radical(@!q:pointer);
var x,@!y:pointer; {temporary registers for box construction}
@!delta,@!clr:scaled; {dimensions involved in the calculation}
begin x:=clean_box(nucleus(q),cramped_style(cur_style));
if cur_style<text_style then {display style}
  clr:=default_rule_thickness+(abs(math_x_height(cur_size)) div 4)
else  begin clr:=default_rule_thickness; clr:=clr + (abs(clr) div 4);
  end;
y:=var_delimiter(left_delimiter(q),cur_size,height(x)+depth(x)+clr+
  default_rule_thickness);
delta:=depth(y)-(height(x)+depth(x)+clr);
if delta>0 then clr:=clr+half(delta); {increase the actual clearance}
shift_amount(y):=-(height(x)+clr);
link(y):=overbar(x,clr,height(y));
info(nucleus(q)):=hpack(y,natural); math_type(nucleus(q)):=sub_box;
end;
@y
procedure make_radical(@!q:pointer);
var x,@!y,z:pointer; {temporary registers for box construction}
@!delta,@!clr,ht:scaled; {dimensions involved in the calculation}
begin x:=clean_box(nucleus(q),cramped_style(cur_style));
if cur_style<text_style then {display style}
  clr:=default_rule_thickness+(abs(math_x_height(cur_size)) div 4)
else  begin clr:=default_rule_thickness; clr:=clr + (abs(clr) div 4);
  end;
y:=var_delimiter(left_delimiter(q),cur_size,height(x)+depth(x)+clr+
  default_rule_thickness);
delta:=depth(y)-(height(x)+depth(x)+clr);
if delta>0 then clr:=clr+half(delta); {increase the actual clearance}
shift_amount(y):=-(height(x)+clr);
ht:=height(y);
if subtype(q)=normal then link(y):=overbar(x,clr,ht)
else begin
  z:=var_delimiter(right_delimiter(q),cur_size,height(x)+depth(x)+clr+
    default_rule_thickness);
  shift_amount(z):=-(height(x)+clr);
  if height(z)>ht then ht:=height(z);
  link(y):=overbar(x,clr,ht);
  link(link(y)):=z;
end;
info(nucleus(q)):=hpack(y,natural); math_type(nucleus(q)):=sub_box;
end;
@z

@x
type(tail):=radical_noad; subtype(tail):=normal;
@y
type(tail):=radical_noad; subtype(tail):=cur_chr;
@z

@x
{before |scan_math| in |math_radical|}
@y
if subtype(tail)=normal then mem[right_delimiter(tail)].qqqq:=null_delimiter
else scan_delimiter(right_delimiter(tail),true);
{before |scan_math| in |math_radical|}
@z