summaryrefslogtreecommitdiff
path: root/systems/tex-extensions/clasen/math/radical.ch
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /systems/tex-extensions/clasen/math/radical.ch
Initial commit
Diffstat (limited to 'systems/tex-extensions/clasen/math/radical.ch')
-rw-r--r--systems/tex-extensions/clasen/math/radical.ch99
1 files changed, 99 insertions, 0 deletions
diff --git a/systems/tex-extensions/clasen/math/radical.ch b/systems/tex-extensions/clasen/math/radical.ch
new file mode 100644
index 0000000000..757652cecd
--- /dev/null
+++ b/systems/tex-extensions/clasen/math/radical.ch
@@ -0,0 +1,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
+
+
+
+
+