diff options
Diffstat (limited to 'tex')
-rw-r--r-- | tex/context/base/mkii/cont-new.mkii | 2 | ||||
-rw-r--r-- | tex/context/base/mkii/context.mkii | 2 | ||||
-rw-r--r-- | tex/context/base/mkii/mult-de.mkii | 5 | ||||
-rw-r--r-- | tex/context/base/mkiv/char-def.lua | 1 | ||||
-rw-r--r-- | tex/context/base/mkiv/char-tex.lua | 6 | ||||
-rw-r--r-- | tex/context/base/mkiv/cont-fil.mkiv | 5 | ||||
-rw-r--r-- | tex/context/base/mkiv/cont-new.mkiv | 12 | ||||
-rw-r--r-- | tex/context/base/mkiv/cont-run.mkiv | 18 | ||||
-rw-r--r-- | tex/context/base/mkiv/cont-yes.mkiv | 85 | ||||
-rw-r--r-- | tex/context/base/mkiv/context.mkiv | 4 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-lib.mkvi | 18 | ||||
-rw-r--r-- | tex/context/base/mkiv/luat-ini.mkiv | 1 | ||||
-rw-r--r-- | tex/context/base/mkiv/luat-lib.mkiv | 14 | ||||
-rw-r--r-- | tex/context/base/mkiv/math-ini.lua | 35 | ||||
-rw-r--r-- | tex/context/base/mkiv/mult-def.lua | 8 | ||||
-rw-r--r-- | tex/context/base/mkiv/mult-prm.lua | 4 | ||||
-rw-r--r-- | tex/context/base/mkiv/node-ref.lua | 5 | ||||
-rw-r--r-- | tex/context/base/mkiv/page-imp.mkiv | 6 | ||||
-rw-r--r-- | tex/context/base/mkiv/page-ins.mkiv | 9 | ||||
-rw-r--r-- | tex/context/base/mkiv/prop-ini.mkiv | 64 | ||||
-rw-r--r-- | tex/context/base/mkiv/scrp-ini.mkiv | 4 | ||||
-rw-r--r-- | tex/context/base/mkiv/spac-chr.lua | 3 | ||||
-rw-r--r-- | tex/context/base/mkiv/status-files.pdf | bin | 29907 -> 26166 bytes | |||
-rw-r--r-- | tex/context/base/mkiv/status-lua.pdf | bin | 256345 -> 256281 bytes | |||
-rw-r--r-- | tex/context/base/mkiv/strc-lev.mkvi | 32 | ||||
-rw-r--r-- | tex/context/base/mkiv/supp-dir.mkxl | 54 | ||||
-rw-r--r-- | tex/context/base/mkiv/syst-ini.mkiv | 11 | ||||
-rw-r--r-- | tex/context/base/mkiv/toks-aux.mkiv | 17 | ||||
-rw-r--r-- | tex/context/base/mkxl/anch-bar.mkxl (renamed from tex/context/base/mkiv/anch-bar.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/anch-bck.mklx (renamed from tex/context/base/mkiv/anch-bck.mklx) | 13 | ||||
-rw-r--r-- | tex/context/base/mkxl/anch-pgr.mkxl (renamed from tex/context/base/mkiv/anch-pgr.mkxl) | 45 | ||||
-rw-r--r-- | tex/context/base/mkxl/anch-pos.lmt (renamed from tex/context/base/mkiv/anch-pos.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/anch-pos.mkxl (renamed from tex/context/base/mkiv/anch-pos.mkxl) | 3 | ||||
-rw-r--r-- | tex/context/base/mkxl/anch-snc.mkxl (renamed from tex/context/base/mkiv/anch-snc.mkxl) | 7 | ||||
-rw-r--r-- | tex/context/base/mkxl/anch-tab.mkxl (renamed from tex/context/base/mkiv/anch-tab.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/attr-col.mkxl (renamed from tex/context/base/mkiv/attr-col.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/attr-eff.mkxl (renamed from tex/context/base/mkiv/attr-eff.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/attr-ini.mkxl (renamed from tex/context/base/mkiv/attr-ini.mkxl) | 8 | ||||
-rw-r--r-- | tex/context/base/mkxl/attr-lay.lmt (renamed from tex/context/base/mkiv/attr-lay.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/attr-lay.mkxl (renamed from tex/context/base/mkiv/attr-lay.mkxl) | 4 | ||||
-rw-r--r-- | tex/context/base/mkxl/attr-mkr.mkxl (renamed from tex/context/base/mkiv/attr-mkr.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/attr-neg.mkxl (renamed from tex/context/base/mkiv/attr-neg.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/back-exp.mkxl (renamed from tex/context/base/mkiv/back-exp.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/back-ini.mkxl (renamed from tex/context/base/mkiv/back-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/back-lua.lmt (renamed from tex/context/base/mkiv/back-lua.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/back-lua.mkxl (renamed from tex/context/base/mkiv/back-lua.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/back-mps.lmt (renamed from tex/context/base/mkiv/back-mps.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/back-mps.mkxl (renamed from tex/context/base/mkiv/back-mps.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/back-out.lmt (renamed from tex/context/base/mkiv/back-out.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/back-out.mkxl (renamed from tex/context/base/mkiv/back-out.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/back-pdf.mkxl (renamed from tex/context/base/mkiv/back-pdf.mkxl) | 8 | ||||
-rw-r--r-- | tex/context/base/mkxl/back-res.mkxl (renamed from tex/context/base/mkiv/back-res.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/back-trf.mkxl (renamed from tex/context/base/mkiv/back-trf.mkxl) | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/back-u3d.mkxl | 158 | ||||
-rw-r--r-- | tex/context/base/mkxl/bibl-bib.mkxl (renamed from tex/context/base/mkiv/bibl-bib.mkxl) | 60 | ||||
-rw-r--r-- | tex/context/base/mkxl/bibl-tra.mkxl (renamed from tex/context/base/mkiv/bibl-tra.mkxl) | 47 | ||||
-rw-r--r-- | tex/context/base/mkxl/blob-ini.lmt (renamed from tex/context/base/mkiv/blob-ini.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/blob-ini.mkxl (renamed from tex/context/base/mkiv/blob-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/buff-ini.mkxl | 232 | ||||
-rw-r--r-- | tex/context/base/mkxl/buff-par.mklx | 180 | ||||
-rw-r--r-- | tex/context/base/mkxl/buff-ver.mkxl (renamed from tex/context/base/mkiv/buff-ver.mkxl) | 6 | ||||
-rw-r--r-- | tex/context/base/mkxl/catc-act.mkxl (renamed from tex/context/base/mkiv/catc-act.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/catc-ctx.mkxl (renamed from tex/context/base/mkiv/catc-ctx.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/catc-def.mkxl (renamed from tex/context/base/mkiv/catc-def.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/catc-ini.mkxl (renamed from tex/context/base/mkiv/catc-ini.mkxl) | 8 | ||||
-rw-r--r-- | tex/context/base/mkxl/catc-sym.mkxl (renamed from tex/context/base/mkiv/catc-sym.mkxl) | 1 | ||||
-rw-r--r-- | tex/context/base/mkxl/char-act.mkxl (renamed from tex/context/base/mkiv/char-act.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/char-enc.mkxl (renamed from tex/context/base/mkiv/char-enc.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/char-ini.mkxl (renamed from tex/context/base/mkiv/char-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/char-utf.mkxl (renamed from tex/context/base/mkiv/char-utf.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/chem-ini.mkxl (renamed from tex/context/base/mkiv/chem-ini.mkxl) | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/chem-str.mkxl (renamed from tex/context/base/mkiv/chem-str.mkxl) | 40 | ||||
-rw-r--r-- | tex/context/base/mkxl/cldf-bas.mkxl (renamed from tex/context/base/mkiv/cldf-bas.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cldf-com.mkxl (renamed from tex/context/base/mkiv/cldf-com.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cldf-ini.mkxl (renamed from tex/context/base/mkiv/cldf-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cldf-int.lmt (renamed from tex/context/base/mkiv/cldf-int.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cldf-int.mkxl (renamed from tex/context/base/mkiv/cldf-int.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cldf-lmt.lmt (renamed from tex/context/base/mkiv/cldf-lmt.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cldf-ver.mkxl (renamed from tex/context/base/mkiv/cldf-ver.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/colo-ext.mkxl (renamed from tex/context/base/mkiv/colo-ext.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/colo-grp.mkxl (renamed from tex/context/base/mkiv/colo-grp.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/colo-ini.mkxl (renamed from tex/context/base/mkiv/colo-ini.mkxl) | 101 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-cs.mkxl (renamed from tex/context/base/mkiv/cont-cs.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-de.mkxl (renamed from tex/context/base/mkiv/cont-de.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-en.mkxl (renamed from tex/context/base/mkiv/cont-en.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-fil.mkxl | 152 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-fr.mkxl (renamed from tex/context/base/mkiv/cont-fr.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-gb.mkxl (renamed from tex/context/base/mkiv/cont-gb.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-it.mkxl (renamed from tex/context/base/mkiv/cont-it.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-log.mkxl | 298 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-new.mkxl | 50 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-nl.mkxl (renamed from tex/context/base/mkiv/cont-nl.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-pe.mkxl (renamed from tex/context/base/mkiv/cont-pe.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-ro.mkxl (renamed from tex/context/base/mkiv/cont-ro.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/cont-run.mkxl | 59 | ||||
-rw-r--r-- | tex/context/base/mkxl/context.mkxl (renamed from tex/context/base/mkiv/context.mkxl) | 243 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-con.mkxl (renamed from tex/context/base/mkiv/core-con.mkxl) | 9 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-ctx.mkxl (renamed from tex/context/base/mkiv/core-ctx.mkxl) | 12 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-dat.mkxl (renamed from tex/context/base/mkiv/core-dat.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-def.mkxl (renamed from tex/context/base/mkiv/core-def.mkxl) | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-env.lmt (renamed from tex/context/base/mkiv/core-env.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-env.mkxl (renamed from tex/context/base/mkiv/core-env.mkxl) | 34 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-ini.mkxl (renamed from tex/context/base/mkiv/core-ini.mkxl) | 10 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-lmt.lmt (renamed from tex/context/base/mkiv/core-lmt.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-lmt.mkxl (renamed from tex/context/base/mkiv/core-lmt.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-sys.lmt (renamed from tex/context/base/mkiv/core-sys.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-sys.mkxl (renamed from tex/context/base/mkiv/core-sys.mkxl) | 9 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-two.mkxl (renamed from tex/context/base/mkiv/core-two.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-uti.lua | 470 | ||||
-rw-r--r-- | tex/context/base/mkxl/core-uti.mkxl (renamed from tex/context/base/mkiv/core-uti.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/driv-ini.mkxl (renamed from tex/context/base/mkiv/driv-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/driv-shp.lmt (renamed from tex/context/base/mkiv/driv-shp.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/driv-shp.mkxl (renamed from tex/context/base/mkiv/driv-shp.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/enco-ini.mkxl (renamed from tex/context/base/mkiv/enco-ini.mkxl) | 200 | ||||
-rw-r--r-- | tex/context/base/mkxl/file-ini.mklx (renamed from tex/context/base/mkiv/file-ini.mklx) | 20 | ||||
-rw-r--r-- | tex/context/base/mkxl/file-job.lmt (renamed from tex/context/base/mkiv/file-job.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/file-job.mklx (renamed from tex/context/base/mkiv/file-job.mklx) | 11 | ||||
-rw-r--r-- | tex/context/base/mkxl/file-lib.mkxl (renamed from tex/context/base/mkiv/file-lib.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/file-mod.mklx (renamed from tex/context/base/mkiv/file-mod.mklx) | 16 | ||||
-rw-r--r-- | tex/context/base/mkxl/file-res.mklx (renamed from tex/context/base/mkiv/file-res.mklx) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/file-syn.mklx (renamed from tex/context/base/mkiv/file-syn.mklx) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-aux.mklx (renamed from tex/context/base/mkiv/font-aux.mklx) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-chk.mkxl (renamed from tex/context/base/mkiv/font-chk.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-col.mklx (renamed from tex/context/base/mkiv/font-col.mklx) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-emp.mklx (renamed from tex/context/base/mkiv/font-emp.mklx) | 10 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-fea.mklx (renamed from tex/context/base/mkiv/font-fea.mklx) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-fil.mklx (renamed from tex/context/base/mkiv/font-fil.mklx) | 30 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-gds.mklx | 97 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-ini.mklx (renamed from tex/context/base/mkiv/font-ini.mklx) | 52 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-lib.mklx | 170 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-mat.mklx (renamed from tex/context/base/mkiv/font-mat.mklx) | 23 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-ogr.lmt (renamed from tex/context/base/mkiv/font-ogr.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-pre.mkxl (renamed from tex/context/base/mkiv/font-pre.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-sel.mklx | 276 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-set.mklx | 159 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-sol.mklx (renamed from tex/context/base/mkiv/font-sol.mklx) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-sty.mklx (renamed from tex/context/base/mkiv/font-sty.mklx) | 6 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-sym.mklx (renamed from tex/context/base/mkiv/font-sym.mklx) | 4 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-tra.mkxl (renamed from tex/context/base/mkiv/font-tra.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-uni.mkxl | 27 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-unk.mkxl | 150 | ||||
-rw-r--r-- | tex/context/base/mkxl/font-var.mklx | 57 | ||||
-rw-r--r-- | tex/context/base/mkxl/grph-epd.mkxl (renamed from tex/context/base/mkiv/grph-epd.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/grph-fig.mkxl (renamed from tex/context/base/mkiv/grph-fig.mkxl) | 5 | ||||
-rw-r--r-- | tex/context/base/mkxl/grph-inc.mkxl (renamed from tex/context/base/mkiv/grph-inc.mkxl) | 6 | ||||
-rw-r--r-- | tex/context/base/mkxl/grph-pat.mkxl (renamed from tex/context/base/mkiv/grph-pat.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/grph-raw.mkxl (renamed from tex/context/base/mkiv/grph-raw.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/grph-rul.mkxl (renamed from tex/context/base/mkiv/grph-rul.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/grph-trf.mkxl (renamed from tex/context/base/mkiv/grph-trf.mkxl) | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/hand-ini.mkxl (renamed from tex/context/base/mkiv/hand-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/java-ini.mkxl (renamed from tex/context/base/mkiv/java-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-def.mkxl | 800 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-dis.lmt (renamed from tex/context/base/mkiv/lang-dis.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-frd.mkxl | 143 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-frq.mkxl | 234 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-hyp.lmt (renamed from tex/context/base/mkiv/lang-hyp.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-hyp.mkxl | 262 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-ini.lmt (renamed from tex/context/base/mkiv/lang-ini.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-ini.mkxl (renamed from tex/context/base/mkiv/lang-ini.mkxl) | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-lab.mkxl (renamed from tex/context/base/mkiv/lang-lab.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-mis.mkxl (renamed from tex/context/base/mkiv/lang-mis.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-rep.mkxl | 74 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-spa.mkxl | 74 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-tra.mkxl | 95 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-url.mkxl (renamed from tex/context/base/mkiv/lang-url.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/lang-wrd.mkxl | 67 | ||||
-rw-r--r-- | tex/context/base/mkxl/layo-ini.mkxl (renamed from tex/context/base/mkiv/layo-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/libs-imp-curl.lmt (renamed from tex/context/base/mkiv/libs-imp-curl.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/libs-imp-ghostscript.lmt (renamed from tex/context/base/mkiv/libs-imp-ghostscript.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/libs-imp-graphicsmagick.lmt (renamed from tex/context/base/mkiv/libs-imp-graphicsmagick.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/libs-imp-kpse.lmt (renamed from tex/context/base/mkiv/libs-imp-kpse.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/libs-imp-kpse.mkxl (renamed from tex/context/base/mkiv/libs-imp-kpse.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/libs-imp-mujs.lmt (renamed from tex/context/base/mkiv/libs-imp-mujs.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/libs-imp-mujs.mkxl (renamed from tex/context/base/mkiv/libs-imp-mujs.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/libs-imp-mysql.lmt (renamed from tex/context/base/mkiv/libs-imp-mysql.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/libs-imp-postgress.lmt (renamed from tex/context/base/mkiv/libs-imp-postgress.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/libs-imp-sqlite.lmt (renamed from tex/context/base/mkiv/libs-imp-sqlite.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/libs-imp-zint.lmt (renamed from tex/context/base/mkiv/libs-imp-zint.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/libs-imp-zint.mkxl (renamed from tex/context/base/mkiv/libs-imp-zint.mkxl) | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/libs-ini.mkxl (renamed from tex/context/base/mkiv/libs-ini.mkxl) | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/lpdf-emb.lmt (renamed from tex/context/base/mkiv/lpdf-emb.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/lpdf-img.lmt (renamed from tex/context/base/mkiv/lpdf-img.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/lpdf-lmt.lmt (renamed from tex/context/base/mkiv/lpdf-lmt.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/lpdf-vfc.lmt (renamed from tex/context/base/mkiv/lpdf-vfc.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/luat-bas.mkxl | 52 | ||||
-rw-r--r-- | tex/context/base/mkxl/luat-cod.lmt (renamed from tex/context/base/mkiv/luat-cod.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/luat-cod.mkxl (renamed from tex/context/base/mkiv/luat-cod.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/luat-fio.lmt (renamed from tex/context/base/mkiv/luat-fio.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/luat-ini.mkxl | 296 | ||||
-rw-r--r-- | tex/context/base/mkxl/luat-lib.mkxl | 104 | ||||
-rw-r--r-- | tex/context/base/mkxl/luat-log.lmt (renamed from tex/context/base/mkiv/luat-log.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/luat-soc.mkxl | 52 | ||||
-rw-r--r-- | tex/context/base/mkxl/luat-usr.mkxl | 119 | ||||
-rw-r--r-- | tex/context/base/mkxl/lxml-css.mkxl (renamed from tex/context/base/mkiv/lxml-css.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/lxml-ctx.mkxl (renamed from tex/context/base/mkiv/lxml-ctx.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/lxml-ini.mkxl (renamed from tex/context/base/mkiv/lxml-ini.mkxl) | 16 | ||||
-rw-r--r-- | tex/context/base/mkxl/lxml-sor.mkxl (renamed from tex/context/base/mkiv/lxml-sor.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/m-mkivmkxl.mkxl (renamed from tex/context/base/mkiv/m-mkivmkxl.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-acc.mklx | 151 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-ali.mkxl (renamed from tex/context/base/mkiv/math-ali.mkxl) | 36 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-def.mkxl | 171 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-del.mkxl | 164 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-dis.mkxl | 20 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-fen.mkxl (renamed from tex/context/base/mkiv/math-fen.mkxl) | 14 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-for.mkxl | 47 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-frc.mkxl (renamed from tex/context/base/mkiv/math-frc.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-inc.mkxl | 69 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-ini.mkxl (renamed from tex/context/base/mkiv/math-ini.mkxl) | 78 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-inl.mkxl | 22 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-int.mkxl | 141 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-mis.mkxl | 60 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-noa.lmt (renamed from tex/context/base/mkiv/math-noa.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-pln.mkxl (renamed from tex/context/base/mkiv/math-pln.mkxl) | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-rad.mklx | 269 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-scr.mkxl | 58 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-stc.mklx (renamed from tex/context/base/mkiv/math-stc.mklx) | 13 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-tag.lmt (renamed from tex/context/base/mkiv/math-tag.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/math-toy.mkxl (renamed from tex/context/base/mkiv/math-toy.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-blb.mkxl | 53 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-fig.mkxl | 71 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-fnt.mkxl | 33 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-fun.mkxl | 25 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-grd.mkxl | 105 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-imp-experiments.mkxl (renamed from tex/context/base/mkiv/meta-imp-experiments.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-imp-gamesymbols.mkxl (renamed from tex/context/base/mkiv/meta-imp-gamesymbols.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-imp-symbols.mkxl (renamed from tex/context/base/mkiv/meta-imp-symbols.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-imp-threesix.mkxl (renamed from tex/context/base/mkiv/meta-imp-threesix.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-ini.mkxl (renamed from tex/context/base/mkiv/meta-ini.mkxl) | 88 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-lua.mkxl | 95 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-mac.mkxl (renamed from tex/context/base/mkiv/meta-mac.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-nod.mkxl | 241 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-pag.mkxl (renamed from tex/context/base/mkiv/meta-pag.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-pdf.mkxl | 95 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-pdh.mkxl | 717 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-tex.mkxl | 239 | ||||
-rw-r--r-- | tex/context/base/mkxl/meta-xml.mkxl | 20 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-cnt.lmt (renamed from tex/context/base/mkiv/mlib-cnt.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-ctx.mkxl (renamed from tex/context/base/mkiv/mlib-ctx.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-fio.lmt (renamed from tex/context/base/mkiv/mlib-fio.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-int.lmt (renamed from tex/context/base/mkiv/mlib-int.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-lmp.lmt (renamed from tex/context/base/mkiv/mlib-lmp.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-lmt.lmt (renamed from tex/context/base/mkiv/mlib-lmt.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-lua.lmt (renamed from tex/context/base/mkiv/mlib-lua.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-mat.lmt (renamed from tex/context/base/mkiv/mlib-mat.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-pdf.mkxl (renamed from tex/context/base/mkiv/mlib-pdf.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-pps.mkxl (renamed from tex/context/base/mkiv/mlib-pps.mkxl) | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-ran.lmt (renamed from tex/context/base/mkiv/mlib-ran.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-scn.lmt (renamed from tex/context/base/mkiv/mlib-scn.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mlib-svg.lmt (renamed from tex/context/base/mkiv/mlib-svg.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mult-aux.mkxl (renamed from tex/context/base/mkiv/mult-aux.mkxl) | 14 | ||||
-rw-r--r-- | tex/context/base/mkxl/mult-def.mkxl (renamed from tex/context/base/mkiv/mult-def.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mult-dim.mklx (renamed from tex/context/base/mkiv/mult-dim.mklx) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mult-ini.mkxl (renamed from tex/context/base/mkiv/mult-ini.mkxl) | 42 | ||||
-rw-r--r-- | tex/context/base/mkxl/mult-prm.mkxl (renamed from tex/context/base/mkiv/mult-prm.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/mult-sys.mkxl (renamed from tex/context/base/mkiv/mult-sys.mkxl) | 10 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-aux.lmt (renamed from tex/context/base/mkiv/node-aux.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-bck.mkxl (renamed from tex/context/base/mkiv/node-bck.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-cmp.lmt (renamed from tex/context/base/mkiv/node-cmp.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-fin.mkxl (renamed from tex/context/base/mkiv/node-fin.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-gcm.lmt (renamed from tex/context/base/mkiv/node-gcm.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-ini.lmt (renamed from tex/context/base/mkiv/node-ini.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-ini.mkxl (renamed from tex/context/base/mkiv/node-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-mig.lmt (renamed from tex/context/base/mkiv/node-mig.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-mig.mkxl (renamed from tex/context/base/mkiv/node-mig.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-nut.lmt (renamed from tex/context/base/mkiv/node-nut.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-par.lmt (renamed from tex/context/base/mkiv/node-par.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-rul.mkxl (renamed from tex/context/base/mkiv/node-rul.mkxl) | 31 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-ser.lmt (renamed from tex/context/base/mkiv/node-ser.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-snp.lmt (renamed from tex/context/base/mkiv/node-snp.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/node-tex.lmt (renamed from tex/context/base/mkiv/node-tex.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/norm-ctx.mkxl (renamed from tex/context/base/mkiv/norm-ctx.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-bar.mkxl (renamed from tex/context/base/mkiv/pack-bar.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-bck.mklx (renamed from tex/context/base/mkiv/pack-bck.mklx) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-box.mkxl (renamed from tex/context/base/mkiv/pack-box.mkxl) | 14 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-com.mkxl (renamed from tex/context/base/mkiv/pack-com.mkxl) | 39 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-cut.mkxl | 164 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-fen.mkxl | 97 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-lyr.mkxl (renamed from tex/context/base/mkiv/pack-lyr.mkxl) | 8 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-mis.mklx | 112 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-mrl.mkxl (renamed from tex/context/base/mkiv/pack-mrl.mkxl) | 22 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-obj.lmt | 305 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-obj.mkxl | 168 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-ori.lmt (renamed from tex/context/base/mkiv/pack-ori.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-ori.mkxl (renamed from tex/context/base/mkiv/pack-ori.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-pos.mkxl | 160 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-rul.lmt | 248 | ||||
-rw-r--r-- | tex/context/base/mkxl/pack-rul.mkxl (renamed from tex/context/base/mkiv/pack-rul.mkxl) | 61 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-app.mkxl | 205 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-bck.mkxl (renamed from tex/context/base/mkiv/page-bck.mkxl) | 12 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-box.mklx | 289 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-brk.mkxl | 483 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-col.mkxl | 163 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-com.mkxl | 180 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-cst.mkxl | 789 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-fac.mkxl | 87 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-ffl.mkxl | 247 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-flt.mkxl | 326 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-flw.mkxl | 178 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-imp.mkxl | 1410 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-inf.mkxl | 124 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-ini.mkxl (renamed from tex/context/base/mkiv/page-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-inj.mklx | 228 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-ins.mkxl | 209 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-lay.mkxl (renamed from tex/context/base/mkiv/page-lay.mkxl) | 14 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-mak.mklx | 280 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-mbk.mklx | 243 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-mcl.mkxl (renamed from tex/context/base/mkiv/page-mcl.mkxl) | 4 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-mix.mkxl (renamed from tex/context/base/mkiv/page-mix.mkxl) | 80 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-mrk.mkxl | 238 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-not.mkxl (renamed from tex/context/base/mkiv/page-not.mkxl) | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-one.mkxl (renamed from tex/context/base/mkiv/page-one.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-otr.mklx (renamed from tex/context/base/mkiv/page-otr.mklx) | 8 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-par.mkxl | 73 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-pcl.mkxl | 857 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-plg.mkxl | 213 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-pst.mkxl | 110 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-sel.mklx | 417 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-sid.mkxl | 1019 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-smp.mkxl | 56 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-spr.mkxl (renamed from tex/context/base/mkiv/page-spr.mkxl) | 18 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-str.mkxl | 128 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-txt.mklx (renamed from tex/context/base/mkiv/page-txt.mklx) | 40 | ||||
-rw-r--r-- | tex/context/base/mkxl/page-var.mkxl | 20 | ||||
-rw-r--r-- | tex/context/base/mkxl/phys-dim.mkxl (renamed from tex/context/base/mkiv/phys-dim.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/publ-inc.mkxl (renamed from tex/context/base/mkiv/publ-inc.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/publ-ini.mkxl (renamed from tex/context/base/mkiv/publ-ini.mkxl) | 22 | ||||
-rw-r--r-- | tex/context/base/mkxl/publ-old.mkxl | 22 | ||||
-rw-r--r-- | tex/context/base/mkxl/publ-tra.mkxl (renamed from tex/context/base/mkiv/publ-tra.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/publ-xml.mkxl (renamed from tex/context/base/mkiv/publ-xml.mkxl) | 16 | ||||
-rw-r--r-- | tex/context/base/mkxl/regi-ini.mkxl (renamed from tex/context/base/mkiv/regi-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/scrn-bar.mklx | 402 | ||||
-rw-r--r-- | tex/context/base/mkxl/scrn-but.mklx | 1031 | ||||
-rw-r--r-- | tex/context/base/mkxl/scrn-fld.mklx | 1013 | ||||
-rw-r--r-- | tex/context/base/mkxl/scrn-hlp.mklx | 162 | ||||
-rw-r--r-- | tex/context/base/mkxl/scrn-ini.mklx (renamed from tex/context/base/mkiv/scrn-ini.mklx) | 4 | ||||
-rw-r--r-- | tex/context/base/mkxl/scrn-pag.mklx (renamed from tex/context/base/mkiv/scrn-pag.mklx) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/scrn-ref.mklx | 102 | ||||
-rw-r--r-- | tex/context/base/mkxl/scrn-wid.mklx | 744 | ||||
-rw-r--r-- | tex/context/base/mkxl/scrp-ini.mkxl | 109 | ||||
-rw-r--r-- | tex/context/base/mkxl/sort-ini.mkxl | 19 | ||||
-rw-r--r-- | tex/context/base/mkxl/spac-ali.mkxl (renamed from tex/context/base/mkiv/spac-ali.mkxl) | 16 | ||||
-rw-r--r-- | tex/context/base/mkxl/spac-chr.mkxl (renamed from tex/context/base/mkiv/spac-chr.mkxl) | 25 | ||||
-rw-r--r-- | tex/context/base/mkxl/spac-def.mkxl | 91 | ||||
-rw-r--r-- | tex/context/base/mkxl/spac-flr.mkxl | 194 | ||||
-rw-r--r-- | tex/context/base/mkxl/spac-grd.mkxl (renamed from tex/context/base/mkiv/spac-grd.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/spac-hor.mkxl (renamed from tex/context/base/mkiv/spac-hor.mkxl) | 98 | ||||
-rw-r--r-- | tex/context/base/mkxl/spac-lin.mkxl | 211 | ||||
-rw-r--r-- | tex/context/base/mkxl/spac-pag.mkxl | 182 | ||||
-rw-r--r-- | tex/context/base/mkxl/spac-par.lmt (renamed from tex/context/base/mkiv/spac-par.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/spac-par.mkxl (renamed from tex/context/base/mkiv/spac-par.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/spac-prf.mklx | 113 | ||||
-rw-r--r-- | tex/context/base/mkxl/spac-ver.lmt (renamed from tex/context/base/mkiv/spac-ver.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/spac-ver.mkxl (renamed from tex/context/base/mkiv/spac-ver.mkxl) | 100 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-bkm.mkxl (renamed from tex/context/base/mkiv/strc-bkm.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-blk.mkxl (renamed from tex/context/base/mkiv/strc-blk.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-con.mklx (renamed from tex/context/base/mkiv/strc-con.mklx) | 6 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-def.mkxl | 338 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-des.mklx (renamed from tex/context/base/mkiv/strc-des.mklx) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-doc.mkxl (renamed from tex/context/base/mkiv/strc-doc.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-enu.mklx (renamed from tex/context/base/mkiv/strc-enu.mklx) | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-flt.mklx (renamed from tex/context/base/mkiv/strc-flt.mklx) | 71 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-ind.mkxl (renamed from tex/context/base/mkiv/strc-ind.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-ini.mklx (renamed from tex/context/base/mkiv/strc-ini.mklx) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-itm.mklx (renamed from tex/context/base/mkiv/strc-itm.mklx) | 29 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-lab.mkxl (renamed from tex/context/base/mkiv/strc-lab.mkxl) | 12 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-lev.mklx (renamed from tex/context/base/mkiv/strc-lev.mklx) | 33 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-lnt.mklx (renamed from tex/context/base/mkiv/strc-lnt.mklx) | 8 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-lst.mklx (renamed from tex/context/base/mkiv/strc-lst.mklx) | 9 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-mar.mkxl (renamed from tex/context/base/mkiv/strc-mar.mkxl) | 21 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-mat.mkxl (renamed from tex/context/base/mkiv/strc-mat.mkxl) | 23 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-not.mklx (renamed from tex/context/base/mkiv/strc-not.mklx) | 24 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-num.mkxl (renamed from tex/context/base/mkiv/strc-num.mkxl) | 6 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-pag.mkxl (renamed from tex/context/base/mkiv/strc-pag.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-ref.mklx (renamed from tex/context/base/mkiv/strc-ref.mklx) | 29 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-reg.mkxl (renamed from tex/context/base/mkiv/strc-reg.mkxl) | 7 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-ren.mkxl (renamed from tex/context/base/mkiv/strc-ren.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-sbe.mkxl (renamed from tex/context/base/mkiv/strc-sbe.mkxl) | 8 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-sec.mkxl (renamed from tex/context/base/mkiv/strc-sec.mkxl) | 8 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-syn.mkxl (renamed from tex/context/base/mkiv/strc-syn.mkxl) | 14 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-tag.lmt (renamed from tex/context/base/mkiv/strc-tag.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-tag.mkxl (renamed from tex/context/base/mkiv/strc-tag.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-tnt.mkxl (renamed from tex/context/base/mkiv/strc-tnt.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/strc-usr.mkxl (renamed from tex/context/base/mkiv/strc-usr.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/supp-box.lmt (renamed from tex/context/base/mkiv/supp-box.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/supp-box.mkxl (renamed from tex/context/base/mkiv/supp-box.mkxl) | 121 | ||||
-rw-r--r-- | tex/context/base/mkxl/supp-dir.mkxl | 44 | ||||
-rw-r--r-- | tex/context/base/mkxl/supp-mat.mkxl (renamed from tex/context/base/mkiv/supp-mat.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/supp-ran.mkxl | 49 | ||||
-rw-r--r-- | tex/context/base/mkxl/symb-emj.mkxl (renamed from tex/context/base/mkiv/symb-emj.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/symb-ini.mkxl (renamed from tex/context/base/mkiv/symb-ini.mkxl) | 11 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-aux.lmt (renamed from tex/context/base/mkiv/syst-aux.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-aux.mkxl (renamed from tex/context/base/mkiv/syst-aux.mkxl) | 184 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-cmp.mkxl | 22 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-con.mkxl (renamed from tex/context/base/mkiv/syst-con.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-fnt.mkxl (renamed from tex/context/base/mkiv/syst-fnt.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-ini.mkxl (renamed from tex/context/base/mkiv/syst-ini.mkxl) | 115 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-lua.lmt (renamed from tex/context/base/mkiv/syst-lua.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-lua.mkxl (renamed from tex/context/base/mkiv/syst-lua.mkxl) | 6 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-mac.lmt (renamed from tex/context/base/mkiv/syst-mac.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-mes.mkxl | 20 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-pln.mkxl | 119 | ||||
-rw-r--r-- | tex/context/base/mkxl/syst-rtp.mkxl | 18 | ||||
-rw-r--r-- | tex/context/base/mkxl/tabl-com.mkxl (renamed from tex/context/base/mkiv/tabl-com.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/tabl-frm.mkxl (renamed from tex/context/base/mkiv/tabl-frm.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/tabl-ltb.mkxl (renamed from tex/context/base/mkiv/tabl-ltb.mkxl) | 32 | ||||
-rw-r--r-- | tex/context/base/mkxl/tabl-mis.mkxl (renamed from tex/context/base/mkiv/tabl-mis.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/tabl-ntb.mkxl (renamed from tex/context/base/mkiv/tabl-ntb.mkxl) | 82 | ||||
-rw-r--r-- | tex/context/base/mkxl/tabl-nte.mkxl (renamed from tex/context/base/mkiv/tabl-nte.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/tabl-tab.mkxl (renamed from tex/context/base/mkiv/tabl-tab.mkxl) | 16 | ||||
-rw-r--r-- | tex/context/base/mkxl/tabl-tbl.mkxl (renamed from tex/context/base/mkiv/tabl-tbl.mkxl) | 42 | ||||
-rw-r--r-- | tex/context/base/mkxl/tabl-tsp.mkxl (renamed from tex/context/base/mkiv/tabl-tsp.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/tabl-xnt.mklx (renamed from tex/context/base/mkiv/tabl-xnt.mklx) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/tabl-xtb.mklx (renamed from tex/context/base/mkiv/tabl-xtb.mklx) | 22 | ||||
-rw-r--r-- | tex/context/base/mkxl/task-ini.mkxl (renamed from tex/context/base/mkiv/task-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/toks-aux.lmt (renamed from tex/context/base/mkiv/toks-aux.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/toks-aux.mkxl | 68 | ||||
-rw-r--r-- | tex/context/base/mkxl/toks-ini.lmt (renamed from tex/context/base/mkiv/toks-ini.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/toks-ini.mkxl (renamed from tex/context/base/mkiv/toks-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/toks-scn.lmt (renamed from tex/context/base/mkiv/toks-scn.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/toks-scn.mkxl (renamed from tex/context/base/mkiv/toks-scn.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/trac-ctx.mkxl (renamed from tex/context/base/mkiv/trac-ctx.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/trac-deb.lmt (renamed from tex/context/base/mkiv/trac-deb.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/trac-deb.mkxl (renamed from tex/context/base/mkiv/trac-deb.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/trac-inf.lmt (renamed from tex/context/base/mkiv/trac-inf.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/trac-jus.mkxl (renamed from tex/context/base/mkiv/trac-jus.mkxl) | 2 | ||||
-rw-r--r-- | tex/context/base/mkxl/trac-tex.mkxl (renamed from tex/context/base/mkiv/trac-tex.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/trac-tim.lmt (renamed from tex/context/base/mkiv/trac-tim.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/trac-vis.lmt (renamed from tex/context/base/mkiv/trac-vis.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/trac-vis.mkxl (renamed from tex/context/base/mkiv/trac-vis.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/type-def.mkxl | 48 | ||||
-rw-r--r-- | tex/context/base/mkxl/type-fbk.mkxl | 70 | ||||
-rw-r--r-- | tex/context/base/mkxl/type-ini.mklx (renamed from tex/context/base/mkiv/type-ini.mklx) | 125 | ||||
-rw-r--r-- | tex/context/base/mkxl/type-lua.mkxl | 86 | ||||
-rw-r--r-- | tex/context/base/mkxl/type-set.mkxl | 139 | ||||
-rw-r--r-- | tex/context/base/mkxl/type-siz.mkxl | 169 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-bld.mkxl | 62 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-brk.mkxl (renamed from tex/context/base/mkiv/typo-brk.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-cap.mkxl (renamed from tex/context/base/mkiv/typo-cap.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-chr.mkxl | 87 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-cln.mkxl (renamed from tex/context/base/mkiv/typo-cln.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-del.mkxl (renamed from tex/context/base/mkiv/typo-del.mkxl) | 11 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-dig.mkxl | 58 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-dir.mkxl (renamed from tex/context/base/mkiv/typo-dir.mkxl) | 13 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-drp.mkxl | 129 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-fkr.mkxl | 38 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-fln.mkxl | 109 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-ini.mkxl (renamed from tex/context/base/mkiv/typo-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-inj.mkxl (renamed from tex/context/base/mkiv/typo-inj.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-itc.mklx (renamed from tex/context/base/mkiv/typo-itc.mklx) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-itm.mkxl | 270 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-krn.mkxl (renamed from tex/context/base/mkiv/typo-krn.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-lan.mkxl (renamed from tex/context/base/mkiv/typo-lan.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-lig.mkxl (renamed from tex/context/base/mkiv/typo-lig.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-lin.lmt (renamed from tex/context/base/mkiv/typo-lin.lmt) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-lin.mkxl (renamed from tex/context/base/mkiv/typo-lin.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-mar.mkxl (renamed from tex/context/base/mkiv/typo-mar.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-ovl.mkxl | 116 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-pag.mkxl | 20 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-par.mkxl | 30 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-plc.mkxl | 39 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-pnc.mkxl (renamed from tex/context/base/mkiv/typo-pnc.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-prc.mklx | 99 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-rep.mkxl | 42 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-rub.mkxl | 173 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-scr.mkxl (renamed from tex/context/base/mkiv/typo-scr.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-spa.mkxl | 78 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-sus.mkxl | 51 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-tal.mkxl | 303 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-txt.mklx | 240 | ||||
-rw-r--r-- | tex/context/base/mkxl/typo-wrp.mkxl | 58 | ||||
-rw-r--r-- | tex/context/base/mkxl/unic-ini.mkxl (renamed from tex/context/base/mkiv/unic-ini.mkxl) | 0 | ||||
-rw-r--r-- | tex/context/interface/mkii/keys-de.xml | 5 | ||||
-rw-r--r-- | tex/context/interface/mkiv/context-en.xml | 624 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-boxes.xml | 6 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-catcodes.xml | 2 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-columns.xml | 108 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-common-argument.xml | 11 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-common-instance.xml | 5 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-context.pdf | bin | 959252 -> 964271 bytes | |||
-rw-r--r-- | tex/context/interface/mkiv/i-context.xml | 3 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-counter.xml | 3 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-document.xml | 22 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-filler.xml | 94 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-fonts.xml | 2 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-framed.xml | 7 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-hspace.xml | 28 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-hyphenation.xml | 12 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-itemgroup.xml | 4 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-linefiller.xml | 30 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-lua.xml | 47 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-marking.xml | 5 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-mathmatrix.xml | 10 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-note.xml | 2 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-pagenumber.xml | 1 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-parwrapper.xml | 80 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-readme.pdf | bin | 24972 -> 24996 bytes | |||
-rw-r--r-- | tex/context/interface/mkiv/i-replacement.xml | 4 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-setup.xml | 6 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-synonym.xml | 4 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-system.xml | 14 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-vspace.xml | 12 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-xml.xml | 11 | ||||
-rw-r--r-- | tex/context/modules/mkiv/m-chart.mkvi | 2 | ||||
-rw-r--r-- | tex/context/modules/mkiv/m-gnuplot.mkxl | 2 | ||||
-rw-r--r-- | tex/context/modules/mkiv/m-timing.mkxl | 14 | ||||
-rw-r--r-- | tex/context/modules/mkiv/s-system-macros.mkxl | 31 | ||||
-rw-r--r-- | tex/context/modules/mkiv/s-system-tokens.mkxl | 3 | ||||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 2 |
508 files changed, 27333 insertions, 2600 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index e9b6498ba..e264dc856 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2020.11.19 11:23} +\newcontextversion{2020.11.23 18:34} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 7b8c74210..a4eaeaf72 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2020.11.19 11:23} +\edef\contextversion{2020.11.23 18:34} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-de.mkii b/tex/context/base/mkii/mult-de.mkii index b9235f6b7..3e2caec87 100644 --- a/tex/context/base/mkii/mult-de.mkii +++ b/tex/context/base/mkii/mult-de.mkii @@ -774,6 +774,7 @@ \setinterfaceconstant{deepnumbercommand}{deepnumbercommand} \setinterfaceconstant{deeptextcommand}{deeptextcommand} \setinterfaceconstant{default}{default} +\setinterfaceconstant{define}{define} \setinterfaceconstant{delay}{wartezeit} \setinterfaceconstant{depth}{tiefe} \setinterfaceconstant{depthcorrection}{tiefekorrektur} @@ -2073,7 +2074,7 @@ \setinterfacecommand{startnarrower}{startenger} \setinterfacecommand{startopposite}{startgegenueber} \setinterfacecommand{startoverlay}{startoverlay} -\setinterfacecommand{startoverzicht}{startueberblick} +\setinterfacecommand{startoverview}{startueberblick} \setinterfacecommand{startpacked}{startkleinerdurchschuss} \setinterfacecommand{startpositioning}{startpositionieren} \setinterfacecommand{startproduct}{startprodukt} @@ -2116,7 +2117,7 @@ \setinterfacecommand{stopnarrower}{stopenger} \setinterfacecommand{stopopposite}{stopgegenueber} \setinterfacecommand{stopoverlay}{stopoverlay} -\setinterfacecommand{stopoverzicht}{stopueberblick} +\setinterfacecommand{stopoverview}{stopueberblick} \setinterfacecommand{stoppacked}{stopkleinerdurchschuss} \setinterfacecommand{stoppositioning}{stoppositionieren} \setinterfacecommand{stopproduct}{stopprodukt} diff --git a/tex/context/base/mkiv/char-def.lua b/tex/context/base/mkiv/char-def.lua index 70e564399..79a210338 100644 --- a/tex/context/base/mkiv/char-def.lua +++ b/tex/context/base/mkiv/char-def.lua @@ -71060,6 +71060,7 @@ characters.data={ [0x2423]={ adobename="blank", category="so", + contextname="textcontrolspace", description="OPEN BOX", direction="on", linebreak="al", diff --git a/tex/context/base/mkiv/char-tex.lua b/tex/context/base/mkiv/char-tex.lua index 1e86ca171..4580ae40a 100644 --- a/tex/context/base/mkiv/char-tex.lua +++ b/tex/context/base/mkiv/char-tex.lua @@ -679,15 +679,15 @@ if not csletters then if is_character[category] then if chr.unicodeslot < 128 then if isletter then - texsetmacro(contextname,utfchar(u),"permanent") + texsetmacro(contextname,utfchar(u),"immutable") else texsetchar(contextname,u) end else - texsetmacro(contextname,utfchar(u),"permanent") + texsetmacro(contextname,utfchar(u),"immutable") end elseif is_command[category] and not forbidden[u] then - texsetmacro(contextname,utfchar(u),"permanent") + texsetmacro(contextname,utfchar(u),"immutable") end end end diff --git a/tex/context/base/mkiv/cont-fil.mkiv b/tex/context/base/mkiv/cont-fil.mkiv index aa7d9ddb3..edef8dbc8 100644 --- a/tex/context/base/mkiv/cont-fil.mkiv +++ b/tex/context/base/mkiv/cont-fil.mkiv @@ -149,9 +149,4 @@ %definefilesynonym [set-13] [setups-proofing] %definefilesynonym [set-15] [setups-generate] -\ifcase\contextlmtxmode \else - \definefilesynonym [ecmascript] [libs-imp-mujs] - \definefilesynonym [zint] [libs-imp-zint] -\fi - \endinput diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 53f8ab353..6ff794299 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2020.11.19 11:23} +\newcontextversion{2020.11.23 18:34} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc @@ -35,16 +35,10 @@ \ifdefined\w \else \unexpanded\def\w{\mathortext\word\mathword} \fi \appendtoks - \enforced\overloaded\let\t\mathtext - \enforced\overloaded\let\w\mathword + \let\t\mathtext + \let\w\mathword \to \everymathematics -\pushoverloadmode - % charts needs these - \overloaded\unletfrozen\name % for now - \overloaded\frozen\let\type\type -\popoverloadmode - %D We're done. \protect \endinput diff --git a/tex/context/base/mkiv/cont-run.mkiv b/tex/context/base/mkiv/cont-run.mkiv index fba9cfaa9..12c12e0d9 100644 --- a/tex/context/base/mkiv/cont-run.mkiv +++ b/tex/context/base/mkiv/cont-run.mkiv @@ -53,16 +53,12 @@ \unexpanded\def\blocksynctexfile[#1]% {\processcommacommand{#1}\synctexblockfilename} -\ifcase\contextlmtxmode - \def\continuewhenlmtxmode - {\starttext - \startTEXpage[\c!offset=2ex,\c!foregroundstyle=\tttf]% - This file needs \LuaMetaTeX\ and \ConTeXt\ \LMTX.% - \stopTEXpage - \stoptext - \endinput} -\else - \let\continuewhenlmtxmode\relax -\fi +\def\continuewhenlmtxmode + {\starttext + \startTEXpage[\c!offset=2ex,\c!foregroundstyle=\tttf]% + This file needs \LuaMetaTeX\ and \ConTeXt\ \LMTX.% + \stopTEXpage + \stoptext + \endinput} \protect \endinput diff --git a/tex/context/base/mkiv/cont-yes.mkiv b/tex/context/base/mkiv/cont-yes.mkiv index f9af8fcee..d17c4878c 100644 --- a/tex/context/base/mkiv/cont-yes.mkiv +++ b/tex/context/base/mkiv/cont-yes.mkiv @@ -11,89 +11,6 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -% At some point I will reconsider the \starttext .. \stoptext -% wraping as we can assume proper styling. It's a left-over from -% mkii that we need to get rid of. - -% now moved to cont-run.lua -% -% \startluacode -% -% -- When a style is loaded there is a good change that we never enter -% -- this code. -% -% local report = logs.reporter("system") -% -% environment.initializefilenames() -- todo: check if we really need to pre-prep the filename -% -% local arguments = environment.arguments -% local suffix = environment.suffix -% local filename = environment.filename -- hm, not inputfilename ! -% -% if suffix == "xml" or arguments.forcexml then -% -% -- Maybe we should move the preamble parsing here as it -% -- can be part of (any) loaded (sub) file. The \starttext -% -- wrapping might go away. -% -% report("processing as xml: %s",filename) -% -% context.starttext() -% context.xmlprocess("main",filename,"") -% context.stoptext() -% -% elseif suffix == "cld" or arguments.forcecld then -% -% report("processing as cld: %s",filename) -% -% context.runfile(filename) -% -% elseif suffix == "lua" or arguments.forcelua then -% -% -- The wrapping might go away. Why is is it there in the -% -- first place. -% -% report("processing as lua: %s",filename) -% -% context.starttext() -% context.ctxlua(string.format('dofile("%s")',filename)) -% context.stoptext() -% -% elseif suffix == "mp" or arguments.forcemp then -% -% report("processing as metapost: %s",filename) -% -% context.starttext() -% context.processMPfigurefile(filename) -% context.stoptext() -% -% -- elseif suffix == "prep" then -% -- -% -- -- Why do we wrap here. Because it can be xml? Let's get rid -% -- -- of prepping in general. -% -- -% -- context.starttext() -% -- context.input(filename) -% -- context.stoptext() -% -% else -% -% -- \writestatus{system}{processing as tex} -% -- We have a regular tex file so no \starttext yet as we can -% -- load fonts. -% -% -- context.enabletrackers { "resolvers.*" } -% context.input(filename) -% -- context.disabletrackers { "resolvers.*" } -% -% end -% -% context.finishjob() -% -% \stopluacode - -% We don't want to be in protected mode! - -\processjob % from cont-run.lua +\processjob \endinput diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 2331cd2e2..0e8437dc0 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2020.11.19 11:23} +\edef\contextversion{2020.11.23 18:34} %D Kind of special: @@ -462,8 +462,6 @@ \loadmarkfile{lang-wrd} % can be optional (discussion with mm sideeffect) \loadmarkfile{lang-rep} % can be optional (bt 2013 side effect) -\loadmarkfile{prop-ini} % only for downward compatibility - \loadmarkfile{mlib-ctx} % messy order \loadmarkfile{meta-ini} diff --git a/tex/context/base/mkiv/font-lib.mkvi b/tex/context/base/mkiv/font-lib.mkvi index f4a20c8df..db9df49cd 100644 --- a/tex/context/base/mkiv/font-lib.mkvi +++ b/tex/context/base/mkiv/font-lib.mkvi @@ -49,17 +49,13 @@ \registerctxluafile{font-osd}{} %registerctxluafile{font-osm}{} -\ifcase\contextlmtxmode - \ifcase\directlua{tex.print(callback.list()["provide_charproc_data"] == false and 1 or 0)}\relax - % this is the generic variant that will become luatex-fonts-ocl once we have - % more recent versions of luatex 1.13/1.14 on the garden - \registerctxluafile{font-ocl}{} - \else - \registerctxluafile{font-ocm}{} - \fi -\else - \registerctxluafile{font-ogr}{autosuffix} % lmtx -\fi +% \ifcase\directlua{tex.print(callback.list()["provide_charproc_data"] == false and 1 or 0)}\relax +% % this is the generic variant that will become luatex-fonts-ocl once we have +% % more recent versions of luatex 1.13/1.14 on the garden + \registerctxluafile{font-ocl}{} +% \else +% \registerctxluafile{font-ocm}{} +% \fi % we use otf code for type one diff --git a/tex/context/base/mkiv/luat-ini.mkiv b/tex/context/base/mkiv/luat-ini.mkiv index 053e2ea4d..09014ad86 100644 --- a/tex/context/base/mkiv/luat-ini.mkiv +++ b/tex/context/base/mkiv/luat-ini.mkiv @@ -130,7 +130,6 @@ \protected\def\setdocumentargumentdefault#1#2{\clf_setdocumentdefaultargument{#1}{#2}} \def\getdocumentfilename #1{\clf_getdocumentfilename\numexpr#1\relax} \def\getdocumentargument #1{\clf_getdocumentargument{#1}{}} -\protected\def\setdocumentargument #1#2{\clf_setdocumentargument{#1}{#2}} \def\getdocumentargumentdefault#1#2{\clf_getdocumentargument{#1}{#2}} % seldom used so no need for speedy variants: diff --git a/tex/context/base/mkiv/luat-lib.mkiv b/tex/context/base/mkiv/luat-lib.mkiv index e89747de7..6dbcdaf54 100644 --- a/tex/context/base/mkiv/luat-lib.mkiv +++ b/tex/context/base/mkiv/luat-lib.mkiv @@ -45,10 +45,6 @@ \registerctxluafile{util-soc-imp-http} {} \registerctxluafile{util-soc-imp-tp} {} -\ifcase\contextlmtxmode\else - \registerctxluafile{util-zip}{} -\fi - \registerctxluafile{data-ini}{} \registerctxluafile{data-exp}{} \registerctxluafile{data-env}{} @@ -73,10 +69,6 @@ \registerctxluafile{data-use}{} \registerctxluafile{data-aux}{} -% \ifcase\contextlmtxmode -% \registerctxluafile{util-lib}{} -% \fi - \registerctxluafile{luat-cbk}{} \registerctxluafile{luat-run}{} \registerctxluafile{luat-fio}{autosuffix} @@ -99,8 +91,8 @@ \registerctxluafile{lxml-aux}{} \registerctxluafile{lxml-mis}{} -\frozen\overloaded\protected\def\writestatus#1#2{\ctxlua{logs.status([==[#1]==],[==[#2]==])}} -\frozen\overloaded\protected\def\writestring #1{\ctxlua{logs.writer([==[#1]==],"\string\n")}} -\frozen\overloaded\protected\def\writeline {\ctxlua{logs.newline()}} +\protected\def\writestatus#1#2{\ctxlua{logs.status([==[#1]==],[==[#2]==])}} +\protected\def\writestring #1{\ctxlua{logs.writer([==[#1]==],"\string\n")}} +\protected\def\writeline {\ctxlua{logs.newline()}} \endinput diff --git a/tex/context/base/mkiv/math-ini.lua b/tex/context/base/mkiv/math-ini.lua index 4f7e803d0..b5c4581b7 100644 --- a/tex/context/base/mkiv/math-ini.lua +++ b/tex/context/base/mkiv/math-ini.lua @@ -231,37 +231,38 @@ local setmathcharacter = function(class,family,slot,unicode,mset,dset) return mset, dset end -local f_accent = formatters[ [[\ugdef\%s{\Umathaccent 0 "%X "%X }]] ] -local f_topaccent = formatters[ [[\ugdef\%s{\Umathaccent 0 "%X "%X }]] ] -local f_botaccent = formatters[ [[\ugdef\%s{\Umathbotaccent 0 "%X "%X }]] ] -local f_over = formatters[ [[\ugdef\%s{\Udelimiterover "%X "%X }]] ] -local f_under = formatters[ [[\ugdef\%s{\Udelimiterunder "%X "%X }]] ] -local f_fence = formatters[ [[\ugdef\%s{\Udelimiter "%X "%X "%X }]] ] -local f_delimiter = formatters[ [[\ugdef\%s{\Udelimiter 0 "%X "%X }]] ] -local f_radical = formatters[ [[\ugdef\%s{\Uradical "%X "%X }]] ] -local f_root = formatters[ [[\ugdef\%s{\Uroot "%X "%X }]] ] ------ f_char = formatters[ [[\ugdef\%s{\Umathchar "%X "%X "%X }]] -local f_char = formatters[ [[\Umathchardef\%s "%X "%X "%X ]] ] +-- todo: make nice setters for this in lua + +local f_accent = formatters[ [[\defUmathtopaccent \%s{%X}{%X}{%X}]] ] +local f_topaccent = formatters[ [[\defUmathtopaccent \%s{%X}{%X}{%X}]] ] +local f_botaccent = formatters[ [[\defUmathbotaccent \%s{%X}{%X}{%X}]] ] +local f_over = formatters[ [[\defUdelimiterover \%s{%X}{%X}{%X}]] ] +local f_under = formatters[ [[\defUdelimiterunder\%s{%X}{%X}{%X}]] ] +local f_fence = formatters[ [[\defUdelimiter \%s{%X}{%X}{%X}]] ] +local f_delimiter = formatters[ [[\defUdelimiter \%s{%X}{%X}{%X}]] ] +local f_radical = formatters[ [[\defUradical \%s{%X}{%X}]] ] +local f_root = formatters[ [[\defUroot \%s{%X}{%X}]] ] +local f_char = formatters[ [[\defUmathchar \%s{%X}{%X}{%X}]] ] local texmathchardef = tex.mathchardef local setmathsymbol = function(name,class,family,slot) -- hex is nicer for tracing if class == classes.accent then - ctx_sprint(f_accent(name,family,slot)) + ctx_sprint(f_topaccent(name,0,family,slot)) elseif class == classes.topaccent then - ctx_sprint(f_topaccent(name,family,slot)) + ctx_sprint(f_topaccent(name,0,family,slot)) elseif class == classes.botaccent then - ctx_sprint(f_botaccent(name,family,slot)) + ctx_sprint(f_botaccent(name,0,family,slot)) elseif class == classes.over then - ctx_sprint(f_over(name,family,slot)) + ctx_sprint(f_over(name,0,family,slot)) elseif class == classes.under then - ctx_sprint(f_under(name,family,slot)) + ctx_sprint(f_under(name,0,family,slot)) elseif class == open_class or class == close_class or class == middle_class then setdelcode("global",slot,{family,slot,0,0}) ctx_sprint(f_fence(name,class,family,slot)) elseif class == classes.delimiter then setdelcode("global",slot,{family,slot,0,0}) - ctx_sprint(f_delimiter(name,family,slot)) + ctx_sprint(f_delimiter(name,0,family,slot)) elseif class == classes.radical then ctx_sprint(f_radical(name,family,slot)) elseif class == classes.root then diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua index 6d6813fde..661a444de 100644 --- a/tex/context/base/mkiv/mult-def.lua +++ b/tex/context/base/mkiv/mult-def.lua @@ -5996,7 +5996,7 @@ return { ["pe"]="شروعپوشش", ["ro"]="startoverlay", }, - ["startoverzicht"]={ + ["startoverview"]={ ["cs"]="startprehled", ["de"]="startueberblick", ["en"]="startoverview", @@ -6410,7 +6410,7 @@ return { ["pe"]="پایانپوشش", ["ro"]="stopoverlay", }, - ["stopoverzicht"]={ + ["stopoverview"]={ ["cs"]="stopprehled", ["de"]="stopueberblick", ["en"]="stopoverview", @@ -8354,6 +8354,10 @@ return { ["pe"]="فرمانمتنعمیق", ["ro"]="deeptextcommand", }, + ["define"]={ + ["en"]="define", + ["nl"]="definieer", + }, ["default"]={ ["cs"]="implicitni", ["de"]="default", diff --git a/tex/context/base/mkiv/mult-prm.lua b/tex/context/base/mkiv/mult-prm.lua index 3d0f65dba..c60ed1640 100644 --- a/tex/context/base/mkiv/mult-prm.lua +++ b/tex/context/base/mkiv/mult-prm.lua @@ -291,8 +291,10 @@ return { "futureexpand", "futureexpandis", "futureexpandisap", + "gdefcsname", "gleaders", "glet", + "gletcsname", "glyphdatafield", "glyphdimensionsmode", "glyphoptions", @@ -425,11 +427,13 @@ return { "tpack", "tracingfonts", "tracingmath", + "undent", "unletfrozen", "unletprotected", "vpack", "wordboundary", "wrapuppar", + "xdefcsname", "xtoksapp", "xtokspre", }, diff --git a/tex/context/base/mkiv/node-ref.lua b/tex/context/base/mkiv/node-ref.lua index e0bd35f6b..098ed50c2 100644 --- a/tex/context/base/mkiv/node-ref.lua +++ b/tex/context/base/mkiv/node-ref.lua @@ -429,9 +429,14 @@ local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,tx else if id == glue_code then local subtype = getsubtype(current) + -- todo in lmtx: lefthangskip and righthangskip if subtype == leftskip_code or subtype == parfillleftskip_code then goto NEXT elseif subtype == rightskip_code or subtype == parfillskip_code then + if reference and (done[reference] or 0) == 0 then + head, current = inject_range(head,first,last,reference,make,stack,parent,pardir,firstdir) + reference, first, last, firstdir = nil, nil, nil, nil + end goto NEXT end end diff --git a/tex/context/base/mkiv/page-imp.mkiv b/tex/context/base/mkiv/page-imp.mkiv index a83089986..829ed24f4 100644 --- a/tex/context/base/mkiv/page-imp.mkiv +++ b/tex/context/base/mkiv/page-imp.mkiv @@ -167,11 +167,7 @@ % \def\page_shipout_box#1{\normalshipout\box#1\relax} % takes a number -\ifcase\contextlmtxmode - \def\page_shipout_show_box{\scratchcounter} -\else - \def\page_shipout_show_box{\showbox diagnose} -\fi +\def\page_shipout_show_box{\scratchcounter} \unexpanded\def\page_shipout_box#1% {\ifcase\tracingoutput\else diff --git a/tex/context/base/mkiv/page-ins.mkiv b/tex/context/base/mkiv/page-ins.mkiv index 96088b79e..6f2b56f82 100644 --- a/tex/context/base/mkiv/page-ins.mkiv +++ b/tex/context/base/mkiv/page-ins.mkiv @@ -51,13 +51,8 @@ \fi \to \everysetupinsertion -\ifcase\contextlmtxmode - \setupinsertion - [\c!anchoring=\v!none] -\else - \setupinsertion - [\c!anchoring=\v!auto] -\fi +\setupinsertion + [\c!anchoring=\v!none] \appendtoks \page_inserts_check_anchoring diff --git a/tex/context/base/mkiv/prop-ini.mkiv b/tex/context/base/mkiv/prop-ini.mkiv deleted file mode 100644 index 3b1c59b24..000000000 --- a/tex/context/base/mkiv/prop-ini.mkiv +++ /dev/null @@ -1,64 +0,0 @@ -%D \module -%D [ file=prop-ini, -%D version=2003.04.20, -%D title=\CONTEXT\ Property Macros, -%D subtitle=Initialization, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\writestatus{loading}{ConTeXt Property Macros / Initialization} - -%D This module is replaced by dedicated mechanisms. Originally properties were -%D a sort of attributes in \MKII, but now we do things different anyway. We keep -%D a surrogate mechanism around for compatibility reasons but even this will -%D become obsolete some day. - -\unprotect - -\installcorenamespace{propertytypes} -\installcorenamespace{propertydefiners} -\installcorenamespace{propertystarters} - -\def\properties_obsolete_message - {\writestatus\m!system{properties are obsolete, use dedicated commands}% - \glet\properties_obsolete_message\donothing} - -\setvalue{\??propertydefiners\v!layer }[#1][#2][#3]{\defineviewerlayer[#1][#3]} -\setvalue{\??propertydefiners\s!effect }[#1][#2][#3]{\defineeffect [#1][#3]} -\setvalue{\??propertydefiners\v!negative}[#1][#2][#3]{} - -\unexpanded\def\defineproperty - {\dotripleempty\properties_define} - -\def\properties_define[#1][#2][#3]% - {\properties_obsolete_message - \setevalue{\??propertytypes#1}{#2}% - \getvalue{\??propertydefiners#2}[#1][#2][#3]} - -\setvalue{\??propertystarters\v!layer }#1{\let\properties_stop\stopviewerlayer\startviewerlayer[#1]} -\setvalue{\??propertystarters\s!effect }#1{\let\properties_stop\stopeffect \starteffect [#1]} -\setvalue{\??propertystarters\v!negative}#1{\let\properties_stop\stopnegative \startnegative } - -\unexpanded\def\property[#1]% - {\groupedcommand{\properties_start{#1}}\properties_stop} - -\unexpanded\def\startproperty[#1]% - {\properties_start{#1}} - -\unexpanded\def\stopproperty - {\properties_stop} - -\unexpanded\def\properties_start#1% - {\pushmacro\properties_stop - \getvalue{\??propertystarters\getvalue{\??propertytypes#1}}{#1}} - -\unexpanded\def\properties_stop - {\properties_stop - \popmacro\properties_stop} - -\protect \endinput diff --git a/tex/context/base/mkiv/scrp-ini.mkiv b/tex/context/base/mkiv/scrp-ini.mkiv index ab934fe3b..4eb3f29e3 100644 --- a/tex/context/base/mkiv/scrp-ini.mkiv +++ b/tex/context/base/mkiv/scrp-ini.mkiv @@ -42,9 +42,7 @@ \registerctxluafile{scrp-tha}{} \registerctxluafile{scrp-tib}{} -\ifcase \contextlmtxmode - \definesystemattribute[script][public,pickup] -\fi +\definesystemattribute[script][public,pickup] %D Since scripts need specific \LUA\ code we use hard coded attribute values, but we %D might have more tricks at some time, so we use a proper define macro too. diff --git a/tex/context/base/mkiv/spac-chr.lua b/tex/context/base/mkiv/spac-chr.lua index 899d274b4..ac90926e1 100644 --- a/tex/context/base/mkiv/spac-chr.lua +++ b/tex/context/base/mkiv/spac-chr.lua @@ -129,7 +129,8 @@ end local function nbsp(head,current) local para = fontparameters[getfont(current)] - if getattr(current,a_alignstate) == 1 then -- flushright + local attr = getattr(current,a_alignstate) or 0 + if attr >= 1 or attr <= 3 then -- flushright head, current = inject_nobreak_space(0x00A0,head,current,para.space,0,0) else head, current = inject_nobreak_space(0x00A0,head,current,para.space,para.spacestretch,para.spaceshrink) diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 01700f5fc..c96cba81a 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 09db66519..cbfa899a4 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-lev.mkvi b/tex/context/base/mkiv/strc-lev.mkvi index cfb704fc9..b8b633c32 100644 --- a/tex/context/base/mkiv/strc-lev.mkvi +++ b/tex/context/base/mkiv/strc-lev.mkvi @@ -23,31 +23,33 @@ \unprotect -\permanent\tolerant\protected\def\definesectionlevels[#category]#spacer[#list]% - {\clf_definesectionlevels{#category}{#list}} % we could scan/use public at the lua end +\unexpanded\def\definesectionlevels{\dodoubleargument\strc_levels_define} +\unexpanded\def\startsectionlevel {\dosingleempty \strc_levels_start_section} +\unexpanded\def\startsubjectlevel {\dosingleempty \strc_levels_start_subject} -\permanent\tolerant\protected\def\startsectionlevel[#category]% +\unexpanded\def\strc_levels_define[#category][#list]{\clf_definesectionlevels{#category}{#list}} +\unexpanded\def\stopsectionlevel {\clf_stopsectionlevel} +\unexpanded\def\stopsubjectlevel {\clf_stopsectionlevel} + +\unexpanded\def\nostarthead{\dotripleargument\strc_levels_start_nop} % used at the lua end +\unexpanded\def\nostophead {\dosingleargument\strc_levels_stop_nop } % used at the lua end + +\unexpanded\def\strc_levels_start_section[#category]% {\doifelseassignment{#category}% {\clf_startsectionlevel\plusone{\v!default}{\currentnamedsection}[#category]}% {\clf_startsectionlevel\plusone {#category}{\currentnamedsection}}} -\permanent\protected\def\stopsectionlevel - {\clf_stopsectionlevel} % we could use public at the lua end - -\permanent\tolerant\protected\def\startsubjectlevel[#category]% +\unexpanded\def\strc_levels_start_subject[#category]% {\doifelseassignment{#category}% {\clf_startsectionlevel\plustwo{\v!default}{\currentnamedsection}[#category]}% {\clf_startsectionlevel\plustwo {#category}{\currentnamedsection}}} -\permanent\protected\def\stopsubjectlevel - {\clf_stopsectionlevel} % we could use public at the lua end - -\permanent\tolerant\protected\def\nostarthead[#category]#spacer[#settings]#spacer[#userdata]% +\unexpanded\def\strc_levels_start_nop[#category][#settings][#userdata]% {\blank \noindentation{\tttf[start missing section level #category]} \blank} -\permanent\tolerant\protected\def\nostarthead[#category]% +\unexpanded\def\strc_levels_stop_nop[#category]% {\blank \noindentation{\tttf[stop missing section level #category]} \blank} @@ -61,9 +63,9 @@ {\v!subsubsubsection,\v!subsubsubject}, {\v!subsubsubsubsection,\v!subsubsubject}] -\aliased\let\definestructurelevels\definesectionlevels -\aliased\let\startstructurelevel \startsectionlevel -\aliased\let\stopstructurelevel \stopsectionlevel +\let\definestructurelevels\definesectionlevels +\let\startstructurelevel \startsectionlevel +\let\stopstructurelevel \stopsectionlevel \protect \endinput diff --git a/tex/context/base/mkiv/supp-dir.mkxl b/tex/context/base/mkiv/supp-dir.mkxl deleted file mode 100644 index e6c2a5869..000000000 --- a/tex/context/base/mkiv/supp-dir.mkxl +++ /dev/null @@ -1,54 +0,0 @@ -%D \module -%D [ file=supp-dir, -%D version=2004.11.11, -%D title=\CONTEXT\ Support Macros, -%D subtitle=Directional Things, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\unprotect - -\chardef\directionlefttoright\zerocount -\chardef\directionrighttoleft\plusone - -\edef\??bdir{\ifdefined\bodydir bdir\else direction\fi} - -\protected\edef\naturalhbox {\hbox \??bdir\directionlefttoright} -\protected\edef\naturalvbox {\vbox \??bdir\directionlefttoright} -\protected\edef\naturalvtop {\vtop \??bdir\directionlefttoright} -\protected\edef\naturalhpack {\hpack \??bdir\directionlefttoright} -\protected\edef\naturalvpack {\vpack \??bdir\directionlefttoright} -\protected\edef\naturaltpack {\tpack \??bdir\directionlefttoright} - -\protected\edef\reversehbox {\hbox \??bdir\directionrighttoleft} -\protected\edef\reversevbox {\vbox \??bdir\directionrighttoleft} -\protected\edef\reversevtop {\vtop \??bdir\directionrighttoleft} -\protected\edef\reversehpack {\hpack \??bdir\directionrighttoleft} -\protected\edef\reversevpack {\vpack \??bdir\directionrighttoleft} -\protected\edef\reversetpack {\tpack \??bdir\directionrighttoleft} - -\ifdefined\bodydir - \let\bodydir \undefined \let\normalbodydir \undefined - \let\bodydirection\undefined \let\normalbodydirection\undefined -\fi - -\ifdefined\pagedir - \let\pagedir \undefined \let\normalpagedir \undefined - \let\pagedirection\undefined \let\normalpagedirection\undefined -\fi - -% \expanded{\defineactivecharacter \number"2000E} {\textdirection\directionrighttoleft\relax} -% \expanded{\defineactivecharacter \number"2000F} {\textdirection\directionlefttoright\relax} - -\def\syst_direction_string#1{\ifcase#1=\plusone r2l\else l2r\fi} - -\protected\def\showdirsinmargin - {\normalexpanded{\inleft{\naturalhbox - {\ttxx[\syst_direction_string\pardirection,\syst_direction_string\textdirection]}}}} - -\protect \endinput diff --git a/tex/context/base/mkiv/syst-ini.mkiv b/tex/context/base/mkiv/syst-ini.mkiv index b1ba9e0f3..6b84d33df 100644 --- a/tex/context/base/mkiv/syst-ini.mkiv +++ b/tex/context/base/mkiv/syst-ini.mkiv @@ -583,6 +583,17 @@ \protected\def\uedef{\protected\edef} \protected\def\uxdef{\protected\xdef} +% For now: + +\protected\def\defUmathtopaccent #1#2#3#4{\global\instance\protected\def#1{\Umathaccent "#2 "#3 "#4 }} +\protected\def\defUmathbotaccent #1#2#3#4{\global\instance\protected\def#1{\Umathbotaccent "#2 "#3 "#4 }} +\protected\def\defUdelimiterover #1#2#3#4{\global\instance\protected\def#1{\Udelimiterover "#2 "#3 }} +\protected\def\defUdelimiterunder #1#2#3#4{\global\instance\protected\def#1{\Udelimiterunder "#2 "#3 }} +\protected\def\defUdelimiter #1#2#3#4{\global\instance\protected\def#1{\Udelimiter "#2 "#2 "#4 }} +\protected\def\defUradical #1#2#3{\global\instance\protected\def#1{\Uradical "#2 "#3 }} +\protected\def\defUroot #1#2#3{\global\instance\protected\def#1{\Uroot "#2 "#3 }} +\protected\def\defUmathchar #1#2#3#4{\global\instance\Umathchardef #1 "#2 "#3 "#4 } + %D For a while we keep the following, as systems like tikz need it. Best %D not use that one \CONTEXT. diff --git a/tex/context/base/mkiv/toks-aux.mkiv b/tex/context/base/mkiv/toks-aux.mkiv index f66b51ec5..5b43de596 100644 --- a/tex/context/base/mkiv/toks-aux.mkiv +++ b/tex/context/base/mkiv/toks-aux.mkiv @@ -15,23 +15,6 @@ \unprotect -% The older \type {\scantokens} overload has been replace by a more modern -% one (in \LMTX): -% -% \protected\def\whatever#1[#2](#3)\relax{oeps #1 and #2 and #3 done ## error} -% \scratchtoks{foo \framed{\red 123}456} -% -% \showluatokens{123\what} -% \showluatokens\whatever -% \showluatokens\framed -% -% \showluatokens\scratchtoks -% \showluatokens\everypar - -\ifcase\contextlmtxmode \or - \registerctxluafile{toks-aux}{autosuffix} -\fi - \installcorenamespace {tokenlist} \unexpanded\def\definetokenlist[#1]% diff --git a/tex/context/base/mkiv/anch-bar.mkxl b/tex/context/base/mkxl/anch-bar.mkxl index 3587eb8a0..3587eb8a0 100644 --- a/tex/context/base/mkiv/anch-bar.mkxl +++ b/tex/context/base/mkxl/anch-bar.mkxl diff --git a/tex/context/base/mkiv/anch-bck.mklx b/tex/context/base/mkxl/anch-bck.mklx index 91e523d8f..3f0504c4b 100644 --- a/tex/context/base/mkiv/anch-bck.mklx +++ b/tex/context/base/mkxl/anch-bck.mklx @@ -323,9 +323,10 @@ \ifdim\lastskip>\zeropoint \advance\textbackgroundskip-\lastskip \fi - \ifgridsnapping \else \ifdim\textbackgroundskip>\zeropoint + \ifgridsnapping + \orelse\ifdim\textbackgroundskip>\zeropoint \kern\textbackgroundskip\nobreak - \fi \fi + \fi \nobreak \vskip-\dimexpr\lineheight+\parskip\relax % problem: we loose the hangindent \nobreak @@ -638,6 +639,8 @@ %D As an example we define a grid background: +\pushoverloadmode + \definetextbackground [\v!grid] [\c!state=\v!stop, @@ -647,7 +650,11 @@ \c!background=, \c!alternative=1] -\ifx\basegrid\undefined \else \overloaded\aliased\letcsname\v!grid\endcsname\basegrid \fi +\ifx\basegrid\undefined \else + \aliased\letcsname\v!grid\endcsname\basegrid +\fi + +\popoverloadmode %D Some examples (that might become modules anch-imp-whatever): diff --git a/tex/context/base/mkiv/anch-pgr.mkxl b/tex/context/base/mkxl/anch-pgr.mkxl index 3439fd5a2..62dfe02d5 100644 --- a/tex/context/base/mkiv/anch-pgr.mkxl +++ b/tex/context/base/mkxl/anch-pgr.mkxl @@ -32,7 +32,7 @@ \installcorenamespace{positioncleanup} \protected\def\anch_positions_set_action#1% - {\expandafter\gdef\csname\??positionaction#1\endcsname} % nicely gobbles spaces + {\gdefcsname\??positionaction#1\endcsname} % nicely gobbles spaces \permanent\protected\def\doifpositionaction#1% {\ifcsname\??positionaction#1\endcsname @@ -50,7 +50,7 @@ \aliased\let\doifpositionactionelse\doifelsepositionaction -\protected\def\dopositionaction#1% +\permanent\protected\def\dopositionaction#1% {\edef\currentpositionaction{#1}% \ifcsname\??positionaction\currentpositionaction\endcsname \anch_positions_action_indeed @@ -97,7 +97,8 @@ \def\anch_positions_cleanup_action % not in trialtypesetting {\ifcsname\??positioncleanup\currentpositionaction\endcsname \the\everycleanpositionaction - \setxvalue{\??positioncleanup\currentpositionaction}{\csname\??positioncleanup\currentpositionaction\endcsname}% + \xdefcsname\??positioncleanup\currentpositionaction\endcsname + {\csname\??positioncleanup\currentpositionaction\endcsname}% \fi} \permanent\protected\def\handlepositionaction#1\with#2\on#3% ugly, will change @@ -107,10 +108,10 @@ \normalexpanded{\anch_positions_set_action{\currentpositionanchor}{\noexpand\getvalue{\??positioncleanup\currentpositionanchor}}}% \let#1\relax \ifcsname\??positioncleanup\currentpositionanchor\endcsname - \setxvalue{\??positioncleanup\currentpositionanchor}% + \xdefcsname\??positioncleanup\currentpositionanchor\endcsname {\csname\??positioncleanup\currentpositionanchor\endcsname#1#2}% \else - \setxvalue{\??positioncleanup\currentpositionanchor}% + \xdefcsname\??positioncleanup\currentpositionanchor\endcsname {#1#2}% \fi \endgroup} @@ -207,16 +208,17 @@ %D %D \typebuffer[graphic] -\def\MPanchoridentifier{mpa} % {mp-anchor} +\immutable\def\MPanchoridentifier{mpa} % {mp-anchor} +\mutable \def\MPanchornumber {\the\realpageno} +\mutable \let\MPanchorid \empty %D The rest of the definitions concerning such overlays may look complicated, -\let\currentpositionoverlay\empty +\mutable\let\currentpositionoverlay\empty %D Position actions are automatically executed when a position is set. -\def\textbackgroundoverlay#1{\v!text#1} -\def\MPanchornumber {\the\realpageno} +\immutable\def\textbackgroundoverlay#1{\v!text#1} \permanent\protected\def\positionoverlay % the test prevents too many redundant positions {\ifpositioning % in (not used) text* position layers @@ -233,14 +235,14 @@ \fi \endgroup} -\def\MPoverlayanchor#1{\MPpos\MPanchorid} +\permanent\def\MPoverlayanchor#1{\MPpos\MPanchorid} \def\anch_positions_overlay_compose {\vpack to \d_overlay_height {%\writestatus{!!!}{\currentpositionoverlay/\MPanchoridentifier/\MPanchornumber}% \edef\MPanchorid{\currentpositionoverlay::\MPanchoridentifier:\MPanchornumber}% realpageno % \edef\MPanchor##1{\MPpos\MPanchorid}% - \let\MPanchor\MPoverlayanchor % no need to fetch it already, seldom used + \enforced\let\MPanchor\MPoverlayanchor % no need to fetch it already, seldom used \the\everyinsertpositionaction \copyposition{\currentpositionoverlay::\MPanchoridentifier}\MPanchorid \setbox\scratchbox\hbox to \d_overlay_width % \hpack @@ -272,7 +274,7 @@ \def\anch_positions_region_overlay_compose {\vpack to \d_overlay_height {\let\MPanchorid\currentpositionregion - \let\MPanchor\MPoverlayanchor % no need to fetch it already, seldom used + \enforced\let\MPanchor\MPoverlayanchor % no need to fetch it already, seldom used \the\everyinsertpositionaction \copyposition{\currentpositionoverlay::\MPanchoridentifier}\MPanchorid \setbox\scratchbox\hbox to \d_overlay_width % \hpack @@ -296,7 +298,7 @@ \ifdefined\checkpositionoverlays \else \let\checkpositionoverlays\relax \fi -\let\currentpositionoverlay\empty +\mutable\let\currentpositionoverlay\empty \def\anch_positions_overlay_start_yes#1% {\checkpositionoverlays @@ -343,6 +345,18 @@ \expandafter\gobbletwoarguments \fi{#1}{#2}} +% \unexpanded\def\MPpositiongraphic +% {\dodoublegroupempty\anch_positions_meta_graphic_direct} + +% \def\anch_positions_meta_graphic_direct#1% tag setups +% {\ifcsname\??positionmethod#1\endcsname % method +% \expandafter\anch_positions_meta_graphic_direct_indeed_method +% \else\ifcsname\??positiongraphic#1\endcsname +% \doubleexpandafter\anch_positions_meta_graphic_direct_indeed_normal +% \else +% \doubleexpandafter\anch_positions_meta_graphic_direct_indeed_unknown +% \fi\fi{#1}} + \def\anch_positions_meta_graphic_direct_method{\anch_positions_meta_graphic_direct\??positionmethod } \def\anch_positions_meta_graphic_direct_normal{\anch_positions_meta_graphic_direct\??positiongraphic} @@ -352,7 +366,8 @@ \edef\currentmpvariableclass{#2}% \anch_positions_meta_graphic_prepare \obeyMPboxorigin % do we also set the size ? when needed this must be done in mp ... might change - \enforced\def\MPpositiongraphic{\anch_positions_meta_graphic_nested{#3}}% takes two extra arguments + \enforced\tolerant\protected\def\MPpositiongraphic##=##*##={\anch_positions_meta_graphic_nested{#3}{##1}{##2}}% takes two extra arguments +% \def\anch_positions_meta_graphic_direct{\anch_positions_meta_graphic_nested{#3}}% takes two extra arguments \setbox\b_anch_positions_graphic\hbox % \hpack {\ignorespaces\begincsname#1#2\endcsname\removelastspace}% \smashbox\b_anch_positions_graphic @@ -368,7 +383,7 @@ \endgroup}% \permanent\def\startMPpositionmethod#1#2\stopMPpositionmethod - {\setgvalue{\??positionmethod#1}{#2}} % todo: var list here + {\gdefcsname\??positionmethod#1\endcsname{#2}} % todo: var list here \aliased\let\stopMPpositionmethod\relax diff --git a/tex/context/base/mkiv/anch-pos.lmt b/tex/context/base/mkxl/anch-pos.lmt index e1d9bd752..e1d9bd752 100644 --- a/tex/context/base/mkiv/anch-pos.lmt +++ b/tex/context/base/mkxl/anch-pos.lmt diff --git a/tex/context/base/mkiv/anch-pos.mkxl b/tex/context/base/mkxl/anch-pos.mkxl index e232d9cd3..53544fedc 100644 --- a/tex/context/base/mkiv/anch-pos.mkxl +++ b/tex/context/base/mkxl/anch-pos.mkxl @@ -82,8 +82,7 @@ \aliased\let\MPregion \MPr \aliased\let\MPcolumn \MPc \aliased\let\MPparagraph\MPn - - \let\MPanchor \MPpos % overloaded locally when needed (todo: LMTX) +\aliased\let\MPanchor \MPpos % overloaded locally when needed (todo: LMTX) \aliased\let\MPleftskip \MPls % compatible feature \aliased\let\MPrightkip \MPrs % compatible feature diff --git a/tex/context/base/mkiv/anch-snc.mkxl b/tex/context/base/mkxl/anch-snc.mkxl index 5f0246155..51fb02d7c 100644 --- a/tex/context/base/mkiv/anch-snc.mkxl +++ b/tex/context/base/mkxl/anch-snc.mkxl @@ -28,15 +28,12 @@ \let\c_sync_n\relax -\unexpanded\def\definesyncpositions[#1]% +\permanent\protected\def\definesyncpositions[#1]% {\ifcsname\??syncposcounter:#1\endcsname \else \expandafter\newcount\csname\??syncposcounter:#1\endcsname \fi} -\unexpanded\def\syncposition - {\dodoubleempty\anch_sync_position} - -\def\anch_sync_position[#1][#2]% we could actually use par positions +\permanent\tolerant\protected\def\syncposition[#1]#*[#2]% we could actually use par positions {\dontleavehmode \ifcsname\??syncposcounter:#1\endcsname \let\c_sync_n\lastnamedcs diff --git a/tex/context/base/mkiv/anch-tab.mkxl b/tex/context/base/mkxl/anch-tab.mkxl index 8f4bb0b5b..8f4bb0b5b 100644 --- a/tex/context/base/mkiv/anch-tab.mkxl +++ b/tex/context/base/mkxl/anch-tab.mkxl diff --git a/tex/context/base/mkiv/attr-col.mkxl b/tex/context/base/mkxl/attr-col.mkxl index c75f448e9..c75f448e9 100644 --- a/tex/context/base/mkiv/attr-col.mkxl +++ b/tex/context/base/mkxl/attr-col.mkxl diff --git a/tex/context/base/mkiv/attr-eff.mkxl b/tex/context/base/mkxl/attr-eff.mkxl index 04a0c55ce..04a0c55ce 100644 --- a/tex/context/base/mkiv/attr-eff.mkxl +++ b/tex/context/base/mkxl/attr-eff.mkxl diff --git a/tex/context/base/mkiv/attr-ini.mkxl b/tex/context/base/mkxl/attr-ini.mkxl index 47e680c25..de22cd6e2 100644 --- a/tex/context/base/mkiv/attr-ini.mkxl +++ b/tex/context/base/mkxl/attr-ini.mkxl @@ -28,7 +28,7 @@ \permanent\protected\def\pushattribute#1% {\global\advance\csname\??attributestack\string#1\endcsname\plusone - \global\defcsname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname{\number\attribute#1}} + \gdefcsname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname{\number\attribute#1}} \permanent\protected\def\popattribute#1% {\attribute#1\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname\relax @@ -69,13 +69,13 @@ \doifinset\s!nomath{#3}% {\xtoksapp\t_attr_list_nomath{\csname\??attributeprefix#2\endcsname\attributeunsetvalue}}% \doifinset\s!public{#3}% - {\aliased\global\letcsname#2\s!attribute\expandafter\endcsname\csname\??attributeid#2\endcsname}% \attribute\fooattribute + {\aliased\gletcsname#2\s!attribute\expandafter\endcsname\csname\??attributeid#2\endcsname}% \attribute\fooattribute \doifinset\s!pickup{#3}% {\global\expandafter\integerdef\csname\??attributepickup#2\endcsname\attributeunsetvalue \xtoksapp\t_attr_list_pickup{\csname\??attributeprefix#2\endcsname\csname\??attributepickup#2\endcsname}% \ifcsname#2\s!attribute\endcsname - \global\edefcsname\s!pickup#2\s!attribute\endcsname{\expandafter\integerdef\csname\??attributepickup#2\endcsname\csname\??attributeprefix#2\endcsname}% - \global\edefcsname\s!forget#2\s!attribute\endcsname{\expandafter\integerdef\csname\??attributepickup#2\endcsname\attributeunsetvalue}% + \xdefcsname\s!pickup#2\s!attribute\endcsname{\expandafter\integerdef\csname\??attributepickup#2\endcsname\csname\??attributeprefix#2\endcsname}% + \xdefcsname\s!forget#2\s!attribute\endcsname{\expandafter\integerdef\csname\??attributepickup#2\endcsname\attributeunsetvalue}% \fi}% \fi} diff --git a/tex/context/base/mkiv/attr-lay.lmt b/tex/context/base/mkxl/attr-lay.lmt index d0febb9ee..d0febb9ee 100644 --- a/tex/context/base/mkiv/attr-lay.lmt +++ b/tex/context/base/mkxl/attr-lay.lmt diff --git a/tex/context/base/mkiv/attr-lay.mkxl b/tex/context/base/mkxl/attr-lay.mkxl index 4e8a56eba..6cb1387ca 100644 --- a/tex/context/base/mkiv/attr-lay.mkxl +++ b/tex/context/base/mkxl/attr-lay.mkxl @@ -76,7 +76,7 @@ \permanent\def\attr_layoutcomponent_initialize#1% {\edef\layoutcomponentboxattribute{\clf_definedlayoutcomponent{#1}}% \edef\layoutcomponentboxattribute{attr \viewerlayerattribute \layoutcomponentboxattribute\relax}% - \global\letcsname\??layoutcomponentattribute#1\endcsname\layoutcomponentboxattribute} + \gletcsname\??layoutcomponentattribute#1\endcsname\layoutcomponentboxattribute} \permanent\def\attr_layoutcomponent_set#1% make this faster {\expandafter\let\expandafter\layoutcomponentboxattribute\csname\??layoutcomponentattribute#1\endcsname @@ -91,7 +91,7 @@ \permanent\let\resetlayoutcomponentattribute\relax \let\layoutcomponentboxattribute \empty -\protected\def\showlayoutcomponents +\permanent\protected\def\showlayoutcomponents {\enforced\let\setlayoutcomponentattribute \attr_layoutcomponent_set \enforced\let\resetlayoutcomponentattribute\attr_layoutcomponent_reset} diff --git a/tex/context/base/mkiv/attr-mkr.mkxl b/tex/context/base/mkxl/attr-mkr.mkxl index 2209af241..2209af241 100644 --- a/tex/context/base/mkiv/attr-mkr.mkxl +++ b/tex/context/base/mkxl/attr-mkr.mkxl diff --git a/tex/context/base/mkiv/attr-neg.mkxl b/tex/context/base/mkxl/attr-neg.mkxl index c849e6bf6..c849e6bf6 100644 --- a/tex/context/base/mkiv/attr-neg.mkxl +++ b/tex/context/base/mkxl/attr-neg.mkxl diff --git a/tex/context/base/mkiv/back-exp.mkxl b/tex/context/base/mkxl/back-exp.mkxl index f248ca214..f248ca214 100644 --- a/tex/context/base/mkiv/back-exp.mkxl +++ b/tex/context/base/mkxl/back-exp.mkxl diff --git a/tex/context/base/mkiv/back-ini.mkxl b/tex/context/base/mkxl/back-ini.mkxl index 00bfeb188..00bfeb188 100644 --- a/tex/context/base/mkiv/back-ini.mkxl +++ b/tex/context/base/mkxl/back-ini.mkxl diff --git a/tex/context/base/mkiv/back-lua.lmt b/tex/context/base/mkxl/back-lua.lmt index dc836f12b..dc836f12b 100644 --- a/tex/context/base/mkiv/back-lua.lmt +++ b/tex/context/base/mkxl/back-lua.lmt diff --git a/tex/context/base/mkiv/back-lua.mkxl b/tex/context/base/mkxl/back-lua.mkxl index 0fb1bcc88..0fb1bcc88 100644 --- a/tex/context/base/mkiv/back-lua.mkxl +++ b/tex/context/base/mkxl/back-lua.mkxl diff --git a/tex/context/base/mkiv/back-mps.lmt b/tex/context/base/mkxl/back-mps.lmt index 4a2a573c4..4a2a573c4 100644 --- a/tex/context/base/mkiv/back-mps.lmt +++ b/tex/context/base/mkxl/back-mps.lmt diff --git a/tex/context/base/mkiv/back-mps.mkxl b/tex/context/base/mkxl/back-mps.mkxl index d4d428d42..d4d428d42 100644 --- a/tex/context/base/mkiv/back-mps.mkxl +++ b/tex/context/base/mkxl/back-mps.mkxl diff --git a/tex/context/base/mkiv/back-out.lmt b/tex/context/base/mkxl/back-out.lmt index 1f33da557..1f33da557 100644 --- a/tex/context/base/mkiv/back-out.lmt +++ b/tex/context/base/mkxl/back-out.lmt diff --git a/tex/context/base/mkiv/back-out.mkxl b/tex/context/base/mkxl/back-out.mkxl index 5cf79b2ea..5cf79b2ea 100644 --- a/tex/context/base/mkiv/back-out.mkxl +++ b/tex/context/base/mkxl/back-out.mkxl diff --git a/tex/context/base/mkiv/back-pdf.mkxl b/tex/context/base/mkxl/back-pdf.mkxl index c28352c92..1ce97cede 100644 --- a/tex/context/base/mkiv/back-pdf.mkxl +++ b/tex/context/base/mkxl/back-pdf.mkxl @@ -31,7 +31,7 @@ \registerctxluafile{lpdf-fld}{} \registerctxluafile{lpdf-mov}{} \registerctxluafile{lpdf-u3d}{} % this will become a module -\registerctxluafile{lpdf-swf}{} % this will become a module +%registerctxluafile{lpdf-swf}{} % this will become a module \registerctxluafile{lpdf-tag}{} \registerctxluafile{lpdf-fmt}{} \registerctxluafile{lpdf-pde}{} @@ -43,8 +43,8 @@ \registerctxluafile{back-pdp}{} \registerctxluafile{back-pdf}{} % some code will move to lpdf-* -\loadmarkfile{back-u3d} % this will become a module -\loadmarkfile{back-swf} % this will become a module +\loadmkxlfile{back-u3d} % this will become a module +%loadmkxlfile{back-swf} % this will become a module \unprotect @@ -144,7 +144,7 @@ #1% \clf_stopactualtext} -\let\pdfactualtext\pdfbackendactualtext +\aliased\let\pdfactualtext\pdfbackendactualtext %D Bah, this is also needed for tikz: diff --git a/tex/context/base/mkiv/back-res.mkxl b/tex/context/base/mkxl/back-res.mkxl index 52317b946..52317b946 100644 --- a/tex/context/base/mkiv/back-res.mkxl +++ b/tex/context/base/mkxl/back-res.mkxl diff --git a/tex/context/base/mkiv/back-trf.mkxl b/tex/context/base/mkxl/back-trf.mkxl index 2eedcdd1c..96479614d 100644 --- a/tex/context/base/mkiv/back-trf.mkxl +++ b/tex/context/base/mkxl/back-trf.mkxl @@ -67,6 +67,8 @@ %D \dostopclipping %D \stoptyping +\mutable\let\MPclippath\empty + \permanent\protected\def\dostartclipping#1#2#3% we can move this to lua and only set a box here {\forcecolorhack \meta_grab_clip_path{#1}{#2}{#3}% diff --git a/tex/context/base/mkxl/back-u3d.mkxl b/tex/context/base/mkxl/back-u3d.mkxl new file mode 100644 index 000000000..297dd5545 --- /dev/null +++ b/tex/context/base/mkxl/back-u3d.mkxl @@ -0,0 +1,158 @@ +%D \module +%D [ file=back-u3d, +%D version=2009.04.15, +%D title=\CONTEXT\ Backend Macros, +%D subtitle=U3D Experiment, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D This is only a placeholder that demonstrates the usage of u3d resources. The +%D user interface is rather messy an might be improved. The files and setup is +%D derived from an example by Michael Vidiassov. + +\endinput + +\starttext + +\startluaparameterset [u3d:myset:controls:1] + view = { + name = 'default', + bg = {1,1,1}, + mag = 100, + coo = {0,0,0}, + c2c = {0,0,1}, + rot = {40,0,60}, + roo = 6, + lights = 'CAD' + }, + js = 'cloudq.js' +\stopluaparameterset + +\startluaparameterset [u3d:myset:controls:2] + views = { + { + name = 'AnglePositioning', + bg = {1,1,1}, + azimuth = 45, + altitude = 45, + roo = 50, + aac = 2.5, + lights = 'Artwork' + }, + { + name = 'RotationPositioning', + bg = {1,1,1}, + rot = {0,45,45}, + roo = 50, + aac = 2.5, + lights = 'Artwork' + }, + { + name = 'VectorPositioning', + bg = {1,0,0}, + c2c = {1,1,math.sqrt(2)}, + roo = 50, + aac = 2.5, + lights = 'CAD' + }, + { + name = 'PositionPositioning', + bg = {1,0,0}, + pos = {1+25,1+25,1+50/math.sqrt(2)}, + aac = 2.5, + lights = 'CAD' + }, + { + name = 'ortho', + bg = {1,1,1}, + mag = 300, + lights = 'CAD', + crossection = {} + } + }, + view = { + name = 'default', + bg = {1,1,1}, + c2c = {-1,-1,0}, + roo = 50, + aac = 2.5, + roll = 45, + lights = 'CAD', + crossection = { + normal = {-1,-1,-1}, + transparent = true + }, + nodes = { + { + name = 'xlabel', + visible = false + }, + { + name = 'ylabel', + opacity = 0.5 + }, + { + name = 'zlabel', + rendermode = 'Wireframe' + } + } + } +\stopluaparameterset + +\useexternalfigure + [cloudq] + [cloudq.u3d] + [width=0.7\textwidth, + height=.7\textwidth, + display=u3d:myset:display:1, + controls=u3d:myset:controls:1] + +\useexternalfigure + [axes] + [axes.u3d] + [width=0.7\textwidth, + height=.7\textwidth, + controls=u3d:myset:controls:1] + +\startluaparameterset[u3d:myset:display:2] + toolbar = true, + preview = 'cloudq.png' +\stopluaparameterset + +\startluaparameterset[u3d:myset:display:3] + toolbar = true, + tree = false, + preview = 'axes.png' +\stopluaparameterset + +\startluaparameterset[u3d:myset:display:4] + toolbar = true, + tree = false, + view = { + name = 'view', + bg = {0.1,0.1,0.1}, + c2c = {-1,-1,0}, + roo = 50, + aac = 2.5, + roll = 45, + lights = 'Red' + } +\stopluaparameterset + +\startluaparameterset[u3d:myset:display:5] + toolbar = true, + tree = false, + view = 'ortho' +\stopluaparameterset + +\placefigure[here]{none}{\externalfigure[cloudq][display=u3d:myset:display:2]} +\placefigure[here]{none}{\externalfigure[axes] [display=u3d:myset:display:3]} +\placefigure[here]{none}{\externalfigure[axes] [display=u3d:myset:display:4]} +\placefigure[here]{none}{\externalfigure[axes] [display=u3d:myset:display:5,width=0.5\textwidth,height=.5\textwidth]} + +\stoptext diff --git a/tex/context/base/mkiv/bibl-bib.mkxl b/tex/context/base/mkxl/bibl-bib.mkxl index f8a8a7cd9..6d35d8de0 100644 --- a/tex/context/base/mkiv/bibl-bib.mkxl +++ b/tex/context/base/mkxl/bibl-bib.mkxl @@ -360,30 +360,30 @@ {\csname \ifcsname\??pb\currentbibtexsession:\currentbibtexvariant#1\endcsname \??pb\currentbibtexsession:\currentbibtexvariant#1% - \else\ifcsname\??pb:\currentbibtexvariant#1\endcsname + \orelse\ifcsname\??pb:\currentbibtexvariant#1\endcsname \??pb:\currentbibtexvariant#1% - \else\ifcsname\??pb\currentbibtexsession#1\endcsname + \orelse\ifcsname\??pb\currentbibtexsession#1\endcsname \??pb\currentbibtexsession#1% - \else\ifcsname\??pb#1\endcsname + \orelse\ifcsname\??pb#1\endcsname \??pb#1% \else \s!empty - \fi\fi\fi\fi + \fi \endcsname} \def\bibtexcitationparameter#1% {\csname \ifcsname\??pv\currentbibtexsession:\currentbibtexvariant#1\endcsname \??pv\currentbibtexsession:\currentbibtexvariant#1% - \else\ifcsname\??pv:\currentbibtexvariant#1\endcsname + \orelse\ifcsname\??pv:\currentbibtexvariant#1\endcsname \??pv:\currentbibtexvariant#1% - \else\ifcsname\??pv\currentbibtexsession#1\endcsname + \orelse\ifcsname\??pv\currentbibtexsession#1\endcsname \??pv\currentbibtexsession#1% - \else\ifcsname\??pv#1\endcsname + \orelse\ifcsname\??pv#1\endcsname \??pv#1% \else \s!empty - \fi\fi\fi\fi + \fi \endcsname} % setup commands @@ -391,50 +391,50 @@ \protected\def\setupbibtexpublications {\let\currentpublicationclass\??pb \let\everysetupbibtexwhatever\everysetupbibtexpublications - \dodoubleargument\dosetupbibtexwhatever} + \dosetupbibtexwhatever} \protected\def\setupbibtexcitations {\let\currentpublicationclass\??pv \let\everysetupbibtexwhatever\everysetupbibtexcitations - \dodoubleargument\dosetupbibtexwhatever} + \dosetupbibtexwhatever} \protected\def\setupbibtexpublicationvariants {\let\currentpublicationclass\??pb \let\everysetupbibtexwhatever\everysetupbibtexpublications - \dotripleargument\dosetupbibtexwhatevervariant} + \dosetupbibtexwhatevervariant} \protected\def\setupbibtexcitationvariants {\let\currentpublicationclass\??pv \let\everysetupbibtexwhatever\everysetupbibtexcitations - \dotripleargument\dosetupbibtexwhatevervariant} + \dosetupbibtexwhatevervariant} -\def\dosetupbibtexwhatever[#1][#2]% [sessionlist] [setup] - {\ifsecondargument +\tolerant\def\dosetupbibtexwhatever[#1]#*[#2]% [sessionlist] [setup] + {\ifarguments\or + % setups + \getparameters[\currentpublicationclass][#1]% + \the\everysetupbibtexwhatever + \or % sessions setups \def\dobtxcommand##1{\getparameters[\currentpublicationclass##1][#2]}% \processcommalist[#1]\dobtxcommand - \else + \fi} + +\tolerant\def\dosetupbibtexwhatevervariant[#1]#*[#2]#*[#3]% [sessionlist] [variantlist] [setup] + {\ifarguments\or % setups \getparameters[\currentpublicationclass][#1]% \the\everysetupbibtexwhatever - \fi} - -\def\dosetupbibtexwhatevervariant[#1][#2][#3]% [sessionlist] [variantlist] [setup] - {\ifthirdargument + \or + % variants setups + \def\dobtxcommand##1{\getparameters[\currentpublicationclass:##1][#2]}% + \processcommalist[#1]\dobtxcommand + \or % sessions variants setups \def\dobtxcommand##1% {\def\dodobtxcommand####1{\getparameters[\currentpublicationclass##1:####1][#3]}% \processcommalist[#2]\dodobtxcommand}% \processcommalist[#1]\docbtxommand - \else\ifsecondargument - % variants setups - \def\dobtxcommand##1{\getparameters[\currentpublicationclass:##1][#2]}% - \processcommalist[#1]\dobtxcommand - \else - % setups - \getparameters[\currentpublicationclass][#1]% - \the\everysetupbibtexwhatever - \fi\fi} + \fi} % some initializations @@ -640,13 +640,13 @@ {\edef\currentbibtexsessiontag{#1}% \ifx\currentbibtexsessiontag\empty % can't really happen - \else\ifx\currentbibtexcriterium\v!all + \orelse\ifx\currentbibtexcriterium\v!all \dotypesetbibtexpublication % was \doplacepublicationindeed \else \ctxlua{bibtex.hacks.doifalreadyplaced("\currentbibtexsessiontag")} \donothing \dotypesetbibtexpublication - \fi\fi} + \fi} \def\dotypesetbibtexpublication {\doifelsebibreferencefound\currentbibtexsessiontag diff --git a/tex/context/base/mkiv/bibl-tra.mkxl b/tex/context/base/mkxl/bibl-tra.mkxl index c85a664ba..2fecf9cd8 100644 --- a/tex/context/base/mkiv/bibl-tra.mkxl +++ b/tex/context/base/mkxl/bibl-tra.mkxl @@ -562,7 +562,7 @@ \ifnum\etallimitcounter<\commalistsize\relax \bibalternative{#1etaltext}% \fi - \else\ifnum\numexpr\scratchcounter+\plusone\relax=#2\relax + \orelse\ifnum\numexpr\scratchcounter+\plusone\relax=#2\relax \ifnum\commalistsize>\plustwo \bibalternative\c!finalnamesep \else @@ -570,7 +570,7 @@ \fi \else \bibalternative\c!namesep - \fi\fi + \fi \fi} \protected\def\dospecialbibinsert#1#2#3% @@ -788,21 +788,21 @@ \expanded{\setuplist[pubs][\c!width=\the\wd\scratchbox,\c!distance=\zeropoint]}% \ifx\@@pbnumbering\v!short \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{\bibgetvars\currentpublicationkey}}}% - \else\ifx\@@pbnumbering\v!bib + \orelse\ifx\@@pbnumbering\v!bib \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{\bibgetvarn\currentpublicationkey}}}% \else \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{##1}}}% - \fi\fi} + \fi} {\doifelsenothing{\listparameter\c!width} {\let \publistnumberbox \hbox} {\edef\publistnumberbox{\hbox to \listparameter\c!width}}% \ifx\@@pbnumbering\v!short \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{\bibgetvars\currentpublicationkey}}}% - \else\ifx\@@pbnumbering\v!bib + \orelse\ifx\@@pbnumbering\v!bib \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{\bibgetvarn\currentpublicationkey}}}% \else \def\@@pblimitednumber##1{\publistnumberbox{\@@pbnumbercommand{##1}}}% - \fi\fi}% + \fi}% \ifx\@@pbnumbering\v!no \setuplist[pubs][\c!numbercommand=,\c!symbol=\v!none,\c!textcommand=\outdented]% \else @@ -940,12 +940,9 @@ \protected\def\docite[#1][#2]% {\begingroup - \doifelsenothing{#2}\secondargumentfalse\secondargumenttrue - \ifsecondargument - \dowhatevercite{#1}{#2}% - \else - \donumberedcite{#1}% - \fi + \doifelsesomething{#2} + {\dowhatevercite{#1}{#2}}% + {\donumberedcite{#1}}% \endgroup} \protected\def\dowhatevercite#1#2% @@ -994,10 +991,8 @@ %D \macros{setupcite} -\protected\def\setupcite{\dodoubleempty\dosetupcite} - -\protected\def\dosetupcite[#1][#2]% - {\ifsecondargument +\permanent\tolerant\protected\def\setupcite[#1]#*[#2]% + {\ifparameter#2\or \def\dodosetupcite##1{\getparameters[\??pv##1][#2]}% \processcommalist[#1]\dodosetupcite \else % default case @@ -1006,12 +1001,12 @@ %D Low-level stuff -\protected\def\getcitedata#1[#2]#3[#4]#5to#6% +\protected\def\getcitedata#1[#2]#*[#3]#*to#4% {\bgroup - \dofetchapublication{#4}% + \dofetchapublication{#3}% \doifelsedefined{\??pb @bib#2}% - {\xdef#6{\getvalue{\??pb @bib#2}}}% - {\xdef#6{\getvalue{\??pb @#2}}}% + {\xdef#4{\getvalue{\??pb @bib#2}}}% + {\xdef#4{\getvalue{\??pb @#2}}}% \egroup} \protected\def\dofetchapublication#1% @@ -1095,11 +1090,11 @@ \setcurrentbibauthor{#1}% \ifnum\scratchcounter=\plusone \ixfirstcommand - \else\ifnum \scratchcounter=\authorcount\relax + \orelse\ifnum \scratchcounter=\authorcount\relax \ixlastcommand \else \ixsecondcommand - \fi\fi} + \fi} \protected\def\setcurrentbibauthor#1% sensitive for empty entries but I don't want to touch this {\getcommacommandsize[#1]% @@ -1123,11 +1118,11 @@ {\advance\citescratchcounter\plusone \ifnum \citescratchcounter=#1\relax \edef\currentbibauthor{\currentbibauthor##1}% - \else\ifnum\numexpr\citescratchcounter+\plusone\relax=#1\relax + \orelse\ifnum\numexpr\citescratchcounter+\plusone\relax=#1\relax \edef\currentbibauthor{\currentbibauthor##1\bibalternative{andtext}}% \else \edef\currentbibauthor{\currentbibauthor##1\bibalternative{namesep}}% - \fi\fi}% + \fi}% \processcommalist[#2]\bibprocessauthoritem} \setupcite @@ -1227,11 +1222,11 @@ \def\mytempc{#1}% \ifx\mytempc\myauthor \quitcommalist - \else\ifnum\bibitemwanted=\bibitemcounter\relax + \orelse\ifnum\bibitemwanted=\bibitemcounter\relax \global\advance\bibitemwanted \plusone \global\bibitemcounter\bibitemwanted\relax \expandafter\doglobal\expandafter\robustaddtocommalist\expandafter{{\myauthor}}\thebibauthors - \fi\fi} + \fi} %D This macro should be clear now. diff --git a/tex/context/base/mkiv/blob-ini.lmt b/tex/context/base/mkxl/blob-ini.lmt index 42a18fddd..42a18fddd 100644 --- a/tex/context/base/mkiv/blob-ini.lmt +++ b/tex/context/base/mkxl/blob-ini.lmt diff --git a/tex/context/base/mkiv/blob-ini.mkxl b/tex/context/base/mkxl/blob-ini.mkxl index 3443836b7..3443836b7 100644 --- a/tex/context/base/mkiv/blob-ini.mkxl +++ b/tex/context/base/mkxl/blob-ini.mkxl diff --git a/tex/context/base/mkxl/buff-ini.mkxl b/tex/context/base/mkxl/buff-ini.mkxl new file mode 100644 index 000000000..815107851 --- /dev/null +++ b/tex/context/base/mkxl/buff-ini.mkxl @@ -0,0 +1,232 @@ +%D \module +%D [ file=buff-ini, +%D version=2011.11.22, % previous big effort 2000.01.05, +%D title=\CONTEXT\ Buffer Macros, +%D subtitle=Buffers, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Buffer Macros / Buffers} + +\registerctxluafile{buff-ini}{} + +\unprotect + +%D There have been several iterations in \MKIV\ but here we only show the currently +%D used one. One can always look back (and maybe learn some). It will never look +%D pretty and never be efficient but it has served us for ages (conceptually it's +%D as in \MKII). + +\mutable\let\currentbuffer\empty + +\permanent\def\doifelsebuffer#1{\clf_doifelsebuffer{#1}} % expandable, todo: use public implementor + +\aliased\let\doifbufferelse\doifelsebuffer + +\permanent\tolerant\protected\def\resetbuffer[#1]{\clf_erasebuffer{#1}} % todo: use public implementor + +\permanent\setuvalue{\e!start\v!buffer}% + {\begingroup % (3) + \obeylines + \buff_start} + +\tolerant\def\buff_start[#1]#*[#2]% + {\buff_start_indeed{}{#1}{\e!start\v!buffer}{\e!stop\v!buffer}} + +\def\buff_start_indeed#1#2#3#4% + {\edef\p_strip{\namedbufferparameter{#1}\c!strip}% for aditya + \normalexpanded{\buff_pickup + {#2}% + {#3}% + {#4}% + {}% + {\buff_stop{#4}}% + \ifx\p_strip\v!no\zerocount\else\plusone\fi}} + +\permanent\protected\def\grabbufferdatadirect % name start stop + {\begingroup % (6) + \buff_start_indeed\empty} + +\permanent\protected\def\grabbufferdata % was: \dostartbuffer + {\begingroup % (4) + \obeylines + \buff_grab_direct} + +\tolerant\def\buff_grab_direct[#1]#*[#2]#*[#3]#*[#4]% [category] [name] [start] [stop] + {\ifnum\lastarguments=\plusfour + \expandafter\buff_start_indeed + \else + \expandafter\buff_start_indeed_default + \fi{#1}{#2}{#3}{#4}} + +\def\buff_start_indeed_default#1#2#3#4{\buff_start_indeed\empty{#1}{#2}{#3}} + +% \let\buff_finish\relax +% \let\buff_gobble\relax + +\protected\def\buff_pickup#1#2#3#4#5#6% name, startsequence, stopsequence, before, after, undent + {\begingroup % (1) + #4% + \begingroup % (2) + \scratchcounter\catcodetable + \clf_erasebuffer{#1}% + \setcatcodetable\vrbcatcodes + \protected\def\dofinishpickupbuffer + {\endgroup % (1) + \endgroup % (2) + #5}% + % todo: we need to skip the first lineending which is an active character + % but sometimes we have something different ... this is a side effect of + % checking for optional arguments i.e. the next token is already tokenized + % and for that reason we have the \relax as well as the \string + \clf_pickupbuffer + {#1}% + {#2}% + {#3}% + {\string\dofinishpickupbuffer}% + \scratchcounter + \ifnum#6=\plusone\s!true\else\s!false\fi + % \relax} + \expandafter\relax\string} % maybe \normalexpanded{\relax\utfchar{7}}} signal + +\protected\def\buff_stop#1% + {\endgroup % (3 & 4 & 5 & 6) + \begincsname#1\endcsname} + +\aliased\let\endbuffer\relax + +\permanent\tolerant\protected\def\setbuffer[#1]#:#2\endbuffer % seldom used so we just pass #2 + {\clf_assignbuffer{#1}{\detokenize{#2}}\catcodetable\relax} + +% beware, never adapt the global buffer settings, actually we might introduce +% a broken parent chain for this purpose but on the other hand it's not that +% different from framed cum suis + +\installcorenamespace{buffer} + +\installcommandhandler \??buffer {buffer} \??buffer + +\setupbuffer + [\c!before=, + \c!after=] + +\newcount\c_buff_n_of_defined + +\mutable\let\currentdefinedbuffer\s!dummy + +\appendtoks + \global\advance\c_buff_n_of_defined\plusone + \setexpandedbufferparameter\c!number{\number\c_buff_n_of_defined}% + \edef\currentdefinedbuffer{def-\number\c_buff_n_of_defined}% + \frozen\instance\setuevalue{\e!start\currentbuffer}{\buff_start_defined{\currentbuffer}{\currentdefinedbuffer}{\e!start\currentbuffer}{\e!stop\currentbuffer}}% + \frozen\instance\setuevalue{\e!get \currentbuffer}{\buff_get_stored {\currentbuffer}{\currentdefinedbuffer}}% +\to \everydefinebuffer + +\protected\def\buff_start_defined + {\begingroup % (5) + \buff_start_indeed} + +\permanent\def\thebuffernumber #1{\namedbufferparameter{#1}\c!number} +\permanent\def\thedefinedbuffer#1{def-\namedbufferparameter{#1}\c!number} + +\permanent\tolerant\protected\def\getbuffer[#1]% [name] + {\namedbufferparameter\empty\c!before\relax + \doifelsenothing{#1} + {\buff_get_stored_indeed\empty} + {\processcommalist[#1]\buff_get_stored_indeed}% + \namedbufferparameter\empty\c!after\relax} + +\protected\def\buff_get_stored#1#2% + {\namedbufferparameter{#1}\c!before\relax + \buff_get_stored_indeed{#2}% + \namedbufferparameter{#1}\c!after\relax} + +\protected\def\buff_get_stored_indeed#1% + {\clf_getbuffer{#1}} + +\permanent\protected\def\getdefinedbuffer[#1]% + {\buff_get_stored{#1}{\thedefinedbuffer{#1}}}% + +\permanent\tolerant\protected\def\inlinebuffer[#1]% [name] + {\doifelsenothing{#1} + {\buff_get_stored_inline_indeed\empty} + {\processcommalist[#1]\buff_get_stored_inline_indeed}} + +\protected\def\buff_get_stored_inline_indeed#1% + {\ignorespaces\clf_getbuffer{#1}\removeunwantedspaces} + +\permanent\def\rawbuffer#1% expandable + {\clf_getbuffer{#1}} + +\definebuffer + [\v!hiding] + +\setupbuffer + [\v!hiding] + [\c!before=, + \c!after=] + +\permanent\protected\protected\def\processTEXbuffer[#1]% keep case, maybe also lower + {\pushcatcodetable + \catcodetable\ctxcatcodes % \setcatcodetable + \buff_get_stored_indeed{#1}% + \popcatcodetable} + +% only mkiv: +% +% \startbuffer[x] +% x +% \stopbuffer +% +% \savebuffer[x] [temp] % gets name: jobname-temp.tmp +% \savebufferinfile[x][temp.log] % gets name: temp.log + +\installcorenamespace{savebuffer} + +\installsetuponlycommandhandler \??savebuffer {savebuffer} + +\setupsavebuffer + [\c!list=, + \c!file=, + \c!prefix=\v!yes] + +\permanent\tolerant\protected\def\savebuffer[#1]#*[#2]% + {\begingroup + \ifhastok={#1}% + \setupcurrentsavebuffer[#1]% + \else + \setupcurrentsavebuffer[\c!list={#1},\c!file=#2]% + \fi + \clf_savebuffer{\directsavebufferparameter\c!list}{\directsavebufferparameter\c!file}{\directsavebufferparameter\c!prefix}% + \endgroup} + +%D Experimental: no expansion of commands in buffer! + +% \startbuffer[what] +% context("WHAT") +% \stopbuffer +% \startbuffer +% context("JOBNAME") +% \stopbuffer +% +% \ctxluabuffer[what] \ctxluabuffer + +\permanent\tolerant\protected\def\ctxluabuffer[#1]{\clf_getbufferctxlua{#1}} % todo: use public implementor +\permanent\tolerant\protected\def\mkvibuffer [#1]{\clf_getbuffermkvi {#1}} % todo: use public implementor + +% maybe still used elsewhere + +\permanent\protected\def\doprocesstexbuffer#1{\buff_process_tex[#1]} % still used? if not ... it will go away + +\aliased\let\dostartbuffer\grabbufferdata % for old times sake, this will go away + +% new (expandable): + +\permanent\def\getbufferdata[#1]{\buff_get_stored_indeed{#1}} + +\protect \endinput diff --git a/tex/context/base/mkxl/buff-par.mklx b/tex/context/base/mkxl/buff-par.mklx new file mode 100644 index 000000000..663ea7254 --- /dev/null +++ b/tex/context/base/mkxl/buff-par.mklx @@ -0,0 +1,180 @@ +%D \module +%D [ file=buff-par, +%D version=2010.12.05, +%D title=\CONTEXT\ Buffer Macros, +%D subtitle=Parallel, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Buffer Macros / Parallel} + +\registerctxluafile{buff-par}{} + +%D This module is made for Thomas Schmitz as part of a project. There is +%D no documentation yet. Also, this code is unfinished and not tested well. +%D +%D \starttyping +%D \defineparallel[main][one,two] +%D +%D \startmain +%D \startone +%D first 0 +%D [reference] first 1 +%D first 2 +%D first 3 +%D \stopone +%D \starttwo +%D second 1 +%D second 2 +%D \stoptwo +%D \stopmain +%D +%D \startmain +%D \startone +%D first 4 +%D first 4 +%D \stopone +%D \starttwo +%D second 3 +%D second 4 +%D \stoptwo +%D \stopmain +%D +%D \placeparallel[main][one][criterium=all] +%D +%D \placeparallel[main][two][criterium=all] +%D \stoptyping + +%D criterium=all start=<number> n=<number> + +\unprotect + +\installcorenamespace{parallel} +\installcorenamespace{parallelhandler} + +\installcommandhandler \??parallel {parallel} \??parallel + +\setupparallel + [\c!setups=parallel:place:default] + +\pushoverloadmode + +\let\buff_parallel_define_saved \defineparallel +\let\buff_process_parallel_instance\relax + +\permanent\tolerant\protected\overloaded\def\defineparallel[#name]#spacer[#instances]% + {\buff_parallel_define_saved[#name][\c!list={#instances}]% list is internal + \clf_defineparallel{#name}{#instances}% + \expandafter\newtoks\csname\??parallelhandler#name\endcsname + \processcommacommand[#instances]{\buff_parallel_define_instance{#name}}% + \frozen\instance\setuevalue{\e!start#name}{\buff_parallel_start{#name}}% + \frozen\instance\setuevalue{\e!stop #name}{\buff_parallel_stop}} + +\popoverloadmode + +\def\buff_process_parallel_instances + {\the\csname\??parallelhandler\currentparallel\endcsname} + +\def\buff_parallel_define_instance#name#instance% + {\normalexpanded{\buff_parallel_define_saved[#instance][#name]}% + \definebuffer[#instance]% + %\edef\t_buff_parallel{\csname\??parallelhandler#name\endcsname}% + \expandafter\let\expandafter\t_buff_parallel\csname\??parallelhandler#name\endcsname + \toksapp\t_buff_parallel{\edef\currentparallelinstance{#instance}\buff_process_parallel_instance\relax}% + \setuevalue{\e!stop#instance}{\buff_parallel_save{#instance}}} + +\pushoverloadmode + +\let\buff_parallel_setup_saved \setupparallel + +\permanent\tolerant\protected\def\setupparallel[#name]#spacer[#instances]#spacer[#setups]% + {\processcommalist[#instances]{\buff_parallel_setup_instance{#name}{#setups}}} + +\popoverloadmode + +\def\buff_parallel_setup_instance#name#setups#instance% + {\buff_parallel_setup_saved[#name:#instance][#setups]} + +\protected\def\buff_parallel_start#name% + {\pushmacro\currentparallel + \edef\currentparallel{#name}% + \clf_nextparallel{\currentparallel}} + +\protected\def\buff_parallel_stop + {\popmacro\currentparallel} + +\protected\def\buff_parallel_save#instance% defined moet ook aan de lua kant kunnen + {\clf_saveparallel + {\currentparallel}% + {#instance}% + {\thedefinedbuffer{#instance}}% + \relax} + +\permanent\tolerant\protected\def\placeparallel[#name]#spacer[#instance]#spacer[#settings]% + {\begingroup + \edef\currentparallel{#name}% + \setupcurrentparallel[#settings]% + \clf_placeparallel + {\currentparallel}% + {#instance}% + {% + % setups {\parallelparameter\c!setups}% + start {\parallelparameter\c!start}% + n {\parallelparameter\c!n}% + criterium {\parallelparameter\c!criterium}% + }% + \relax + \endgroup} + +\def\doflushparallel#instance#status#line#label#content% called at lua end + {\begingroup + \def\currentparallelinstance{#instance}% + \def\currentparallelnumber {#status}% + \def\currentparallelline {#line}% + \def\currentparallellabel {#label}% + \def\currentparallelcontent {#content}% can be kep at the lua end .. no need to use a virtual file + \ifcase#status\relax + \expandafter\buff_parallel_flush_nop + \or + \expandafter\buff_parallel_flush_yes + \fi + \endgroup} + +\def\buff_parallel_flush_nop + {} + +\def\buff_parallel_flush_yes + %{\directsetup{\namedparallelparameter{\currentparallel:\currentparallelinstance}\c!setups}} + {\directsetup{\namedparallelparameter{\currentparallelinstance}\c!setups}} + +\permanent\protected\def\doifelseparallel#name#instance% + {\clf_doifelseparallel{#name}{#instance}} + +\aliased\let\doifparallelelse\doifelseparallel + +\permanent\tolerant\protected\def\resetparallel[#name]#spacer[#instance]% + {\clf_resetparallel{#name}{#instance}} + +\startsetups parallel:place:default + \hangafter\plusone + \hangindent4\emwidth + \dontleavehmode + \hbox to 3\emwidth \bgroup + \hss + \bf + \doifsomething \currentparallellabel { + \textreference[\currentparallellabel]{\currentparallelline} + } + \currentparallelline + \quad + \egroup + \currentparallelcontent + \par +\stopsetups + +\protect \endinput diff --git a/tex/context/base/mkiv/buff-ver.mkxl b/tex/context/base/mkxl/buff-ver.mkxl index 6e3b0ffe3..8ca44a956 100644 --- a/tex/context/base/mkiv/buff-ver.mkxl +++ b/tex/context/base/mkxl/buff-ver.mkxl @@ -192,10 +192,10 @@ \def\buff_verbatim_initialize_visualizer#1% {\ifproductionrun\clf_loadvisualizer{#1}\fi} -\protected\def\doifelsevisualizer#1% +\permanent\protected\def\doifelsevisualizer#1% {\clf_doifelsevisualizer{#1}} -\let\doifvisualizerelse\doifelsevisualizer +\aliased\let\doifvisualizerelse\doifelsevisualizer %D Verbatim command are very sensitive to argument processing, which is a direct %D result of the \CATCODES\ being fixed at reading time. @@ -763,7 +763,7 @@ \let\currenttyping\v!buffer \buff_verbatim_type_buffer} -\protected\def\typedefinedbuffer[#1]% +\permanent\protected\def\typedefinedbuffer[#1]% {\buff_verbatim_type_defined_buffer[\v!buffer][\thedefinedbuffer{#1}]}% \appendtoks diff --git a/tex/context/base/mkiv/catc-act.mkxl b/tex/context/base/mkxl/catc-act.mkxl index 4ccf22a7f..4ccf22a7f 100644 --- a/tex/context/base/mkiv/catc-act.mkxl +++ b/tex/context/base/mkxl/catc-act.mkxl diff --git a/tex/context/base/mkiv/catc-ctx.mkxl b/tex/context/base/mkxl/catc-ctx.mkxl index fcaec65d0..fcaec65d0 100644 --- a/tex/context/base/mkiv/catc-ctx.mkxl +++ b/tex/context/base/mkxl/catc-ctx.mkxl diff --git a/tex/context/base/mkiv/catc-def.mkxl b/tex/context/base/mkxl/catc-def.mkxl index e93345e1c..e93345e1c 100644 --- a/tex/context/base/mkiv/catc-def.mkxl +++ b/tex/context/base/mkxl/catc-def.mkxl diff --git a/tex/context/base/mkiv/catc-ini.mkxl b/tex/context/base/mkxl/catc-ini.mkxl index 1dcd2107f..84d58b977 100644 --- a/tex/context/base/mkiv/catc-ini.mkxl +++ b/tex/context/base/mkxl/catc-ini.mkxl @@ -90,7 +90,7 @@ \permanent\protected\def\newcatcodetable#1% we could move the cctdefcounter to lua {\global\advance\c_syst_catcodes_n\plusone - \global\defcsname\??catcodetablen\number\c_syst_catcodes_n\endcsname{\string#1}% logging + \gdefcsname\??catcodetablen\number\c_syst_catcodes_n\endcsname{\string#1}% logging %\setnewconstant#1\c_syst_catcodes_n \immutable\integerdef#1\c_syst_catcodes_n \ctxcommand{registercatcodetable("\expandafter\gobbleoneargument\string#1",\number#1)}} @@ -178,20 +178,20 @@ \fi} \def\syst_catcodes_let_c % only first time - {\frozen\enforced\global\defcsname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname\expandafter + {\frozen\enforced\gdefcsname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname\expandafter {\enforced\letcsname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}% \syst_catcodes_reinstate_unexpanded \csname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname} \def\syst_catcodes_def_c % only first time (we could use \normalexpanded here) - {\frozen\enforced\global\defcsname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname + {\frozen\enforced\gdefcsname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname \expandafter##\expandafter1\expandafter {\frozen\enforced\defcsname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}% \syst_catcodes_reinstate_normal \csname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname} \def\syst_catcodes_ued_c % only first time - {\frozen\enforced\global\defcsname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname + {\frozen\enforced\gdefcsname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname \expandafter##\expandafter1\expandafter {\frozen\enforced\protected\defcsname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}% \syst_catcodes_reinstate_unexpanded diff --git a/tex/context/base/mkiv/catc-sym.mkxl b/tex/context/base/mkxl/catc-sym.mkxl index 5334d7723..f60537da8 100644 --- a/tex/context/base/mkiv/catc-sym.mkxl +++ b/tex/context/base/mkxl/catc-sym.mkxl @@ -38,6 +38,7 @@ \immutable\edef\letterexclamationmark {\expandtoken \othercatcode \exclamationmarkasciicode} \immutable\edef\letterat {\expandtoken \othercatcode \atsignasciicode} \immutable\edef\lettercolon {\expandtoken \othercatcode \colonasciicode} +\immutable\edef\letterhyphen {\expandtoken \othercatcode \hyphenasciicode} \immutable\edef\letterleftparenthesis {\expandtoken \othercatcode \leftparentasciicode} \immutable\edef\letterrightparenthesis {\expandtoken \othercatcode \rightparentasciicode} diff --git a/tex/context/base/mkiv/char-act.mkxl b/tex/context/base/mkxl/char-act.mkxl index 3fb4d2da6..3fb4d2da6 100644 --- a/tex/context/base/mkiv/char-act.mkxl +++ b/tex/context/base/mkxl/char-act.mkxl diff --git a/tex/context/base/mkiv/char-enc.mkxl b/tex/context/base/mkxl/char-enc.mkxl index d0dd3d20a..d0dd3d20a 100644 --- a/tex/context/base/mkiv/char-enc.mkxl +++ b/tex/context/base/mkxl/char-enc.mkxl diff --git a/tex/context/base/mkiv/char-ini.mkxl b/tex/context/base/mkxl/char-ini.mkxl index 1df5d4b01..1df5d4b01 100644 --- a/tex/context/base/mkiv/char-ini.mkxl +++ b/tex/context/base/mkxl/char-ini.mkxl diff --git a/tex/context/base/mkiv/char-utf.mkxl b/tex/context/base/mkxl/char-utf.mkxl index a7cbab345..a7cbab345 100644 --- a/tex/context/base/mkiv/char-utf.mkxl +++ b/tex/context/base/mkxl/char-utf.mkxl diff --git a/tex/context/base/mkiv/chem-ini.mkxl b/tex/context/base/mkxl/chem-ini.mkxl index 55bbbd874..b88d4d834 100644 --- a/tex/context/base/mkiv/chem-ini.mkxl +++ b/tex/context/base/mkxl/chem-ini.mkxl @@ -26,7 +26,7 @@ %D Quick and dirty: %D %D \starttyping -%D \unexpanded\def\molecule#1% +%D \permanent\protected\def\molecule#1% %D {$\enablesupersub\tf#1$} %D \stoptyping %D diff --git a/tex/context/base/mkiv/chem-str.mkxl b/tex/context/base/mkxl/chem-str.mkxl index 5274de949..2212ddfcb 100644 --- a/tex/context/base/mkiv/chem-str.mkxl +++ b/tex/context/base/mkxl/chem-str.mkxl @@ -209,15 +209,12 @@ \enforced\let\chemical\structurechemical \to\everystructurechemical -\protected\def\structurechemical - {\dotripleempty\strc_chem_indeed} - -\def\strc_chem_indeed - {\ifthirdargument +\permanent\tolerant\protected\def\structurechemical[#1]#*[#2]#*[#3]% + {\ifparameter#3\or \expandafter\strc_chem_indeed_three \else \expandafter\strc_chem_indeed_two - \fi} + \fi[#1][#2][#3]} \def\strc_chem_indeed_three[#1][#2][#3]% {\writestatus\m!chemicals{hyperlinked chemicals not yet supported}% todo reference, for the moment ignored @@ -504,17 +501,14 @@ % \hbox{\mathematics{\tf\triggermathstyle\scratchcounter\clf_inlinechemical{#1}}}% % \endgroup} -\permanent\protected\def\displaychemical - {\dotriplegroupempty\chem_display} - -\def\chem_display#1#2#3% +\permanent\tolerant\protected\def\displaychemical#=#=#=% {\the\everychemical \everychemical\emptytoks \quad \vcenter\bgroup \usechemicalstyleandcolor\c!style\c!color - \ifthirdargument - \ifsecondargument + \ifparameter#3\or + \ifparameter#2\or \halign{\aligntab\hss\alignmark\alignmark\hss\cr#2\cr\molecule{#1}\cr#3\cr}% \else \halign{\aligntab\hss\alignmark\alignmark\hss \cr\molecule{#1}\cr#2\cr}% @@ -625,20 +619,18 @@ \definechemicalsymbol[d:OPENCOMPLEX] [{\chemicalsymbol[d:opencomplex]}] \definechemicalsymbol[d:CLOSECOMPLEX][{\chemicalsymbol[d:closecomplex]}] -\permanent\protected\def\formulachemical - {\relax\dotriplegroupempty\chem_formula} - -\def\chem_formula#1#2#3% we could do hboxes and measure - {\ifthirdargument - \doifelsenothing{#2}\chem_formula_top_nop{\chem_formula_top_yes{#2}}% - \doifelsenothing{#3}\chem_formula_bot_nop{\chem_formula_bot_yes{#3}}% - \else\ifsecondargument - \chem_formula_top_nop - \doifelsenothing{#2}\chem_formula_bot_nop{\chem_formula_bot_yes{#2}}% - \else +\permanent\tolerant\protected\def\formulachemical#=#=#=% + {\relax + \ifarguments\or \chem_formula_top_nop \chem_formula_bot_nop - \fi\fi + \or + \chem_formula_top_nop + \doifelsenothing{#2}\chem_formula_bot_nop{\chem_formula_bot_yes{#2}}% + \or + \doifelsenothing{#2}\chem_formula_top_nop{\chem_formula_top_yes{#2}}% + \doifelsenothing{#3}\chem_formula_bot_nop{\chem_formula_bot_yes{#3}}% + \fi \ifcsname\??chemicalsymbol d:\detokenize{#1}\endcsname \toksapp\t_chem_mid{\chemicalsymbol[d:#1]\aligntab}% \else diff --git a/tex/context/base/mkiv/cldf-bas.mkxl b/tex/context/base/mkxl/cldf-bas.mkxl index 962db5209..962db5209 100644 --- a/tex/context/base/mkiv/cldf-bas.mkxl +++ b/tex/context/base/mkxl/cldf-bas.mkxl diff --git a/tex/context/base/mkiv/cldf-com.mkxl b/tex/context/base/mkxl/cldf-com.mkxl index 7a8f7bf5c..7a8f7bf5c 100644 --- a/tex/context/base/mkiv/cldf-com.mkxl +++ b/tex/context/base/mkxl/cldf-com.mkxl diff --git a/tex/context/base/mkiv/cldf-ini.mkxl b/tex/context/base/mkxl/cldf-ini.mkxl index b393eb9b5..b393eb9b5 100644 --- a/tex/context/base/mkiv/cldf-ini.mkxl +++ b/tex/context/base/mkxl/cldf-ini.mkxl diff --git a/tex/context/base/mkiv/cldf-int.lmt b/tex/context/base/mkxl/cldf-int.lmt index 4f486221b..4f486221b 100644 --- a/tex/context/base/mkiv/cldf-int.lmt +++ b/tex/context/base/mkxl/cldf-int.lmt diff --git a/tex/context/base/mkiv/cldf-int.mkxl b/tex/context/base/mkxl/cldf-int.mkxl index a564afc80..a564afc80 100644 --- a/tex/context/base/mkiv/cldf-int.mkxl +++ b/tex/context/base/mkxl/cldf-int.mkxl diff --git a/tex/context/base/mkiv/cldf-lmt.lmt b/tex/context/base/mkxl/cldf-lmt.lmt index f3121eadc..f3121eadc 100644 --- a/tex/context/base/mkiv/cldf-lmt.lmt +++ b/tex/context/base/mkxl/cldf-lmt.lmt diff --git a/tex/context/base/mkiv/cldf-ver.mkxl b/tex/context/base/mkxl/cldf-ver.mkxl index 0ff63810e..0ff63810e 100644 --- a/tex/context/base/mkiv/cldf-ver.mkxl +++ b/tex/context/base/mkxl/cldf-ver.mkxl diff --git a/tex/context/base/mkiv/colo-ext.mkxl b/tex/context/base/mkxl/colo-ext.mkxl index df2d9d768..df2d9d768 100644 --- a/tex/context/base/mkiv/colo-ext.mkxl +++ b/tex/context/base/mkxl/colo-ext.mkxl diff --git a/tex/context/base/mkiv/colo-grp.mkxl b/tex/context/base/mkxl/colo-grp.mkxl index 82dd67959..82dd67959 100644 --- a/tex/context/base/mkiv/colo-grp.mkxl +++ b/tex/context/base/mkxl/colo-grp.mkxl diff --git a/tex/context/base/mkiv/colo-ini.mkxl b/tex/context/base/mkxl/colo-ini.mkxl index 21d5d5aba..15cedb51d 100644 --- a/tex/context/base/mkiv/colo-ini.mkxl +++ b/tex/context/base/mkxl/colo-ini.mkxl @@ -123,7 +123,7 @@ \let\g_color\empty \let\g_style\empty -\protected\def\switchtocolor[#1]{\begincsname#1\endcsname} +\permanent\protected\def\switchtocolor[#1]{\begincsname#1\endcsname} % transparency @@ -458,8 +458,8 @@ \expandafter\secondoftwoarguments \fi} -\let\paletlist\empty -\let\paletsize\!!zerocount +\mutable\let\paletlist\empty +\mutable\let\paletsize\!!zerocount \permanent\protected\def\getpaletlist[#1]% {\edef\paletlist{\begincsname\??paletlist#1\endcsname}} @@ -485,7 +485,7 @@ \protected\def\colo_palets_define_a#1#2#3% {\colo_palet_prepare{#1}% \ifcondition\validassignment{#2}% - \setevalue{\??colorpaletspecification#1}{#2}% + \edefcsname\??colorpaletspecification#1\endcsname{#2}% \processcommalist[#2]{\colo_palets_define_one{#1}}% \orelse\ifcsname\??colorpaletspecification#2\endcsname \normalexpanded{\colo_palets_define_b{#1}{\lastnamedcs}\empty}% @@ -493,7 +493,7 @@ \protected\def\colo_palets_define_b#1#2#3% {\colo_palet_prepare{#1}% - \setevalue{\??colorpaletspecification#1}{#2}% + \edefcsname\??colorpaletspecification#1\endcsname{#2}% \colo_palet_extend{#2}% \colo_palets_define_assign{#1}{#2}{#3}} @@ -851,7 +851,7 @@ \clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax \colo_basics_synchronize{#1}% \ifcase\c_colo_protection - \protected\instance\setvalue{#1}{\colo_helpers_activate{#1}}% + \protected\instance\defcsname#1\endcsname{\colo_helpers_activate{#1}}% \fi \fi} @@ -866,7 +866,7 @@ \fi \fi} -\let\definenamedcolor\definecolor +\aliased\let\definenamedcolor\definecolor \def\colo_basics_defined_and_activated#1% {\clf_defineprocesscolordummy{#1}% we could pass dummy here too @@ -886,7 +886,7 @@ {\clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax \colo_basics_synchronize{#1}% \ifcase\c_colo_protection - \protected\instance\setvalue{#1}{\colo_helpers_activate{#1}}% + \protected\instance\defcsname#1\endcsname{\colo_helpers_activate{#1}}% \fi} %D Spotcolors used setxvalue but that messes up currentcolor and probably no global @@ -973,7 +973,7 @@ \v_colo_freeze_state \relax \colo_basics_synchronize{#1}% - \protected\instance\setvalue{#1}{\colo_helpers_activate{#1}}} + \protected\instance\defcsname#1\endcsname{\colo_helpers_activate{#1}}} %D Here is a more efficient helper for pgf: %D @@ -1011,10 +1011,10 @@ %D %D \stopmode -\def\pgf@context@registercolor#1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\zerocount\thecolorattribute{#1}}} -\def\pgf@context@registergray #1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plustwo \thecolorattribute{#1}}} -\def\pgf@context@registerrgb #1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusthree\thecolorattribute{#1}}} -\def\pgf@context@registercmyk #1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusfour \thecolorattribute{#1}}} +\protected\def\pgf@context@registercolor#1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\zerocount\thecolorattribute{#1}}} +\protected\def\pgf@context@registergray #1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plustwo \thecolorattribute{#1}}} +\protected\def\pgf@context@registerrgb #1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusthree\thecolorattribute{#1}}} +\protected\def\pgf@context@registercmyk #1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusfour \thecolorattribute{#1}}} %D \starttyping %D \ifdefined\pgf@context@registercolor @@ -1037,7 +1037,7 @@ \expandafter\secondoftwoarguments \fi} -\let\doifcolorelse\doifelsecolor +\aliased\let\doifcolorelse\doifelsecolor \permanent\def\doifcolor#1% {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname @@ -1099,7 +1099,7 @@ \permanent\protected\def\starttextcolor[#1]% {\doifsomething{#1}{\colo_helpers_switch_to_maintextcolor{#1}}} -\let\stoptextcolor\relax +\aliased\let\stoptextcolor\relax \let\p_colo_textcolor\empty @@ -1122,13 +1122,14 @@ \def\colo_helpers_inherited_direct_ts#1{\ifcsname\??transparencysetter #1\endcsname\lastnamedcs\fi} \def\colo_helpers_inherited_direct_ta#1{\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi} -\let\colo_helpers_set_value\setvalue +\let\colo_defcsname\defcsname +\let\colo_endcsname\endcsname \appendtoks \ifconditional\c_colo_expanded - \let\colo_helpers_set_value\setevalue + \let\colo_defcsname\edefcsname \else - \let\colo_helpers_set_value\setvalue + \let\colo_defcsname\defcsname \fi \to \everysetupcolors @@ -1146,23 +1147,23 @@ \def\colo_palets_define_inherit#1#2#3% {\colo_basics_inherit{#1:#2}{#3}% - \colo_helpers_set_value{\??colorsetter #1:#2}{\colo_helpers_inherited_direct_cs{#3}}% - \colo_helpers_set_value{\??colorattribute #1:#2}{\colo_helpers_inherited_direct_ca{#3}}% - \colo_helpers_set_value{\??transparencysetter #1:#2}{\colo_helpers_inherited_direct_ts{#3}}% - \colo_helpers_set_value{\??transparencyattribute#1:#2}{\colo_helpers_inherited_direct_ta{#3}}} + \colo_defcsname\??colorsetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_cs{#3}}% + \colo_defcsname\??colorattribute #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ca{#3}}% + \colo_defcsname\??transparencysetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ts{#3}}% + \colo_defcsname\??transparencyattribute#1:#2\colo_endcsname{\colo_helpers_inherited_direct_ta{#3}}} \def\colo_palets_define_undefine#1#2#3% - {\localundefine{\??colorsetter #1:#2}% - \localundefine{\??colorattribute #1:#2}% - \localundefine{\??transparencysetter #1:#2}% - \localundefine{\??transparencyattribute#1:#2}} + {\letcsname\??colorsetter #1:#2\endcsname\undefined + \letcsname\??colorattribute #1:#2\endcsname\undefined + \letcsname\??transparencysetter #1:#2\endcsname\undefined + \letcsname\??transparencyattribute#1:#2\endcsname\undefined} \def\colo_palets_define_assign#1#2#3% {\definecolor[\??colorpalet#1:#2][#3]% - \colo_helpers_set_value{\??colorsetter #1:#2}{\colo_helpers_inherited_direct_cs{\??colorpalet#1:#2}}% - \colo_helpers_set_value{\??colorattribute #1:#2}{\colo_helpers_inherited_direct_ca{\??colorpalet#1:#2}}% - \colo_helpers_set_value{\??transparencysetter #1:#2}{\colo_helpers_inherited_direct_ts{\??colorpalet#1:#2}}% - \colo_helpers_set_value{\??transparencyattribute#1:#2}{\colo_helpers_inherited_direct_ta{\??colorpalet#1:#2}}} + \colo_defcsname\??colorsetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_cs{\??colorpalet#1:#2}}% + \colo_defcsname\??colorattribute #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ca{\??colorpalet#1:#2}}% + \colo_defcsname\??transparencysetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ts{\??colorpalet#1:#2}}% + \colo_defcsname\??transparencyattribute#1:#2\colo_endcsname{\colo_helpers_inherited_direct_ta{\??colorpalet#1:#2}}} \setvalue{\??colorattribute currentcolor}{\the\c_attr_color} % for mpcolor \setvalue{\??transparencyattribute currentcolor}{\the\c_attr_transparency} % for mpcolor @@ -1174,20 +1175,32 @@ %D Low level defs: -\permanent\protected\def\colordefalc#1#2{\setevalue{\??colorattribute #1}{#2}\setvalue {\??colorsetter #1}{\c_attr_color #2 }} -\permanent\protected\def\colordefagc#1#2{\setxvalue{\??colorattribute #1}{#2}\setgvalue{\??colorsetter #1}{\c_attr_color #2 }} % was not g -\permanent\protected\def\colordefalt#1#2{\setevalue{\??transparencyattribute#1}{#2}\setvalue {\??transparencysetter#1}{\c_attr_transparency#2 }} -\permanent\protected\def\colordefagt#1#2{\setxvalue{\??transparencyattribute#1}{#2}\setgvalue{\??transparencysetter#1}{\c_attr_transparency#2 }} - -\permanent\protected\def\colordefflc#1#2{\setvalue {\??colorattribute #1}{\colo_helpers_inherited_current_ca{#2}}\setvalue {\??colorsetter #1}{\colo_helpers_inherited_current_cs{#2}}} -\permanent\protected\def\colordeffgc#1#2{\setgvalue{\??colorattribute #1}{\colo_helpers_inherited_current_ca{#2}}\setvalue {\??colorsetter #1}{\colo_helpers_inherited_current_cs{#2}}} -\permanent\protected\def\colordefflt#1#2{\setvalue {\??transparencyattribute#1}{\colo_helpers_inherited_current_ta{#2}}\setvalue {\??transparencysetter#1}{\colo_helpers_inherited_current_ts{#2}}} -\permanent\protected\def\colordeffgt#1#2{\setgvalue{\??transparencyattribute#1}{\colo_helpers_inherited_current_ta{#2}}\setgvalue{\??transparencysetter#1}{\colo_helpers_inherited_current_ts{#2}}} - -\permanent\protected\def\colordefrlc #1{\localundefine {\??colorattribute #1}\localundefine {\??colorsetter #1}} -\permanent\protected\def\colordefrgc #1{\globalundefine{\??colorattribute #1}\globalundefine{\??colorsetter #1}} -\permanent\protected\def\colordefrlt #1{\localundefine {\??transparencyattribute#1}\localundefine {\??transparencysetter#1}} -\permanent\protected\def\colordefrgt #1{\globalundefine{\??transparencyattribute#1}\globalundefine{\??transparencysetter#1}} +\permanent\protected\def\colordefalc#1#2{\edefcsname\??colorattribute #1\endcsname{#2}% + \defcsname \??colorsetter #1\endcsname{\c_attr_color #2 }} +\permanent\protected\def\colordefagc#1#2{\xdefcsname\??colorattribute #1\endcsname{#2}% + \gdefcsname\??colorsetter #1\endcsname{\c_attr_color #2 }} % was not g +\permanent\protected\def\colordefalt#1#2{\edefcsname\??transparencyattribute#1\endcsname{#2}% + \gdefcsname\??transparencysetter #1\endcsname{\c_attr_transparency#2 }} +\permanent\protected\def\colordefagt#1#2{\xdefcsname\??transparencyattribute#1\endcsname{#2}% + \gdefcsname\??transparencysetter #1\endcsname{\c_attr_transparency#2 }} + +\permanent\protected\def\colordefflc#1#2{\defcsname \??colorattribute #1\endcsname{\colo_helpers_inherited_current_ca{#2}}% + \defcsname \??colorsetter #1\endcsname{\colo_helpers_inherited_current_cs{#2}}} +\permanent\protected\def\colordeffgc#1#2{\gdefcsname\??colorattribute #1\endcsname{\colo_helpers_inherited_current_ca{#2}}% + \defcsname \??colorsetter #1\endcsname{\colo_helpers_inherited_current_cs{#2}}} +\permanent\protected\def\colordefflt#1#2{\defcsname \??transparencyattribute#1\endcsname{\colo_helpers_inherited_current_ta{#2}}% + \defcsname \??transparencysetter #1\endcsname{\colo_helpers_inherited_current_ts{#2}}} +\permanent\protected\def\colordeffgt#1#2{\gdefcsname\??transparencyattribute#1\endcsname{\colo_helpers_inherited_current_ta{#2}}% + \defcsname \??transparencysetter #1\endcsname{\colo_helpers_inherited_current_ts{#2}}} + +\permanent\protected\def\colordefrlc #1{\letcsname \??colorattribute #1\endcsname\undefined + \letcsname \??colorsetter #1\endcsname\undefined} +\permanent\protected\def\colordefrgc #1{\gletcsname\??colorattribute #1\endcsname\undefined + \gletcsname\??colorsetter #1\endcsname\undefined} +\permanent\protected\def\colordefrlt #1{\letcsname \??transparencyattribute#1\endcsname\undefined + \letcsname \??transparencysetter #1\endcsname\undefined} +\permanent\protected\def\colordefrgt #1{\gletcsname\??transparencyattribute#1\endcsname\undefined + \gletcsname\??transparencysetter #1\endcsname\undefined} %D \macros %D {colorvalue, grayvalue} diff --git a/tex/context/base/mkiv/cont-cs.mkxl b/tex/context/base/mkxl/cont-cs.mkxl index 8e5ae567c..8e5ae567c 100644 --- a/tex/context/base/mkiv/cont-cs.mkxl +++ b/tex/context/base/mkxl/cont-cs.mkxl diff --git a/tex/context/base/mkiv/cont-de.mkxl b/tex/context/base/mkxl/cont-de.mkxl index 579cc88c3..579cc88c3 100644 --- a/tex/context/base/mkiv/cont-de.mkxl +++ b/tex/context/base/mkxl/cont-de.mkxl diff --git a/tex/context/base/mkiv/cont-en.mkxl b/tex/context/base/mkxl/cont-en.mkxl index bfb17ffb3..bfb17ffb3 100644 --- a/tex/context/base/mkiv/cont-en.mkxl +++ b/tex/context/base/mkxl/cont-en.mkxl diff --git a/tex/context/base/mkxl/cont-fil.mkxl b/tex/context/base/mkxl/cont-fil.mkxl new file mode 100644 index 000000000..0ca3bb05a --- /dev/null +++ b/tex/context/base/mkxl/cont-fil.mkxl @@ -0,0 +1,152 @@ +%D \module +%D [ file=cont-fil, +%D version=1997.11.15, +%D title=\CONTEXT\ Miscellaneous Macros, +%D subtitle=File Synonyms, +%D author=J. Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Todo: use full names and remove calls at the tex end (now integrated in \LUA\ +%D library code .. then we can load it at runtime when needed. We can also remove +%D some of the names that no longer make sense for \LMTX. + +\writestatus{loading}{ConTeXt File Synonyms} + +\definefilesynonym [chemics] [chemic] + +\definefilesynonym [unit] [units] + +\definefilesynonym [pstric] [pstricks] +\definefilesynonym [pstrick] [pstricks] + +\definefilesynonym [finance] [financ] + +\definefilesynonym [dir-make] [dir-01] +\definefilesynonym [dir-identify] [dir-05] + +\definefilesynonym [int-load] [set-11] +\definefilesynonym [int-make] [set-12] + + \definefilesynonym [fig-base] [fig-00] + \definefilesynonym [fig-make] [fig-01] + \definefilesynonym [fig-fake] [fig-02] + \definefilesynonym [fig-missing] [fig-06] + + \definefilesynonym [exi-interface] [exi-21] + + \definefilesynonym [res-make] [res-01] + \definefilesynonym [res-base] [res-04] + \definefilesynonym [res-crop] [res-07] + \definefilesynonym [res-trace] [res-08] + \definefilesynonym [res-log] [res-09] + \definefilesynonym [res-identify] [res-12] + + \definefilesynonym [med-show] [res-50] + +\definefilesynonym [pre-general] [pre-00] +\definefilesynonym [pre-original] [present-original] +\definefilesynonym [pre-green] [present-green] +\definefilesynonym [pre-funny] [present-funny] +\definefilesynonym [pre-colorful] [present-colorful] +\definefilesynonym [pre-fuzzy] [present-fuzzy] +\definefilesynonym [pre-polish] [pre-06] +\definefilesynonym [pre-spider] [pre-07] +\definefilesynonym [pre-wonder] [pre-08] +\definefilesynonym [pre-windows] [present-windows] +\definefilesynonym [pre-grow] [present-grow] +\definefilesynonym [pre-stack] [present-stack] +\definefilesynonym [pre-split] [present-split] +\definefilesynonym [pre-balls] [present-balls] +\definefilesynonym [pre-weird] [present-weird] +\definefilesynonym [pre-stepwise] [present-stepwise] +\definefilesynonym [pre-stepper] [present-stepper] +\definefilesynonym [pre-punk] [present-punk] +\definefilesynonym [pre-random] [present-random] + +\definefilesynonym [pre-arrows] [pre-12] +\definefilesynonym [pre-writing] [pre-13] +\definefilesynonym [pre-knot] [pre-16] +\definefilesynonym [pre-shade] [pre-18] +\definefilesynonym [pre-organic] [pre-19] +\definefilesynonym [pre-speckle] [pre-20] +\definefilesynonym [pre-zoom] [pre-21] +\definefilesynonym [pre-cycle] [pre-22] +\definefilesynonym [pre-super] [pre-23] +\definefilesynonym [pre-more] [pre-26] + +\definefilesynonym [pre-01] [present-original] +\definefilesynonym [pre-02] [present-green] +\definefilesynonym [pre-03] [present-funny] +\definefilesynonym [pre-04] [present-colorful] +\definefilesynonym [pre-05] [present-fuzzy] +\definefilesynonym [pre-09] [present-windows] +\definefilesynonym [pre-10] [present-grow] +\definefilesynonym [pre-11] [present-stack] +\definefilesynonym [pre-14] [present-split] +\definefilesynonym [pre-15] [present-balls] +\definefilesynonym [pre-17] [present-weird] +\definefilesynonym [pre-41] [present-tiles] +\definefilesynonym [pre-60] [present-stepwise] +\definefilesynonym [pre-61] [present-stepper] +\definefilesynonym [pre-62] [present-overlap] +\definefilesynonym [pre-69] [present-wobbling] +\definefilesynonym [pre-70] [present-punk] +\definefilesynonym [pre-71] [present-random] + +\definefilesynonym [abr-01] [abbreviations-pseudocaps] +\definefilesynonym [abr-02] [abbreviations-smallcaps] +\definefilesynonym [abr-03] [abbreviations-words] +\definefilesynonym [abr-04] [abbreviations-mixed] + +\definefilesynonym [art-01] [article-basic] +\definefilesynonym [article] [article-basic] +\definefilesynonym [mag-01] [magazine-basic] +\definefilesynonym [magazine] [magazine-basic] +\definefilesynonym [mod-01] [module-basic] +\definefilesynonym [module] [module-basic] + +\definefilesynonym [map-10] [maps] % for a while + +\definefilesynonym [mml] [mathml] +\definefilesynonym [cml] [chemml] + +\definefilesynonym [letter] [cor-01] +\definefilesynonym [memo] [cor-02] +\definefilesynonym [resume] [cor-03] + +\definefilesynonym [fnt-10] [fonts-complete] +\definefilesynonym [fnt-11] [fonts-system] +\definefilesynonym [fnt-20] [fonts-steps] +\definefilesynonym [fnt-21] [fonts-steps] +\definefilesynonym [fnt-22] [fonts-engines] +\definefilesynonym [fnt-23] [fonts-shapes] +\definefilesynonym [fnt-24] [fonts-cjk] +\definefilesynonym [fnt-25] [math-characters] +\definefilesynonym [fnt-28] [fonts-goodies] +\definefilesynonym [fnt-29] [fonts-shapes] +\definefilesynonym [fnt-31] [fonts-coverage] +\definefilesynonym [fnt-33] [math-coverage] + +\definefilesynonym [mat-10] [math-characters] +\definefilesynonym [mat-11] [math-characters] +\definefilesynonym [mat-12] [math-parameters] +\definefilesynonym [mat-20] [math-parameters] + +\definefilesynonym [syn-01] [syntax] + +\definefilesynonym [reg-01] [regimes-list] + +\definefilesynonym [set-11] [setups-basics] +\definefilesynonym [set-12] [setups-overview] +%definefilesynonym [set-13] [setups-proofing] +%definefilesynonym [set-15] [setups-generate] + +\definefilesynonym [ecmascript] [libs-imp-mujs] +\definefilesynonym [zint] [libs-imp-zint] + +\endinput diff --git a/tex/context/base/mkiv/cont-fr.mkxl b/tex/context/base/mkxl/cont-fr.mkxl index bedae536b..bedae536b 100644 --- a/tex/context/base/mkiv/cont-fr.mkxl +++ b/tex/context/base/mkxl/cont-fr.mkxl diff --git a/tex/context/base/mkiv/cont-gb.mkxl b/tex/context/base/mkxl/cont-gb.mkxl index 464b237da..464b237da 100644 --- a/tex/context/base/mkiv/cont-gb.mkxl +++ b/tex/context/base/mkxl/cont-gb.mkxl diff --git a/tex/context/base/mkiv/cont-it.mkxl b/tex/context/base/mkxl/cont-it.mkxl index 1702a872f..1702a872f 100644 --- a/tex/context/base/mkiv/cont-it.mkxl +++ b/tex/context/base/mkxl/cont-it.mkxl diff --git a/tex/context/base/mkxl/cont-log.mkxl b/tex/context/base/mkxl/cont-log.mkxl new file mode 100644 index 000000000..3d110c648 --- /dev/null +++ b/tex/context/base/mkxl/cont-log.mkxl @@ -0,0 +1,298 @@ +%D \module +%D [ file=cont-log, +%D version=1995.10.10, +%D title=\CONTEXT\ Miscellaneous Macros, +%D subtitle=\TEX\ Logos, +%D author=J. Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt TeX Logos} + +%D The system that is used to typeset this text is called \TEX, typeset with an +%D lowered~E. From te beginning of \TEX, authors of macro packages adapted this +%D raising and lowering style. In this module we define some of those logos. + +%D We define the uppercase logo commands as (unfrozen) instances because they can be +%D redefined in the synonyms modules. + +\unprotect + +\frozen\instance\protected\def\TeX + {\dontleavehmode + \begingroup + T% + \setbox\scratchbox\hbox{M}% + \kern-.1667\wd\scratchbox + \lower.5\exheight\hbox{E}% + \kern-.125\wd\scratchbox + X% + \endgroup} + +\frozen\instance\protected\def\TeXsuffix{\wordboundary\TeX} +\frozen\instance\protected\def\TeXprefix{\TeX\wordboundary} + +\frozen\instance\protected\def\ConTeXt + {\dontleavehmode + \begingroup + Con% + \wordboundary + \setbox\scratchboxone\hbox{T\kern\zeropoint e}% + \setbox\scratchboxtwo\hbox{Te}% + \discretionary{-}{}{\kern\dimexpr\wd\scratchboxtwo-\wd\scratchboxone\relax}% + \TeX t% + \endgroup} + +\frozen\instance\protected\def\PPCHTeX{ppch\TeX} + +\frozen\instance\protected\def\LaTeX % requested by erik frambach + {\dontleavehmode + \begingroup + \setbox\scratchbox\hbox{L}% + \scratchdimen\ht\scratchbox + \setbox\scratchbox\hbox{\doresetattribute{case}\txx A}% + L\kern-.55\wd\scratchbox + \raise\scratchdimen\hbox{\lower\ht\scratchbox\copy\scratchbox}% + \kern-.2\wd\scratchbox\TeX + \endgroup} + +\frozen\instance\protected\def\TaBlE + {T% + \kern-.27\emwidth\lower.5\exheight\hbox{A}% + \kern-.18\emwidth B% + \kern-.1\emwidth\lower.5\exheight\hbox{L}% + \kern-.075\emwidth E} + +\frozen\instance\protected\def\PiCTeX + {P% + \kern-.12\emwidth\lower.5\exheight\hbox{I}% + \kern-.075\emwidth C% + \kern-.11\emwidth\TeX} + +\def\syst_logos_ams_script#1% + {\normalstartimath + \cal\ifdim\bodyfontsize>1.1\emwidth\scriptstyle\fi#1% + \normalstopimath} + +\frozen\instance\protected\def\AmSTeX + {\dontleavehmode + \syst_logos_ams_script A% + \kern-.1667\emwidth\lower.5\exheight\hbox{\syst_logos_ams_script M}% + \kern-.125\emwidth\syst_logos_ams_script S% + -\TeX} + +\frozen\instance\protected\def\LamSTeX + {L% + \kern-.4\emwidth\raise.3\exheight\hbox{\syst_logos_ams_script A}% + \kern-.25\emwidth\lower.4\exheight\hbox{\syst_logos_ams_script M}% + \kern-.1\emwidth{\syst_logos_ams_script S}% + -\TeX} + +%D Alternative \CONTEXT\ logo, first Idris S.~Hamid's version: +%D +%D \def\Context +%D {{\sc C\kern -.0667emo\kern -.0667emn\kern -.0549emt\kern +%D -.1667em\lower.5ex\hbox {e}\kern -.125emx\kern -.0549emt}} +%D +%D I changed this into one that adapts itself: + +\frozen\instance\protected\def\Context % wrong usage of \getscaledglyph + {\dontleavehmode + \begingroup + C% + \kern -.0667\emwidth + \getscaledglyph{.8}\empty{% + O\kern-.0667\emwidth + N% + \discretionary{-}{}{\kern-.0549\emwidth}% + T% + \doifelseitalic{\kern-.1\emwidth}{\kern-.1667\emwidth}% + \lower.5\exheight\hbox{E}% + \doifelseitalic\empty{\kern-.11em}% + X% + \kern-.055\emwidth + T% + }% + \endgroup} + +%D The \METAFONT\ and \METAPOST\ logos adapt themselves to the current fontsize, an +%D ugly but usefull hack. + +\let\logofont\nullfont + +% \loadmapfile[original-base.map] % stil needed? not if we assume afm + +\protected\def\setMFPfont% more sensitive for low level changes + {\font\logofont=logo% + \ifx\fontalternative\s!bf\s!bf\orelse + \ifx\fontalternative\s!it\s!sl\orelse + \ifx\fontalternative\s!sl\s!sl\orelse + \ifx\fontalternative\s!bi\s!bf\orelse + \ifx\fontalternative\s!bs\s!bf\fi + 10 at \currentfontscale\bodyfontsize % there is no afm in the minimals yet + \logofont} + +\def\syst_logos_meta_hyphen % there is no hyphenchar in this font + {\discretionary{\vrule\s!height.33\emwidth\s!depth-.27\emwidth\s!width.33\emwidth}{}{}} + +\frozen\instance\protected\def\MetaFont + {\dontleavehmode + \begingroup + \setMFPfont META\syst_logos_meta_hyphen FONT% + \endgroup} + +% \protected\def\MetaPost +% {\dontleavehmode +% \begingroup +% \setMFPfont META\syst_logos_meta_hyphen POST% +% \endgroup} +% +% As decided on the ConText Meeting 2013 the logo has been simplified: + +\instance\protected\def\MetaPost{MetaPost} +\instance\protected\def\MetaFun {MetaFun} + +%D \macros +%D {TEX, METAFONT, METAPOST, METAFUN, +%D PICTEX, TABLE, +%D CONTEXT, PPCHTEX, +%D AMSTEX, LATEX, LAMSTEX} +%D +%D We define the funny written ones as well as the less error prone upper case names +%D (in \CONTEXT\ we tend to write all user defined commands, like abbreviations, in +%D uppercase.) + +\instance\protected\def\METAFONT{\MetaFont} +\instance\protected\def\METAPOST{\MetaPost} +\instance\protected\def\PPCHTEX {\PPCHTeX} +\instance\protected\def\CONTEXT {\ConTeXt} +\instance\protected\def\METAFUN {\MetaFun} + +\instance\protected\def\TEX {\TeX} +\instance\protected\def\LATEX {\LaTeX} +\instance\protected\def\PICTEX {\PiCTeX} +\instance\protected\def\TABLE {\TaBlE} +\instance\protected\def\AMSTEX {\AmSTeX} +\instance\protected\def\LAMSTEX {\LamSTeX} +\instance\protected\def\INRSTEX {inrs\TeX} + +\instance\protected\def\PRAGMA {Pragma ADE} + +%D And this is how they show up: \TeX, \MetaFont, \MetaPost, \PiCTeX, \TaBlE, \ConTeXt, +%D \PPCHTeX, \AmSTeX, \LaTeX, \LamSTeX. + +%D Some placeholders: + +\frozen\instance\protected\def\eTeX {\mathematics{\varepsilon}-\TeX} +\frozen\instance\protected\def\pdfTeX {pdf\wordboundary\TeX} +\frozen\instance\protected\def\pdfeTeX {pdfe-\wordboundary\TeX} +\frozen\instance\protected\def\luaTeX {lua\wordboundary\TeX} +\frozen\instance\protected\def\Lua {Lua} +\frozen\instance\protected\def\luajitTeX {lua\wordboundary jit\wordboundary\TeX} +\frozen\instance\protected\def\luametaTeX{lua\wordboundary meta\wordboundary\TeX} +%frozen\instance\protected\def\XeTeX {X\lower.5\exheight\hbox{\kern-.15\emwidth\mirror{E}}\kern-.1667\emwidth\TeX} + +% Adapted from a patch by Mojca: + +\def\syst_logos_xetex_e + {\setbox\scratchbox\hbox{E}% + \raise\dimexpr\ht\scratchbox+\dp\scratchbox\relax\hbox{\rotate[\c!rotation=180]{\box\scratchbox}}} + +\frozen\instance\protected\def\XeTeX + {X\lower.5\exheight + \hbox + {\kern-.15\emwidth + \iffontchar\font"018E\relax + \char"018E% + \else + \ifx\fontalternative\s!bf \mirror{E}\orelse + \ifx\fontalternative\s!it\syst_logos_xetex_e\orelse + \ifx\fontalternative\s!sl\syst_logos_xetex_e\orelse + \ifx\fontalternative\s!bi\syst_logos_xetex_e\orelse + \ifx\fontalternative\s!bs\syst_logos_xetex_e\orelse + \mirror{E}\fi + \fi}% + \kern-.1667\emwidth\TeX} + +\instance\protected\def\ETEX {\eTeX} +\instance\protected\def\PDFTEX {\pdfTeX} +\instance\protected\def\PDFETEX {\pdfeTeX} +\instance\protected\def\LUATEX {\luaTeX} +\instance\protected\def\LUAJITTEX {\luajitTeX} +\instance\protected\def\LuaTeX {\luaTeX} +\instance\protected\def\LuaMetaTeX{\luametaTeX} +\instance\protected\def\LUAMETATEX{\luametaTeX} +\instance\protected\def\XETEX {\XeTeX} + +\frozen\instance\protected\def\LuaTeX + {\dontleavehmode + \begingroup + Lua% + % hope for kerning, try aT + \setbox0\hbox{aT}% + \setbox2\hbox{a\kern\zeropoint T}% + \ifdim\wd0=\wd2 % kerns can go two ways + % no aT kerning, try oT as a is not symmetrical + \setbox0\hbox{oT}% + \setbox2\hbox{o\kern\zeropoint T}% + \ifdim\wd0=\wd2 % kerns can go two ways + % no aT and oT kerning, try To + \setbox0\hbox{To}% + \setbox2\hbox{T\kern\zeropoint o}% + % maybe we need to compensate for the angle (sl/it/bs/bi) + \fi + \ifdim\wd0=\wd2\else + \kern\dimexpr\wd0-\wd2\relax + \fi + \fi + \TeX + \endgroup} + +\frozen\instance\protected\def\LuajitTeX + {\dontleavehmode + \begingroup + % at this moment there is no real need for kerning tT + Luajit\kern\zeropoint\TeX + \endgroup} + +\frozen\instance\let\luaTeX \LuaTeX +\frozen\instance\let\luajitTeX\LuajitTeX + +\instance\protected\def\LUATEX {\LuaTeX} +\instance\protected\def\LUAJITTEX{\LuajitTeX} + +\instance\protected\def\MKII{MkII} % MarkTwo +\instance\protected\def\MKIV{MkIV} % MarkFour : MKIV +\instance\protected\def\MKVI{MkVI} % MarkSix : MKIV +\instance\protected\def\MKXL{MkXL} % MarkFourty : LMTX +\instance\protected\def\MKLX{MkLX} % MarkSixty : LMTX +\instance\protected\def\MKIX{MkIX} % : MKIV / LMTX +\instance\protected\def\MKXI{MkXI} % : MKIV / LMTX + +\instance\protected\def\MPII{MpII} % MarkTwo +\instance\protected\def\MPIV{MpIV} % MarkFour : MetaFun +\instance\protected\def\MPVI{MpVI} % MarkSix : MetaFun +\instance\protected\def\MPXL{MpXL} % MarkFourty : LuaMetaFun +\instance\protected\def\MPLX{MpLX} % MarkSixty : LuaMetaFun + +\instance\protected\def\LMTX{LMTX} % for LuaMetaTeX + +\appendtoks + \enforced\instance\def\ConTeXt {ConTeXt}% + \enforced\instance\def\MetaPost {MetaPost}% + \enforced\instance\def\MetaFont {MetaFont}% + \enforced\instance\def\MetaFun {MetaFun}% + \enforced\instance\def\TeX {TeX}% + \enforced\instance\let\TeXsuffix \TeX + \enforced\instance\let\TeXprefix \TeX + \enforced\instance\def\LuaTeX {LuaTeX}% + \enforced\instance\def\LuajitTeX {LuajitTeX}% + \enforced\instance\def\LuaMetaTeX{LuaMetaTeX}% + %\let\wordboundary\empty % primitive so we need to promote it to frozen (orjust preroll) +\to \everysimplifycommands + +\protect \endinput diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl new file mode 100644 index 000000000..e44f73f9d --- /dev/null +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -0,0 +1,50 @@ +%D \module +%D [ file=cont-new, +%D version=1995.10.10, +%D title=\CONTEXT\ Miscellaneous Macros, +%D subtitle=New Macros, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +% \normalend % uncomment this to get the real base runtime + +\newcontextversion{2020.11.23 18:34} + +%D This file is loaded at runtime, thereby providing an excellent place for hacks, +%D patches, extensions and new features. There can be local overloads in cont-loc +%D (which has always been the case) and experimental code in cont-exp (which is also +%D so old that I need to remind myself to check it occasionally, so here is the +%D reminder). + +% \enabletrackers[pages.timing] +% \enabletrackers[system.usage=summary] + +\unprotect + +\writestatus\m!system{beware: some patches loaded from cont-new.mkiv} + +%D I need to verify if this indeed will make it into \type {math-ini.mkiv}, that is: +%D does Alan use it? + +\ifdefined\t \else \permanent\protected\def\t{\mathortext\text\mathtext} \fi +\ifdefined\w \else \permanent\protected\def\w{\mathortext\word\mathword} \fi + +\appendtoks + \enforced\aliased\let\t\mathtext + \enforced\aliased\let\w\mathword +\to \everymathematics + +\pushoverloadmode + % charts needs these + \overloaded\unletfrozen\name % for now + \overloaded\frozen\let\type\type +\popoverloadmode + +%D We're done. + +\protect \endinput diff --git a/tex/context/base/mkiv/cont-nl.mkxl b/tex/context/base/mkxl/cont-nl.mkxl index 1f00e7e89..1f00e7e89 100644 --- a/tex/context/base/mkiv/cont-nl.mkxl +++ b/tex/context/base/mkxl/cont-nl.mkxl diff --git a/tex/context/base/mkiv/cont-pe.mkxl b/tex/context/base/mkxl/cont-pe.mkxl index 82bf73721..82bf73721 100644 --- a/tex/context/base/mkiv/cont-pe.mkxl +++ b/tex/context/base/mkxl/cont-pe.mkxl diff --git a/tex/context/base/mkiv/cont-ro.mkxl b/tex/context/base/mkxl/cont-ro.mkxl index 6d636c7dc..6d636c7dc 100644 --- a/tex/context/base/mkiv/cont-ro.mkxl +++ b/tex/context/base/mkxl/cont-ro.mkxl diff --git a/tex/context/base/mkxl/cont-run.mkxl b/tex/context/base/mkxl/cont-run.mkxl new file mode 100644 index 000000000..909c07204 --- /dev/null +++ b/tex/context/base/mkxl/cont-run.mkxl @@ -0,0 +1,59 @@ +%D \module +%D [ file=cont-run, +%D version=2014.12.26, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Runner, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Core Macros / Runner} + +\registerctxluafile{cont-run}{} + +% \enabletrackers[system.synctex.visualize] +% \enabletrackers[system.synctex.xml] +% \enabledirectives[system.synctex.details] +% \setupsynctex[state=start] + +\unprotect + +\permanent\let\synctexsetfilename \clf_synctexsetfilename % can be public implementors +\permanent\let\synctexresetfilename\clf_synctexresetfilename % idem +\permanent\let\synctexblockfilename\clf_synctexblockfilename % idem + +\aliased\let\synctexpause \donothing +\aliased\let\synctexresume \donothing +\aliased\let\synctexpushline\donothing +\aliased\let\synctexpopline \donothing + +\appendtoks\synctexpause \to\everybeforeoutput +\appendtoks\synctexresume\to\everyafteroutput + +\permanent\protected\def\setupsynctex[#1]% + {\begingroup + \getdummyparameters[\c!state=\v!stop,\c!method=\v!max,#1]% + \edef\p_state{\dummyparameter\c!state}% + \clf_setupsynctex + state {\p_state}% + method {\dummyparameter\c!method}% + \relax + \ifx\p_state\v!start + % when public implementor, use conditional + \enforced\glet\synctexpause \clf_synctexpause + \enforced\glet\synctexresume \clf_synctexresume + \enforced\glet\synctexpushline\clf_synctexpushline + \enforced\glet\synctexpopline \clf_synctexpopline + \fi + \endgroup} + +\permanent\protected\def\blocksynctexfile[#1]% + {\processcommacommand{#1}\synctexblockfilename} + +\aliased\let\continuewhenlmtxmode\relax + +\protect \endinput diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkxl/context.mkxl index e28f32f07..ca9c6be40 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2020.11.19 11:23} +\edef\contextversion{2020.11.23 18:34} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error @@ -86,13 +86,13 @@ %D Now the more fundamental code gets defined. \loadmkxlfile{norm-ctx} -\loadmarkfile{syst-pln} -\loadmarkfile{syst-mes} +\loadmkxlfile{syst-pln} +\loadmkxlfile{syst-mes} \loadmkxlfile{luat-cod} -\loadmarkfile{luat-bas} -\loadmarkfile{luat-lib} -\loadmarkfile{luat-soc} +\loadmkxlfile{luat-bas} +\loadmkxlfile{luat-lib} +\loadmkxlfile{luat-soc} \loadmkxlfile{catc-ini} \loadmkxlfile{catc-act} @@ -108,7 +108,7 @@ %D From here on we have \unexpanded being \normalprotected, as we already had %D \type {\unexpanded} long before etex came around. -\loadmarkfile{luat-ini} +\loadmkxlfile{luat-ini} \loadmkxlfile{toks-scn} \loadmkxlfile{syst-aux} @@ -116,9 +116,9 @@ \loadmkxlfile{syst-con} \loadmkxlfile{syst-fnt} -\loadmarkfile{syst-rtp} +\loadmkxlfile{syst-rtp} -\loadmarkfile{luat-usr} +\loadmkxlfile{luat-usr} \loadmklxfile{file-ini} \loadmklxfile{file-res} @@ -149,7 +149,7 @@ \loadmkxlfile{trac-ctx} % maybe move up -\loadmarkfile{toks-aux} +\loadmkxlfile{toks-aux} \loadmkxlfile{attr-ini} @@ -184,7 +184,7 @@ \loadmkxlfile{supp-box} -\loadmarkfile{supp-ran} +\loadmkxlfile{supp-ran} \loadmkxlfile{supp-mat} \loadmkxlfile{core-uti} @@ -194,7 +194,7 @@ \loadmkxlfile{typo-ini} \loadmkxlfile{typo-lin} -\loadmarkfile{typo-bld} % par builders +\loadmkxlfile{typo-bld} % par builders \loadmkxlfile{typo-inj} @@ -204,14 +204,14 @@ \loadmkxlfile{core-sys} \loadmkxlfile{core-con} -\loadmarkfile{cont-fil} +\loadmkxlfile{cont-fil} \loadmkxlfile{regi-ini} \loadmkxlfile{enco-ini} \loadmkxlfile{hand-ini} \loadmkxlfile{lang-ini} -\loadmarkfile{lang-hyp} % also loads dis +\loadmkxlfile{lang-hyp} % also loads dis \loadmkxlfile{lang-lab} \loadmkxlfile{unic-ini} @@ -225,30 +225,30 @@ \loadmkxlfile{node-bck} % overloads anch-pgr (experimental and undocumented) -\loadmarkfile{pack-cut} +\loadmkxlfile{pack-cut} \loadmkxlfile{lang-mis} \loadmkxlfile{lang-url} -\loadmarkfile{lang-def} +\loadmkxlfile{lang-def} % \loadmkvifile{file-job} % why so late? \loadmkxlfile{symb-ini} % brrr depends on fonts -\loadmarkfile{sort-ini} +\loadmkxlfile{sort-ini} -\loadmkvifile{pack-mis} +\loadmklxfile{pack-mis} \loadmkxlfile{pack-ori} \loadmkxlfile{pack-rul} \loadmkxlfile{pack-mrl} \loadmklxfile{pack-bck} -\loadmarkfile{pack-fen} +\loadmkxlfile{pack-fen} \loadmkxlfile{lxml-ini} \loadmkxlfile{lxml-sor} -\loadmkvifile{typo-prc} -\loadmkivfile{typo-plc} +\loadmklxfile{typo-prc} +\loadmkxlfile{typo-plc} \loadmklxfile{strc-ini} \loadmkxlfile{strc-tag} @@ -261,26 +261,26 @@ \loadmkxlfile{strc-pag} % hm, depends on core-num \loadmkxlfile{strc-ren} %loadmarkfile{strc-xml} -\loadmarkfile{strc-def} % might happen later +\loadmkxlfile{strc-def} % might happen later \loadmklxfile{strc-ref} %loadmarkfile{strc-reg} \loadmklxfile{strc-lev} % experiment \loadmkxlfile{spac-hor} \loadmkxlfile{spac-ali} -\loadmarkfile{spac-flr} +\loadmkxlfile{spac-flr} \loadmkxlfile{spac-ver} % beware, hooks into strc-sec -\loadmarkfile{spac-lin} -\loadmarkfile{spac-pag} +\loadmkxlfile{spac-lin} +\loadmkxlfile{spac-pag} \loadmkxlfile{spac-par} -\loadmarkfile{spac-def} -\loadmkvifile{spac-prf} +\loadmkxlfile{spac-def} +\loadmklxfile{spac-prf} \loadmkxlfile{spac-grd} \loadmklxfile{scrn-ini} -\loadmkvifile{scrn-ref} +\loadmklxfile{scrn-ref} -\loadmarkfile{pack-obj} +\loadmkxlfile{pack-obj} \loadmklxfile{strc-itm} @@ -294,49 +294,48 @@ % \loadmarkfile{core-sys} -\loadmarkfile{page-var} +\loadmkxlfile{page-var} \loadmklxfile{page-otr} \loadmkxlfile{page-ini} -\loadmarkfile{page-ins} -\loadmarkfile{page-fac} -\loadmarkfile{page-brk} -\loadmarkfile{page-col} -\loadmarkfile{page-inf} -\loadmarkfile{page-flt} +\loadmkxlfile{page-ins} +\loadmkxlfile{page-fac} +\loadmkxlfile{page-brk} +\loadmkxlfile{page-col} +\loadmkxlfile{page-inf} +\loadmkxlfile{page-flt} \loadmkxlfile{page-bck} \loadmkxlfile{page-not} \loadmkxlfile{page-one} \loadmkxlfile{page-lay} -\loadmkvifile{page-box} +\loadmklxfile{page-box} \loadmklxfile{page-txt} -\loadmarkfile{page-sid} % when +\loadmkxlfile{page-sid} \loadmklxfile{strc-flt} -\loadmarkfile{page-pst} -\loadmkvifile{page-mbk} +\loadmkxlfile{page-pst} +\loadmklxfile{page-mbk} %loadmarkfile{page-mul} % \usecolumns[old-multicolumns] -\loadmarkfile{page-mix} -\loadmarkfile{page-smp} -%loadmarkfile{page-set} % \usecolumns[old-columnsets] -\loadmarkfile{page-cst} -\loadmarkfile{page-pcl} % new +\loadmkxlfile{page-mix} +\loadmkxlfile{page-smp} +\loadmkxlfile{page-cst} +\loadmkxlfile{page-pcl} % new \loadmkxlfile{pack-lyr} -\loadmarkfile{pack-pos} -\loadmkvifile{page-mak} +\loadmkxlfile{pack-pos} +\loadmklxfile{page-mak} \loadmkxlfile{page-mcl} \loadmkxlfile{strc-reg} % uses mixed columns -\loadmkvifile{page-lin} -\loadmarkfile{page-par} -\loadmarkfile{typo-pag} +\loadmklxfile{page-lin} +\loadmkxlfile{page-par} +\loadmkxlfile{typo-pag} \loadmkxlfile{typo-mar} -\loadmarkfile{typo-itm} +\loadmkxlfile{typo-itm} -\loadmarkfile{buff-ini} +\loadmkxlfile{buff-ini} \loadmkxlfile{buff-ver} -\loadmkvifile{buff-par} +\loadmklxfile{buff-par} \loadmarkfile{buff-imp-tex} % optional as also runtime if not loaded \loadmarkfile{buff-imp-mp} % optional as also runtime if not loaded @@ -348,48 +347,48 @@ \loadmkxlfile{strc-blk} -\loadmarkfile{page-imp} -\loadmkvifile{page-sel} % optional -\loadmkvifile{page-inj} % optional +\loadmkxlfile{page-imp} +\loadmklxfile{page-sel} % optional +\loadmklxfile{page-inj} % optional \loadmklxfile{scrn-pag} -\loadmkvifile{scrn-wid} -\loadmkvifile{scrn-but} -\loadmkvifile{scrn-bar} +\loadmklxfile{scrn-wid} +\loadmklxfile{scrn-but} +\loadmklxfile{scrn-bar} -\loadmarkfile{page-com} % optional (after scrn-pag) +\loadmkxlfile{page-com} % optional (after scrn-pag) \loadmkxlfile{strc-bkm} % bookmarks \loadmkxlfile{java-ini} -\loadmkvifile{scrn-fld} -\loadmkvifile{scrn-hlp} +\loadmklxfile{scrn-fld} +\loadmklxfile{scrn-hlp} \loadmkxlfile{char-enc} -\loadmkvifile{font-lib} % way too late but after language +\loadmklxfile{font-lib} % way too late but after language \loadmklxfile{font-fil} -\loadmkvifile{font-var} +\loadmklxfile{font-var} \loadmklxfile{font-fea} \loadmklxfile{font-mat} \loadmklxfile{font-ini} \loadmklxfile{font-sym} \loadmklxfile{font-sty} -\loadmkvifile{font-set} +\loadmklxfile{font-set} \loadmklxfile{font-emp} \loadmkxlfile{font-pre} -\loadmarkfile{font-unk} +\loadmkxlfile{font-unk} \loadmkxlfile{font-tra} \loadmkxlfile{font-chk} -\loadmarkfile{font-uni} +\loadmkxlfile{font-uni} \loadmklxfile{font-col} -\loadmkvifile{font-gds} +\loadmklxfile{font-gds} \loadmklxfile{font-aux} -\loadmkvifile{font-sel} +\loadmklxfile{font-sel} -\loadmarkfile{typo-tal} -\loadmarkfile{typo-par} % par builders (uses fonts) +\loadmkxlfile{typo-tal} +\loadmkxlfile{typo-par} % par builders (uses fonts) \loadmkxlfile{tabl-com} %loadmarkfile{tabl-pln} @@ -417,56 +416,54 @@ \loadmkxlfile{trac-jus} \loadmkxlfile{typo-cln} -\loadmarkfile{typo-wrp} -\loadmarkfile{typo-spa} +\loadmkxlfile{typo-wrp} +\loadmkxlfile{typo-spa} \loadmkxlfile{typo-krn} \loadmklxfile{typo-itc} \loadmkxlfile{typo-dir} \loadmkxlfile{typo-brk} \loadmkxlfile{typo-cap} -\loadmarkfile{typo-dig} -\loadmarkfile{typo-rep} -\loadmkvifile{typo-txt} -\loadmarkfile{typo-drp} -\loadmarkfile{typo-fln} -\loadmarkfile{typo-sus} +\loadmkxlfile{typo-dig} +\loadmkxlfile{typo-rep} +\loadmklxfile{typo-txt} +\loadmkxlfile{typo-drp} +\loadmkxlfile{typo-fln} +\loadmkxlfile{typo-sus} \loadmkxlfile{typo-lig} -\loadmarkfile{typo-chr} -\loadmarkfile{typo-rub} -\loadmkivfile{typo-fkr} +\loadmkxlfile{typo-chr} +\loadmkxlfile{typo-rub} +\loadmkxlfile{typo-fkr} \loadmkxlfile{typo-pnc} \loadmklxfile{type-ini} -\loadmarkfile{type-set} +\loadmkxlfile{type-set} -\loadmarkfile{scrp-ini} +\loadmkxlfile{scrp-ini} \loadmkxlfile{symb-emj} -\loadmarkfile{lang-tra} % can be optional (discussion with mm sideeffect) -\loadmarkfile{lang-wrd} % can be optional (discussion with mm sideeffect) -\loadmarkfile{lang-rep} % can be optional (bt 2013 side effect) - -\loadmarkfile{prop-ini} % only for downward compatibility +\loadmkxlfile{lang-tra} % can be optional (discussion with mm sideeffect) +\loadmkxlfile{lang-wrd} % can be optional (discussion with mm sideeffect) +\loadmkxlfile{lang-rep} % can be optional (bt 2013 side effect) \loadmkxlfile{mlib-ctx} % messy order \loadmkxlfile{meta-ini} -\loadmarkfile{meta-tex} -\loadmarkfile{meta-fun} +\loadmkxlfile{meta-tex} +\loadmkxlfile{meta-fun} \loadmkxlfile{meta-pag} -\loadmarkfile{meta-grd} -\loadmarkfile{meta-fnt} -\loadmarkfile{meta-nod} -\loadmarkfile{meta-lua} +\loadmkxlfile{meta-grd} +\loadmkxlfile{meta-fnt} +\loadmkxlfile{meta-nod} +\loadmkxlfile{meta-lua} \loadmkxlfile{meta-mac} -\loadmarkfile{page-mrk} % depends on mp +\loadmkxlfile{page-mrk} % depends on mp -\loadmarkfile{page-flw} +\loadmkxlfile{page-flw} \loadmkxlfile{page-spr} -\loadmarkfile{page-plg} -\loadmarkfile{page-str} +\loadmkxlfile{page-plg} +\loadmkxlfile{page-str} \loadmkxlfile{anch-pgr} % can be moved up (nicer for dependencies) \loadmklxfile{anch-bck} @@ -476,21 +473,21 @@ \loadmkxlfile{math-ini} % way after font-pre ! \loadmkxlfile{math-pln} -\loadmarkfile{math-for} -\loadmarkfile{math-def} % also saves some meanings +\loadmkxlfile{math-for} +\loadmkxlfile{math-def} % also saves some meanings \loadmkxlfile{math-ali} \loadmklxfile{math-stc} \loadmkxlfile{math-frc} -\loadmarkfile{math-mis} -\loadmarkfile{math-scr} -\loadmarkfile{math-int} -\loadmarkfile{math-del} +\loadmkxlfile{math-mis} +\loadmkxlfile{math-scr} +\loadmkxlfile{math-int} +\loadmkxlfile{math-del} \loadmkxlfile{math-fen} -\loadmkvifile{math-acc} -\loadmkvifile{math-rad} -\loadmarkfile{math-inl} -\loadmarkfile{math-dis} -%loadmarkfile{math-lan} +\loadmklxfile{math-acc} +\loadmklxfile{math-rad} +\loadmkxlfile{math-inl} +\loadmkxlfile{math-dis} +%loadmkxlfile{math-lan} \loadmkxlfile{math-toy} \loadmkxlfile{strc-mat} @@ -521,14 +518,14 @@ \loadmkxlfile{pack-box} \loadmkxlfile{pack-bar} -\loadmarkfile{page-app} -\loadmarkfile{meta-fig} +\loadmkxlfile{page-app} +\loadmkxlfile{meta-fig} -\loadmarkfile{page-ffl} +\loadmkxlfile{page-ffl} -\loadmarkfile{lang-spa} % will become obsolete +\loadmkxlfile{lang-spa} % will become obsolete -\loadmarkfile{typo-ovl} % fuzzy project (tracing) code +\loadmkxlfile{typo-ovl} % fuzzy project (tracing) code % old bibtex support: (will be m-oldbibtex.mkiv) @@ -540,13 +537,13 @@ \loadmkxlfile{publ-ini} \loadmkxlfile{publ-tra} \loadmkxlfile{publ-xml} -\loadmarkfile{publ-old} +\loadmkxlfile{publ-old} %loadmarkfile{x-xtag} % no longer preloaded -\loadmarkfile{meta-xml} +\loadmkxlfile{meta-xml} -\loadmarkfile{cont-log} +\loadmkxlfile{cont-log} \loadmkxlfile{cldf-ver} % verbatim, this can come late \loadmkxlfile{cldf-com} % commands, this can come late @@ -570,20 +567,20 @@ \loadmkxlfile{mlib-pdf} \loadmkxlfile{mlib-pps} -\loadmarkfile{meta-pdf} -\loadmarkfile{meta-blb} +\loadmkxlfile{meta-pdf} +\loadmkxlfile{meta-blb} \loadmkxlfile{grph-epd} -\loadmarkfile{math-inc} % an experiment +\loadmkxlfile{math-inc} % an experiment \loadmkxlfile{publ-inc} % an experiment \loadmkxlfile{task-ini} -\loadmarkfile{syst-cmp} % compatibility stuff moved here +\loadmkxlfile{syst-cmp} % compatibility stuff moved here \loadmkxlfile{libs-ini} -\loadmarkfile{cont-run} % the main runner (used in cont-yes.mkiv) +\loadmkxlfile{cont-run} % the main runner (used in cont-yes.mkiv) \setupcurrentlanguage[\defaultlanguagetag] diff --git a/tex/context/base/mkiv/core-con.mkxl b/tex/context/base/mkxl/core-con.mkxl index 088a118f2..3601dc630 100644 --- a/tex/context/base/mkiv/core-con.mkxl +++ b/tex/context/base/mkxl/core-con.mkxl @@ -568,11 +568,8 @@ % checkedconversion(method,n,language) -\protected\def\defineconversion - {\dotripleempty\syst_converters_define_conversion} - -\def\syst_converters_define_conversion[#1][#2][#3]% from now on global (maybe local again some day) - {\ifthirdargument +\permanent\tolerant\protected\def\defineconversion[#1]#*[#2]#*[#3]% from now on global (maybe local again some day) + {\ifparameter#3\or \syst_converters_define_conversion_indeed{#1#2}{#1:#2}{#3}% \else \syst_converters_define_conversion_indeed{#1}{#1}{#2}% @@ -598,7 +595,7 @@ 3\fi\fi \endcsname{#1}{\number#2}} -\protected\def\uconvertnumber % unexpandable +\permanent\protected\def\uconvertnumber % unexpandable {\convertnumber} \setvalue{\??conversionarguments1}#1{\csname\??conversion\currentlanguage#1\endcsname} diff --git a/tex/context/base/mkiv/core-ctx.mkxl b/tex/context/base/mkxl/core-ctx.mkxl index 77fb0f139..8837640d4 100644 --- a/tex/context/base/mkiv/core-ctx.mkxl +++ b/tex/context/base/mkxl/core-ctx.mkxl @@ -19,11 +19,11 @@ % called directly in core-def.mkiv % -% \unexpanded\def\job_options_get_commandline {\clf_setdocumentcommandline} -% \unexpanded\def\job_options_get_ctxfile {\clf_setdocumentctxfile} -% \unexpanded\def\job_options_set_modes {\clf_setdocumentmodes} -% \unexpanded\def\job_options_set_modules {\clf_setdocumentmodules} -% \unexpanded\def\job_options_set_environments{\clf_setdocumentenvironments} -% \unexpanded\def\job_options_set_filenames {\clf_setdocumentfilenames} +% \protected\def\job_options_get_commandline {\clf_setdocumentcommandline} +% \protected\def\job_options_get_ctxfile {\clf_setdocumentctxfile} +% \protected\def\job_options_set_modes {\clf_setdocumentmodes} +% \protected\def\job_options_set_modules {\clf_setdocumentmodules} +% \protected\def\job_options_set_environments{\clf_setdocumentenvironments} +% \protected\def\job_options_set_filenames {\clf_setdocumentfilenames} \protect \endinput diff --git a/tex/context/base/mkiv/core-dat.mkxl b/tex/context/base/mkxl/core-dat.mkxl index 7360a4e46..7360a4e46 100644 --- a/tex/context/base/mkiv/core-dat.mkxl +++ b/tex/context/base/mkxl/core-dat.mkxl diff --git a/tex/context/base/mkiv/core-def.mkxl b/tex/context/base/mkxl/core-def.mkxl index a413b8738..c7baf9ab1 100644 --- a/tex/context/base/mkiv/core-def.mkxl +++ b/tex/context/base/mkxl/core-def.mkxl @@ -149,7 +149,7 @@ % temporary here: \pushoverloadmode - \frozen\unexpanded\def\arg{\mathortext\normalmatharg\normaltextarg} + \frozen\protected\def\arg{\mathortext\normalmatharg\normaltextarg} \popoverloadmode % might move to \everydump or even disappear: diff --git a/tex/context/base/mkiv/core-env.lmt b/tex/context/base/mkxl/core-env.lmt index 388e96787..388e96787 100644 --- a/tex/context/base/mkiv/core-env.lmt +++ b/tex/context/base/mkxl/core-env.lmt diff --git a/tex/context/base/mkiv/core-env.mkxl b/tex/context/base/mkxl/core-env.mkxl index e1a96b35f..ccb5b665e 100644 --- a/tex/context/base/mkiv/core-env.mkxl +++ b/tex/context/base/mkxl/core-env.mkxl @@ -79,13 +79,13 @@ \mutable\let\syst_mode_prefix\relax -\protected\def\preventmode{\unprotect\syst_modes_prevent} -\protected\def\enablemode {\unprotect\syst_modes_enable } -\protected\def\disablemode{\unprotect\syst_modes_disable} +\permanent\protected\def\preventmode{\unprotect\syst_modes_prevent} +\permanent\protected\def\enablemode {\unprotect\syst_modes_enable } +\permanent\protected\def\disablemode{\unprotect\syst_modes_disable} -\protected\def\globalpreventmode{\let\syst_mode_prefix\global\unprotect\syst_modes_prevent} -\protected\def\globalenablemode {\let\syst_mode_prefix\global\unprotect\syst_modes_enable } -\protected\def\globaldisablemode{\let\syst_mode_prefix\global\unprotect\syst_modes_disable} +\permanent\protected\def\globalpreventmode{\let\syst_mode_prefix\global\unprotect\syst_modes_prevent} +\permanent\protected\def\globalenablemode {\let\syst_mode_prefix\global\unprotect\syst_modes_enable } +\permanent\protected\def\globaldisablemode{\let\syst_mode_prefix\global\unprotect\syst_modes_disable} \def\syst_modes_prevent[#1]{\protect\fastprocesscommacommand[#1]\syst_modes_prevent_indeed\let\syst_mode_prefix\relax} \def\syst_modes_enable [#1]{\protect\fastprocesscommacommand[#1]\syst_modes_enable_indeed \let\syst_mode_prefix\relax} @@ -138,7 +138,7 @@ % handy for mp -\def\booleanmodevalue#1% +\permanent\def\booleanmodevalue#1% {\ifcsname\??mode#1\endcsname \ifcase\lastnamedcs \s!false @@ -515,11 +515,11 @@ \permanent\protected\def\startlocalsetups{\begingroup\doifelsenextoptionalcs\syst_setups_start_loc_yes\syst_setups_start_loc_nop} \aliased\let\stoplocalsetups\relax \permanent\protected\def\startsetups {\begingroup\doifelsenextoptionalcs\syst_setups_start_tex_yes\syst_setups_start_tex_nop} \aliased\let\stopsetups \relax -\def\syst_setups_start_lua_two#1#2#+\stopluasetups {\endgroup\dodoglobal\defcsname\??setup#1:#2\endcsname##1{#3}} -\def\syst_setups_start_xml_two#1#2#+\stopxmlsetups {\endgroup\dodoglobal\defcsname\??setup#1:#2\endcsname##1{#3}} -\def\syst_setups_start_raw_two#1#2#+\stoprawsetups {\endgroup\dodoglobal\defcsname\??setup#1:#2\endcsname##1{#3}} -\def\syst_setups_start_loc_two#1#2#+\stoplocalsetups{\endgroup\dodoglobal\defcsname\??setup#1:#2\endcsname##1{#3}} -\def\syst_setups_start_tex_two#1#2#+\stopsetups {\endgroup\dodoglobal\defcsname\??setup#1:#2\endcsname##1{#3}} +\def\syst_setups_start_lua_two#1#2#+\stopluasetups {\endgroup\dodoglobal\instance\defcsname\??setup#1:#2\endcsname##1{#3}} +\def\syst_setups_start_xml_two#1#2#+\stopxmlsetups {\endgroup\dodoglobal\instance\defcsname\??setup#1:#2\endcsname##1{#3}} +\def\syst_setups_start_raw_two#1#2#+\stoprawsetups {\endgroup\dodoglobal\instance\defcsname\??setup#1:#2\endcsname##1{#3}} +\def\syst_setups_start_loc_two#1#2#+\stoplocalsetups{\endgroup\dodoglobal\instance\defcsname\??setup#1:#2\endcsname##1{#3}} +\def\syst_setups_start_tex_two#1#2#+\stopsetups {\endgroup\dodoglobal\instance\defcsname\??setup#1:#2\endcsname##1{#3}} \tolerant\def\syst_setups_start_lua_yes[#1]#*[#2]% {\the\t_syst_setups_lua @@ -568,7 +568,7 @@ \def\syst_setups_start_loc_one#1#2{\syst_setups_start_loc_two{}{#1}} % [..] \def\syst_setups_start_tex_one#1#2{\syst_setups_start_tex_two{}{#1}} % [..] -\def\luasetup#1{\ctxlua{\syst_setups{#1}}} +\permanent\def\luasetup#1{\ctxlua{\syst_setups{#1}}} %D System setups: @@ -620,10 +620,10 @@ \getvariable{#2}\s!set \popmacro\currentvariableclass}} -\permanent\protected\def\setvariable #1#2#3{\defcsname \??variables#1:#2\endcsname{#3}} -\permanent\protected\def\setevariable#1#2#3{\edefcsname \??variables#1:#2\endcsname{#3}} -\permanent\protected\def\setgvariable#1#2#3{\global\defcsname \??variables#1:#2\endcsname{#3}} -\permanent\protected\def\setxvariable#1#2#3{\global\edefcsname\??variables#1:#2\endcsname{#3}} +\permanent\protected\def\setvariable #1#2#3{\defcsname \??variables#1:#2\endcsname{#3}} +\permanent\protected\def\setevariable#1#2#3{\edefcsname\??variables#1:#2\endcsname{#3}} +\permanent\protected\def\setgvariable#1#2#3{\defcsname \??variables#1:#2\endcsname{#3}} +\permanent\protected\def\setxvariable#1#2#3{\xdefcsname\??variables#1:#2\endcsname{#3}} \permanent \def\getvariable #1#2{\begincsname\??variables#1:#2\endcsname} \permanent\protected\def\showvariable#1#2{\showvalue{\begincsname\??variables#1:#2\endcsname}} diff --git a/tex/context/base/mkiv/core-ini.mkxl b/tex/context/base/mkxl/core-ini.mkxl index 2e32e9bdd..94a0faeb9 100644 --- a/tex/context/base/mkiv/core-ini.mkxl +++ b/tex/context/base/mkxl/core-ini.mkxl @@ -62,7 +62,7 @@ \newtoks \everysimplifycommands \newtoks \everypreroll -\let\simplifiedcommands\everysimplifycommands % backward compatible, will stay as it's used in styles +\aliased\let\simplifiedcommands\everysimplifycommands % backward compatible, will stay as it's used in styles \newconditional\simplifyingcommands % public @@ -144,8 +144,8 @@ \newtoks\everystarttextproperties \newtoks\everystoptextproperties -\unexpanded\def\starttextproperties{\the\everystarttextproperties} -\unexpanded\def\stoptextproperties {\the\everystoptextproperties} +\permanent\protected\def\starttextproperties{\the\everystarttextproperties} +\permanent\protected\def\stoptextproperties {\the\everystoptextproperties} %D \macros %D {trialtypesetting} @@ -203,9 +203,9 @@ \boxedcontenttrue \to \everyboxedcontent -\unexpanded\def\startboxedcontent{\bgroup\the\everyboxedcontent} +\permanent\protected\def\startboxedcontent{\bgroup\the\everyboxedcontent} -\let\stopboxedcontent\egroup +\aliased\let\stopboxedcontent\egroup %D We store some original meanings, maybe in \type {math-ini}. diff --git a/tex/context/base/mkiv/core-lmt.lmt b/tex/context/base/mkxl/core-lmt.lmt index ccbdcc0df..ccbdcc0df 100644 --- a/tex/context/base/mkiv/core-lmt.lmt +++ b/tex/context/base/mkxl/core-lmt.lmt diff --git a/tex/context/base/mkiv/core-lmt.mkxl b/tex/context/base/mkxl/core-lmt.mkxl index 77ef17966..77ef17966 100644 --- a/tex/context/base/mkiv/core-lmt.mkxl +++ b/tex/context/base/mkxl/core-lmt.mkxl diff --git a/tex/context/base/mkiv/core-sys.lmt b/tex/context/base/mkxl/core-sys.lmt index 12f001e37..12f001e37 100644 --- a/tex/context/base/mkiv/core-sys.lmt +++ b/tex/context/base/mkxl/core-sys.lmt diff --git a/tex/context/base/mkiv/core-sys.mkxl b/tex/context/base/mkxl/core-sys.mkxl index c0280033f..bcf216c0a 100644 --- a/tex/context/base/mkiv/core-sys.mkxl +++ b/tex/context/base/mkxl/core-sys.mkxl @@ -226,7 +226,7 @@ % \definestartstop[tracing][\c!style=\tt] % \protected\def\ignorestartstop[#1]% -% {\protected\expandafter\def\csname\e!start#1\expandafter\endcsname\expandafter +% {\protected\defcsname\e!start#1\expandafter\endcsname\expandafter % {\expandafter\gobbleuntil\csname\e!stop#1\endcsname}} % % \ignorestartstop[bagger] @@ -236,12 +236,11 @@ \installcommandhandler \??highlight {highlight} \??highlight % we could do with less \setuphighlight - [\c!command=\v!yes] + [\c!define=\v!yes] \appendtoks - \edef\p_command{\highlightparameter\c!command}% - \ifx\p_command\v!yes - \frozen\setuevalue\currenthighlight{\typo_highlights_indeed{\currenthighlight}}% + \ifcstok{\highlightparameter\c!define}\v!yes + \frozen\instance\setuevalue\currenthighlight{\typo_highlights_indeed{\currenthighlight}}% \fi \to \everydefinehighlight diff --git a/tex/context/base/mkiv/core-two.mkxl b/tex/context/base/mkxl/core-two.mkxl index 0299e76f5..0299e76f5 100644 --- a/tex/context/base/mkiv/core-two.mkxl +++ b/tex/context/base/mkxl/core-two.mkxl diff --git a/tex/context/base/mkxl/core-uti.lua b/tex/context/base/mkxl/core-uti.lua new file mode 100644 index 000000000..60cf3d6a9 --- /dev/null +++ b/tex/context/base/mkxl/core-uti.lua @@ -0,0 +1,470 @@ +if not modules then modules = { } end modules ['core-uti'] = { + version = 1.001, + comment = "companion to core-uti.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- todo: keep track of changes here (hm, track access, and only true when +-- accessed and changed) + +--[[ldx-- +<p>A utility file has always been part of <l n='context'/> and with +the move to <l n='luatex'/> we also moved a lot of multi-pass info +to a <l n='lua'/> table. Instead of loading a <l n='tex'/> based +utility file under different setups, we now load a table once. This +saves much runtime but at the cost of more memory usage.</p> +--ldx]]-- + +local math = math +local format, match = string.format, string.match +local next, type, tostring, tonumber = next, type, tostring, tonumber +local concat = table.concat + +local definetable = utilities.tables.definetable +local accesstable = utilities.tables.accesstable +local migratetable = utilities.tables.migratetable +local serialize = table.serialize +local packers = utilities.packers +local allocate = utilities.storage.allocate +local mark = utilities.storage.mark + +local getrandom = utilities.randomizer.get +local setrandomseedi = utilities.randomizer.setseedi +local getrandomseed = utilities.randomizer.getseed + +local implement = interfaces.implement + +local texgetcount = tex.getcount + +local report_passes = logs.reporter("job","passes") + +job = job or { } +local job = job + +job.version = 1.31 +job.packversion = 1.02 + +-- some day we will implement loading of other jobs and then we need +-- job.jobs + +--[[ldx-- +<p>Variables are saved using in the previously defined table and passed +onto <l n='tex'/> using the following method. Of course one can also +directly access the variable using a <l n='lua'/> call.</p> +--ldx]]-- + +local savelist, comment = { }, { } + +function job.comment(key,value) + if type(key) == "table" then + for k, v in next, key do + comment[k] = v + end + else + comment[key] = value + end +end + +job.comment("version",job.version) + +local enabled = true +local initialized = false + +directives.register("job.save",function(v) enabled = v end) + +function job.disablesave() + enabled = false -- for instance called when an error +end + +function job.initialize(loadname,savename) + if not initialized then + if not loadname or loadname == "" then + loadname = tex.jobname .. ".tuc" + end + if not savename or savename == "" then + savename = tex.jobname .. ".tua" + end + job.load(loadname) -- has to come after structure is defined ! + luatex.registerstopactions(function() + if enabled then + job.save(savename) + end + end) + initialized = true + end +end + +function job.register(collected, tobesaved, initializer, finalizer, serializer) + savelist[#savelist+1] = { collected, tobesaved, initializer, finalizer, serializer } +end + +-- as an example we implement variables + +local tobesaved, collected, checksums = allocate(), allocate(), allocate() + +local jobvariables = { + collected = collected, + tobesaved = tobesaved, + checksums = checksums, +} + +-- if not checksums.old then checksums.old = md5.HEX("old") end -- used in experiment +-- if not checksums.new then checksums.new = md5.HEX("new") end -- used in experiment + +job.variables = jobvariables + +local function initializer() + checksums = jobvariables.checksums +end + +job.register('job.variables.checksums', 'job.variables.checksums', initializer) + +local rmethod, rvalue +local collectedmacros, tobesavedmacros + +local ctx_setxvalue = context.setxvalue + +local function initializer() + tobesaved = jobvariables.tobesaved + collected = jobvariables.collected + -- + rvalue = collected.randomseed + if not rvalue then + rvalue = getrandom("initialize") + setrandomseedi(rvalue) + rmethod = "initialized" + else + setrandomseedi(rvalue) + rmethod = "resumed" + end + tobesaved.randomseed = rvalue + -- + collectedmacros = collected.macros + tobesavedmacros = tobesaved.macros + if not collectedmacros then + collectedmacros = { } + collected.macros = collectedmacros + end + if not tobesavedmacros then + tobesavedmacros = { } + tobesaved.macros = tobesavedmacros + end + -- will become collected.macros + for cs, value in next, collectedmacros do + if type(value) == "string" then -- safeguard + ctx_setxvalue(cs,value) + end + end +end + +job.register('job.variables.collected', tobesaved, initializer) + +function jobvariables.save(cs,value) + tobesavedmacros[cs] = value +end + +function jobvariables.restore(cs) + return collectedmacros[cs] or tobesavedmacros[cs] +end + +function job.getrandomseed() + return tobesaved.randomseed or getrandomseed() +end + +-- checksums + +function jobvariables.getchecksum(tag) + return checksums[tag] -- no default +end + +function jobvariables.makechecksum(data) + return data and md5.HEX(data) -- no default +end + +function jobvariables.setchecksum(tag,checksum) + checksums[tag] = checksum +end + +-- + +local packlist = { + "numbers", + "ownnumbers", + "metadata", + "sectiondata", + "prefixdata", + "numberdata", + "pagedata", + "directives", + "specification", + "processors", -- might become key under directives or metadata +-- "references", -- we need to rename of them as only one packs (not structures.lists.references) +} + +local skiplist = { + "datasets", + "userdata", + "positions", +} + +-- not ok as we can have arbitrary keys in userdata and dataset so some day we +-- might need a bit more granularity, like skippers + +local jobpacker = packers.new(packlist,job.packversion,skiplist) -- jump number when changs in hash + +job.pack = true +-- job.pack = false + +directives.register("job.pack",function(v) job.pack = v end) + +local _save_, _load_, _others_ = { }, { }, { } -- registers timing + +function job.save(filename) -- we could return a table but it can get pretty large + statistics.starttiming(_save_) + local f = io.open(filename,'w') + if f then + f:write("local utilitydata = { }\n\n") + f:write(serialize(comment,"utilitydata.comment",true),"\n\n") + for l=1,#savelist do + -- f:write("do\n\n") -- no solution for the jit limitatione either + local list = savelist[l] + local target = format("utilitydata.%s",list[1]) + local data = list[2] + local finalizer = list[4] + local serializer = list[5] + if type(data) == "string" then + data = utilities.tables.accesstable(data) + end + if type(finalizer) == "function" then + finalizer() + end + if job.pack then + packers.pack(data,jobpacker,true) + end + local definer, name = definetable(target,true,true) -- no first and no last + if serializer then + f:write(definer,"\n\n",serializer(data,name,true),"\n\n") + else + f:write(definer,"\n\n",serialize(data,name,true),"\n\n") + end + -- f:write("end\n\n") + end + if job.pack then + packers.strip(jobpacker) + -- f:write("do\n\n") + f:write(serialize(jobpacker,"utilitydata.job.packed",true),"\n\n") + -- f:write("end\n\n") + end + f:write("return utilitydata") + f:close() + end + statistics.stoptiming(_save_) +end + +local function load(filename) + if lfs.isfile(filename) then + + local function dofile(filename) + local result = loadstring(io.loaddata(filename)) + if result then + return result() + else + return nil + end + end + + local okay, data = pcall(dofile,filename) + if okay and type(data) == "table" then + local jobversion = job.version + local datacomment = data.comment + local dataversion = datacomment and datacomment.version or "?" + if dataversion ~= jobversion then + report_passes("version mismatch: %s <> %s",dataversion,jobversion) + else + return data + end + else + os.remove(filename) -- probably a bad file (or luajit overflow as it cannot handle large tables well) + report_passes("removing stale job data file %a, restart job, message: %s%s",filename,tostring(data), + jit and " (try luatex instead of luajittex)" or "") + os.exit(true) -- trigger second run + end + end +end + +function job.load(filename) + statistics.starttiming(_load_) + local utilitydata = load(filename) + if utilitydata then + local jobpacker = utilitydata.job.packed + local handlers = { } + for i=1,#savelist do + local list = savelist[i] + local target = list[1] + local initializer = list[3] + local result = accesstable(target,utilitydata) + if result then + local done = packers.unpack(result,jobpacker,true) + if done then + migratetable(target,mark(result)) + if type(initializer) == "function" then + handlers[#handlers+1] = { initializer, result } + end + else + report_passes("pack version mismatch") + end + end + end + -- so we have all tables available (unpacked) + for i=1,#handlers do + local handler = handlers[i] + handler[1](handler[2]) + end + end + statistics.stoptiming(_load_) +end + +function job.loadother(filename) + statistics.starttiming(_load_) + _others_[#_others_+1] = file.nameonly(filename) + local utilitydata = load(filename) + if utilitydata then + local jobpacker = utilitydata.job.packed + local unpacked = { } + for l=1,#savelist do + local list = savelist[l] + local target = list[1] + local result = accesstable(target,utilitydata) + local done = packers.unpack(result,jobpacker,true) + if done then + migratetable(target,result,unpacked) + end + end + unpacked.job.packed = nil -- nicer in inspecting + return unpacked + end + statistics.stoptiming(_load_) +end + +-- function job.keep(filename) +-- local suffix = file.suffix(filename) +-- local base = file.removesuffix(filename) +-- if suffix == "" then +-- suffix = "tuc" +-- end +-- for i=1,10 do +-- local tmpname = format("%s-%s-%02d.tmp",base,suffix,i) +-- if lfs.isfile(tmpname) then +-- os.remove(tmpname) +-- report_passes("removing %a",tmpname) +-- end +-- end +-- if lfs.isfile(filename) then +-- local tmpname = format("%s-%s-%02d.tmp",base,suffix,environment.currentrun or 1) +-- report_passes("copying %a into %a",filename,tmpname) +-- file.copy(filename,tmpname) +-- else +-- report_passes("no file %a, nothing kept",filename) +-- end +-- end + +-- eventually this will end up in strc-ini + +statistics.register("startup time", function() + return statistics.elapsedseconds(statistics,"including runtime option file processing") +end) + +statistics.register("jobdata time",function() + if enabled then + if #_others_ > 0 then + return format("%s seconds saving, %s seconds loading, other files: %s",statistics.elapsedtime(_save_),statistics.elapsedtime(_load_),concat(_others_," ")) + else + return format("%s seconds saving, %s seconds loading",statistics.elapsedtime(_save_),statistics.elapsedtime(_load_)) + end + else + if #_others_ > 0 then + return format("nothing saved, %s seconds loading, other files: %s",statistics.elapsedtime(_load_),concat(_others_," ")) + else + return format("nothing saved, %s seconds loading",statistics.elapsedtime(_load_)) + end + end +end) + +statistics.register("callbacks", function() + local c_internal = status.callbacks or 0 + local c_file = status.indirect_callbacks or 0 + local c_direct = status.direct_callbacks or 0 + local c_late = backends.getcallbackstate().count + local c_function = status.function_callbacks or 0 + local c_total = c_internal + c_file + c_direct + c_late + c_function + local n_pages = structures.pages.nofpages or 0 + local c_average = n_pages > 0 and math.round(c_total/n_pages) or 0 + local result = format ( + "internal: %s, file: %s, direct: %s, late: %s, function %s, total: %s (%s per page)", + c_internal, c_file, c_direct, c_late, c_function, c_total, c_average + ) + statistics.callbacks = function() + return result + end + return result +end) + +statistics.register("randomizer", function() + if rmethod and rvalue then + return format("%s with value %s",rmethod,rvalue) + end +end) + +-- a sort of joke (for ctx meeting) + +-- local kg_per_watt_per_second = 1 / 15000000 +-- local watts_per_core = 50 +-- local speedup_by_other_engine = 1.2 +-- local used_wood_factor = watts_per_core * kg_per_watt_per_second / speedup_by_other_engine +-- local used_wood_factor = (50 / 15000000) / 1.2 + + +function statistics.formatruntime(runtime) + if not environment.initex then -- else error when testing as not counters yet + -- stoptiming(statistics) -- to be sure + local shipped = texgetcount('nofshipouts') + local pages = texgetcount('realpageno') + if pages > shipped then + pages = shipped + end + runtime = tonumber(runtime) + if shipped > 0 or pages > 0 then + local persecond = (runtime > 0) and (shipped/runtime) or pages + if pages == 0 then + pages = shipped + end + return format("%0.3f seconds, %i processed pages, %i shipped pages, %.3f pages/second",runtime,pages,shipped,persecond) + else + return format("%0.3f seconds",runtime) + end + end +end + +implement { + name = "savevariable", + actions = job.variables.save, + arguments = "2 strings", +} + +implement { + name = "setjobcomment", + actions = job.comment, + arguments = { { "*" } } +} + +implement { + name = "initializejob", + actions = job.initialize +} + +implement { + name = "disablejobsave", + actions = job.disablesave +} diff --git a/tex/context/base/mkiv/core-uti.mkxl b/tex/context/base/mkxl/core-uti.mkxl index b8d3bf7eb..b8d3bf7eb 100644 --- a/tex/context/base/mkiv/core-uti.mkxl +++ b/tex/context/base/mkxl/core-uti.mkxl diff --git a/tex/context/base/mkiv/driv-ini.mkxl b/tex/context/base/mkxl/driv-ini.mkxl index 9f489a2a1..9f489a2a1 100644 --- a/tex/context/base/mkiv/driv-ini.mkxl +++ b/tex/context/base/mkxl/driv-ini.mkxl diff --git a/tex/context/base/mkiv/driv-shp.lmt b/tex/context/base/mkxl/driv-shp.lmt index 8e3a936bb..8e3a936bb 100644 --- a/tex/context/base/mkiv/driv-shp.lmt +++ b/tex/context/base/mkxl/driv-shp.lmt diff --git a/tex/context/base/mkiv/driv-shp.mkxl b/tex/context/base/mkxl/driv-shp.mkxl index 199215a59..199215a59 100644 --- a/tex/context/base/mkiv/driv-shp.mkxl +++ b/tex/context/base/mkxl/driv-shp.mkxl diff --git a/tex/context/base/mkiv/enco-ini.mkxl b/tex/context/base/mkxl/enco-ini.mkxl index 104b2f890..1f8a121d5 100644 --- a/tex/context/base/mkiv/enco-ini.mkxl +++ b/tex/context/base/mkxl/enco-ini.mkxl @@ -11,14 +11,14 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D This is stripped down version of th eoriginal enco-ini.tex file. For more details +%D This is stripped down version of the original enco-ini.tex file. For more details %D you might want to study the \MKII\ file but since \LUATEX\ is unicode inside we %D need less code. %D Much in here will disappear in \LMTX\ because we assume proper \UNICODE\ usage. % When dealing with characters we have four cases to take into account when moving -% from mkii to mkiv: +% from \MKII\ to \MKIV: % 1. <byte 200> => ref to slot 200 in current font % 2. \char 200 => ref to slot 200 in current font @@ -40,12 +40,12 @@ %D Obsolete (but sometimes used in styles) -\let\defaultencoding\s!default +\immutable\let\defaultencoding\s!default %D \macros %D {defineaccent, definecharacter, definecommand} %D -%D Some of these are used at the \LUA\ end! +%D Some of these are used at the \LUA\ end but the names will change. \installcorenamespace{accents} @@ -97,18 +97,16 @@ % \buildtextaccent\greekdasia\greekalphamacron % \buildtextaccent\textacute q -%D We can use offsets in \LMTX\ but even that makes n o sense because we have +%D We can use offsets in \LMTX\ but even that makes no sense because we have %D a virtual feature already in \MKIV. -%D We define them frozen so that we can overload them. - \newbox\b_enco_accent \permanent\protected\def\buildmathaccent#1% {\mathaccent#1 } \permanent\protected\def\buildtextaccent#1#2% we could do all at the lua end - {\dontleavehmode\begingroup % but that's no fun (yet) + {\dontleavehmode\begingroup % but that's no fun (yet) \setbox\scratchboxone\hbox{#1}% accent \setbox\scratchboxtwo\hbox{#2}% character \scratchheight\dimexpr\ht\scratchboxtwo-\ht\scratchboxone\relax @@ -196,22 +194,22 @@ % \aliased\let\P\paragraphmark \aliased\let\textP\paragraphmark % obsolete (surfaced in bibliographic files) % \aliased\let\S\sectionmark \aliased\let\textS\sectionmark % obsolete (surfaced in bibliographic files) -\permanent\def\eszett {ß} \permanent\def\Eszett {SS} \permanent\def\Ssharp{SS} -\permanent\def\lslash {ł} \permanent\def\Lslash {Ł} -\permanent\def\dslash {đ} \permanent\def\Dslash {Đ} -%permanent\def\oslash {ø} %permanent\def\Oslash {Ø} % clashes with math: use \Ostroke -\permanent\def\dcroat {đ} \permanent\def\Dcroat {Đ} -\permanent\def\kcedilla{ķ} \permanent\def\Kcedilla{Ķ} -\permanent\def\lcedilla{ļ} \permanent\def\Lcedilla{Ļ} -\permanent\def\ncedilla{ņ} \permanent\def\Ncedilla{Ņ} -\permanent\def\rcedilla{ŗ} \permanent\def\Rcedilla{Ŗ} -\permanent\def\aumlaut {ä} \permanent\def\Aumlaut {Ä} -\permanent\def\eumlaut {ë} \permanent\def\Eumlaut {Ë} -\permanent\def\iumlaut {ï} \permanent\def\Iumlaut {Ï} -\permanent\def\oumlaut {ö} \permanent\def\Oumlaut {Ö} -\permanent\def\uumlaut {ü} \permanent\def\Uumlaut {Ü} - -% from enco-com: +\immutable\def\eszett {ß} \immutable\def\Eszett {SS} \permanent\def\Ssharp{SS} +\immutable\def\lslash {ł} \immutable\def\Lslash {Ł} +\immutable\def\dslash {đ} \immutable\def\Dslash {Đ} +%immutable\def\oslash {ø} %immutable\def\Oslash {Ø} % clashes with math: use \Ostroke +\immutable\def\dcroat {đ} \immutable\def\Dcroat {Đ} +\immutable\def\kcedilla{ķ} \immutable\def\Kcedilla{Ķ} +\immutable\def\lcedilla{ļ} \immutable\def\Lcedilla{Ļ} +\immutable\def\ncedilla{ņ} \immutable\def\Ncedilla{Ņ} +\immutable\def\rcedilla{ŗ} \immutable\def\Rcedilla{Ŗ} +\immutable\def\aumlaut {ä} \immutable\def\Aumlaut {Ä} +\immutable\def\eumlaut {ë} \immutable\def\Eumlaut {Ë} +\immutable\def\iumlaut {ï} \immutable\def\Iumlaut {Ï} +\immutable\def\oumlaut {ö} \immutable\def\Oumlaut {Ö} +\immutable\def\uumlaut {ü} \immutable\def\Uumlaut {Ü} + +% From \type {enco-com} we had these: % \aliased\let\AE\AEligature \aliased\let\ae\aeligature % \aliased\let\OE\OEligature \aliased\let\oe\oeligature @@ -222,38 +220,26 @@ % \aliased\let\O \Oslash \aliased\let\o \oslash % \aliased\let\SZ\Eszett \aliased\let\sz\eszett % \aliased\let\SS\Ssharp -% for old times sake (obsolete) +%D For old times sake we keep these (obsolete): -\def\textflorin{ƒ} \def\florin {ƒ} -\def\pound {£} \def\sterling{£} -\def\promille {‰} \def\permille{‰} +\immutable\def\textflorin{ƒ} \immutable\def\florin {ƒ} +\immutable\def\pound {£} \immutable\def\sterling{£} +\immutable\def\promille {‰} \immutable\def\permille{‰} -% tex specific +%D These are kind of \TEX\ specific \pushoverloadmode -%D Was missing: - \permanent\protected\def\ampersand{\mathortext\mathampersand\textampersand} - -\ifdefined\textpercent - \permanent\let\percent \textpercent - \permanent\let\procent \textpercent - %\permanent\let\ampersand \textampersand - \permanent\let\dollar \textdollar - \permanent\let\hash \texthash -\else - \permanent\def\percent {\textpercent} - \permanent\def\procent {\textpercent} - %\permanent\def\ampersand {\textampersand} - \permanent\def\dollar {\textdollar} - \permanent\def\hash {\texthash} -\fi +\immutable\let\percent\textpercent +\immutable\let\procent\textpercent +\immutable\let\dollar \textdollar +\immutable\let\hash \texthash \popoverloadmode -% from enco-mis: +%D These come from the \MKII\ file \type {enco-mis}: \permanent\protected\def\fakepercent {\mathematics{\normalsuperscript{\scriptscriptstyle0}\kern-.25\emwidth/\kern-.2\emwidth\normalsubscript{\scriptscriptstyle0}}} @@ -274,51 +260,54 @@ \def\permine{\fakepermine} -% some more: what with freezing here? +%D some more: what with freezing here? \ifdefined\softhyphen \else \aliased\let\softhyphen\explicitdiscretionary \fi -\def\hyphen {\softhyphen} -\def\compoundwordmark {\hyphen} -\def\cwm {\hyphen} -\def\nonbreakinghyphen{\hyphen} -\def\breakinghyphen {\hyphen\prewordbreak} +%D The softhyhen is never used but we keep the definition below: + +\aliased\let\hyphen \softhyphen % never used + +% But we ditch these: -% quotes +% \def\hyphen {\softhyphen} % never used +% \def\compoundwordmark {\hyphen} +% \def\cwm {\hyphen} +% \def\nonbreakinghyphen{\hyphen} +% \def\breakinghyphen {\hyphen\prewordbreak} -\def\lowerleftsingleninequote {\quotesinglebase} -\def\lowerleftdoubleninequote {\quotedblbase} -\def\lowerrightsingleninequote {\quotesinglebase} -\def\lowerrightdoubleninequote {\quotedblbase} +%D Quotes \unknown\ we keep these funny names because they indicate where we come +%D from \unknown\ long long ago when we had no real useful names for them. Some +%D ancient styles might still use them. -\def\upperleftsingleninequote {\quoteright} -\def\upperleftdoubleninequote {\quotedblright} -\def\upperrightsingleninequote {\quoteright} -\def\upperrightdoubleninequote {\quotedblright} +\aliased\let\lowerleftsingleninequote \quotesinglebase +\aliased\let\lowerleftdoubleninequote \quotedblbase +\aliased\let\lowerrightsingleninequote\quotesinglebase +\aliased\let\lowerrightdoubleninequote\quotedblbase -\def\upperleftsinglesixquote {\quoteleft} -\def\upperleftdoublesixquote {\quotedblleft} -\def\upperrightsinglesixquote {\quoteleft} -\def\upperrightdoublesixquote {\quotedblleft} +\aliased\let\upperleftsingleninequote \quoteright +\aliased\let\upperleftdoubleninequote \quotedblright +\aliased\let\upperrightsingleninequote\quoteright +\aliased\let\upperrightdoubleninequote\quotedblright -\def\leftsubguillemot {\guilsingleleft} -\def\rightsubguillemot {\guilsingleright} +\aliased\let\upperleftsinglesixquote \quoteleft +\aliased\let\upperleftdoublesixquote \quotedblleft +\aliased\let\upperrightsinglesixquote \quoteleft +\aliased\let\upperrightdoublesixquote \quotedblleft -% left-overs (some day in private unicode space, so that we can roundtrip) +\aliased\let\leftsubguillemot \guilsingleleft +\aliased\let\rightsubguillemot \guilsingleright + +% Some left-overs that wil go away! \permanent\protected\def\textblacksquare{\dontleavehmode\hbox{\vrule\s!width.3\s!em\s!height.4\s!em\s!depth-.1\s!em}} %permanent\protected\def\schwa {\hbox{\rotate[\c!rotation=180,\c!location=\v!high]{\hbox{e}}}} \permanent\protected\def\schwagrave {\buildtextgrave\schwa} -\chardef\textcontrolspace"2423 - \installcorenamespace{controlspace} -% \protected\def\fallbackcontrolspace % beware: non-matching widths -% {\hbox to \interwordspace{\hss\getglyph{LMTypewriter-Regular}\textcontrolspace\hss}% - \permanent\protected\def\fallbackcontrolspace % beware, current font, we also need to honor color {\hbox to \interwordspace \bgroup \hss @@ -334,47 +323,26 @@ \protected\def\enco_fast_control_space_define {\scratchdimen\interwordspace \definedfont[LMTypewriter-Regular at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody]% see font-sym.mkiv - \global\letcsname\??controlspace\number\scratchdimen\endcsname\lastrawfontcall} + \gletcsname\??controlspace\number\scratchdimen\endcsname\lastrawfontcall} \permanent\protected\def\normalcontrolspace - {\iffontchar\font\textcontrolspace + %{\iffontchar\font\numexpr\expandafter`\textcontrolspace\relax + {\iffontchar\font\textcontrolspace % in luametatex we also accept a char \textcontrolspace \else \fallbackcontrolspace \fi} -\let\textvisiblespace\normalcontrolspace +\aliased\let\textvisiblespace\normalcontrolspace \permanent\protected\def\optionalcontrolspace - {\iffontchar\font\textcontrolspace + %{\iffontchar\font\numexpr\expandafter`\textcontrolspace\relax + {\iffontchar\font\textcontrolspace % in luametatex we also accept a char \textcontrolspace \else \asciispacechar % used for export ! \fi} -% \protected\def\fastcontrolspace % no glyph resolving after first (use grouped) -% {\enco_fast_control_space} -% -% \def\enco_fast_control_space -% {\iffontchar\font\textcontrolspace -% \enco_fast_control_space_nop -% \else -% \enco_fast_control_space_yes -% \fi -% \enco_fast_control_space} -% -% \newbox\b_enco_control_space -% -% \def\enco_fast_control_space_nop -% {\let\enco_fast_control_space\textcontrolspace} -% -% \def\enco_fast_control_space_yes -% {\setbox\b_enco_control_space\fallbackcontrolspace -% \let\enco_fast_control_space\flushcontrolspacebox} -% -% \def\flushcontrolspacebox -% {\copy\b_enco_control_space} - % a few defaults (\<whatever>{}), we really need the verbose \empty as it will be % stringified .. anyhow, we define this at the lua end now but keep it here as a % reference @@ -404,8 +372,8 @@ \dontleavehmode\hbox{\vrule\s!depth .12\fontexheight\font\s!width \fontinterwordspace\font\s!height\zeropoint}% \fi} -\permanent\protected\def\fakeunderscores{\let\_\fakeunderscore} -\permanent\protected\def\textunderscores{\let\_\textunderscore} +\permanent\protected\def\fakeunderscores{\enforced\let\_\fakeunderscore} +\permanent\protected\def\textunderscores{\enforced\let\_\textunderscore} \textunderscores @@ -438,34 +406,6 @@ \permanent\protected\def\inch {\mathematics{\prime\prime}} % was: \hbox{\rm\char125\relax} \permanent\protected\def\fraction#1#2{\mathematics{#1\over#2}} -% \def\periodswidth {.5em} -% \def\periodsdefault{3} % was 5, but now it's like \unknown -% -% \protected\def\periods -% {\dosingleempty\enco_periods} -% -% \def\doperiods[#1]% todo: also n=,width= or maybe just #1,#2 -% {\dontleavehmode -% \begingroup -% \scratchdimen\periodswidth -% \hbox to \iffirstargument#1\else\periodsdefault\fi \scratchdimen -% {\leaders\hbox to \scratchdimen{\hss\periodsymbol\hss}\hss}% -% \endgroup} -% -% better for export: -% -% \protected\def\enco_periods[#1]% todo: also n=,width= or maybe just #1,#2 -% {\dontleavehmode -% \hbox\bgroup -% \setbox\scratchbox\hbox to \periodswidth{\hss\periodsymbol\hss}% -% \dorecurse{\iffirstargument#1\else\periodsdefault\fi}{\copy\scratchbox}% -% \egroup} -% -% \protected\def\unknown -% {\periods\relax} % relax prevents lookahead for [] -% -% per request: - %D \startbuffer %D \startlines %D x\periods x diff --git a/tex/context/base/mkiv/file-ini.mklx b/tex/context/base/mkxl/file-ini.mklx index a410854a8..66d03b2f9 100644 --- a/tex/context/base/mkiv/file-ini.mklx +++ b/tex/context/base/mkxl/file-ini.mklx @@ -94,14 +94,14 @@ \newtoks \everystartreadingfile \newtoks \everystopreadingfile -\protected\def\startreadingfile% beter een every en \setnormalcatcodes +\permanent\protected\def\startreadingfile% beter een every en \setnormalcatcodes {\global\advance\readingfilelevel\plusone \the\everystartreadingfile \pushcatcodetable % saveguard \setcatcodetable\ctxcatcodes \clf_pushregime}% temporarily this way -\protected\def\stopreadingfile +\permanent\protected\def\stopreadingfile {\popcatcodetable % saveguard \clf_popregime % temporarily this way \the\everystopreadingfile @@ -178,15 +178,15 @@ %D %D \start \typebuffer \getbuffer \stop -\newconstant\kindoffile % 0=normal 1=full path spec (or http) / set at the lua end +\newconstant\kindoffile % 0=normal 1=full path spec (or http) / set at the lua end +\newconstant\splitoffkind -\def\splitoffroot{.} \newconstant\splitoffkind - -\let\splitofffull\empty -\let\splitoffpath\empty -\let\splitoffbase\empty -\let\splitoffname\empty -\let\splitofftype\empty +\mutable\def\splitoffroot{.} +\mutable\let\splitofffull\empty +\mutable\let\splitoffpath\empty +\mutable\let\splitoffbase\empty +\mutable\let\splitoffname\empty +\mutable\let\splitofftype\empty \permanent\protected\def\splitfilename{\clf_splitfilename} diff --git a/tex/context/base/mkiv/file-job.lmt b/tex/context/base/mkxl/file-job.lmt index 95ad48e82..95ad48e82 100644 --- a/tex/context/base/mkiv/file-job.lmt +++ b/tex/context/base/mkxl/file-job.lmt diff --git a/tex/context/base/mkiv/file-job.mklx b/tex/context/base/mkxl/file-job.mklx index 6e8f8e83f..b455b1770 100644 --- a/tex/context/base/mkiv/file-job.mklx +++ b/tex/context/base/mkxl/file-job.mklx @@ -47,7 +47,8 @@ \mutable\let\locatedfilepath\empty -\protected\def\locatefilepath#name{\edef\locatedfilepath{\clf_locatefilepath{#name}}} % todo: set at the lua end, catcodes and such +\permanent\protected\def\locatefilepath#name% + {\edef\locatedfilepath{\clf_locatefilepath{#name}}} % todo: set at the lua end, catcodes and such % % maybe: % @@ -113,8 +114,8 @@ \newtoks\everystartnotext \newtoks\everystopnotext -\protected\def\startnotext{\the\everystartnotext} -\protected\def\stopnotext {\the\everystopnotext\normalend} +\permanent\protected\def\startnotext{\the\everystartnotext} +\permanent\protected\def\stopnotext {\the\everystopnotext\normalend} % protect structure @@ -310,8 +311,8 @@ \ifx\empty\currentdocument\else\resetmode\currentdocument\fi \popmacro\currentdocument} -\aliased \let\documentvariable \documentparameter -\aliased\protected\def\unexpandeddocumentvariable{\documentparameter} +\aliased \let\documentvariable \documentparameter +\permanent\protected\def\unexpandeddocumentvariable{\documentparameter} \permanent\protected\def\doifelsedocumentvariable#name{\doifelsesomething{\documentvariable{#name}}} \permanent\protected\def\doifdocumentvariable #name{\doifsomething {\documentvariable{#name}}} diff --git a/tex/context/base/mkiv/file-lib.mkxl b/tex/context/base/mkxl/file-lib.mkxl index c2ec555cf..c2ec555cf 100644 --- a/tex/context/base/mkiv/file-lib.mkxl +++ b/tex/context/base/mkxl/file-lib.mkxl diff --git a/tex/context/base/mkiv/file-mod.mklx b/tex/context/base/mkxl/file-mod.mklx index bf9b948bf..5e9cd0159 100644 --- a/tex/context/base/mkiv/file-mod.mklx +++ b/tex/context/base/mkxl/file-mod.mklx @@ -261,12 +261,12 @@ \permanent\protected\def\installmodulecommandluasingle#1#2{\enforced\permanent\protected\def#1{\normalexpanded{\syst_modules_single_lua{\csstring#1}{#2}}}} \permanent\protected\def\installmodulecommandluadouble#1#2{\enforced\permanent\protected\def#1{\normalexpanded{\syst_modules_double_lua{\csstring#1}{#2}}}} -\unexpanded\def\syst_modules_one_lua#1#2#3% +\protected\def\syst_modules_one_lua#1#2#3% {\directsetup{module:#1:start}% \ctxlua{#2(\!!bs#3\!!es)}% \directsetup{module:#1:stop}} -\unexpanded\def\syst_modules_two_lua#1#2#3#4% +\protected\def\syst_modules_two_lua#1#2#3#4% {\directsetup{module:#1:start}% \ctxlua{#2(\!!bs#3\!!es,\!!bs#4\!!es)}% \directsetup{module:#1:stop}} @@ -274,16 +274,4 @@ \permanent\protected\def\installmodulecommandluaone#1#2{\enforced\permanent\protected\def#1{\normalexpanded{\syst_modules_one_lua{\csstring#1}{#2}}}} \permanent\protected\def\installmodulecommandluatwo#1#2{\enforced\permanent\protected\def#1{\normalexpanded{\syst_modules_two_lua{\csstring#1}{#2}}}} -% obsolete -% -% \def\documentresources{\@@erurl} -% -% \unexpanded\def\setupexternalresources -% {\dodoubleargument\getparameters[\??er]} -% -% \setupexternalresources -% [url=] - -% new: - \protect \endinput diff --git a/tex/context/base/mkiv/file-res.mklx b/tex/context/base/mkxl/file-res.mklx index a523302d1..a523302d1 100644 --- a/tex/context/base/mkiv/file-res.mklx +++ b/tex/context/base/mkxl/file-res.mklx diff --git a/tex/context/base/mkiv/file-syn.mklx b/tex/context/base/mkxl/file-syn.mklx index 25f36f742..25f36f742 100644 --- a/tex/context/base/mkiv/file-syn.mklx +++ b/tex/context/base/mkxl/file-syn.mklx diff --git a/tex/context/base/mkiv/font-aux.mklx b/tex/context/base/mkxl/font-aux.mklx index caf32510e..caf32510e 100644 --- a/tex/context/base/mkiv/font-aux.mklx +++ b/tex/context/base/mkxl/font-aux.mklx diff --git a/tex/context/base/mkiv/font-chk.mkxl b/tex/context/base/mkxl/font-chk.mkxl index b84056e4e..b84056e4e 100644 --- a/tex/context/base/mkiv/font-chk.mkxl +++ b/tex/context/base/mkxl/font-chk.mkxl diff --git a/tex/context/base/mkiv/font-col.mklx b/tex/context/base/mkxl/font-col.mklx index 1dd5b25c6..1dd5b25c6 100644 --- a/tex/context/base/mkiv/font-col.mklx +++ b/tex/context/base/mkxl/font-col.mklx diff --git a/tex/context/base/mkiv/font-emp.mklx b/tex/context/base/mkxl/font-emp.mklx index da993a82c..33104a6d7 100644 --- a/tex/context/base/mkiv/font-emp.mklx +++ b/tex/context/base/mkxl/font-emp.mklx @@ -87,11 +87,11 @@ \ifx\fontalternative\s!bi \bf \else \emphasistypeface \fi} -\let\typeface \normaltypeface % public -\let\boldface \normalboldface % public -\let\slantedface\normalslantedface % public -\let\italicface \normalitalicface % public -\let\swapface \swaptypeface % public +\aliased\let\typeface \normaltypeface % public +\aliased\let\boldface \normalboldface % public +\aliased\let\slantedface\normalslantedface % public +\aliased\let\italicface \normalitalicface % public +\aliased\let\swapface \swaptypeface % public %D To be set with the default body font environment: \type {em} being \type %D {slanted} or \type {italic}. diff --git a/tex/context/base/mkiv/font-fea.mklx b/tex/context/base/mkxl/font-fea.mklx index 5f83c87d3..5f83c87d3 100644 --- a/tex/context/base/mkiv/font-fea.mklx +++ b/tex/context/base/mkxl/font-fea.mklx diff --git a/tex/context/base/mkiv/font-fil.mklx b/tex/context/base/mkxl/font-fil.mklx index 7f618179c..08c9241aa 100644 --- a/tex/context/base/mkiv/font-fil.mklx +++ b/tex/context/base/mkxl/font-fil.mklx @@ -88,7 +88,7 @@ {\letcsname\??fontfile\fontclass\m_font_name\endcsname\m_font_file \doifelsenextoptionalcs\font_basics_define_font_synonym_yes_opt\font_basics_define_font_synonym_yes_nil} -\protected\def\edefinefontsynonym[#name]#spacer[#file]% +\permanent\protected\def\edefinefontsynonym[#name]#spacer[#file]% {\edef\m_font_name{#name}% \edef\m_font_file{#file}% \ifempty\fontclass @@ -158,10 +158,10 @@ \letcsname\??fontfile\m_font_name\s!designsize\endcsname\undefined} \def\font_basics_define_font_synonym_yes_nil - {\global\letcsname\??fontfile\fontclass\m_font_name\s!features \endcsname\undefined - \global\letcsname\??fontfile\fontclass\m_font_name\s!fallbacks \endcsname\undefined - \global\letcsname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\undefined - \global\letcsname\??fontfile\fontclass\m_font_name\s!designsize\endcsname\undefined} + {\gletcsname\??fontfile\fontclass\m_font_name\s!features \endcsname\undefined + \gletcsname\??fontfile\fontclass\m_font_name\s!fallbacks \endcsname\undefined + \gletcsname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\undefined + \gletcsname\??fontfile\fontclass\m_font_name\s!designsize\endcsname\undefined} \def\font_basics_get_font_parameter_nop_finish {\letcsname\??fontfile\m_font_name\s!features \endcsname\p_features @@ -170,10 +170,10 @@ \letcsname\??fontfile\m_font_name\s!designsize\endcsname\p_designsize} \def\font_basics_get_font_parameter_yes_finish - {\global\letcsname\??fontfile\fontclass\m_font_name\s!features \endcsname\p_features - \global\letcsname\??fontfile\fontclass\m_font_name\s!fallbacks \endcsname\p_fallbacks - \global\letcsname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\p_goodies - \global\letcsname\??fontfile\fontclass\m_font_name\s!designsize\endcsname\p_designsize} + {\gletcsname\??fontfile\fontclass\m_font_name\s!features \endcsname\p_features + \gletcsname\??fontfile\fontclass\m_font_name\s!fallbacks \endcsname\p_fallbacks + \gletcsname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\p_goodies + \gletcsname\??fontfile\fontclass\m_font_name\s!designsize\endcsname\p_designsize} %\definefontsynonym [KopFont] [\fontclassname{officina}{SerifBold}] %\defineclassfontsynonym [KopFont] [officina] [SerifBold] @@ -371,12 +371,12 @@ % we can pack them (don't use \setxvalue!) \permanent\protected\def\savefontclassparameters#style#rscale#features#fallbacks#goodies#designsize#direction% - {\global\letcsname\??fontclass\fontclass#style\s!rscale \endcsname#rscale% - \global\letcsname\??fontclass\fontclass#style\s!features \endcsname#features% - \global\letcsname\??fontclass\fontclass#style\s!fallbacks \endcsname#fallbacks% - \global\letcsname\??fontclass\fontclass#style\s!goodies \endcsname#goodies% - \global\letcsname\??fontclass\fontclass#style\s!designsize\endcsname#designsize% - \global\letcsname\??fontclass\fontclass#style\s!direction \endcsname#direction}% math + {\gletcsname\??fontclass\fontclass#style\s!rscale \endcsname#rscale% + \gletcsname\??fontclass\fontclass#style\s!features \endcsname#features% + \gletcsname\??fontclass\fontclass#style\s!fallbacks \endcsname#fallbacks% + \gletcsname\??fontclass\fontclass#style\s!goodies \endcsname#goodies% + \gletcsname\??fontclass\fontclass#style\s!designsize\endcsname#designsize% + \gletcsname\??fontclass\fontclass#style\s!direction \endcsname#direction}% math % bonus diff --git a/tex/context/base/mkxl/font-gds.mklx b/tex/context/base/mkxl/font-gds.mklx new file mode 100644 index 000000000..897478273 --- /dev/null +++ b/tex/context/base/mkxl/font-gds.mklx @@ -0,0 +1,97 @@ +%D \module +%D [ file=font-gds, +%D version=2009.10.14, +%D title=\CONTEXT\ Font Support, +%D subtitle=Colorschemes, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Font Support / Colorschemes} + +%registerctxluafile{font-gds}{} + +\unprotect + +% this will become colorgroups and move to font-col or so + +\definecolor[colorscheme:1:1][s=.75] +\definecolor[colorscheme:1:2][r=.75] +\definecolor[colorscheme:1:3][g=.75] +\definecolor[colorscheme:1:4][b=.75] +\definecolor[colorscheme:1:5][c=.75] +\definecolor[colorscheme:1:6][m=.75] +\definecolor[colorscheme:1:7][y=.75] + +\definecolor[colorscheme:2:7][s=.75] +\definecolor[colorscheme:2:6][r=.75] +\definecolor[colorscheme:2:5][g=.75] +\definecolor[colorscheme:2:4][b=.75] +\definecolor[colorscheme:2:3][c=.75] +\definecolor[colorscheme:2:2][m=.75] +\definecolor[colorscheme:2:1][y=.75] + +\definecolor[colorscheme:3:1][r=.75] +\definecolor[colorscheme:3:2][g=.75] +\definecolor[colorscheme:3:3][b=.75] +\definecolor[colorscheme:3:4][g=.75,b=.75] +\definecolor[colorscheme:3:5][r=.75,b=.75] +\definecolor[colorscheme:3:6][r=.75,g=.75] +\definecolor[colorscheme:3:7][g=.75] + +\definecolor[colorscheme:4:1] [r=.6] % a +\definecolor[colorscheme:4:5] [g=.6] % e +\definecolor[colorscheme:4:9] [b=.6] % i +\definecolor[colorscheme:4:15][g=.6,b=.6] % o +\definecolor[colorscheme:4:21][r=.6,b=.6] % u +\definecolor[colorscheme:4:25][r=.6,b=.6] % y + +\definesystemattribute[colorscheme][public] + +\permanent\protected\def\loadfontgoodies[#filename]{\clf_loadfontgoodies{#filename}} % todo: public implementor + +\permanent\protected\def\setfontcolorscheme % will move to the lua end + {\clf_enablefontcolorschemes + \enforced\permanent\protected\xdef\setfontcolorscheme[##1]{\c_attr_colorscheme##1\relax}% + \setfontcolorscheme} + +\permanent\protected\def\resetfontcolorscheme + {\c_attr_colorscheme\attributeunsetvalue} + +\protect \endinput + +% \definefontfeature[husayni-colored][goodies=husayni,colorscheme=default,featureset=default] +% +% \definedfont[husayni*husayni-colored at 36pt] +% +% \starttext \righttoleft +% +% \setfontcolorscheme[1] +% +% اَلْحَمْدُ لِلّٰهِ حَمْدَ مُعْتَرِفٍ بِحَمْدِهٖ، مُغْتَرِفٌ مِنْ بِحَارِ +% مَجْدِهٖ، بِلِسَانِ ٱلثَّنَاۤءِ شَاكِرًا، وَلِحُسْنِ اٰلاۤئِهٖ نَاشِرًا؛ +% اَلَّذِيْ خَلَقَ ٱلْمَوْتَ وَٱلْحَيٰوةَ، وَٱلْخَيْرَ وَٱلشَّرَّ، +% وَٱلنَّفْعَ وَٱلضَّرَّ، وَٱلسُّكُوْنَ وَٱلْحَرَكَةَ، وَٱلْأَرْوَاحَ +% وَٱلْأَجْسَامَ، وَٱلذِّكْرَ وَٱلنِّسْيَانَ. +% +% \setfontcolorscheme[2] +% +% اَلْحَمْدُ لِلّٰهِ حَمْدَ مُعْتَرِفٍ بِحَمْدِهٖ، مُغْتَرِفٌ مِنْ بِحَارِ +% مَجْدِهٖ، بِلِسَانِ ٱلثَّنَاۤءِ شَاكِرًا، وَلِحُسْنِ اٰلاۤئِهٖ نَاشِرًا؛ +% اَلَّذِيْ خَلَقَ ٱلْمَوْتَ وَٱلْحَيٰوةَ، وَٱلْخَيْرَ وَٱلشَّرَّ، +% وَٱلنَّفْعَ وَٱلضَّرَّ، وَٱلسُّكُوْنَ وَٱلْحَرَكَةَ، وَٱلْأَرْوَاحَ +% وَٱلْأَجْسَامَ، وَٱلذِّكْرَ وَٱلنِّسْيَانَ. +% +% \resetfontcolorscheme +% +% اَلْحَمْدُ لِلّٰهِ حَمْدَ مُعْتَرِفٍ بِحَمْدِهٖ، مُغْتَرِفٌ مِنْ بِحَارِ +% مَجْدِهٖ، بِلِسَانِ ٱلثَّنَاۤءِ شَاكِرًا، وَلِحُسْنِ اٰلاۤئِهٖ نَاشِرًا؛ +% اَلَّذِيْ خَلَقَ ٱلْمَوْتَ وَٱلْحَيٰوةَ، وَٱلْخَيْرَ وَٱلشَّرَّ، +% وَٱلنَّفْعَ وَٱلضَّرَّ، وَٱلسُّكُوْنَ وَٱلْحَرَكَةَ، وَٱلْأَرْوَاحَ +% وَٱلْأَجْسَامَ، وَٱلذِّكْرَ وَٱلنِّسْيَانَ. +% +% \stoptext diff --git a/tex/context/base/mkiv/font-ini.mklx b/tex/context/base/mkxl/font-ini.mklx index 7bb7f832a..5d39001b1 100644 --- a/tex/context/base/mkiv/font-ini.mklx +++ b/tex/context/base/mkxl/font-ini.mklx @@ -410,7 +410,7 @@ \installcorenamespace{fontnormalizedbody} -\protected\def\normalizebodyfontsize#macro#body% +\permanent\protected\def\normalizebodyfontsize#macro#body% {\expandafter\let\expandafter#macro\csname\??fontnormalizedbody\number\dimexpr#body\endcsname \ifx#macro\relax \normalizebodyfontsize_indeed#macro{#body}% @@ -418,7 +418,7 @@ \def\normalizebodyfontsize_indeed#macro#body% {\edef#macro{\clf_nbfs\dimexpr#body\relax}% - \global\letcsname\??fontnormalizedbody\number\dimexpr#body\endcsname#macro} + \gletcsname\??fontnormalizedbody\number\dimexpr#body\endcsname#macro} \permanent\def\thenormalizedbodyfontsize#body% {\clf_nbfs\dimexpr#body\relax} @@ -668,15 +668,15 @@ \newcount\lastfontid % also used at the lua end / tex end \newtoks \everydefinefont -\let\relativefontid\minusone % todo, not yet used +\mutable\let\relativefontid\minusone -\let\c_font_feature_inheritance_fontnone \zerocount % none -\let\c_font_feature_inheritance_fontonly \plusone % fontonly -\let\c_font_feature_inheritance_classonly \plustwo % classonly -\let\c_font_feature_inheritance_fontfirst \plusthree % fontfirst -\let\c_font_feature_inheritance_classfirst\plusfour % classfirst +\aliased\let\c_font_feature_inheritance_fontnone \zerocount % none +\aliased\let\c_font_feature_inheritance_fontonly \plusone % fontonly +\aliased\let\c_font_feature_inheritance_classonly \plustwo % classonly +\aliased\let\c_font_feature_inheritance_fontfirst \plusthree % fontfirst +\aliased\let\c_font_feature_inheritance_classfirst\plusfour % classfirst -\let\c_font_feature_inheritance_default \c_font_feature_inheritance_fontfirst +\aliased\let\c_font_feature_inheritance_default \c_font_feature_inheritance_fontfirst \setnewconstant\c_font_feature_inheritance_mode \c_font_feature_inheritance_default @@ -1461,14 +1461,14 @@ \protected\def\font_basics_define_body_font_yes_xx[#one#two#rest=#value]% global {\ifcsname\m_font_asked_style#one#two#rest\endcsname\else\font_basics_check_fontname_combination\m_font_asked_style{#one#two}{#rest}\fi - \global\letcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-1\endcsname\undefined - \global\protected\edefcsname\??fontinstanceready\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-0\endcsname + \gletcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-1\endcsname\undefined + \protected\xdefcsname\??fontinstanceready\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-0\endcsname {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest-0}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}% - \global\letcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-2\endcsname\undefined - \global\protected\edefcsname\??fontinstanceready\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-4\endcsname + \gletcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-2\endcsname\undefined + \protected\xdefcsname\??fontinstanceready\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-4\endcsname {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest-4}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}% - \global\letcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-3\endcsname\undefined - \global\protected\edefcsname\??fontinstanceready\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-5\endcsname + \gletcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-3\endcsname\undefined + \protected\xdefcsname\??fontinstanceready\fontclass-\m_font_asked_body-\m_font_asked_style-#one#two-#rest-5\endcsname {\font_helpers_trigger{\m_font_asked_body-\m_font_asked_style-#one#two#rest-5}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}% } @@ -1482,7 +1482,7 @@ \letcsname\??fontinstanceclass\m_font_asked_body-\s!mm-#one#two#rest-1\endcsname\undefined % \letcsname\??fontinstanceclass\m_font_asked_body-\s!mm-#one#two#rest-2\endcsname\undefined % \letcsname\??fontinstanceclass\m_font_asked_body-\s!mm-#one#two#rest-3\endcsname\undefined - \global\protected\edefcsname\??fontinstanceready\m_font_asked_body-\s!mm-#one#two#rest\endcsname + \protected\xdefcsname\??fontinstanceready\m_font_asked_body-\s!mm-#one#two#rest\endcsname {\font_helpers_trigger{\m_font_asked_body-\s!mm-#one#two#rest}{\noexpand\font_rscale_mm}{\m_font_asked_body}{\normalunexpanded{#value}}}% } @@ -1490,10 +1490,10 @@ \protected\def\font_basics_define_body_font_yes_mm[#one#two#rest=#value]% global {%\ifcsname\s!mm\endcsname\else\font_basics_check_fontname_combination\s!mm{#one#two}{#rest}\fi - \global\letcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-1\endcsname\undefined - % \global\letcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-2\endcsname\undefined - % \global\letcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-3\endcsname\undefined - \global\protected\edefcsname\??fontinstanceready\fontclass-\m_font_asked_body-\s!mm-#one#two#rest\endcsname + \gletcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-1\endcsname\undefined + % \gletcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-2\endcsname\undefined + % \gletcsname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-3\endcsname\undefined + \protected\xdefcsname\??fontinstanceready\fontclass-\m_font_asked_body-\s!mm-#one#two#rest\endcsname {\font_helpers_trigger{\m_font_asked_body-\s!mm-#one#two#rest}{\number\p_font_rscale}{\m_font_asked_body}{\normalunexpanded{#value}}}% } @@ -1710,10 +1710,10 @@ \fi -\let\defaultfontstyle \s!rm -\let\defaultfontalternative\s!tf -\let\defaultfontsize \empty -\let\defaultfontface \!!zerocount +% \let\defaultfontstyle \s!rm +% \let\defaultfontalternative\s!tf +% \let\defaultfontsize \empty +% \let\defaultfontface \!!zerocount %D So far for synchronisation. (We can inline the following macros.) @@ -2109,7 +2109,7 @@ \enforced\noexpand\edef\noexpand\xtextface {\currentbodyfontdimension\s!x }% \enforced\noexpand\edef\noexpand\xxtextface {\currentbodyfontdimension\s!xx }% }% - \global\letcsname\??fontbodyfaces\fontbody\endcsname\font_basics_set_faces} + \gletcsname\??fontbodyfaces\fontbody\endcsname\font_basics_set_faces} \permanent\def\currentbodyfontdimension#parameter% there can be factors here {\the\dimexpr @@ -2428,7 +2428,7 @@ \protected\def\font_basics_predefine#1#2% {\font_basics_defined_font_yes[#2]% - \global\letcsname#1\expandafter\endcsname\csname\v_font_identifier_basic\endcsname} + \gletcsname#1\expandafter\endcsname\csname\v_font_identifier_basic\endcsname} \protected\def\font_basics_predefined#1% {\font_basics_predefine{\??predefinedfont#1}{#1}} diff --git a/tex/context/base/mkxl/font-lib.mklx b/tex/context/base/mkxl/font-lib.mklx new file mode 100644 index 000000000..4a0c1627f --- /dev/null +++ b/tex/context/base/mkxl/font-lib.mklx @@ -0,0 +1,170 @@ +%D \module +%D [ file=font-lib, +%D version=2011.01.13, % (copied fron font-ini) +%D title=\CONTEXT\ Font Macros, +%D subtitle=Libraries, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Font Macros / Libraries} + +\unprotect + +\registerctxluafile{font-ini}{} +\registerctxluafile{font-log}{} +\registerctxluafile{font-con}{} +\registerctxluafile{font-cft}{} +\registerctxluafile{font-enc}{} +\registerctxluafile{font-agl}{} % if needed we can comment this and delay loading +\registerctxluafile{font-cid}{} % cid maps +\registerctxluafile{font-map}{optimize} + +% helpers + +\registerctxluafile{font-otr}{optimize} % opentype fontloader +\registerctxluafile{font-web}{} % opentype fontloader +\registerctxluafile{font-cff}{optimize} % quadratic outlines +\registerctxluafile{font-ttf}{optimize} % cubic outlines +\registerctxluafile{font-dsp}{optimize} % ... for this one +\registerctxluafile{font-hsh}{} % hashes used by context +\registerctxluafile{font-vfc}{} +\registerctxluafile{font-prv}{} % needs hashes +\registerctxluafile{font-nod}{optimize} +\registerctxluafile{font-oti}{} % otf initialization +\registerctxluafile{font-ott}{} % otf tables (first) +\registerctxluafile{font-otl}{} +\registerctxluafile{font-oto}{} +\registerctxluafile{font-otj}{optimize} +\registerctxluafile{font-oup}{} +\registerctxluafile{font-ota}{} +\registerctxluafile{font-ots}{optimize} +\registerctxluafile{font-otd}{optimize} +\registerctxluafile{font-otc}{} +\registerctxluafile{font-oth}{} +\registerctxluafile{font-osd}{} +%registerctxluafile{font-osm}{} +\registerctxluafile{font-ogr}{autosuffix} + +% we use otf code for type one + +\registerctxluafile{font-onr}{optimize} +\registerctxluafile{font-one}{optimize} +\registerctxluafile{font-afk}{} + +% tfm + +\registerctxluafile{font-tpk}{optimize} +\registerctxluafile{font-tfm}{} + +% name database + +\registerctxluafile{font-syn}{} +\registerctxluafile{font-trt}{} + +% shapes + +\registerctxluafile{font-shp}{} + +% so far + +\registerctxluafile{font-pat}{} % patchers + +\registerctxluafile{node-fnt}{} % here + +\registerctxluafile{font-mps}{} % outline fun + +\registerctxluafile{font-lua}{} + +\registerctxluafile{font-vir}{} +\registerctxluafile{font-enh}{} + +\registerctxluafile{good-ini}{} +\registerctxluafile{good-gen}{} +\registerctxluafile{good-ctx}{} +\registerctxluafile{good-mth}{} + +\registerctxluafile{font-def}{} +\registerctxluafile{font-ctx}{} % after def as it overloads + +% extensions, order matters + +\registerctxluafile{font-imp-ligatures}{} +\registerctxluafile{font-imp-tex}{} +\registerctxluafile{font-imp-reorder}{} +\registerctxluafile{font-imp-properties}{} +\registerctxluafile{font-imp-unicode}{} +\registerctxluafile{font-imp-math}{} +\registerctxluafile{font-imp-notused}{} +\registerctxluafile{font-imp-effects}{} +\registerctxluafile{font-imp-quality}{} +\registerctxluafile{font-imp-italics}{} +\registerctxluafile{font-imp-dimensions}{} +\registerctxluafile{font-imp-spacekerns}{} +\registerctxluafile{font-imp-tweaks}{} +\registerctxluafile{font-imp-combining}{} + +\doifelsefileexists{font-imp-scripts.lua} { + \registerctxluafile{font-imp-scripts}{} +} { + % not yet, lmtx feature +} + +\registerctxluafile{font-imp-tracing}{} % comes last! + +\registerctxluafile{font-fbk}{} + +\registerctxluafile{font-aux}{} + +\registerctxluafile{font-lig}{} % only for experiments so try to avoid it + +%D Some low level helpers +%D +%D \starttyping +%D \def\TestLookup#specification% +%D {\dolookupfontbyspec{#specification} +%D pattern: #specification, found: \dolookupnoffound +%D \blank +%D \dorecurse {\dolookupnoffound} {% +%D \recurselevel:~\dolookupgetkeyofindex{fontname}{\recurselevel}\quad +%D }% +%D \blank} +%D +%D \TestLookup{familyname=helveticaneue} +%D \TestLookup{familyname=helveticaneue,weight=bold} +%D \TestLookup{familyname=helveticaneue,weight=bold,style=italic} +%D \stoptyping + +%D We can also move the lookups to the fonts.namespace (of commands) one can also +%D directly use the clf calls when speed is needed. + +% todo: public implementors: + +\permanent \def\dolookupfontbyspec #1{\clf_fontlookupinitialize{#1}} +\permanent \def\dolookupnoffound {\clf_fontlookupnoffound} +\permanent \def\dolookupgetkeyofindex#1#2{\clf_fontlookupgetkeyofindex{#1}\numexpr#2\relax} +\permanent \def\dolookupgetkey #1{\clf_fontlookupgetkey{#1}} +\permanent \def\cleanfontname #1{\clf_cleanfontname{#1}} +\permanent\protected\def\setfontofid #1{\clf_setfontofid\numexpr#1\relax} + +% this is an ugly hack needed for postponed inclusion stuff ... don't try +% to understand this ... these are kind of old mkiv solutions + +\permanent\protected\def\typethreefont#1{\setfontid#1\relax} +\permanent\protected\def\typethreechar#1{\char#1\hskip-\fontcharwd\font#1\relax} +\permanent\protected\def\typethreelast#1{\char#1\relax} +\permanent\protected\def\typethreecode#1{\pdfliteral direct {#1}} + +\newtoks\typethreetoks +\let \typethreemacro\empty + +\typethreetoks {% + \setbox\zerocount\hpack{\typethreemacro}% + \setbox\zerocount\hpack{\raise\dp\zerocount\box\zerocount}% +} + +\protect \endinput diff --git a/tex/context/base/mkiv/font-mat.mklx b/tex/context/base/mkxl/font-mat.mklx index 8ee5f4043..39e799ec3 100644 --- a/tex/context/base/mkiv/font-mat.mklx +++ b/tex/context/base/mkxl/font-mat.mklx @@ -54,13 +54,13 @@ % todo: \c_font_fam_mr -\let\c_font_fam_mr \zerocount % math regular -\let\c_font_fam_mr_lr\plusone % math regular l2r -\let\c_font_fam_mr_rl\plustwo % math regular r2l +\aliased\let\c_font_fam_mr \zerocount % math regular +\aliased\let\c_font_fam_mr_lr\plusone % math regular l2r +\aliased\let\c_font_fam_mr_rl\plustwo % math regular r2l -\let\c_font_fam_mb \plusthree % math bold -\let\c_font_fam_mb_lr\plusfour % math bold l2r -\let\c_font_fam_mb_rl\plusfive % math bold r2l +\aliased\let\c_font_fam_mb \plusthree % math bold +\aliased\let\c_font_fam_mb_lr\plusfour % math bold l2r +\aliased\let\c_font_fam_mb_rl\plusfive % math bold r2l \definesystemattribute[mathfamily][public] @@ -69,11 +69,9 @@ % \frozen ... -\def\mathtextsuffix {-text} -\def\mathscriptsuffix {-script} -\def\mathscriptscriptsuffix{-scriptscript} - -\def\mathsizesuffix{\ifcase\fontface\or\mathtextsuffix\or\mathscriptsuffix\or\mathscriptscriptsuffix\fi} +\immutable\def\mathtextsuffix {-text} +\immutable\def\mathscriptsuffix {-script} +\immutable\def\mathscriptscriptsuffix{-scriptscript} %D Beware: truefontname also does a fallback on defaultfontclass so there %D can be some interference here, which is why we use a different method @@ -103,7 +101,8 @@ \settrue \c_font_auto_size \fi} -\let\mathsizesuffix\empty +%def\mathsizesuffix{\ifcase\fontface\or\mathtextsuffix\or\mathscriptsuffix\or\mathscriptscriptsuffix\fi} +\mutable\let\mathsizesuffix\empty \def\font_helpers_set_math_family_indeed#mrtag#family% \fontface etc are also used later on {\let\savedfontbody\fontbody diff --git a/tex/context/base/mkiv/font-ogr.lmt b/tex/context/base/mkxl/font-ogr.lmt index e57e88ed6..e57e88ed6 100644 --- a/tex/context/base/mkiv/font-ogr.lmt +++ b/tex/context/base/mkxl/font-ogr.lmt diff --git a/tex/context/base/mkiv/font-pre.mkxl b/tex/context/base/mkxl/font-pre.mkxl index 8468fbbd7..8468fbbd7 100644 --- a/tex/context/base/mkiv/font-pre.mkxl +++ b/tex/context/base/mkxl/font-pre.mkxl diff --git a/tex/context/base/mkxl/font-sel.mklx b/tex/context/base/mkxl/font-sel.mklx new file mode 100644 index 000000000..6c9ab3d7e --- /dev/null +++ b/tex/context/base/mkxl/font-sel.mklx @@ -0,0 +1,276 @@ +%D \module +%D [ file=font-sel, +%D version=2016.08.28, +%D title=\CONTEXT\ User Module, +%D subtitle=Selectfont, +%D author=Wolfgang Schuster, +%D date=\currentdate, +%D copyright=Wolfgang Schuster, +%D license=GNU General Public License] + +\writestatus{loading}{ConTeXt User Module / Selectfont} + +\registerctxluafile{font-sel}{} + +\unprotect + +\installcorenamespace {selectfont} +\installsimplecommandhandler \??selectfont {selectfont} + +\protected\def\selectfont_register[#style][#settings]% + {\begingroup + \edef\currentselectfont{\expandnamespacevalue\??fontshortstyle{#style}\s!rm}% + \checkselectfontparent + \setupcurrentselectfont[#settings]% + \edef\p_selectfont_preset{\selectfontparameter\c!preset}% + \ifx\p_selectfont_preset\empty \else + \processcommacommand[\p_selectfont_preset]\selectfont_preset_process + \setupcurrentselectfont[#settings]% + \fi + \font_helpers_process_alternative_list\clf_registerfontalternative + \setexpandedselectfontparameter\c!style{\expandnamespaceparameter\??fontshortstyle\selectfontparameter\c!style\s!rm}% + \xdef\selectfont_index{\clf_registerfontfamily + metadata {% + typeface {\selectfontparameter\c!label}% + style {\selectfontparameter\c!style}% + family {\selectfontparameter\c!name}% + } + options {% + designsize {\selectfontparameter\s!designsize}% + rscale {\selectfontparameter\s!rscale}% + goodies {\selectfontparameter\c!goodies}% + extras {\selectfontparameter\c!extras}% + features {\selectfontparameter\c!features}% + preset {\selectfontparameter\c!preset}% + range {\selectfontparameter\c!range}% fallback only + offset {\selectfontparameter\c!offset}% fallback only + check {\selectfontparameter\c!check}% fallback only + force {\selectfontparameter\c!force}% fallback only + } + userdata {% + \luaexpanded{#settings}% + }}% + \endgroup} + +%D \macros +%D {definefontfamilypreset} + +\installcorenamespace {selectfontpreset} + +\permanent\tolerant\protected\def\definefontfamilypreset[#name]#spacer[#settings]% + {\setvalue{\??selectfontpreset#name}{\setupcurrentselectfont[#settings]}% + \clf_definefontfamilypreset{#name}{\luaexpanded{#settings}}} + +\def\selectfont_preset_process#name% + {\ifcsname\??selectfontpreset#name\endcsname + \lastnamedcs + \else + % unknown preset + \fi} + +\definefontfamilypreset + [range:chinese] + [\c!range={cjkcompatibilityforms, + cjkcompatibilityideographs, + cjkcompatibilityideographssupplement, + cjkradicalssupplement, + cjkstrokes, + cjksymbolsandpunctuation, + cjkunifiedideographs, + cjkunifiedideographsextensiona, + cjkunifiedideographsextensionb, + halfwidthandfullwidthforms, + verticalforms, + bopomofo, + bopomofoextended}] + +\definefontfamilypreset + [range:japanese] + [\c!range={cjkcompatibilityforms, + cjkcompatibilityideographs, + cjkcompatibilityideographssupplement, + cjkradicalssupplement, + cjkstrokes, + cjksymbolsandpunctuation, + cjkunifiedideographs, + cjkunifiedideographsextensiona, + cjkunifiedideographsextensionb, + halfwidthandfullwidthforms, + verticalforms, + hiragana, + katakana}] + +\definefontfamilypreset + [range:korean] + [\c!range={cjkcompatibilityforms, + cjkcompatibilityideographs, + cjkcompatibilityideographssupplement, + cjkradicalssupplement, + cjkstrokes, + cjksymbolsandpunctuation, + cjkunifiedideographs, + cjkunifiedideographsextensiona, + cjkunifiedideographsextensionb, + halfwidthandfullwidthforms, + verticalforms, + hangulcompatibilityjamo, + hanguljamo, + hanguljamoextendeda, + hanguljamoextendedb, + hangulsyllables}] + +\definefontfamilypreset + [range:cyrillic] + [\c!range={cyrillic, + cyrillicextendeda, + cyrillicextendedb, + cyrillicsupplement}] + +\definefontfamilypreset + [range:greek] + [\c!range={greekandcoptic, + greekextended, + ancientgreeknumbers}] + +\definefontfamilypreset + [range:hebrew] + [\c!range={hebrew, + alphabeticpresentationforms}] + +\definefontfamilypreset [math:digitsnormal] [\c!range=digitsnormal] +\definefontfamilypreset [math:digitsbold] [\c!range=digitsnormal,\c!offset=digitsbold,\s!tf=style:bold] + +\definefontfamilypreset [math:uppercasenormal] [\c!range=uppercasenormal] +\definefontfamilypreset [math:uppercaseitalic] [\c!range=uppercasenormal,\c!offset=uppercaseitalic, \s!tf=style:italic] +\definefontfamilypreset [math:uppercasebold] [\c!range=uppercasenormal,\c!offset=uppercasebold, \s!tf=style:bold] +\definefontfamilypreset [math:uppercasebolditalic] [\c!range=uppercasenormal,\c!offset=uppercasebolditalic,\s!tf=style:bolditalic] + +\definefontfamilypreset [math:lowercasenormal] [\c!range=lowercasenormal] +\definefontfamilypreset [math:lowercaseitalic] [\c!range=lowercasenormal,\c!offset=lowercaseitalic, \s!tf=style:italic] +\definefontfamilypreset [math:lowercasebold] [\c!range=lowercasenormal,\c!offset=lowercasebold, \s!tf=style:bold] +\definefontfamilypreset [math:lowercasebolditalic] [\c!range=lowercasenormal,\c!offset=lowercasebolditalic,\s!tf=style:bolditalic] + +\definefontfamilypreset [math:mathematicaloperators] [\c!range=mathematicaloperators] + +\definefontfamilypreset [math:lowercasegreeknormal] [\c!range=lowercasegreeknormal] +\definefontfamilypreset [math:lowercasegreekitalic] [\c!range=lowercasegreeknormal,\c!offset=lowercasegreekitalic, \s!tf=style:italic] +\definefontfamilypreset [math:lowercasegreekbold] [\c!range=lowercasegreeknormal,\c!offset=lowercasegreekbold, \s!tf=style:bold] +\definefontfamilypreset [math:lowercasegreekbolditalic] [\c!range=lowercasegreeknormal,\c!offset=lowercasegreekbolditalic,\s!tf=style:bolditalic] + +\definefontfamilypreset [math:uppercasegreeknormal] [\c!range=uppercasegreeknormal] +\definefontfamilypreset [math:uppercasegreekitalic] [\c!range=uppercasegreeknormal,\c!offset=uppercasegreekitalic, \s!tf=style:italic] +\definefontfamilypreset [math:uppercasegreekbold] [\c!range=uppercasegreeknormal,\c!offset=uppercasegreekbold, \s!tf=style:bold] +\definefontfamilypreset [math:uppercasegreekbolditalic] [\c!range=uppercasegreeknormal,\c!offset=uppercasegreekbolditalic,\s!tf=style:bolditalic] + +%D \macros +%D {definefontfamily,definefallbackfamily} +%D +%D The \tex{definefontfamily} creates like \tex{definetypeface} a collection of font +%D with different styles which can be later called with the \tex{setupbodyfont} command. +%D +%D The command takes three mandatory commands which are (a) the name of the fontclass, +%D (b) the styles of the font and (c) the name of the font. +%D +%D \starttyping +%D \definefontfamily [dejavu] [serif] [DejaVu Serif] +%D \definefontfamily [dejavu] [sans] [DejaVu Sans] +%D \definefontfamily [dejavu] [mono] [DejaVu Sans Mono] +%D \definefontfamily [dejavu] [math] [XITS Math] [rscale=1.1] +%D +%D \definefontfamily [office] [serif] [Times New Roman] +%D \definefontfamily [office] [sans] [Arial] [rscale=0.9] +%D \definefontfamily [office] [mono] [Courier] +%D \definefontfamily [office] [math] [TeX Gyre Termes Math] +%D +%D \definefontfamily [linux] [serif] [Linux Libertine O] +%D \definefontfamily [linux] [sans] [Linux Biolinum O] +%D \definefontfamily [linux] [mono] [Latin Modern Mono] +%D \definefontfamily [linux] [math] [TeX Gyre Pagella Math] [rscale=0.9] +%D +%D \setupbodyfont[dejavu] +%D +%D \starttext +%D +%D \rm Serif \ss Sans \tt Mono \m{1+2=3} +%D +%D \switchtobodyfont[office] +%D +%D \rm Serif 123 \ss Sans \tt Mono \m{1+2=3} +%D +%D \switchtobodyfont[linux] +%D +%D \rm Serif 123 \ss Sans \tt Mono \m{1+2=3} +%D +%D \stoptext +%D \stoptyping +%D +%D When a document contains different languages and the global font lacks some characters +%D for one language, one could set a different font where these charcters are taken from. +%D This fallback font (there can be more than one for a certain style) could be set with +%D the \tex{definefallbackfamily} command which takes the same argument as +%D the \tex{definefontfamily} command. +%D +%D \starttyping +%D \definefallbackfamily [mainface] [serif] [DejaVu Serif] [range=cyrillic] +%D \definefontfamily [mainface] [serif] [TeX Gyre Pagella] +%D +%D \setupbodyfont[mainface] +%D +%D \setuplanguage[en][patterns={us,ru}] +%D +%D \starttext +%D +%D \input knuth +%D +%D Традиционная систематика лишайников оказывается во многом условна и +%D +%D \stoptext +%D \stoptyping +%D +%D Another feature of the module is the \type{designsize} key which allows one to enable +%D optical sizes when they are a feature of the requested font. +%D +%D \starttyping +%D \definefontfamily[mainface][serif][Latin Modern Roman][designsize=auto] +%D +%D \setupbodyfont[mainface] +%D +%D \starttext +%D \scale[width=\textwidth]{\switchtobodyfont [6pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic} +%D \scale[width=\textwidth]{\switchtobodyfont [8pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic} +%D \scale[width=\textwidth]{\switchtobodyfont [10pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic} +%D \scale[width=\textwidth]{\switchtobodyfont [12pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic} +%D \scale[width=\textwidth]{\switchtobodyfont[17.3pt]\tf Regular, \it Italic \bf Bold and \bi BoldItalic} +%D \stoptext +%D \stoptyping + +% tf = … | * … | name:… | name:* … | file:… | file:* … | style:medium + +\permanent\tolerant\protected\def\definefontfamily[#typeface]#spacer[#style]#spacer[#family]#spacer[#settings]% + {\doifelseassignment{#settings} + {\selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},#settings]} + {\selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},\c!preset={#settings}]}% + \clf_definefontfamily\selectfont_index\relax} + +\permanent\tolerant\def\definefallbackfamily[#typeface]#spacer[#style]#spacer[#family]#spacer[#settings]% + {\doifelseassignment{#settings} + {\selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},#settings]} + {\selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},\c!preset={#settings}]}% + \clf_definefallbackfamily\selectfont_index\relax} + +\permanent\tolerant\protected\def\setupfontfamily[#style]#spacer[#settings]% + {\ifparameter#settings\or + \edef\currentselectfont{\expandnamespacevalue\??fontshortstyle{#style}\s!rm}% + \setupcurrentselectfont[#settings]% + \else + \let\currentselectfont\empty + \setupcurrentselectfont[#style]% + \fi} + +\setupselectfont + [ \c!features=\s!default, + \s!designsize=\s!default, + \s!rscale=\selectfontparameter\c!scale, + \c!scale=1] + +\protect diff --git a/tex/context/base/mkxl/font-set.mklx b/tex/context/base/mkxl/font-set.mklx new file mode 100644 index 000000000..03dc8bb32 --- /dev/null +++ b/tex/context/base/mkxl/font-set.mklx @@ -0,0 +1,159 @@ +%D \module +%D [ file=font-set, +%D version=2011.01.13, % (copied fron font-ini) +%D title=\CONTEXT\ Font Macros, +%D subtitle=Initial Loading, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Font Macros / Initial Loading} + +\unprotect + +%D Defining fonts using \type {\definebodyfont} takes time, so we prefer to +%D predefine at least the Computer Modern Roman fonts. However, loading all those +%D fonts at definition time would take both time and space. But even worse, once +%D fonts are loaded into memory, their encoding vector is fixed, which is a handicap +%D when we want to distribute the compact \type {fmt} files. So what we want to do +%D is defining fonts in a way that postpones the loading. We accomplish this by only +%D loading the fonts when we switch to another bodyfont size. Among the other +%D alternatives, such as loading the font at the moment of activation and redefining +%D the activation macro afterwards, this proved to be the most efficient +%D alternative. +%D +%D The next few macros take care of the one exeption on this scheme. When at format +%D generation time we load the default font file, the one that defines the Computer +%D Modern Fonts, we don't want the fonts metrics to end up in the format file, so we +%D temporary prohibit loading. This means that at runtime we have to load the +%D default bodyfont size just before we start typesetting. + +% \enablemode[lmmath] + +\let\m_font_fallback_name\empty + +% keep as reference: +% +% \def\font_preloads_reset_nullfont % this is needed because some macro packages (tikz) misuse \nullfont +% {\dorecurse\plusseven{\fontdimen\recurselevel\nullfont\zeropoint}% keep en eye on this as: +% \clf_resetnullfont % in luatex 0.70 this will also do the previous +% \glet\font_preloads_reset_nullfont\relax} + +\def\font_preload_check_mode + {\doifelsemode{lmmath} + {\def\m_font_fallback_name{modern-designsize-virtual}}% this will stay + {\def\m_font_fallback_name{modern-designsize}}% % this might become 'modern' + \glet\font_preload_check_mode\relax} + +\def\font_preload_default_fonts + {\font_preloads_reset + \font_preload_check_mode + \setupbodyfont[\m_font_fallback_name,\fontstyle,\fontbody]% + \showmessage\m!fonts6{fallback \m_font_fallback_name\space \fontstyle\normalspace\normalizedbodyfontsize}} + +\def\font_preload_default_fonts_mm + {\font_preload_check_mode + \writestatus\m!fonts{preloading \m_font_fallback_name\space (math)}% + \definetypeface[\fontclass][\s!mm][\s!math][\m_font_fallback_name][\s!default]% + \showmessage\m!fonts6{fallback \m_font_fallback_name\space mm \normalizedbodyfontsize}} + +\def\font_preload_default_fonts_tt + {\font_preload_check_mode + \writestatus\m!fonts{preloading \m_font_fallback_name\space (mono)}% + \definetypeface[\fontclass][\s!tt][\s!mono][\m_font_fallback_name][\s!default]% + \showmessage\m!fonts6{fallback \m_font_fallback_name\space tt \normalizedbodyfontsize}} + +\def\font_preloads_reset + {\glet\font_preload_default_fonts \relax + %\glet\font_preload_default_fonts_tt\relax + %\glet\font_preload_default_fonts_mm\relax + \glet\font_preloads_zero_stage \relax + \glet\font_preloads_first_stage \relax + \glet\font_preloads_second_stage \relax + %\glet\font_preloads_third_stage \relax + \glet\fourthstagepreloadfonts \relax + \global\everyhbox\emptytoks + \global\everyvbox\emptytoks + % old: \font_preloads_reset_nullfont, new: + \clf_resetnullfont} + +\appendtoks + \font_preloads_reset +\to \everystartnotext + +\def\font_preloads_reset_checked + {\glet\font_preload_default_fonts_tt\relax + \glet\font_preload_default_fonts_mm\relax + \glet\font_preloads_third_stage \relax +% \glet\font_preloads_fourth_stage \relax + } + +\def\font_preloads_zero_stage_indeed + {\definedfont[\s!file:lmmono10-regular sa 1]} + +\protected\def\font_preloads_zero_stage + {\writestatus\m!fonts{beware: no fonts are loaded yet, using 'lm mono' in box}% + \glet\font_preloads_zero_stage\font_preloads_zero_stage_indeed + \font_preloads_zero_stage} + +\protected\def\font_preloads_first_stage % % *nofonts -> *preloadfonts + {\doifelsemode{*preloadfonts} + {\font_preload_default_fonts + \writestatus\m!fonts{preloading latin modern fonts (first stage)}} + {\writestatus\m!fonts{latin modern fonts are not preloaded}}} + +\protected\def\font_preloads_second_stage + {\writestatus\m!fonts{preloading latin modern fonts (second stage)}% + \font_preload_default_fonts} + +\protected\def\font_preloads_third_stage % always + {\ifx\fontclass\empty + \writestatus\m!fonts{preloading latin modern fonts (third stage)}% + \font_preload_default_fonts + \font_preloads_reset + \else + \font_preloads_reset + \push_macro_fontstyle + \ifcsname\??fontclass\fontclass\s!mm\s!features\endcsname \else + \font_preload_default_fonts_mm + \fi + \ifcsname\??fontclass\fontclass\s!tt\s!features\endcsname \else + \font_preload_default_fonts_tt + \fi + \pop_macro_fontstyle + \font_preloads_reset_checked % reset third, mm and tt + \setupbodyfont[\fontstyle]% + \fi} + +\protected\def\font_preloads_fourth_stage + {\begingroup + %ifzeropt\fontcharwd\font\number`!\relax + \setbox\scratchbox\hpack{\tf c o n t e x t}% + \ifzeropt\wd\scratchbox + \writeline + \writestatus\m!fonts{!! No bodyfont has been defined and no defaults have been}% + \writestatus\m!fonts{!! loaded (maybe due to a missing \string\starttext).}% + \writeline + \fi + \font_preloads_reset + \endgroup} + +\appendtoks + \everyhbox{\font_preloads_zero_stage}% + \everyvbox{\font_preloads_zero_stage}% +\to \everydump + +\protected\def\font_preloads_at_every_job {\font_preloads_first_stage } +\protected\def\font_preloads_at_start_text{\font_preloads_second_stage} +\protected\def\font_preloads_at_stop_text {\font_preloads_fourth_stage} +\protected\def\font_preloads_at_definition{\font_preloads_third_stage + \glet\font_preloads_at_definition\relax} + +% \protected\def\checkpreloadedbodyfont % no \let here +% {\font_preloads_at_start_text} + +\protect \endinput diff --git a/tex/context/base/mkiv/font-sol.mklx b/tex/context/base/mkxl/font-sol.mklx index 8f3d3d712..8f3d3d712 100644 --- a/tex/context/base/mkiv/font-sol.mklx +++ b/tex/context/base/mkxl/font-sol.mklx diff --git a/tex/context/base/mkiv/font-sty.mklx b/tex/context/base/mkxl/font-sty.mklx index 0cb76eee9..9444232ba 100644 --- a/tex/context/base/mkiv/font-sty.mklx +++ b/tex/context/base/mkxl/font-sty.mklx @@ -62,7 +62,7 @@ \ifcsname#command\endcsname % no redefinition \orelse\ifnum\c_fonts_basics_alternative_style_method=\plusone - \ifthirdargument + \ifparameter#command\or \permanent\setuevalue{#command}{\triggergroupedcommandcs\begincsname\??alternativestyle#command\endcsname}% \else \permanent\setuvalue{#command}{\triggergroupedcommand{#variantone}}% @@ -309,7 +309,7 @@ \installcorenamespace{styleenvironment} -\protected\def\startstyle[#name]% +\permanent\protected\def\startstyle[#name]% {\begingroup \csname\??styleenvironment \ifcsname\??stylecheck#name\endcsname @@ -321,7 +321,7 @@ \fi \endcsname{#name}} -\protected\def\stopstyle +\permanent\protected\def\stopstyle {\endgroup \autoinsertnextspace} % will be configurable, maybe also in \definestartstop diff --git a/tex/context/base/mkiv/font-sym.mklx b/tex/context/base/mkxl/font-sym.mklx index d95314099..7f68d267e 100644 --- a/tex/context/base/mkiv/font-sym.mklx +++ b/tex/context/base/mkxl/font-sym.mklx @@ -116,7 +116,7 @@ \ifx\fontalternative\s!bs#yes\orelse \ifx\fontalternative\s!bi#yes\else#nop\fi} -\let\doifitalicelse\doifelseitalic +\aliased\let\doifitalicelse\doifelseitalic %D For an example of usage of the following command, see \type {cont-log.tex}. %D @@ -166,7 +166,7 @@ \def\font_basics_define_symbolic_font {\definefont[currentsymbolfont][\askedsymbolfont]% \currentsymbolfont - \global\letcsname\??symbolfont\askedsymbolfont\endcsname\lastrawfontcall} + \gletcsname\??symbolfont\askedsymbolfont\endcsname\lastrawfontcall} \permanent\protected\def\getnamedglyphstyled#fontname#character{{\setstyledsymbolicfont{#fontname}\clf_fontchar{#character}}} \permanent\protected\def\getnamedglyphdirect#fontname#character{{\setdirectsymbolicfont{#fontname}\clf_fontchar{#character}}} diff --git a/tex/context/base/mkiv/font-tra.mkxl b/tex/context/base/mkxl/font-tra.mkxl index 72addc5e9..72addc5e9 100644 --- a/tex/context/base/mkiv/font-tra.mkxl +++ b/tex/context/base/mkxl/font-tra.mkxl diff --git a/tex/context/base/mkxl/font-uni.mkxl b/tex/context/base/mkxl/font-uni.mkxl new file mode 100644 index 000000000..390f17468 --- /dev/null +++ b/tex/context/base/mkxl/font-uni.mkxl @@ -0,0 +1,27 @@ +%D \module +%D [ file=font-uni, +%D version=2008.11.03, % 1999.10.10, +%D title=\CONTEXT\ Font Macros, +%D subtitle=\UNICODE, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Font Macros / Unicode} + +%D In \MKIV\ we only provide the \type {\uchar} macro and implement it as just an +%D \UTF\ converter. We expand it so best not use not use it for active characters. +%D In practice this command is probably never used anyway but we keep if for old +%D styles. + +\unprotect + +\permanent\def\uchar#1#2{\clf_uchar\numexpr#1\relax\numexpr#2\relax} + +\aliased\let\uc\uchar + +\protect \endinput diff --git a/tex/context/base/mkxl/font-unk.mkxl b/tex/context/base/mkxl/font-unk.mkxl new file mode 100644 index 000000000..986a5c9bf --- /dev/null +++ b/tex/context/base/mkxl/font-unk.mkxl @@ -0,0 +1,150 @@ +%D \module +%D [ file=font-unk, +%D version=1998.09.10, +%D title=\CONTEXT\ Font Macros, +%D subtitle=Unknown Defaults, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D This module is rather important, because it enables us to define and call for not +%D yet defined fonts in a way completely independant of real font names. First we +%D map some meaningful names onto unknown filenames. + +\unprotect + +\definefontsynonym [Serif] [unknown] +\definefontsynonym [SerifBold] [unknown] +\definefontsynonym [SerifItalic] [unknown] +\definefontsynonym [SerifSlanted] [unknown] +\definefontsynonym [SerifBoldItalic] [unknown] +\definefontsynonym [SerifBoldSlanted] [unknown] +\definefontsynonym [SerifCaps] [unknown] + +\definefontsynonym [Sans] [unknown] +\definefontsynonym [SansBold] [unknown] +\definefontsynonym [SansItalic] [unknown] +\definefontsynonym [SansSlanted] [unknown] +\definefontsynonym [SansBoldItalic] [unknown] +\definefontsynonym [SansBoldSlanted] [unknown] +\definefontsynonym [SansCaps] [unknown] + +\definefontsynonym [Mono] [unknown] +\definefontsynonym [MonoBold] [unknown] +\definefontsynonym [MonoItalic] [unknown] +\definefontsynonym [MonoSlanted] [unknown] +\definefontsynonym [MonoBoldItalic] [unknown] +\definefontsynonym [MonoBoldSlanted] [unknown] +\definefontsynonym [MonoCaps] [unknown] + +\definefontsynonym [MathRoman] [unknown] +\definefontsynonym [MathRomanL2R] [MathRoman] +\definefontsynonym [MathRomanR2L] [MathRoman] +\definefontsynonym [MathRomanBold] [MathRoman] +\definefontsynonym [MathRomanBoldL2R] [MathRomanBold] +\definefontsynonym [MathRomanBoldR2L] [MathRomanBold] + +\definefontsynonym [Handwriting] [unknown] +\definefontsynonym [Calligraphic] [unknown] + +%D This permit us to define (use) fonts that refer to the default style (so, Bold +%D may expand to SansBold or SerifBold, depending on the default style in the +%D typeface). The \LUA\ call is used to set the current alternative in a +%D non|-|interfering way. This make sure that the CurrentFont synonym (in font-sym) +%D is working as expected (e.g.\ in MixedCaps). Yes, this is complicates stuff. + +\definefontsynonym[\s!Normal] [\noexpand\clf_tf\noexpand\v_font_string_d] +\definefontsynonym[\s!Bold] [\noexpand\clf_bf\noexpand\v_font_string_d\noexpand\s!Bold] +\definefontsynonym[\s!Italic] [\noexpand\clf_it\noexpand\v_font_string_d\noexpand\s!Italic] +\definefontsynonym[\s!Slanted] [\noexpand\clf_sl\noexpand\v_font_string_d\noexpand\s!Slanted] +\definefontsynonym[\s!BoldItalic] [\noexpand\clf_bi\noexpand\v_font_string_d\noexpand\s!BoldItalic] +\definefontsynonym[\s!BoldSlanted][\noexpand\clf_bs\noexpand\v_font_string_d\noexpand\s!BoldSlanted] +\definefontsynonym[\s!Caps] [\noexpand\clf_tf\noexpand\v_font_string_d\noexpand\s!Caps] + +%D Also handy: + +\definefontsynonym [Regular] [Serif] +\definefontsynonym [RegularBold] [SerifBold] +\definefontsynonym [RegularItalic] [SerifItalic] +\definefontsynonym [RegularSlanted] [SerifSlanted] +\definefontsynonym [RegularBoldItalic] [SerifBoldItalic] +\definefontsynonym [RegularBoldSlanted] [SerifBoldSlanted] +\definefontsynonym [RegularCaps] [SerifCaps] + +\definefontsynonym [Support] [Sans] +\definefontsynonym [SupportBold] [SansBold] +\definefontsynonym [SupportItalic] [SansItalic] +\definefontsynonym [SupportSlanted] [SansSlanted] +\definefontsynonym [SupportBoldItalic] [SansBoldItalic] +\definefontsynonym [SupportBoldSlanted] [SansBoldSlanted] +\definefontsynonym [SupportCaps] [SansCaps] + +%D Well, not that good an idea: + +\definefontsynonym [Roman] [Serif] +\definefontsynonym [RomanBold] [SerifBold] +\definefontsynonym [RomanItalic] [SerifItalic] +\definefontsynonym [RomanSlanted] [SerifSlanted] +\definefontsynonym [RomanBoldItalic] [SerifBoldItalic] +\definefontsynonym [RomanBoldSlanted] [SerifBoldSlanted] +\definefontsynonym [RomanCaps] [SerifCaps] + +\definefontsynonym [Type] [Mono] +\definefontsynonym [TypeBold] [MonoBold] +\definefontsynonym [TypeItalic] [MonoItalic] +\definefontsynonym [TypeSlanted] [MonoSlanted] +\definefontsynonym [TypeBoldItalic] [MonoBoldItalic] +\definefontsynonym [TypeBoldSlanted] [MonoBoldSlanted] +\definefontsynonym [TypeCaps] [MonoCaps] + +%D Next we define roman, sans and monospaced font sets. + +\definebodyfont [default] [rm] + [\s!tf=Serif sa 1, + \s!bf=SerifBold sa 1, + \s!it=SerifItalic sa 1, + \s!sl=SerifSlanted sa 1, + \s!bi=SerifBoldItalic sa 1, + \s!bs=SerifBoldSlanted sa 1, + \s!sc=SerifCaps sa 1] + +\definebodyfont [default] [ss] + [\s!tf=Sans sa 1, + \s!bf=SansBold sa 1, + \s!it=SansItalic sa 1, + \s!sl=SansSlanted sa 1, + \s!bi=SansBoldItalic sa 1, + \s!bs=SansBoldSlanted sa 1, + \s!sc=SansCaps sa 1] + +\definebodyfont [default] [tt] + [\s!tf=Mono sa 1, + \s!bf=MonoBold sa 1, + \s!it=MonoItalic sa 1, + \s!sl=MonoSlanted sa 1, + \s!bi=MonoBoldItalic sa 1, + \s!bs=MonoBoldSlanted sa 1, + \s!sc=MonoCaps sa 1] + +\definebodyfont [default] [mm] + [\s!mr =MathRoman mo 1, + \s!mrlr=MathRomanL2R mo 1, + \s!mrrl=MathRomanR2L mo 1, + \s!mb =MathRomanBold mo 1, + \s!mblr=MathRomanBoldL2R mo 1, + \s!mbrl=MathRomanBoldR2L mo 1] + +\definebodyfont [default] [hw] + [\s!tf=Handwriting sa 1] + +\definebodyfont [default] [cg] + [\s!tf=Calligraphy sa 1] + +%D These definitions come into action as soon as names are mapped onto real file +%D names (or names that themselves are mapped). + +\protect \endinput diff --git a/tex/context/base/mkxl/font-var.mklx b/tex/context/base/mkxl/font-var.mklx new file mode 100644 index 000000000..421521f50 --- /dev/null +++ b/tex/context/base/mkxl/font-var.mklx @@ -0,0 +1,57 @@ +%D \module +%D [ file=font-var, +%D version=2011.01.13, % (copied fron font-ini) +%D title=\CONTEXT\ Font Macros, +%D subtitle=Common Variables, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Font Macros / Common Variables} + +\unprotect + +% some more will move here + +%D \macros +%D {fontstyle,fontalternative,fontsize,fontbody} +%D +%D Within a bodyfont, fonts can come in different sizes. For instance \type {\tf} is +%D accompanied by \type {\tfa}, \type {\tfb} etc. The first two characters denote +%D the alternative, while the third character in these sequences represents the +%D size. The actual size is saved in a macro. The styles, being roman (\type {\rm}), +%D sans serif (\type {\ss}) etc. are also available. + +% fontclass % modern dejavu +% fontbody % ... 10pt 11pt 12pt ... +% fontstyle % rm ss tt mm hw cg ... +% fontalternative % tf bf sl it bs bi sc ... +% fontsize % a b c d ... +% fontface % 0=normal 1=text 2=script 3=scriptscript 4=x 5=xx (math are temporary) + +\mutable\def\normalizedbodyfontsize{12pt} + +\immutable\def\defaultfontbody {\normalizedbodyfontsize} +\immutable\let\defaultfontstyle \s!rm +\immutable\let\defaultfontalternative\s!tf +\immutable\let\defaultfontsize \empty +\immutable\let\defaultfontface \!!zerocount + +\mutable\let\globalfontclass\empty +\mutable\let\fontclass \empty +\mutable\let\fontbody \defaultfontbody +\mutable\let\fontstyle \defaultfontstyle +\mutable\let\fontalternative\defaultfontalternative +\mutable\let\fontsize \defaultfontsize +\mutable\let\fontface \!!zerocount + +\installmacrostack\fontstyle + +% we can use an indirect mapping for fontclasses (map string onto numbers) and indeed this +% is somewhat more efficient but also makes the code messy ... maybe some day ... + +\protect \endinput diff --git a/tex/context/base/mkiv/grph-epd.mkxl b/tex/context/base/mkxl/grph-epd.mkxl index a0fcc51da..a0fcc51da 100644 --- a/tex/context/base/mkiv/grph-epd.mkxl +++ b/tex/context/base/mkxl/grph-epd.mkxl diff --git a/tex/context/base/mkiv/grph-fig.mkxl b/tex/context/base/mkxl/grph-fig.mkxl index d28427d40..723a627a5 100644 --- a/tex/context/base/mkiv/grph-fig.mkxl +++ b/tex/context/base/mkxl/grph-fig.mkxl @@ -174,6 +174,11 @@ \aliased\let\stopfigure\relax +\ifdefined\referring \else \let\referring\relax \fi +\ifdefined\marking \else \let\marking \relax \fi +\ifdefined\remark \else \let\remark \relax \fi +\ifdefined\colorbar \else \let\colorbar \relax \fi + \protected\def\grph_steps_test_figure#1#2#3#4% {\begingroup \setbox\scratchbox\hpack diff --git a/tex/context/base/mkiv/grph-inc.mkxl b/tex/context/base/mkxl/grph-inc.mkxl index 1e6d614a6..21be4abf6 100644 --- a/tex/context/base/mkiv/grph-inc.mkxl +++ b/tex/context/base/mkxl/grph-inc.mkxl @@ -28,7 +28,7 @@ \registerctxluafile{grph-fil}{} \registerctxluafile{grph-mem}{} \registerctxluafile{grph-u3d}{} % this will become a module -\registerctxluafile{grph-swf}{} % this will become a module +%registerctxluafile{grph-swf}{} % this will become a module \unprotect @@ -589,12 +589,12 @@ \ifx\p_option\v!frame \setfalse\c_grph_include_skip \letexternalfigureparameter\c!frame\v!on - \else\ifx\p_option\v!empty + \orelse\ifx\p_option\v!empty \settrue\c_grph_include_skip \letexternalfigureparameter\c!frame\v!off \else \setfalse\c_grph_include_skip - \fi\fi + \fi % fake color in gray bitmaps, assumes that % a transparent color is used \edef\p_foregroundcolor{\externalfigureparameter\c!foregroundcolor}% diff --git a/tex/context/base/mkiv/grph-pat.mkxl b/tex/context/base/mkxl/grph-pat.mkxl index 92fd5ad74..92fd5ad74 100644 --- a/tex/context/base/mkiv/grph-pat.mkxl +++ b/tex/context/base/mkxl/grph-pat.mkxl diff --git a/tex/context/base/mkiv/grph-raw.mkxl b/tex/context/base/mkxl/grph-raw.mkxl index 66194551b..66194551b 100644 --- a/tex/context/base/mkiv/grph-raw.mkxl +++ b/tex/context/base/mkxl/grph-raw.mkxl diff --git a/tex/context/base/mkiv/grph-rul.mkxl b/tex/context/base/mkxl/grph-rul.mkxl index ef65b1fe4..ef65b1fe4 100644 --- a/tex/context/base/mkiv/grph-rul.mkxl +++ b/tex/context/base/mkxl/grph-rul.mkxl diff --git a/tex/context/base/mkiv/grph-trf.mkxl b/tex/context/base/mkxl/grph-trf.mkxl index 0a423bd6b..9e00da7a4 100644 --- a/tex/context/base/mkiv/grph-trf.mkxl +++ b/tex/context/base/mkxl/grph-trf.mkxl @@ -868,7 +868,7 @@ \settrue \c_grph_rotate_obey_depth \grph_rotate_framed} -\protected\def\dorotatebox#1% {angle} \hbox/\vbox/\vtop % a fast low level one +\permanent\protected\def\dorotatebox#1% {angle} \hbox/\vbox/\vtop % a fast low level one {\ifcase#1\relax \expandafter\gobbleoneargument \else diff --git a/tex/context/base/mkiv/hand-ini.mkxl b/tex/context/base/mkxl/hand-ini.mkxl index 3fd82f239..3fd82f239 100644 --- a/tex/context/base/mkiv/hand-ini.mkxl +++ b/tex/context/base/mkxl/hand-ini.mkxl diff --git a/tex/context/base/mkiv/java-ini.mkxl b/tex/context/base/mkxl/java-ini.mkxl index 513dc20e3..513dc20e3 100644 --- a/tex/context/base/mkiv/java-ini.mkxl +++ b/tex/context/base/mkxl/java-ini.mkxl diff --git a/tex/context/base/mkxl/lang-def.mkxl b/tex/context/base/mkxl/lang-def.mkxl new file mode 100644 index 000000000..5698bb4af --- /dev/null +++ b/tex/context/base/mkxl/lang-def.mkxl @@ -0,0 +1,800 @@ +%D \module +%D [ file=lang-def, +%D version=2011.01.24, % merge of language files +%D title=\CONTEXT\ Language Macros, +%D subtitle=Languages Definitions, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Language Macros / Definitions} + +%D See \type {lang-*.tex} for some historic notes. + +\unprotect + +% Germanic Languages: Danish, Faeroese, Icelandic, Norwegian, +% Swedish, German, Yiddish, Afrikaans, Dutch, English, Flemush, +% Frisian, Plattdeutsch + +\installlanguage + [\s!en] + [\c!spacing=\v!broad, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!month,\space,\v!day,{,\space},\v!year}, + \s!patterns=\s!us, + \s!lefthyphenmin=2, + \s!righthyphenmin=3] + +\installlanguage + [\s!nl] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\lowerleftsingleninequote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\lowerleftdoubleninequote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!day,\space,\v!month,\space,\v!year}] + +\installlanguage + [\s!de] + [\c!spacing=\v!packed, + \s!lefthyphenmin=3, + \s!righthyphenmin=3, + \c!leftsentence=\hbox{\endash\space}, + \c!rightsentence=\hbox{\space\endash}, + \c!leftsubsentence=\endash, + \c!rightsubsentence=\endash, + \c!leftquote=\lowerleftsingleninequote, + \c!rightquote=\upperrightsinglesixquote, + \c!leftquotation=\lowerleftdoubleninequote, + \c!rightquotation=\upperrightdoublesixquote, + \c!date={\v!day,{.\space},\v!month,\space,\v!year}] + +\installlanguage + [\s!da] + [\c!spacing=\v!packed, + \c!leftsentence={\hbox{\endash\enskip}}, + \c!rightsentence={\hbox{\enskip\endash}}, + \c!leftsubsentence=\endash, + \c!rightsubsentence=\endash, + \c!leftquote=\lowerleftsingleninequote, + \c!rightquote=\upperrightsinglesixquote, + \c!leftquotation=\lowerleftdoubleninequote, + \c!rightquotation=\upperrightdoublesixquote, + \c!date={\v!day,{.\space},\v!month,\space,\v!year}] + +\installlanguage + [\s!sv] + [\c!spacing=\v!packed, + \c!leftsentence=\hbox{\endash\space}, + \c!rightsentence=\hbox{\space\endash}, + \c!leftsubsentence=\endash, + \c!rightsubsentence=\endash, + \c!leftquote=\upperrightsingleninequote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperrightdoubleninequote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!day,\space,\v!month,\space,\v!year}] + +\installlanguage + [\s!af] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!year,\space,\v!month,\space,\v!day}] + +\installlanguage + [\s!nb] + [\c!spacing=\v!packed, + \s!lefthyphenmin=2, + \s!righthyphenmin=2, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\leftguillemot, + \c!rightquotation=\rightguillemot, + \c!date={\v!day,{.},\space,\v!month,\space,\v!year}] + +\installlanguage + [\s!nn] + [\c!spacing=\v!packed, + \s!lefthyphenmin=2, + \s!righthyphenmin=2, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\leftguillemot, + \c!rightquotation=\rightguillemot, + \c!date={\v!day,{.},\space,\v!month,\space,\v!year}] + +\installlanguage [\s!no] [\s!nb] +\installlanguage [\s!norwegian] [\s!nb] +\installlanguage [\s!bokmal] [\s!nb] +\installlanguage [\s!nynorsk] [\s!nn] + +\installlanguage % old german + [deo] + [\c!spacing=\v!packed, + \c!default=\s!de] + +\installlanguage + [de-de] + [\c!spacing=\v!packed, + \c!default=\s!de] + +\installlanguage + [de-at] + [\c!spacing=\v!packed, + \c!default=\s!de, + \c!leftquote=\leftguillemot, + \c!rightquote=\rightguillemot, + \c!leftquotation=\leftguillemot, + \c!rightquotation=\rightguillemot] + +\installlanguage + [de-ch] + [\c!spacing=\v!packed, + \c!default=\s!de] + +%D And some alternative (but very real) english patterns: + +\installlanguage + [en-gb] + [\c!default=\s!en, + \s!patterns=\s!gb, + \s!lefthyphenmin=3, + \s!righthyphenmin=3, + % the reverse of american (or maybe the american did it the reverse) + \c!leftquote=\upperleftdoublesixquote, + \c!rightquote=\upperrightdoubleninequote, + \c!leftquotation=\upperleftsinglesixquote, + \c!rightquotation=\upperrightsingleninequote] + +\installlanguage + [en-us] + [\c!default=\s!en, + \s!patterns=\s!us] + +\installlanguage [\s!uk] [\s!en-\s!gb] +\installlanguage [\s!us] [\s!en-\s!us] + +\installlanguage [usenglish] [\s!en-\s!us] +\installlanguage [ukenglish] [\s!en-\s!gb] +\installlanguage [english] [\s!en] +\installlanguage [dutch] [\s!nl] +\installlanguage [german] [\s!de] +\installlanguage [danish] [\s!da] +\installlanguage [swedish] [\s!sv] +\installlanguage [afrikaans] [\s!af] + +% Slavic Languages: Belarussian, Russian, Ukrainian, Bulgarian, +% Macedonian, Serbian, Croatian, Slovenian, Czech, Kushubian, +% Lusatian/Sorbian/Wendish, Polish, Slovak, Albanian, Illyrian, +% Armenian + +\installlanguage + [\s!pl] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\lowerleftsingleninequote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\lowerleftdoubleninequote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!day,{.\space},\v!month,\space,\v!year}] + +\installlanguage + [\s!cs] + [\c!spacing=\v!packed, + \c!leftsentence={\nobreakspace\endash\thickglue\penalty\zerocount\relax}, + \c!rightsentence=\c!leftsentence, + \c!leftsubsentence=\c!leftsentence, + \c!rightsubsentence=\c!rightsentence, + \c!leftquote=\lowerleftsingleninequote, + \c!rightquote=\upperrightsinglesixquote, + \c!leftquotation=\lowerleftdoubleninequote, + \c!rightquotation=\upperrightdoublesixquote, + \c!date={\v!day,{.\fourperemspace},\v!month,\space,\v!year}, + \s!lefthyphenmin=2, + \s!righthyphenmin=3] + +\installlanguage + [\s!sk] + [\c!spacing=\v!packed, + \c!leftsentence={\nobreakspace\endash\thickglue\penalty\zerocount\relax}, + \c!rightsentence=\c!leftsentence, + \c!leftsubsentence=\c!leftsentence, + \c!rightsubsentence=\c!rightsentence, + \c!leftquote=\lowerleftsingleninequote, + \c!rightquote=\upperrightsinglesixquote, + \c!leftquotation=\lowerleftdoubleninequote, + \c!rightquotation=\upperrightdoublesixquote, + \c!date={\v!day,{.\fourperemspace},\v!month,\space,\v!year}, + \s!lefthyphenmin=2, + \s!righthyphenmin=3] + +\installlanguage + [\s!hr] + [\c!spacing=\v!packed, + \c!leftsentence=\hbox{\endash\space}, + \c!rightsentence=\hbox{\space\endash}, + \c!leftsubsentence=\endash, + \c!rightsubsentence=\endash, + \c!leftquote=\lowerleftsingleninequote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\lowerleftdoubleninequote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!day,{.},\space,\v!month,\space,\v!year}] + +\installlanguage + [\s!sl] + [\c!command=\v!no, + \c!spacing=\v!packed, + \c!leftsentence=\hbox{\endash\space}, + \c!rightsentence=\hbox{\space\endash}, + \c!leftsubsentence=\endash, + \c!rightsubsentence=\endash, + \c!leftquote=\guilsingleright, + \c!rightquote=\guilsingleleft, + \c!leftquotation=\rightguillemot, + \c!rightquotation=\leftguillemot, + \c!date={\v!day,{.},\space,\v!month,\space,\v!year}] + +\installlanguage [\s!polish] [\s!pl] +\installlanguage [\s!czech] [\s!cs] +\installlanguage [\s!slovak] [\s!sk] +\installlanguage [\s!croatian] [\s!hr] +\installlanguage [\s!slovenian] [\s!sl] +\installlanguage [slovene] [\s!sl] % both possible (mojca: still needed?) + +% Cyrillic Languages + +\installlanguage + [\s!ru] + [\s!lefthyphenmin=2, + \s!righthyphenmin=2, + \c!spacing=\v!packed, + \c!leftsentence=\leftguillemot, + \c!rightsentence=\rightguillemot, + \c!leftsubsentence=\lowerleftdoubleninequote, + \c!rightsubsentence=\upperrightdoubleninequote, + \c!leftquote=\lowerleftdoubleninequote, + \c!rightquote=\upperrightdoubleninequote, + \c!leftquotation=\leftguillemot, + \c!rightquotation=\rightguillemot, + \c!date={\v!day,\space,\v!month,\space,\v!year}] + +\installlanguage + [\s!ua] + [\s!lefthyphenmin=2, + \s!righthyphenmin=2, + \c!spacing=\v!packed, + \c!leftsentence=\leftguillemot, + \c!rightsentence=\rightguillemot, + \c!leftsubsentence=\lowerleftdoubleninequote, + \c!rightsubsentence=\upperrightdoubleninequote, + \c!leftquote=\lowerleftdoubleninequote, + \c!rightquote=\upperrightdoubleninequote, + \c!leftquotation=\leftguillemot, + \c!rightquotation=\rightguillemot, + \c!date={\v!day,\space,\v!month,\space,\v!year}, + \s!patterns=\s!uk] + +\installlanguage [\s!russian] [\s!ru] +\installlanguage [\s!ukrainian] [\s!ua] + +% Uralic Languages: Cheremiss, Estonian, Finnish, Karelian, Laap, +% Mordvinian, Permian tongues, Hungarian, Ostyak, Vogul, Samoyed + +\installlanguage + [\s!fi] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!year,\space,\v!month,\space,\v!day}] + +\installlanguage + [\s!et] + [\c!default=\s!en, + \c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\leftguillemot, + \c!rightquote=\rightguillemot, + \c!leftquotation=\lowerrightdoubleninequote, + \c!rightquotation=\upperrightdoublesixquote, + \c!time={h,{.},m}, + \c!date={\v!day,.,\space,\v!month,\space,\v!year}, + \s!patterns=\s!et] + +\installlanguage + [\s!hu] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\lowerleftsingleninequote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\lowerleftdoubleninequote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!year,.,\space,\v!month,\space,\v!day,.}] + +\installlanguage [\s!finnish] [\s!fi] +\installlanguage [\s!estonian] [\s!et] +\installlanguage [\s!hungarian] [\s!hu] + +% Altaic Languages: Uigur, Uzbek, Azeri/Azerbaijani, Chuvash, +% Turkish, Turkmen, Kazakh, Kazar, Kireghiz, Noghay, Talar, +% Buryat, Kalmuck, Khalkha + +\installlanguage + [\s!tr] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!year,\space,\v!month,\space,\v!day}] + +\installlanguage + [\s!tk] + [\c!spacing=\v!broad, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!year,\space,\v!month,\space,\v!day}, + \s!patterns=\s!tk, + \s!lefthyphenmin=1, + \s!righthyphenmin=2] + +\installlanguage [\s!turkish] [\s!tr] +\installlanguage [\s!turkmen] [\s!tk] + +% Anatolian Languages + +% Hebrew + +\installlanguage % same as arabic now .. someone needs to fix this + [\s!he] + [\c!spacing=\v!broad, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!day,\space,\v!month,{،\space},\v!year}] + +\installlanguage % same as arabic now .. someone needs to fix this + [\s!yi] + [\s!he] + +\installlanguage [\s!hebrew] [\s!he] +\installlanguage [\s!yiddish] [\s!yi] + +% Arabic Languages + +\installlanguage + [\s!ar] + [\c!spacing=\v!broad, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!day,\space,\v!month,{،\space},\v!year}] + +\installlanguage [\s!arabic] [\s!ar] + +\installlanguage + [\s!pe] + [\c!spacing=\v!broad, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\leftguillemot, + \c!rightquote=\rightguillemot, + \c!leftquotation=\leftguillemot, + \c!rightquotation=\rightguillemot, + \c!date={\v!day,\space,\v!month,\space,\v!year}] + +\installlanguage [\s!persian] [\s!pe] +\installlanguage [\s!fa] [\s!pe] % these two are redundant but sometimes might +\installlanguage [\s!farsi] [\s!fa] % sound more natural .. best set labels to 'pe' + +% Just aliases to "ar" for now + +\installlanguage[\s!ar-ae][\c!default=\s!ar] % U.A.E. +\installlanguage[\s!ar-bh][\c!default=\s!ar] % Bahrain +\installlanguage[\s!ar-eg][\c!default=\s!ar] % Egypt +\installlanguage[\s!ar-in][\c!default=\s!ar] % India? +\installlanguage[\s!ar-kw][\c!default=\s!ar] % Kuwait +\installlanguage[\s!ar-ly][\c!default=\s!ar] % Libya +\installlanguage[\s!ar-om][\c!default=\s!ar] % Oman +\installlanguage[\s!ar-qa][\c!default=\s!ar] % Qatar +\installlanguage[\s!ar-sa][\c!default=\s!ar] % Saudi Arabia +\installlanguage[\s!ar-sd][\c!default=\s!ar] % Sudan +\installlanguage[\s!ar-tn][\c!default=\s!ar] % Tunisia +\installlanguage[\s!ar-ye][\c!default=\s!ar] % Yemen + +% Farsi (Persian) + +\installlanguage[\s!ar-ir][\c!default=\s!pe] +%installlanguage[\s!pe-ir][\c!default=\s!pe] +%installlanguage[\s!fa-ir][\c!default=\s!fa] + +% Syriac months + +\installlanguage[\s!ar-sy][\c!default=\s!ar] % Syria +\installlanguage[\s!ar-iq][\c!default=\s!ar-sy] % Iraq +\installlanguage[\s!ar-jo][\c!default=\s!ar-sy] % Jordan +\installlanguage[\s!ar-lb][\c!default=\s!ar-sy] % Lebanon + +% Maghribi months + +\installlanguage[\s!ar-dz][\c!default=\s!ar] % Algeria +\installlanguage[\s!ar-ma][\c!default=\s!ar] % Morocco + +% Artificial Languages: Esperanto + +\installlanguage + [\s!esperanto] + [%\c!spacing=\v!packed, + %\c!leftsentence=\emdash, + %\c!rightsentence=\emdash, + %\c!leftsubsentence=\emdash, + %\c!rightsubsentence=\emdash, + %\c!leftquote=\lowerleftdoubleninequote, + %\c!rightquote=\upperrightdoublesixquote, + %\c!leftquotation=\lowerleftdoubleninequote, + %\c!rightquotation=\upperrightdoublesixquote, + %\c!date={\v!year,~m.,\space,\v!month,\space,\v!day,~d.}, + \s!patterns=eo, + \s!lefthyphenmin=2, + \s!righthyphenmin=2] + +% Baltic Languages: Lettish/Latvian, Lietuvių/Lithuanian + +\installlanguage + [\s!lt] + [\c!command=\v!no, + \c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\lowerleftdoubleninequote, + \c!rightquote=\upperrightdoublesixquote, + \c!leftquotation=\lowerleftdoubleninequote, + \c!rightquotation=\upperrightdoublesixquote, + \c!date={\v!year,~m.,\space,\v!month,\space,\v!day,~d.}, + \s!patterns=\s!lt, + \s!lefthyphenmin=2, + \s!righthyphenmin=2] + +\installlanguage [\s!lithuanian] [\s!lt] + +% Celtic: Breton, Welsh, Irish, Manx, Scottish Gaelic + +% CJK: Chinese, Japanese, Korean + +\installlanguage + [\s!cn] + [\c!leftsentence=——, + \c!rightsentence=——, + \c!leftsubsentence=——, + \c!rightsubsentence=——, + \c!leftquote=‘, + \c!rightquote=’, + \c!leftquotation=“, + \c!rightquotation=”, + \c!date={\v!year,年,\space,\v!month,\v!day,日}] + +\installlanguage + [\s!ja] + [\c!leftsentence=——, + \c!rightsentence=——, + \c!leftsubsentence=——, + \c!rightsubsentence=——, + \c!leftquote=‘, + \c!rightquote=’, + \c!leftquotation=「, + \c!rightquotation=」, + \c!date={西暦,\v!year,年,\v!month,月,\v!day,日}] + +\installlanguage + [\s!kr] + [\c!leftsentence=——, + \c!rightsentence=——, + \c!leftsubsentence=——, + \c!rightsubsentence=——, + \c!leftquote=‘, + \c!rightquote=’, + \c!leftquotation=“, + \c!rightquotation=”, + % \c!date={서기,\space,\v!year,\labeltext{\v!year},\space,\v!month,\labeltext{\v!month},\space,\v!day,\labeltext{\v!day}}] + \c!date={\v!year,\labeltext{\v!year},\space,\v!month,\labeltext{\v!month},\space,\v!day,\labeltext{\v!day}}] + +\installlanguage [\s!chinese] [\s!cn] +\installlanguage [\s!japanese] [\s!ja] +\installlanguage [\s!korean] [\s!kr] + +% Greek + +\installlanguage + [\s!gr] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=“, + \c!rightquote=”, + \c!leftquotation=«, + \c!rightquotation=», + \c!date={\v!day\space\v!month\space\v!year}, + \s!patterns=\s!agr] % ok? + +\installlanguage [\s!greek] [\s!gr] + +\installlanguage + [\s!agr] + [\s!default=\s!gr, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote] + +\installlanguage [\s!ancientgreek] [\s!agr] + +% Indo-Iranian Languages: 34. + +% Italic Languages: Latin, Italian, Rhaeto-Romanic, Rumanian, +% Sardian, Catalan, French, Ladino, Portuguese, Proven\c{c}al, +% Spanish + +\ifdefined\guillemotspace \else \let\guillemotspace\empty \fi +\ifdefined\sentencespace \else \let\sentencespace \empty \fi + +\installlanguage + [\s!fr] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\leftguillemot, + \c!rightquote=\rightguillemot, + \c!leftquotation=\leftguillemot, + \c!rightquotation=\rightguillemot, + \c!time={h,{\Uchar104 },m},% we need to cheat in order to get the h + \c!date={\v!day:mnem,\v!space,\v!month,\v!space,\v!year}] + +\installlanguage + [\s!es] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!day,{ de },\v!month,{ de },\v!year}] + +\installlanguage [sp] [\s!es] % old times context + +\installlanguage + [\s!ca] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!day,\space,\v!month,\space,\v!year}] + +% Note GB left|/|right (sub)sentences are for \quote {incisi}. + +\installlanguage + [\s!it] + [\c!command=\v!no, + \c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\endash, + \c!rightsubsentence=\endash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!leftspeech=\leftguillemot, + \c!middlespeech=\leftguillemot, + \c!rightspeech=\rightguillemot, + \c!date={\v!day,\space,\v!month,\space,\v!year}] + +\installlanguage % the same as italian + [\s!la] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!day,\space,\v!month,\space,\v!year}] + +\installlanguage % ancient latin + [\s!ala] + [\c!default=\s!la] + +\installlanguage + [\s!pt] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!year,\space,\v!month,\space,\v!day}] + +\installlanguage[\s!pt-br][\c!default=\s!pt] % Brazil +\installlanguage[\s!es-es][\c!default=\s!es] % Spain +\installlanguage[\s!es-la][\c!default=\s!es] % Latin America + +\installlanguage + [\s!ro] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\leftguillemot, + \c!rightquote=\rightguillemot, + \c!leftquotation=\lowerrightdoubleninequote, + \c!rightquotation=\upperleftdoublesixquote, + \c!date={\v!day,\space,\v!month,\space,\v!year}] + +%D For compatibility reasons we also define: + +\installlanguage [\s!french] [\s!fr] +\installlanguage [\s!spanish] [\s!es] +\installlanguage [\s!catalan] [\s!ca] +\installlanguage [\s!italian] [\s!it] +\installlanguage [\s!latin] [\s!la] +\installlanguage [\s!portuguese] [\s!pt] +\installlanguage [\s!romanian] [\s!ro] + +% Vietnamese Language + +\installlanguage + [\s!vi] + [\c!spacing=\v!packed, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\quoteleft, + \c!rightquote=\quoteright, + \c!leftquotation=\quotedblleft, + \c!rightquotation=\quotedblright, + \c!date={{ },dd,{/},mm,{/},yy}] + +\installlanguage [\s!vietnamese] [\s!vi] + +% Thai (teaser for Mojca) + +\installlanguage + [\s!th] + [\c!spacing=\v!broad, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!month,\space,\v!day,{,\space},\v!year}, + \s!patterns=\s!th, + \s!lefthyphenmin=2, + \s!righthyphenmin=3] + +\installlanguage [\s!thai] [\s!th] + +%D Malayalam (needs to be checked) + +\installlanguage + [\s!ml] + [\c!spacing=\v!broad, + \c!leftsentence=\emdash, + \c!rightsentence=\emdash, + \c!leftsubsentence=\emdash, + \c!rightsubsentence=\emdash, + \c!leftquote=\upperleftsinglesixquote, + \c!rightquote=\upperrightsingleninequote, + \c!leftquotation=\upperleftdoublesixquote, + \c!rightquotation=\upperrightdoubleninequote, + \c!date={\v!month,\space,\v!day,{,\space},\v!year}, + \s!patterns=\s!ml, + \s!lefthyphenmin=2, + \s!righthyphenmin=3] + +\installlanguage [\s!malayalam] [\s!ml] + +%D Todo: generate this one from languages.data + +\installlanguage[nld][\s!nl] +\installlanguage[deu][\s!de] +\installlanguage[eng][\s!en] +\installlanguage[fra][\s!fr] +%installlanguage[grk][\s!agr] + +%D This might go: + +\installlanguage[cz][\s!cs] +%installlanguage[fa][\s!fr] % for dutchies only + +\protect \endinput diff --git a/tex/context/base/mkiv/lang-dis.lmt b/tex/context/base/mkxl/lang-dis.lmt index 263225691..263225691 100644 --- a/tex/context/base/mkiv/lang-dis.lmt +++ b/tex/context/base/mkxl/lang-dis.lmt diff --git a/tex/context/base/mkxl/lang-frd.mkxl b/tex/context/base/mkxl/lang-frd.mkxl new file mode 100644 index 000000000..352e5016d --- /dev/null +++ b/tex/context/base/mkxl/lang-frd.mkxl @@ -0,0 +1,143 @@ +%D \module +%D [ file=lang-frd, +%D version=2004.01.15, +%D title=\CONTEXT\ Language Macros, +%D subtitle=Language Frequency Table Data, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\endinput + +%D This is experimental work! Old stuff, whenever I need it I might +%D do it in \LUA. + +% http://www.onzetaal.nl/advies/letterfreq.html + +\startcharactertable[nl] + \charfreq a 7.47 + \charfreq b 1.58 + \charfreq c 1.24 + \charfreq d 5.93 + \charfreq e 18.91 + \charfreq f .81 + \charfreq g 3.4 + \charfreq h 2.38 + \charfreq i 6.5 + \charfreq j 1.46 + \charfreq k 2.25 + \charfreq l 3.57 + \charfreq m 2.21 + \charfreq n 10.03 + \charfreq o 6.06 + \charfreq p 1.57 + \charfreq q .009 + \charfreq r 6.41 + \charfreq s 3.73 + \charfreq t 6.79 + \charfreq u 1.99 + \charfreq v 2.85 + \charfreq w 1.52 + \charfreq x .04 + \charfreq y .035 + \charfreq z 1.39 +\stopcharactertable + +% http://caislab.icu.ac.kr/course/2001/spring/ice605/down/010306.pdf + +% \startcharactertable[en] +% \charfreq a 8.2 +% \charfreq b 1.5 +% \charfreq c 2.8 +% \charfreq d 4.3 +% \charfreq e 12.7 +% \charfreq f 2.2 +% \charfreq g 2 +% \charfreq h 6.1 +% \charfreq i 7 +% \charfreq j .2 +% \charfreq k .8 +% \charfreq l 4 +% \charfreq m 2.4 +% \charfreq n 6.7 +% \charfreq o 7.5 +% \charfreq p 1.9 +% \charfreq q .1 +% \charfreq r 6 +% \charfreq s 6.3 +% \charfreq t 9.1 +% \charfreq u 2.8 +% \charfreq v 1 +% \charfreq w 2.3 +% \charfreq x .1 +% \charfreq y 2 +% \charfreq z .1 +% \stopcharactertable + +% http://www.blankenburg.de/gat/pages/fach/info/analyse2.htm + +\startcharactertable[en] + \charfreq a 8.04 + \charfreq b 1.54 + \charfreq c 3.06 + \charfreq d 3.99 + \charfreq e 12.51 + \charfreq f 2.3 + \charfreq g 1.96 + \charfreq h 5.49 + \charfreq i 7.26 + \charfreq j .16 + \charfreq k .67 + \charfreq l 4.14 + \charfreq m 2.53 + \charfreq n 7.09 + \charfreq o 7.6 + \charfreq p 2 + \charfreq q .11 + \charfreq r 6.12 + \charfreq s 6.54 + \charfreq t 9.25 + \charfreq u 2.71 + \charfreq v .99 + \charfreq w 1.92 + \charfreq x .19 + \charfreq y 1.73 + \charfreq z .09 +\stopcharactertable + +% http://www.blankenburg.de/gat/pages/fach/info/analyse2.htm + +\startcharactertable[de] + \charfreq a 6.47 + \charfreq b 1.93 + \charfreq c 2.68 + \charfreq d 4.83 + \charfreq e 17.48 + \charfreq f 1.65 + \charfreq g 3.06 + \charfreq h 4.23 + \charfreq i 7.73 + \charfreq j .27 + \charfreq k 1.46 + \charfreq l 3.49 + \charfreq m 2.58 + \charfreq n 9.84 + \charfreq o 2.98 + \charfreq p .96 + \charfreq q .02 + \charfreq r 7.54 + \charfreq s 6.83 + \charfreq t 6.13 + \charfreq u 4.17 + \charfreq v .94 + \charfreq w 1.48 + \charfreq x .04 + \charfreq y .08 + \charfreq z 1.14 +\stopcharactertable + +\endinput diff --git a/tex/context/base/mkxl/lang-frq.mkxl b/tex/context/base/mkxl/lang-frq.mkxl new file mode 100644 index 000000000..07bc1654d --- /dev/null +++ b/tex/context/base/mkxl/lang-frq.mkxl @@ -0,0 +1,234 @@ +%D \module +%D [ file=lang-frq, +%D version=2004.01.15, +%D title=\CONTEXT\ Language Macros, +%D subtitle=Frequency Tables, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\endinput + +\writestatus{loading}{ConTeXt Language Macros / Frequency Tables} + +%D Some day I might redo this \LUA. But anyway, who uses it. It's rather old code. + +\unprotect + +%M \usemodule[layout] + +%D \macros +%D {charwidthmethod} +%D +%D This module implements a method for determining the width of an +%D average character in a language. It uses the dimensions of the +%D current fonts. +%D +%D \def\ShwChrWd#1#2#3% +%D {\chardef\charwidthmethod#1\relax +%D \mainlanguage[#2#3]\the\dimexpr(\averagecharwidth)} +%D +%D \starttabulate[|c|c|c|c|c|c|] +%D \HL +%D \NC \NC\bf0=amount\NC\bf1=.5em\NC2=ex\NC\bf3=frequency\NC\bf4=list\NC\NR +%D \HL +%D \NC\bf en\NC\ShwChrWd0en\NC\ShwChrWd1en\NC\ShwChrWd2en\NC\ShwChrWd3en\NC\ShwChrWd4en\NC\NR +%D \NC\bf nl\NC\ShwChrWd0nl\NC\ShwChrWd1nl\NC\ShwChrWd2nl\NC\ShwChrWd3nl\NC\ShwChrWd4nl\NC\NR +%D \NC\bf de\NC\ShwChrWd0de\NC\ShwChrWd1de\NC\ShwChrWd2de\NC\ShwChrWd3de\NC\ShwChrWd4de\NC\NR +%D \HL +%D \stoptabulate +%D +%D Method~1 ignores the widths and assumes that each character has a +%D width of .5em, which is true for most monospaced fonts. Method~2 +%D takes the x as starting point, and assumes that it's height kind of +%D matches its width. Method~3 is the best one, and determines the +%D average width based on the language specific character table. +%D Method~4 is a mixture between the first two methods: character +%D specific widths applied to an equal distribution. Method~0 reports +%D the total count, which normally is~100. + +\setnewconstant\charwidthmethod=3 % 0=amount 1=em 2=ex 3=frequency 4=flattened >4=ex + +%D \macros +%D {charwidthlanguage} +%D +%D The language used for the calculations is defined as: + +\def\charwidthlanguage{\currentmainlanguage} + +%D \macros +%D {charfreq} +%D +%D This method comes into action in the following macro: + +\def\charfreq#1 #2 % character fraction + {+(\ifcase\charwidthmethod + #2\dimexpr100\onepoint\relax + \or + #2\dimexpr\emwidth/2\relax + \or + #2\dimexpr\exheight\relax + \or + #2\fontcharwd\font`#1% + \or + \dimexpr100\fontcharwd\font`#1/\charactertsize\charwidthlanguage\relax % ugly hack + \else + #2\dimexpr\exheight\relax + \fi)} + +%D \macros +%D {startcharactertable} +%D +%D A frequency table is defined with the following macro. The \type +%D {charfreq} macro is used in this table. + +\installcorenamespace{frequencywidths} +\installcorenamespace{frequencycounts} + +\aliased\let\stopcharactertable\relax + +\permanent\protected\def\startcharactertable[#1]#2\stopcharactertable % \dimexpr has fuzzy lookahead + {\startnointerference + \setgvalue{\??frequencywidths#1}{#2}% the width vector + \scratchcounter\zerocount \def\charfreq##1 ##2 {\advance\scratchcounter\plusone} #2% + \setxvalue{\??frequencycounts#1}{\the\scratchcounter}% the character count + \stopnointerference} + +%D \macros +%D {charactertable,charactertsize} +%D +%D The table content as well as the number of entries can be fetched with +%D the following two macros. The architecture of the table and calling +%D macro permits a fully expandable application. + +\permanent\def\charactertable#1% + {\csname\??frequencywidths\ifcsname\??frequencywidths#1\endcsname#1\else\s!en\fi\endcsname} + +\permanent\def\charactertsize#1% + {\csname\??frequencycounts\ifcsname\??frequencycounts#1\endcsname#1\else\s!en\fi\endcsname} + +%D Although it is of hardly any use, you can inherit a character table: +%D +%D \starttyping +%D \startcharactertable[cz] \charactertable{en} \stopcharactertable +%D \stoptyping + +\startcharactertable[en] + % empty +\stopcharactertable % kind of default + +%D \macros +%D {averagecharwidth} +%D +%D This macro reports the average width for the current main +%D language (\the \dimexpr (\averagecharwidth)). + +\permanent\def\averagecharwidth{\dimexpr(\zeropoint\charactertable\charwidthlanguage)/100\relax} + +\permanent\protected\def\showcharfreq + {\hbox\bgroup + \charwidthlanguage:% + \dostepwiserecurse\zerocount\plusfour\plusone + {\setconstant\charwidthmethod\recurselevel\relax + \enspace\recurselevel/\the\dimexpr(\averagecharwidth)}% + \egroup} + +%D Just for fun, we show a few frequency tables as graphic (\in {figure} +%D [fig:charfreq]). +%D +%D \startbuffer +%D \definepalet [charfreq] [en=darkred, nl=darkgreen, de=darkblue] +%D +%D \def\charfreq#1 #2 % +%D {\startMPdrawing +%D interim linejoin := butt ; +%D a := ASCII "#1" ; +%D if (a >= (ASCII "a")) and (a <= (ASCII "z")) : +%D draw ((0,#2*.25cm)--origin--(0,#2*.5cm)) +%D shifted (a*4mm+o,0) +%D withpen pencircle scaled .5mm +%D withcolor c; +%D fi ; +%D \stopMPdrawing} +%D +%D \resetMPdrawing +%D \startMPdrawing +%D numeric a, o ; a := o := 0 ; +%D color c ; c := .5white ; +%D string s ; s := "" ; +%D \stopMPdrawing +%D +%D \startMPdrawing o := 0mm ; c := \MPcolor{charfreq:en} ; \stopMPdrawing +%D \charactertable{en} +%D +%D \startMPdrawing o := 1mm ; c := \MPcolor{charfreq:nl} ; \stopMPdrawing +%D \charactertable{nl} +%D +%D \startMPdrawing o := 2mm ; c := \MPcolor{charfreq:de} ; \stopMPdrawing +%D \charactertable{de} +%D +%D \startMPdrawing +%D for a := ASCII "a" upto ASCII "z" : +%D draw textext.bot("\strut\tttf " & char a) shifted (a*4mm+1mm,-1mm) ; +%D endfor ; +%D \stopMPdrawing +%D +%D \MPdrawingdonetrue \getMPdrawing \resetMPdrawing +%D \stopbuffer +%D +%D \placefigure +%D [here] +%D [fig:charfreq] +%D {The character distributions for English, Dutch and German.} +%D {\getbuffer} +%D +%D A few samples of usage of this mechanism are shown below: +%D +%D \startbuffer +%D {\mainlanguage[en]\hsize65\averagecharwidth\mainlanguage[en]\input ward \blank} +%D {\mainlanguage[nl]\hsize65\averagecharwidth\mainlanguage[en]\input ward \blank} +%D {\mainlanguage[de]\hsize65\averagecharwidth\mainlanguage[en]\input ward \blank} +%D \stopbuffer +%D +%D \typebuffer \getbuffer +%D +%D Although the widthts differ, the consequenes for breaking the paragraph +%D into lines are minimal. + +%D \macros +%D {freezeaveragecharacterwidth} +%D +%D This macro can be used to make sure that the width does not change during a +%D page break when another font is used. + +\aliased\let\normalaveragecharacterwidth\averagecharacterwidth + +\permanent\def\freezeaveragecharacterwidth % global + {\enforced\xdef\averagecharacterwidth{\dimexpr\the\normalaveragecharacterwidth\relax}} + +%D Example: +%D +%D \starttyping +%D \input lang-frq.mkiv +%D \input lang-frd.mkiv +%D +%D \setupbodyfont +%D [dejavu] +%D +%D \setemeasure{textwidth}{\the\dimexpr70\averagecharwidth} +%D +%D \setuplayout +%D [width=\measure{textwidth}] +%D +%D \showframe +%D +%D \starttext +%D \input ward +%D \stoptext +%D \stoptyping + +\protect \endinput diff --git a/tex/context/base/mkiv/lang-hyp.lmt b/tex/context/base/mkxl/lang-hyp.lmt index c2862f536..c2862f536 100644 --- a/tex/context/base/mkiv/lang-hyp.lmt +++ b/tex/context/base/mkxl/lang-hyp.lmt diff --git a/tex/context/base/mkxl/lang-hyp.mkxl b/tex/context/base/mkxl/lang-hyp.mkxl new file mode 100644 index 000000000..87423d6d3 --- /dev/null +++ b/tex/context/base/mkxl/lang-hyp.mkxl @@ -0,0 +1,262 @@ +%D \module +%D [ file=lang-ini, +%D version=2014.08.10, +%D title=\CONTEXT\ Language Macros, +%D subtitle=Experimental Patterns, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D This is an experimental module. We often have to deal with titles that have +%D conflicting demands: +%D +%D \startitemize +%D \startitem They go into a dedicated space (often a graphic). \stopitem +%D \startitem The words cannot be hyphenated. \stopitem +%D \startitem But as an escape they can get hyphenated. \stopitem +%D \startitem In that case we want at least an extra word on the last line. \stopitem +%D \stopitemize +%D +%D These and maybe more cases can be dealt with using dedicated hyphenation +%D mechanisms. At he same time we want to experiment with more extensive patterns +%D as discussed in {\em TUGboat, Volume 27 (2006), No. 2—Proceedings of EuroTEX2006}. + +% lua: 5.341 5.354 +% tex: 5.174 5.262 + +\writestatus{loading}{ConTeXt Language Macros / Initialization} + +\registerctxluafile{lang-dis}{autosuffix} +\registerctxluafile{lang-hyp}{autosuffix} + +\unprotect + +\definesystemattribute[hyphenation][public] + +%D After a decade of playing with these things in \LUATEX|/|\MKIV\ it's time to +%D finish the way we deal with discretionaries. Apart from the fact that they play a +%D role in hyphenation they also need to be dealt with in fonts. Flattening, cleanup +%D and such are now more or less default in \CONTEXT\ so we can simplify some of the +%D code. We also use the new penalty mechanism. + +\newcount\compoundhyphenpenalty + +% \ifcase\contextlmtxmode +% \hyphenpenaltymode\plusfour +% \automatichyphenmode\plusone +% \fi + +\hyphenpenalty 50 % hyphenator +\automatichyphenpenalty 50 % - +\explicithyphenpenalty 50 % \- +\compoundhyphenpenalty 50 +\exceptionpenalty 1000 + +%D This command can change! At some point we will keep the setting with the +%D paragraph and then the \type {\par} can go. + +\installcorenamespace{hyphenation} +\installcorenamespace{hyphenationfeatures} + +\installparameterhandler \??hyphenation {hyphenation} +\installsetuphandler \??hyphenation {hyphenation} + +\setuphyphenation + [\c!method=\s!default, + \s!righthyphenchar=0, % number tzt g: etc + \s!lefthyphenchar=0] % number + +\appendtoks + \clf_sethyphenationmethod{\hyphenationparameter\c!method}% +\to \everysetuphyphenation + +%D These are mostly meant for manuals: + +\permanent\protected\def\starthyphenation[#1]% + {\begingroup + \clf_pushhyphenation{#1}} + +\permanent\protected\def\stophyphenation + {\ifhmode\par\fi + \clf_pophyphenation + \endgroup} + +% This is a global setting, so we need to disable it when needed. However, as +% we are (hopefully) compatible and attribute driven one can also just keep it +% enabled. +% +% \setuphyphenation +% [\c!method=\s!traditional] % no translations + +\permanent\tolerant\protected\def\definehyphenationfeatures[#1]#*[#2]% + {\begingroup + \letdummyparameter\c!characters \empty % maybe \s!characters + \letdummyparameter\c!hyphens \empty % maybe \s!hyphens + \letdummyparameter\c!joiners \empty % maybe \s!joiners + \letdummyparameter\c!rightwords \zerocount % maybe \s!rightwords + \letdummyparameter\s!lefthyphenmin \zerocount + \letdummyparameter\s!righthyphenmin \zerocount + \letdummyparameter\s!hyphenmin \zerocount + \letdummyparameter\s!lefthyphenchar \zerocount + \letdummyparameter\s!righthyphenchar\zerocount + \letdummyparameter\c!alternative \empty + \letdummyparameter\c!rightedge \empty + \letdummyparameter\c!rightchars \empty + \getdummyparameters[#2]% + \clf_definehyphenationfeatures + {#1}% + { + characters {\dummyparameter\c!characters}% + hyphens {\dummyparameter\c!hyphens}% + joiners {\dummyparameter\c!joiners}% + rightwordmin \numexpr\dummyparameter\c!rightwords\relax + rightchars {\dummyparameter\c!rightchars}% + charmin \numexpr\dummyparameter\s!hyphenmin\relax + leftcharmin \numexpr\dummyparameter\s!lefthyphenmin\relax + rightcharmin \numexpr\dummyparameter\s!righthyphenmin\relax + leftchar \numexpr\dummyparameter\s!lefthyphenchar\relax + rightchar \numexpr\dummyparameter\s!righthyphenchar\relax + alternative {\dummyparameter\c!alternative}% + rightedge {\dummyparameter\c!rightedge}% + % autohyphen {\dummyparameter\c!autohyphen} + % hyphenonly {\dummyparameter\c!hyphenonly} + }% + \relax + \endgroup} + +\permanent\protected\def\sethyphenationfeatures[#1]% + {\clf_sethyphenationfeatures{#1}} + +\permanent\protected\def\resethyphenationfeatures + {\attribute\hyphenationattribute\attributeunsetvalue} + +\resethyphenationfeatures + +% todo: \start ... \stop too + +\permanent\tolerant\protected\def\registerhyphenationpattern[#1]#*[#2]% + {\clf_registerhyphenationpattern\ifparameter#2\or{#1}{#2}\else{\currentlanguage}{#1}\fi\s!true\relax} + +\permanent\tolerant\protected\def\unregisterhyphenationpattern[#1]#*[#2]% + {\clf_registerhyphenationpattern\ifparameter#2\or{#1}{#2}\else{\currentlanguage}{#1}\fi\s!false\relax} + +\permanent\tolerant\protected\def\registerhyphenationexception[#1]#*[#2]% + {\clf_registerhyphenationexception\ifparameter#2\or{#1}{#2}\else{\currentlanguage}{#1}\fi\relax} + +\permanent\tolerant\protected\def\showhyphenationtrace[#1]#*[#2]% + {\begingroup + \tt + \clf_showhyphenationtrace\ifparameter#2\or{#1}{#2}\else{\currentlanguage}{#1}\fi\relax + \endgroup} + +% For old times sake: + +\permanent\protected\def\atleastoneword#1% + {\begingroup + \starthyphenation[traditional]% this might become default or a faster switch + \sethyphenationfeatures[words]% + #1\par + \stophyphenation + \endgroup} + +%D For me: + +\permanent\protected\def\showdiscretionaries + {\clf_showdiscretionaries} + +%D These are (at least now) not cummulative: + +\definehyphenationfeatures % just an example + [fences] + [\c!characters={[]()}] + +\definehyphenationfeatures + [words] + [\c!rightwords=1, + \s!lefthyphenmin=4, + \s!righthyphenmin=4] + +\definehyphenationfeatures + [default] + [%c!rightedge=\v!tex, + \c!hyphens=\v!yes, + \c!joiners=\v!yes] + +\definehyphenationfeatures + [strict] + [\c!rightedge=\s!tex] + +% \sethyphenationfeatures +% [fences] + +% \sethyphenationfeatures +% [default,fences] + +% \setuphyphenation % will be default +% [method=expanded] + +\protect \endinput + +% \starttext +% +% \enabledirectives[hyphenators.method=traditional] +% +% % \dorecurse{1000}{\input tufte \par} +% +% \setupalign[verytolerant,flushleft] +% \setuplayout[width=140pt] \showframe +% +% longword longword long word longword longwordword \blank +% +% \enabledirectives[hyphenators.rightwordsmin=1] +% +% longword longword long word longword longwordword\blank +% +% \disabledirectives[hyphenators.rightwordsmin] +% +% longword longword long word longword longwordword\blank +% +% \atleastoneword{longword longword long word longword longwordword} +% +% \enabledirectives[hyphenators.method=traditional] +% +% \stoptext + +% \startluacode +% -- e1ë/e=e reëel re-eel +% -- a1atje./a=t,1,3 omaatje oma-tje +% -- schif1f/ff=f,5,2 Schiffahrt Schiff-fahrt +% +% languages.hyphenators.traditional.registerpattern("en","a1b", { start = 1, length = 2, before = "CD", after = "EF" } ) +% languages.hyphenators.traditional.registerpattern("en","e1ë", { start = 1, length = 2, before = "e", after = "e" } ) +% languages.hyphenators.traditional.registerpattern("en","oo1ë", { start = 2, length = 2, before = "o", after = "e" } ) +% languages.hyphenators.traditional.registerpattern("en","qqxc9xkqq",{ start = 3, length = 4, before = "ab", after = "cd" } ) -- replacement start length +% +% -- print("reëel", injecthyphens(dictionaries.nl,"reëel", 2,2)) +% -- print("reeëel", injecthyphens(dictionaries.nl,"reeëel", 2,2)) +% -- print("rooëel", injecthyphens(dictionaries.nl,"rooëel", 2,2)) +% -- print( "QXcXkQ", injecthyphens(dictionaries.de, "QXcXkQ", 2,2)) +% -- print( "QQXcXkQQ", injecthyphens(dictionaries.de, "QQXcXkQQ", 2,2)) +% -- print( "QQQXcXkQQQ", injecthyphens(dictionaries.de, "QQQXcXkQQQ", 2,2)) +% -- print("QQQQXcXkQQQQ",injecthyphens(dictionaries.de,"QQQQXcXkQQQQ",2,2)) +% -- +% -- print( "QQXcXkQQ QQXcXkQQ", injecthyphens(dictionaries.de, "QQXcXkQQ QQXcXkQQ", 2,2)) +% \stopluacode +% +% \starttext +% +% \blank +% +% xreëel rooëel \par xxabxx xxxabxxx \par +% +% \hsize1mm \lefthyphenmin2 \righthyphenmin2 +% +% \blank Capacity \blank capacity \blank xyabxy \blank xreëel \blank rooëel \blank +% +% xy\discretionary{CD}{EF}{ab}xy % xxacceedxxx +% +% \stoptext diff --git a/tex/context/base/mkiv/lang-ini.lmt b/tex/context/base/mkxl/lang-ini.lmt index 5f2dd1a55..5f2dd1a55 100644 --- a/tex/context/base/mkiv/lang-ini.lmt +++ b/tex/context/base/mkxl/lang-ini.lmt diff --git a/tex/context/base/mkiv/lang-ini.mkxl b/tex/context/base/mkxl/lang-ini.mkxl index 8ca8d7e8e..6a230e165 100644 --- a/tex/context/base/mkiv/lang-ini.mkxl +++ b/tex/context/base/mkxl/lang-ini.mkxl @@ -357,7 +357,7 @@ \appendtoks % we need to reassign the number because new patterns can be defined later on % so let's hope not that many \setups happen during a run - \global\letcsname\??languagenumbers\currentlanguage\endcsname\undefined + \gletcsname\??languagenumbers\currentlanguage\endcsname\undefined \to \everysetuplanguage \def\lang_basics_synchronize_yes diff --git a/tex/context/base/mkiv/lang-lab.mkxl b/tex/context/base/mkxl/lang-lab.mkxl index 8968631a0..8968631a0 100644 --- a/tex/context/base/mkiv/lang-lab.mkxl +++ b/tex/context/base/mkxl/lang-lab.mkxl diff --git a/tex/context/base/mkiv/lang-mis.mkxl b/tex/context/base/mkxl/lang-mis.mkxl index de15ec526..de15ec526 100644 --- a/tex/context/base/mkiv/lang-mis.mkxl +++ b/tex/context/base/mkxl/lang-mis.mkxl diff --git a/tex/context/base/mkxl/lang-rep.mkxl b/tex/context/base/mkxl/lang-rep.mkxl new file mode 100644 index 000000000..36e484242 --- /dev/null +++ b/tex/context/base/mkxl/lang-rep.mkxl @@ -0,0 +1,74 @@ +%D \module +%D [ file=lang-rep, +%D version=2013.04.28, +%D title=\CONTEXT\ Language Macros, +%D subtitle=Substitution, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D As I needed an example of messing with nodes for the bacho\TEX\ tutorial +%D I cooked up this. In the end I decided to stick to a simpler example and +%D just finished this off in case someone really needs it. + +\writestatus{loading}{ConTeXt Language Macros / Replacements} + +\unprotect + +\registerctxluafile{lang-rep}{} + +\definesystemattribute[replacements][public,global] + +%D \startluacode +%D +%D -- todo: other nodes (prelude to more experiments with auto dropped caps) +%D +%D languages.replacements.add("basics", { +%D ["aap"] = "monkey", +%D ["noot"] = "nut", +%D ["never"] = "forever", +%D ["newer"] = "cooler", +%D ["new"] = "cool", +%D -- ["special"] = "veryspe{>>>}{<<<}{=}cial", +%D }) +%D +%D \stopluacode +%D +%D \replaceword[more][this][that] +%D \replaceword[more][crap][support] +%D \replaceword[more][---][—] +%D \replaceword[basics][special][veryspe{>>>}{<<<}{=}cial] +%D +%D \starttyping +%D \start \setreplacements[basics] What the heck, it's now or never, isn't it new? \par \stop +%D \start \setreplacements[more] Do we --- {\it really} --- need this kind of crap? \par \stop +%D \start \setreplacements[basics] All kinds of special thingies! \par \stop +%D \start \setreplacements[basics] \hsize1mm special \par \stop +%D \stoptyping + +\permanent\protected\def\setreplacements[#1]% + {\clf_setreplacements{#1}} + +\permanent\protected\def\resetreplacements + {\c_attr_replacements\attributeunsetvalue} + +\permanent\tolerant\protected\def\replaceword[#1]#*[#2]#*[#3]% + {\ifarguments\or\or + \clf_addreplacementslist{#1}{#2}% + \or + \clf_addreplacements{#1}{#2}{#3}% + \fi} + +\appendtoks + \resetreplacements +\to \everyresettypesetting + +\appendtoks + \resetreplacements +\to \everyinitializeverbatim + +\protect \endinput diff --git a/tex/context/base/mkxl/lang-spa.mkxl b/tex/context/base/mkxl/lang-spa.mkxl new file mode 100644 index 000000000..3e4972acb --- /dev/null +++ b/tex/context/base/mkxl/lang-spa.mkxl @@ -0,0 +1,74 @@ +%D \module +%D [ file=lang-spa, +%D version=2002.04.17, +%D title=\CONTEXT\ Language Macros, +%D subtitle=Spacing, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Language Macros / Spacing} + +%D This module was created in the process of enhancing support for French (with the +%D help of Daniel Flipo). +%D +%D This will (or already has) become obsolete! + +\unprotect + +\definehspace [\s!fr] [quotation] [\flexiblespaceamount{.8}{.3}{.8}] +\definehspace [\s!fr] [sentence] [\fixedspaceamount{1}] + +%definehspace [\s!fr] [quote] [\flexiblespaceamount{.8}{.3}{.8}] +%definehspace [\s!fr] [speech] [\flexiblespaceamount{.8}{.3}{.8}] + +\definehspace [\s!fr] [interquotation] [\zeropoint] +\definehspace [\s!fr] [intersentence] [\zeropoint] + +\definehspace [\string :] [\zeropoint] +\definehspace [\string ;] [\zeropoint] +\definehspace [\string !] [\zeropoint] +\definehspace [\string ?] [\zeropoint] + +\definehspace [\s!fr] [\string :] [\spaceamount] +\definehspace [\s!fr] [\string ;] [.16667em] +\definehspace [\s!fr] [\string !] [.16667em] +\definehspace [\s!fr] [\string ?] [.16667em] + +%D Alternative discretionary handlers: + +%definetextmodediscretionary : {\removeunwantedspaces\prewordbreak\kern\hspaceamount\currentlanguage{:}:} +%definetextmodediscretionary ; {\removeunwantedspaces\prewordbreak\kern\hspaceamount\currentlanguage{;};} +%definetextmodediscretionary ? {\removeunwantedspaces\prewordbreak\kern\hspaceamount\currentlanguage{?}?} +%definetextmodediscretionary ! {\removeunwantedspaces\prewordbreak\kern\hspaceamount\currentlanguage{!}!} + +\definetextmodediscretionary : {\removeunwantedspaces\wordboundary\kern\hspaceamount\currentlanguage{:}:} +\definetextmodediscretionary ; {\removeunwantedspaces\wordboundary\kern\hspaceamount\currentlanguage{;};} +\definetextmodediscretionary ? {\removeunwantedspaces\wordboundary\kern\hspaceamount\currentlanguage{?}?} +\definetextmodediscretionary ! {\removeunwantedspaces\wordboundary\kern\hspaceamount\currentlanguage{!}!} + +%D \startbuffer +%D \mainlanguage[en] \quotation{test \quotation{test} test}\par +%D \mainlanguage[nl] \quotation{test \quotation{test} test}\par +%D \mainlanguage[fr] \quotation{test \quotation{test} test}\par +%D +%D \mainlanguage[en] \quotation{\quotation{test} test}\par +%D \mainlanguage[nl] \quotation{\quotation{test} test}\par +%D \mainlanguage[fr] \quotation{\quotation{test} test}\par +%D +%D \mainlanguage[en] |<|test |<|test|>| test|>| \par +%D \mainlanguage[nl] |<|test |<|test|>| test|>| \par +%D \mainlanguage[fr] |<|test |<|test|>| test|>| \par +%D +%D \mainlanguage[en] |<||<|test|>| test|>| \par +%D \mainlanguage[nl] |<||<|test|>| test|>| \par +%D \mainlanguage[fr] |<||<|test|>| test|>| \par +%D \stopbuffer +%D +%D \typebuffer {\getbuffer} + +\protect \endinput diff --git a/tex/context/base/mkxl/lang-tra.mkxl b/tex/context/base/mkxl/lang-tra.mkxl new file mode 100644 index 000000000..b087832e0 --- /dev/null +++ b/tex/context/base/mkxl/lang-tra.mkxl @@ -0,0 +1,95 @@ +%D \module +%D [ file=lang-tra, +%D version=2020.10.31, +%D title=\CONTEXT\ Language Macros, +%D subtitle=Transliteration, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Language Macros / Transliteration} + +\registerctxluafile{lang-tra}{} + +\unprotect + +\definesystemattribute[transliteration][public,global] + +\installcorenamespace {transliteration} + +\permanent\tolerant\protected\def\definetransliteration[#1]#*[#2]% + {\clf_definedtransliteration{#1}{#2}} + +\permanent\protected\def\settransliteration[#1]% + {\clf_settransliteration{#1}} + +\permanent\protected\def\starttransliteration[#1]% + {\begingroup + \clf_settransliteration{#1}} + +\permanent\protected\def\stoptransliteration + {\endgroup} + +\permanent\protected\def\resettransliteration + {\c_attr_transliteration\attributeunsetvalue} + +\appendtoks + \resettransliteration +\to \everyinitializeverbatim + +\protect \endinput + +% \setupbodyfont[dejavu] +% +% \input lang-tra.mkiv +% +% \definetransliteration[serbian][serbian to latin] +% +% \starttext +% +% \settransliteration[serbian to latin] +% +% \startchapter[title={АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ}] +% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ +% \start +% \settransliteration[serbian to latin] +% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ +% \stop +% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ +% \stopchapter +% +% \resettransliteration +% +% \startchapter[title={АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ}] +% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ +% \start +% \settransliteration[serbian to latin] +% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ +% \stop +% АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ +% \stopchapter +% +% \definehead[ChapterA][chapter] +% \definehead[ChapterB][chapter] +% +% \startsetups s-to-l +% \settransliteration[serbian to latin] +% \red +% \stopsetups +% +% % maybe we need a setups key for this +% % hm, \definesetups [xxx] [aa,bb,cc] +% +% \setuphead[ChapterB][commandbefore=\setups{s-to-l}] +% +% \startChapterA[title={АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ}] +% \stopChapterA +% +% \startChapterB[title={АБВ ГДЕ ЖЗИЙ КЛМНОП РСТУ ФХЦЧ ШЩЪЬ ЮЯ}] +% \stopChapterB +% +% \stoptext diff --git a/tex/context/base/mkiv/lang-url.mkxl b/tex/context/base/mkxl/lang-url.mkxl index bb51f838a..bb51f838a 100644 --- a/tex/context/base/mkiv/lang-url.mkxl +++ b/tex/context/base/mkxl/lang-url.mkxl diff --git a/tex/context/base/mkxl/lang-wrd.mkxl b/tex/context/base/mkxl/lang-wrd.mkxl new file mode 100644 index 000000000..d0964a677 --- /dev/null +++ b/tex/context/base/mkxl/lang-wrd.mkxl @@ -0,0 +1,67 @@ +%D \module +%D [ file=lang-wrd, +%D version=2006.XX.XX, +%D title=\CONTEXT\ Language Macros, +%D subtitle=Checking, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Experimental. + +\writestatus{loading}{ConTeXt Language Macros / Checking} + +\registerctxluafile{lang-wrd}{} + +\unprotect + +% \loadspellchecklist[en][words-en.txt] +% \loadspellchecklist[us][words-en.txt] +% \loadspellchecklist[nl][words-nl.txt] +% \setupspellchecking[state=start,method=1] +% +% \setupspellchecking[state=start,method=2] +% ... +% \typefile{\jobname.words} +% +% beware, maybe some day we will honour grouping +% +% 1: spell checking +% 2: word counting +% 3: language coloring + +\installcorenamespace{spell} + +\installdirectcommandhandler \??spell {spellchecking} + +\appendtoks + \doifelse{\directspellcheckingparameter\c!state}\v!start + {\clf_enablespellchecking + method {\directspellcheckingparameter\c!method}% + list {\directspellcheckingparameter\c!list}% + \relax} + {\clf_disablespellchecking}% +\to \everysetupspellchecking + +\permanent\tolerant\protected\def\loadspellchecklist[#1]#*[#2]% can be public implementor + {\clf_loadspellchecklist{#1}{#2}} + +\setupspellchecking + [\c!state=\v!stop, + \c!method=1, + \c!list=] + +\definecolor[word:yes] [g=.75] +\definecolor[word:no] [r=.75] + +%definecolor[word:unset] [s=.75] +\definecolor[word:en] [b=.75] +\definecolor[word:de] [r=.75] +\definecolor[word:nl] [g=.75] +\definecolor[word:unknown][r=.75,g=.75] + +\protect \endinput diff --git a/tex/context/base/mkiv/layo-ini.mkxl b/tex/context/base/mkxl/layo-ini.mkxl index 4979989cd..4979989cd 100644 --- a/tex/context/base/mkiv/layo-ini.mkxl +++ b/tex/context/base/mkxl/layo-ini.mkxl diff --git a/tex/context/base/mkiv/libs-imp-curl.lmt b/tex/context/base/mkxl/libs-imp-curl.lmt index b30739794..b30739794 100644 --- a/tex/context/base/mkiv/libs-imp-curl.lmt +++ b/tex/context/base/mkxl/libs-imp-curl.lmt diff --git a/tex/context/base/mkiv/libs-imp-ghostscript.lmt b/tex/context/base/mkxl/libs-imp-ghostscript.lmt index b129a58c1..b129a58c1 100644 --- a/tex/context/base/mkiv/libs-imp-ghostscript.lmt +++ b/tex/context/base/mkxl/libs-imp-ghostscript.lmt diff --git a/tex/context/base/mkiv/libs-imp-graphicsmagick.lmt b/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt index 6f5d1d967..6f5d1d967 100644 --- a/tex/context/base/mkiv/libs-imp-graphicsmagick.lmt +++ b/tex/context/base/mkxl/libs-imp-graphicsmagick.lmt diff --git a/tex/context/base/mkiv/libs-imp-kpse.lmt b/tex/context/base/mkxl/libs-imp-kpse.lmt index f8e4a9907..f8e4a9907 100644 --- a/tex/context/base/mkiv/libs-imp-kpse.lmt +++ b/tex/context/base/mkxl/libs-imp-kpse.lmt diff --git a/tex/context/base/mkiv/libs-imp-kpse.mkxl b/tex/context/base/mkxl/libs-imp-kpse.mkxl index f76c99029..f76c99029 100644 --- a/tex/context/base/mkiv/libs-imp-kpse.mkxl +++ b/tex/context/base/mkxl/libs-imp-kpse.mkxl diff --git a/tex/context/base/mkiv/libs-imp-mujs.lmt b/tex/context/base/mkxl/libs-imp-mujs.lmt index 264c8e531..264c8e531 100644 --- a/tex/context/base/mkiv/libs-imp-mujs.lmt +++ b/tex/context/base/mkxl/libs-imp-mujs.lmt diff --git a/tex/context/base/mkiv/libs-imp-mujs.mkxl b/tex/context/base/mkxl/libs-imp-mujs.mkxl index a8fe5801f..a8fe5801f 100644 --- a/tex/context/base/mkiv/libs-imp-mujs.mkxl +++ b/tex/context/base/mkxl/libs-imp-mujs.mkxl diff --git a/tex/context/base/mkiv/libs-imp-mysql.lmt b/tex/context/base/mkxl/libs-imp-mysql.lmt index 3e938a6de..3e938a6de 100644 --- a/tex/context/base/mkiv/libs-imp-mysql.lmt +++ b/tex/context/base/mkxl/libs-imp-mysql.lmt diff --git a/tex/context/base/mkiv/libs-imp-postgress.lmt b/tex/context/base/mkxl/libs-imp-postgress.lmt index 629079b01..629079b01 100644 --- a/tex/context/base/mkiv/libs-imp-postgress.lmt +++ b/tex/context/base/mkxl/libs-imp-postgress.lmt diff --git a/tex/context/base/mkiv/libs-imp-sqlite.lmt b/tex/context/base/mkxl/libs-imp-sqlite.lmt index 5d38986f3..5d38986f3 100644 --- a/tex/context/base/mkiv/libs-imp-sqlite.lmt +++ b/tex/context/base/mkxl/libs-imp-sqlite.lmt diff --git a/tex/context/base/mkiv/libs-imp-zint.lmt b/tex/context/base/mkxl/libs-imp-zint.lmt index 2c346ae7d..2c346ae7d 100644 --- a/tex/context/base/mkiv/libs-imp-zint.lmt +++ b/tex/context/base/mkxl/libs-imp-zint.lmt diff --git a/tex/context/base/mkiv/libs-imp-zint.mkxl b/tex/context/base/mkxl/libs-imp-zint.mkxl index fbea52888..b2adf05ad 100644 --- a/tex/context/base/mkiv/libs-imp-zint.mkxl +++ b/tex/context/base/mkxl/libs-imp-zint.mkxl @@ -28,7 +28,7 @@ \definefont[usedzintfont][dejavusansmono at 10bp] -\unexpanded\def\barcode[#1]% [alternative=,text=] +\permanent\protected\def\barcode[#1]% [alternative=,text=] {\bgroup \usedzintfont \getdummyparameters diff --git a/tex/context/base/mkiv/libs-ini.mkxl b/tex/context/base/mkxl/libs-ini.mkxl index e04c7c193..d77046fbf 100644 --- a/tex/context/base/mkiv/libs-ini.mkxl +++ b/tex/context/base/mkxl/libs-ini.mkxl @@ -26,7 +26,7 @@ \unprotect -% \unexpanded\def\uselibrary[#1]% +% \permanent\protected\def\uselibrary[#1]% % {\clf_uselibrary{#1}} \protect \endinput diff --git a/tex/context/base/mkiv/lpdf-emb.lmt b/tex/context/base/mkxl/lpdf-emb.lmt index d2da4473a..d2da4473a 100644 --- a/tex/context/base/mkiv/lpdf-emb.lmt +++ b/tex/context/base/mkxl/lpdf-emb.lmt diff --git a/tex/context/base/mkiv/lpdf-img.lmt b/tex/context/base/mkxl/lpdf-img.lmt index fc53740f6..fc53740f6 100644 --- a/tex/context/base/mkiv/lpdf-img.lmt +++ b/tex/context/base/mkxl/lpdf-img.lmt diff --git a/tex/context/base/mkiv/lpdf-lmt.lmt b/tex/context/base/mkxl/lpdf-lmt.lmt index 2bbf5ba61..2bbf5ba61 100644 --- a/tex/context/base/mkiv/lpdf-lmt.lmt +++ b/tex/context/base/mkxl/lpdf-lmt.lmt diff --git a/tex/context/base/mkiv/lpdf-vfc.lmt b/tex/context/base/mkxl/lpdf-vfc.lmt index 65b863203..65b863203 100644 --- a/tex/context/base/mkiv/lpdf-vfc.lmt +++ b/tex/context/base/mkxl/lpdf-vfc.lmt diff --git a/tex/context/base/mkxl/luat-bas.mkxl b/tex/context/base/mkxl/luat-bas.mkxl new file mode 100644 index 000000000..0add4ce69 --- /dev/null +++ b/tex/context/base/mkxl/luat-bas.mkxl @@ -0,0 +1,52 @@ +%D \module +%D [ file=luat-bas, % moved from luat-lib, +%D version=2006.09.11, +%D title=\CONTEXT\ Lua Macros, +%D subtitle=Basic \LUA\ Libraries, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Lua Macros / Basic Lua Libraries} + +\registerctxluafile{l-bit32} {} % before sandbox +\registerctxluafile{l-lua} {} % before sandbox +\registerctxluafile{l-macro} {} +\registerctxluafile{l-sandbox} {} +\registerctxluafile{l-package} {} +\registerctxluafile{l-lpeg} {} +\registerctxluafile{l-function}{} +\registerctxluafile{l-string} {} +\registerctxluafile{l-table} {} +\registerctxluafile{l-boolean} {} +\registerctxluafile{l-number} {} +\registerctxluafile{l-math} {} +%registerctxluafile{l-aux} {} +\registerctxluafile{l-io} {} +\registerctxluafile{l-os} {} +\registerctxluafile{l-file} {} +\registerctxluafile{l-gzip} {} +\registerctxluafile{l-md5} {} +\registerctxluafile{l-sha} {} +\registerctxluafile{l-dir} {} +\registerctxluafile{l-unicode} {optimize} +%registerctxluafile{l-utils} {} +\registerctxluafile{l-url} {} +\registerctxluafile{l-set} {} + +\registerctxluafile{l-macro-imp-optimize}{} + +% \registerctxluafile{socket}{} +% \registerctxluafile{ltn12} {} +% \registerctxluafile{mime} {} +% \registerctxluafile{http} {} +% \registerctxluafile{url} {} +% \registerctxluafile{tp} {} +% \registerctxluafile{ftp} {} +% %registerctxluafile{smtp} {} + +\endinput diff --git a/tex/context/base/mkiv/luat-cod.lmt b/tex/context/base/mkxl/luat-cod.lmt index e4432345e..e4432345e 100644 --- a/tex/context/base/mkiv/luat-cod.lmt +++ b/tex/context/base/mkxl/luat-cod.lmt diff --git a/tex/context/base/mkiv/luat-cod.mkxl b/tex/context/base/mkxl/luat-cod.mkxl index fec88aecd..fec88aecd 100644 --- a/tex/context/base/mkiv/luat-cod.mkxl +++ b/tex/context/base/mkxl/luat-cod.mkxl diff --git a/tex/context/base/mkiv/luat-fio.lmt b/tex/context/base/mkxl/luat-fio.lmt index c70ed54e4..c70ed54e4 100644 --- a/tex/context/base/mkiv/luat-fio.lmt +++ b/tex/context/base/mkxl/luat-fio.lmt diff --git a/tex/context/base/mkxl/luat-ini.mkxl b/tex/context/base/mkxl/luat-ini.mkxl new file mode 100644 index 000000000..4f6556eda --- /dev/null +++ b/tex/context/base/mkxl/luat-ini.mkxl @@ -0,0 +1,296 @@ +%D \module +%D [ file=luat-ini, +%D version=2005.08.11, +%D title=\CONTEXT\ Lua Macros, +%D subtitle=Initialization, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Lua Macros / Initialization} + +\unprotect + +%D Loading lua code can be done using \type {startup.lua}. The following method uses +%D the \TEX\ input file locator of kpse. At least we need to use that way of loading +%D when we haven't yet define our own code, which we keep outside the format. We +%D will keep code outside \TEX\ files as much as possible. The solutions evolved +%D with the engine but one can find some history in the \MKIV\ files and articles. + +\ifdefined\setnaturalcatcodes \else \let\setnaturalcatcodes\relax \fi +\ifdefined\obeylualines \else \let\obeylualines \relax \fi +\ifdefined\obeyluatokens \else \let\obeyluatokens \relax \fi + +%D A few more goodies: + +\aliased\let\stoplua \relax % tex catcodes +\aliased\let\stopluacode\relax % lua catcodes + +%D It might makes sense to have a \type {\directelua} so that we can avoid the \type +%D {\normalexpanded} around \type {\directlua}. Something to discuss in the team. + +\permanent\protected\def\startlua % \stoplua + {\begingroup + \obeylualines + \luat_start_lua_indeed} + +\def\luat_start_lua_indeed#1\stoplua + {\normalexpanded{\endgroup\noexpand\directlua{#1}}} % \zerocount is default + +\permanent\protected\def\startluacode % \stopluacode + {\begingroup + \obeylualines + \obeyluatokens + \luat_start_lua_code_indeed} + +\def\luat_start_lua_code_indeed#1\stopluacode + {\normalexpanded{\endgroup\noexpand\directlua{#1}}} % \zerocount is default + +%D Some delayed definitions: + +\ifdefined\obeylines \else \let\obeylines \relax \fi +\ifdefined\obeyedline \else \let\obeyedline \relax \fi +\ifdefined\obeyspaces \else \let\obeyspaces \relax \fi +\ifdefined\obeyedspace \else \let\obeyedspace \relax \fi + +\let\obeylualines\relax + +\newtoks\everyluacode + +%D It is nicer for checking with \type {s-system-macros} if we have some meaning: + +\ifdefined\n \else \def\n{n} \fi \ifdefined\r \else \def\r{r} \fi +\ifdefined\f \else \def\f{f} \fi \ifdefined\t \else \def\t{t} \fi +\ifdefined\a \else \def\a{a} \fi \ifdefined\b \else \def\b{b} \fi +\ifdefined\v \else \def\v{v} \fi \ifdefined\s \else \def\s{s} \fi + +\ifdefined\+ \else \def\+{+} \fi \ifdefined\- \else \def\-{-} \fi + +\ifdefined\1 \else \def\1{1} \fi \ifdefined\2 \else \def\2{2} \fi +\ifdefined\3 \else \def\3{3} \fi \ifdefined\4 \else \def\4{4} \fi +\ifdefined\5 \else \def\5{5} \fi \ifdefined\6 \else \def\6{6} \fi +\ifdefined\7 \else \def\7{7} \fi \ifdefined\8 \else \def\8{8} \fi +\ifdefined\9 \else \def\9{9} \fi \ifdefined\0 \else \def\0{0} \fi + +\immutable\edef\lua_letter_backslash{\string\\} +\immutable\edef\lua_letter_bar {\string\|} \immutable\edef\lua_letter_dash {\string\-} +\immutable\edef\lua_letter_lparent {\string\(} \immutable\edef\lua_letter_rparent {\string\)} +\immutable\edef\lua_letter_lbrace {\string\{} \immutable\edef\lua_letter_rbrace {\string\}} +\immutable\edef\lua_letter_squote {\string\'} \immutable\edef\lua_letter_dquote {\string\"} +\immutable\edef\lua_letter_n {\string\n} \immutable\edef\lua_letter_r {\string\r} +\immutable\edef\lua_letter_f {\string\f} \immutable\edef\lua_letter_t {\string\t} +\immutable\edef\lua_letter_a {\string\a} \immutable\edef\lua_letter_b {\string\b} +\immutable\edef\lua_letter_v {\string\v} \immutable\edef\lua_letter_s {\string\s} +\immutable\edef\lua_letter_one {\string\1} \immutable\edef\lua_letter_two {\string\2} +\immutable\edef\lua_letter_three {\string\3} \immutable\edef\lua_letter_four {\string\4} +\immutable\edef\lua_letter_five {\string\5} \immutable\edef\lua_letter_six {\string\6} +\immutable\edef\lua_letter_seven {\string\7} \immutable\edef\lua_letter_eight {\string\8} +\immutable\edef\lua_letter_nine {\string\9} \immutable\edef\lua_letter_zero {\string\0} + +\pushoverloadmode + \let\-\explicitdiscretionary +\popoverloadmode + +\everyluacode {% \appendtoks + \enforced\let\\\lua_letter_backslash + \enforced\let\|\lua_letter_bar \enforced\let\-\lua_letter_dash + \enforced\let\(\lua_letter_lparent \enforced\let\)\lua_letter_rparent + \enforced\let\{\lua_letter_lbrace \enforced\let\}\lua_letter_rbrace + \enforced\let\'\lua_letter_squote \enforced\let\"\lua_letter_dquote + \enforced\let\n\lua_letter_n \enforced\let\r\lua_letter_r + \enforced\let\f\lua_letter_f \enforced\let\t\lua_letter_t + \enforced\let\a\lua_letter_a \enforced\let\b\lua_letter_b + \enforced\let\v\lua_letter_v \enforced\let\s\lua_letter_s + \enforced\let\1\lua_letter_one \enforced\let\2\lua_letter_two + \enforced\let\3\lua_letter_three \enforced\let\4\lua_letter_four + \enforced\let\5\lua_letter_five \enforced\let\6\lua_letter_six + \enforced\let\7\lua_letter_seven \enforced\let\8\lua_letter_eight + \enforced\let\9\lua_letter_nine \enforced\let\0\lua_letter_zero +} % \to \everyluacode + +\permanent\protected\def\obeyluatokens + {\setcatcodetable\luacatcodes + \the\everyluacode} + +\immutable\edef\luamajorversion{\ctxwrite{LUAMINORVERSION}} +\immutable\edef\luaminorversion{\ctxwrite{LUAMAJORVERSION}} + +%D We need a way to pass strings safely to \LUA\ without the need for tricky +%D escaping. Compare: +%D +%D \starttyping +%D \ctxlua {something("anything tricky can go here")} +%D \ctxlua {something([\luastringsep[anything tricky can go here]\luastringsep])} +%D \stoptyping + +\def\luastringsep{===} % this permits \typefile{self} otherwise nested b/e sep problems + +\edef\!!bs{[\luastringsep[} +\edef\!!es{]\luastringsep]} + +%D We have a the following available as primitive so there is no need for it: +%D +%D \starttyping +%D \edef\luaescapestring#1{\!!bs#1\!!es} +%D \stoptyping + +\permanent\protected\def\setdocumentfilename #1#2{\clf_setdocumentfilename\numexpr#1\relax{#2}} +\permanent \def\getdocumentfilename #1{\clf_getdocumentfilename\numexpr#1\relax} +\permanent\protected\def\setdocumentargument #1#2{\clf_setdocumentargument{#1}{#2}} +\permanent \def\getdocumentargument #1{\clf_getdocumentargument{#1}{}} +\permanent\protected\def\setdocumentargumentdefault#1#2{\clf_setdocumentdefaultargument{#1}{#2}} +\permanent \def\getdocumentargumentdefault#1#2{\clf_getdocumentargument{#1}{#2}} + +% seldom used so no need for speedy variants: + +\permanent\def\doifelsedocumentargument #1{\doifelsesomething{\clf_getdocumentargument{#1}}} +\permanent\def\doifdocumentargument #1{\doifsomething {\clf_getdocumentargument{#1}}} +\permanent\def\doifnotdocumentargument #1{\doifnothing {\clf_getdocumentargument{#1}}} +\permanent\def\doifelsedocumentfilename #1{\doifelsesomething{\clf_getdocumentfilename\numexpr#1\relax}} +\permanent\def\doifdocumentfilename #1{\doifsomething {\clf_getdocumentfilename\numexpr#1\relax}} +\permanent\def\doifnotdocumentfilename #1{\doifnothing {\clf_getdocumentfilename\numexpr#1\relax}} + +\aliased\let\doifdocumentargumentelse\doifelsedocumentargument +\aliased\let\doifdocumentfilenameelse\doifelsedocumentfilename + +%D A handy helper: + +\permanent\def\luaexpanded#1{\luaescapestring\expandafter{\normalexpanded{#1}}} + +%D Experimental: + +\permanent\protected\def\startluaparameterset[#1]% \stopluaparameterset + {\begingroup + \obeylualines + \obeyluatokens + \luat_start_lua_parameter_set{#1}} + +\def\luat_start_lua_parameter_set#1#2\stopluaparameterset + {\ctxlua{parametersets["#1"]={#2}}% + \endgroup} + +\aliased\let\stopluaparameterset\relax + +\permanent\def\luaparameterset#1#2{\ctxlua{parametersets["#1"]={#2} context("#1")}} + +% todo: \mergeparameterset + +% usage: +% +% \startluaparameterset [u3d:myset:display:1] +% toolbar=false, +% tree=true +% \stopluaparameterset +% +% option=u3d:myset:display:1 +% +% or: +% +% option=\luaparameterset{u3d:myset:display:1}{toolbar=false,tree=true} + +%D A Handy helper: + +\permanent\def\luaconditional#1{\ifcase#1tru\else fals\fi e} + +%D Goodie: +%D +%D \starttyping +%D \ctxluacode{context("%0.5f",1/3)} +%D \stoptyping + +\permanent\protected\def\ctxluacode + {\begingroup + \obeylualines + \obeyluatokens + \catcode\leftbraceasciicode \plusone + \catcode\rightbraceasciicode\plustwo + \afterassignment\luat_lua_code + \scratchtoks=} + +% Hm, are we sure that the \* commands work out okay here? We could probably +% use \setcatcodetable\luacatcodes instead of \obeyluatokens now. + +\def\luat_lua_code + {\normalexpanded{\endgroup\noexpand\directlua\expandafter{\the\scratchtoks}}} % \zerocount is default + +% \startctxfunction MyFunctionA +% context(" A1 ") +% \stopctxfunction +% +% \startctxfunctiondefinition MyFunctionB +% context(" B2 ") +% \stopctxfunctiondefinition +% +% \starttext +% \dorecurse{10000}{\ctxfunction{MyFunctionA}} \page +% \dorecurse{10000}{\MyFunctionB} \page +% \dorecurse{10000}{\ctxlua{context(" C3 ")}} \page +% \stoptext + +\installsystemnamespace{ctxfunction} + +\permanent\protected\def\startctxfunctiondefinition #1 % \stopctxfunctiondefinition + {\begingroup \obeylualines \obeyluatokens \luat_start_lua_function_definition_indeed{#1}} + +\installsystemnamespace{luafunction} + +\def\luat_start_lua_function_definition_indeed#1#2\stopctxfunctiondefinition + {\endgroup + \expandafter\chardef\csname\??luafunction#1\endcsname\ctxcommand{ctxfunction(\!!bs#2\!!es)}\relax + \edefcsname#1\endcsname{\noexpand\luafunction\csname\??luafunction#1\endcsname}} + +\permanent\protected\def\setctxluafunction#1#2% experiment + {\expandafter\chardef\csname\??luafunction#1\endcsname#2\relax + \edefcsname#1\endcsname{\noexpand\luafunction\csname\??luafunction#1\endcsname}} + +\aliased\let\stopctxfunctiondefinition\relax + +\permanent\protected\def\startctxfunction #1 % \stopctxfunction + {\begingroup \obeylualines \obeyluatokens \luat_start_lua_function_indeed{#1}} + +\def\luat_start_lua_function_indeed#1#2\stopctxfunction + {\endgroup\edefcsname\??ctxfunction#1\endcsname{\noexpand\luafunction\ctxcommand{ctxfunction(\!!bs#2\!!es)}\relax}} + +\aliased\let\stopctxfunction\relax + +\permanent\def\ctxfunction#1% + {\begincsname\??ctxfunction#1\endcsname} + +%D In theory this is faster due to the call not being wrapped in a function but in +%D practice the speedup can't be noticed. The actions called for often have lots of +%D lookups so an extra one doesn't matter much. The kind of calls differs a lot per +%D document and often there are other ways to optimize a style. For instance we can +%D gain a lot when defining a font, but when a frozen definition is used that gain +%D gets completely lost. For some calls (take list writers) it can get worse if only +%D because readability gets worse and passing is already efficient due to selective +%D flushing, while with the token scanners one has to scan all of them. + +% \startctxfunctiondefinition foo commands.foo() \stopctxfunctiondefinition +% +% \installctxfunction\foo{commands.foo} + +\protected\def\installctxfunction#1#2% expandable + {\edef\m_syst_name{\csstring#1}% + \global\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxfunction(\!!bs#2\!!es,true)}\relax} + +\protected\def\installctxscanner#1#2% expandable + {\edef\m_syst_name{\csstring#1}% + \global\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxscanner("\m_syst_name",\!!bs#2\!!es,true)}\relax} + +\protected\def\installprotectedctxfunction#1#2% protected + {\edef\m_syst_name{\csstring#1}% + \global\protected\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxfunction(\!!bs#2\!!es,true)}\relax} + +\protected\def\installprotectedctxscanner#1#2% protected + {\edef\m_syst_name{\csstring#1}% + \global\protected\expandafter\normalluadef\csname\m_syst_name\endcsname\ctxcommand{ctxscanner("\m_syst_name",\!!bs#2\!!es,true)}\relax} + +\protected\def\resetctxscanner#1% + {\edef\m_syst_name{\csstring#1}% + \gletcsname\m_syst_name\endcsname\relax} + +\protect \endinput diff --git a/tex/context/base/mkxl/luat-lib.mkxl b/tex/context/base/mkxl/luat-lib.mkxl new file mode 100644 index 000000000..d4d3e860f --- /dev/null +++ b/tex/context/base/mkxl/luat-lib.mkxl @@ -0,0 +1,104 @@ +%D \module +%D [ file=luat-lib, +%D version=2006.09.11, +%D title=\CONTEXT\ Lua Macros, +%D subtitle=Libraries, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Lua Macros / Libraries} + +\registerctxluafile{util-str}{} +\registerctxluafile{util-tab}{} +\registerctxluafile{util-fil}{optimize} +\registerctxluafile{util-sac}{optimize} +\registerctxluafile{util-sto}{} % could also be done in trac-deb.mkiv +\registerctxluafile{util-pck}{} +\registerctxluafile{util-prs}{} +\registerctxluafile{util-fmt}{} +\registerctxluafile{util-dim}{} + +\registerctxluafile{trac-set}{} +\registerctxluafile{luat-log}{autosuffix} +\registerctxluafile{trac-inf}{autosuffix} +\registerctxluafile{util-lua}{} +\registerctxluafile{util-deb}{} % could also be done in trac-deb.mkiv + +\registerctxluafile{util-tpl}{} % needs tracker +\registerctxluafile{util-seq}{} + +\registerctxluafile{util-sta}{} + +\registerctxluafile{util-sbx}{} % needs tracker and templates + +\registerctxluafile{util-soc-imp-reset} {} +\registerctxluafile{util-soc-imp-socket} {} +\registerctxluafile{util-soc-imp-ltn12} {} +\registerctxluafile{util-soc-imp-mime} {} +\registerctxluafile{util-soc-imp-url} {} +\registerctxluafile{util-soc-imp-headers}{} +\registerctxluafile{util-soc-imp-http} {} +\registerctxluafile{util-soc-imp-tp} {} + +\registerctxluafile{util-zip}{} + +\registerctxluafile{data-ini}{} +\registerctxluafile{data-exp}{} +\registerctxluafile{data-env}{} +\registerctxluafile{data-tmp}{} +\registerctxluafile{data-met}{} +\registerctxluafile{data-res}{} +\registerctxluafile{data-inp}{} +\registerctxluafile{data-out}{} +\registerctxluafile{data-fil}{} % opener gets overloaded in data-tex + +\registerctxluafile{data-pre}{} % after data-res +\registerctxluafile{data-bin}{} % before data-tex +\registerctxluafile{data-tex}{} % after data-pre +\registerctxluafile{data-vir}{} +\registerctxluafile{data-zip}{} +%registerctxluafile{data-crl}{} +\registerctxluafile{data-sch}{} +\registerctxluafile{data-tre}{} +\registerctxluafile{data-lua}{} +\registerctxluafile{data-ctx}{} +\registerctxluafile{data-con}{} +\registerctxluafile{data-use}{} +\registerctxluafile{data-aux}{} + +\registerctxluafile{luat-cbk}{} +\registerctxluafile{luat-run}{} +\registerctxluafile{luat-fio}{autosuffix} +\registerctxluafile{luat-cnf}{} +\registerctxluafile{luat-lua}{} +\registerctxluafile{luat-sto}{} +\registerctxluafile{luat-ini}{} +\registerctxluafile{util-env}{} +\registerctxluafile{luat-env}{} +\registerctxluafile{luat-exe}{} % simplified +\registerctxluafile{luat-iop}{} % simplified +%registerctxluafile{luat-bwc}{} +\registerctxluafile{trac-lmx}{} % might become l-lmx or luat-lmx +\registerctxluafile{luat-mac}{} +%registerctxluafile{luat-prp}{} % for the moment of not much use + +\registerctxluafile{lxml-tab}{} +\registerctxluafile{lxml-lpt}{} +\registerctxluafile{lxml-xml}{} +\registerctxluafile{lxml-aux}{} +\registerctxluafile{lxml-mis}{} + +\pushoverloadmode + +\permanent\protected\def\writestatus#1#2{\ctxlua{logs.status([==[#1]==],[==[#2]==])}} +\permanent\protected\def\writestring #1{\ctxlua{logs.writer([==[#1]==],"\string\n")}} +\permanent\protected\def\writeline {\ctxlua{logs.newline()}} + +\popoverloadmode + +\endinput diff --git a/tex/context/base/mkiv/luat-log.lmt b/tex/context/base/mkxl/luat-log.lmt index 684b2ac8d..684b2ac8d 100644 --- a/tex/context/base/mkiv/luat-log.lmt +++ b/tex/context/base/mkxl/luat-log.lmt diff --git a/tex/context/base/mkxl/luat-soc.mkxl b/tex/context/base/mkxl/luat-soc.mkxl new file mode 100644 index 000000000..b2ce70483 --- /dev/null +++ b/tex/context/base/mkxl/luat-soc.mkxl @@ -0,0 +1,52 @@ +%D \module +%D [ file=luat-soc, +%D version=2018.08.05, +%D title=\CONTEXT\ Lua Macros, +%D subtitle=Socket Libraries, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Lua Macros / Socket Libraries} + +%D In \LUATEX\ we provide the socket library that is more or less the standard one +%D for \LUA. It has been around for a while and seems to be pretty stable. The +%D binary module is copmpiled into \LUATEX\ and the accompanying .lua files are +%D preloaded. These files are mostly written by Diego Nehab, Andre Carregal, Javier +%D Guerra, and Fabio Mascarenhas with contributions from Diego Nehab, Mike Pall, +%D David Burgess, Leonardo Godinho, Thomas Harning Jr., and Gary NG. The originals +%D are part of and copyrighted by the Kepler project. +%D +%D Here we reload a slightly reworked version of these \type {.lua} files. We keep +%D the same (documented) interface but streamlined some fo the code. No more +%D modules, no more pre 5.2 \LUA, etc. Also, as it loads into the \CONTEXT +%D ecosystem, we plug in some logging. (and maybe tracing in the future). As we +%D don't support serial ports in \LUATEX, related code has been dropped. +%D +%D The files are reformatted so that we can more easilly add additional features +%D and|/|or tracing options. Any error introduced there is our fault! The url module +%D might be replaced by the one in \CONTEXT. When we need mbox a suitable variant +%D will be provided. + +%D Currently we preload the related \LUA\ code in \LUATEX, but that might change at +%D some point. We're prepared for that. + +% \registerctxluafile{util-soc-imp-reset} {} +% +% \registerctxluafile{util-soc-imp-socket} {} +% % registerctxluafile{util-soc-imp-copas} {} +% \registerctxluafile{util-soc-imp-ltn12} {} +% % registerctxluafile{util-soc-imp-mbox} {} +% \registerctxluafile{util-soc-imp-mime} {} +% \registerctxluafile{util-soc-imp-url} {} +% \registerctxluafile{util-soc-imp-headers}{} +% \registerctxluafile{util-soc-imp-http} {} +% \registerctxluafile{util-soc-imp-tp} {} +% % registerctxluafile{util-soc-imp-ftp} {} +% % registerctxluafile{util-soc-imp-smtp} {} + +\endinput diff --git a/tex/context/base/mkxl/luat-usr.mkxl b/tex/context/base/mkxl/luat-usr.mkxl new file mode 100644 index 000000000..8c43a5a72 --- /dev/null +++ b/tex/context/base/mkxl/luat-usr.mkxl @@ -0,0 +1,119 @@ +%D \module +%D [ file=luat-usr, +%D version=2005.08.11,% moved from luat-ini +%D title=\CONTEXT\ Lua Macros, +%D subtitle=Initialization, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Lua Macros / Userspace} + +\unprotect + +\registerctxluafile{luat-usr}{} + +%D A few goodies: +%D +%D \startbuffer +%D \luascript { context("foo 1:") context(i) } +%D \luathread {test} { i = 10 context("bar 1:") context(i) } +%D \luathread {test} { context("bar 2:") context(i) } +%D \luathread {test} {} +%D \luathread {test} { context("bar 3:") context(i) } +%D \luascript { context("foo 2:") context(i) } +%D \stopbuffer +%D +%D \typebuffer \startlines \getbuffer \stoplines + +\let\luascript\clf_luascript % todo: public implementors +\let\luathread\clf_luathread % todo: public implementors + +%D \macros +%D {definenamedlua} +%D +%D We provide an interface for defining instances. We don't have the definers yet +%D so we do it low level: + +\def\s!lua {lua} +\def\s!code {code} +\def\s!data {data} +\def\s!start{start} +\def\s!stop {stop} + +%D Beware: because \type {\expanded} is een convert command, the error message will +%D show \type{<inserted text>} as part of the message. + +\installsystemnamespace{luacode} + +\permanent\tolerant\protected\def\definenamedlua[#1]#*[#2]% + {\ifarguments \orelse \ifcsname\??luacode#1\endcsname \else + \bgroup + % + \edef\fullname{lua_code_#1}% + % + \clf_registernamedlua{#1}{#2}{\fullname}% + % + \frozen\instance\protected\xdefcsname\s!start#1\s!code\endcsname + {\begingroup + \obeylualines + \obeyluatokens + \csname\??luacode#1\endcsname}% + % + \aliased\gletcsname\s!stop#1\s!code\endcsname\relax + % + \normalexpanded{\xdefcsname\??luacode#1\endcsname##1\csname\s!stop#1\s!code\endcsname}% + {\noexpand\expandafter\endgroup + \noexpand\expandafter + \expandafter\noexpand\csname clf_\fullname\endcsname + \noexpand\expandafter{\noexpand\normalexpanded{##1}}}% + \frozen\instance\gletcsname#1\s!code\expandafter\endcsname\csname clf_\fullname\endcsname + \egroup + \fi} + +%D We predefine a few. + +% \definenamedlua[module][module instance] % not needed + +\definenamedlua[user] [private user] +\definenamedlua[third] [third party module] +\definenamedlua[isolated][isolated] + +%D In practice this works out as follows: +%D +%D \startbuffer +%D \startluacode +%D context("LUA") +%D \stopluacode +%D +%D \startusercode +%D global.context("USER 1") +%D context.par() +%D context("USER 2") +%D context.par() +%D if characters then +%D context("ACCESS directly") +%D elseif global.characters then +%D context("ACCESS via global") +%D else +%D context("NO ACCESS at all") +%D end +%D context.par() +%D if bogus then +%D context("ACCESS directly") +%D elseif global.bogus then +%D context("ACCESS via global") +%D else +%D context("NO ACCESS at all") +%D end +%D context.par() +%D \stopusercode +%D \stopbuffer +%D +%D \typebuffer + +\protect \endinput diff --git a/tex/context/base/mkiv/lxml-css.mkxl b/tex/context/base/mkxl/lxml-css.mkxl index c7c8d8afd..c7c8d8afd 100644 --- a/tex/context/base/mkiv/lxml-css.mkxl +++ b/tex/context/base/mkxl/lxml-css.mkxl diff --git a/tex/context/base/mkiv/lxml-ctx.mkxl b/tex/context/base/mkxl/lxml-ctx.mkxl index f4b2edc79..f4b2edc79 100644 --- a/tex/context/base/mkiv/lxml-ctx.mkxl +++ b/tex/context/base/mkxl/lxml-ctx.mkxl diff --git a/tex/context/base/mkiv/lxml-ini.mkxl b/tex/context/base/mkxl/lxml-ini.mkxl index e8d017bf3..f331718e9 100644 --- a/tex/context/base/mkiv/lxml-ini.mkxl +++ b/tex/context/base/mkxl/lxml-ini.mkxl @@ -32,7 +32,7 @@ % undocumented: -\def\ctxlxml #1{\ctxlua{lxml.#1}} +\permanent\def\ctxlxml#1{\ctxlua{lxml.#1}} % for now indirect .. this will change when we have updated luatex (scan_argument) @@ -128,7 +128,7 @@ %let\xmltoparameters \clf_xmltoparameters %let\xmlverbatim \clf_xmlverbatim -\let\xmlposition \xmlindex +\aliased\let\xmlposition\xmlindex \permanent\protected\def\xmlinfo#1{\hbox{\ttxx[\xmlname{#1}]}} \permanent\protected\def\xmlshow#1{\startpacked\ttx\xmlverbatim{#1}\stoppacked} @@ -140,7 +140,7 @@ % we need to pass the last argument as function, so -\protected\def\xmlsetfunction#1#2#3{\ctxcommand{xmlsetfunction("#1",\!!bs#2\!!es,#3)}} +\permanent\protected\def\xmlsetfunction#1#2#3{\ctxcommand{xmlsetfunction("#1",\!!bs#2\!!es,#3)}} % goodie: @@ -243,7 +243,7 @@ \aliased\let\xmlregistersetup \xmlappendsetup \aliased\let\xmlregisterdocumentsetup\xmlappenddocumentsetup -\def\xmldocument{main} +\mutable\def\xmldocument{main} \permanent\protected\def\xmlregisteredsetups {\xmlstarttiming @@ -328,13 +328,13 @@ \else % maybe test for existence \edef\currenttyping{xml:\currenttyping}% \fi - \protected\def\stopxmldisplayverbatim + \enforced\protected\def\stopxmldisplayverbatim {\endofverbatimlines \stoppacked}% \doinitializeverbatim \beginofverbatimlines} -\let\stopxmldisplayverbatim\relax +\aliased\let\stopxmldisplayverbatim\relax \permanent\tolerant\protected\def\startxmlinlineverbatim[#1]% {\begingroup @@ -344,10 +344,10 @@ \else % maybe test for existence \edef\currenttype{xml:\currenttype}% \fi - \let\stopxmlinlineverbatim\endgroup + \enforced\let\stopxmlinlineverbatim\endgroup \doinitializeverbatim} -\let\stopxmlinlineverbatim\relax +\aliased\let\stopxmlinlineverbatim\relax % processing instructions diff --git a/tex/context/base/mkiv/lxml-sor.mkxl b/tex/context/base/mkxl/lxml-sor.mkxl index 798047e04..798047e04 100644 --- a/tex/context/base/mkiv/lxml-sor.mkxl +++ b/tex/context/base/mkxl/lxml-sor.mkxl diff --git a/tex/context/base/mkiv/m-mkivmkxl.mkxl b/tex/context/base/mkxl/m-mkivmkxl.mkxl index 9aea14eb2..9aea14eb2 100644 --- a/tex/context/base/mkiv/m-mkivmkxl.mkxl +++ b/tex/context/base/mkxl/m-mkivmkxl.mkxl diff --git a/tex/context/base/mkxl/math-acc.mklx b/tex/context/base/mkxl/math-acc.mklx new file mode 100644 index 000000000..b5580fff2 --- /dev/null +++ b/tex/context/base/mkxl/math-acc.mklx @@ -0,0 +1,151 @@ +%D \module +%D [ file=math-acc, +%D version=2013.07.31, +%D title=\CONTEXT\ Math Macros, +%D subtitle=Accents, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Math Macros / Accents} + +% There are probably errors ... too distracted by amazing (piano) music videos running +% on top of scite ... so: experimental code. + +\unprotect + +% This module permits overloading of accents so that we can do fancy things. The +% implementation is similar to stackers. By default accenst are defined in a simple +% way. Contrary to extensibles accents cannot grow indefinitely. Alas the +% implementation of accents is different too, in the sense that they are +% prepositioned i.e. are already raised. (In my opinion for no real reason as they +% need to adapt anyway). +% +% $ \ruledhbox{$H$} \hat{H} \ruledhbox{$\widehat{H}$} \widehat{H} $ +% +% One alternative is: +% +% \definemathoverextensible [top] [hoed] ["FE302] +% \definemathoverextensible [top] [slang] ["FE303] +% +% $ \hoed{H} \ruledhbox{$\hoed{H}$} \ruledhbox{$\hoed{\tf H}$} \slang{H} $ +% +% But that nills the italic correction (and I'm in nood to mess with that again). +% +% \definemathaccents [myaccents] [color=darkred] +% \definemathtopaccent [myaccents] [mywidehat] ["0302] +% +% $ \hat{H} \widehat{H} \mywidehat{H} $ + +%D Older implementations are kept in the \MKII\ and \MKIV\ modules for educational +%D purposes. + +\installcorenamespace{mathaccents} + +\installcommandhandler \??mathaccents {mathaccents} \??mathaccents + +\setupmathaccents + [\c!top=, + \c!bottom=, + \c!mathstyle=, + \c!color=, + \c!define=\v!yes] % not used + +\definemathaccents + [\v!both] + +\definemathaccents + [\v!top] + [\v!both] + +\definemathaccents + [\v!bottom] + [\v!both] + +\permanent\tolerant\protected\def\definemathtopaccent[#1]#*[#2]#*[#3]% class name top + {\ifparameter#3\or + \frozen\instance\setuevalue{#2}{\math_accents_make_double {#1}\plusone{\number#3}\zerocount}% + \else + \frozen\instance\setuevalue{#1}{\math_accents_make_double\noexpand\currentmathaccents\plusone{\number#2}\zerocount}% + \fi} + +\permanent\tolerant\protected\def\definemathbottomaccent[#1]#*[#2]#*[#3]% class name bottom + {\ifparameter#3\or + \frozen\instance\setuevalue{#2}{\math_accents_make_double {#1}\plustwo\zerocount{\number#3}}% + \else + \frozen\instance\setuevalue{#1}{\math_accents_make_double\noexpand\currentmathaccents\plustwo\zerocount{\number#2}}% + \fi} + +\permanent\tolerant\protected\def\definemathdoubleaccent[#1]#*[#2]#*[#3]#*[#4]% class name top bottom + {\ifparameter#4\or + \frozen\instance\setuevalue{#2}{\math_accents_make_double {#1}\plusthree{\number#3}{\number#4}}% + \else + \frozen\instance\setuevalue{#1}{\math_accents_make_double\noexpand\currentmathaccents\plusthree{\number#2}{\number#3}}% + \fi} + +\def\math_accents_color_push_yes + {\pushcolor[\p_math_accent_color]% + \let\math_accents_color_pop\popcolor} + +\def\math_accents_color_push_nop + {\let\math_accents_color_pop\donothing} + +\protected\def\math_accents_make_double#class#kind#top#bottom#content% + {\begingroup + \edef\currentmathaccents {#class}% + \edef\p_math_accent_color{\mathaccentsparameter\c!color}% + \startusemathstyleparameter\mathaccentsparameter + \ifempty\p_math_accent_color + \math_accents_color_push_nop + \else + \math_accents_color_push_yes + \fi + \ifcase#kind\or + \Umathaccent \fam\zerocount#top + \or + \Umathaccent bottom \fam\zerocount#bottom + \or + \Umathaccent both \fam\zerocount#top + \fam\zerocount#bottom + \fi + {\math_accents_color_pop#content}% + \stopusemathstyleparameter + \endgroup} + +%D Relative new: + +\newconditional\c_math_accents_auto_dotless \settrue\c_math_accents_auto_dotless % cf opentype math + +\aliased\let\normalgrave\grave \permanent\protected\def\dotlessgrave#1{\normalgrave{\mathdotless#1}} +\aliased\let\normalddot \ddot \permanent\protected\def\dotlessddot #1{\normalddot {\mathdotless#1}} +\aliased\let\normalbar \bar \permanent\protected\def\dotlessbar #1{\normalbar {\mathdotless#1}} +\aliased\let\normalacute\acute \permanent\protected\def\dotlessacute#1{\normalacute{\mathdotless#1}} +\aliased\let\normalhat \hat \permanent\protected\def\dotlesshat #1{\normalhat {\mathdotless#1}} +\aliased\let\normalcheck\check \permanent\protected\def\dotlesscheck#1{\normalcheck{\mathdotless#1}} +\aliased\let\normalbreve\breve \permanent\protected\def\dotlessbreve#1{\normalbreve{\mathdotless#1}} +\aliased\let\normaldot \dot \permanent\protected\def\dotlessdot #1{\normaldot {\mathdotless#1}} +\aliased\let\normalring \ring \permanent\protected\def\dotlessring #1{\normalring {\mathdotless#1}} +\aliased\let\normaltilde\tilde \permanent\protected\def\dotlesstilde#1{\normaltilde{\mathdotless#1}} +\aliased\let\normaldddot\dddot \permanent\protected\def\dotlessdddot#1{\normaldddot{\mathdotless#1}} + +\def\math_accents_auto_dotless#1#2{\ifconditional\c_math_accents_auto_dotless\expandafter#2\else\expandafter#1\fi} + +\permanent\protected\def\grave {\math_accents_auto_dotless\normalgrave \dotlessgrave } +\permanent\protected\def\ddot {\math_accents_auto_dotless\normalddot \dotlessddot } +\permanent\protected\def\bar {\math_accents_auto_dotless\normalbar \dotlessbar } +\permanent\protected\def\acute {\math_accents_auto_dotless\normalacute \dotlessacute } +\permanent\protected\def\hat {\math_accents_auto_dotless\normalhat \dotlesshat } +\permanent\protected\def\check {\math_accents_auto_dotless\normalcheck \dotlesscheck } +\permanent\protected\def\breve {\math_accents_auto_dotless\normalbreve \dotlessbreve } +\permanent\protected\def\dot {\math_accents_auto_dotless\normaldot \dotlessdot } +\permanent\protected\def\ring {\math_accents_auto_dotless\normalring \dotlessring } +\permanent\protected\def\tilde {\math_accents_auto_dotless\normaltilde \dotlesstilde } +\permanent\protected\def\dddot {\math_accents_auto_dotless\normaldddot \dotlessdddot } + +\aliased\let\mathring\ring % for a while + +\protect \endinput diff --git a/tex/context/base/mkiv/math-ali.mkxl b/tex/context/base/mkxl/math-ali.mkxl index e5c693f98..587eaf6a1 100644 --- a/tex/context/base/mkiv/math-ali.mkxl +++ b/tex/context/base/mkxl/math-ali.mkxl @@ -393,8 +393,8 @@ \installcommandhandler \??mathalignment {mathalignment} \??mathalignment \appendtoks - \setuevalue{\e!start\currentmathalignment}{\math_alignment_start[\currentmathalignment]}% - \setvalue {\e!stop \currentmathalignment}{\math_alignment_stop}% + \frozen\instance\setuevalue{\e!start\currentmathalignment}{\math_alignment_start[\currentmathalignment]}% + \frozen\instance\setvalue {\e!stop \currentmathalignment}{\math_alignment_stop}% \to \everydefinemathalignment \setupmathalignment @@ -410,15 +410,17 @@ \ifdefined \startalignment - \let\align_math_normal_start\startalign - \let\align_math_normal_stop \stopalign + \pushoverloadmode - \let\align_text_normal_start\startalignment - \let\align_text_normal_stop \stopalignment + \aliased\let\align_math_normal_start\startalign + \aliased\let\align_math_normal_stop \stopalign + + \aliased\let\align_text_normal_start\startalignment + \aliased\let\align_text_normal_stop \stopalignment \permanent\overloaded\protected\def\startalign {\ifmmode - \enforced\let\stopalign\align_math_normal_stop % cannot be an unexpanded def ... lookahead in align + \enforced\let\stopalign\align_math_normal_stop % cannot be a protected def ... lookahead in align \expandafter\align_math_normal_start \orelse\ifinformula \enforced\let\stopalign\align_math_normal_stop @@ -428,21 +430,23 @@ \expandafter\align_text_normal_start \fi} - \overloaded\let\stopalign\relax + \aliased\let\stopalign\relax \permanent\overloaded\protected\def\startalignment {\ifmmode - \enforced\let\stopalignment\align_math_normal_stop % cannot be an unexpanded def ... lookahead in align + \enforced\let\stopalignment\align_math_normal_stop % cannot be a protected def ... lookahead in align \expandafter\align_math_normal_start \orelse\ifinformula - \enforced\let\stopalignment\align_math_normal_stop % cannot be an unexpanded def ... lookahead in align + \enforced\let\stopalignment\align_math_normal_stop % cannot be a protected def ... lookahead in align \expandafter\align_math_normal_start \else \enforced\let\stopalignment\align_text_normal_stop \expandafter\align_text_normal_start \fi} - \overloaded\let\stopalignment\relax + \aliased\let\stopalignment\relax + + \pushoverloadmode \fi @@ -655,8 +659,8 @@ \c!right={\right.}] \appendtoks - \setuevalue{\e!start\currentmathcases}{\math_cases_start[\currentmathcases]}% - \setvalue {\e!stop \currentmathcases}{\math_cases_stop}% + \frozen\instance\setuevalue{\e!start\currentmathcases}{\math_cases_start[\currentmathcases]}% + \frozen\instance\setvalue {\e!stop \currentmathcases}{\math_cases_stop}% \to \everydefinemathcases \permanent\protected\def\math_cases_NC_zero @@ -805,8 +809,8 @@ \c!align=\v!middle] \appendtoks - \setuevalue{\e!start\currentmathmatrix}{\math_matrix_start[\currentmathmatrix]}% - \setvalue {\e!stop \currentmathmatrix}{\math_matrix_stop}% no u else lookahead problem + \frozen\instance\setuevalue{\e!start\currentmathmatrix}{\math_matrix_start[\currentmathmatrix]}% + \frozen\instance\setvalue {\e!stop \currentmathmatrix}{\math_matrix_stop}% no u else lookahead problem \to \everydefinemathmatrix \def\math_matrix_start_table @@ -1171,7 +1175,7 @@ \appendtoks \edef\p_simplecommand{\mathmatrixparameter\c!simplecommand}% \ifempty\p_simplecommand\else - \setuevalue{\p_simplecommand}{\math_matrix_simple[\currentmathmatrix]}% + \frozen\instance\setuevalue{\p_simplecommand}{\math_matrix_simple[\currentmathmatrix]}% \fi \to \everydefinemathmatrix diff --git a/tex/context/base/mkxl/math-def.mkxl b/tex/context/base/mkxl/math-def.mkxl new file mode 100644 index 000000000..29ad9b465 --- /dev/null +++ b/tex/context/base/mkxl/math-def.mkxl @@ -0,0 +1,171 @@ + %D \module +%D [ file=math-tex, +%D version=2001.04.12, +%D title=\CONTEXT\ Math Macros, +%D subtitle=Definitions, +%D author={Hans Hagen, Taco Hoekwater \& Aditya Mahajan}, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Math Macros / Definitions} + +\unprotect + +\pushoverloadmode % cap etc + +\startluacode + mathematics.define(\number\defaultmathfamily) + -- mathematics.xml.registerentities() +\stopluacode + +\popoverloadmode + +\activatemathcharacters + +%D The \mfunction macro is an alternative for \hbox with a controlable font +%D switch. + +\definemathcommand [arccos] [nolop] {\mfunctionlabeltext{arccos}} +\definemathcommand [arcsin] [nolop] {\mfunctionlabeltext{arcsin}} +\definemathcommand [arctan] [nolop] {\mfunctionlabeltext{arctan}} +\definemathcommand [arccosh] [nolop] {\mfunctionlabeltext{arccosh}} +\definemathcommand [arcsinh] [nolop] {\mfunctionlabeltext{arcsinh}} +\definemathcommand [arctanh] [nolop] {\mfunctionlabeltext{arctanh}} +\definemathcommand [acos] [nolop] {\mfunctionlabeltext{acos}} +\definemathcommand [asin] [nolop] {\mfunctionlabeltext{asin}} +\definemathcommand [atan] [nolop] {\mfunctionlabeltext{atan}} +\definemathcommand [arg] [nolop] {\mfunctionlabeltext{arg}} +\definemathcommand [cosh] [nolop] {\mfunctionlabeltext{cosh}} +\definemathcommand [cos] [nolop] {\mfunctionlabeltext{cos}} +\definemathcommand [coth] [nolop] {\mfunctionlabeltext{coth}} +\definemathcommand [cot] [nolop] {\mfunctionlabeltext{cot}} +\definemathcommand [csc] [nolop] {\mfunctionlabeltext{csc}} +\definemathcommand [deg] [nolop] {\mfunctionlabeltext{deg}} +\definemathcommand [det] [limop] {\mfunctionlabeltext{det}} +\definemathcommand [dim] [nolop] {\mfunctionlabeltext{dim}} +\definemathcommand [exp] [nolop] {\mfunctionlabeltext{exp}} +\definemathcommand [gcd] [limop] {\mfunctionlabeltext{gcd}} +\definemathcommand [hom] [nolop] {\mfunctionlabeltext{hom}} +\definemathcommand [inf] [limop] {\mfunctionlabeltext{inf}} +\definemathcommand [injlim] [limop] {\mfunctionlabeltext{injlim}} +\definemathcommand [ker] [nolop] {\mfunctionlabeltext{ker}} +\definemathcommand [lg] [nolop] {\mfunctionlabeltext{lg}} +\definemathcommand [liminf] [limop] {\mfunctionlabeltext{liminf}} +\definemathcommand [limsup] [limop] {\mfunctionlabeltext{limsup}} +\definemathcommand [lim] [limop] {\mfunctionlabeltext{lim}} +\definemathcommand [ln] [nolop] {\mfunctionlabeltext{ln}} +\definemathcommand [log] [nolop] {\mfunctionlabeltext{log}} +\definemathcommand [median] [limop] {\mfunctionlabeltext{median}} +\definemathcommand [max] [limop] {\mfunctionlabeltext{max}} +\definemathcommand [min] [limop] {\mfunctionlabeltext{min}} +\definemathcommand [mod] [limop] {\mfunctionlabeltext{mod}} +%definemathcommand [div] [limop] {\mfunctionlabeltext{div}} % overloads \div symbol +\definemathcommand [projlim] [limop] {\mfunctionlabeltext{projlim}} +\definemathcommand [Pr] [limop] {\mfunctionlabeltext{Pr}} +\definemathcommand [sec] [nolop] {\mfunctionlabeltext{sec}} +\definemathcommand [sinh] [nolop] {\mfunctionlabeltext{sinh}} +\definemathcommand [sin] [nolop] {\mfunctionlabeltext{sin}} +\definemathcommand [sup] [limop] {\mfunctionlabeltext{sup}} +\definemathcommand [tanh] [nolop] {\mfunctionlabeltext{tanh}} +\definemathcommand [tan] [nolop] {\mfunctionlabeltext{tan}} +\definemathcommand [diff] {\mfunctionlabeltext{diff}} + +\aliased\let\normalmatharg\arg % todo: maybe automatically + +%D This needs checking: + +\permanent\protected\def\setoperatorlimits#1#2% operator limits + {\savenormalmeaning{#1}% + \expandafter\def\expandafter#1\expandafter{\csname normal\csstring#1\endcsname#2}} + +\pushoverloadmode + +\setoperatorlimits \int \intlimits +\setoperatorlimits \iint \intlimits +\setoperatorlimits \iiint \intlimits +\setoperatorlimits \oint \intlimits +\setoperatorlimits \oiint \intlimits +\setoperatorlimits \oiiint \intlimits +\setoperatorlimits \intclockwise \intlimits +\setoperatorlimits \ointclockwise \intlimits +\setoperatorlimits \ointctrclockwise \intlimits + +\popoverloadmode + +%D \macros +%D {centercolon, colonminus, minuscolon, colonequals, equalscolon, +%D colonapprox, approxcolon, colonsim, simcolon, coloncolon, +%D coloncolonminus, minuscoloncolon, coloncolonequals, +%D equalscoloncolon, coloncolonapprox, approxcoloncolon, +%D colonsim, simcoloncolon} +%D +%D The following colon related definitions are provided by Aditya +%D Mahajan who derived them from \type {mathtools.sty} and \type +%D {colonequals.sty}. This will be redone as part of the overhaul +%D and font updates. +%D +%D In $a := b$ the colon is not vertically centered with the equal +%D to. Also the distance between colon and equal to is a bit large. +%D So, we define a vertically centered colon \tex {centercolon} and +%D a few macros for colon and double colon relation symbols. +%D +%D \startlines +%D \formula {A \centercolon B} +%D \formula {A \colonminus B} +%D \formula {A \minuscolon B} +%D \formula {A \colonequals B} +%D \formula {A \equalscolon B} +%D \formula {A \colonapprox B} +%D \formula {A \approxcolon B} +%D \formula {A \colonsim B} +%D \formula {A \simcolon B} +%D \formula {A \coloncolon B} +%D \formula {A \coloncolonminus B} +%D \formula {A \minuscoloncolon B} +%D \formula {A \coloncolonequals B} +%D \formula {A \equalscoloncolon B} +%D \formula {A \coloncolonapprox B} +%D \formula {A \approxcoloncolon B} +%D \formula {A \colonsim B} +%D \formula {A \simcoloncolon B} +%D \stoplines +%D +%D The next macros take care of the space between the colon and the +%D relation symbol. + +\pushoverloadmode + +\definemathcommand [colonsep] {\mkern-1.2mu} +\definemathcommand [doublecolonsep] {\mkern-0.9mu} + +\definemathcommand [centercolon] [rel] {\mathstylevcenteredhbox\colon} +\definemathcommand [colonminus] [rel] {\centercolon\colonsep\mathrel{-}} +%definemathcommand [minuscolon] [rel] {\mathrel{-}\colonsep\centercolon} % native char +%definemathcommand [colonequals] [rel] {\centercolon\colonsep=} % native char +%definemathcommand [equalscolon] [rel] {=\centercolon\colonsep} % native char +\definemathcommand [colonapprox] [rel] {\centercolon\colonsep\approx} +\definemathcommand [approxcolon] [rel] {\approx\centercolon\colonsep} +\definemathcommand [colonsim] [rel] {\centercolon\colonsep\sim} +\definemathcommand [simcolon] [rel] {\sim\centercolon\colonsep} + +\definemathcommand [coloncolon] [rel] {\centercolon\doublecolonsep\centercolon} +\definemathcommand [coloncolonminus] [rel] {\coloncolon\colonsep\mathrel{-}} +\definemathcommand [minuscoloncolon] [rel] {\mathrel{-}\colonsep\coloncolon} +\definemathcommand [coloncolonequals] [rel] {\coloncolon\colonsep=} % native char +\definemathcommand [equalscoloncolon] [rel] {=\coloncolon\colonsep} +\definemathcommand [coloncolonapprox] [rel] {\coloncolon\colonsep\approx} +\definemathcommand [approxcoloncolon] [rel] {\approx\coloncolon\colonsep} +\definemathcommand [coloncolonsim] [rel] {\coloncolon\colonsep\sim} +\definemathcommand [simcoloncolon] [rel] {\sim\coloncolon\colonsep} + +\popoverloadmode + +% \appendtoks +% \def\over{\primitive\over}% +% \to \everymathematics + +\protect \endinput diff --git a/tex/context/base/mkxl/math-del.mkxl b/tex/context/base/mkxl/math-del.mkxl new file mode 100644 index 000000000..3995c08b2 --- /dev/null +++ b/tex/context/base/mkxl/math-del.mkxl @@ -0,0 +1,164 @@ +%D \module +%D [ file=math-del, +%D version=2007.07.19, +%D title=\CONTEXT\ Math Macros, +%D subtitle=Delimiters, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Math Macros / Delimiters} + +\unprotect + +%D Old code that will be redone: +%D +%D \macros +%D {checkdelimiters, fakeleftdelimiter, fakerightdelimiter} +%D +%D Handy for non matching situations (as with mathml): +%D +%D \starttyping +%D \checkdelimiters{... bla bla ...} +%D \fakeleftdelimiter +%D ... bla bla ... +%D \fakerightdelimiter +%D \stoptyping + +% Actually we can do better now with lua hacks. + +\newcount\c_math_delimiter_nesting + +\permanent\protected\def\leftfakedelimiter {\advance\c_math_delimiter_nesting\minusone\gobbleoneargument} +\permanent\protected\def\rightfakedelimiter{\advance\c_math_delimiter_nesting\plusone \gobbleoneargument} + +\permanent\protected\def\checkdelimiters#1% + {\c_math_delimiter_nesting\zerocount + \setbox\scratchbox\hbox\bgroup + \let\left \leftfakedelimiter + \let\right\rightfakedelimiter + \normalstartimath#1\expandafter\normalstopimath\expandafter + \egroup + \expandafter\c_math_delimiter_nesting\the\c_math_delimiter_nesting\relax} + +\permanent\protected\def\fakeleftdelimiter {\ifnum\c_math_delimiter_nesting>\zerocount\left .\fi} +\permanent\protected\def\fakerightdelimiter{\ifnum\c_math_delimiter_nesting<\zerocount\right.\fi} + +%D The following macros are used in the MathML interpreter, so there is a good +%D change of them never being documented for other usage. + +\aliased\let\normalordelimiter\secondoftwoarguments +\aliased\let\normalorfiller \firstoftwoarguments + +\permanent\protected\def\enabledelimiter {\enforced\let\normalordelimiter\secondoftwoarguments} +\permanent\protected\def\disabledelimiter{\enforced\let\normalordelimiter\firstoftwoarguments} + +\permanent\protected\def\enablefiller {\enforced\let\normalorfiller\secondoftwoarguments} +\permanent\protected\def\disablefiller {\enforced\let\normalorfiller\firstoftwoarguments} + +\permanent\protected\def\mathopnolimits#1{\mathop{\mathrm#1}\nolimits} % was \rm, which follows text fonts (used in mml parser, check!) +\permanent\protected\def\mathopdolimits#1{\mathop{\mathrm#1}} % was \rm, which follows text fonts (used in mml parser, check!) + +% A new experiment: + +% Hm, we already have \definemathextensible so we need to preserve that one. We now +% use \definemathdelimiter. + +\installcorenamespace {mathdelimiter} + +\installcommandhandler \??mathdelimiter {mathdelimiter} \??mathdelimiter + +\aliased\let\setupmathdelimiters\setupmathdelimiter + +\setupmathdelimiters + [\c!symbol=0, + \c!define=\v!yes, + \c!factor=1.5, + \c!axis=\v!yes, + % \c!exact=\v!yes + \c!height=\exheight, + \c!depth=\exheight] + +\appendtoks + \ifcstok{\mathdelimiterparameter\c!define}\v!yes + \frozen\instance\setuevalue\currentmathdelimiter{\mathdelimiter[\currentmathdelimiter]}% + \fi +\to \everydefinemathdelimiter + +\permanent\tolerant\protected\def\mathdelimiter[#1]#*[#2]% + {\mathop + {\edef\currentmathdelimiter{#1}% + \iftok{#2}\emptytoks + \edef\p_factor{\mathdelimiterparameter\c!factor}% + \orelse\ifhastok={#2}% + \setupcurrentmathdelimiter[#2]% + \edef\p_factor{\mathdelimiterparameter\c!factor}% + \else + \edef\p_factor{#2}% + \fi + \edef\p_exact{\mathdelimiterparameter\c!exact}% + \edef\p_axis {\mathdelimiterparameter\c!axis}% + \edef\p_leftoffset{\mathdelimiterparameter\c!leftoffset}% + \edef\p_rightoffset{\mathdelimiterparameter\c!rightoffset}% + \ifx\p_leftoffset\empty\else + \mskip\p_leftoffset + \fi + \Uvextensible + \ifx\p_exact\v!yes exact \fi + \ifx\p_axis \v!yes axis \fi + height \p_factor\dimexpr\mathdelimiterparameter\c!height\relax + depth \p_factor\dimexpr\mathdelimiterparameter\c!depth \relax + \Udelimiter\zerocount\zerocount\mathdelimiterparameter\c!symbol + \relax + \ifx\p_rightoffset\empty\else + \mskip\p_rightoffset + \fi}} + +\definemathdelimiter[integral][\c!symbol="222B] + +% \setupmathdelimiter[integral][rightoffset=-3mu,exact=yes,factor=2] +% +% \let\inlineint \int +% \let\displayint\integral +% +% \protected\def\int{\ifmmode\inlineordisplaymath\inlineint\displayint\else\normalint\fi} +% +% \startlines +% \ruledhbox{$\integral f\frac{1}{2}$} +% \ruledhbox{$\integral[factor=1] f\frac{1}{2}$} +% \ruledhbox{$\integral[factor=3] f\frac{1}{2}$} +% \ruledhbox{$\int f\frac{1}{2}$} +% \stoplines + +\permanent\protected\def\autointegral#1#2#3% + {\ifmmode + \setbox\nextbox\mathstylehbox{#3}% + \scratchdimen\ifdim\nextboxht>\nextboxdp\nextboxht\else\nextboxdp\fi + \mathlimop{% + \Uvextensible + height \scratchdimen + depth \scratchdimen + exact% + axis% + \Udelimiter \plusfour \zerocount "222B% + }% + \limits % nolimits needs more work: kerning and so + \normalsuperscript{#1}% + \normalsubscript{#2}% + \box\nextbox + \else + \char"222B\relax + \fi} + +% \startformula +% a = +% \autointegral{t}{b}1 + +% \autointegral{t}{b}{\frac{\frac{3}{4}}{\frac{1}{2}}} + +% \autointegral{t}{b}{\frac{\frac{\frac{\frac{1}{2}}{2}}{2}}{2}} +% \stopformula + +\protect \endinput diff --git a/tex/context/base/mkxl/math-dis.mkxl b/tex/context/base/mkxl/math-dis.mkxl new file mode 100644 index 000000000..5b70970f3 --- /dev/null +++ b/tex/context/base/mkxl/math-dis.mkxl @@ -0,0 +1,20 @@ +%D \module +%D [ file=math-ali, +%D version=2008.10.20, +%D title=\CONTEXT\ Math Macros, +%D subtitle=Display, +%D author={Hans Hagen, Taco Hoekwater \& Aditya Mahajan}, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Math Macros / Display} + +\unprotect + +% display spacing code will move here + +\protect \endinput diff --git a/tex/context/base/mkiv/math-fen.mkxl b/tex/context/base/mkxl/math-fen.mkxl index 4d19fb210..f18d72c85 100644 --- a/tex/context/base/mkiv/math-fen.mkxl +++ b/tex/context/base/mkxl/math-fen.mkxl @@ -781,11 +781,11 @@ % wrappers -\protected\def\startcheckedfences +\permanent\protected\def\startcheckedfences {\begingroup \enableautofences} -\protected\def\stopcheckedfences +\permanent\protected\def\stopcheckedfences {\endgroup} % \appendtoks @@ -805,7 +805,7 @@ \newconstant\c_math_fences_delimiters_mode \c_math_fences_delimiters_mode"16 % \numexpr"02+"04+"10\relax -%unexpanded\def\enableautofencemode {\mathdelimitersmode\plussix} % the shift (1) is too fragile +%protected\def\enableautofencemode {\mathdelimitersmode\plussix} % the shift (1) is too fragile \protected\def\enableautofencemode {\mathdelimitersmode\c_math_fences_delimiters_mode} \protected\def\disableautofencemode{\mathdelimitersmode\zerocount} @@ -821,9 +821,9 @@ %D The next characters were used for constructing nicer extensibles but %D nowadays we have real characters. -\Umathchardef\braceld\zerocount \defaultmathfamily "FF07A -\Umathchardef\bracerd\zerocount \defaultmathfamily "FF07B -\Umathchardef\bracelu\zerocount \defaultmathfamily "FF07C -\Umathchardef\braceru\zerocount \defaultmathfamily "FF07D +\immutable\Umathchardef\braceld\zerocount \defaultmathfamily "FF07A +\immutable\Umathchardef\bracerd\zerocount \defaultmathfamily "FF07B +\immutable\Umathchardef\bracelu\zerocount \defaultmathfamily "FF07C +\immutable\Umathchardef\braceru\zerocount \defaultmathfamily "FF07D \protect diff --git a/tex/context/base/mkxl/math-for.mkxl b/tex/context/base/mkxl/math-for.mkxl new file mode 100644 index 000000000..e6ea402de --- /dev/null +++ b/tex/context/base/mkxl/math-for.mkxl @@ -0,0 +1,47 @@ +%D \module +%D [ file=strc-mat, +%D version=2008.10.20, +%D title=\CONTEXT\ Structure Macros, +%D subtitle=Math Numbering, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Structure Macros / Math Formulas} + +%D This module only provides the code for defining formulas and +%D fetching parameters. The action takes place later. + +\unprotect + +%D \macros +%D {setupformulas,setupsubformulas,setupformulaframed} + +\installcorenamespace{formula} +\installcorenamespace{subformula} +\installcorenamespace{formulaframed} +\installcorenamespace{formulaoption} + +\installcommandhandler \??formula {formula} \??formula +\installcommandhandler \??subformula {subformula} \??subformula % maybe just setuphandler (no childs used yet) +\installframedcommandhandler \??formulaframed {formulaframed} \??formulaframed + +\aliased\let\setupformulas \setupformula +\aliased\let\setupsubformulas\setupsubformula + +\appendtoks + \normalexpanded{\defineformulaframed[\currentformula][\currentformulaparent]}% +\to \everydefineformula + +\def\strc_formulas_option#1% + {\ifcsname\??formulaoption#1\endcsname + \lastnamedcs + \else + \font_basics_switchtobodyfont{#1}% for old time sake, might go away, only pt so maybe dimension and small test + \fi} + +\protect \endinput diff --git a/tex/context/base/mkiv/math-frc.mkxl b/tex/context/base/mkxl/math-frc.mkxl index b232868cd..b232868cd 100644 --- a/tex/context/base/mkiv/math-frc.mkxl +++ b/tex/context/base/mkxl/math-frc.mkxl diff --git a/tex/context/base/mkxl/math-inc.mkxl b/tex/context/base/mkxl/math-inc.mkxl new file mode 100644 index 000000000..c23684fd3 --- /dev/null +++ b/tex/context/base/mkxl/math-inc.mkxl @@ -0,0 +1,69 @@ +%D \module +%D [ file=math-inc, +%D version=2018.06.23, +%D title=\CONTEXT\ Math Macros, +%D subtitle=XML inclusion, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Math Macros / XML inclusion} + +\registerctxluafile{math-inc}{} + +%D I had some doubt about including this in \CONTEXT\ but it might serve some users +%D anyway. It's always the question to what extent one can be really roundtrip. I +%D might improve it when I need it. + +% Talking about creating from a source ... June Lee's transcription of +% Close to You by Jacob Collier is an amazing example: +% +% https://www.youtube.com/watch?v=hdBVN-HMuqI + +\unprotect + +\definesymbol[mmlattachment][{\infofont\darkred mml}] +\definesymbol[mmlcomment] [{\infofont\darkblue mml}] + +\permanent\protected\def\lxml_add_mml_blob#1#2% + {\relax + \clf_xmlformulatobuffer\number\c_strc_formulas_n{temp-xml-export}% + #2% + [\c!symbol=#1,% + \c!space=\v!yes,% + \c!buffer=temp-xml-export,% + \c!name={formula-\number\c_strc_formulas_n.xml}]% + \relax} + +\permanent\protected\def\xmlattachmml + {\iftrialtypesetting \else \ifexporting \iflocation + \dostarttagged\t!ignore\empty + \lxml_add_mml_blob{mmlattachment}\attachment + \dostoptagged + \fi \fi \fi} + +\permanent\protected\def\xmlcommentmml + {\iftrialtypesetting \else \ifexporting \iflocation + \dostarttagged\t!ignore\empty + \lxml_add_mml_blob{mmlcomment}\comment + \dostoptagged + \fi \fi \fi} + +%D This kind of feature creep is not yet configurable, nor documented. + +\permanent\protected\def\xmladdmmlsource + {\iftrialtypesetting \else \ifexporting \iflocation + \dostarttagged\t!ignore\empty + \inleftmargin{% + \lxml_add_mml_blob{mmlattachment}\attachment + \quad + \lxml_add_mml_blob{mmlcomment}\comment + }% + \dostoptagged + \fi \fi \fi} + +\protect \endinput diff --git a/tex/context/base/mkiv/math-ini.mkxl b/tex/context/base/mkxl/math-ini.mkxl index ad3ad4b20..7838d8fde 100644 --- a/tex/context/base/mkiv/math-ini.mkxl +++ b/tex/context/base/mkxl/math-ini.mkxl @@ -423,11 +423,8 @@ \expandafter\math_set_font_alternate\lastnamedcs \fi} -\protected\def\setupmathrendering % the name might change - {\dodoubleargument\math_setup_rendering} - -\def\math_setup_rendering[#1][#2]% - {\ifsecondargument +\permanent\tolerant\protected\def\setupmathrendering[#1]#*[#2]% the name might change + {\ifparameter#2\or \getparameters[\??mathstylealternative#1:][#2]% \else \getparameters[\??mathstylealternative][#1]% @@ -685,19 +682,19 @@ {\ifparameter#3\or \edef\nofmathcommandarguments{#3}% make this one m_arguments \ifx\nofmathcommandarguments\v!one - \frozen\setuvalue{\??mathcommand#1}##1{\mathcodecommand{#2}{#4{##1}}}% + \frozen\protected\defcsname\??mathcommand#1\endcsname##1{\mathcodecommand{#2}{#4{##1}}}% \orelse\ifx\nofmathcommandarguments\v!two - \frozen\setuvalue{\??mathcommand#1}##1##2{\mathcodecommand{#2}{#4{##1}{##2}}}% + \frozen\protected\defcsname\??mathcommand#1\endcsname##1##2{\mathcodecommand{#2}{#4{##1}{##2}}}% \else - \frozen\setuvalue{\??mathcommand#1}{\mathcodecommand{#2}{#4}}% + \frozen\protected\defcsname\??mathcommand#1\endcsname{\mathcodecommand{#2}{#4}}% \fi \orelse\ifparameter#2\or - \frozen\setuvalue{\??mathcommand#1}{\mathcodecommand{#2}{#4}}% + \frozen\protected\defcsname\??mathcommand#1\endcsname{\mathcodecommand{#2}{#4}}% \else - \frozen\setuvalue{\??mathcommand#1}{\mathcodecommand{nothing}{#4}}% + \frozen\protected\defcsname\??mathcommand#1\endcsname{\mathcodecommand{nothing}{#4}}% \fi \ifparameter#1\or % safeguard - \letcsnamecsname\csname#1\endcsname\csname\??mathcommand#1\endcsname + \letcsname#1\expandafter\endcsname\csname\??mathcommand#1\endcsname \fi} \permanent\protected\def\mathcommand#1% @@ -729,7 +726,7 @@ \relax \hskip-.01\emwidth} -\protected\def\showmathstruts % let's not overload \math_strut_normal +\permanent\protected\def\showmathstruts % let's not overload \math_strut_normal {\enforced\let\math_strut\math_strut_visual} \let\math_strut\math_strut_normal @@ -804,7 +801,7 @@ %D The next hack is needed needed for sine, cosine etc. -\let\mathfunction\firstofoneunexpanded +\aliased\let\mathfunction\firstofoneunexpanded \let\math_tags_function \firstofoneunexpanded \let\math_tags_functionlabeltext\mathlabeltext @@ -885,6 +882,8 @@ #2% \endgroup} +\ifdefined\apply \else \aliased\let\apply\relax \fi + \appendtoks \enforced\let\math_tags_mfunctiontxt\clf_tagmfunctiontxt \enforced\let\math_tags_mfunctionlab\clf_tagmfunctionlab @@ -1202,8 +1201,8 @@ \newconditional \knuthmode -\let\nonknuthmode\relax % no longer needed in MkIV -\let\donknuthmode\relax % no longer needed in MkIV +\aliased\let\nonknuthmode\relax % no longer needed in MkIV +\aliased\let\donknuthmode\relax % no longer needed in MkIV % \def\nonknuthmode % {\pushcatcodetable @@ -2295,14 +2294,12 @@ \fi } -\protected\def\math_style_set#1% - {\edef\m_math_style_asked{#1}% +\permanent\tolerant\protected\def\setmathstyle[#1]#;#=% so we accept [] and {} + {\edef\m_math_style_asked{#1#2}% \ifempty\m_math_style_asked \else \math_style_set_indeed \fi} -\let\setmathstyle\math_style_set - \permanent\def\installmathstyle#1#2% {\ifcsname\??mathstylecommand#1\endcsname \else \setvalue{\??mathstylecommand#1}{#2}% @@ -2353,32 +2350,6 @@ \rawprocesscommacommand[#2]\math_style_collect \letcsname\??mathstyle#1\normalexpanded{\endcsname\math_style_add_to_cache_choice}} -% \def\math_style_set_indeed -% {\csname\??mathstyle -% \ifcsname\??mathstyle\m_math_style_asked\endcsname -% \m_math_style_asked -% \else -% \??mathstyle -% \fi -% \endcsname} -% -% \setvalue{\??mathstyle\??mathstyle}% -% {\csname\??mathstylecache -% \ifcsname\??mathstylecache\m_math_style_asked\endcsname -% \m_math_style_asked -% \else -% \??mathstylecache -% \fi -% \endcsname} -% -% \setvalue{\??mathstylecache\??mathstylecache}% -% {\c_math_styles_state_style \zerocount -% \c_math_styles_state_cramped\zerocount -% \c_math_styles_state_size \zerocount -% \rawprocesscommacommand[\m_math_style_asked]\math_style_collect -% \expandafter\glet\csname\??mathstylecache\m_math_style_asked\normalexpanded{\endcsname\math_style_add_to_cache_choice}% -% \csname\??mathstylecache\m_math_style_asked\endcsname} - \def\math_style_set_indeed {\ifcsname\??mathstyle\m_math_style_asked\endcsname \lastnamedcs @@ -2398,7 +2369,7 @@ \c_math_styles_state_cramped\zerocount \c_math_styles_state_size \zerocount \rawprocesscommacommand[\m_math_style_asked]\math_style_collect - \expandafter\glet\csname\??mathstylecache\m_math_style_asked\normalexpanded{\endcsname\math_style_add_to_cache_choice}% + \gletcsname\??mathstylecache\m_math_style_asked\normalexpanded{\endcsname\math_style_add_to_cache_choice}% \csname\??mathstylecache\m_math_style_asked\endcsname} \letvalue{\??mathstyle \??mathstyle }\math_style_set_mathstyle_mathstyle % still needed? @@ -2415,26 +2386,26 @@ \permanent\protected\def\startmathstyle[#1]% {\edef\m_math_style_asked{#1}% \ifempty\m_math_style_asked - \let\stopmathstyle\relax + \enforced\aliased\let\stopmathstyle\relax \else \bgroup \math_style_set_indeed - \let\stopmathstyle\egroup + \enforced\aliased\let\stopmathstyle\egroup \fi} -\let\stopmathstyle\relax +\aliased\let\stopmathstyle\relax \permanent\protected\def\startusemathstyleparameter#1% {\edef\m_math_style_asked{#1\c!mathstyle}% \ifempty\m_math_style_asked - \let\stopusemathstyleparameter\relax + \enforced\let\stopusemathstyleparameter\relax \else \bgroup \math_style_set_indeed - \let\stopusemathstyleparameter\egroup + \enforced\let\stopusemathstyleparameter\egroup \fi} -\let\stopusemathstyleparameter\relax +\aliased\let\stopusemathstyleparameter\relax %D Something similar can be used in the (re|)|definition of \type {\text}. This %D version is a variation on the one in the math module (see \type{m-math} and|/|or @@ -2899,6 +2870,9 @@ {\clf_enablescriptunstacking \c_attr_mathunstack\plusone} +\ifdefined\stackscripts \else \aliased\let\stackscripts \relax \fi +\ifdefined\unstackscripts \else \aliased\let\unstackscripts\relax \fi + \appendtoks \enforced\let\stackscripts \math_scripts_stack \enforced\let\unstackscripts\math_scripts_unstack diff --git a/tex/context/base/mkxl/math-inl.mkxl b/tex/context/base/mkxl/math-inl.mkxl new file mode 100644 index 000000000..2c7284458 --- /dev/null +++ b/tex/context/base/mkxl/math-inl.mkxl @@ -0,0 +1,22 @@ +%D \module +%D [ file=math-inl, +%D version=2008.10.20, +%D title=\CONTEXT\ Math Macros, +%D subtitle=Inline, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Math Macros / Inline} + +\unprotect + +% The \MKII\ math grid snapping code has gone. A pity as it was rather effective +% and worked quite well (for a couple of projects where it was demanded). Other code +% might show up / move here. + +\protect \endinput diff --git a/tex/context/base/mkxl/math-int.mkxl b/tex/context/base/mkxl/math-int.mkxl new file mode 100644 index 000000000..4b3d63f2b --- /dev/null +++ b/tex/context/base/mkxl/math-int.mkxl @@ -0,0 +1,141 @@ +%D \module +%D [ file=math-int, +%D version=2007.07.19, +%D title=\CONTEXT\ Math Macros, +%D subtitle=Scripts, +%D author={Hans Hagen \& Taco Hoekwater \& Aditya Mahajan}, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Math Macros / Integrals} + +% todo: int and sum etc can be stackers + +\unprotect + +%D \startbuffer +%D $\int _a^b f(x) dx $ and also +%D $\iint _a^b f(x,y) dxdy$, +%D $\iiint _a^b f(x,y) dxdy$, +%D \startformula +%D \int _a^b f(x) dx \quad +%D \iint _a^b f(x) dx \quad +%D \iiint _a^b f(x) dx \quad +%D \stopformula +%D \stopbuffer +%D +%D Default: \getbuffer +%D +%D Displaylimits: \setupmathematics[integral=displaylimits] \getbuffer +%D +%D Limits: \setupmathematics[integral=limits] \getbuffer + +%D Adapted to mkiv by HH from code by AM. + +\installcorenamespace{mathintegral} + +\newconstant\mathintlimitmode + +\def\intlimits % also used elsewhere + {\ifcase\mathintlimitmode + \nolimits + \or + \displaylimits + \or + \limits + \or + \ifnum\attribute\mathmodeattribute=\plusone + \limits + \else + \nolimits + \fi + \else + % none + \fi} + +\letvalue{\??mathintegral nolimits}\zerocount +\letvalue{\??mathintegral displaylimits}\plusone +\letvalue{\??mathintegral limits}\plustwo +\letvalue{\??mathintegral autolimits}\plusthree +\letvalue{\??mathintegral none}\plusfour + +\appendtoks + \mathintlimitmode\executeifdefined{\??mathintegral\mathematicsparameter\s!integral}\zerocount +\to \everyswitchmathematics + +\setupmathematics +% [\v!integral=nolimits] + [\v!integral=autolimits] + +%D The following code is used for fallbacks and might become obsolete once +%D we have enough \OPENTYPE\ math fonts. + +% \def\math_repeated_integal_i +% {\int} + +% \def\math_repeated_integal_ii +% {\math_repeated_integal_i +% \math_repeated_integral_kern +% \math_repeated_integal_i +% \math_repeat_integral_finish +% \intlimits} + +% \def\math_repeated_integal_iii +% {\math_repeated_integal_i +% \math_repeated_integral_kern +% \math_repeated_integal_ii} +% +% \def\math_repeated_integal_iiii +% {\math_repeated_integal_i +% \math_repeated_integral_kern +% \math_repeated_integal_iii} +% +% \protected\def\math_repeat_integral#1% +% {\let\math_repeat_integral_finish\donothing +% \iffontchar\textfont\zerocount#1\relax +% \expandafter\math_repeat_integral_real +% \else +% \expandafter\math_repeat_integral_fake +% \fi} +% +% \def\math_repeat_integral_fake#1#2% +% {\let\math_repeat_integral_fake_symbol#2% +% \futurelet\next\math_repeat_integral_fake_indeed} +% +% \def\math_repeat_integral_real#1#2% +% {#1} +% +% \definemathcommand [iint] {\math_repeat_integral{"0222C}\normalint \math_repeated_integal_ii } % double +% \definemathcommand [iiint] {\math_repeat_integral{"0222D}\normaliint \math_repeated_integal_iii } % tripple +% \definemathcommand [iiiint] {\math_repeat_integral{"FFFFF}\normaliiint\math_repeated_integal_iiii} % quadruple +% +% \def\math_repeated_integral_kern +% {\mkern-6mu\mathchoice{\mkern-3mu}{}{}{}} +% +% \def\math_repeat_integral_fake_indeed +% {\ifx\next\limits +% \math_repeated_integral_correction +% \orelse\ifx\next\displaylimits +% \math_repeated_integral_correction +% \orelse\ifx\next\nolimits +% % nothing +% \orelse\ifcase\mathintlimitmode +% % nothing +% \else +% \math_repeated_integral_correction +% \fi +% \math_repeat_integral_fake_symbol} +% +% \def\math_repeated_integral_correction +% {\mkern-7mu\mathchoice{\mkern-2mu}{}{}{}% +% \mathop\bgroup\mkern7mu\mathchoice{\mkern2mu}{}{}{}\let\math_repeat_integral_finish\egroup} +% +% %D If the \type{\limits} option is used after \type {\iint}, use \type +% %D {\mathop} and fudge the left hand space a bit to make the subscript +% %D visually centered. + +\protect \endinput diff --git a/tex/context/base/mkxl/math-mis.mkxl b/tex/context/base/mkxl/math-mis.mkxl new file mode 100644 index 000000000..a824c5933 --- /dev/null +++ b/tex/context/base/mkxl/math-mis.mkxl @@ -0,0 +1,60 @@ +%D \module +%D [ file=math-mis, +%D version=2013.04.06, % 2007.07.19, +%D title=\CONTEXT\ Math Macros, +%D subtitle=Miscellaneous, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Math Macros / Miscellaneous} + +\unprotect + +%D This file contains left-overs moved from other files. It's mostly old stuff +%D that we keep around for compatbility reasons. + +%D \macros +%D {qedsymbol} +%D +%D [HH] The general Quod Erat Demonstrandum symbol is defined in such a way that +%D we can configure it. Because this symbol is also used in text mode, we make it +%D a normal text symbol with special behavior. + +\permanent\protected\def\qedsymbol#1% + {\ifhmode + \unskip\nobreakspace\hfill#1\par + \orelse\ifmmode + #1\relax % leading \eqno removed + \else + \dontleavehmode\emptyhbox\hfill#1\par + \fi} + +\definesymbol [qed] [\qedsymbol{\mathematics{\square}}] + +%D \macros +%D {QED} +%D +%D [HH] For compatbility reasons we also provide the \type {\QED} command. In case +%D this command is overloaded, we still have the symbol available. \symbol[qed] + +\permanent\protected\def\QED{\symbol[qed]} + +%D \macros +%D {boxed} +%D +%D [HH] Another macro that users might expect (slightly adapted): + +\permanent\protected\def\boxed % maybe obsolete + {\ifmmode\expandafter\mframed\else\expandafter\framed\fi} + +%D Something low level for scientific calculator notation: + +\permanent\protected\def\scinot#1#2% + {#1\times10^{#2}} + +\protect \endinput diff --git a/tex/context/base/mkiv/math-noa.lmt b/tex/context/base/mkxl/math-noa.lmt index 25e1823e2..25e1823e2 100644 --- a/tex/context/base/mkiv/math-noa.lmt +++ b/tex/context/base/mkxl/math-noa.lmt diff --git a/tex/context/base/mkiv/math-pln.mkxl b/tex/context/base/mkxl/math-pln.mkxl index 2e090c224..c5d814fbe 100644 --- a/tex/context/base/mkiv/math-pln.mkxl +++ b/tex/context/base/mkxl/math-pln.mkxl @@ -24,7 +24,7 @@ % might change \protected\def\hrulefill{\leaders\hrule\hfill} -\protected\def\dotfill {\cleaders\hbox{\normalstartimath\mathsurround\zeropoint\mkern1.5mu.\mkern1.5mu\normalstopimath}\hfill} +%protected\def\dotfill {\cleaders\hbox{\normalstartimath\mathsurround\zeropoint\mkern1.5mu.\mkern1.5mu\normalstopimath}\hfill} % will move diff --git a/tex/context/base/mkxl/math-rad.mklx b/tex/context/base/mkxl/math-rad.mklx new file mode 100644 index 000000000..4196bd0f7 --- /dev/null +++ b/tex/context/base/mkxl/math-rad.mklx @@ -0,0 +1,269 @@ +%D \module +%D [ file=math-rad, +%D version=2013.07.13, +%D title=\CONTEXT\ Math Macros, +%D subtitle=Radicals, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Math Macros / Radicals} + +\unprotect + +%D \starttyping +%D $\sqrt[3]{10}$ +%D \stoptyping +%D +%D This root command will be overloaded later: + +%D Old stuff: + +% \def\rootradical{\Uroot \defaultmathfamily "221A } % can be done in char-def +% \def\surdradical{\Uradical \defaultmathfamily "221A } % can be done in char-def + +\permanent\protected\def\root#1\of{\rootradical{#1}} % #2 + +\protected\def\sqrt{\doifelsenextoptionalcs\rootwithdegree\rootwithoutdegree} % will be redefined + +\permanent\protected\def\styledrootradical#1#2% so that \text works ok ... \rootradical behaves somewhat weird + {\normalexpanded{\rootradical + {\normalunexpanded{#1}}% + {\noexpand\triggermathstyle{\number\normalmathstyle}% + \normalunexpanded{#2}}}} + +% experimental new keyword: (maybe keywords should come after the symbol) +% +% \permanent\protected\def\styledrootradical#1#2% so that \text works ok ... \rootradical behaves somewhat weird +% {\Uroot style \normalmathstyle "0 "221A {#1}{#2}} + +\permanent\protected\def\rootwithdegree[#1]{\rootradical{#1}} +\permanent\protected\def\rootwithoutdegree {\rootradical {}} + +%D Even older stuff: + +% % is now a ordinary character +% +% \let\normalsurd\surd % \Uradical "0 "221A +% \permanent\protected\def\surd{\normalsurd{}} + +%D The real thing. If needed one can control matters with one of the many +%D \type {\Umath...} parameters. +%D +%D \starttyping +%D \def\R {\Umathradicaldegreeafter\textstyle0pt} +%D \def\RR{\Umathradicaldegreeafter\textstyle\dimexpr +%D \Umathradicaldegreeafter\textstyle+.1em\relax} +%D \def\RRR{\frozen\Umathradicaldegreeafter\textstyle\dimexpr +%D \Umathradicaldegreeafter\textstyle+.2em\relax} +%D +%D $ \sqrt[3]{5} \RR\sqrt[3]{5} \sqrt[3]{5} $\par +%D $ \sqrt[3]{5} {\RRR\sqrt[3]{5}} \sqrt[3]{5} $\par +%D $ \RR\sqrt[3]{5} {\RRR\sqrt[3]{5}} \sqrt[3]{5} $\par +%D +%D \def\R {\Umathradicaldegreeafter\textstyle +%D 0pt} +%D \def\RR {\Umathradicaldegreeafter\textstyle +%D 0.95\Umathradicaldegreeafter\textstyle} +%D \def\RRR{\frozen\Umathradicaldegreeafter\textstyle +%D 0.9\Umathradicaldegreeafter\textstyle} +%D +%D $ \sqrt[3]{5} \RR\sqrt[3]{5} \sqrt[3]{5} $\par +%D $ \sqrt[3]{5} {\RRR\sqrt[3]{5}} \sqrt[3]{5} $\par +%D $ \RR\sqrt[3]{5} {\RRR\sqrt[3]{5}} \sqrt[3]{5} $\par +%D +%D \def\RR {\mathopenupparameter\Umathradicaldegreeafter{.1}} +%D +%D $ \sqrt[3]{5} \RR\sqrt[3]{5} \sqrt[3]{5} $\par +%D $ \sqrt[3]{5} {\RR\sqrt[3]{5}} \sqrt[3]{5} $\par +%D \stoptyping + +\installcorenamespace{mathradical} +\installcorenamespace{mathradicalalternative} + +\installcommandhandler \??mathradical {mathradical} \??mathradical + +\setupmathradical + [\c!alternative=\v!normal, + \c!mpoffset=.25\exheight] + +\appendtoks + \frozen\instance\setuevalue{\currentmathradical}{\math_radical_handle{\currentmathradical}} +\to \everydefinemathradical + +\protected\def\math_radical_handle#tag% + {\begingroup + \edef\currentmathradical{#tag}% + \doifelsenextoptionalcs\math_radical_degree_yes\math_radical_degree_nop} + +\def\math_radical_alternative{\csname\??mathradicalalternative\mathradicalparameter\c!alternative\endcsname} + +\def\m_math_no_degree{{}} + +\def\math_radical_degree_yes[#degree]{\edef\currentmathradicaldegree{#degree}\math_radical_indeed} +\def\math_radical_degree_nop {\let\currentmathradicaldegree\m_math_no_degree\math_radical_indeed} + +\def\math_radical_indeed#body% + {\math_radical_alternative{#body}\endgroup} + +\setvalue{\??mathradicalalternative\v!default}% #body% + {\rootradical{\currentmathradicaldegree}} % {#body}} + +\setvalue{\??mathradicalalternative\v!normal}#body% + {\edef\p_color{\mathradicalparameter\c!color}% + \ifempty\p_color + \styledrootradical{\currentmathradicaldegree}{#body}% {} really needed as \rootradical expands first + \orelse\ifempty\currentmathradicaldegree + \pushcolor[\p_color]% + \styledrootradical{\currentmathradicaldegree}% + {\popcolor#body}% + \else + \pushcolor[\p_color]% + \styledrootradical{\popcolor\currentmathradicaldegree\pushcolor[\p_color]}% + {\popcolor#body}% + \fi} + +\startMPextensions + vardef math_radical_simple(expr w,h,d,o) = + (-h/2-o,h/2-o) -- + (-h/4-o,-d-o) -- + (-o,h+o) -- + (w+o,h+o) -- + (w+o,h-h/10+o) + enddef ; +\stopMPextensions + +\startuniqueMPgraphic{minifun::math:radical:default}%{...} + draw + math_radical_simple(OverlayWidth,OverlayHeight,OverlayDepth,OverlayOffset) + % withpen pencircle xscaled (2OverlayLineWidth) yscaled (3OverlayLineWidth/4) rotated 30 + withpen pencircle scaled OverlayLineWidth + % dashed evenly + withcolor OverlayLineColor ; +\stopuniqueMPgraphic + +% todo: spacing .. this is just an experiment (article driven) + +\setvalue{\??mathradicalalternative\v!mp}#body% we could use dowithnextbox + {\begingroup + \scratchoffset\mathradicalparameter\c!mpoffset + \setbox\nextbox\mathstylehbox{#body}% + % we use the \overlay variables as these are passes anyway and + % it's more efficient than using parameters + \d_overlay_width \wd\nextbox + \d_overlay_height \ht\nextbox + \d_overlay_depth \dp\nextbox + \d_overlay_offset \scratchoffset + \d_overlay_linewidth\the\dimexpr\triggeredmathstyleparameter\Umathfractionrule + % + \edef\overlaylinecolor{\mathradicalparameter\c!color}% + % + \edef\p_mp{\mathradicalparameter\c!mp}% + % + \setbox\scratchbox\hpack\bgroup % todo: tag this box as sqrt + \uniqueMPgraphic + {\p_mp}% + %{...}% + \egroup + \scratchdimen \wd\scratchbox + \scratchtopoffset \dimexpr\scratchoffset+\dp\nextbox\relax + \scratchbottomoffset\dimexpr\scratchoffset+\ht\nextbox/2\relax + \hpack to \scratchdimen{\hss\box\nextbox\hskip\scratchoffset}% + \hskip-\scratchdimen + \lower\dimexpr\scratchtopoffset\box\scratchbox% + \ifx\currentmathradicaldegree\empty \else + \setbox\scratchbox\mathstylehbox{\scriptscriptstyle\currentmathradicaldegree\hss}% + \wd\scratchbox\scratchdimen + \hskip-\scratchdimen + \raise\dimexpr\scratchbottomoffset\box\scratchbox + \fi + \endgroup} + +\definemathradical[sqrt][mp=minifun::math:radical:default] + +% \setupmathradical[sqrt][alternative=normal,color=darkblue] +% \setupmathradical[sqrt][alternative=mp,color=darkgreen] + +%D Because I wanted to illustrate some more fun stuff another mechanism +%D is provided as well ... let's put some dangerous tools in the hand of +%D math jugglers like Aditya. + +\installcorenamespace{mathornament} +\installcorenamespace{mathornamentalternative} + +\installcommandhandler \??mathornament {mathornament} \??mathornament + +\setupmathornament + [\c!alternative=\v!mp, % currently mp only .. maybe some day layer too + \c!mpoffset=.25\exheight] + +\appendtoks + \frozen\instance\setuevalue{\currentmathornament}{\math_ornament_handle{\currentmathornament}}% +\to \everydefinemathornament + +\protected\def\math_ornament_handle#tag#body% + {\begingroup + \edef\currentmathornament{#tag}% + \csname\??mathornamentalternative\mathornamentparameter\c!alternative\endcsname{#body}% + \endgroup} + +\setvalue{\??mathornamentalternative\v!mp}#body% we could use dowithnextbox + {\begingroup + \scratchoffset\mathornamentparameter\c!mpoffset + \setbox\nextbox\mathstylehbox{#body}% + \d_overlay_width \wd\nextbox + \d_overlay_height \ht\nextbox + \d_overlay_depth \dp\nextbox + \d_overlay_offset \scratchoffset + \d_overlay_linewidth\linewidth + \edef\overlaylinecolor{\mathornamentparameter\c!color}% + \edef\p_mp{\mathornamentparameter\c!mp}% + % the width of the graphic determines the width of the final result + \setbox\scratchbox\hpack{\uniqueMPgraphic{\p_mp}}% todo: add code key + tag + \hpack to \wd\scratchbox{\hss\box\nextbox\hss}% + \hskip-\wd\scratchbox + \box\scratchbox + \endgroup} + +% \startMPextensions +% vardef math_ornament_hat(expr w,h,d,o,l) = +% image ( path p ; p := +% (w/2,h + 10l) -- +% (o + w,h + o) -- +% (w/2,h + 7l) -- +% (-o,h + o) -- +% cycle ; +% fill p ; +% setbounds currentpicture to (-o,0) -- (w+o,0) -- (w+o,h+2o) -- (-o,h+2o) -- cycle ; +% ) +% enddef ; +% \stopMPextensions +% +% \startuniqueMPgraphic{math:ornament:hat} +% draw +% math_ornament_hat( +% OverlayWidth, +% OverlayHeight, +% OverlayDepth, +% OverlayOffset, +% OverlayLineWidth +% ) +% withpen +% pencircle +% xscaled (2OverlayLineWidth) +% yscaled (3OverlayLineWidth/4) +% rotated 30 +% withcolor +% OverlayLineColor ; +% draw boundingbox currentpicture; +% \stopuniqueMPgraphic +% +% \definemathornament [mathhat] [mp=math:ornament:hat] +% +% \dorecurse{8}{$\mathhat{\blackrule[width=#1ex,color=gray]}$ } + +\protect \endinput diff --git a/tex/context/base/mkxl/math-scr.mkxl b/tex/context/base/mkxl/math-scr.mkxl new file mode 100644 index 000000000..555f549f1 --- /dev/null +++ b/tex/context/base/mkxl/math-scr.mkxl @@ -0,0 +1,58 @@ +%D \module +%D [ file=math-scr, +%D version=2007.07.19, +%D title=\CONTEXT\ Math Macros, +%D subtitle=Scripts, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Math Macros / Scripts} + +\unprotect + +%D These macros were first needed by Frits (Gajes) Spijkers (of the Math4All project +%D that we participate in), and used for typesetting the minus sign that is keyed +%D into scientific calculators. We use the monospaced signs, that we also define as +%D symbol, so that they can be overloaded. We can probably do it nicer now (in lmtx). + +\def\math_scripts_raised_symbol#1% + {\mathchoice + {\math_scripts_raised_symbol_indeed5\tf {#1}}% + {\math_scripts_raised_symbol_indeed5\tf {#1}}% + {\math_scripts_raised_symbol_indeed4\tx {#1}}% + {\math_scripts_raised_symbol_indeed3\txx{#1}}} + +\def\math_scripts_raised_symbol_indeed#1#2#3% + {\mathord{{#2\raise.#1ex\hbox{#2\symbol[#3]}}}} + +\def\math_scripts_raised_number#1% + {\mathchoice + {\math_scripts_raised_number_indeed\tf {#1}}% + {\math_scripts_raised_number_indeed\tf {#1}}% + {\math_scripts_raised_number_indeed\tx {#1}}% + {\math_scripts_raised_number_indeed\txx{#1}}} + +\def\math_scripts_raised_number_indeed#1#2% + {\setbox\scratchbox\hbox{0}% + \mathord{\hbox to \wd\scratchbox{\hss#1\symbol[#2]\hss}}} + +\definesymbol[positive] [\getglyph{Mono}{+}] +\definesymbol[negative] [\getglyph{Mono}{-}] +\definesymbol[zeroamount][\getglyph{Mono}{-}] + +\permanent\protected\def\negative {\math_scripts_raised_symbol{negative}} +\permanent\protected\def\positive {\math_scripts_raised_symbol{positive}} +\permanent\protected\def\zeroamount{\math_scripts_raised_number{zeroamount}} + +%D How negative such a symbol looks is demonstrated in: $\negative 10^{\negative +%D 10^{\negative 10}}$. + +% \setuptextformulas % why here +% [\c!size=\v!normal] + +\protect \endinput diff --git a/tex/context/base/mkiv/math-stc.mklx b/tex/context/base/mkxl/math-stc.mklx index 1ee8e85a2..1f9047394 100644 --- a/tex/context/base/mkiv/math-stc.mklx +++ b/tex/context/base/mkxl/math-stc.mklx @@ -323,7 +323,6 @@ \fi} \protected\def\math_stackers_triplet#method#category#codepoint#toptext#bottomtext% - %{\math_stackers_start_group{#category}% {\begingroup \edef\currentmathstackers{#category}% \mathstackersparameter\c!left\relax @@ -333,18 +332,6 @@ \edef\p_location {\mathstackersparameter\c!location}% \edef\p_strut {\mathstackersparameter\c!strut}% \edef\p_alternative{\mathstackersparameter\c!alternative}% - % \ifx\p_order\v!reverse - % \ifsecondargument - % \edef\m_math_stackers_text_top {#bottomtext}% - % \edef\m_math_stackers_text_bottom{#toptext}% - % \else - % \edef\m_math_stackers_text_top {#toptext}% - % \let\m_math_stackers_text_bottom \empty - % \fi - % \else - % \edef\m_math_stackers_text_top {#toptext}% - % \edef\m_math_stackers_text_bottom{#bottomtext}% - % \fi \edef\m_math_stackers_text_top {#toptext}% \edef\m_math_stackers_text_bottom{#bottomtext}% \ifparameter#bottomtext\or diff --git a/tex/context/base/mkiv/math-tag.lmt b/tex/context/base/mkxl/math-tag.lmt index eb58b5450..eb58b5450 100644 --- a/tex/context/base/mkiv/math-tag.lmt +++ b/tex/context/base/mkxl/math-tag.lmt diff --git a/tex/context/base/mkiv/math-toy.mkxl b/tex/context/base/mkxl/math-toy.mkxl index 510872e3b..510872e3b 100644 --- a/tex/context/base/mkiv/math-toy.mkxl +++ b/tex/context/base/mkxl/math-toy.mkxl diff --git a/tex/context/base/mkxl/meta-blb.mkxl b/tex/context/base/mkxl/meta-blb.mkxl new file mode 100644 index 000000000..247d3a34e --- /dev/null +++ b/tex/context/base/mkxl/meta-blb.mkxl @@ -0,0 +1,53 @@ +%D \module +%D [ file=meta-blb, +%D version=2018.04.12, +%D title=\METAPOST\ Graphics, +%D subtitle=Blobs, +%D author=Hans Hagen, +%D date=\ currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{MetaPost Graphics / Blobs} + +\registerctxluafile{meta-blb}{} + +\unprotect + +\permanent\protected\def\MPLIBgetblobscaledcm#1#2#3#4#5#6#7#8#9% + {\clf_mpgetblob\MPtextbox#1\relax + \setbox\MPbox\hpack\bgroup + \dotransformnextbox{#2}{#3}{#4}{#5}{#6}{#7}% + \vpack to \zeropoint\bgroup + \vss + \hpack to \zeropoint \bgroup + % \fastsxsy{#8}{#9}{\raise\dp\MPtextbox\box\MPtextbox}% + \fastsxsy{#8}{#9}{\box\MPtextbox}% + \hss + \egroup + \egroup + \egroup + \smashbox\MPbox + \box\MPbox} + +%D An example of usage: + +\definefontfeature[followtext][liga=no] + +\permanent\protected\def\MPLIBfollowtext#1#2% + {\begingroup + \scratchcounter#1\relax + \setbox\scratchbox\hbox{\addff{followtext}#2}% + \clf_MPLIBconvertfollowtext\scratchcounter\scratchbox + \endgroup} + +%D New: + +\newtoks\mpblobtext + +\permanent\protected\mpblobtext{\global\setbox\mptextbox\vbox{\clf_mpblobtext}} + +\protect \endinput diff --git a/tex/context/base/mkxl/meta-fig.mkxl b/tex/context/base/mkxl/meta-fig.mkxl new file mode 100644 index 000000000..9ddd5e394 --- /dev/null +++ b/tex/context/base/mkxl/meta-fig.mkxl @@ -0,0 +1,71 @@ +%D \module +%D [ file=meta-fig, +%D version=2000.09.07, +%D title=\METAPOST\ Graphics, +%D subtitle=Stand Alone Graphics, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{MetaPost Graphics / Stand Alone Graphics} + +\unprotect + +%D This module implements a method for defining stand||alone||graphics, that is, +%D each graphic gets is own page. Because graphics are wrapped in a \type {\framed}, +%D you can add overlays to the graphic directly, and since the whole \CONTEXT\ +%D machinery is available, you can also add page backgrounds. +%D +%D \starttyping +%D \setupMPpage +%D [offset=1pt, +%D background=color, +%D backgroundcolor=green] +%D +%D \startMPpage +%D fill fullcircle scaled 10cm withcolor red ; +%D \stopMPpage +%D +%D \startMPpage +%D fill fullsquare rotated 45 scaled 8cm withcolor blue ; +%D \stopMPpage +%D \stoptyping +%D +%D Although this is hardly of any use, you can mix these definitions with the text +%D flow, since all settings are kept local. The page is clipped to the image size. + +\definefittingpage + [MPpage] + [\c!align=, + \c!command=\meta_process_graphic_command, + \c!instance=] + +\permanent\protected\def\setupMPpage + {\setupfittingpage[MPpage]} + +\protected\def\meta_process_graphic_command + {\doif{\fittingpageparameter\c!alternative}\v!offset + {\def\meta_relocate_graphic{\clf_setpageorigin\MPllx\MPlly\relax}}% + \meta_process_graphic_instance{\fittingpageparameter\c!instance}} + +%D \macros +%D {MPfigure} +%D +%D A bit out of place, here but nevertheless: + +\permanent\protected\def\MPfigure#1#2% test for dup figure, can be replaced by a textext + {\bgroup + \getfiguredimensions[#1]% [\c!object=\v!no] already set + \startMPcode + draw externalfigure "#1" + xscaled \the\dimexpr\figurewidth \relax\space % must be points + yscaled \the\dimexpr\figureheight\relax\space % must be points + #2 ; + \stopMPcode + \egroup} + +\protect \endinput diff --git a/tex/context/base/mkxl/meta-fnt.mkxl b/tex/context/base/mkxl/meta-fnt.mkxl new file mode 100644 index 000000000..690571c79 --- /dev/null +++ b/tex/context/base/mkxl/meta-fnt.mkxl @@ -0,0 +1,33 @@ +%D \module +%D [ file=meta-fnt, +%D version=2013.09.06, +%D title=\METAPOST\ Graphics, +%D subtitle=Fonts, +%D author=Hans Hagen, +%D date=\ currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{MetaPost Graphics / Fonts} + +\registerctxluafile{meta-fnt}{} + +\unprotect + +\permanent\tolerant\protected\def\definemetafont[#1]#*[#2]#*[#3]% + {\clf_definemetafont + fontname {#1}% + filename {#2}% + % no #3 settings yet (compose, instances) + \relax} + +% \startluacode +% metapost.fonts.define { fontname = "bidi-symbols", filename = "bidi-symbols.mp" } +% \stopluacode + +% \definemetafont[bidi-symbols][bidi-symbols.mp] + +\protect \endinput diff --git a/tex/context/base/mkxl/meta-fun.mkxl b/tex/context/base/mkxl/meta-fun.mkxl new file mode 100644 index 000000000..e30660392 --- /dev/null +++ b/tex/context/base/mkxl/meta-fun.mkxl @@ -0,0 +1,25 @@ +%D \module +%D [ file=meta-fun, +%D version=2009.06.02, +%D title=\METAPOST\ Graphics, +%D subtitle=Goodies, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{MetaPost Graphics / Goodies} + +\registerctxluafile{meta-fun}{} + +\unprotect + +%D Just a few handy helpers: + +\ifdefined\MPtoks\else \newtoks\MPtoks \fi +\ifdefined\MPbox \else \newbox \MPbox \fi + +\protect \endinput diff --git a/tex/context/base/mkxl/meta-grd.mkxl b/tex/context/base/mkxl/meta-grd.mkxl new file mode 100644 index 000000000..009149e46 --- /dev/null +++ b/tex/context/base/mkxl/meta-grd.mkxl @@ -0,0 +1,105 @@ +%D \module +%D [ file=meta-grd, +%D version=2012.06.28, +%D title=\METAPOST\ Graphics, +%D subtitle=grids, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{MetaPost Graphics / Grids} + +\unprotect + +%D This used to be a \TEX\ method, and a rather old one too. We keep it around but +%D in a more modern way. +%D +%D \startbuffer +%D \basegrid +%D [nx=8,ny=5, +%D dx=.5,dy=.25, +%D unit=cm,scale=2,factor=1, +%D offset=1ex,xstep=2,ystep=1, +%D align=middle,style=\tt\tx] +%D \stopbuffer +%D +%D \typebuffer +%D +%D \placefigure +%D {An example of a grid.} +%D {\getbuffer} + +\startuseMPgraphic{meta:grd:basegrid} + begingroup ; + + save sc, dx, dy, wd, ht, ox, oy, ax, ay ; + + sc = \directdummyparameter\c!factor*\directdummyparameter\c!scale ; + dx = \MPdpar\directdummyparameter\c!dx*sc ; + dy = \MPdpar\directdummyparameter\c!dy*sc ; + wd = \directdummyparameter\c!nx*dx ; + ht = \directdummyparameter\c!ny*dy ; + ox = \MPdpar\directdummyparameter\c!xoffset\relax ; + oy = \MPdpar\directdummyparameter\c!yoffset\relax ; + + if "\directdummyparameter\c!align" = "\v!middle" : + ax = \MPdpar\directdummyparameter\c!dx/2 + ay = \MPdpar\directdummyparameter\c!dy/2 + else : + ax = 0 ; + ay = 0 ; + fi ; + + draw image ( + for i=0 step dx until wd : draw (i,0) -- (i,ht) ; endfor ; + for i=0 step dy until ht : draw (0,i) -- (wd,i) ; endfor ; + ) + withpen pencircle scaled \MPdpar\directdummyparameter\c!rulethickness\space + withcolor "\directdummyparameter\c!rulecolor" ; + + draw image ( + if \directdummyparameter\c!xstep > 0 : + for i=1 step \directdummyparameter\c!xstep until \directdummyparameter\c!nx : + draw thetextext.bot(decimal i,(i*dx-ax,oy)); + endfor ; + fi ; + if \directdummyparameter\c!ystep > 0 : + for i=1 step \directdummyparameter\c!ystep until \directdummyparameter\c!ny : + draw thetextext.lft(decimal i,(ox,i*dy-ay)) ; + endfor ; + fi ; + ) + withcolor "\directdummyparameter\c!color" ; + + endgroup ; +\stopuseMPgraphic + +\permanent\tolerant\protected\def\basegrid[#1]% + {\dontleavehmode + \hbox\bgroup + \getdummyparameters + [\c!nx=10,\c!ny=10,% + \c!dx=.5,\c!dy=.5,% + \c!xstep=0,\c!ystep=0,% + \c!unit=\s!cm,\c!scale=1,\c!factor=1,% + \c!offset=.25\exheight,% + \c!xoffset=\directdummyparameter\c!offset,% + \c!yoffset=\directdummyparameter\c!offset,% + \c!align=,% + \c!color=\currentcolorname,% + \c!rulecolor=\currentcolorname,% + \c!rulethickness=\linewidth,% + #1]% + \usedummystyleandcolor\c!style\c!color + \setexpandeddummyparameter\c!dx{\directdummyparameter\c!dx\directdummyparameter\c!unit}% + \setexpandeddummyparameter\c!dy{\directdummyparameter\c!dy\directdummyparameter\c!unit}% + \useMPgraphic{meta:grd:basegrid}% + \egroup} + +\aliased\let\grid\basegrid + +\protect \endinput diff --git a/tex/context/base/mkiv/meta-imp-experiments.mkxl b/tex/context/base/mkxl/meta-imp-experiments.mkxl index 644a8fff0..644a8fff0 100644 --- a/tex/context/base/mkiv/meta-imp-experiments.mkxl +++ b/tex/context/base/mkxl/meta-imp-experiments.mkxl diff --git a/tex/context/base/mkiv/meta-imp-gamesymbols.mkxl b/tex/context/base/mkxl/meta-imp-gamesymbols.mkxl index d79e59f69..d79e59f69 100644 --- a/tex/context/base/mkiv/meta-imp-gamesymbols.mkxl +++ b/tex/context/base/mkxl/meta-imp-gamesymbols.mkxl diff --git a/tex/context/base/mkiv/meta-imp-symbols.mkxl b/tex/context/base/mkxl/meta-imp-symbols.mkxl index f88fd6f87..f88fd6f87 100644 --- a/tex/context/base/mkiv/meta-imp-symbols.mkxl +++ b/tex/context/base/mkxl/meta-imp-symbols.mkxl diff --git a/tex/context/base/mkiv/meta-imp-threesix.mkxl b/tex/context/base/mkxl/meta-imp-threesix.mkxl index 56a400b45..56a400b45 100644 --- a/tex/context/base/mkiv/meta-imp-threesix.mkxl +++ b/tex/context/base/mkxl/meta-imp-threesix.mkxl diff --git a/tex/context/base/mkiv/meta-ini.mkxl b/tex/context/base/mkxl/meta-ini.mkxl index 3e1c54d53..c715cbca5 100644 --- a/tex/context/base/mkiv/meta-ini.mkxl +++ b/tex/context/base/mkxl/meta-ini.mkxl @@ -70,9 +70,9 @@ \restoreendofline % see interferences-001.tex \to \everyMPgraphic -\def\MPruntimefile {mprun} -\def\currentMPformat {metafun} -\def\defaultMPinstance{metafun} +\mutable \def\MPruntimefile {mprun} +\mutable \def\currentMPformat {metafun} +\immutable\def\defaultMPinstance{metafun} \installcorenamespace{mpinstance} \installcorenamespace{mpinclusions} @@ -98,17 +98,17 @@ \gtoksapp\t_meta_definitions{#2}% \let\currentMPinstance\m_meta_saved_instance} -\permanent\let\stopMPdefinitions\relax +\aliased\let\stopMPdefinitions\relax \permanent\tolerant\protected\def\startMPextensions#=#:#2\stopMPextensions % we could use buffers instead {\clf_setmpextensions{#1}{#2}} -\permanent\let\stopMPextensions\relax +\aliased\let\stopMPextensions\relax \permanent\protected\def\startMPinitializations#1\stopMPinitializations % for all instances, when enabled {\gtoksapp\t_meta_initializations{#1}} -\permanent\let\stopMPinitializations\relax +\aliased\let\stopMPinitializations\relax \permanent\tolerant\protected\def\startMPinclusions[#1]#*#=#:#3\stopMPinclusions {\let\m_meta_saved_instance\currentMPinstance % \pushmacro @@ -122,7 +122,7 @@ \gtoksapp\t_meta_inclusions{#3}% \let\currentMPinstance\m_meta_saved_instance} % \popmacro -\permanent\let\stopMPinclusions\relax +\aliased\let\stopMPinclusions\relax % The next was broken since we added instances so it will go away! @@ -229,7 +229,7 @@ \def\meta_end_graphic_group {\endgroup} -\def\MPaskedfigure{false} +\mutable\def\MPaskedfigure{false} \def\meta_flush_current_initializations {\ifconditional\c_meta_include_initializations @@ -359,7 +359,7 @@ \permanent\protected\def\finalizeMPdrawing {\MPdrawingdonetrue} -\let\MPdrawingdata\empty +\mutable\let\MPdrawingdata\empty \permanent\protected\def\resetMPdrawing {\glet\MPdrawingdata\empty @@ -389,7 +389,7 @@ {\xdef\MPdrawingdata{\MPdrawingdata#2}}% \egroup} -\permanent\let\stopMPdrawing\relax +\aliased\let\stopMPdrawing\relax \permanent\def\MPdrawing#1% {\relax @@ -399,9 +399,9 @@ \egroup} \permanent\protected\def\startMPclip#1#2\stopMPclip % todo: store at the lua end or just store less - {\setgvalue{\??mpclip#1}{#2}} + {\gdefcsname\??mpclip#1\endcsname{#2}} -\permanent\let\stopMPclip\relax +\aliased\let\stopMPclip\relax \protected\def\meta_grab_clip_path#1#2#3% {\begingroup @@ -502,7 +502,7 @@ \permanent\tolerant\protected\def\presetMPvariable[#1]#*[#2=#3]% {\ifcsname\??graphicvariable#1:#2\endcsname \else - \setvalue{\??graphicvariable#1:#2}{#3}% + \defcsname\??graphicvariable#1:#2\endcsname{#3}% \fi} \permanent\def\MPrawvar#1#2% no checking @@ -570,8 +570,8 @@ \meta_prepare_variable_dimension \fi} -\let\MPvar \MPvariable -\let\setMPvariables\setupMPvariables +\aliased\let\MPvar \MPvariable +\aliased\let\setMPvariables\setupMPvariables %D \macros %D {startuniqueMPgraphic, uniqueMPgraphic} @@ -669,23 +669,23 @@ \meta_enable_include % redundant \global\advance\c_meta_object_counter\plusone \meta_use_box{\number\c_meta_object_counter}\hpack{\meta_process_graphic{#3}}% was vbox, graphic must end up as hbox - \setxvalue{\??mpgraphic\overlaystamp:#1}{\meta_reuse_box{\number\c_meta_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}% + \xdefcsname\??mpgraphic\overlaystamp:#1\endcsname{\meta_reuse_box{\number\c_meta_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}% \csname\??mpgraphic\overlaystamp:#1\endcsname\empty \fi \endgroup} % todo: we partially expand -\protected\def\startuniqueMPgraphic +\permanent\protected\def\startuniqueMPgraphic {\dodoublegroupempty\meta_start_unique_graphic} -\permanent\let\stopuniqueMPgraphic\relax +\aliased\let\stopuniqueMPgraphic\relax \def\meta_start_unique_graphic#1% {\normalexpanded{\meta_start_unique_graphic_indeed{#1}}} \permanent\protected\def\meta_start_unique_graphic_indeed#1#2#3\stopuniqueMPgraphic - {\setgvalue{\??mpgraphic#1}{\meta_handle_unique_graphic{#1}{#2}{#3}}} + {\gdefcsname\??mpgraphic#1\endcsname{\meta_handle_unique_graphic{#1}{#2}{#3}}} \permanent\tolerant\protected\def\uniqueMPgraphic#=#*#=% {\meta_begin_graphic_group{#1}% @@ -707,24 +707,24 @@ \permanent\protected\def\startuseMPgraphic % todo, modernize {\dodoublegroupempty\meta_start_use_graphic} -\permanent\let\stopuseMPgraphic\relax +\aliased\let\stopuseMPgraphic\relax \def\meta_start_use_graphic#1% {\normalexpanded{\meta_start_use_graphic_indeed{#1}}} \protected\def\meta_start_use_graphic_indeed#1#2#3\stopuseMPgraphic - {\setgvalue{\??mpgraphic#1}{\meta_handle_use_graphic{#1}{#2}{#3}}} + {\gdefcsname\??mpgraphic#1\endcsname{\meta_handle_use_graphic{#1}{#2}{#3}}} \permanent\protected\def\startusableMPgraphic % redundant but handy % todo, modernize {\dodoublegroupempty\meta_start_usable_graphic} -\permanent\let\stopusableMPgraphic\relax +\aliased\let\stopusableMPgraphic\relax \def\meta_start_usable_graphic#1% {\normalexpanded{\meta_start_usable_graphic_indeed{#1}}} \protected\def\meta_start_usable_graphic_indeed#1#2#3\stopusableMPgraphic - {\setgvalue{\??mpgraphic#1}{\meta_handle_use_graphic{#1}{#2}{#3}}} + {\gdefcsname\??mpgraphic#1\endcsname{\meta_handle_use_graphic{#1}{#2}{#3}}} \def\meta_handle_reusable_graphic#1#2#3% {\begingroup @@ -736,20 +736,20 @@ \meta_enable_include % redundant \global\advance\c_meta_object_counter\plusone \meta_use_box{\number\c_meta_object_counter}\hpack{\meta_process_graphic{#3}}% was vbox, graphic must end up as hbox - \setxvalue{\??mpgraphic#1}{\meta_reuse_box{\number\c_meta_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}% + \gdefcsname\??mpgraphic#1\endcsname{\meta_reuse_box{\number\c_meta_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}% \csname\??mpgraphic#1\endcsname\empty \endgroup} \permanent\protected\def\startreusableMPgraphic % todo, modernize {\dodoublegroupempty\meta_start_reusable_graphic} -\permanent\let\stopreusableMPgraphic\relax +\aliased\let\stopreusableMPgraphic\relax \def\meta_start_reusable_graphic#1% {\normalexpanded{\meta_start_reusable_graphic_indeed{#1}}} \protected\def\meta_start_reusable_graphic_indeed#1#2#3\stopreusableMPgraphic - {\setgvalue{\??mpgraphic#1}{\meta_handle_reusable_graphic{#1}{#2}{#3}}} + {\gdefcsname\??mpgraphic#1\endcsname{\meta_handle_reusable_graphic{#1}{#2}{#3}}} \permanent\tolerant\protected\def\useMPgraphic#=#*#=% {\meta_begin_graphic_group{#1}% @@ -791,14 +791,14 @@ \permanent\tolerant\protected\def\startuniqueMPpagegraphic % todo the modern way {\dodoublegroupempty\meta_start_unique_page_graphic} -\permanent\let\stopuniqueMPpagegraphic\relax +\aliased\let\stopuniqueMPpagegraphic\relax \def\meta_start_unique_page_graphic#1% {\normalexpanded{\meta_start_unique_page_graphic_indeed{#1}}} \protected\def\meta_start_unique_page_graphic_indeed#1#2#3\stopuniqueMPpagegraphic % inefficient, double storage - {\setgvalue{\??mpgraphic o:#1}{\meta_handle_unique_graphic{o:#1}{#2}{#3}}% % but these also keep the state - \setgvalue{\??mpgraphic e:#1}{\meta_handle_unique_graphic{e:#1}{#2}{#3}}} % and meaning will be redefined + {\gdefcsname\??mpgraphic o:#1\endcsname{\meta_handle_unique_graphic{o:#1}{#2}{#3}}% % but these also keep the state + \gdefcsname\??mpgraphic e:#1\endcsname{\meta_handle_unique_graphic{e:#1}{#2}{#3}}} % and meaning will be redefined \permanent\tolerant\protected\def\uniqueMPpagegraphic#=#=% {\meta_begin_graphic_group{#1}% @@ -827,10 +827,10 @@ \edef\overlaystamp{\overlaystamp:\MPvariable{#1}}} \permanent\protected\def\getMPdata {\clf_getMPdata} - \let\rawMPdata \clf_getMPdata % we need frozen at the lua end + \aliased\let\rawMPdata \clf_getMPdata % we need frozen at the lua end \permanent\protected\def\getMPstored{\clf_getMPstored} - \let\rawMPstored \clf_getMPstored % we need frozen at the lua end + \aliased\let\rawMPstored \clf_getMPstored % we need frozen at the lua end %D We need this trick because we need to make sure that the tex scanner sees %D newlines and does not quit. Also, we do need to flush the buffer under a normal @@ -851,7 +851,7 @@ %D In order to synchronize the main \TEX\ run and the runs local to \METAPOST, %D environments can be passed. -\protected\def\startMPenvironment +\permanent\protected\def\startMPenvironment {\begingroup \catcode\endoflineasciicode\ignorecatcode \meta_start_environment} @@ -868,9 +868,9 @@ \fi \clf_mptexset{\detokenize{#2}}} -\permanent\let\stopMPenvironment\relax +\aliased\let\stopMPenvironment\relax -\protected\def\resetMPenvironment +\permanent\protected\def\resetMPenvironment {\clf_mptexreset} \protected\def\useMPenvironmentbuffer[#1]% @@ -902,7 +902,7 @@ \meta_process_graphic{#2}% \endgroup} -\permanent\let\stopMPcode\relax +\aliased\let\stopMPcode\relax %D This one is not optimized because it's only used for small snippets, if it %D is used at all. @@ -927,7 +927,7 @@ % \startMPrun{mprun} input mp-www.mp ; \stopMPrun % instance % \externalfigure[mprun.4][width=10cm,height=8cm] -\let\MPruninstance\defaultMPinstance +\mutable\let\MPruninstance\defaultMPinstance \permanent\protected\def\useMPrun#1#2% name n {\begingroup @@ -938,7 +938,7 @@ \permanent\tolerant\protected\def\startMPrun#=#:#2\stopMPrun {\normalexpanded{\startuseMPgraphic{\iftok{#1}\emptytoks mprun\else#1\fi}}#2\stopuseMPgraphic} -\permanent\let\stopMPrun\relax +\aliased\let\stopMPrun\relax %D The \type {\resetMPenvironment} is a quick way to erase %D the token list. @@ -1142,7 +1142,7 @@ \ifcsname\??mpgraphic e:#1\endcsname\expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments\fi} -\let\doifMPgraphicelse\doifelseMPgraphic +\aliased\let\doifMPgraphicelse\doifelseMPgraphic %D New: @@ -1222,8 +1222,8 @@ \permanent\tolerant\protected\def\startstaticMPgraphic#=#:#=#:#3\stopstaticMPgraphic {\startreusableMPgraphic{\??mpstaticgraphic#1}{#2}#3\stopreusableMPgraphic} -\permanent\let\stopstaticMPfigure \relax -\permanent\let\stopstaticMPgraphic\relax +\aliased\let\stopstaticMPfigure \relax +\aliased\let\stopstaticMPgraphic\relax \permanent\tolerant\protected\def\usestaticMPfigure[#1]#*[#2]% {\ifarguments\or @@ -1316,8 +1316,8 @@ \prependtoks \clf_mppushvariables \to \everybeforepagebody \appendtoks \clf_mppopvariables \to \everyafterpagebody -\let\MPpushvariables\clf_mppushvariables -\let\MPpopvariables \clf_mppopvariables +\aliased\let\MPpushvariables\clf_mppushvariables +\aliased\let\MPpopvariables \clf_mppopvariables %D We also provide an outputless run: @@ -1335,7 +1335,7 @@ \egroup \endgroup} -\permanent\let\stopMPcalculation\relax +\aliased\let\stopMPcalculation\relax %D \macros %D {setupMPgraphics} @@ -1366,6 +1366,8 @@ %D [mpy=\jobname.mpy] %D \stoptyping +\mutable\let\MPdataMPYfile\empty + \appendtoks \edef\p_mpy{\directMPgraphicsparameter{mpy}}% \ifempty\p_mpy \else diff --git a/tex/context/base/mkxl/meta-lua.mkxl b/tex/context/base/mkxl/meta-lua.mkxl new file mode 100644 index 000000000..e06677d5e --- /dev/null +++ b/tex/context/base/mkxl/meta-lua.mkxl @@ -0,0 +1,95 @@ +%D \module +%D [ file=meta-lua, +%D version=2012.07.23, +%D title=\METAPOST\ Integrated Graphics, +%D subtitle=Templates, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Don't use this code yet. I use it in some experimental rendering of graphics +%D based on output from database queries. It's not that pretty but will be +%D considered when the (similar) lmx code is redone. Also, dropping the print +%D variant makes it nicer. This experiment is part of playing with several template +%D mechanisms. (Also see trac-lmx.) +%D +%D Note for myself: see if the (bar)chart code use in q2p can use this kind of +%D magic. Basically we then need a channel to data. + +\writestatus{loading}{MetaPost Library Graphics / Templates} + +\registerctxluafile{meta-lua}{} + +\continueifinputfile{meta-lua.mkiv} + +\starttext + +% conforming btex ... etex + +\startbuffer[test-a] + blua for i=1,100,5 do elua + draw fullcircle scaled (blua p(i) elua * cm) withcolor green withpen pencircle scaled 4 ; + blua end elua + + blua for i=1,100,10 do elua + draw fullcircle scaled (blua p(i) elua * cm) withcolor red withpen pencircle scaled 2 ; + blua end elua +\stopbuffer + +\startMPpage[offset=10pt] + input "mpstemplate://buffer?name=test-a" ; +\stopMPpage + +% conforming lmx + +\startbuffer[test-b] + <?lua for i=1,100,5 do ?> + draw fullcircle scaled (<?lua p(i) ?> * cm) withcolor green withpen pencircle scaled 4 ; + <?lua end ?> + + <?lua for i=1,100,10 do ?> + draw fullcircle scaled (<?lua p(i) ?> * cm) withcolor red withpen pencircle scaled 2 ; + <?lua end ?> +\stopbuffer + +\startMPpage[offset=10pt] + input "mpstemplate://buffer?name=test-b" ; +\stopMPpage + +\startMPpage[offset=10pt] + picture p[] ; % we can't input nested + input "mpstemplate://buffer?name=test-a&method=metapost" ; + p[1] := currentpicture ; currentpicture := nullpicture ; + input "mpstemplate://buffer?name=test-b&method=xml" ; + p[2] := currentpicture ; currentpicture := nullpicture ; + draw p[1] ysized 3cm ; + draw p[2] ysized 4cm shifted (4cm,0) ; +\stopMPpage + +% a mixture (using a wrapped input) + +\startMPpage[offset=10pt] + draw image (loadfile("mpstemplate://buffer?name=test-a&method=metapost")) ysized 3cm shifted (4cm,0cm) ; + draw image (loadfile("mpstemplate://buffer?name=test-b&method=xml")) ysized 3cm shifted (0cm,4cm) ; + draw loadimage ("mpstemplate://buffer?name=test-a&method=metapost") ysized 4cm shifted (4cm,4cm) ; + draw loadimage ("mpstemplate://buffer?name=test-b&method=xml") ysized 4cm shifted (0cm,0cm) ; +\stopMPpage + +% conforming myself + +\startluacode + context.startMPpage { offset = "10pt" } + for i=1,100,5 do + context("draw fullcircle scaled (%s * cm) withcolor green withpen pencircle scaled 4 ;",i) + end + for i=1,100,10 do + context("draw fullcircle scaled (%s * cm) withcolor red withpen pencircle scaled 2 ;",i) + end + context.stopMPpage() +\stopluacode + +\stoptext diff --git a/tex/context/base/mkiv/meta-mac.mkxl b/tex/context/base/mkxl/meta-mac.mkxl index 76b7396ae..76b7396ae 100644 --- a/tex/context/base/mkiv/meta-mac.mkxl +++ b/tex/context/base/mkxl/meta-mac.mkxl diff --git a/tex/context/base/mkxl/meta-nod.mkxl b/tex/context/base/mkxl/meta-nod.mkxl new file mode 100644 index 000000000..a89901edb --- /dev/null +++ b/tex/context/base/mkxl/meta-nod.mkxl @@ -0,0 +1,241 @@ +%D \module +%D [ file=meta-nod, +%D version=2016.11.23, +%D title=\METAPOST\ Graphics, +%D subtitle=Nodes, +%D author={Alan Braslau and Hans Hagen}, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\registerctxluafile{meta-nod}{} + +\unprotect + +\defineMPinstance + [nodes] + [\s!format=metafun, + \s!extensions=\v!yes, + \s!initializations=\v!yes, + \c!method=\s!double] + +\defineframed + [node] + [\c!frame=\v!off] + +\defineframed + [smallnode] + [node] + [\c!foregroundstyle=\small] + +% \startMPdefinitions{nodes} +% loadmodule "node" ; +% \stopMPdefinitions + +\protect + +%D This module provides a simple \TEX\ layer on top of the nodes library that is +%D preloaded in \METAFUN. More information can be found in the manual and article. +%D +%D We strongly advice to use the \METAPOST\ interface and only provide this \TEX\ +%D variant as proof of concept. There are no plans to extend this module because we +%D see no advantage in using a \TEX\ interface over a \METAPOST\ one. +%D +%D \startbuffer +%D \startnodes +%D \placenode[0,0]{A} +%D \placenode[1,0]{B} +%D \connectnodes [0,1] [option=doublearrow] +%D \stopnodes +%D +%D \startnodes[dx=2cm,rotation=45] +%D \placenode[0,0]{A} +%D \placenode[1,0]{B} +%D \placenode[1,1]{C} +%D \placenode[0,1]{D} +%D \connectnodes [0,2] [option=doublearrow,label=a,offset=.05] +%D \connectnodes [1,3] [option=doublearrows] +%D \stopnodes +%D +%D \startnodes[dx=2cm,dy=2cm] +%D \nodeMPcode{ahlength := 12pt ; ahangle := 30 ; ahvariant := 1 ;} +%D \mpcode{ahlength := 12pt ; ahangle := 30 ; ahvariant := 1 ;} +%D \placenode[0,1]{\node{A}} +%D \placenode[1,1]{\node{B}} +%D \placenode[0,0]{\node{C}} +%D \placenode[1,0]{\node{D}} +%D \connectnodes [0,3] [option=arrow,label={ }] +%D \connectnodes [1,2] [option=arrow] +%D \stopnodes +%D \stopbuffer +%D +%D \typebuffer +%D +%D \startlinecorrection \getbuffer \stoplinecorrection + +\unprotect + +\installcorenamespace{metanodes} +\installcorenamespace{metanodesoption} +\installcorenamespace{metanodesalternative} +\installcorenamespace{metanodesposition} + +% todo: maybe instances + +\installparameterhandler \??metanodes {metanodes} +\installsetuphandler \??metanodes {metanodes} + +\setupmetanodes + [\c!option =, + \c!alternative =, + \c!offset =0, + \c!position =, + \c!label =, + \c!dx =2\emwidth, + \c!dy =2\emwidth, + \c!rotation =90, + \c!rulethickness =.5pt, + \c!command =] + +\newtoks\t_every_meta_nodes +\newtoks\t_meta_nodes + +%D Hm, we started out simple but it now quickly becomes the usual mess of \TEX, +%D \METAPOST\ and \LUA. Hard to understand. + +\newcount\c_meta_nodes_n + +\aliased\let\stopnodes\relax + +\permanent\tolerant\protected\def\startnodes[#1]#:#2\stopnodes + {\hpack\bgroup + \setupcurrentmetanodes[#1]% + \edef\p_meta_option{\metanodesparameter\c!option}% + \edef\p_meta_alternative{\metanodesparameter\c!alternative}% + \the\t_every_meta_nodes + \c_meta_nodes_n\zerocount + \t_meta_nodes\emptytoks + #2\removeunwantedspaces + % for alan, will be commented: + \writestatus{metanodes}{\detokenize\expandafter{\the\t_meta_nodes}}% + \clf_grph_nodes_initialize + \startMPcode + mfun_node_init(% + \the\dimexpr\metanodesparameter\c!dx\relax,% + \the\dimexpr\metanodesparameter\c!dy\relax,% + \metanodesparameter\c!rotation% + ) ; + \the\t_meta_nodes ; + mfun_node_flush ; + \stopMPcode + \clf_grph_nodes_reset + \egroup} + +\permanent\tolerant\protected\def\grph_nodes_node[#1]#*[#2]% + {\grph_nodes_node_indeed[#1][#2]} + +\def\grph_nodes_node_indeed[#1,#2][#3]#4% + {\begingroup + \setupcurrentmetanodes[#3]% + \edef\p_label{#4}% + \edef\p_reference{\metanodesparameter\c!reference}% + \ifx\p_reference\empty\else + \clf_grph_nodes_register{\p_reference}\c_meta_nodes_n\relax + \fi + \normalexpanded{\endgroup\noexpand\etoksapp\t_meta_nodes{% + mfun_node_make(\number#1,\number#2% + \ifx\p_label\empty + ,""% + \else + ,"\metanodesparameter\c!command{\p_label}"% + \fi + );% + }}% + \advance\c_meta_nodes_n\plusone} + +\appendtoks + \enforced\let\placenode\grph_nodes_node +\to \t_every_meta_nodes + +\permanent\tolerant\protected\def\grph_nodes_fromto[#1]#*[#2]% + {\grph_nodes_fromto_indeed[#1][#2]}% get rid of {n,m} % todo: we can use #_ or so + +\letvalue{\??metanodesposition }\empty +\setvalue{\??metanodesposition top}{.top} +\setvalue{\??metanodesposition bottom}{.bot} +\setvalue{\??metanodesposition left}{.lft} +\setvalue{\??metanodesposition right}{.rt} +\setvalue{\??metanodesposition upperleft}{.ulft} +\setvalue{\??metanodesposition topleft}{.ulft} +\setvalue{\??metanodesposition lefttop}{.ulft} +\setvalue{\??metanodesposition upperright}{.urt} +\setvalue{\??metanodesposition topright}{.urt} +\setvalue{\??metanodesposition righttop}{.urt} +\setvalue{\??metanodesposition lowerleft}{.llft} +\setvalue{\??metanodesposition bottomleft}{.llft} +\setvalue{\??metanodesposition leftbottom}{.llft} +\setvalue{\??metanodesposition lowerright}{.lrt} +\setvalue{\??metanodesposition bottomright}{.lrt} +\setvalue{\??metanodesposition rightbottom}{.lrt} + +\def\grph_nodes_fromto_indeed[#1,#2][#3]% we can't group because etoksapp doesn't like that + {\begingroup + \setupcurrentmetanodes[#3]% + \edef\p_label {\metanodesparameter\c!label}% + \edef\p_rulethickness{\metanodesparameter\c!rulethickness}% + \edef\p_command {\metanodesparameter\c!command}% better get an error early + \normalexpanded{\endgroup\noexpand\etoksapp\t_meta_nodes{% + \ifcsname\??metanodesalternative\metanodesparameter\c!alternative\endcsname + \lastnamedcs + \else + \csname\??metanodesalternative\endcsname + \fi + \space + mfun_nodes_fromto\begincsname\??metanodesposition\metanodesparameter\c!position\endcsname(% + \metanodesparameter\c!offset,% + % \number#1,\number#2% + \clf_grph_nodes_resolve{#1},\clf_grph_nodes_resolve{#2}% + \ifempty\p_label + ,""% + \else + ,"\ifempty\p_command\p_label\else\p_command{\p_label}\fi"% + \fi + )% + \space + \ifcsname\??metanodesoption\metanodesparameter\c!option\endcsname + \lastnamedcs + \else + \csname\??metanodesoption\endcsname + \fi + \space + \ifx\p_rulethickness\empty \else + withpen pencircle scaled \the\dimexpr\p_rulethickness\relax + \fi + ;% + }}} + +\setvalue{\??metanodesalternative }{draw} +\setvalue{\??metanodesalternative arrow}{drawarrow} +\setvalue{\??metanodesalternative doublearrow}{drawdblarrow} +\setvalue{\??metanodesalternative doublearrows}{drawdoublearrows} + +\setvalue{\??metanodesoption }{} +\setvalue{\??metanodesoption dashed}{dashed evenly} +\setvalue{\??metanodesoption dotted}{dashed withdots scaled .5} + +\appendtoks + \enforced\let\connectnodes\grph_nodes_fromto +\to \t_every_meta_nodes + +\permanent\protected\def\grph_nodes_code#1% + {\etoksapp\t_meta_nodes{#1}} + +\appendtoks + \enforced\let\nodeMPcode\grph_nodes_code + \enforced\let\mpcode \grph_nodes_code +\to \t_every_meta_nodes + +\protect \endinput diff --git a/tex/context/base/mkiv/meta-pag.mkxl b/tex/context/base/mkxl/meta-pag.mkxl index 86de11eeb..86de11eeb 100644 --- a/tex/context/base/mkiv/meta-pag.mkxl +++ b/tex/context/base/mkxl/meta-pag.mkxl diff --git a/tex/context/base/mkxl/meta-pdf.mkxl b/tex/context/base/mkxl/meta-pdf.mkxl new file mode 100644 index 000000000..d53ff7780 --- /dev/null +++ b/tex/context/base/mkxl/meta-pdf.mkxl @@ -0,0 +1,95 @@ +%D \module +%D [ file=meta-pdf, +%D version=2006.06.07, +%D title=\METAPOST\ Graphics, +%D subtitle=Conversion to \PDF, +%D author=Hans Hagen \& others (see text), +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\registerctxluafile{meta-pdf}{} + +\writestatus{loading}{MetaPost Graphics / MPS to PDF} + +\unprotect + +%D \macros +%D {convertMPtoPDF} +%D +%D The next set of macros implements \METAPOST\ to \PDF\ conversion. The traditional +%D method is in the MkII files and the older \MKIV\ method is kept in meta-pdh +%D files. The main conversion command is still the same but the scale parameters are +%D ignored in \MKIV: +%D +%D \starttyping +%D \convertMPtoPDF {filename} {x scale} {y scale} +%D \stoptyping +%D +%D Much code has gone due to the fact that we now use pre and post scripts and no +%D specials. This also means that you should use a modern \METAPOST\ or reprocess +%D graphics. The color control flags are also gone as we now integrate into the +%D regular colorspace handling (i.e.\ no longer independent configurations.) + +\permanent\def\PDFMPformoffset{\ifdefined\objectoffset\objectoffset\else\zeropoint\fi} % obsolete, will go + +\mutable\let\MPfilename\empty + +\permanent\protected\def\convertMPtoPDF#1#2#3% scaling no longer supported at this level (so #2 & #3 are ignored) + {\dostarttagged\t!mpgraphic\empty + \naturalvpack attr \imageattribute 1 \bgroup + \message{[MP to PDF]}% + \xdef\MPfilename{#1}% + \resetMPboundingbox + \forgetall + \offinterlineskip + \setbox\MPbox\vpack\bgroup + \clf_convertmpstopdf{\MPfilename}% + \removeunwantedspaces % not that needed + \egroup + \finalizeMPbox + \box\MPbox + \egroup + \dostoptagged} + +\protect \endinput + +%D Test code: +%D +%D \startbuffer +%D \startMPcode +%D fill fullcircle scaled 3cm withcolor red ; +%D fill fullcircle scaled 2cm withcolor green ; +%D fill fullcircle scaled 1cm withcolor blue ; +%D currentpicture := currentpicture shifted (-4cm,0) ; +%D fill fullcircle scaled 3cm withcolor cmyk(0,0,1,0) ; +%D fill fullcircle scaled 2cm withcolor cmyk(0,1,0,0) ; +%D fill fullcircle scaled 1cm withcolor cmyk(0,0,1,0) ; +%D currentpicture := currentpicture shifted (-4cm,0) ; +%D draw fullcircle scaled 3cm dashed evenly ; +%D draw fullcircle scaled 2cm dashed withdots ; +%D draw origin withpen pencircle scaled 3mm; +%D currentpicture := currentpicture shifted (-4cm,0) ; +%D fill fullcircle scaled 2cm shifted (-.5cm,+.5cm) withcolor transparent(1,.5,red); +%D fill fullcircle scaled 2cm shifted (-.5cm,-.5cm) withcolor transparent(1,.5,red); +%D fill fullcircle scaled 2cm shifted (+.5cm,+.5cm) withcolor transparent(1,.5,green); +%D fill fullcircle scaled 2cm shifted (+.5cm,-.5cm) withcolor transparent(1,.5,cmyk(1,0,1,.5)); +%D currentpicture := currentpicture shifted (12cm,-4cm) ; +%D draw "o e p s" infont defaultfont scaled 2 shifted (-1cm,0) ; +%D currentpicture := currentpicture shifted (-4cm,0) ; +%D % bug: shift +%D draw fullcircle scaled 3cm withpen pencircle yscaled 3mm xscaled 2mm rotated 30 ; +%D draw fullcircle scaled 2cm withpen pencircle yscaled 3mm xscaled 2mm rotated 20 withcolor red ; +%D filldraw fullcircle scaled 1cm withpen pencircle yscaled 3mm xscaled 2mm rotated 10 withcolor green ; +%D currentpicture := currentpicture shifted (-4cm,0) ; +%D % shade cannot handle shift +%D circular_shade(fullcircle scaled 3cm,0,.2red,.9green) ; +%D circular_shade(fullcircle scaled 3cm shifted(+4cm,0),0,cmyk(1,0,0,0),cmyk(0,1,0,0)) ; +%D filldraw boundingbox currentpicture enlarged -3cm withpen pencircle scaled 1pt withcolor .5white ; +%D \stopMPcode +%D \stopbuffer +%D +%D \typebuffer \startlinecorrection \getbuffer \stoplinecorrection diff --git a/tex/context/base/mkxl/meta-pdh.mkxl b/tex/context/base/mkxl/meta-pdh.mkxl new file mode 100644 index 000000000..fa731868d --- /dev/null +++ b/tex/context/base/mkxl/meta-pdh.mkxl @@ -0,0 +1,717 @@ +%D \module +%D [ file=meta-pdf, +%D version=2006.06.07, +%D title=\METAPOST\ Graphics, +%D subtitle=Conversion to \PDF, +%D author=Hans Hagen \& others (see text), +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\endinput + +%D Formerly known as supp-pdf.tex and supp-mpe.tex and meta-pdf.mkiv. +%D +%D Beware: this file is not used but kept for historic purposed! Never +%D mix this one into mkiv again as it uses other variables. + +% \useMPgraphic{1} +% \testfeatureonce{250}{\setbox0\hbox{\convertMPtoPDF{test-mps-mpgraph.1}{1}{1}}} +% +% 8.4 : mkii, direct parsing by tex +% 11.8 : mkiv, dirty conversion (10.8 with dirty tricks) +% 14.5 : mkiv, clean conversion +% 7.4 : mkiv, simulated clean direct lua from mp +% 0.3 : time taken by tex to handle converted code +% +% timings may differ now that we revamped the backend + +\registerctxluafile{meta-pdf}{} + +%D We will clean up the color mess later. + +\writestatus{loading}{MetaPost Graphics / MPS to PDF} + +\unprotect + +%D First we define a handy constant: + +\bgroup \catcode\commentasciicode\othercatcode \xdef\letterpercent{\string%} \egroup + +%D \macros +%D {convertMPtoPDF} +%D +%D The next set of macros implements \METAPOST\ to \PDF\ +%D conversion. The traditional method is in the MkII file. +%D +%D The main conversion command is: +%D +%D \starttyping +%D \convertMPtoPDF {filename} {x scale} {y scale} +%D \stoptyping +%D +%D The dimensions are derived from the bounding box. So we +%D only have to say: +%D +%D \starttyping +%D \convertMPtoPDF{mp-pra-1.eps}{1}{1} +%D \convertMPtoPDF{mp-pra-1.eps}{.5}{.5} +%D \stoptyping + +%D \macros +%D {makeMPintoPDFobject,lastPDFMPobject} +%D +%D For experts there are a few more options. When attributes +%D are to be added, the code must be embedded in an object +%D accompanied with the appropriate directives. One can +%D influence this process with \type {\makeMPintoPDFobject}. +%D +%D This option defaults to~0, because \CONTEXT\ takes care +%D of objects at another level, which saves some bytes. +%D +%D \starttabulate[|l|l|p|] +%D \NC 0 \NC never \NC don't use an object \NC\NR +%D \NC 1 \NC always \NC always use an object \NC\NR +%D \NC 2 \NC optional \NC use object when needed \NC\NR +%D \stoptabulate +%D +%D The last object number used is avaliable in the macro +%D \type {\lastPDFMPobject}. + +\ifx\makeMPintoPDFobject \undefined \newconstant\makeMPintoPDFobject \fi +\ifx\everyMPtoPDFconversion\undefined \newtoks \everyMPtoPDFconversion \fi + +\let\lastPDFMPobject \!!zerocount +\let\currentPDFresources\empty +\let\setMPextensions \relax + +\def\PDFMPformoffset + {\ifx\objectoffset\undefined\zeropoint\else\objectoffset\fi} + +\def\resetMPvariables#1#2#3% + {\glet\MPwidth \!!zeropoint + \glet\MPheight \!!zeropoint + \glet\MPllx \!!zerocount + \glet\MPlly \!!zerocount + \glet\MPurx \!!zerocount + \glet\MPury \!!zerocount + \xdef\MPxscale {#2}\ifx\MPxscale\empty\let\MPxscale\!!plusone\fi + \xdef\MPyscale {#3}\ifx\MPyscale\empty\let\MPyscale\!!plusone\fi + \xdef\MPfilename {#1}} + +%D The main macro: + +\def\convertMPtoPDF#1#2#3% watch the transparency reset + {\resetMPvariables{#1}{#2}{#3}% + \vpack\bgroup + \forgetall + \offinterlineskip + \setbox\scratchbox\vpack\bgroup + \setnormalcatcodes % we can be in verbatim or so + \message{[MP to PDF]}% + \startMPresources + \pdfliteral{\letterpercent\space mps begin}% + \pdfliteral{q 1 0 0 1 0 0 cm}% + \ctxlua{metapost.mptopdf.convertmpstopdf("\MPfilename")}\removeunwantedspaces + \pdfliteral{Q}% + \pdfliteral{\letterpercent\space mps end}% + \stopMPresources + \egroup + \setbox\scratchbox\hpack\bgroup + \hskip-\MPllx\onebasepoint + \raise-\MPlly\onebasepoint + \box\scratchbox + \egroup + \setbox\scratchbox\vpack to \MPheight\bgroup + \vfill + \hsize\MPwidth + \smashbox\scratchbox + \box\scratchbox + \egroup + \wd\scratchbox\MPwidth + \ht\scratchbox\MPheight + \dopackageMPgraphic\scratchbox + \egroup} + +\let\processMPtoPDFfile\convertMPtoPDF + +%D A common hook. + +\let\MPfshowcommand\empty + +%D Objects. + +\def\dopackageMPgraphic#1% #1 = boxregister + {\ifcase\makeMPintoPDFobject\or\or\ifx\currentPDFresources\empty\else + % an existing value of 2 signals object support (set elsewhere) + \makeMPintoPDFobject\plusone + \fi\fi + \ifcase\makeMPintoPDFobject + \box#1% + \or + \scratchdimen\PDFMPformoffset\relax + \ifdim\scratchdimen>\zeropoint % compensate for error + \setbox#1\vpack spread 2\scratchdimen + {\forgetall\vss\hpack spread 2\scratchdimen{\hss\box#1\hss}\vss}% + \fi + \setMPPDFobject{\currentPDFresources}{#1}% + \ifdim\scratchdimen>\zeropoint % compensate for error + \vpack to \MPheight + {\forgetall\vss\hpack to \MPwidth{\hss\getMPPDFobject\hss}\vss}% + \else + \getMPPDFobject + \fi + \glet\currentPDFresources\empty + \else + \box#1% + \fi} + +\def\setMPPDFobject#1#2% resources boxnumber + {\ifx\everyPDFxform\undefined\else\the\everyPDFxform\fi + \immediate\saveboxresource resources{#1}#2% + \edef\getMPPDFobject{\noexpand\useboxresource\the\lastsavedboxresourceindex}} + +\let\getMPPDFobject\relax + +%D \macros +%D {deleteMPgraphic, +%D startMPresources, +%D stopMPresources} + +\ifx\deleteMPgraphic\undefined + \def\deleteMPgraphic#1{} +\fi + +\ifx\startMPresources\undefined + \let\startMPresources\relax + \let\stopMPresources\relax +\fi + +%D We implement extensions by using the \METAPOST\ special +%D mechanism. Opposite to \TEX's specials, the \METAPOST\ ones +%D are flushed before or after the graphic data, but thereby +%D are no longer connected to a position. +%D +%D We implement specials by overloading the \type {fill} +%D operator. By counting the fills, we can let the converter +%D treat the appropriate fill in a special way. The +%D specification of the speciality can have two forms, +%D determined by the setting of a boolean variable: +%D +%D \starttyping +%D _inline_specials_ := false ; % comment like code (default) +%D _inline_specials_ := true ; % command like code +%D \stoptyping +%D +%D When the specification is embedded as comment, it looks +%D like: +%D +%D \starttyping +%D %%MetaPostSpecial <size> <data> <number> <identifier> +%D \stoptyping +%D +%D The in||line alternative is more tuned for \POSTSCRIPT, +%D since it permits us to define a macro \type {special}. +%D +%D \starttyping +%D inline : <data> <number> <identifier> <size> special +%D \stoptyping +%D +%D The \type {identifier} determines what to do, and the data +%D can be used to accomplish this. A type~2 shading function +%D has identifier~2. Alltogether, the number of parameters is +%D specified in \type {size}. The \type {number} is the number +%D of the fill that needs the special treatment. For a type~2 +%D and~3 shaded fill, the datablock contains the following + +%D data: +%D +%D \starttyping +%D from to n inner_r g b x y outer_r g b x y +%D from to n inner_r g b x y radius outer_r g b x y radius +%D \stoptyping + +\newconditional\manyMPspecials \settrue\manyMPspecials + +%D In case of \PDF, we need to prepare resourcs. + +\newtoks\MPstartresources +\newtoks\MPstopresources + +\def\startMPresources + {\the\MPstartresources} + +\def\stopMPresources + {\the\MPstopresources} + +%D Some day we may consider collecting local resources. + +\appendtoks + \glet\currentPDFresources\empty % kind of redundant +\to \MPstartresources + +% \appendtoks +% \collectPDFresources +% \glet\currentPDFresources\collectedPDFresources +% \to \MPstopresources + +\appendtoksonce + \the\everyPDFxform +\to \MPstopresources + +%D Special number~1 is dedicated to \CMYK\ support. If you +%D want to know why: look at this: +%D +%D \startbuffer[mp] +%D fill fullcircle xyscaled (3cm,1cm) withcolor \MPcolor{test} ; +%D \stopbuffer +%D +%D \startbuffer[cmyk] +%D \startcombination[4*1] +%D {\definecolor[test][c=1,y=.3,k=.3] \processMPbuffer[mp]} {c=1 y=.3 k=.3} +%D {\definecolor[test][c=.9,y=.15] \processMPbuffer[mp]} {c=.9 y=.15} +%D {\definecolor[test][c=.25,y=.8] \processMPbuffer[mp]} {c=.25 y=.8} +%D {\definecolor[test][c=.45,y=.1] \processMPbuffer[mp]} {c=.45 y=.1} +%D \stopcombination +%D \stopbuffer +%D +%D \placefigure +%D {\CMYK\ support disabled, +%D conversion to \RGB.} +%D {\setupcolors[cmyk=nee,state=start]\getbuffer[cmyk]} +%D +%D \placefigure +%D {\CMYK\ support enabled, +%D no support in \METAPOST.} +%D {\setupcolors[cmyk=ja,mpcmyk=nee,state=start]\getbuffer[cmyk]} +%D +%D \placefigure +%D {\CMYK\ support enabled, +%D no conversion to \RGB, +%D support in \METAPOST} +%D {\setupcolors[cmyk=ja,state=start]\getbuffer[cmyk]} + +% \let\revokeMPtransparencyspecial\relax + +%D Transparency support used specials 60 (rgb) and 61 +%D (cmyk). +%D +%D \startbuffer +%D u := 2cm ; path p ; p := fullcircle scaled u shifted (u/4,0); +%D +%D fill p rotated 90 withcolor transparent(1,.5,yellow) ; +%D fill p rotated 210 withcolor transparent(1,.5,green) ; +%D fill p rotated 330 withcolor transparent(1,.5,blue) ; +%D \stopbuffer +%D +%D \typebuffer +%D +%D \startlinecorrection \processMPbuffer \stoplinecorrection +%D +%D One can also communicate colors between \CONTEXT\ and +%D \METAPOST: +%D +%D \startbuffer +%D \definecolor[tcyan] [c=1,k=.2,t=.5] +%D \definecolor[tmagenta][m=1,k=.2,t=.5] +%D \definecolor[tyellow] [y=1,k=.2,t=.5] +%D \stopbuffer +%D +%D \typebuffer \getbuffer +%D +%D \startbuffer +%D u := 2cm ; path p ; p := fullcircle scaled u shifted (u/4,0); +%D +%D fill p rotated 90 withcolor \MPcolor{tcyan} ; +%D fill p rotated 210 withcolor \MPcolor{tmagenta} ; +%D fill p rotated 330 withcolor \MPcolor{tyellow} ; +%D \stopbuffer +%D +%D \startlinecorrection \processMPbuffer \stoplinecorrection + +%D Shading is an example of a more advanced graphic feature, +%D but users will seldom encounter those complications. Here +%D we only show a few simple examples, but many other +%D alternatives are possible by setting up the functions built +%D in \PDF\ in the appropriate way. +%D +%D Shading has to do with interpolation between two or more +%D points or user supplied ranges. In \PDF, the specifications +%D of a shade has to be encapsulated in objects and passed on +%D as resources. This is a \PDF\ level 1.3. feature. One can +%D simulate three dimensional shades as well and define simple +%D functions using a limited set of \POSTSCRIPT\ primitives. +%D Given the power of \METAPOST\ and these \PDF\ features, we +%D can achieve superb graphic effects. +%D +%D Since everything is hidden in \TEX\ and \METAPOST\ graphics, +%D we can stick to high level \CONTEXT\ command, as shown in +%D the following exmples. +%D +%D \startbuffer +%D \startuniqueMPgraphic{CircularShade} +%D path p ; p := unitsquare xscaled OverlayWidth yscaled OverlayHeight ; +%D circular_shade(p,0,.2red,.9red) ; +%D \stopuniqueMPgraphic +%D +%D \startuniqueMPgraphic{LinearShade} +%D path p ; p := unitsquare xscaled OverlayWidth yscaled OverlayHeight ; +%D linear_shade(p,0,.2blue,.9blue) ; +%D \stopuniqueMPgraphic +%D +%D \startuniqueMPgraphic{DuotoneShade} +%D path p ; p := unitsquare xscaled OverlayWidth yscaled OverlayHeight ; +%D linear_shade(p,2,.5green,.5red) ; +%D \stopuniqueMPgraphic +%D \stopbuffer +%D +%D \typebuffer +%D +%D \getbuffer +%D +%D These graphics can be hooked into the overlay mechanism, +%D which is available in many commands. +%D +%D \startbuffer +%D \defineoverlay[demo 1][\uniqueMPgraphic{CircularShade}] +%D \defineoverlay[demo 2][\uniqueMPgraphic {LinearShade}] +%D \defineoverlay[demo 3][\uniqueMPgraphic {DuotoneShade}] +%D \stopbuffer +%D +%D \typebuffer +%D +%D \getbuffer +%D +%D These backgrounds can for instance be applied to \type +%D {\framed}: +%D +%D \startbuffer +%D \setupframed[width=3cm,height=2cm,frame=off] +%D \startcombination[3*1] +%D {\framed[backgroundachtergrond=demo 1]{\bfd \white Demo 1}} {} +%D {\framed[backgroundachtergrond=demo 2]{\bfd \white Demo 2}} {} +%D {\framed[backgroundachtergrond=demo 3]{\bfd \white Demo 3}} {} +%D \stopcombination +%D \stopbuffer +%D +%D \typebuffer +%D +%D \startlinecorrection +%D \getbuffer +%D \stoplinecorrection +%D +%D There are a few more alternatives, determined by the second +%D parameter passed to \type {circular_shade} and alike. +%D +%D \def\SomeShade#1#2#3#4#5% +%D {\startuniqueMPgraphic{Shade-#1} +%D width := OverlayWidth ; +%D height := OverlayHeight ; +%D path p ; p := unitsquare xscaled width yscaled height ; +%D #2_shade(p,#3,#4,#5) ; +%D \stopuniqueMPgraphic +%D \defineoverlay[Shade-#1][\uniqueMPgraphic{Shade-#1}]% +%D \framed[backgroundachtergrond=Shade-#1,width=2cm,height=2cm,frame=off]{}} +%D +%D \startlinecorrection +%D \startcombination[5*1] +%D {\SomeShade{10}{circular}{0}{.3blue}{.9blue}} {circular 0} +%D {\SomeShade{11}{circular}{1}{.3blue}{.9blue}} {circular 1} +%D {\SomeShade{12}{circular}{2}{.3blue}{.9blue}} {circular 2} +%D {\SomeShade{13}{circular}{3}{.3blue}{.9blue}} {circular 3} +%D {\SomeShade{14}{circular}{4}{.3blue}{.9blue}} {circular 4} +%D \stopcombination +%D \stoplinecorrection +%D +%D \blank +%D +%D \startlinecorrection +%D \startcombination[5*1] +%D {\SomeShade{20}{circular}{0}{.9green}{.3green}} {circular 0} +%D {\SomeShade{21}{circular}{1}{.9green}{.3green}} {circular 1} +%D {\SomeShade{22}{circular}{2}{.9green}{.3green}} {circular 2} +%D {\SomeShade{23}{circular}{3}{.9green}{.3green}} {circular 3} +%D {\SomeShade{24}{circular}{4}{.9green}{.3green}} {circular 4} +%D \stopcombination +%D \stoplinecorrection +%D +%D \blank +%D +%D \startlinecorrection +%D \startcombination[4*1] +%D {\SomeShade{30}{linear}{0}{.3red}{.9red}} {linear 0} +%D {\SomeShade{31}{linear}{1}{.3red}{.9red}} {linear 1} +%D {\SomeShade{32}{linear}{2}{.3red}{.9red}} {linear 2} +%D {\SomeShade{33}{linear}{3}{.3red}{.9red}} {linear 3} +%D \stopcombination +%D \stoplinecorrection +%D +%D These macros closely cooperate with the \METAPOST\ module +%D \type {mp-spec.mp}, which is part of the \CONTEXT\ +%D distribution. +%D +%D The low level (\PDF) implementation is based on the \TEX\ +%D based \METAPOST\ to \PDF\ converter. Shading is supported +%D by overloading the \type {fill} operator as implemented +%D earlier. In \PDF\ type~2 and~3 shading functions are +%D specified in terms of: +%D +%D \starttabulate[|Tl|l|] +%D \NC /Domain \NC sort of meeting range \NC \NR +%D \NC /C0 \NC inner shade \NC \NR +%D \NC /C1 \NC outer shade \NC \NR +%D \NC /N \NC smaller values, bigger inner circles \NC \NR +%D \stoptabulate + +% \newcount\currentPDFshade % 0 % global (document wide) counter +% +% \def\dosetMPsomePDFshade#1#2% +% {\immediate\pdfobj +% {<</FunctionType 2 +% /Domain [\gMPs1 \gMPs2] +% /C0 [\MPshadeA] +% /C1 [\MPshadeB] +% /N \gMPs3>>}% +% \immediate\pdfobj +% {<</ShadingType #1 +% /ColorSpace /\MPresolvedspace +% /Function \the\pdflastobj\space 0 R +% /Coords [\MPshadeC] +% /Extend [true true]>>}% +% \global\advance\currentPDFshade \plusone +% \ctxlua{lpdf.adddocumentshade("Sh\the\currentPDFshade",lpdf.reference(\the\pdflastobj))}% +% \setxvalue{\@@MPSK#2}{\noexpand\dohandleMPshade{\the\currentPDFshade}}} +% +% \def\dosetMPlinearshade {\dosetMPsomePDFshade2}% #1 +% \def\dosetMPcircularshade{\dosetMPsomePDFshade3}% #1 +% +% \defineMPspecial{30} +% {\normalexpanded{\noexpand\resolveMPrgbcolor{\gMPs4}{\gMPs5}{\gMPs6}}\to\MPshadeA +% \normalexpanded{\noexpand\resolveMPrgbcolor{\gMPs{9}}{\gMPs{10}}{\gMPs{11}}}\to\MPshadeB +% \edef\MPshadeC{\gMPs7 \gMPs8 \gMPs{12} \gMPs{13}}% +% \dosetMPlinearshade{\gMPs{14}}} +% +% \defineMPspecial{31} +% {\normalexpanded{\noexpand\resolveMPrgbcolor{\gMPs4}{\gMPs5}{\gMPs6}}\to\MPshadeA +% \normalexpanded{\noexpand\resolveMPrgbcolor{\gMPs{10}}{\gMPs{11}}{\gMPs{12}}}\to\MPshadeB +% \edef\MPshadeC{\gMPs7 \gMPs8 \gMPs9 \gMPs{13} \gMPs{14} \gMPs{15}}% +% \dosetMPcircularshade{\gMPs{16}}} +% +% \defineMPspecial{32} +% {\normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}}\to\MPshadeA +% \normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs{10}}{\gMPs{11}}{\gMPs{12}}{\gMPs{13}}}\to\MPshadeB +% \edef\MPshadeC{\gMPs8 \gMPs9 \gMPs{14} \gMPs{15}}% +% \dosetMPlinearshade{\gMPs{16}}} +% +% \defineMPspecial{33} +% {\normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}}\to\MPshadeA +% \normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs{11}}{\gMPs{12}}{\gMPs{13}}{\gMPs{14}}}\to\MPshadeB +% \edef\MPshadeC{\gMPs8 \gMPs9 \gMPs{10} \gMPs{15} \gMPs{16} \gMPs{17}}% +% \dosetMPcircularshade{\gMPs{18}}} +% +% \defineMPspecial{34} +% {\normalexpanded{\noexpand\resolveMPspotcolor{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}}\to\MPshadeA +% \normalexpanded{\noexpand\resolveMPspotcolor{\gMPs{10}}{\gMPs{11}}{\gMPs{12}}{\gMPs{13}}}\to\MPshadeB +% \edef\MPshadeC{\gMPs8 \gMPs9 \gMPs{14} \gMPs{15}}% +% \dosetMPlinearshade{\gMPs{16}}} +% +% \defineMPspecial{35} +% {\normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}}\to\MPshadeA +% \normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs{11}}{\gMPs{12}}{\gMPs{13}}{\gMPs{14}}}\to\MPshadeB +% \edef\MPshadeC{\gMPs8 \gMPs9 \gMPs{10} \gMPs{15} \gMPs{16} \gMPs{17}}% +% \dosetMPcircularshade{\gMPs{18}}} +% +% \newconditional\ignoreMPpath +% +% \def\dohandleMPshade#1% +% {\revokeMPtransparencyspecial +% \settrue\ignoreMPpath +% \def\extraMPpathcode{/Sh#1 sh Q}% +% \pdfliteral{q /Pattern cs}} +% +% \defineMPspecial{10} +% {\setxvalue{\@@MPSK\gMPs8}% +% {\noexpand\handleMPfigurespecial{\gMPs1}{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}{\gMPs8}}} +% +% \def\handleMPfigurespecial#1#2#3#4#5#6#7#8% todo : combine with ext fig +% {\letgvalueempty{\@@MPSK#8}% +% \vbox to \zeropoint +% {\vss +% \hbox to \zeropoint +% {\ifcase\pdfoutput\or % will be hooked into the special driver +% \doiffileelse{#7} +% {\doifundefinedelse{mps:x:#7} +% {\immediate\pdfximage\s!width\onebasepoint\s!height\onebasepoint{#7}% +% \setxvalue{mps:x:#7}{\pdfrefximage\the\pdflastximage}}% +% {\message{[reusing figure #7]}}% +% \pdfliteral{q #1 #2 #3 #4 #5 #6 cm}% +% \rlap{\getvalue{mps:x:#7}}% +% \pdfliteral{Q}} +% {\message{[unknown figure #7]}}% +% \fi +% \hss}}} + +%D An example of using both special features is the +%D following. +%D +%D \starttyping +%D \startMPpage +%D externalfigure "hakker1b.png" scaled 22cm rotated 10 shifted (-2cm,0cm); +%D externalfigure "hakker1b.png" scaled 10cm rotated -10 ; +%D externalfigure "hakker1b.png" scaled 7cm rotated 45 shifted (8cm,12cm) ; +%D path p ; p := unitcircle xscaled 15cm yscaled 20cm; +%D path q ; q := p rotatedaround(center p,90) ; +%D path r ; r := buildcycle(p,q) ; clip currentpicture to r ; +%D path s ; s := boundingbox currentpicture enlarged 5mm ; +%D picture c ; c := currentpicture ; currentpicture := nullpicture ; +%D circular_shade(s,0,.2red,.9red) ; +%D addto currentpicture also c ; +%D \stopMPpage +%D \stoptyping + +% \defineMPspecial{20} +% {\setxvalue{\@@MPSK\gMPs6}% +% {\noexpand\handleMPhyperlink{\gMPs1}{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs6}}} +% +% \def\handleMPhyperlink#1#2#3#4#5#6% +% {\letgvalueempty{\@@MPSK#6}% +% \setbox\scratchbox\hbox +% {\setbox\scratchbox\emptyhbox +% \wd\scratchbox\dimexpr-#1\onebasepoint+#3\onebasepoint\relax +% \ht\scratchbox\dimexpr-#2\onebasepoint+#4\onebasepoint\relax +% \gotobox{\box\scratchbox}[#5]}% +% \setbox\scratchbox\hbox +% {\hskip\dimexpr\MPxoffset\onebasepoint+#1\onebasepoint\relax +% \raise\dimexpr\MPyoffset\onebasepoint+#2\onebasepoint\relax +% \box\scratchbox}% +% \smashbox\scratchbox +% \box\scratchbox} + +%D This special (number 50) passes positions to a tex file. +%D This method uses a two||pass approach an (mis|)|used the +%D context positioning macros. In \type {core-pos} we will +%D implement the low level submacro needed. +%D +%D \startbuffer +%D \definelayer[test] +%D +%D \setlayer +%D [test] +%D [x=\MPx{somepos-1},y=\MPy{somepos-1}] +%D {Whatever we want here!} +%D +%D \setlayer +%D [test] +%D [x=\MPx{somepos-2},y=\MPy{somepos-2}] +%D {Whatever we need there!} +%D +%D \startuseMPgraphic{oeps} +%D draw fullcircle scaled 6cm withcolor red ; +%D register ("somepos-1",1cm,2cm,center currentpicture) ; +%D register ("somepos-2",4cm,3cm,(-1cm,-2cm)) ; +%D \stopuseMPgraphic +%D +%D \framed[background=test,offset=overlay]{\useMPgraphic{oeps}} +%D \stopbuffer +%D +%D \typebuffer +%D +%D Here the width and height are not realy used, but one can +%D imagine situations where tex has to work with values +%D calculated by \METAPOST. +%D +%D \startlinecorrection +%D \getbuffer +%D \stoplinecorrection +%D +%D Later we will implement a more convenient macro: +%D +%D \starttyping +%D \setMPlayer [test] [somepos-1] {Whatever we want here!} +%D \setMPlayer [test] [somepos-2] {Whatever we need there!} +%D \stoptyping + +\startMPinitializations + mp_shade_version := 2 ; +\stopMPinitializations + +%D This is done much cleaner in \MPLIB. + +\def\MPStextext#1#2#3#4#5% if we clean up this plugin model, we can + {\def\MPtextdata{#3}% % delegate the splitter to lua + redesign + \def\MPtextsize{#2}% + \def\lastMPmoveX{#4}% + \def\lastMPmoveY{#5}% + \defconvertedcommand\MPtextdata\MPtextdata % no edef + \splitstring\MPtextdata\at::::\to\MPtexttag\and\MPtextnumber + \executeifdefined{handleMPtext\MPtexttag} + {\setbox\scratchbox\hbox % text + {\font\temp=#1\space at #2\onebasepoint + \let\c\char + \temp + \MPfshowcommand{#3}}% + \setbox\scratchbox\hpack + {\hskip#4\onebasepoint + \raise#5\onebasepoint + \box\scratchbox}% + \smashbox\scratchbox + \box\scratchbox}} + +We save the special variables on a stack. It's not that fast, but it make +implementing the special more convenient. + +%D The boundingbox. + +\def\MPSboundingbox#1#2#3#4% + {\xdef\MPllx {#1}\xdef\MPlly{#2}\xdef\MPurx{#3}\xdef\MPury{#4}% + \xdef\MPwidth {\the\dimexpr#3\onebasepoint-#1\onebasepoint\relax}% + \xdef\MPheight{\the\dimexpr#4\onebasepoint-#2\onebasepoint\relax}} + +\MPSboundingbox0000 + +%D Test code: + +% \startMPcode +% fill fullcircle scaled 3cm withcolor red ; +% fill fullcircle scaled 2cm withcolor green ; +% fill fullcircle scaled 1cm withcolor blue ; +% currentpicture := currentpicture shifted (-4cm,0) ; +% fill fullcircle scaled 3cm withcolor cmyk(0,0,1,0) ; +% fill fullcircle scaled 2cm withcolor cmyk(0,1,0,0) ; +% fill fullcircle scaled 1cm withcolor cmyk(0,0,1,0) ; +% currentpicture := currentpicture shifted (-4cm,0) ; +% draw fullcircle scaled 3cm dashed evenly ; +% draw fullcircle scaled 2cm dashed withdots ; +% draw origin withpen pencircle scaled 3mm; +% currentpicture := currentpicture shifted (-4cm,0) ; +% fill fullcircle scaled 2cm shifted (-.5cm,+.5cm) withcolor transparent(1,.5,red); +% fill fullcircle scaled 2cm shifted (-.5cm,-.5cm) withcolor transparent(1,.5,red); +% fill fullcircle scaled 2cm shifted (+.5cm,+.5cm) withcolor transparent(1,.5,green); +% fill fullcircle scaled 2cm shifted (+.5cm,-.5cm) withcolor transparent(1,.5,cmyk(1,0,1,.5)); +% currentpicture := currentpicture shifted (12cm,-4cm) ; +% draw "o e p s" infont defaultfont scaled 2 shifted (-1cm,0) ; +% currentpicture := currentpicture shifted (-4cm,0) ; +% % bug: shift +% draw fullcircle scaled 3cm withpen pencircle yscaled 3mm xscaled 2mm rotated 30 ; +% draw fullcircle scaled 2cm withpen pencircle yscaled 3mm xscaled 2mm rotated 20 withcolor red ; +% filldraw fullcircle scaled 1cm withpen pencircle yscaled 3mm xscaled 2mm rotated 10 withcolor green ; +% currentpicture := currentpicture shifted (-4cm,0) ; +% % shade cannot handle shift +% circular_shade(fullcircle scaled 3cm,0,.2red,.9green) ; +% circular_shade(fullcircle scaled 3cm shifted(+4cm,0),0,cmyk(1,0,0,0),cmyk(0,1,0,0)) ; +% filldraw boundingbox currentpicture enlarged -3cm withpen pencircle scaled 1pt withcolor .5white ; +% \stopMPcode + +% We cannot use attributes for switching colors in mp literals because +% grouping (qQ) interferes. + +% \def\dohandleMPshade#1% +% {\revokeMPtransparencyspecial +% \settrue\ignoreMPpath +% \def\extraMPpathcode{/#1 sh Q}% +% \pdfliteral{q /Pattern cs}} + +\protect \endinput diff --git a/tex/context/base/mkxl/meta-tex.mkxl b/tex/context/base/mkxl/meta-tex.mkxl new file mode 100644 index 000000000..9afbbe066 --- /dev/null +++ b/tex/context/base/mkxl/meta-tex.mkxl @@ -0,0 +1,239 @@ +%D \module +%D [ file=meta-tex, +%D version=2006.06.07, +%D title=\CONTEXT\ Support Macros, +%D subtitle=\METAPOST\ fast text insertion, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\registerctxluafile{meta-tex}{} + +\unprotect + +% Ok, we support this in MkIV because Mojca kept the pressure on. It +% looks a bit like a hack. But in fact this method is obsolete and +% eventually might go away. + +\installcorenamespace{graphictextext} +\installcorenamespace{graphictexdepth} +\installcorenamespace{graphictexarguments} + +\permanent\protected\def\startTeXtexts#1\stopTeXtexts + {#1} + +\aliased\let\stopTeXtexts\relax + +\permanent\tolerant\protected\def\TeXtext[#1]#:#2#3% contrary to mkii we don't process yet but we do expand + {\setxvalue{\??graphictextext#2}{\meta_textext_indeed{#1}{#3}}} + +\protected\def\meta_textext_indeed#1#2% + {\begingroup + \setbox\nextbox\hbox{#2}% + \ifcsname\??graphictexdepth#1\endcsname + \lastnamedcs + \else + \syst_boxes_lower_nextbox_dp + \fi + \box\nextbox + \endgroup} + +\permanent\def\getTeXtext#1% + {\begincsname\??graphictextext#1\endcsname} + +\letvalue{\??graphictexdepth d}\syst_boxes_lower_nextbox_dp +\letvalue{\??graphictexdepth \s!depth}\syst_boxes_lower_nextbox_dp +\letvalue{\??graphictexdepth n}\donothing +\letvalue{\??graphictexdepth\s!nodepth}\donothing + +% \definetextext[framed]{\framed} +% +% \startMPcode +% draw \sometxt[framed]{black} rotated 45 ; +% \stopMPcode +% +% But Mojca wanted more! Two arguments. +% +% \definetextext[framed]{\framed} +% +% \startMPcode +% draw \sometxt{This is for} rotated 45 ; +% draw \sometxt[framed][foregroundstyle=bold]{Mojca's}; +% draw \sometxt[framed]{eyes only!} rotated -45 ; +% \stopMPcode + +\permanent\protected\def\definetextext[#1]% + {\def\currenttextext{#1}% + \doifelsenextoptionalcs\meta_textext_define_one\meta_textext_define_zero} + +\def\meta_textext_define_one {\setvalue{\??graphictexarguments1:\currenttextext}} +\def\meta_textext_define_zero{\setvalue{\??graphictexarguments0:\currenttextext}} + +\permanent\def\sometxt#1#{\meta_some_txt{#1}} + +\def\meta_some_txt#1#2% we need to capture embedded quotes (a bit messy as later on textext is filtered + {textext.drt("\mpsometxt#1{\clf_metapostescaped{#2}}")} + +\permanent\protected\def\mpsometxt % no _ catcode + {\doifelsenextoptionalcs\meta_some_txt_indeed_yes\meta_some_txt_indeed_nop} + +\def\meta_some_txt_indeed_yes[#1]% + {\def\currenttextext{#1}% + \csname\??graphictexarguments + \ifcsname\??graphictexarguments0:#1\endcsname0\else + \ifcsname\??graphictexarguments1:#1\endcsname1\else + ?\fi\fi + \endcsname} + +\def\meta_some_txt_indeed_nop + {} + +\setvalue{\??graphictexarguments ?}{} +\setvalue{\??graphictexarguments 0}{\csname\??graphictexarguments\currenttextext\endcsname} +\setvalue{\??graphictexarguments 1}{\dosingleempty\meta_gx_one} + +\def\meta_gx_one{\csname\??graphictexarguments1:\currenttextext\endcsname} + +% \definetextext[framed][#1]#2{\framed[width=4cm]{\switchtobodyfont[#1]#2}} +% \definetextext[simple]{\framed[width=8cm]} +% +% \starttext +% +% \startMPcode +% draw \sometxt{This is for} rotated 45 ; +% draw \sometxt[framed][ss,16pt] {Mojca's}; +% draw \sometxt[framed]{eyes only!} rotated -45 ; +% draw \sometxt[simple]{Quotes "indeed" work!} rotated 180 ; +% \stopMPcode +% +% \stoptext +% +% a lua one: +% +% \protected\def\definetextext[#1]#2{\setvalue{@@st@@#1}{#2}} +% +% \def\sometxt #1#{\dosometxt{#1}} % grab optional [args] +% \def\dosometxt #1#2{\ctxlua{metapost.sometxt(\!!bs#1\!!es,\!!bs#2\!!es)}} +% +% \def\sometxta #1{textext.drt("#1")} +% \def\sometxtb #1#2{textext.drt("\getvalue{@@st@@#1}{#2}")} +% \def\sometxtc #1#2#3{textext.drt("\getvalue{@@st@@#1}{\switchtobodyfont[#2]#3}")} + +% Best use the mp macro instead since it provides positioning. +% +% \startuseMPgraphic{testgraphic} +% draw \sometxt{\ruledhbox{\strut hans hagen}} scaled 3; +% % draw textext.drt("\ruledhbox{\strut hans hagen}") scaled 3; +% % draw textext.dlft("\ruledhbox{\strut hans hagen}") scaled 3; +% % draw textext.lft("\ruledhbox{\strut hans hagen}") scaled 3; +% draw llcorner currentpicture -- urcorner currentpicture withcolor yellow; +% draw lrcorner currentpicture -- ulcorner currentpicture withcolor yellow; +% draw boundingbox currentpicture withcolor blue ; +% draw origin withcolor red withpen pencircle scaled 1pt; +% \stopuseMPgraphic +% +% {\showstruts\useMPgraphic{testgraphic}} + +\permanent\protected\def\MPexponent #1#2{\mathematics{#1\times10^{#2}}} +\permanent\protected\def\MPformatted #1#2{\clf_metapostformatted{#1}{#2}} +\permanent\protected\def\MPgraphformat#1#2{\clf_metapostgraphformat{#1}{#2}} + +%D Some new fun (but exprimental for a while): + +\permanent\protected\def\MPLIBoutlinetext#1#2#3% index kind text + {\begingroup + \setbox\scratchbox\hbox{#3}% + \clf_MPLIBconvertoutlinetext\numexpr#1\relax{#2}\scratchbox + \endgroup} + +%D For now here. We don't do the whole thing, because then one can as +%D well just export to pdf. We assume consistent integration. + +\definefontsynonym[serif-normal-normal] [\s!Serif] +\definefontsynonym[serif-normal-italic] [\s!SerifItalic] +\definefontsynonym[serif-normal-oblique][\s!SerifSlanted] +\definefontsynonym[serif-bold-normal] [\s!SerifBold] +\definefontsynonym[serif-bold-italic] [\s!SerifBoldItalic] +\definefontsynonym[serif-bold-oblique] [\s!SerifBoldSlanted] + +\definefontsynonym[sans-normal-normal] [\s!Sans] +\definefontsynonym[sans-normal-italic] [\s!SansItalic] +\definefontsynonym[sans-normal-oblique] [\s!SansSlanted] +\definefontsynonym[sans-bold-normal] [\s!SansBold] +\definefontsynonym[sans-bold-italic] [\s!SansBoldItalic] +\definefontsynonym[sans-bold-oblique] [\s!SansBoldSlanted] + +\definefontsynonym[mono-normal-normal] [\s!Mono] +\definefontsynonym[mono-normal-italic] [\s!MonoItalic] +\definefontsynonym[mono-normal-oblique] [\s!MonoSlanted] +\definefontsynonym[mono-bold-normal] [\s!MonoBold] +\definefontsynonym[mono-bold-italic] [\s!MonoBoldItalic] +\definefontsynonym[mono-bold-oblique] [\s!MonoBoldSlanted] + +\installcorenamespace {svgfamily} + +\setvalue{\??svgfamily }{serif} +\setvalue{\??svgfamily serif}{serif} +\setvalue{\??svgfamily sans}{sans} +\setvalue{\??svgfamily mono}{mono} + +%D This can't change because otherwise \type {\scale[width=4cm]{graphic}} fails. + +\permanent\protected\def\svgscaled#1% + {\fastsxsy{#1}{#1}\svgnormal} + +\permanent\protected\def\svgnormal#1#2#3#4% family weight style text + {\bgroup + \edef\p_family{#1}% + \ifx\p_family\empty\else + \edef\p_font{\ifcsname\??svgfamily#1\endcsname\lastnamedcs\else#1\fi-#2-#3}% + \predefinedfont[\s!spec:\p_font*\s!default\space @ 10bp]% + \fi + #4% + \egroup} + +\permanent\protected\def\svgcolored#1#2#3#4% r g b text + {\colored[r=#1,g=#2,b=#3]{#4}} + +\permanent\protected\def\svgplaced#1#2#3#4% dx dy width text + {\doifelsenothing{#3}% + {\hpack}% + {\hpack to #3}% + {\raise#2\onebasepoint\hbox{\kern#1\onebasepoint\relax#4}}} + +\newdimen\grph_svg_scratchwidth % maybe \startsvgpos etc + +\permanent\protected\def\svgposchar#1#2#3% dx dy char + {\setbox\scratchbox\hpack\bgroup + \raise#2\onebasepoint\hbox\bgroup + \kern\dimexpr#1\onebasepoint-\grph_svg_scratchwidth\relax + \char#3\relax + \egroup + \egroup + \advance\grph_svg_scratchwidth\wd\scratchbox + \box\scratchbox} + +\permanent\protected\def\svgchar#1% char + {\char#1\relax} + +\definelayer[svgmps][\c!method=\v!fit] + +\permanent\protected\def\svgstartlayer + {\resetlayer[svgmps]% + \setlayer[svgmps]\bgroup} + +\permanent\protected\def\svgstoplayer + {\egroup + \flushlayer[svgmps]} + +\permanent\protected\def\svgsetlayer#1#2% + {\setlayer[svgmps][\c!x=#1\onebasepoint,\c!y=#2\onebasepoint]} % {#3} + +\permanent\protected\def\svghashed#1% + {\clf_svghashed#1\relax} + +\protect \endinput diff --git a/tex/context/base/mkxl/meta-xml.mkxl b/tex/context/base/mkxl/meta-xml.mkxl new file mode 100644 index 000000000..bd93bda8c --- /dev/null +++ b/tex/context/base/mkxl/meta-xml.mkxl @@ -0,0 +1,20 @@ +%D \module +%D [ file=meta-xml, +%D version=2002.11.27, +%D title=\METAPOST\ Graphics, +%D subtitle=XML Hacks, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{MetaPost Graphics / XML Hacks} + +\unprotect + +% not needed in mkiv + +\protect \endinput diff --git a/tex/context/base/mkiv/mlib-cnt.lmt b/tex/context/base/mkxl/mlib-cnt.lmt index 667384ed7..667384ed7 100644 --- a/tex/context/base/mkiv/mlib-cnt.lmt +++ b/tex/context/base/mkxl/mlib-cnt.lmt diff --git a/tex/context/base/mkiv/mlib-ctx.mkxl b/tex/context/base/mkxl/mlib-ctx.mkxl index 88f26c9ac..88f26c9ac 100644 --- a/tex/context/base/mkiv/mlib-ctx.mkxl +++ b/tex/context/base/mkxl/mlib-ctx.mkxl diff --git a/tex/context/base/mkiv/mlib-fio.lmt b/tex/context/base/mkxl/mlib-fio.lmt index 4290537dd..4290537dd 100644 --- a/tex/context/base/mkiv/mlib-fio.lmt +++ b/tex/context/base/mkxl/mlib-fio.lmt diff --git a/tex/context/base/mkiv/mlib-int.lmt b/tex/context/base/mkxl/mlib-int.lmt index 86e2e5732..86e2e5732 100644 --- a/tex/context/base/mkiv/mlib-int.lmt +++ b/tex/context/base/mkxl/mlib-int.lmt diff --git a/tex/context/base/mkiv/mlib-lmp.lmt b/tex/context/base/mkxl/mlib-lmp.lmt index ff9682e87..ff9682e87 100644 --- a/tex/context/base/mkiv/mlib-lmp.lmt +++ b/tex/context/base/mkxl/mlib-lmp.lmt diff --git a/tex/context/base/mkiv/mlib-lmt.lmt b/tex/context/base/mkxl/mlib-lmt.lmt index f0b59248a..f0b59248a 100644 --- a/tex/context/base/mkiv/mlib-lmt.lmt +++ b/tex/context/base/mkxl/mlib-lmt.lmt diff --git a/tex/context/base/mkiv/mlib-lua.lmt b/tex/context/base/mkxl/mlib-lua.lmt index 8721ed60c..8721ed60c 100644 --- a/tex/context/base/mkiv/mlib-lua.lmt +++ b/tex/context/base/mkxl/mlib-lua.lmt diff --git a/tex/context/base/mkiv/mlib-mat.lmt b/tex/context/base/mkxl/mlib-mat.lmt index 3a63b32c7..3a63b32c7 100644 --- a/tex/context/base/mkiv/mlib-mat.lmt +++ b/tex/context/base/mkxl/mlib-mat.lmt diff --git a/tex/context/base/mkiv/mlib-pdf.mkxl b/tex/context/base/mkxl/mlib-pdf.mkxl index 90a5b5a86..90a5b5a86 100644 --- a/tex/context/base/mkiv/mlib-pdf.mkxl +++ b/tex/context/base/mkxl/mlib-pdf.mkxl diff --git a/tex/context/base/mkiv/mlib-pps.mkxl b/tex/context/base/mkxl/mlib-pps.mkxl index 3830de762..d010d9991 100644 --- a/tex/context/base/mkiv/mlib-pps.mkxl +++ b/tex/context/base/mkxl/mlib-pps.mkxl @@ -35,7 +35,7 @@ \newbox \MPtextbox \newtoks\everyMPLIBsettext % not used -\def\mlib_flush_environment +\permanent\protected\def\mlib_flush_environment {%\writestatus\m!metapost{flushing environment}% \clf_mptexget \enforced\let\MPLIBflushenvironment\relax}% MPenvironments are depricated} diff --git a/tex/context/base/mkiv/mlib-ran.lmt b/tex/context/base/mkxl/mlib-ran.lmt index cb8645e8d..cb8645e8d 100644 --- a/tex/context/base/mkiv/mlib-ran.lmt +++ b/tex/context/base/mkxl/mlib-ran.lmt diff --git a/tex/context/base/mkiv/mlib-scn.lmt b/tex/context/base/mkxl/mlib-scn.lmt index ff1cff0e3..ff1cff0e3 100644 --- a/tex/context/base/mkiv/mlib-scn.lmt +++ b/tex/context/base/mkxl/mlib-scn.lmt diff --git a/tex/context/base/mkiv/mlib-svg.lmt b/tex/context/base/mkxl/mlib-svg.lmt index 4c4122476..4c4122476 100644 --- a/tex/context/base/mkiv/mlib-svg.lmt +++ b/tex/context/base/mkxl/mlib-svg.lmt diff --git a/tex/context/base/mkiv/mult-aux.mkxl b/tex/context/base/mkxl/mult-aux.mkxl index 97ae12be1..9c8613783 100644 --- a/tex/context/base/mkiv/mult-aux.mkxl +++ b/tex/context/base/mkxl/mult-aux.mkxl @@ -143,7 +143,7 @@ % \orelse\ifx#3\empty % \mult_interfaces_get_parameters_error_two % \else -% \expandafter\def\csname\m_mult_interfaces_namespace#1\endcsname{#2}% +% \defcsname\m_mult_interfaces_namespace#1\endcsname{#2}% % \fi % \doubleexpandafter\mult_interfaces_get_parameters_item} % @@ -245,8 +245,8 @@ \protected\def\mult_interfaces_lete#1#2{\letcsname#1#2\endcsname\empty} \protected\def\mult_interfaces_def #1#2{\defcsname#1#2\endcsname} \protected\def\mult_interfaces_edef#1#2{\edefcsname#1#2\endcsname} - \protected\def\mult_interfaces_gdef#1#2{\globaldef\csname#1#2\endcsname} - \protected\def\mult_interfaces_xdef#1#2{\globaledef\csname#1#2\endcsname} + \protected\def\mult_interfaces_gdef#1#2{\gdefcsname#1#2\endcsname} + \protected\def\mult_interfaces_xdef#1#2{\xdefcsname#1#2\endcsname} % \stopinterface %D Do, we only interface the assignment definition: @@ -1078,13 +1078,13 @@ \permanent\protected\def\installmacrostack#1% {\ifdefined#1\else\mutable\let#1\empty\fi - \global\protected\defcsname push_macro_\csstring#1\endcsname{\localpushmacro#1}% - \global\protected\defcsname pop_macro_\csstring#1\endcsname{\localpopmacro #1}} + \protected\gdefcsname push_macro_\csstring#1\endcsname{\localpushmacro#1}% + \protected\gdefcsname pop_macro_\csstring#1\endcsname{\localpopmacro #1}} \permanent\protected\def\installglobalmacrostack#1% {\ifdefined#1\else\mutable\glet#1\empty\fi - \global\protected\defcsname push_macro_\csstring#1\endcsname{\globalpushmacro#1}% - \global\protected\defcsname pop_macro_\csstring#1\endcsname{\globalpopmacro #1}} + \protected\gdefcsname push_macro_\csstring#1\endcsname{\globalpushmacro#1}% + \protected\gdefcsname pop_macro_\csstring#1\endcsname{\globalpopmacro #1}} % \showmacrostack can be used to see if there are different entries diff --git a/tex/context/base/mkiv/mult-def.mkxl b/tex/context/base/mkxl/mult-def.mkxl index 13e22dade..13e22dade 100644 --- a/tex/context/base/mkiv/mult-def.mkxl +++ b/tex/context/base/mkxl/mult-def.mkxl diff --git a/tex/context/base/mkiv/mult-dim.mklx b/tex/context/base/mkxl/mult-dim.mklx index 0526b3775..0526b3775 100644 --- a/tex/context/base/mkiv/mult-dim.mklx +++ b/tex/context/base/mkxl/mult-dim.mklx diff --git a/tex/context/base/mkiv/mult-ini.mkxl b/tex/context/base/mkxl/mult-ini.mkxl index 709e7142f..70db84b2d 100644 --- a/tex/context/base/mkiv/mult-ini.mkxl +++ b/tex/context/base/mkxl/mult-ini.mkxl @@ -393,7 +393,7 @@ %D For old times sake: -\let\showwarning\showmessage +\aliased\let\showwarning\showmessage %D \macros %D {dosetvalue,dosetevalue,dosetgvalue,dosetxvalue,docopyvalue,doresetvalue} % dogetvalue @@ -407,13 +407,13 @@ \pushoverloadmode -\permanent\protected\def\doletvalue #1#2{\letcsname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -\permanent\protected\def\dosetvalue #1#2{\defcsname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +\permanent\protected\def\doletvalue #1#2{\letcsname #1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +\permanent\protected\def\dosetvalue #1#2{\defcsname #1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} \permanent\protected\def\dosetevalue #1#2{\edefcsname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -\permanent\protected\def\dosetgvalue #1#2{\global\defcsname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -\permanent\protected\def\dosetxvalue #1#2{\global\edefcsname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -\permanent\protected\def\doresetvalue #1#2{\letcsname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty} -\permanent\protected\def\doignorevalue#1#2#3{\letcsname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty} +\permanent\protected\def\dosetgvalue #1#2{\gdefcsname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +\permanent\protected\def\dosetxvalue #1#2{\xdefcsname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} +\permanent\protected\def\doresetvalue #1#2{\letcsname #1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty} +\permanent\protected\def\doignorevalue#1#2#3{\letcsname #1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty} \permanent\protected\def\docopyvalue#1#2#3% {\ifcsname\k!prefix!#3\endcsname @@ -426,13 +426,13 @@ \startinterface english - \permanent\protected\def\doletvalue #1#2{\letcsname#1#2\endcsname} - \permanent\protected\def\dosetvalue #1#2{\defcsname#1#2\endcsname} + \permanent\protected\def\doletvalue #1#2{\letcsname #1#2\endcsname} + \permanent\protected\def\dosetvalue #1#2{\defcsname #1#2\endcsname} \permanent\protected\def\dosetevalue #1#2{\edefcsname#1#2\endcsname} - \permanent\protected\def\dosetgvalue #1#2{\global\defcsname#1#2\endcsname} - \permanent\protected\def\dosetxvalue #1#2{\global\edefcsname#1#2\endcsname} - \permanent\protected\def\doresetvalue #1#2{\letcsname#1#2\endcsname\empty} - \permanent\protected\def\doignorevalue#1#2#3{\letcsname#1#2\endcsname\empty} + \permanent\protected\def\dosetgvalue #1#2{\gdefcsname#1#2\endcsname} + \permanent\protected\def\dosetxvalue #1#2{\xdefcsname#1#2\endcsname} + \permanent\protected\def\doresetvalue #1#2{\letcsname #1#2\endcsname\empty} + \permanent\protected\def\doignorevalue#1#2#3{\letcsname #1#2\endcsname\empty} \permanent\protected\def\docopyvalue#1#2#3% {\defcsname#1#3\expandafter\endcsname\expandafter @@ -735,18 +735,18 @@ %D For at the \LUA\ end (experiment): -\def\ui_c#1#2{\immutable\global\defcsname\c!prefix!#1\endcsname{#1}% - \immutable\global\defcsname\k!prefix!#2\endcsname{#1}} % backmapping from non english -\def\ui_s #1{\immutable\global\defcsname\c!prefix!#1\endcsname{#1}% - \immutable\global\defcsname\k!prefix!#1\endcsname{#1}} % backmapping from non english -\def\ui_v#1#2{\immutable\global\defcsname\v!prefix!#1\endcsname{#2}} -\def\ui_e#1#2{\immutable\global\defcsname\e!prefix!#1\endcsname{#2}} +\def\ui_c#1#2{\immutable\gdefcsname\c!prefix!#1\endcsname{#1}% + \immutable\gdefcsname\k!prefix!#2\endcsname{#1}} % backmapping from non english +\def\ui_s #1{\immutable\gdefcsname\c!prefix!#1\endcsname{#1}% + \immutable\gdefcsname\k!prefix!#1\endcsname{#1}} % backmapping from non english +\def\ui_v#1#2{\immutable\gdefcsname\v!prefix!#1\endcsname{#2}} +\def\ui_e#1#2{\immutable\gdefcsname\e!prefix!#1\endcsname{#2}} \def\ui_a#1#2{\frozen\protected\def#2{#1}} % will go away \startinterface english - \def\ui_c#1#2{\immutable\global\defcsname\c!prefix!#1\endcsname{#1}} - \def\ui_s #1{\immutable\global\defcsname\c!prefix!#1\endcsname{#1}} + \def\ui_c#1#2{\immutable\gdefcsname\c!prefix!#1\endcsname{#1}} + \def\ui_s #1{\immutable\gdefcsname\c!prefix!#1\endcsname{#1}} \stopinterface diff --git a/tex/context/base/mkiv/mult-prm.mkxl b/tex/context/base/mkxl/mult-prm.mkxl index 2ec763c39..2ec763c39 100644 --- a/tex/context/base/mkiv/mult-prm.mkxl +++ b/tex/context/base/mkxl/mult-prm.mkxl diff --git a/tex/context/base/mkiv/mult-sys.mkxl b/tex/context/base/mkxl/mult-sys.mkxl index b782e9db4..38355f4cb 100644 --- a/tex/context/base/mkiv/mult-sys.mkxl +++ b/tex/context/base/mkxl/mult-sys.mkxl @@ -556,11 +556,11 @@ %D calls to other files), old macro's, to garantee compatibility and new macro's noy %D yet present in the format. -\definefileconstant {sysfilename} {cont-sys.mkiv} -\definefileconstant {newfilename} {cont-new.mkiv} -\definefileconstant {locfilename} {cont-loc.mkiv} -\definefileconstant {expfilename} {cont-exp.mkiv} -\definefileconstant {fntfilename} {cont-fnt.mkiv} % not yet used +\definefileconstant {sysfilename} {cont-sys.mkxl} +\definefileconstant {newfilename} {cont-new.mkxl} +\definefileconstant {locfilename} {cont-loc.mkxl} +\definefileconstant {expfilename} {cont-exp.mkxl} +\definefileconstant {fntfilename} {cont-fnt.mkxl} % not yet used \definefileconstant {gdsfilename} {cont-fnt.lfg} % not yet used %D The setup files for the language, font, color and special subsystems have a common diff --git a/tex/context/base/mkiv/node-aux.lmt b/tex/context/base/mkxl/node-aux.lmt index d952ec41b..d952ec41b 100644 --- a/tex/context/base/mkiv/node-aux.lmt +++ b/tex/context/base/mkxl/node-aux.lmt diff --git a/tex/context/base/mkiv/node-bck.mkxl b/tex/context/base/mkxl/node-bck.mkxl index e37d65b1c..e37d65b1c 100644 --- a/tex/context/base/mkiv/node-bck.mkxl +++ b/tex/context/base/mkxl/node-bck.mkxl diff --git a/tex/context/base/mkiv/node-cmp.lmt b/tex/context/base/mkxl/node-cmp.lmt index 21fd700f0..21fd700f0 100644 --- a/tex/context/base/mkiv/node-cmp.lmt +++ b/tex/context/base/mkxl/node-cmp.lmt diff --git a/tex/context/base/mkiv/node-fin.mkxl b/tex/context/base/mkxl/node-fin.mkxl index 183e02429..183e02429 100644 --- a/tex/context/base/mkiv/node-fin.mkxl +++ b/tex/context/base/mkxl/node-fin.mkxl diff --git a/tex/context/base/mkiv/node-gcm.lmt b/tex/context/base/mkxl/node-gcm.lmt index 8b09fb82b..8b09fb82b 100644 --- a/tex/context/base/mkiv/node-gcm.lmt +++ b/tex/context/base/mkxl/node-gcm.lmt diff --git a/tex/context/base/mkiv/node-ini.lmt b/tex/context/base/mkxl/node-ini.lmt index 5cce9030d..5cce9030d 100644 --- a/tex/context/base/mkiv/node-ini.lmt +++ b/tex/context/base/mkxl/node-ini.lmt diff --git a/tex/context/base/mkiv/node-ini.mkxl b/tex/context/base/mkxl/node-ini.mkxl index 4cb322448..4cb322448 100644 --- a/tex/context/base/mkiv/node-ini.mkxl +++ b/tex/context/base/mkxl/node-ini.mkxl diff --git a/tex/context/base/mkiv/node-mig.lmt b/tex/context/base/mkxl/node-mig.lmt index c19913509..c19913509 100644 --- a/tex/context/base/mkiv/node-mig.lmt +++ b/tex/context/base/mkxl/node-mig.lmt diff --git a/tex/context/base/mkiv/node-mig.mkxl b/tex/context/base/mkxl/node-mig.mkxl index 420140e6f..420140e6f 100644 --- a/tex/context/base/mkiv/node-mig.mkxl +++ b/tex/context/base/mkxl/node-mig.mkxl diff --git a/tex/context/base/mkiv/node-nut.lmt b/tex/context/base/mkxl/node-nut.lmt index 6b9dd803e..6b9dd803e 100644 --- a/tex/context/base/mkiv/node-nut.lmt +++ b/tex/context/base/mkxl/node-nut.lmt diff --git a/tex/context/base/mkiv/node-par.lmt b/tex/context/base/mkxl/node-par.lmt index af3125d23..af3125d23 100644 --- a/tex/context/base/mkiv/node-par.lmt +++ b/tex/context/base/mkxl/node-par.lmt diff --git a/tex/context/base/mkiv/node-rul.mkxl b/tex/context/base/mkxl/node-rul.mkxl index 3697e92ef..72201ac71 100644 --- a/tex/context/base/mkiv/node-rul.mkxl +++ b/tex/context/base/mkxl/node-rul.mkxl @@ -88,10 +88,10 @@ \aliased\let\setupbars\setupbar \appendtoks - \ifsecondargument - \node_rules_define - \else + \ifempty\currentbar \the\t_node_rules_checklist + \else + \node_rules_define \fi \to \everysetupbar @@ -198,7 +198,7 @@ \permanent\protected\def\pushbar[#1]% {\global\advance\c_node_rules_nesting\plusone - \expandafter\edef\csname\??barstack\number\c_node_rules_nesting\endcsname{\c_attr_ruled\the\c_attr_ruled}% + \edefcsname\??barstack\number\c_node_rules_nesting\endcsname{\c_attr_ruled\the\c_attr_ruled}% \node_rules_set{#1}} \permanent\protected\def\popbar @@ -367,10 +367,10 @@ \let\setupshifts\setupshift \appendtoks - \ifsecondargument - \node_shifts_define - \else + \ifempty\currentshift \the\t_node_shifts_checklist + \else + \node_shifts_define \fi \to \everysetupshift @@ -397,13 +397,6 @@ \protected\def\node_shifts_redefine#1% {\def\currentshift{#1}\node_shifts_define} -% \protected\def\node_shifts_set -% {\clf_enableshifts -% \glet\node_shifts_set\node_shifts_set_indeed -% \node_shifts_set} -% -% \def\node_shifts_set_indeed#1% todo: check parent ! - \protected\def\node_shifts_set#1% todo: check parent ! todo: move attr etc to lua {\def\currentshift{#1}% \expandafter\let\expandafter\c_node_shifts_index\csname\??shiftindex#1\endcsname @@ -416,12 +409,12 @@ \useshiftstyleandcolor\c!style\c!color \dosetupisolatedalign{\shiftparameter\c!align}} % weird feature that i probably needed once -\protected\def\startshift[#1]% +\permanent\protected\def\startshift[#1]% {\begingroup \node_shifts_set{#1}% \ignorespaces} -\protected\def\stopshift +\permanent\protected\def\stopshift {\removeunwantedspaces \endgroup} @@ -486,10 +479,10 @@ \aliased\let\setuplinefillers\setuplinefiller \appendtoks - \ifsecondargument - \node_linefiller_define - \else + \ifempty\currentlinefiller \the\t_node_linefiller_checklist + \else + \node_linefiller_define \fi \to \everysetuplinefiller diff --git a/tex/context/base/mkiv/node-ser.lmt b/tex/context/base/mkxl/node-ser.lmt index 0d7f3ccad..0d7f3ccad 100644 --- a/tex/context/base/mkiv/node-ser.lmt +++ b/tex/context/base/mkxl/node-ser.lmt diff --git a/tex/context/base/mkiv/node-snp.lmt b/tex/context/base/mkxl/node-snp.lmt index 8c0237a5c..8c0237a5c 100644 --- a/tex/context/base/mkiv/node-snp.lmt +++ b/tex/context/base/mkxl/node-snp.lmt diff --git a/tex/context/base/mkiv/node-tex.lmt b/tex/context/base/mkxl/node-tex.lmt index aae084740..aae084740 100644 --- a/tex/context/base/mkiv/node-tex.lmt +++ b/tex/context/base/mkxl/node-tex.lmt diff --git a/tex/context/base/mkiv/norm-ctx.mkxl b/tex/context/base/mkxl/norm-ctx.mkxl index 5cee04935..5cee04935 100644 --- a/tex/context/base/mkiv/norm-ctx.mkxl +++ b/tex/context/base/mkxl/norm-ctx.mkxl diff --git a/tex/context/base/mkiv/pack-bar.mkxl b/tex/context/base/mkxl/pack-bar.mkxl index c6a111531..c6a111531 100644 --- a/tex/context/base/mkiv/pack-bar.mkxl +++ b/tex/context/base/mkxl/pack-bar.mkxl diff --git a/tex/context/base/mkiv/pack-bck.mklx b/tex/context/base/mkxl/pack-bck.mklx index 3c15beb5f..3c15beb5f 100644 --- a/tex/context/base/mkiv/pack-bck.mklx +++ b/tex/context/base/mkxl/pack-bck.mklx diff --git a/tex/context/base/mkiv/pack-box.mkxl b/tex/context/base/mkxl/pack-box.mkxl index b638dda3b..7221f7a5f 100644 --- a/tex/context/base/mkiv/pack-box.mkxl +++ b/tex/context/base/mkxl/pack-box.mkxl @@ -66,7 +66,7 @@ \next}% picks up a box \pack_anchors_process_defined_indeed} -\protected\def\anchor[#1]% +\permanent\protected\def\anchor[#1]% {\begingroup \edef\currentanchor{#1}% \ifcsname\??anchor\currentanchor\endcsname @@ -521,8 +521,8 @@ \c!voffset=\scratchoffset, % is set to \bleedingparameter\c!offset \c!hoffset=\scratchoffset] % which often saves one resolve -\def\bleedwidth {\the\hsize} % these are global ! -\def\bleedheight{\the\vsize} % these are global ! +\permanent\def\bleedwidth {\the\hsize} % these are global ! +\permanent\def\bleedheight{\the\vsize} % these are global ! \newconditional\c_pack_boxes_l \newconditional\c_pack_boxes_r @@ -548,8 +548,8 @@ {\hbox\bgroup \global\advance\c_pack_boxes_bleeds\plusone % - \xdef\bleedwidth {\the\hsize}% - \xdef\bleedheight{\the\vsize}% + \enforced\permanent\xdef\bleedwidth {\the\hsize}% + \enforced\permanent\xdef\bleedheight{\the\vsize}% % \edef\currentbgposition {bleed:\number\c_pack_boxes_bleeds}% \edef\currentpageposition{page:0}% todo: per page @@ -571,7 +571,7 @@ % \doifelse{\bleedingparameter\c!stretch}\v!yes\donetrue\donefalse % - \xdef\bleedwidth{\the\dimexpr + \enforced\permanent\xdef\bleedwidth{\the\dimexpr \ifdone \ifconditional\c_pack_boxes_l \scratchwidth+\MPx\currentbgposition-\MPx\currentpageposition @@ -584,7 +584,7 @@ \scratchwidth \fi+\scratchhoffset \relax}% - \xdef\bleedheight{\the\dimexpr + \enforced\permanent\xdef\bleedheight{\the\dimexpr \ifdone \ifconditional\c_pack_boxes_t \paperheight -\MPy\currentbgposition+\MPy\currentpageposition % not checked diff --git a/tex/context/base/mkiv/pack-com.mkxl b/tex/context/base/mkxl/pack-com.mkxl index 9392a68a6..034035f35 100644 --- a/tex/context/base/mkiv/pack-com.mkxl +++ b/tex/context/base/mkxl/pack-com.mkxl @@ -216,6 +216,11 @@ % % faster +\ifdefined\startcontent \else \aliased\let\startcontent\relax \fi +\ifdefined\stopcontent \else \aliased\let\stopcontent \relax \fi +\ifdefined\startcaption \else \aliased\let\startcaption\relax \fi +\ifdefined\stopcaption \else \aliased\let\stopcaption \relax \fi + \protected\def\pack_common_content_start{\bgroup\ignorespaces} \protected\def\pack_common_content_stop {\removeunwantedspaces\egroup} \protected\def\pack_common_caption_start{\bgroup\ignorespaces} @@ -223,7 +228,7 @@ \newtoks\everycombination -\protected\def\stopcombination +\permanent\protected\def\stopcombination {\bgroup\normalexpanded{\egroup{}\ntimes{{}{}}\c_pack_combinations_y}% brr \dostoptagged \egroup @@ -262,10 +267,10 @@ % \the\everycombination % - \let\startcontent\pack_common_content_start - \let\stopcontent \pack_common_content_stop - \let\startcaption\pack_common_caption_start - \let\stopcaption \pack_common_caption_stop + \enforced\let\startcontent\pack_common_content_start + \enforced\let\stopcontent \pack_common_content_stop + \enforced\let\startcaption\pack_common_caption_start + \enforced\let\stopcaption \pack_common_caption_stop % \edef\p_height {\combinationparameter\c!height}% \edef\p_width {\combinationparameter\c!width}% @@ -388,7 +393,7 @@ \m_pack_combinations_valigner{\box\b_pack_combinations_content}% % we need to save the caption for a next alignment line \pack_combinations_save_caption}% - \ifnum\c_pack_combinations_y>\plusone + \unless\ifnum\c_pack_combinations_y>\plusone \global\advance\c_pack_combinations_y\minusone \global\advance\c_pack_combinations_x\minusone \ifcase\c_pack_combinations_x @@ -504,9 +509,9 @@ %\insidecolumnstrue % trick, forces no centering, todo: proper switch/feature \postcenterfloatmethod\zerocount \forcelocalfloats - \protected\def\stopfloatcombination{\pack_combinations_stop_float{#1}}} + \enforced\permanent\protected\def\stopfloatcombination{\pack_combinations_stop_float{#1}}} -\let\stopfloatcombination\relax +\aliased\let\stopfloatcombination\relax \def\pack_combinations_float_check_x_y {\ifnum\numexpr\c_pack_combinations_x*\c_pack_combinations_y\relax<\noflocalfloats\relax @@ -678,10 +683,10 @@ \newdimen\s_pack_pairedboxes_size \appendtoks - \setuevalue{\e!setup\currentpairedbox\e!endsetup}{\setuppairedbox [\currentpairedbox]}% - \setuevalue{\e!place\currentpairedbox }{\placepairedbox [\currentpairedbox]}% one argument is mandate anyway - \setuevalue{\e!start\e!place\currentpairedbox }{\startplacepairedbox[\currentpairedbox]}% one argument is mandate anyway - \setuevalue{\e!stop\e!place \currentpairedbox }{\stopplacepairedbox }% + \frozen\instance\setuevalue{\e!setup\currentpairedbox\e!endsetup}{\setuppairedbox [\currentpairedbox]}% + \frozen\instance\setuevalue{\e!place\currentpairedbox }{\placepairedbox [\currentpairedbox]}% one argument is mandate anyway + \frozen\instance\setuevalue{\e!start\e!place\currentpairedbox }{\startplacepairedbox[\currentpairedbox]}% one argument is mandate anyway + \frozen\instance\setuevalue{\e!stop\e!place \currentpairedbox }{\stopplacepairedbox }% \to \everydefinepairedbox \permanent\tolerant\protected\def\startplacepairedbox[#1]#*[#2]% @@ -693,10 +698,10 @@ \edef\p_location{\pairedboxparameter\c!location}% \edef\p_n {\pairedboxparameter\c!n}% % - \let\startcontent\pack_common_content_start - \let\stopcontent \pack_common_content_stop - \let\startcaption\pack_common_caption_start - \let\stopcaption \pack_common_caption_stop + \enforced\let\startcontent\pack_common_content_start + \enforced\let\stopcontent \pack_common_content_stop + \enforced\let\startcaption\pack_common_caption_start + \enforced\let\stopcaption \pack_common_caption_stop % \globalsetsystemmode{pairedbox}% \pack_pairedboxes_before @@ -704,7 +709,7 @@ \permanent\protected\def\stopplacepairedbox{} % we just pick up two boxes -\let\placepairedbox\startplacepairedbox % we just pick up two boxes +\aliased\let\placepairedbox\startplacepairedbox % we just pick up two boxes \def\pack_pairedboxes_first_pickup {\dowithnextboxcs\pack_pairedboxes_first\hbox diff --git a/tex/context/base/mkxl/pack-cut.mkxl b/tex/context/base/mkxl/pack-cut.mkxl new file mode 100644 index 000000000..08a5eab11 --- /dev/null +++ b/tex/context/base/mkxl/pack-cut.mkxl @@ -0,0 +1,164 @@ +%D \module +%D [ file=pack-cut, % comes from core-vis/trac-vis +%D version=1996.06.01, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Cut boxes, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +%D \macros +%D {makecutbox, cuthbox, cutvbox, cutvtop} +%D +%D Although mainly used for marking the page, these macros can also serve local use. +%D +%D \startbuffer +%D \setbox0=\vbox{a real \crlf vertical box} \makecutbox0 +%D \stopbuffer +%D +%D \typebuffer +%D +%D This marked \type{\vbox} shows up as: +%D +%D \startlinecorrection +%D \getbuffer +%D \stoplinecorrection +%D +%D The alternative macros are used as: +%D +%D \startbuffer +%D \cuthbox{a made cut box} +%D \stopbuffer +%D +%D \typebuffer +%D +%D This is typeset as: +%D +%D \startlinecorrection +%D \getbuffer +%D \stoplinecorrection +%D +%D By setting the next macros one can influence the length of the marks as well as +%D the horizontal and vertical divisions. + +\newdimen\d_pack_cutmarks_width +\newdimen\d_pack_cutmarks_height +\newdimen\d_pack_cutmarks_depth + +\newcount\horizontalcutmarks \horizontalcutmarks \plustwo +\newcount\verticalcutmarks \verticalcutmarks \plustwo +\newcount\cutmarkoffset \cutmarkoffset \plusone + +\mutable\let\cutmarksymbol \relax +\mutable\let\cutmarktoptext \empty +\mutable\let\cutmarkbottomtext \empty +\mutable\let\cutmarkhoffset \empty +\mutable\let\cutmarkvoffset \empty +\mutable\def\cutmarklength {2\bodyfontsize} +\mutable\def\cutmarkrulethickness{\onepoint} + +\permanent\protected\def\horizontalcuts + {\hpack to \d_pack_cutmarks_width + {\dorecurse\horizontalcutmarks{\vrule\s!width\cutmarkrulethickness\s!height\cutmarklength\hfill}% + \unskip}} + +\permanent\protected\def\verticalcuts + {\vpack to \dimexpr\d_pack_cutmarks_height+\d_pack_cutmarks_depth\relax + {\hsize\cutmarklength + \dorecurse\verticalcutmarks{\vrule\s!height\cutmarkrulethickness\s!width\hsize\vfill}% + \unskip}} + +\permanent\protected\def\baselinecuts + {\ifdim\d_pack_cutmarks_depth>\zeropoint + \vpack to \dimexpr\d_pack_cutmarks_height+\d_pack_cutmarks_depth\relax + {\hsize\dimexpr\cutmarklength/2\relax + \vskip\zeropoint\s!plus\d_pack_cutmarks_height + \vrule\s!height\cutmarkrulethickness\s!width\hsize + \vskip\zeropoint\s!plus\d_pack_cutmarks_depth}% + \fi} + +\permanent\protected\def\cutmarksymbols#1% + {\hpack to \d_pack_cutmarks_width + {\setbox\scratchbox\hbox to \cutmarklength + {\hss\infofont\cutmarksymbol\hss}% + \hss + \vpack to \cutmarklength + {\scratchdimen\dimexpr\cutmarklength/2\relax + \scratchskip \ifx\cutmarkhoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkhoffset\fi + \vss + \hbox to \d_pack_cutmarks_width + {\llap{\copy\scratchbox\hskip\scratchskip}% + \hskip\scratchdimen\hss + \infofont#1% + \hss\hskip\scratchdimen + \rlap{\hskip\scratchskip\copy\scratchbox}}% + \vss}% + \hss}} + +\permanent\protected\def\makecutbox#1% + {\bgroup + \d_pack_cutmarks_height\ht#1% + \d_pack_cutmarks_depth \dp#1% + \d_pack_cutmarks_width \wd#1% + \setbox#1\hpack + {\dontcomplain + \forgetall + \boxmaxdepth\maxdimen + \offinterlineskip + \scratchdimen\dimexpr\cutmarklength/2\relax + \hsize\d_pack_cutmarks_width + \setbox\scratchbox\vpack + {\setbox\scratchbox\hpack{\horizontalcuts}% + \scratchskip\ifx\cutmarkvoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi + \tlap{\copy\scratchbox\vskip\scratchskip}% + \hpack to \d_pack_cutmarks_width + {\scratchskip\ifx\cutmarkhoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkhoffset\fi + \setbox\scratchbox\hpack{\verticalcuts}% + \llap{\copy\scratchbox\hskip\scratchskip}% + \ifdim\d_pack_cutmarks_depth=\zeropoint + \hfill + \else + \bgroup + \setbox\scratchbox\hpack{\baselinecuts}% + \llap{\copy\scratchbox\hskip\scratchskip}% + \hfill + \rlap{\hskip\scratchskip\copy\scratchbox}% + \egroup + \fi + \rlap{\hskip\scratchskip\copy\scratchbox}}% + \blap{\vskip\scratchskip\copy\scratchbox}}% + \ht\scratchbox\d_pack_cutmarks_height + \dp\scratchbox\d_pack_cutmarks_depth + \wd\scratchbox\zeropoint + \startcolor[\defaulttextcolor]% + \box\scratchbox + \ifx\cutmarksymbol\relax \else + \setbox\scratchbox\vpack + {\scratchskip\ifx\cutmarkvoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi + \vskip-\dimexpr\scratchskip+\cutmarklength\relax + \hpack{\cutmarksymbols\cutmarktoptext}% + \vskip\dimexpr\scratchskip+\d_pack_cutmarks_height+\d_pack_cutmarks_depth+\scratchskip\relax + \hpack{\cutmarksymbols\cutmarkbottomtext}}% + \ht\scratchbox\d_pack_cutmarks_height + \dp\scratchbox\d_pack_cutmarks_depth + \wd\scratchbox\zeropoint + \box\scratchbox + \fi + \stopcolor + \box#1}% + \wd#1\d_pack_cutmarks_width + \ht#1\d_pack_cutmarks_height + \dp#1\d_pack_cutmarks_depth + \egroup} + +\permanent\protected\def\cuthbox{\hpack\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\hbox} +\permanent\protected\def\cutvbox{\vpack\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\vbox} +\permanent\protected\def\cutvtop{\tpack\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\vtop} + +\protect \endinput diff --git a/tex/context/base/mkxl/pack-fen.mkxl b/tex/context/base/mkxl/pack-fen.mkxl new file mode 100644 index 000000000..8fa74b884 --- /dev/null +++ b/tex/context/base/mkxl/pack-fen.mkxl @@ -0,0 +1,97 @@ +%D \module +%D [ file=pack-fen, +%D version=2011.07.21, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle= Fences for Ruled Content, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Packaging Macros / Fences for Ruled Content} + +%D \startbuffer +%D \useMPlibrary[meta-imp-hooks.mkiv] +%D +%D \framed[frame=off,bottomframe=righthook]{Bottom right hook} +%D \stopbuffer +%D +%D \typebuffer +%D +%D \startlinecorrection +%D \getbuffer +%D \stoplinecorrection + +\unprotect + +\permanent\protected\def\installleftframerenderer#1#2% + {\setvalue{\??framedleft\v!on#1}{\whateverleftframe{#2}}% + \letcsname\??framedleft\v!off#1\expandafter\endcsname\csname\??framedleft\v!on#1\endcsname} + +\permanent\protected\def\installrightframerenderer#1#2% + {\setvalue{\??framedright\v!on#1}{\whateverrightframe{#2}}% + \letcsname\??framedright\v!off#1\expandafter\endcsname\csname\??framedright\v!on#1\endcsname} + +\permanent\protected\def\installtopframerenderer#1#2% + {\setvalue{\??framedtop\v!on#1}{\whatevertopframe{#2}}% + \letcsname\??framedtop\v!off#1\expandafter\endcsname\csname\??framedtop\v!on#1\endcsname} + +\permanent\protected\def\installbottomframerenderer#1#2% + {\setvalue{\??framedbottom\v!on#1}{\whateverbottomframe{#2}}% + \letcsname\??framedbottom\v!off#1\expandafter\endcsname\csname\??framedbottom\v!on#1\endcsname} + +\ifdefined \pack_framed_overlay_initialize_indeed + + \aliased\let\setinstalledframedimensions\pack_framed_overlay_initialize_indeed + +\else + + \permanent\protected\def\setinstalledframedimensions + {\d_overlay_width \frameddimenwd + \d_overlay_height \dimexpr\frameddimenht+\frameddimendp\relax + \d_overlay_depth \frameddimendp + \d_overlay_linewidth \ruledlinewidth + \edef\overlaycolor {\framedparameter\c!backgroundcolor}% + \edef\overlaylinecolor{\framedparameter\c!framecolor}} + +\fi + +\newbox\b_framed_rendered + +\permanent\def\whateverleftframe#1% + {\setinstalledframedimensions + \setbox\b_framed_rendered\vpack to \d_overlay_height{\vss#1\vss}% + \setbox\b_framed_rendered\hpack to \zeropoint{\box\b_framed_rendered\hss}% + \ht\b_framed_rendered\zeropoint + \dp\b_framed_rendered\zeropoint + \box\b_framed_rendered} + +\permanent\def\whateverrightframe#1% + {\setinstalledframedimensions + \setbox\b_framed_rendered\vpack to \d_overlay_height{\vss#1\vss}% + \setbox\b_framed_rendered\hpack to \zeropoint{\hss\box\b_framed_rendered}% + \ht\b_framed_rendered\zeropoint + \dp\b_framed_rendered\zeropoint + \box\b_framed_rendered} + +\permanent\def\whatevertopframe#1% + {\setinstalledframedimensions + \setbox\b_framed_rendered\hpack to \d_overlay_width{\hss#1\hss}% + \setbox\b_framed_rendered\vpack to \zeropoint{\box\b_framed_rendered\vss}% + \ht\b_framed_rendered\zeropoint + \dp\b_framed_rendered\zeropoint + \box\b_framed_rendered + \nointerlineskip} + +\permanent\def\whateverbottomframe#1% + {\setinstalledframedimensions + \setbox\b_framed_rendered\hpack to \d_overlay_width{\hss#1\hss}% + \setbox\b_framed_rendered\vpack to \zeropoint{\vss\box\b_framed_rendered}% + \ht\b_framed_rendered\zeropoint + \dp\b_framed_rendered\zeropoint + \box\b_framed_rendered} + +\protect \endinput diff --git a/tex/context/base/mkiv/pack-lyr.mkxl b/tex/context/base/mkxl/pack-lyr.mkxl index 366eeff75..e85b3c185 100644 --- a/tex/context/base/mkiv/pack-lyr.mkxl +++ b/tex/context/base/mkxl/pack-lyr.mkxl @@ -487,7 +487,7 @@ \expandafter\secondoftwoarguments \fi} -\let\doiflayerdataelse\doifelselayerdata +\aliased\let\doiflayerdataelse\doifelselayerdata %D \macros %D {flushlayer} @@ -698,7 +698,7 @@ \d_overlay_height\layerparameter\c!height \composedlayer{#1}}} -\let\placelayer\flushlayer +\aliased\let\placelayer\flushlayer %D \macros %D {setMPlayer} @@ -730,8 +730,8 @@ %D {\useMPgraphic{oeps}} %D \stoptyping -\def\MPlayerwidth {\hsize} -\def\MPlayerheight{\vsize} +\mutable\def\MPlayerwidth {\hsize} +\mutable\def\MPlayerheight{\vsize} \permanent\tolerant\protected\def\setMPlayer[#1]#*[#2]#*[#3]% {\edef\MPlayerwidth {\MPw{#2}}% diff --git a/tex/context/base/mkxl/pack-mis.mklx b/tex/context/base/mkxl/pack-mis.mklx new file mode 100644 index 000000000..5c63f533c --- /dev/null +++ b/tex/context/base/mkxl/pack-mis.mklx @@ -0,0 +1,112 @@ +%D \module +%D [ file=pack-mis, % moved from e.g. core-mis +%D version=1998.01.29, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Miscelaneous, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Packing Macros / Misc Commands} + +\unprotect + +% a quite old mechanism already (but inheritance added) +% +% \defineplacement[name][settings] +% \setupplacement [name][settings] +% \placement [name][settings] +% \place<name> [settings] + +\installcorenamespace{placement} + +\installcommandhandler \??placement {placement} \??placement + +\appendtoks + \frozen\instance\setuevalue{\e!place\currentplacement}{\pack_placement{\currentplacement}}% +\to \everydefineplacement + +\setupplacement + [\c!left=\hss, + \c!right=\hss, + \c!linecorrection=\v!off, + \c!depthcorrection=\v!off, + \c!grid=\v!middle, + %\c!before=, + %\c!after=, + \c!margin=\v!standard] + +\permanent\protected\def\placement[#tag]% + {\pack_placement{#tag}} + +\protected\def\pack_placement#tag% + {\bgroup + \edef\currentplacement{#tag}% + \doifelsenextoptionalcs\pack_placement_yes\pack_placement_nop} + +\def\pack_placement_yes[#settings]% + {\setupcurrentplacement[#settings]% + \pack_placement_nop} + +\def\pack_placement_nop + {\dowithnextboxcontentcs\forgetall\pack_placement_flush\vbox} + +\def\pack_placement_flush + {\setlocalhsize + \placementparameter\c!before + \begingroup + \disableparpositions + \setbox\nextbox\hbox to \localhsize + {\placementparameter\c!left + \flushnextbox + \placementparameter\c!right}% + %\ifinsidefloat \else + % \page_backgrounds_add_local_to_box\nextbox + %\fi +\flushnotes % new per 2014-05-29 : todo: move them up in the mvl + \ifgridsnapping + \pack_placement_flush_grid_yes + \else + \pack_placement_flush_grid_nop + \fi + \endgroup + \placementparameter\c!after + \egroup} + +\def\pack_placement_flush_grid_yes + {\edef\p_grid{\placementparameter\c!grid}% + \ifempty\p_grid + \let\p_grid\v!middle + \fi + \pack_placement_flush_grid_noindent + \snaptogrid[\p_grid]\hbox{\box\nextbox}} + +\def\pack_placement_flush_grid_nop + {\edef\p_linecorrection {\placementparameter\c!linecorrection}% + \edef\p_depthcorrection{\placementparameter\c!depthcorrection}% + \ifx\p_linecorrection\v!on + \startbaselinecorrection + \fi + \pack_placement_flush_grid_noindent + \box\nextbox + \ifx\p_depthcorrection\v!on + \baselinecorrection + \fi + \ifx\p_linecorrection\v!on + \stopbaselinecorrection + \fi} + +\def\pack_placement_flush_grid_noindent + {\edef\p_margin{\placementparameter\c!margin}% + \ifx\p_margin\v!standard + \noindent + \orelse\ifx\p_margin\v!yes + \noindent + \fi} + +\protect \endinput + diff --git a/tex/context/base/mkiv/pack-mrl.mkxl b/tex/context/base/mkxl/pack-mrl.mkxl index edc581953..f9736aa74 100644 --- a/tex/context/base/mkiv/pack-mrl.mkxl +++ b/tex/context/base/mkxl/pack-mrl.mkxl @@ -523,28 +523,22 @@ % can be done nicer with futureexpandis -\permanent\protected\def\textrule - {\dosingleempty\pack_textrule} - -\def\pack_textrule - {\iffirstargument - \expandafter\pack_textrule_yes - \else +\permanent\tolerant\protected\def\textrule[#1]% + {\ifarguments \expandafter\pack_textrule_nop - \fi} + \else + \expandafter\pack_textrule_yes + \fi[#1]} \def\pack_textrule_yes[#1]% {\expandnamespacevalue\??textrulealternatives{#1}\v!bottom} -\def\pack_textrule_nop[#1]% - {\dosinglegroupempty\pack_textrule_nop_indeed} - -\def\pack_textrule_nop_indeed - {\iffirstargument +\tolerant\def\pack_textrule_nop[#1]#:#=% + {\ifparameter#2\or \expandafter\pack_textrule_nop_indeed_yes \else \expandafter\pack_textrule_nop_indeed_nop - \fi} + \fi[#1]{#2}} \def\pack_textrule_nop_indeed_yes {\csname\??textrulealternatives\v!top\endcsname} diff --git a/tex/context/base/mkxl/pack-obj.lmt b/tex/context/base/mkxl/pack-obj.lmt new file mode 100644 index 000000000..f021339b4 --- /dev/null +++ b/tex/context/base/mkxl/pack-obj.lmt @@ -0,0 +1,305 @@ +if not modules then modules = { } end modules ['pack-obj'] = { + version = 1.001, + comment = "companion to pack-obj.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +--[[ldx-- +<p>We save object references in the main utility table. jobobjects are +reusable components.</p> +--ldx]]-- + +local context = context +local codeinjections = backends.codeinjections +local ctx_doifelse = commands.doifelse + +local report = logs.reporter("objects") +local trace = false trackers.register("objects",function(v) trace = v end) + +local nuts = nodes.nuts + +local setlink = nuts.setlink +local getlist = nuts.getlist +local setbox = nuts.setbox + +local new_latelua = nuts.pool.latelua + +local settexdimen = tokens.setters.dimen + +local getcount = tex.getcount + +local implement = interfaces.implement +local setmacro = interfaces.setmacro + +local allocate = utilities.storage.allocate + +local collected = allocate() +local tobesaved = allocate() + +local jobobjects = { + collected = collected, + tobesaved = tobesaved, +} + +job.objects = jobobjects + +local function initializer() + collected = jobobjects.collected + tobesaved = jobobjects.tobesaved +end + +job.register('job.objects.collected', tobesaved, initializer, nil) + +local function saveobject(tag,number,page) + local data = { number, page } + tobesaved[tag] = data + collected[tag] = data +end + +local function saveobjectspec(specification) + local tag = specification.tag + local data = { specification.number, specification.page } + tobesaved[tag] = data + collected[tag] = data +end + +local function setobject(tag,number,page) + collected[tag] = { number, page } +end + +local function getobject(tag) + return collected[tag] or tobesaved[tag] +end + +local function getobjectnumber(tag,default) + local o = collected[tag] or tobesaved[tag] + return o and o[1] or default +end + +local function getobjectpage(tag,default) + local o = collected[tag] or tobesaved[tag] + return o and o[2] or default +end + +jobobjects.save = saveobject +jobobjects.set = setobject +jobobjects.get = getobject +jobobjects.number = getobjectnumber +jobobjects.page = getobjectpage + +-- implement { +-- name = "saveobject", +-- actions = saveobject +-- } +-- +-- implement { +-- name = "setobject", +-- actions = setobject, +-- arguments = { "string", "integer", "integer" } +-- } +-- +-- implement { +-- name = "objectnumber", +-- actions = { getobjectnumber, context }, +-- arguments = "2 strings", +-- } +-- +-- implement { +-- name = "objectpage", +-- actions = { getobjectpage, context }, +-- arguments = "2 strings", +-- } +-- +-- implement { +-- name = "doifelseobjectreferencefound", +-- actions = { getobject, commands.doifelse }, +-- arguments = "string" +-- } + +-- if false then +-- -- we can flush the inline ref ourselves now if we want +-- local flush = new_latelua("pdf.flushxform("..index..")") +-- flush.next = list +-- next.prev = flush +-- end + +local data = table.setmetatableindex("table") + +objects = { + data = data, + n = 0, +} + +local objects = objects + +function objects.register(ns,id,b,referenced,offset,mode) + local n = objects.n + 1 + objects.n = n + nodes.handlers.finalizebox(b) + if mode == 0 then + -- tex + data[ns][id] = { + codeinjections.registerboxresource(b), -- a box number + offset, + referenced or false, + mode, + } + else + -- box (backend) + data[ns][id] = { + codeinjections.registerboxresource(b,offset), -- a box number + false, + referenced, + mode, + } + end + if trace then + report("registering object %a (n=%i)",id,n) + end +end + +function objects.restore(ns,id) -- why not just pass a box number here too (ok, we also set offset) + local d = data[ns][id] + if d then + local index = d[1] + local offset = d[2] + local status = d[3] + local mode = d[4] + local hbox = codeinjections.restoreboxresource(index) -- a nut ! + if status then + local list = getlist(hbox) + local page = new_latelua { + action = saveobjectspec, + tag = ns .. "::" .. id, + number = index, + page = getcount("realpageno"), + } + -- list is a rule + setlink(list,page) + end + setbox("objectbox",hbox) + settexdimen("objectoff",offset or 0) + else + setbox("objectbox",nil) + settexdimen("objectoff",0) -- for good old times + end + if trace then + report("restoring object %a",id) + end +end + +function objects.dimensions(index) + local d = data[ns][id] + if d then + return codeinjections.boxresourcedimensions(d[1]) + else + return 0, 0, 0, 0 + end +end + +function objects.reference(ns,id) + local d = data[ns][id] + if d then + return d[1] + else + return getobjectnumber(ns .."::" .. id,0) + end +end + +function objects.page(ns,id) + return getobjectpage(ns .."::" .. id,getcount("realpageno")) +end + +function objects.found(ns,id) + return data[ns][id] +end + +implement { + name = "registerreferencedobject", + arguments = { "string", "string", "integer", true, "dimension", "integer" }, + actions = objects.register, +} + +implement { + name = "registerobject", + arguments = { "string", "string", "integer", false, "dimension", "integer" }, + actions = objects.register, +} + +implement { + name = "restoreobject", + arguments = "2 strings", + actions = objects.restore, +} + +implement { + name = "doifelseobjectfound", + arguments = "2 arguments", + public = true, + protected = true, + actions = function(ns,id) + ctx_doifelse(data[ns][id]) + -- ctx_doifelse(objects.reference(ns,id)) + end, +} + +implement { + name = "doifelseobjectreferencefound", + arguments = "2 arguments", + public = true, + protected = true, + actions = function(ns,id) + -- ctx_doifelse(data[ns][id]) + ctx_doifelse(objects.reference(ns,id)) + end, +} + +implement { + name = "getobjectreference", + arguments = { "argument", "argument", "csname" }, + public = true, + protected = true, + actions = function(ns,id,target) + setmacro(target,objects.reference(ns,id),"global") + end +} + +implement { + name = "getobjectreferencepage", + arguments = { "argument", "argument", "csname" }, + public = true, + protected = true, + actions = function(ns,id,target) + setmacro(target,objects.page(ns,id),"global") + end +} + +implement { + name = "getobjectdimensions", + arguments = "2 arguments", + public = true, + protected = true, + actions = function(ns,id) + local object = data[ns][id] + local w, h, d, o = 0, 0, 0, 0 + if object then + w, h, d, o = codeinjections.boxresourcedimensions(object[1]) + end + settexdimen("objectwd",w or 0) + settexdimen("objectht",h or 0) + settexdimen("objectdp",d or 0) + settexdimen("objectoff",o or #objects > 2 and object[2] or 0) + end +} + +-- for the moment here: + +implement { + name = "registerbackendsymbol", + arguments = { "string", "integer" }, + actions = function(...) + codeinjections.registersymbol(...) + end +} diff --git a/tex/context/base/mkxl/pack-obj.mkxl b/tex/context/base/mkxl/pack-obj.mkxl new file mode 100644 index 000000000..751434db0 --- /dev/null +++ b/tex/context/base/mkxl/pack-obj.mkxl @@ -0,0 +1,168 @@ +%D \module +%D [ file=pack-obj, +%D version=1998.01.15, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Objects, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Packaging Macros / Objects} + +\unprotect + +\registerctxluafile{pack-obj}{autosuffix} + +%D \macros +%D {setobject,getobject,ifinobject} +%D +%D Boxes can be considered reuable objects. Traditionally once passed to the \DVI\ +%D file, such objects cannot be reused. In \PDF\ however, reusing is possible and +%D sometimes even a necessity. Therefore, \CONTEXT\ supports reusable objects and +%D \LUATEX\ has native support for so called box resources. +%D +%D The first application of objects in \CONTEXT\ concerned \METAPOST\ graphics and +%D fill||in form fields. Reusing resources can save lots of bytes and sometimes also +%D runtime. +%D +%D \starttyping +%D \setobject{class}{name}\somebox{} +%D \getobject{class}{name} +%D \stoptyping +%D +%D Here \type {\somebox} can be whatever box specification suits \TEX. Although the +%D implementation in \MKIV\ is somewhat different the principles have not changed. + +\installcorenamespace {objects} + +\newif \ifinobject +\newbox \objectbox + +\def\objectoffset{1cm} + +\newdimen\objectoff \permanent\def\objectmargin{\the\objectoff} +\newdimen\objectwd \permanent\def\objectwidth {\the\objectwd} +\newdimen\objectht \permanent\def\objectheight{\the\objectht} +\newdimen\objectdp \permanent\def\objectdepth {\the\objectdp} + +%D If I have time I will use the unreferenced variant for e.g. mp reuse. This can be +%D rewritten in \LUA\ anyway. + +\permanent\protected\def\setreferencedobject #1#2{\begingroup\synctexpause\objectoff\objectoffset\inobjecttrue\dowithnextbox{\pack_objects_set_yes{#1}{#2}}} +\permanent\protected\def\settightreferencedobject #1#2{\begingroup\synctexpause\objectoff\zeropoint \inobjecttrue\dowithnextbox{\pack_objects_set_yes{#1}{#2}}} +\permanent\protected\def\setunreferencedobject #1#2{\begingroup\synctexpause\objectoff\objectoffset\inobjecttrue\dowithnextbox{\pack_objects_set_nop{#1}{#2}}} +\permanent\protected\def\settightunreferencedobject#1#2{\begingroup\synctexpause\objectoff\zeropoint \inobjecttrue\dowithnextbox{\pack_objects_set_nop{#1}{#2}}} + +\aliased\let\setobject \setreferencedobject +\aliased\let\settightobject\settightreferencedobject + +%D We can get subtle differences in boundingboxes but both methods work ok. + +\newconstant\c_pack_objects_offset_mode % 0=tex 1=box + +\protected\def\pack_objects_set_yes#1#2% + {\ifcase\c_pack_objects_offset_mode + \ifzeropt\objectoff + \pack_objects_package_nop\nextbox + \else + \pack_objects_package_yes\nextbox + \fi + \else + \pack_objects_package_nop\nextbox + \fi + \clf_registerreferencedobject{#1}{#2}\objectbox\objectoff\c_pack_objects_offset_mode + \synctexresume + \endgroup} + +\protected\def\pack_objects_set_nop#1#2% + {\ifcase\c_pack_objects_offset_mode + \ifzeropt\objectoff + \pack_objects_package_nop\nextbox + \else + \pack_objects_package_yes\nextbox + \fi + \else + \pack_objects_package_nop\nextbox + \fi + \clf_registerobject{#1}{#2}\objectbox\objectoff\c_pack_objects_offset_mode + \synctexresume + \endgroup} + +\def\pack_objects_package_nop#1% we pack because otherwise \ruledhbox is still tight + {\setbox\objectbox\hpack{\box#1}} + +\def\pack_objects_package_yes#1% + {\objectwd\dimexpr\wd#1+2\objectoff\relax + \objectht\dimexpr\ht#1+ \objectoff\relax + \objectdp\dimexpr\dp#1+ \objectoff\relax + \setbox\objectbox\hpack + {\hskip\objectoff + \box#1}% + \wd\objectbox\objectwd + \ht\objectbox\objectht + \dp\objectbox\objectdp} + +\permanent\protected\def\getobject#1#2% + {\begingroup + \synctexpause + \clf_restoreobject{#1}{#2}% + \ifzeropt\objectoff\else + \objectoff-\objectoff + \pack_objects_package_yes\objectbox + \fi + \box\objectbox + \synctexresume + \endgroup} + +%D If needed one can ask for the dimensions of an object with: +%D +%D \starttyping +%D \getobjectdimensions{class}{name} +%D \stoptyping +%D +%D The results are reported in \type {\objectwidth}, \type {\objectheight} and \type +%D {\objectdepth} as well as \type {\objectoffset}. + +% \getobjectdimensions #1#2 % defined at the lua end + +%D \macros +%D {doifobjectfoundelse,doifobjectreferencefoundelse} +%D +%D To prevent redundant definition of objects, one can use the next tests: +%D +%D \starttyping +%D \doifobjectfoundelse{class}{object}{do then}{do else} +%D \doifobjectreferencefoundelse{class}{object}{do then}{do else} +%D \stoptyping + +\immutable\def\defaultobjectreference{0} +\immutable\def\defaultobjectpage {\realfolio} + +% \getobjectreference {#1}{#2\csname % define at the lua end +% \getobjectreferencepage {#1}{#2\csname % define at the lua end +% \doifelseobjectfound {#1}{#2} % defined atthe lua end +% \doifelseobjectreferencefound {#1}{#2} % defined atthe lua end + +\aliased\let\dogetobjectreference \getobjectreference % for now, will go away +\aliased\let\dogetobjectreferencepage\getobjectreferencepage % for now, will go away + +\aliased\let\doifobjectfoundelse \doifelseobjectfound +\aliased\let\doifobjectreferencefoundelse\doifelseobjectreferencefound + +%D For the moment here: + +\mutable\let\lastpredefinedsymbol\empty % some day we can do more at the lua end + +\permanent\protected\def\predefinesymbol[#1]% + {\begingroup + \xdef\lastpredefinedsymbol{#1}% + \settightobject{SYM}{#1}\hbox{\symbol[#1]}% to be checked ... maybe only fitting + \getobjectreference{SYM}{#1}\m_back_object_reference + \clf_registerbackendsymbol{#1}\m_back_object_reference\relax + \endgroup} + +\protect \endinput diff --git a/tex/context/base/mkiv/pack-ori.lmt b/tex/context/base/mkxl/pack-ori.lmt index a786b19ef..a786b19ef 100644 --- a/tex/context/base/mkiv/pack-ori.lmt +++ b/tex/context/base/mkxl/pack-ori.lmt diff --git a/tex/context/base/mkiv/pack-ori.mkxl b/tex/context/base/mkxl/pack-ori.mkxl index 4365db3ac..4365db3ac 100644 --- a/tex/context/base/mkiv/pack-ori.mkxl +++ b/tex/context/base/mkxl/pack-ori.mkxl diff --git a/tex/context/base/mkxl/pack-pos.mkxl b/tex/context/base/mkxl/pack-pos.mkxl new file mode 100644 index 000000000..025232eb3 --- /dev/null +++ b/tex/context/base/mkxl/pack-pos.mkxl @@ -0,0 +1,160 @@ +%D \module +%D [ file=pack-pos, +%D version=2010.11.17 % real old code, updated a bit +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Positioning, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Packaging Macros / Positioning} + +\unprotect + +% An old but still usefull mechanism: +% +% \ruledvbox{\startpositioning +% \position(1,1){test} +% \position[xstep=relative](1,1){test} +% \position[ystep=relative](3,-1){test} +% \position(10,10){test} +% \stoppositioning} +% +% watch out: rather global + +\installcorenamespace {positioning} + +\installcommandhandler \??positioning {positioning} \??positioning + +\setuppositioning + [\c!state=\v!start, + \c!unit=\s!cm, + \c!factor=\plusone, + \c!scale =\plusone, + \c!xfactor=\positioningparameter\c!factor, + \c!yfactor=\positioningparameter\c!factor, + \c!xscale=\positioningparameter\c!scale, + \c!yscale=\positioningparameter\c!scale, + \c!xstep=\v!absolute, + \c!ystep=\v!absolute, + \c!xoffset=\zeropoint, + \c!yoffset=\zeropoint] + +\newdimen\d_pack_positioning_x_position +\newdimen\d_pack_positioning_y_position +\newdimen\d_pack_positioning_x_dimension +\newdimen\d_pack_positioning_y_dimension +\newdimen\d_pack_positioning_x_offset +\newdimen\d_pack_positioning_y_offset + +\newbox\b_pack_positioning + +\permanent\tolerant\protected\def\startpositioning[#1]#*[#2]% + {\bgroup + \ifparameters + \let\currentpositioning\empty + \or + \ifhastok={#1}% + \let\currentpositioning\empty + \setupcurrentpositioning[#1]% + \else + \edef\currentpositioning{#1}% + \fi + \or + \edef\currentpositioning{#1}% + \setupcurrentpositioning[#2]% + \fi + \d_pack_positioning_x_position \zeropoint + \d_pack_positioning_y_position \zeropoint + \d_pack_positioning_x_dimension\zeropoint + \d_pack_positioning_y_dimension\zeropoint + \d_pack_positioning_x_offset \zeropoint + \d_pack_positioning_y_offset \zeropoint + \hfuzz\paperwidth + \vfuzz\paperheight + \setbox\b_pack_positioning\hbox\bgroup + \ignorespaces} + +\permanent\protected\def\stoppositioning + {\removeunwantedspaces + \doifnot{\positioningparameter\c!offset}\v!yes + {\global\d_pack_positioning_x_offset\zeropoint + \global\d_pack_positioning_y_offset\zeropoint}% + \global\advance\d_pack_positioning_x_dimension\d_pack_positioning_x_offset + \global\advance\d_pack_positioning_y_dimension\d_pack_positioning_y_offset + \egroup + \vbox to \d_pack_positioning_y_dimension + {\vskip\d_pack_positioning_y_offset + \hbox to \d_pack_positioning_x_dimension + {\hskip\d_pack_positioning_x_offset + \box\b_pack_positioning + \hfill} + \vfill}% + \egroup} + +\protected\def\pack_positioning_calculate#1#2#3#4#5#6#7#8#9% + {\setdimensionwithunit\scratchdimen{#1}{\positioningparameter\c!unit}% + \scratchdimen\positioningparameter#8\scratchdimen + \scratchdimen\positioningparameter#9\scratchdimen + \advance\scratchdimen\positioningparameter#4\relax + % == \scratchdimen\dimexpr#8\dimexpr#9\scratchdimen\relax+#4\relax + \doif{\positioningparameter#2}\v!relative + {\advance\scratchdimen#3% + \letpositioningparameter#4\zeropoint}% + #3\scratchdimen + \doifnot{\positioningparameter\c!state}\v!overlay + {\scratchdimen\dimexpr#5\nextbox+#3\relax + \ifdim #3<-#7\relax \global#7-#3\relax \fi + \ifdim\scratchdimen> #6\relax \global#6\scratchdimen\fi}} + +\permanent\tolerant\protected\def\position[#1]#*(#2,#3)% + {\bgroup + \ifparameter#1\or + \setupcurrentpositioning[#1]% + \fi + \removeunwantedspaces + \dowithnextbox{\pack_positioning_position_indeed{#2}{#3}}\hbox} + +\def\pack_positioning_position_indeed#1#2% + {\dontcomplain + \pack_positioning_calculate + {#1}% + \c!xstep + \d_pack_positioning_x_position + \c!xoffset + \wd + \d_pack_positioning_x_dimension + \d_pack_positioning_x_offset + \c!xscale + \c!xfactor + \pack_positioning_calculate + {#2}% + \c!ystep + \d_pack_positioning_y_position + \c!yoffset + \htdp + \d_pack_positioning_y_dimension + \d_pack_positioning_y_offset + \c!yscale + \c!yfactor + \vbox to \zeropoint + {\offinterlineskip % else we get an empty line + \vskip\d_pack_positioning_y_position + \hbox to \zeropoint + {\hskip\d_pack_positioning_x_position + \box\nextbox + \hss} + \vss}% + \normalexpanded + {\egroup + \d_pack_positioning_x_position\the\d_pack_positioning_x_position + \d_pack_positioning_y_position\the\d_pack_positioning_y_position + \setexpandedpositioningparameter\c!xoffset{\the\dimexpr\positioningparameter\c!xoffset}% + \setexpandedpositioningparameter\c!yoffset{\the\dimexpr\positioningparameter\c!yoffset}}% + \ignorespaces} + +\protect \endinput diff --git a/tex/context/base/mkxl/pack-rul.lmt b/tex/context/base/mkxl/pack-rul.lmt new file mode 100644 index 000000000..3fa179604 --- /dev/null +++ b/tex/context/base/mkxl/pack-rul.lmt @@ -0,0 +1,248 @@ +if not modules then modules = { } end modules ['pack-rul'] = { + version = 1.001, + optimize = true, + comment = "companion to pack-rul.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +--[[ldx-- +<p>An explanation is given in the history document <t>mk</t>.</p> +--ldx]]-- + +-- we need to be careful with display math as it uses shifts + +-- \framed[align={lohi,middle}]{$x$} +-- \framed[align={lohi,middle}]{$ $} +-- \framed[align={lohi,middle}]{\hbox{ }} +-- \framed[align={lohi,middle}]{\hbox{}} +-- \framed[align={lohi,middle}]{$\hskip2pt$} + +local type = type + +local context = context + +local nodecodes = nodes.nodecodes +local listcodes = nodes.listcodes + +local hlist_code = nodecodes.hlist +local vlist_code = nodecodes.vlist + +local boxlist_code = listcodes.box +local linelist_code = listcodes.line +local equationlist_code = listcodes.equation + +local texsetdimen = tex.setdimen +local texsetcount = tex.setcount + +local implement = interfaces.implement + +local nuts = nodes.nuts + +local getnext = nuts.getnext +local getprev = nuts.getprev +local getlist = nuts.getlist +local setlist = nuts.setlist +local getwhd = nuts.getwhd +local getid = nuts.getid +local getsubtype = nuts.getsubtype +local getbox = nuts.getbox +local getdirection = nuts.getdirection +local setshift = nuts.setshift +local setwidth = nuts.setwidth +local getwidth = nuts.getwidth +local setboxglue = nuts.setboxglue +local getboxglue = nuts.getboxglue + +local hpack = nuts.hpack +local getdimensions = nuts.dimensions +local flush_node = nuts.flush + +local traversers = nuts.traversers +local nexthlist = traversers.hlist +local nextvlist = traversers.vlist +local nextlist = traversers.list + +local checkformath = false + +directives.register("framed.checkmath",function(v) checkformath = v end) -- experiment + +-- beware: dir nodes and pseudostruts can end up on lines of their own + +local function doreshapeframedbox(n) + local box = getbox(n) + local noflines = 0 + local nofnonzero = 0 + local firstheight = nil + local lastdepth = nil + local lastlinelength = 0 + local minwidth = 0 + local maxwidth = 0 + local totalwidth = 0 + local averagewidth = 0 + local boxwidth = getwidth(box) + -- if boxwidth ~= 0 and getsubtype(box) == vlist_code then + if boxwidth ~= 0 then + local list = getlist(box) + if list then + local hdone = false + for n, id, subtype, list in nextlist, list do -- no dir etc needed + local width, height, depth = getwhd(n) + if not firstheight then + firstheight = height + end + lastdepth = depth + noflines = noflines + 1 + if list then + if id == hlist_code then + if subtype == boxlist_code or subtype == linelist_code then + lastlinelength = getdimensions(list) + else + lastlinelength = width + end + hdone = true + else + lastlinelength = width + -- vdone = true + end + if lastlinelength > maxwidth then + maxwidth = lastlinelength + end + if lastlinelength < minwidth or minwidth == 0 then + minwidth = lastlinelength + end + if lastlinelength > 0 then + nofnonzero = nofnonzero + 1 + end + totalwidth = totalwidth + lastlinelength + end + end + if not firstheight then + -- done) + elseif maxwidth ~= 0 then + if hdone then + for h, id, subtype, list in nextlist, list do + if list and id == hlist_code then + -- called a lot so maybe a simple case is needed + if subtype == boxlist_code or subtype == linelist_code then + -- getdirection is irrelevant here so it will go + -- somehow a parfillskip also can get influenced + local p = hpack(list,maxwidth,'exactly',getdirection(h)) -- multiple return value + local set, order, sign = getboxglue(p) + setboxglue(h,set,order,sign) + setlist(p) + flush_node(p) + elseif checkformath and subtype == equationlist_code then + -- display formulas use a shift + if nofnonzero == 1 then + setshift(h,0) + end + end + setwidth(h,maxwidth) + end + end + end + -- if vdone then + -- for v in nextvlist, list do + -- local width = getwidth(n) + -- if width > maxwidth then + -- setwidth(v,maxwidth) + -- end + -- end + -- end + setwidth(box,maxwidth) + averagewidth = noflines > 0 and totalwidth/noflines or 0 + else -- e.g. empty math {$ $} or \hbox{} or ... + setwidth(box,0) + end + end + end + texsetcount("global","framednoflines",noflines) + texsetdimen("global","framedfirstheight",firstheight or 0) -- also signal + texsetdimen("global","framedlastdepth",lastdepth or 0) + texsetdimen("global","framedminwidth",minwidth) + texsetdimen("global","framedmaxwidth",maxwidth) + texsetdimen("global","framedaveragewidth",averagewidth) +end + +local function doanalyzeframedbox(n) -- traverse_list + local box = getbox(n) + local noflines = 0 + local firstheight = nil + local lastdepth = nil + if getwidth(box) ~= 0 then + local list = getlist(box) + if list then + for n in nexthlist, list do + local width, height, depth = getwhd(n) + if not firstheight then + firstheight = height + end + lastdepth = depth + noflines = noflines + 1 + end + for n in nextvlist, list do + local width, height, depth = getwhd(n) + if not firstheight then + firstheight = height + end + lastdepth = depth + noflines = noflines + 1 + end + end + end + texsetcount("global","framednoflines",noflines) + texsetdimen("global","framedfirstheight",firstheight or 0) + texsetdimen("global","framedlastdepth",lastdepth or 0) +end + +implement { name = "doreshapeframedbox", actions = doreshapeframedbox, arguments = "integer" } +implement { name = "doanalyzeframedbox", actions = doanalyzeframedbox, arguments = "integer" } + +local function maxboxwidth(box) + local boxwidth = getwidth(box) + if boxwidth == 0 then + return 0 + end + local list = getlist(box) + if not list then + return 0 + end + if getid(box) == hlist_code then + return boxwidth + end + local lastlinelength = 0 + local maxwidth = 0 + for n, subtype in nexthlist, list do -- no dir etc needed + local l = getlist(n) + if l then + if subtype == boxlist_code or subtype == linelist_code then + lastlinelength = getdimensions(l) + else + lastlinelength = getwidth(n) + end + if lastlinelength > maxwidth then + maxwidth = lastlinelength + end + end + end + for n, subtype in nextvlist, list do -- no dir etc needed + local l = getlist(n) + if l then + lastlinelength = getwidth(n) + if lastlinelength > maxwidth then + maxwidth = lastlinelength + end + end + end + return maxwidth +end + +nodes.maxboxwidth = maxboxwidth + +implement { + name = "themaxboxwidth", + actions = function(n) context("%rsp",maxboxwidth(getbox(n))) end, -- r = rounded + arguments = "integer" +} diff --git a/tex/context/base/mkiv/pack-rul.mkxl b/tex/context/base/mkxl/pack-rul.mkxl index c9383dff0..28fed1c51 100644 --- a/tex/context/base/mkiv/pack-rul.mkxl +++ b/tex/context/base/mkxl/pack-rul.mkxl @@ -18,7 +18,7 @@ %D packaging and expansion we also keep tracing reasonable. For instance, multiple %D stacked backgrounds can slow down a run if not optimized this way. -\registerctxluafile{pack-rul}{optimize} +\registerctxluafile{pack-rul}{autosuffix,optimize} \unprotect @@ -65,7 +65,7 @@ %D A helper: -\def\frameddimension#1{\the\dimexpr\framedparameter{#1}\relax} +\permanent\def\frameddimension#1{\the\dimexpr\framedparameter{#1}\relax} %D Inheritance: @@ -404,16 +404,6 @@ %D %D The resulting box is lowered to the right depth. -%def\overlaywidth {\the\hsize\space} % We preset the variables -%def\overlayheight {\the\vsize\space} % to some reasonable default -%def\overlaydepth {0pt } % values. The attributes -%let\overlayoffset \overlaydepth % of the frame can be (are) -%let\overlaylinewidth \overlaydepth % set somewhere else. -\let\overlaycolor \empty -\let\overlaylinecolor \empty - -\permanent\def\overlayradius{\framedparameter\c!frameradius} - \newdimen\d_overlay_width \newdimen\d_overlay_height \newdimen\d_overlay_depth @@ -424,14 +414,18 @@ % expandable ... in a future version the space will go (in mp one can use Overlay*) -\permanent\def\overlaywidth {\the\d_overlay_width \space} % We preset the variables -\permanent\def\overlayheight {\the\d_overlay_height \space} % to some reasonable default -\permanent\def\overlaydepth {\the\d_overlay_depth \space} % values. -\permanent\def\overlayoffset {\the\d_overlay_offset \space} % of the frame can be (are) -\permanent\def\overlaylinewidth {\the\d_overlay_linewidth\space} % set somewhere else. -\permanent\def\overlayregion {\m_overlay_region} +\mutable \def\overlaywidth {\the\d_overlay_width \space} % We preset the variables +\mutable \def\overlayheight {\the\d_overlay_height \space} % to some reasonable default +\mutable \def\overlaydepth {\the\d_overlay_depth \space} % values. +\mutable \def\overlayoffset {\the\d_overlay_offset \space} % of the frame can be (are) +\mutable \def\overlaylinewidth {\the\d_overlay_linewidth\space} % set somewhere else. +\mutable \def\overlayregion {\m_overlay_region} -% public but kind of protected +\mutable \def\overlayradius {\framedparameter\c!frameradius} +\mutable \def\overlaycolor {\framedparameter\c!backgroundcolor} +\mutable \def\overlaylinecolor {\framedparameter\c!framecolor} +%mutable \edef\overlaycorner {\framedparameter\c!backgroundcorner} +%mutable \edef\overlayradius {\framedparameter\c!backgroundradius} \permanent\def\usedoverlaywidth {\dimexpr\d_overlay_width \relax} \permanent\def\usedoverlayheight {\dimexpr\d_overlay_height \relax} @@ -493,7 +487,7 @@ \expandafter\secondoftwoarguments \fi} -\let\doifoverlayelse\doifelseoverlay +\aliased\let\doifoverlayelse\doifelseoverlay %D The content of the box will be (temporary) saved in a box. We also have an %D extra box for backgrounds. @@ -587,10 +581,10 @@ \d_overlay_depth \d_framed_target_dp \d_overlay_linewidth \d_framed_linewidth \d_overlay_offset \framedbackgroundoffset\relax - \edef\overlaycolor {\framedparameter\c!backgroundcolor}% let ? + % We expand these once: + \edef\overlaycolor {\framedparameter\c!backgroundcolor}% \edef\overlaylinecolor{\framedparameter\c!framecolor}% only needed for layers - %\edef\overlaycorner {\framedparameter\c!backgroundcorner}% - %\edef\overlayradius {\framedparameter\c!backgroundradius}% + % \let\pack_framed_overlay_initialize\relax} %D One can explictly insert the foreground box. For that purpose we introduce the @@ -823,7 +817,7 @@ {\removeunwantedspaces \egroup} -\protected\def\normalframedwithsettings[#1]% +\permanent\protected\def\normalframedwithsettings[#1]% {\bgroup \advance\c_pack_framed_nesting\plusone \letcsname\??framed>\the\c_pack_framed_nesting:\s!parent\endcsname\??framed @@ -1892,9 +1886,7 @@ \xypos\pack_framed_mc_two} \def\pack_framed_mathframed_indeed[#1]#2% no fancy nesting supported here - {\iffirstargument - \setupcurrentmathframed[#1]% - \fi + {\setupcurrentmathframed[#1]% \c_framed_mstyle\normalmathstyle \edef\m_framed_location{\mathframedparameter\c!location}% \ifx\m_framed_location\v!mathematics @@ -2633,7 +2625,7 @@ \appendtoks \frozen\instance\setuevalue{\e!start\currentframedtext}{\pack_framed_text_start {\currentframedtext}}% \frozen\instance\setuevalue{\e!stop \currentframedtext}{\pack_framed_text_stop }% - \frozen\instance\setuevalue {\currentframedtext}{\pack_framed_text_direct{\currentframedtext}}% + \frozen\instance\setuevalue {\currentframedtext}{\pack_framed_text_direct[\currentframedtext]}% \to \everydefineframedtext \setvalue{\??framedtextlocation\v!left }{\letframedtextparameter\c!left \relax @@ -2783,16 +2775,11 @@ %D The simple brace (or group) delimited case is typeset slightly different %D and is not aligned. -\protected\def\pack_framed_text_direct#1% +\tolerant\protected\def\pack_framed_text_direct[#1]#*[#2]% {\bgroup \edef\currentframedtext{#1}% - \dosingleempty\pack_framed_text_start_direct} - -\def\pack_framed_text_start_direct[#1]% - {\usebodyfontparameter\framedtextparameter - \iffirstargument - \setupcurrentframedtext[#1]% - \fi + \usebodyfontparameter\framedtextparameter + \setupcurrentframedtext[#1]% \edef\p_framed_text_strut{\framedtextparameter\c!strut}% \letframedtextparameter\c!strut\v!no \inheritedframedtextframed\bgroup @@ -3002,7 +2989,7 @@ %D Fast enough for most cases (we could do a massive \type {\ifhastok} instead): -\protected\def\doifelseframed#1% +\permanent\protected\def\doifelseframed#1% {\iftok{#1\c!frame }{\v!on}\expandafter\firstoftwoarguments \orelse\iftok{#1\c!topframe }{\v!on}\expandafter\firstoftwoarguments \orelse\iftok{#1\c!bottomframe}{\v!on}\expandafter\firstoftwoarguments diff --git a/tex/context/base/mkxl/page-app.mkxl b/tex/context/base/mkxl/page-app.mkxl new file mode 100644 index 000000000..77a3bf2d6 --- /dev/null +++ b/tex/context/base/mkxl/page-app.mkxl @@ -0,0 +1,205 @@ +%D \module +%D [ file=page-app, % from meta-fig +%D version=1998.01.15, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Independent page building, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Applications} + +%D This needs an update with a proper define and inheritance. + +\unprotect + +\installcorenamespace{fittingpage} + +\installframedcommandhandler \??fittingpage {fittingpage} \??fittingpage + +\newdimen\d_page_fitting_width +\newdimen\d_page_fitting_height +\newbox \b_page_fitting + +\definepapersize + [fittingpage] + [\c!width=\d_page_fitting_width, + \c!height=\d_page_fitting_height] + +\definemakeup + [fittingpage] + [\c!textstate=\v!empty, + \c!doublesided=\v!no, + \c!location=\v!top, % no topskip + \c!pagestate=\fittingpageparameter\c!pagestate]% + +\definelayout + [fittingpage] + [\v!page] + [\c!width=\d_page_fitting_width, + \c!height=\d_page_fitting_height, + \c!location=\v!middle] + +\appendtoks + \frozen\instance\setuevalue{\e!start\currentfittingpage}{\startfittingpage[\currentfittingpage]}% + \frozen\instance\setuevalue{\e!stop \currentfittingpage}{\stopfittingpage}% +\to \everydefinefittingpage + +\permanent\tolerant\protected\def\startfittingpage[#1]#*[#2]% + {\page % this is kind of tricky! there can be preceding page refs + \autostarttext + \bgroup % resulting in a zero height page; test fig-make ! + \setupinterlinespace[\v!top=0]% no topskip + \def\currentfittingpage{#1}% + \dontcomplain + % runs under current page regime, i.e. page variables passed to mp + \setupcurrentfittingpage[\c!paper=,#2]% auto or size or nothing + \doifelsenothing{\fittingpageparameter\c!command} + \page_fitting_start_normal + \page_fitting_start_command} + +\def\page_fitting_start_command + {\grabuntil{\e!stop\currentfittingpage}\page_fitting_stop_command} + +\def\page_fitting_stop_command#1% + {\page_fitting_start_normal + \fittingpageparameter\c!command{#1}% + \page_fitting_stop_normal} + +\def\page_fitting_start_normal + {\setbox\b_page_fitting\hbox + \bgroup + \inheritedfittingpageframed + \bgroup + \gobblespacetokens} + +\protected\def\page_fitting_stop_normal % todo: figure out why a small mp image gets shifted + {\removeunwantedspaces + \egroup + \egroup + % finalize + \doif{\fittingpageparameter\c!margin}\v!page + {\setbox\b_page_fitting\hpack\bgroup + \offsetbox + [\c!leftoffset=\backspace, + \c!rightoffset=\cutspace, + \c!topoffset=\topspace, + \c!bottomoffset=\bottomspace] + {\box\b_page_fitting}% + \egroup}% + \doifsomething{\fittingpageparameter\c!scale} + {\setbox\b_page_fitting\hpack\bgroup + \scale[\c!scale=\fittingpageparameter\c!scale]{\box\b_page_fitting}% + \egroup}% + \ifdim\ht\b_page_fitting=\zeropoint + \ht\b_page_fitting\onepoint + \fi + \ifdim\wd\b_page_fitting=\zeropoint + \wd\b_page_fitting\onepoint + \fi + \d_page_fitting_width \wd\b_page_fitting + \d_page_fitting_height\ht\b_page_fitting + \startlocallayout % hm, we change the papersize so we still need it + \enforced\let\checkcurrentlayout\relax % else interference with odd/even layout + \processaction + [\fittingpageparameter\c!paper] + [ \v!auto=>\def\fittingpapersize{\printpapersize}, + \s!unknown=>\let\fittingpapersize\commalistelement, + \s!default=>\def\fittingpapersize{fittingpage}]% + \normalexpanded{\setuppapersize[fittingpage][\fittingpapersize]}% + \startmakeup[fittingpage]% + \box\b_page_fitting + \stopmakeup + \stoplocallayout % we need to get rid of this and use the built-in + \egroup + \autostoptext} + +\permanent\let\stopfittingpage\page_fitting_stop_normal + +\setupfittingpage + [%\c!scale=1000, + %\c!pagestate=, + \c!strut=\v!no, + \c!align=\v!normal, + \c!offset=\v!overlay, + \c!width=\v!fit, + \c!height=\v!fit, + \c!frame=\v!off] + +%D \TEX\ pages (for \METAPOST\ pages, see \type {meta-fig}): + +%D \starttyping +%D \startTEXpage[align=normal,width=900pt,autowidth=force] +%D \framed[width=800pt,frame=off]{\number\dimexpr800pt}\par +%D \input tufte\par +%D \stopTEXpage +%D \stoptyping +%D +%D Beware: the width is the textwidth! + +\definefittingpage + [TEXpage] + [\c!align=\v!normal] % needed, else problems ! + +\permanent\protected\def\setupTEXpage + {\setupfittingpage[TEXpage]} + +%D For Mojca: +%D +%D \starttyping +%D \startTEXstream \chapter{Bla} Hello world!\crlf Hello world! \stopTEXstream +%D \startTEXpage \chapter{Bla} Hello world!\crlf Hello world! \stopTEXpage +%D \stoptyping +%D +%D maybe I should support stream=yes in framed. + +\permanent\tolerant\protected\def\startTEXstream[#1]% old code, to be redone + {\page + \enableoutputstream[tex]} + +\permanent\protected\def\stopTEXstream + {\disableoutputstream + \startTEXpage % [\c!align=\v!normal] + \outputstreamunvbox[tex]% + \stopTEXpage} + +%D Application pages, a quick \MKIV\ hack: + +\definetypesetting[TEXapplication] +\definebuffer[TEXapplication] + +% we could use a counter and saves runs on numbering them. + +\permanent\def\TEXapplicationfilename{\jobname-texapplication.tex} + +\permanent\protected\def\stopTEXapplication + {\savebuffer[\thedefinedbuffer{TEXapplication}][\TEXapplicationfilename]% + \typesetfile[TEXapplication][\TEXapplicationfilename]\relax} + +%D \macros +%D {startpagefigure} +%D +%D \starttyping +%D \starttext \pagefigure[two.1] \stoptext +%D \stoptyping + +\defineexternalfigure[\v!page:\v!figure][\c!offset=\v!overlay] % we force a parent + +\permanent\tolerant\protected\def\startpagefigure[#1]#*[#2]% + {\bgroup + \setupexternalfigure[\v!page:\v!figure][\c!offset=\v!overlay,#2]% + \startTEXpage[\c!offset=\namedexternalfigureparameter{\v!page:\v!figure}\c!offset,\c!align=\v!normal]% + \externalfigure[#1]\ignorespaces} % so we can put some text below the graphic + +\permanent\protected\def\stoppagefigure + {\stopTEXpage + \egroup} + +\permanent\tolerant\protected\def\pagefigure[#1]#*[#2]% + {\page_figures_start[#1][#2]\stoppagefigure} + +\protect \endinput diff --git a/tex/context/base/mkiv/page-bck.mkxl b/tex/context/base/mkxl/page-bck.mkxl index 94e4f4a95..71036e3e4 100644 --- a/tex/context/base/mkiv/page-bck.mkxl +++ b/tex/context/base/mkxl/page-bck.mkxl @@ -475,18 +475,6 @@ \newtoks\everybackgroundssetup -% \permanent\protected\def\setupbackgrounds -% {\dotripleempty\page_backgrounds_setup} -% -% \def\page_backgrounds_setup -% {\ifthirdargument -% \expandafter\page_backgrounds_setup_double -% \orelse\ifsecondargument -% \expandafter\page_backgrounds_setup_single -% \orelse\iffirstargument -% \expandafter\page_backgrounds_setup_basics -% \fi} - \permanent\tolerant\protected\def\setupbackgrounds[#1]#*[#2]#*[#3]% {\ifarguments \expandafter\gobblethreeoptionals diff --git a/tex/context/base/mkxl/page-box.mklx b/tex/context/base/mkxl/page-box.mklx new file mode 100644 index 000000000..9b6868b04 --- /dev/null +++ b/tex/context/base/mkxl/page-box.mklx @@ -0,0 +1,289 @@ +%D \module +%D [ file=page-box, +%D version=2011.12.05, % moved from other page-* files +%D title=\CONTEXT\ Page Macros, +%D subtitle=Page Boxing, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Boxing} + +\unprotect + +%D The often two step approach (_indeed) saves skipping tokens which is nicer for +%D tracing. Centering the paper area on the print area is determined by the \type +%D {top}, \type {bottom}, \type {left} and \type {right} parameters. + +\def\page_boxes_apply_center#box% we could test for a difference (saves packing) + {\printpaperwidth \v_page_target_scale\printpaperwidth \relax + \printpaperheight\v_page_target_scale\printpaperheight\relax + \ifdim\printpaperheight>\ht#box\relax + \page_boxes_apply_center_indeed#box% + \orelse\ifdim\printpaperwidth>\wd#box\relax + \page_boxes_apply_center_indeed#box% + \fi} + +\def\page_boxes_apply_center_indeed_l_r#box% + {\v_page_target_left + \v_page_target_left_fill + \box#box% + \v_page_target_right_fill + \v_page_target_right} + +\def\page_boxes_apply_center_indeed_r_l#box% + {\v_page_target_right + \v_page_target_right_fill + \box#box% + \v_page_target_left_fill + \v_page_target_left} + +\def\page_boxes_apply_center_indeed#box% we could test for a difference (saves packing) + {\setbox#box\vpack to \printpaperheight + {\v_page_target_top + \v_page_target_top_fill + \hpack to \printpaperwidth + {\ifconditional\c_page_target_print_doublesided + \doifbothsides + {\page_boxes_apply_center_indeed_l_r#box}% + {\page_boxes_apply_center_indeed_l_r#box}% + {\page_boxes_apply_center_indeed_r_l#box}% + \else + \page_boxes_apply_center_indeed_l_r#box% + \fi}% + \par + \v_page_target_bottom_fill + \v_page_target_bottom}} + +\def\page_boxes_apply_offset % #box + {\unless\ifzeropt\topoffset + \expandafter\page_boxes_apply_offset_indeed + \orelse\ifzeropt\backoffset + \expandafter\gobbleoneargument + \else + \expandafter\page_boxes_apply_offset_indeed + \fi} + +\def\page_boxes_apply_offset_indeed#box% + {\scratchwidth \wd#box% + \scratchheight\ht#box% + \scratchdepth \dp#box% + \setbox#box\vpack + {\offinterlineskip + \vskip\topoffset + \hskip\doifbothsides\backoffset\backoffset{-\backoffset}% + \box#box}% + \wd#box\scratchwidth + \ht#box\scratchheight + \dp#box\scratchdepth} + +\def\page_boxes_apply_replicate + {\ifnum\layoutparameter\c!nx>\plusone + \expandafter\page_boxes_apply_replicate_indeed + \orelse\ifnum\layoutparameter\c!ny>\plusone + \expandafter\page_boxes_apply_replicate_indeed + \else + \expandafter\gobbleoneargument + \fi} + +\def\page_boxes_apply_replicate_indeed#box% + {\setbox#box\vpack + {\offinterlineskip + \dorecurse{\layoutparameter\c!ny} + {\hpack{\dorecurse{\layoutparameter\c!nx}{\copy#box\kern\layoutparameter\c!dx}\unskip}% + \vskip\layoutparameter\c!dy} + \unskip}} + +\def\page_boxes_apply_orientate_paper#box% + {\ifnum\number\c_page_target_paper_orientation\number\c_page_target_paper_reverse>\zerocount + \page_boxes_apply_orientate_indeed\c_page_target_paper_orientation\c_page_target_paper_reverse{#box}% + \fi} + +\def\page_boxes_apply_orientate_print#box% + {\ifnum\number\c_page_target_print_orientation\number\c_page_target_print_reverse>\zerocount + \page_boxes_apply_orientate_indeed\c_page_target_print_orientation\c_page_target_print_reverse{#box}% + \fi} + +\def\page_boxes_apply_orientate_indeed#odd#even#box% + {\setbox#box\vpack + {\edef\somerotation{\number\ifdoublesided\ifodd\realpageno#odd\else#even\fi\else#odd\fi}% + \dorotatebox\somerotation\hpack{\box#box}}} + +\def\page_boxes_apply_mirror#box% + {\setbox#box\vpack{\mirror{\box#box}}} + +\def\page_boxes_apply_mirror_paper#box{\ifconditional\c_page_target_paper_mirror\page_boxes_apply_mirror{#box}\fi} +\def\page_boxes_apply_mirror_print#box{\ifconditional\c_page_target_print_mirror\page_boxes_apply_mirror{#box}\fi} + +\aliased\let\page_boxes_apply_negate\negatecolorbox + +\def\page_boxes_apply_negate_print#box% + {\ifconditional\c_page_target_print_negate + \page_boxes_apply_negate#box% + \orelse\ifconditional\c_page_target_paper_negate + \page_boxes_apply_negate#box% + \fi} + +\let\p_page_layouts_scale\relax +\let\p_page_layouts_sx \relax +\let\p_page_layouts_sy \relax + +\def\page_boxes_apply_scale#box% + {\edef\p_page_layouts_scale{\layoutparameter\c!scale}% + \ifdim\p_page_layouts_scale\points=\onepoint + \edef\p_page_layouts_sx{\layoutparameter\c!sx}% + \edef\p_page_layouts_sy{\layoutparameter\c!sy}% + \ifdim\p_page_layouts_sx\points=\onepoint + \ifdim\layoutparameter\c!sy\points=\onepoint + % no scaling done (and no copying either) + \else + \page_boxes_apply_scale_indeed\p_page_layouts_sx\p_page_layouts_sy{#box}% + \fi + \else + \page_boxes_apply_scale_indeed\p_page_layouts_sx\p_page_layouts_sy{#box}% + \fi + \else + \page_boxes_apply_scale_indeed\p_page_layouts_scale\p_page_layouts_scale{#box}% + \fi} + +\def\page_boxes_apply_scale_indeed#sx#sy#box% + {\setbox#box\vpack{\scale[\c!sx=#sx,\c!sy=#sy]{\box#box}}% can be a fast one + \paperwidth #sx\paperwidth + \paperheight#sy\paperheight} + +% \setuppagenumbering[alternative=doublesided] +% \setupcolors[state=start] +% \setuppapersize[A4][A4,oversized] +% \setuplayout[location=middle,clipoffset=5mm] +% \setupbackgrounds +% [page] +% [frame=on,rulethickness=1mm, +% backgroundoffset=10mm,background=color,backgroundcolor=red] +% \starttext \dorecurse{10}{\input tufte \par} \stoptext + +% best use private variables + +\newconditional\c_page_boxes_clip_print \settrue\c_page_boxes_clip_print + +\def\page_boxes_apply_clip_print_left % box + {\ifconditional\c_page_boxes_clip_print + \expandafter\page_boxes_apply_clip_print_indeed\expandafter\conditionalfalse + \else + \expandafter\gobbleoneargument + \fi} + +\def\page_boxes_apply_clip_print_right % box + {\ifconditional\c_page_boxes_clip_print + \expandafter\page_boxes_apply_clip_print_indeed\expandafter\conditionaltrue + \else + \expandafter\gobbleoneargument + \fi} + +\def\page_boxes_apply_clip_print_indeed#right#box% can be made more efficient, see other clipper + {\scratchoffset\pagebackgroundoffset % can be zero which is valid % maybe another variable + \scratchwidth \wd#box% + \scratchheight\ht#box% + \scratchdepth \dp#box% + \setbox#box\hpack + {\advance\scratchheight\dimexpr\scratchdepth+2\scratchoffset\relax + \advance\scratchwidth \scratchoffset + \ifconditional#right\relax + \scratchdimen-\scratchoffset + \kern\scratchdimen + \else + \scratchdimen\zeropoint + \fi + \lower\scratchoffset\hpack + {\clip + [\c!hoffset=\scratchdimen, + \c!voffset=-\scratchoffset, + \c!width=\scratchwidth, + \c!height=\scratchheight]% + {\box#box}}}% + \wd#box\scratchwidth + \ht#box\scratchheight + \dp#box\scratchdepth} + +\def\page_boxes_apply_clip_paper + {\scratchoffset\layoutparameter\c!clipoffset\relax + \ifdim\scratchoffset>\zeropoint + \expandafter\page_boxes_apply_clip_paper_indeed + \else + \expandafter\gobbleoneargument + \fi} + +\def\page_boxes_apply_clip_paper_indeed#box% + {\scratchwidth \wd#box% + \scratchheight\ht#box% + \scratchdepth \dp#box% + \setbox#box\hpack + {\advance\scratchheight\dimexpr\scratchdepth+2\scratchoffset\relax + \advance\scratchwidth \scratchoffset + \doifbothsides + {\advance\scratchwidth\scratchoffset + \scratchdimen-\scratchoffset + \kern\scratchdimen}% + {\scratchdimen\zeropoint} + {\scratchdimen-\scratchoffset + \kern\scratchdimen}% + \lower\scratchoffset\hpack + {\clip + [\c!hoffset=\scratchdimen, + \c!voffset=-\scratchoffset, + \c!width=\scratchwidth, + \c!height=\scratchheight]% + {\box#box}}}% + \wd#box\scratchwidth + \ht#box\scratchheight + \dp#box\scratchdepth} + +% nearly always some displacement so no speedup test needed + +\def\page_boxes_apply_offsets#1% + {\setbox#1\vpack to \paperheight + {\hsize\paperwidth + \vkern\topspace + \hkern\doifbothsides\backspace\backspace{\dimexpr\paperwidth-\backspace-\makeupwidth\relax}% + \box#1}% + \dp#1\zeropoint} + +%D This is rather specialized: + +\newconditional\c_page_areas_enabled +\newbox \b_page_areas_registered + +\def\enabletextarearegistration + {\global\settrue\c_page_areas_enabled} + +\def\page_areas_registered_box + {\ifconditional\c_page_areas_enabled + \expandafter\page_areas_registered_box_indeed + \else + \expandafter\page_areas_registered_box_forget + \fi} + +\def\page_areas_registered_box_forget#1#2#3% #1=lower-dp #2=correct-ht #3=box + {\box#3} + +\def\page_areas_registered_box_indeed#1#2#3% #1=lower-dp #2=correct-ht #3=box + {\anch_mark_flow_box{#3}} + +\def\page_areas_register_boxed#1% + {\begingroup + \setbox\scratchbox\vpack{#1}% + \wd\scratchbox\makeupwidth % somehow a space creeps in + \vpack{\page_areas_registered_box00\scratchbox}% 0 0 will go + \endgroup} + +\def\page_areas_register_direct#1#2% + {\scratchdepth\dp#2% + \dp#2\strutdepth + \anch_mark_flow_only{#2}% + \dp#2\scratchdepth + #1#2} + +\protect \endinput diff --git a/tex/context/base/mkxl/page-brk.mkxl b/tex/context/base/mkxl/page-brk.mkxl new file mode 100644 index 000000000..a8fe10d87 --- /dev/null +++ b/tex/context/base/mkxl/page-brk.mkxl @@ -0,0 +1,483 @@ +%D \module +%D [ file=page-brk, % moved from page-ini +%D version=2011.12.07, % 2000.10.20, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Breaks, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Breaks} + +\unprotect + +\ifdefined\resetcurrentstructuremarkswithpage \else \let\resetcurrentstructuremarkswithpage\relax \fi +\ifdefined\noheaderandfooterlines \else \let\noheaderandfooterlines \relax \fi + +%D Page breaks. + +% \definepagebreak +% [chapter] +% [yes,header,right] +% +% \setuphead +% [chapter] +% [page=chapter, +% header=empty, +% footer=chapter] +% +% \definepagebreak % untested +% [lastpage] +% [left,{empty,right},{empty,left}] + +% public page handler, beware: definepage already in use (core-ref) +% +% \definepagebreak[instance][forsure] +% \definepagebreak[forsure][yes,+4] + +\newconditional\c_page_breaks_enabled \settrue\c_page_breaks_enabled +\newcount \c_page_breaks_prevpage + +\newtoks\everybeforepagebreak +\newtoks\everyafterpagebreak + +\let\page_breaks_current_option \empty +\let\page_breaks_current_options\empty + +\installcorenamespace{pagebreakmethod} +\installcorenamespace{pagebreaks} + +\def\page_breaks_handle#1% + {\edef\page_breaks_current_options{#1}% handy for tracing + \processcommacommand[\page_breaks_current_options]\page_breaks_handle_step} + +\def\page_breaks_handle_step#1% + {\edef\page_breaks_current_option{#1}% can be used in handler + \ifcsname\??pagebreakmethod\page_breaks_current_option\endcsname + \lastnamedcs + \orelse\ifcsname\??pagebreaks\page_breaks_current_option\endcsname + \expandafter\page_breaks_handle\lastnamedcs + \else + \page_breaks_unknown + \fi} + +\def\page_breaks_handle_direct#1% + {\begincsname\??pagebreakmethod#1\endcsname} + +\permanent\protected\def\installpagebreakmethod#1#2% low level definer + {\setvalue{\??pagebreakmethod#1}{#2}} + +\aliased\let\installpagebreakhandler\installpagebreakmethod % will go + +\permanent\tolerant\protected\def\definepagebreak[#1]#*[#2]% + {\setvalue{\??pagebreaks#1}{#2}} + +\appendtoks + \flushnotes +\to \everybeforepagebreak + +\permanent\tolerant\protected\def\pagebreak[#1] + {\par % else no vertical penalties, always before group so that we clear hangs etc (as in side floats) + \ifvmode % extra check + \begingroup + \the\everybeforepagebreak + \c_page_breaks_prevpage\realpageno + \ifcase\pageornamentstate \or + % disable reset after shipout + \global\pageornamentstate\plustwo + \fi + \ifparameter#1\or + \page_breaks_handle{#1}% + \else % so, no pagebreak when \pagebreak[] ! ! ! + \page_breaks_handle_direct\v!yes + \fi + \relax + \ifnum\c_page_breaks_prevpage<\realpageno + \global\pageornamentstate\zerocount + \fi + \the\everyafterpagebreak + \endgroup + \fi} + +\aliased\let\page\pagebreak + +\permanent\protected\def\usepageparameter#1% + {\edef\m_page_breaks_asked{#1\c!page}% + \ifx\m_page_breaks_asked\empty\else + \pagebreak[\m_page_breaks_asked]% + \fi} + +\permanent\protected\def\dousepageparameter#1% + {\edef\m_page_breaks_asked{#1}% + \ifx\m_spac_align_asked\empty\else + \pagebreak[\m_page_breaks_asked]% + \fi} + +\permanent\protected\def\resetpagebreak % used elsewhere too + {\global\settrue\c_page_breaks_enabled} + +\permanent\protected\def\simplifypagebreak % to be used grouped ! + {\enforced\permanent\protected\def\pagebreak[##1]{\goodbreak}} + +\protected\def\disablepagebreaks % to be used grouped ! + {\enforced\let\page_breaks_process\gobbleoneoptional} + +\installpagebreakmethod \s!dummy + {\page_otr_command_flush_all_floats + \page_otr_command_next_page + \page_otr_insert_dummy_page} + +\installpagebreakmethod \v!frame + {\page + \begingroup + \showframe + \page[\v!empty] + \endgroup} + +\protected\def\page_breaks_unknown % how often called ? + {\doifelseinstring{+}\page_breaks_current_option + {\page_otr_command_flush_all_floats + \page_otr_command_next_page + \dorecurse\page_breaks_current_option\page_otr_insert_dummy_page} + {\doifelsenumber\page_breaks_current_option + {\page_otr_command_flush_all_floats + \page_otr_command_next_page + \doloop + {\ifnum\userpageno<\page_breaks_current_option\relax + \page_otr_insert_dummy_page + \else + \exitloop + \fi}} + {}}} + +\installpagebreakmethod \s!unknown + {\page_breaks_unknown} + +\installpagebreakmethod \s!default + {} % do nothing if empty + +\installpagebreakmethod \v!reset + {% better not: \global\pageornamentstate\zerocount + \resetpagebreak} + +\installpagebreakmethod \v!disable + {\global\setfalse\c_page_breaks_enabled} + +\installpagebreakmethod \v!yes + {\ifconditional\c_page_breaks_enabled + \page_otr_command_flush_all_floats + \page_otr_command_next_page + \ifinsidecolumns % this will move to MUL + \page_otr_eject_page % otherwise sometimes no change + \fi + \fi} + +\installpagebreakmethod \v!makeup + {\ifconditional\c_page_breaks_enabled + \page_otr_fill_and_eject_page + \fi} + +\installpagebreakmethod \v!blank + {\ifcase\pageornamentstate + \global\pageornamentstate\plusone + \fi} + +% also needed: \page \doifoddpageelse\relax{\page[\v!blank,\v!right] + +\installpagebreakmethod \v!no + {\ifconditional\c_page_breaks_enabled + \dosomebreak\nobreak + \fi} + +\installpagebreakmethod \v!preference + {\ifconditional\c_page_breaks_enabled + \ifinsidecolumns % this will move to MUL + \dosomebreak\goodbreak + \else + \testpage[3][\zeropoint]% + \fi + \fi} + +\installpagebreakmethod \v!bigpreference + {\ifconditional\c_page_breaks_enabled + \ifinsidecolumns % this will move to MUL + \dosomebreak\goodbreak + \else + \testpage[5][\zeropoint]% + \fi + \fi} + +% \installpagebreakmethod \v!empty {} % defined in page-txt.mkiv +% \installpagebreakmethod \v!header{} % defined in page-txt.mkiv +% \installpagebreakmethod \v!footer{} % defined in page-txt.mkiv + +\def\page_reset_marks_and_insert_dummy + {\resetcurrentstructuremarkswithpage\page_otr_insert_dummy_page} + +\installpagebreakmethod \v!left + {\page_otr_command_flush_all_floats + \page_otr_command_next_page_and_inserts + \doifbothsidesoverruled\donothing\page_reset_marks_and_insert_dummy\donothing} + +\installpagebreakmethod \v!right + {\page_otr_command_flush_all_floats + \page_otr_command_next_page_and_inserts + \doifbothsidesoverruled\donothing\donothing\page_reset_marks_and_insert_dummy} + +\installpagebreakmethod \v!even + {\page + \doifelseoddpage\page_reset_marks_and_insert_dummy\donothing} + +\installpagebreakmethod \v!odd + {\page + \doifelseoddpage\donothing\page_reset_marks_and_insert_dummy} + +\installpagebreakmethod \v!quadruple % not yet ok inside columnsets + {\ifdoublesided + \ifcase\modulonumber\plusfour\realpageno\else + \page_breaks_handle_direct\v!yes + \doloop + {\ifcase\modulonumber\plusfour\realpageno\relax + \exitloop + \else + \page_breaks_handle_direct\v!empty + \fi}% + \fi + \fi} + +\installpagebreakmethod \v!last + {\page_otr_command_flush_all_floats + \page_otr_command_next_page_and_inserts + \relax + \doifbothsidesoverruled + \page_facings_flush % hm + \donothing + {\noheaderandfooterlines + \page_otr_insert_dummy_page}% + \filluparrangedpages} + +\installpagebreakmethod \v!lastpage % handy for backpage preceded by empty pages + {\page_breaks_handle_direct\v!yes + \ifdoublesided + \page_breaks_handle_direct\v!left + \page_breaks_handle_direct\v!empty + \page_breaks_handle_direct\v!empty + \fi} + +\installpagebreakmethod \v!start {\global\settrue \c_otr_shipout_enabled} +\installpagebreakmethod \v!stop {\global\setfalse\c_otr_shipout_enabled} + +\installpagebreakmethod{xy}% for Mojca + {\page_breaks_handle_direct\v!yes + \scratchcounterone \numexpr\rootlayouttargetparameter\c!nx*\rootlayouttargetparameter\c!ny\relax + \scratchcountertwo \luaexpr{math.mod(\the\realpageno-1,\the\scratchcounterone)}\relax + \scratchcounterthree\numexpr\scratchcounterone-\scratchcountertwo\relax + \dorecurse\scratchcounterthree{\page_breaks_handle_direct\v!empty}} + +% Column breaks. + +\installcorenamespace{columnbreakmethod} +\installcorenamespace{columnbreaks} + +\newtoks\everybeforecolumnbreak +\newtoks\everyaftercolumnbreak +\newtoks\everysynchronizecolumn + +\let\page_breaks_columns_current_option \empty +\let\page_breaks_columns_current_options\empty + +\def\page_breaks_columns_handle#1% + {\edef\page_breaks_columns_current_options{#1}% + \processcommacommand[#1]\page_breaks_columns_handle_step} + +\def\page_breaks_columns_handle_step#1% + {\edef\page_breaks_columns_current_option{#1}% + \ifcsname\??columnbreakmethod\currentoutputroutine:\page_breaks_columns_current_option\endcsname + \lastnamedcs + \orelse\ifcsname\??columnbreaks\page_breaks_columns_current_option\endcsname + %\expandafter\csname\page_breaks_columns_handle\??columnbreaks\page_breaks_columns_current_option\endcsname + \lastnamedcs + \orelse\ifcsname\??columnbreakmethod\currentoutputroutine:\s!unknown\endcsname + \lastnamedcs + \fi} + +\def\page_breaks_columns_handle_direct#1% + {\begincsname\??columnbreakmethod\currentoutputroutine:#1\endcsname} + +\protected\def\installcolumnbreakmethod#1#2#3% #1=otr-id #2=tag #3=action + {\setvalue{\??columnbreakmethod#1:#2}{#3}} + +\aliased\let\installcolumnbreakhandler\installcolumnbreakmethod % will go + +\permanent\tolerant\protected\def\definecolumnbreak[#1]#*[#2]% + {\setvalue{\??columnbreaks#1}{#2}} + +%D So, page ornaments are reset after a pagebreak command, unless set! + +\permanent\tolerant\protected\def\columnbreak[#1]% + {\par % else no vertical penalties + \begingroup + \the\everybeforecolumnbreak + \ifparameter#1\or + \page_breaks_columns_handle{#1}% + \else + \page_breaks_columns_handle_direct\v!yes + \fi + \relax + \the\everyaftercolumnbreak + \endgroup + % outside group e.g. setting hsize + \the\everysynchronizecolumn} + +\aliased\let\column\columnbreak + +\appendtoks + \page_otr_command_set_hsize +\to \everysynchronizecolumn + +%D Test page breaks. + +% \newdimen \d_page_tests_test +% \newconstant\c_page_tests_mode + +\newconstant\testpagemethod % old +\newconstant\testpagetrigger % old + +\installcorenamespace {pagechecker} +\installcorenamespace {pagecheckermethod} + +\installcommandhandler \??pagechecker {pagechecker} \??pagechecker + +\setuppagechecker + [\c!method=1, + \c!before=, + \c!after=, + \c!inbetween=, + \c!lines=\plusthree, + \c!offset=\zeropoint] + +\def\page_check_amount + {\dimexpr + \pagecheckerparameter\c!lines\lineheight + +\pagetotal + \ifdim\lastskip<\parskip+\parskip\fi + +\pagecheckerparameter\c!offset + \relax} + +\permanent\tolerant\protected\def\checkpage[#1]#*[#2]% + {\relax % needed before \if + \endgraf + \triggerpagebuilder + \relax + \ifconditional\c_page_breaks_enabled + \begingroup + \edef\currentpagechecker{#1}% + \setupcurrentpagechecker[#2]% + \csname\??pagecheckermethod\pagecheckerparameter\c!method\endcsname + \endgroup + \fi} + +\setvalue{\??pagecheckermethod 0}% + {\ifdim\pagegoal<\maxdimen \relax + \ifdim\pagetotal<\pagegoal \relax + \ifdim\page_check_amount>.99\pagegoal + \pagecheckerparameter\c!before + \penalty-\plustenthousand + \pagecheckerparameter\c!after + \else + \pagecheckerparameter\c!inbetween + \fi + \else + \pagecheckerparameter\c!inbetween + \fi + \else + \pagecheckerparameter\c!inbetween + \fi} + +\setvalue{\??pagecheckermethod 1}% + {\ifdim\pagegoal<\maxdimen \relax + \ifdim\pagetotal<\pagegoal \relax + \ifdim\dimexpr\page_check_amount-\pagegoal\relax>-\lineheight + \pagecheckerparameter\c!before + \penalty-\plustenthousand + \pagecheckerparameter\c!after + \else + \pagecheckerparameter\c!inbetween + \fi + \else + \pagecheckerparameter\c!inbetween + \fi + \else + \goodbreak + \pagecheckerparameter\c!inbetween + \fi} + +\setvalue{\??pagecheckermethod 2}% + {\ifdim\pagegoal<\maxdimen \relax + \ifdim\pagetotal<\pagegoal \relax + \getnoflines\pagegoal + \ifdim\dimexpr\page_check_amount-\noflines\lineheight\relax>-\lineheight + \pagecheckerparameter\c!before + \penalty-\plustenthousand + \pagecheckerparameter\c!after + \else + \pagecheckerparameter\c!inbetween + \fi + \else + \pagecheckerparameter\c!inbetween + \fi + \else + \pagecheckerparameter\c!inbetween + \fi} + +\setvalue{\??pagecheckermethod 3}% + {\ifdim\pagegoal<\maxdimen \relax + \ifdim\pagetotal<\pagegoal \relax + \ifdim\dimexpr\page_check_amount-10\scaledpoint\relax>\pagegoal + \pagecheckerparameter\c!before + \penalty-\plustenthousand + \pagecheckerparameter\c!after + \else + \pagecheckerparameter\c!inbetween + \fi + \orelse\ifdim\pagetotal>\pagegoal + \ifdim\dimexpr\pagetotal-\pageshrink\relax>\pagegoal + \goodbreak + \pagecheckerparameter\c!inbetween + \else + \pagecheckerparameter\c!before + \page + \pagecheckerparameter\c!after + \fi + \else + \pagecheckerparameter\c!inbetween + \fi + \else + \pagecheckerparameter\c!inbetween + \fi} + +\definepagechecker[\s!unknown:0] [\c!method=0,\c!before=,\c!after=,\c!inbetween=] +\definepagechecker[\s!unknown:1][\s!unknown:0][\c!method=1] +\definepagechecker[\s!unknown:2][\s!unknown:0][\c!method=2] +\definepagechecker[\s!unknown:3][\s!unknown:0][\c!method=3] + +\permanent\tolerant\protected\def\testpage [#1]#*[#2]{\normalexpanded{\checkpage[\s!unknown:1][\c!lines=#1,\c!offset=\ifparameter#2\or#2\else\zeropoint\fi]}} % +\permanent\tolerant\protected\def\testpageonly[#1]#*[#2]{\normalexpanded{\checkpage[\s!unknown:2][\c!lines=#1,\c!offset=\ifparameter#2\or#2\else\zeropoint\fi]}} % no penalties added to the mvl +\permanent\tolerant\protected\def\testpagesync[#1]#*[#2]{\normalexpanded{\checkpage[\s!unknown:3][\c!lines=#1,\c!offset=\ifparameter#2\or#2\else\zeropoint\fi]}} % force sync + +%D Test column breaks. + +\permanent\tolerant\protected\def\testcolumn[#1]#*[#2]% + {\ifdefined\page_otr_command_test_column + \ifparameter#2\or + \page_otr_command_test_column[#1][#2]% + \else + \page_otr_command_test_column[#1][\zeropoint]% + \fi + \fi} + +\protect \endinput diff --git a/tex/context/base/mkxl/page-col.mkxl b/tex/context/base/mkxl/page-col.mkxl new file mode 100644 index 000000000..5634589fa --- /dev/null +++ b/tex/context/base/mkxl/page-col.mkxl @@ -0,0 +1,163 @@ +%D \module +%D [ file=page-col, % moved from page-ini +%D version=2011.12.07, % 2000.10.20, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Column Helpers, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Column Helpers} + +%D Here we implement a couple of helpers for dealing with columns. For +%D the moment we keep the names. When the mul and set modules are redone +%D these can be adapted or disappear. + +%D DO WE STILL NEED THESE? + +\unprotect + +%D We reserve a counter for the number of columns as well as the current +%D column. Both are not to be changed by users! + +%newcount\nofcolumns \nofcolumns\plusone % already in core-ini.mkiv +\newcount\mofcolumns \mofcolumns\plusone + +\newconstant\columndirection % 0:lr 1:rl + +\setnewconstant\maxnofcolumns 50 +\setnewconstant\allocatednofcolumns 0 + +\newdimen\columnwidth +\newdimen\columndistance + +%D During initialization the temporary boxes are allocated. This enables us to +%D use as much columns as we want, without exhausting the pool of boxes too +%D fast. We could have packed them in one box, but we've got enough boxes. +%D +%D Two sets of boxes are declared, the txtboxes are used for the text, the +%D topboxes are for moved column floats. + +\installcorenamespace{columntext} +\installcorenamespace{columnfooter} +\installcorenamespace{columntop} +\installcorenamespace{columnbottom} + +\permanent\protected\def\initializecolumns#1% + {\ifnum#1>\maxnofcolumns + \showmessage\m!columns1\maxnofcolumns + \nofcolumns\maxnofcolumns + \else + \nofcolumns#1\relax + \fi + \ifnum\nofcolumns>\allocatednofcolumns + \page_columns_allocate + \fi} + +\def\page_columns_allocate + {\dorecurse\nofcolumns + {\ifnum\recurselevel>\allocatednofcolumns\relax + \ifcsname\??columntext\recurselevel\endcsname \else + \expandafter\newbox\csname\??columntext \recurselevel\endcsname % text + \expandafter\newbox\csname\??columnfooter\recurselevel\endcsname % footer + \expandafter\newbox\csname\??columntop \recurselevel\endcsname % top insert + \expandafter\newbox\csname\??columnbottom\recurselevel\endcsname % bottom insert + \fi + \fi}% + \global\allocatednofcolumns\nofcolumns} + +\mutable\def\currentcolumn{1} + +\immutable\def\firstcolumnbox {\columntextbox\plusone} +\immutable\def\currentcolumnbox{\columntextbox\mofcolumns} +\immutable\def\lastcolumnbox {\columntextbox\nofcolumns} + +\immutable\def\firsttopcolumnbox {\columntopbox \plusone} +\immutable\def\currenttopcolumnbox{\columntopbox \mofcolumns} +\immutable\def\lasttopcolumnbox {\columntopbox \nofcolumns} + +\permanent\def\columntextbox#1{\csname\??columntext \number#1\endcsname} +\permanent\def\columnfootbox#1{\csname\??columnfooter\number#1\endcsname} +\permanent\def\columntopbox #1{\csname\??columntop \number#1\endcsname} +\permanent\def\columnbotbox #1{\csname\??columnbottom\number#1\endcsname} + +\permanent\protected\def\columnsettextbox{\global\setbox\columntextbox} +\permanent\protected\def\columnsetfootbox{\global\setbox\columnfootbox} +\permanent\protected\def\columnsettopbox {\global\setbox\columntopbox} +\permanent\protected\def\columnsetbotbox {\global\setbox\columnbotbox} + +\permanent\protected\def\columngettextbox {\copy\columntextbox} +\permanent\protected\def\columngetfootbox {\copy\columnfootbox} +\permanent\protected\def\columngettopbox {\copy\columntopbox} +\permanent\protected\def\columngetbotbox {\copy\columnbotbox} + +\permanent\protected\def\columnerasetextboxes{\dorecurse\allocatednofcolumns{\columnsettextbox\recurselevel\emptybox}} +\permanent\protected\def\columnerasefootboxes{\dorecurse\allocatednofcolumns{\columnsetfootbox\recurselevel\emptybox}} +\permanent\protected\def\columnerasetopboxes {\dorecurse\allocatednofcolumns{\columnsettopbox \recurselevel\emptybox}} +\permanent\protected\def\columnerasebotboxes {\dorecurse\allocatednofcolumns{\columnsetbotbox \recurselevel\emptybox}} + +%D Without going in details we present two macro's which handle the columns. The +%D action which is transfered by the the first and only parameter can do something +%D with \type {\currentcolumnbox}. In case of the mid columns, \type +%D {\firstcolumnbox} and \type {\lastcolumnbox} are handled outside these macro's. + +\permanent\protected\def\dohandleallcolumnscs#1{\let\page_columns_action #1\page_columns_all_indeed} +\permanent\protected\def\dohandleallcolumns #1{\def\page_columns_action{#1}\page_columns_all_indeed} + +\permanent\protected\def\dohandlerevcolumnscs#1{\let\page_columns_action #1\page_columns_rev_indeed} +\permanent\protected\def\dohandlerevcolumns #1{\def\page_columns_action{#1}\page_columns_rev_indeed} + +\permanent\protected\def\dohandlemidcolumnscs#1{\let\page_columns_action #1\page_columns_mid_indeed} +\permanent\protected\def\dohandlemidcolumns #1{\def\page_columns_action{#1}\page_columns_mid_indeed} + +\protected\def\page_columns_all_indeed + {\mofcolumns\plusone + \edef\currentcolumn{\the\mofcolumns}% + \page_columns_action\relax + \ifnum\mofcolumns<\nofcolumns + \expandafter\page_columns_all_next + \fi} + +\protected\def\page_columns_all_next + {\advance\mofcolumns\plusone + \edef\currentcolumn{\the\mofcolumns}% + \page_columns_action\relax + \ifnum\mofcolumns<\nofcolumns + \expandafter\page_columns_all_next + \fi} + +\protected\def\page_columns_rev_indeed + {\mofcolumns\nofcolumns + \edef\currentcolumn{\the\mofcolumns}% + \page_columns_action\relax + \ifnum\mofcolumns>\plusone + \expandafter\page_columns_rev_prev + \fi} + +\protected\def\page_columns_rev_prev + {\advance\mofcolumns\minusone + \edef\currentcolumn{\the\mofcolumns}% + \page_columns_action\relax + \ifnum\mofcolumns>\plusone + \expandafter\page_columns_rev_prev + \fi} + +\protected\def\page_columns_mid_indeed + {\mofcolumns\plustwo + \ifnum\mofcolumns<\nofcolumns + \expandafter\page_columns_mid_next + \fi} + +\protected\def\page_columns_mid_next + {\edef\currentcolumn{\the\mofcolumns}% + \page_columns_action\relax + \advance\mofcolumns\plusone + \ifnum\mofcolumns<\nofcolumns + \expandafter\page_columns_mid_next + \fi} + +\protect \endinput diff --git a/tex/context/base/mkxl/page-com.mkxl b/tex/context/base/mkxl/page-com.mkxl new file mode 100644 index 000000000..a7d8aaba7 --- /dev/null +++ b/tex/context/base/mkxl/page-com.mkxl @@ -0,0 +1,180 @@ +%D \module +%D [ file=page-com, % moved from page-imp +%D version=1998.01.15, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Page Comments, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D This will become runtime loaded code. + +\writestatus{loading}{ConTeXt Page Macros / Page Comments} + +\unprotect + +%D \macros +%D {setuppagecomment,startpagecomment} +%D +%D This command is not yet documented. Usage: +%D +%D \starttyping +%D \setuppagecomment[state=start,location=right] +%D +%D \startpagecomment +%D \input knuth +%D \stoppagecomment +%D \stoptyping + +\installcorenamespace{pagecomment} +\installcorenamespace{pagecommentlocations} +\installcorenamespace{pagecommentstates} + +\newdimen\d_page_comments_offset +\newdimen\d_page_comments_page_width +\newdimen\d_page_comments_page_height +\newdimen\d_page_comments_width +\newdimen\d_page_comments_height +\newdimen\d_page_comments_distance + +\newconditional\c_page_comment_enabled + +\let\p_page_commands_location\v!none +\let\p_page_commands_state \v!stop + +\installsetuponlycommandhandler \??pagecomment {pagecomment} + +\appendtoks + \edef\p_page_commands_location{\directpagecommentparameter\c!location}% + \edef\p_page_commands_state {\directpagecommentparameter\c!state}% + \expandnamespacemacro\??pagecommentstates\p_page_commands_state\v!none +\to \everysetuppagecomment + +% \ifdefined\scrn_canvas_synchronize_simple + + \appendtoks + \ifx\p_page_commands_state\v!start + \scrn_canvas_synchronize_simple + \else + \scrn_canvas_synchronize_complex + \fi + \to \everyshipout + +% \fi + +\setvalue{\??pagecommentstates\v!start}% + {\d_page_comments_offset \directpagecommentparameter\c!offset \relax + \d_page_comments_distance\directpagecommentparameter\c!distance\relax + \d_page_comments_width \directpagecommentparameter\c!width \relax + \d_page_comments_height \directpagecommentparameter\c!height \relax + \expandnamespacemacro\??pagecommentlocations\p_page_commands_location\v!none + \definepapersize[\v!pagecomment][\c!height=\d_page_comments_page_height,\c!width=\d_page_comments_page_width]% + \setuppapersize[\papersize][\v!pagecomment]% + \setupbackgrounds[\v!paper][\c!background=\v!pagecomment]} % maybe append if already set + +\setvalue{\??pagecommentstates\v!stop}% + {\setupbackgrounds[\v!paper][\c!background=]} + +\setvalue{\??pagecommentstates\v!none}% + {} + +\setvalue{\??pagecommentlocations\v!bottom}% + {\setuplayout[\c!location=]% + \setuppapersize[\c!top=\vskip\d_page_comments_offset,\c!bottom=\vss,\c!left=\hskip\d_page_comments_offset,\c!right=]% + \d_page_comments_page_height\dimexpr\paperheight+2\d_page_comments_offset+\d_page_comments_distance+\d_page_comments_height\relax + \d_page_comments_page_width \dimexpr\paperwidth +2\d_page_comments_offset\relax + \defineoverlay[\v!pagecomment][\page_comments_top_bottom]} + +\setvalue{\??pagecommentlocations\v!top}% + {\setuplayout[\c!location=]% + \setuppapersize[\c!top=\vss,\c!bottom=\vskip\d_page_comments_offset,\c!left=\hskip\d_page_comments_offset,\c!right=]% + \d_page_comments_page_height\dimexpr\paperheight+2\d_page_comments_offset+\d_page_comments_distance+\d_page_comments_height\relax + \d_page_comments_page_width \dimexpr\paperwidth +2\d_page_comments_offset\relax + \defineoverlay[\v!pagecomment][\page_comments_top_bottom]} + +\setvalue{\??pagecommentlocations\v!left}% + {\setuplayout[\c!location=]% + \setuppapersize[\c!top=\vskip\d_page_comments_offset,\c!bottom=,\c!left=\hss,\c!right=\hskip\d_page_comments_offset]% + \d_page_comments_page_height\dimexpr\paperheight+2\d_page_comments_offset\relax + \d_page_comments_page_width \dimexpr\paperwidth +2\d_page_comments_offset+\d_page_comments_distance+\d_page_comments_width\relax + \defineoverlay[\v!pagecomment][\page_comments_left_right]} + +\setvalue{\??pagecommentlocations\v!right}% + {\setuplayout[\c!location=]% + \setuppapersize[\c!top=\vskip\d_page_comments_offset,\c!bottom=,\c!left=\hskip\d_page_comments_offset,\c!right =\hss]% + \d_page_comments_page_height\dimexpr\paperheight+2\d_page_comments_offset\relax + \d_page_comments_page_width \dimexpr\paperwidth +2\d_page_comments_offset+\d_page_comments_distance+\d_page_comments_width\relax + \defineoverlay[\v!pagecomment][\page_comments_left_right]} + +\setvalue{\??pagecommentlocations\v!none}% + {}% \setuppapersize[\c!bottom=,\c!top=,\c!left=,\c!right=]} + +\protected\def\page_comments_top_bottom + {\vpack to \printpaperheight + {%\forgetall + \hsize\printpaperwidth\relax + \ifx\p_page_commands_location\v!bottom + \vskip\dimexpr\paperheight+\d_page_comments_distance+\d_page_comments_offset\relax + \else + \vskip\d_page_comments_offset + \vss + \fi + \hskip\d_page_comments_offset + \vbox to \d_page_comments_height + {%\forgetall + \hsize\paperwidth + \ifconditional\c_page_comment_enabled + \getbuffer[\v!pagecomment]% + \global\setfalse\c_page_comment_enabled + \fi}% + \hfill + \ifx\p_page_commands_location\v!bottom + \vss + \vskip\d_page_comments_offset + \else + \vskip\dimexpr\paperheight+\d_page_comments_distance+\d_page_comments_offset\relax + \fi}} + +\protected\def\page_comments_left_right + {\hpack to \printpaperwidth + {\ifx\p_page_commands_location\v!right + \hskip\dimexpr\paperwidth+\d_page_comments_distance+\d_page_comments_offset\relax + \else + \hskip\d_page_comments_offset + \hss + \fi + \vbox to \printpaperheight + {%\forgetall + \vskip\d_page_comments_offset + \hsize\d_page_comments_width + \ifconditional\c_page_comment_enabled + \getbuffer[\v!pagecomment]% + \global\setfalse\c_page_comment_enabled + \fi + \vss}% + \ifx\p_page_commands_location\v!right + \hss + \hskip\d_page_comments_offset + \else + \hskip\dimexpr\paperwidth+\d_page_comments_distance+\d_page_comments_offset\relax + \fi}} + +\permanent\protected\setvalue{\e!start\v!pagecomment}% + {\global\settrue\c_page_comment_enabled + \grabbufferdatadirect\v!pagecomment{\e!start\v!pagecomment}{\e!stop\v!pagecomment}} + +\aliased\letcsname\e!stop\v!pagecomment\endcsname\relax + +\setuppagecomment + [\c!state=, % \v!stop would invoke background calculation + \c!location=\v!bottom, + \c!offset=.5cm, + \c!distance=.5cm, + \c!height=5cm, + \c!width=10cm] + +\protect \endinput diff --git a/tex/context/base/mkxl/page-cst.mkxl b/tex/context/base/mkxl/page-cst.mkxl new file mode 100644 index 000000000..a033d740b --- /dev/null +++ b/tex/context/base/mkxl/page-cst.mkxl @@ -0,0 +1,789 @@ +%D \module +%D [ file=page-cst, +%D version=2016.12.15, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Page Grids (aka Column Sets), +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +% todo : markings per column + +%D This module is work in progress and in due time it will replace +%D columnsets. + +\writestatus{loading}{ConTeXt Page Macros / Page Grids} + +\registerctxluafile{page-cst}{} + +\unprotect + +% maybe some protected def ([esc]) + +%D Columnsets are kind of special. They are mostly meant for special products with +%D magazine like properties. They are normally not mixed with single column layouts +%D and not all features of \CONTEXT\ might cooperate well with a mechanism like +%D this. We use the name page grid because (as with other reimplementations of +%D \MKII\ features in \MKIV, we need another namespace in order to migrate stepwise. +%D +%D This implementation is not neccessarily better than the previous one but it might +%D be easier to extend it. It should be a bit more efficient. +%D +%D When writing this code I occasionally needed a motivational musical time||out and +%D watching the latest Snarky Puppy DVD brought me the musically and visually videos +%D of Jacob Collier (Piano, voice, anything) on YouTube (and yes, music keeps amazing +%D me). It's definitely more fun to watch that than to write code like this. + +\definesystemconstant{pagegrid} + +\installcorenamespace{pagegrid} + +\installframedcommandhandler \??pagegrid {pagegrid} \??pagegrid + +\setuppagegrid + [\c!distance=1.5\bodyfontsize, + \c!n=\plustwo, + \c!nleft=\pagegridparameter\c!n, + \c!nright=\pagegridparameter\c!n, + %\c!align=, % inherit + %\c!separator=\v!none, + %\c!setups=, + \c!lines=\layoutparameter\c!lines, + \c!frame=\v!off, + \c!strut=\v!no, + \c!offset=\v!overlay, + \c!alternative=\v!local, + \c!width=\v!auto, + \c!page=, + \c!direction=\v!normal, % todo + \c!maxheight=\textheight, + \c!maxwidth=\makeupwidth] + +\appendtoks % could become an option + \frozen\instance\setuevalue{\e!start\currentpagegrid}{\startpagegrid[\currentpagegrid]}% + \frozen\instance\setuevalue{\e!stop \currentpagegrid}{\stoppagegrid}% + \clf_definecolumnset { + name {\currentpagegrid}% + }% +\to \everydefinepagegrid + +\newdimen\d_page_grd_column_width +\newdimen\d_page_grd_max_height +\newdimen\d_page_grd_max_width +\newdimen\d_page_grd_distance + +\newdimen\d_page_grd_reserved_height +\newdimen\d_page_grd_reserved_width +\newcount\c_page_grd_reserved_state + +\newdimen\d_page_grd_gap_height + +\newcount\c_page_grd_n_of_left +\newcount\c_page_grd_n_of_right +\newcount\c_page_grd_n_of_rows +\newcount\c_page_grd_first_column +\newcount\c_page_grd_last_column + +\newbox \b_page_grd_collected +\newbox \b_page_grd_column_rest +\newbox \b_page_grd_column + +%D All the parameters are mandate! + +\permanent\tolerant\protected\def\setuppagegridlines[#1]#*[#2]#*[#3]#*[#4]% id page col value + {\clf_setcolumnsetlines{name {#1} page #2 column #3 value #4}} + +\permanent\tolerant\protected\def\setuppagegridstart[#1]#*[#2]#*[#3]#*[#4]% id page col value + {\clf_setcolumnsetstart{name {#1} page #2 column #3 value #4}} + +\protected\def\page_grd_check + {\dorecurse{\numexpr\pagegridparameter\c!nleft+\pagegridparameter\c!nright} + {\page_grd_check_column{##1}}} + +\protected\def\page_grd_check_column#1% + {\chaintocurrentpagegrid{\currentpagegrid:#1}% + \edef\p_distance{\namedpagegridparameter{\currentpagegrid:#1}\c!distance}% + \edef\p_width {\namedpagegridparameter{\currentpagegrid:#1}\c!width}% + \clf_setcolumnsetproperties {% + name {\currentpagegrid} + column \numexpr#1\relax + \ifempty\p_distance\else + distance \p_distance + \fi + \ifempty\p_width\orelse\ifx\p_width\v!auto\else + width \p_width + \fi + }} + +\appendtoks + \dorecurse{\numexpr\pagegridparameter\c!nleft+\pagegridparameter\c!nright}% + {\chaintocurrentpagegrid{\currentpagegrid:#1}}% +\to \everydefinepagegrid + +\permanent\tolerant\protected\def\startpagegrid[#1]#*[#2]% + {\bgroup + \let\page_grd_start\page_grd_start_dummy + \ifarguments + \let\currentpagegrid\empty + \or + \ifhastok={#1}% + \let\currentpagegrid\empty + \setupcurrentpagegrid[#1]% + \else + \def\currentpagegrid{#1}% + \fi + \or + \edef\currentpagegrid{#1}% + \setupcurrentpagegrid[#2]% + \fi + \usepageparameter\pagegridparameter + \c_page_grd_n_of_left \pagegridparameter\c!nleft\relax + \c_page_grd_n_of_right\pagegridparameter\c!nright\relax + \c_page_grd_n_of_rows \pagegridparameter\c!lines\relax + \d_page_grd_max_width \pagegridparameter\c!maxwidth\relax + \d_page_grd_max_height\pagegridparameter\c!maxheight\relax + \d_page_grd_distance \pagegridparameter\c!distance\relax + % + \ifcase\c_page_grd_n_of_rows + \getrawnoflines{\dimexpr\d_page_grd_max_height-\strutheight+\topskip\relax}% + \c_page_grd_n_of_rows\noflines + \fi + \edef\p_width{\pagegridparameter\c!width}% + \insidecolumnstrue % will be different flag in addition + \clf_resetcolumnset { + name {\currentpagegrid} + nofrows \c_page_grd_n_of_rows + nofleft \c_page_grd_n_of_left + nofright \c_page_grd_n_of_right + lineheight \strutht + linedepth \strutdp + \ifx\p_width\v!auto + % sets \d_page_grd_column_width + \else + width \p_width + \fi + distance \d_page_grd_distance + maxwidth \d_page_grd_max_width + }% + % + \page_grd_check + % + \clf_flushcolumnsetareas{\currentpagegrid}\relax + \setupoutputroutine[\s!pagegrid]% + \page_grd_command_set_hsize + \page_grd_command_set_vsize + % + \columnwidth \d_page_grd_column_width + \columndistance\d_page_grd_distance + \nofcolumns \c_page_grd_n_of_left % not always ok + \textwidth \d_page_grd_column_width % kind of redundant but we had it so ... + % + }%\begingroup} + +\def\page_grd_start_dummy[#1][#2]% + {\let\page_grd_stop\egroup} + +\permanent\protected\def\stoppagegrid + {\page_grd_stop} + +\def\page_grd_stop + {\endgraf % needed, else wrong vsize in one par case + \vfill % otherwise weird \placenotes[endnotes] + \page_grd_command_set_vsize % needed + \penalty\c_page_otr_eject_penalty + \page_grd_command_flush_page + \page_otr_fill_and_eject_page + \page_grd_command_set_vsize % why here + \egroup + \page_otr_command_set_vsize + \page_otr_command_set_hsize} + +\permanent\protected\def\reservepagegrid[#1]% + {\begingroup + \letdummyparameter\c!c\plusone + \letdummyparameter\c!r\plusone + \letdummyparameter\c!nc\plusone + \letdummyparameter\c!nr\plusone + \getdummyparameters[#1]% + \clf_blockcolumnset { + name {\currentpagegrid} + c \dummyparameter\c!c + r \dummyparameter\c!r + nc \dummyparameter\c!nc + nr \dummyparameter\c!nr + }% + \endgroup} + +\permanent\tolerant\protected\def\setpagegrid[#1]% + {\begingroup + \letdummyparameter\c!c\zerocount + \letdummyparameter\c!r\zerocount + \letdummyparameter\c!method\v!here + \letdummyparameter\c!option\v!none + \getdummyparameters[#1]% + \dowithnextboxcs\page_grd_set_indeed\hbox} + +\def\page_grd_set_indeed + {\clf_checkcolumnset { + name {\currentpagegrid} + c \dummyparameter\c!c + r \dummyparameter\c!r + box \nextbox + method {\dummyparameter\c!method} + option {\dummyparameter\c!option} + }% + \ifcase\c_page_grd_reserved_state + \setbox\nextbox\vpack to \d_page_grd_reserved_height \bgroup + \vss + \hpack to \d_page_grd_reserved_width \bgroup + \box\nextbox + \hss + \egroup + \vss + \egroup + \wd\nextbox\d_page_grd_reserved_width + \clf_putincolumnset { + name {\currentpagegrid} + box \nextbox + }% + \fi + \endgroup} + + +\protected\def\page_grd_command_set_vsize + {\clf_setvsizecolumnset{\currentpagegrid}% + \ifdim\d_page_grd_gap_height<\lineheight + \page_grd_command_flush_page + \page_otr_fill_and_eject_page + \fi + \global\vsize\d_page_grd_gap_height + \pagegoal\vsize} + +\protected\def\page_grd_command_set_hsize + {\clf_sethsizecolumnset{\currentpagegrid}% + \hsize\d_page_grd_column_width + \textwidth\d_page_grd_column_width} + +\protected\def\page_grd_command_routine + {\ifvoid\normalpagebox \else + \clf_addtocolumnset{\currentpagegrid}\normalpagebox + \fi + \page_grd_command_set_vsize + \page_grd_command_flush_saved_floats + \page_grd_command_set_vsize + \ifdim\d_page_grd_gap_height<\lineheight + \page_grd_command_flush_page + \fi + \page_grd_command_set_vsize + \clf_flushcolumnsetrest {\currentpagegrid}\normalpagebox + \ifvoid\normalpagebox \else + \unvbox\normalpagebox + \fi} + +\installoutputroutine\synchronizepagegrid + {\ifvoid\normalpagebox\else + \clf_addtocolumnset{\currentpagegrid}\normalpagebox + \page_grd_command_set_vsize + \clf_flushcolumnsetrest{\currentpagegrid}\normalpagebox + \ifvoid\normalpagebox \else + \unvbox\normalpagebox + \fi + \fi} + +% todo line numbers and marks + +\protected\def\page_grd_command_flush_page_column#1% + {\privatescratchcounter#1\relax % or just currentcolumn as in page-col.mkiv + \clf_flushcolumnsetcolumn{\currentpagegrid}\privatescratchcounter + \anch_mark_column_box\b_page_grd_column\privatescratchcounter + \page_marks_synchronize_column\c_page_grd_first_column\c_page_grd_last_column\privatescratchcounter\b_page_grd_column + \ifnum\privatescratchcounter>\c_page_grd_n_of_left + \advance\privatescratchcounter-\c_page_grd_n_of_left + \page_lines_add_numbers_to_box\b_page_grd_column\privatescratchcounter\c_page_grd_n_of_right\plustwo + \else + \page_lines_add_numbers_to_box\b_page_grd_column\privatescratchcounter\c_page_grd_n_of_left\plustwo + \fi + \begingroup + \edef\currentpagegrid{\currentpagegrid:#1}% + \inheritedpagegridframedbox\box\b_page_grd_column + \endgroup} + +\protected\def\page_grd_command_flush_page + {\deactivatecolor % puzzling, try ungrouped color \red or so + \setbox\b_page_grd_collected\hpack\bgroup + \clf_preparecolumnsetflush{\currentpagegrid}% + \letpagegridparameter\c!region\currentpagegrid + \doifelse{\pagegridparameter\c!direction}\v!reverse + {\dostepwiserecurse\c_page_grd_last_column\c_page_grd_first_column\minusone + {\page_grd_command_flush_page_column{##1}% + \ifnum##1>\plusone + \kern\namedpagegridparameter{\currentpagegrid:##1}\c!distance\relax + \fi}}% + {\dostepwiserecurse\c_page_grd_first_column\c_page_grd_last_column\plusone + {\page_grd_command_flush_page_column{##1}% + \ifnum##1<\c_page_grd_last_column + \kern\namedpagegridparameter{\currentpagegrid:##1}\c!distance\relax + \fi}}% + \clf_finishcolumnsetflush{\currentpagegrid}% + \egroup + \page_otr_construct_and_shipout\box\b_page_grd_collected\zerocount % three arguments + \clf_flushcolumnsetareas{\currentpagegrid}\relax + \page_grd_command_flush_saved_floats} + +% slow but robust + +\protected\def\page_grd_command_next_progress + {\strut + \page_grd_command_flush_all_floats + \page_otr_eject_page + \ifcase\clf_columnsetnoto\else + \expandafter\page_grd_command_next_progress + \fi} + +\protected\def\page_grd_command_handle_column + {\ifcase\clf_columnsetgoto{\currentpagegrid}{\page_breaks_columns_current_option}\relax\else + \expandafter\page_grd_command_next_progress + \fi} + +\installcolumnbreakmethod\s!pagegrid\s!unknown {\page_grd_command_handle_column} +\installcolumnbreakmethod\s!pagegrid\v!yes {\page_grd_command_handle_column} + +\protected\def\page_grd_command_next_page + {\ifcase\clf_columnsetgoto{\currentpagegrid}{\v!page}\relax\else + \page_grd_command_flush_page + \fi} + +\protected\def\page_grd_command_next_page_and_inserts + {\page_grd_command_flush_all_floats + \page_grd_command_next_page} + +\let\page_grd_command_flush_all_floats\page_one_command_flush_all_floats +\let\page_grd_command_package_contents\page_one_command_package_contents + +\protected\def\page_grd_command_flush_saved_floats + {\ifconditional\c_page_floats_flushing \else + \ifconditional\c_page_floats_some_waiting + \page_grd_command_flush_saved_floats_indeed + \fi + \fi} + +\protected\def\page_grd_command_flush_saved_floats_indeed + {\page_floats_flush\s!text\plusone + \clf_checkcolumnset { + name {\currentpagegrid} + method {\floatmethod} + width \wd\floatbox + height \ht\floatbox + }% + \ifcase\c_page_grd_reserved_state + \page_grd_place_float_here_indeed + \page_grd_command_set_vsize % needed + \ifconditional\c_page_floats_some_waiting + \doubleexpandafter\page_grd_command_flush_saved_floats_indeed + \fi + \else + \page_floats_resave\s!text + \fi} + +% needs checking + +\protected\def\page_grd_command_flush_floats + {\wait\global\settrue\c_page_floats_flushing + \ifconditional\c_page_floats_some_waiting + \par + \page_grd_command_flush_floats_indeed + \fi + \global\savednoffloats\zerocount + \global\setfalse\c_page_floats_some_waiting + \global\setfalse\c_page_floats_flushing} + +\def\page_grd_command_flush_floats_indeed % much in common with OTRSET + {\ifconditional\c_page_floats_some_waiting + \ifconditional\c_page_floats_compress_flushed + \page_floats_collect\s!text\hsize\d_page_floats_compress_distance + \ifcase\nofcollectedfloats + \page_floats_get + % \or + % \page_floats_get + \else + \setfalse\c_page_floats_center_box % not needed as we do call directly + \global\setbox\floatbox\hbox to \hsize + {\hfil + \dorecurse\nofcollectedfloats + {\ifcase\columndirection % nog document wide + \page_floats_flush\s!text\plusone + \else + \page_floats_flush\s!text{\the\numexpr\nofcollectedfloats-\recurselevel+1\relax}% + \fi + \ifdim\wd\floatbox>\makeupwidth % \hsize + \hbox to \makeupwidth{\hss\box\floatbox\hss}% + \else + \box\floatbox + \fi + \ifnum\recurselevel<\nofcollectedfloats + \hfil + \fi}% + \hfil}% + \fi + \else + \page_floats_get + \fi + \doplacefloatbox + \expandafter\page_grd_command_flush_floats_indeed + \fi} + +% so far + +\protected\def\page_grd_command_check_if_float_fits + {\clf_checkcolumnset { + name {\currentpagegrid} + method {\floatmethod} + % c \zerocount + % r \zerocount + box \floatbox + }% + \ifcase\c_page_grd_reserved_state + \global\settrue\c_page_floats_room + \else + \global\setfalse\c_page_floats_room + \fi} + +\protected\def\page_grd_place_float_here_indeed + {\setbox\floatbox\vpack to \d_page_grd_reserved_height \bgroup + \vss + \hpack to \d_page_grd_reserved_width \bgroup + % \hss % no + \box\floatbox + \hss + \egroup + \vss + \egroup + \clf_putincolumnset { + name {\currentpagegrid} + box \floatbox + }} + +\def\page_grd_place_float_slot + {% safeguard + \ifempty\floatmethod + \let\floatmethod\v!here + \fi + % synchronize + \penalty\c_page_otr_eject_penalty + % push + \setbox\savedfloatbox\box\floatbox + \page_grd_command_flush_saved_floats + \setbox\floatbox\box\savedfloatbox + % pop + \ifconditional\c_page_floats_some_waiting + \page_floats_save\s!text + \nonoindentation + \else + \clf_checkcolumnset { + name {\currentpagegrid} + method {\floatmethod} + \ifempty\floatcolumn \else + c \floatcolumn + \fi + \ifempty\floatrow \else + r \floatrow + \fi + box \floatbox + }% + \ifcase\c_page_grd_reserved_state + \page_grd_place_float_here_indeed + \else + \page_floats_save\s!text + \nonoindentation + \fi + \fi} + +\def\page_grd_place_float_fixed % todo: fallback on here + {\ifempty\floatcolumn + \let\floatmethod\v!here + \orelse\ifempty\floatrow + \let\floatmethod\v!here + \else + \let\floatmethod\v!fixed + \fi + \page_grd_place_float_slot} + +\def\page_grd_place_float_force + {% synchronize + \penalty\c_page_otr_eject_penalty + \clf_checkcolumnset { + name {\currentpagegrid} + method {\floatmethod} + box \floatbox + }% + \ifcase\c_page_grd_reserved_state + \page_grd_place_float_here_indeed + \else + \page_floats_save\s!text + \nonoindentation + \fi} + +\def\page_grd_place_float_page {\page_grd_place_float_slot} % todo: fallback on here + +\def\page_grd_place_float_here {\let\floatmethod\v!here\page_grd_place_float_slot} +\def\page_grd_place_float_top {\page_grd_place_float_slot} +\def\page_grd_place_float_bottom{\page_grd_place_float_slot} + +\installfloatmethod \s!pagegrid \v!here \page_grd_place_float_here +\installfloatmethod \s!pagegrid \v!force \page_grd_place_float_force % todo +%installfloatmethod \s!pagegrid \v!left +%installfloatmethod \s!pagegrid \v!right +%installfloatmethod \s!pagegrid \v!text +\installfloatmethod \s!pagegrid \v!top \page_grd_place_float_top +\installfloatmethod \s!pagegrid \v!bottom \page_grd_place_float_bottom +%installfloatmethod \s!pagegrid \v!auto +%installfloatmethod \s!pagegrid \v!margin +%installfloatmethod \s!pagegrid \v!opposite +\installfloatmethod \s!pagegrid \v!page \page_grd_place_float_page +%installfloatmethod \s!pagegrid \v!leftpage +%installfloatmethod \s!pagegrid \v!rightpage +%installfloatmethod \s!pagegrid \v!inmargin +%installfloatmethod \s!pagegrid \v!inleft +%installfloatmethod \s!pagegrid \v!inright +%installfloatmethod \s!pagegrid \v!leftmargin +%installfloatmethod \s!pagegrid \v!rightmargin +%installfloatmethod \s!pagegrid \v!leftedge +%installfloatmethod \s!pagegrid \v!rightedge +%installfloatmethod \s!pagegrid \v!somewhere +%installfloatmethod \s!pagegrid \v!backspace +%installfloatmethod \s!pagegrid \v!cutspace +\installfloatmethod \s!pagegrid \s!tblr \page_grd_place_float_slot +\installfloatmethod \s!pagegrid \s!lrtb \page_grd_place_float_slot +\installfloatmethod \s!pagegrid \s!tbrl \page_grd_place_float_slot +\installfloatmethod \s!pagegrid \s!rltb \page_grd_place_float_slot +\installfloatmethod \s!pagegrid \s!fxtb \page_grd_place_float_slot +\installfloatmethod \s!pagegrid \s!btlr \page_grd_place_float_slot +\installfloatmethod \s!pagegrid \s!lrbt \page_grd_place_float_slot +\installfloatmethod \s!pagegrid \s!btrl \page_grd_place_float_slot +\installfloatmethod \s!pagegrid \s!rlbt \page_grd_place_float_slot +\installfloatmethod \s!pagegrid \s!fxbt \page_grd_place_float_slot +\installfloatmethod \s!pagegrid \s!fixd \page_grd_place_float_fixed + +\protected\def\page_grd_command_side_float_output + {} % nothing, reset anyway + +\protected\def\page_grd_command_flush_side_floats + {\page_sides_forget_floats} + +\protected\def\page_grd_command_synchronize_side_floats + {\page_sides_forget_floats} + +\protected\def\page_grd_command_synchronize_hsize + {\page_grd_command_set_hsize} + +\protected\def\page_grd_command_flush_all_floats + {\page_one_command_flush_all_floats} + +\defineoutputroutine + [\s!pagegrid] + [\s!page_otr_command_routine =\page_grd_command_routine, + \s!page_otr_command_package_contents =\page_grd_command_package_contents, + \s!page_otr_command_set_vsize =\page_grd_command_set_vsize, + \s!page_otr_command_set_hsize =\page_grd_command_set_hsize, % tricky, goes wrong + \s!page_otr_command_synchronize_hsize =\page_grd_command_synchronize_hsize, + \s!page_otr_command_next_page =\page_grd_command_next_page, + \s!page_otr_command_next_page_and_inserts =\page_grd_command_next_page_and_inserts, + % \s!page_otr_command_set_top_insertions =\page_grd_command_set_top_insertions, + % \s!page_otr_command_set_bottom_insertions =\page_grd_command_set_bottom_insertions, + % \s!page_otr_command_flush_top_insertions =\page_grd_command_flush_top_insertions, + % \s!page_otr_command_flush_bottom_insertions=\page_grd_command_flush_bottom_insertions, + \s!page_otr_command_check_if_float_fits =\page_grd_command_check_if_float_fits, + % \s!page_otr_command_set_float_hsize =\page_grd_command_set_float_hsize, + % \s!page_otr_command_flush_float_box =\page_grd_command_flush_float_box, + \s!page_otr_command_synchronize_side_floats=\page_grd_command_synchronize_side_floats, + \s!page_otr_command_side_float_output =\page_grd_command_side_float_output, + \s!page_otr_command_flush_floats =\page_grd_command_flush_floats, + \s!page_otr_command_flush_side_floats =\page_grd_command_flush_side_floats, + \s!page_otr_command_flush_saved_floats =\page_grd_command_flush_saved_floats, + \s!page_otr_command_flush_all_floats =\page_grd_command_flush_all_floats, + % \s!page_otr_command_flush_margin_blocks =\page_grd_command_flush_margin_blocks, % not used + ] + +% spans + +\installcorenamespace{pagegridspan} + +\installframedcommandhandler \??pagegridspan {pagegridspan} \??pagegridspan + +\setuppagegridspan + [\c!frame=\v!off, + \c!before=, + \c!after=, + \c!offset=\v!overlay, + \c!location=\v!left, + \c!linecorrection=\v!off, + \c!depthcorrection=\v!off, + \c!n=\plustwo, + \c!nlines=\zerocount, + \c!align=\v!normal, + \c!width=\d_page_grd_span_width, + \c!indenting=, + \c!indentnext=\v!yes, + \c!default=\v!here, + \c!alternative=\v!a] + +\newdimen\d_page_grd_span_width + +\permanent\tolerant\protected\def\startpagegridspan[#1]#*[#2]#*[#3]% [#3] gobbles space + {\endgraf % else rubish output if forgotten + \synchronizepagegrid + \bgroup + \forgetall + \edef\currentpagegridspan{#1}% + \clf_sethsizecolumnspan{\currentpagegrid}\pagegridspanparameter\c!n\relax + \setbox\scratchbox\hbox\bgroup\inheritedpagegridspanframed\bgroup + \def\page_grd_span_stop{\page_grd_span_stop_indeed{#2}}% + \usepagegridspanstyleandcolor\c!style\c!color + \pagegridspanparameter\c!before + \ignorespaces} + +\protected\def\page_grd_span_stop_indeed#1% + {\removeunwantedspaces + \par + \verticalstrut + \kern-2\struttotal + \verticalstrut + \endgraf + \pagegridspanparameter\c!after + \egroup\egroup + \setpagegrid[#1]{\box\scratchbox}% + % todo: push into slot + \egroup + \endgraf} + +\permanent\protected\def\stoppagegridspan % indirectness permits aliasing + {\page_grd_span_stop} + +\permanent\def\pagegridspanwidth#1% assumes equal distances + {\the\dimexpr + #1\d_page_grd_column_width + +#1\d_page_grd_distance + - \d_page_grd_distance + \relax} + +% areas + +\installcorenamespace{pagegridarea} + +\installframedcommandhandler \??pagegridarea {pagegridarea} \??pagegridarea + +\setuppagegridarea + [\c!x=\plusone, + \c!y=\plusone, + \c!nx=\plusone, + \c!ny=\plusone, + \c!clipoffset=2\lineheight, + \c!leftoffset=\zeropoint, + \c!rightoffset=\zeropoint, + \c!offset=\v!overlay, + \c!strut=\v!no, + \c!frame=\v!off, + %\c!type=\v!next, + \c!align=\v!normal, + \c!page=\plusone, + \c!state=\v!stop] + +% type: both fixed left right next (not now), then better +% lefttext and righttext or so + +\appendtoks + % \edef\p_type{}% + % \ifx\p_type\v!next + % \doifelseoddpage + % {\letpagegridareaparameter\c!type\v!right}% + % {\letpagegridareaparameter\c!type\v!left}% + % \fi + \clf_registercolumnsetarea { + name {\currentpagegridarea} + % type {\p_type} + % page \pagegridareaparameter\c!page + state {\pagegridareaparameter\c!state} + c \pagegridareaparameter\c!x + r \pagegridareaparameter\c!y + nc \pagegridareaparameter\c!nx + nr \pagegridareaparameter\c!ny + }% +\to \everydefinepagegridarea + +\permanent\tolerant\protected\def\setuppagegridareatext[#1]#*[#2]% + {\edef\currentpagegridarea{#1}% + \setpagegridareaparameter\c!text{#2}} + +% maybe move the left/right correction to the tex end or the offset to lua + +\protected\def\page_grd_set_area#1#2#3#4#5#6#7#8% can be optimized + {\begingroup + \edef\currentpagegridarea{#2}% + \setpagegridareaparameter\c!width {#5\scaledpoint}% + \setpagegridareaparameter\c!height{#6\scaledpoint}% + \setbox\nextbox\hpack\bgroup\inheritedpagegridareaframed\bgroup + \usepagegridareastyleandcolor\c!style\c!color + \ignorespaces + \pagegridareaparameter\c!text + \egroup\egroup + % + \scratchdimen#8\scaledpoint + \ifdim\scratchdimen>\zeropoint + \setbox\scratchbox\vbox\bgroup + \clip + [ \c!offset=\pagegridareaparameter\c!clipoffset,% + \c!rightoffset=\pagegridareaparameter\c!rightoffset,% + \c!width=\scratchdimen,% + % \c!height= + ]% + {\copy\nextbox}% + \egroup + \clf_setcolumnsetarea{name {#1} box \scratchbox c #3 r #4}% + \setbox\scratchbox\vbox\bgroup + \hskip-\layoutparameter\c!backspace % todo: #9 + \clip + [ \c!offset=\pagegridareaparameter\c!clipoffset,% + \c!leftoffset=\pagegridareaparameter\c!rightoffset,% + \c!hoffset=\scratchdimen,% + \c!width=\dimexpr\wd\nextbox-\scratchdimen\relax,% + % \c!height= + ]% + {\box\nextbox}% + \egroup + \clf_setcolumnsetarea{name {#1} box \scratchbox c #7 r #4}% + \else + \setbox\scratchbox\vbox\bgroup + \box\nextbox % wrapping needed + \egroup + \clf_setcolumnsetarea{name {#1} box \scratchbox c #3 r #4}% + \fi + \endgroup} + +\aliased\let\setpagegridarea\page_grd_set_area + +% state start | repeat + +%D The old one, for now: + +\aliased\let\definecolumnset \definepagegrid +\aliased\let\setupcolumnset \setuppagegrid +\aliased\let\setupcolumnsetlines \setuppagegridlines +\aliased\let\setupcolumnsetstart \setuppagegridstart +\aliased\let\startcolumnset \startpagegrid +\aliased\let\stopcolumnset \stoppagegrid +\aliased\let\definecolumnsetspan \definepagegridspan +\aliased\let\setupcolumnsetspan \setuppagegridspan +\aliased\let\startcolumnsetspan \startpagegridspan +\aliased\let\stopcolumnsetspan \stoppagegridspan +\aliased\let\columnsetspanwidth \pagegridspanwidth +\aliased\let\definecolumnsetarea \definepagegridarea +\aliased\let\setupcolumnsetarea \setuppagegridarea +\aliased\let\setupcolumnsetareatext\setuppagegridareatext + +%D It ends here. + +\protect \endinput diff --git a/tex/context/base/mkxl/page-fac.mkxl b/tex/context/base/mkxl/page-fac.mkxl new file mode 100644 index 000000000..03fa98217 --- /dev/null +++ b/tex/context/base/mkxl/page-fac.mkxl @@ -0,0 +1,87 @@ +%D \module +%D [ file=page-fac, % moved from page-ini +%D version=2011.12.07, % 2000.10.20, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Facing Pages, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Facing Pages} + +\unprotect + +%D \macros +%D {setupoppositeplacing,startopposite} +%D +%D \starttyping +%D \starttext +%D test \startopposite \blackrule[width=3cm,height=4cm] \stopopposite test +%D test \startopposite \blackrule[width=3cm,height=4cm] \stopopposite test +%D \stoptext +%D \stoptyping + +\newbox \b_page_facings_content +\newconditional\c_page_facings_busy + +\installcorenamespace{oppositeplacing} + +\installsetuponlycommandhandler \??oppositeplacing {oppositeplacing} + +\permanent\protected\def\startopposite + {\dowithnextboxcontent + {\hsize\makeupwidth}% + {\global\setbox\b_page_facings_content\vbox + {\ifvoid\b_page_facings_content + \directoppositeplacingparameter\c!before + \else + \directoppositeplacingparameter\c!inbetween + \unvbox\b_page_facings_content + \fi + \box\nextbox}}% + \vbox\bgroup} + +\permanent\protected\def\stopopposite + {\egroup} + +\def\page_facings_finish + {\ifvoid\b_page_facings_content \else + \global\setbox\b_page_facings_content\vbox to \makeupheight + {\unvbox\b_page_facings_content + \directoppositeplacingparameter\c!after + \vss}% + \fi} + +\def\page_facings_flush + {\ifconditional\c_page_facings_busy + \ifvoid\b_page_facings_content \else + \page_facings_flush_indeed + \fi + \fi} + +\def\page_facings_flush_indeed + {\ifnum\realpageno>\plusone + \begingroup + \pageornamentstate\plusone % tricky + \page_facings_finish + \page_boxes_shipout{\page_boxes_constructed_page\box\b_page_facings_content}% + \endgroup + \else + \global\setbox\b_page_facings_content\emptybox + \fi} + +\appendtoks + \doifelse{\directoppositeplacingparameter\c!state}\v!start\settrue\setfalse\c_page_facings_busy +\to \everysetupoppositeplacing + +\setupoppositeplacing + [\c!state=\v!start, + \c!before=, + \c!inbetween=\blank, + \c!after=] + +\protect \endinput diff --git a/tex/context/base/mkxl/page-ffl.mkxl b/tex/context/base/mkxl/page-ffl.mkxl new file mode 100644 index 000000000..1ba4bf01d --- /dev/null +++ b/tex/context/base/mkxl/page-ffl.mkxl @@ -0,0 +1,247 @@ +%D \module +%D [ file=page-ffl, +%D version=2018.01.04, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Facing floats, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Facing floats} + +%D The code below comes from a module made for Thomas Schmitz and is now part of the +%D core. A simple example is given here: +%D +%D \starttyping +%D \definefacingfloat +%D [whatever] +%D +%D \setupfacingfloat +%D [whatever] +%D [style=bold, +%D width=frame, +%D offset=10pt, +%D color=white] +%D +%D \setupfacingfloat +%D [whatever:left] +%D [background=color, +%D backgroundcolor=red] +%D +%D \setupfacingfloat +%D [whatever:right] +%D [background=color, +%D backgroundcolor=green] +%D +%D \startfacingfloat[whatever] +%D {\dorecurse{10}{\samplefile{tufte} }} +%D {\dorecurse{10}{\samplefile{ward} }} +%D {\dorecurse{10}{\samplefile{tufte} }} +%D {\dorecurse{10}{\samplefile{ward} }} +%D \stopfacingfloat +%D +%D \startfacingfloat[whatever] +%D \startcontent \dorecurse{10}{\samplefile{tufte} } \stopcontent +%D \startcontent \dorecurse{10}{\samplefile{ward} } \stopcontent +%D \startcontent \dorecurse{10}{\samplefile{tufte} } \stopcontent +%D \startcontent \dorecurse{10}{\samplefile{ward} } \stopcontent +%D \stopfacingfloat +%D +%D \dorecurse{10}{\samplefile{sapolsky} } +%D \stoptyping +%D +%D The idea is to flush related floats more or less in parallel. + +\unprotect + +% width: +% +% -- fit : do nothing +% -- dimension : use that +% -- frame : use hsize minus frame offsets (based on preroll) + +\installcorenamespace {facingfloat} + +\installframedcommandhandler \??facingfloat {facingfloat} \??facingfloat + +\setupfacingfloat + [\c!spaceinbetween=\v!big, + \c!inbetween={\blank[\v!big]}, + \c!width=\v!fit, + %\c!style, + %\c!color, + \c!page=\v!left] + +\appendtoks + \ifx\currentfacingfloatparent\empty + \normalexpanded{\definefacingfloat[\currentfacingfloat:\v!left ][\currentfacingfloat]}% + \normalexpanded{\definefacingfloat[\currentfacingfloat:\v!right][\currentfacingfloat]}% + \fi +\to \everydefinefacingfloat + +\newcount\c_strc_floats_facing_saved +\newcount\c_strc_floats_facing_flushed + +\newbox\b_strc_floats_facing_l +\newbox\b_strc_floats_facing_r + +\let\m_strc_floats_state\relax + +\protected\def\strc_floats_facing_flush + {\ifnum\c_strc_floats_facing_flushed<\c_strc_floats_facing_saved + \ifodd\c_strc_floats_facing_flushed + \ifodd\realpageno + \strc_floats_facing_flush_indeed + \doifelsependingpagecontent\relax{\null\page}% + \fi + \else + \ifodd\realpageno\else + \strc_floats_facing_flush_indeed + \doifelsependingpagecontent\relax{\null\page}% + \fi + \fi + \fi} + +\def\strc_floats_facing_flush_indeed + {\global\advance\c_strc_floats_facing_flushed\plusone + \floatingpenalty\zerocount + \insert\namedinsertionnumber\s!topfloat\bgroup + \forgetall + \ifconditional\c_page_one_top_of_insert + \ifconditional\c_page_one_correct_top_insert + \topskipcorrection % [xx] new: see icare topbleed + \kern-\lineskip + \par + \prevdepth\maxdimen + \fi + \fi + \directboxfromcache{\currentfacingfloat}{\number\c_strc_floats_facing_flushed}% + \vkern\s_page_one_between_top_insert + \egroup + \ifnum\c_strc_floats_facing_saved=\c_strc_floats_facing_flushed + \global\c_strc_floats_facing_saved \zerocount + \global\c_strc_floats_facing_flushed\zerocount + \resetboxesincache{\currentfacingfloat}% + \fi} + +\let\flushfacingfloats\strc_floats_facing_flush + +\protected\def\strc_floats_facing_setup + {\edef\currentfacingfloat{\currentfacingfloat:\m_strc_floats_state}% + \usefacingfloatstyleandcolor\c!style\v!color} + +\protected\def\strc_floats_facing_collect + {\ifx\m_strc_floats_state\v!left + \ifvoid\nextbox\orelse\ifzeropt\wd\nextbox\else + \ifvoid\b_strc_floats_facing_l + \setbox\b_strc_floats_facing_l\box\nextbox + \else + \setbox\b_strc_floats_facing_l\vbox\bgroup + \unvbox\b_strc_floats_facing_l + \facingfloatparameter\c!inbetween + \unvbox\nextbox + \egroup + \fi + \fi + \let\m_strc_floats_state\v!right + \orelse\ifx\m_strc_floats_state\v!right + \ifvoid\nextbox\orelse\ifzeropt\wd\nextbox\else + \ifvoid\b_strc_floats_facing_r + \setbox\b_strc_floats_facing_r\box\nextbox + \else + \setbox\b_strc_floats_facing_r\vbox\bgroup + \unvbox\b_strc_floats_facing_r + \facingfloatparameter\c!inbetween + \unvbox\nextbox + \egroup + \fi + \fi + \let\m_strc_floats_state\v!left + \else + \let\m_strc_floats_state\v!left + \fi} + +\protected\def\strc_floats_facing_handle + {\doifnextbgroupelse + \strc_floats_facing_handle_indeed + \strc_floats_facing_wrap_up} + +\protected\def\strc_floats_facing_handle_indeed + {\dowithnextboxcontent + \strc_floats_facing_setup + {\strc_floats_facing_collect\strc_floats_facing_handle} + \vbox} + +\permanent\protected\def\startfacingfloat[#1]% + {\begingroup + % todo: \usepageparameter +% \edef\p_page{\facingfloatparameter\c!page}% +% \ifx\p_page\empty\else +% \page[\p_page]% +% \fi + % + \edef\currentfacingfloat{#1}% + \edef\p_width{\facingfloatparameter\c!width}% + \letfacingfloatparameter\c!width\v!fit + \ifx\p_width\v!frame + \setbox\scratchbox\hpack{\inheritedfacingfloatframed{}}% + \advance\hsize-\wd\scratchbox + \orelse\ifx\p_width\v!fit + % whatever + \else + \hsize\p_width + \fi + \enforced\let\startcontent\bgroup + \enforced\let\stopcontent\egroup + \let\m_strc_floats_state\v!left + \strc_floats_facing_handle} + +\permanent\protected\def\stopfacingfloat + {\endgroup} + +\protected\def\strc_floats_facing_wrap_up + {\edef\p_spaceinbetween{\facingfloatparameter\c!spaceinbetween}% + \ifx\p_spaceinbetween\empty + \scratchdimen\zeropoint + \else + \setbox\scratchbox\vbox{\directvspacing\p_spaceinbetween}% + \scratchdimen\htdp\scratchbox + \fi + \ifvoid\b_strc_floats_facing_l\else + \page_postprocessors_linenumbers_box\b_strc_floats_facing_l + \fi + \ifvoid\b_strc_floats_facing_r\else + \page_postprocessors_linenumbers_box\b_strc_floats_facing_r + \fi + \doloop{% + \strc_floats_facing_flush_wrap\b_strc_floats_facing_l\v!left + \strc_floats_facing_flush_wrap\b_strc_floats_facing_r\v!right + \ifvoid\b_strc_floats_facing_l\relax\ifvoid\b_strc_floats_facing_r\relax + \exitloop + \fi\fi}} + +\def\strc_floats_facing_flush_wrap#1#2% + {\ifvoid#1\relax + % todo + \else + \begingroup + \setbox\scratchbox\vsplit#1 upto \textheight + \setbox\scratchbox\hpack\bgroup + \edef\currentfacingfloat{\currentfacingfloat:#2}% + \inheritedfacingfloatframed{\box\scratchbox}% + \egroup + \ifdim\ht\scratchbox<\dimexpr\textheight-\scratchdimen\relax + \setbox\scratchbox\vbox{\box\scratchbox\directvspacing\p_spaceinbetween}% + \else + \setbox\scratchbox\vbox to \textheight{\box\scratchbox\vss}% + \fi + \global\advance\c_strc_floats_facing_saved\plusone + \putboxincache{\currentfacingfloat}{\number\c_strc_floats_facing_saved}\scratchbox + \endgroup + \fi} + +\protect \endinput diff --git a/tex/context/base/mkxl/page-flt.mkxl b/tex/context/base/mkxl/page-flt.mkxl new file mode 100644 index 000000000..bc287da7d --- /dev/null +++ b/tex/context/base/mkxl/page-flt.mkxl @@ -0,0 +1,326 @@ +%D \module +%D [ file=page-flt, +%D version=2010.04.08, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Float Management, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Float Management} + +%D This module has code that previously was in other modules. There is also float +%D related code in \type {strc-flt.mkiv}. + +\registerctxluafile{page-flt}{} + +\unprotect + +\defineinsertion[\s!topfloat] +\defineinsertion[\s!bottomfloat] +\defineinsertion[\s!pagefloat] + +\newdimen \d_page_floats_inserted_bottom +\newdimen \d_page_floats_inserted_top +\newdimen \d_page_floats_inserted_page +\newcount \c_page_floats_n_of_top \c_page_floats_n_of_top \plustwo +\newcount \c_page_floats_n_of_bottom \c_page_floats_n_of_bottom\zerocount +\newcount \c_page_floats_n_of_page \c_page_floats_n_of_page \plustwo + +\newconstant\c_page_floats_insertions_topskip_mode % 1 = no topskip + +\def\page_floats_report_total + {\showmessage\m!floatblocks4% + {\the\totalnoffloats + \ifx\floatlocationmethod\empty + \ifx\floatlocation\empty\else,\floatlocation\fi + \else + ,\floatlocationmethod + \fi}} + +\def\page_floats_report_flushed + {\showmessage\m!floatblocks3% + {\the\numexpr\totalnoffloats-\savednoffloats\relax}} + +%D Extra float registers. + +\newconditional\c_page_floats_room +\newconditional\c_page_floats_some_waiting +\newconditional\c_page_floats_not_permitted +\newconditional\c_page_floats_flushing +\newconditional\c_page_floats_center_box \settrue\c_page_floats_center_box +\newconditional\c_page_floats_center_box_local +\newconditional\c_page_floats_center_box_global +\newconditional\c_page_floats_compress_flushed \settrue\c_page_floats_compress_flushed + +\newdimen \d_page_floats_compress_distance + +%D For the moment we keep this but they will become private too. + +\newcount\totalnoffloats % these will be redone ... handled at the lua end anyway +\newcount\savednoffloats % these will be redone ... handled at the lua end anyway +\newcount\nofcollectedfloats % communication channel +\newdimen\maxcollectedfloatstotal % communication channel + +\newcount\noffloatinserts % these will be redone ... handled at the lua end anyway + +\newbox \floattext + +\newdimen\floatwidth +\newdimen\floatheight +\newdimen\floatdepth +\newdimen\floattextwidth +\newdimen\floattextheight + +\newbox \floatbox +\newbox \savedfloatbox + +%D From now on we manage the float stack at the \LUA\ end instead of packing +%D them in a box and splitting off stacked floats. It's not so much less code +%D but it's cleaner this way. It also opens op some posibilities as we can now +%D more conveniently cary additional information around. + +\newtoks \everyfloatscheck + +\appendtoks + \ifcase\savednoffloats + \global\setfalse\c_page_floats_some_waiting + \else + \global\settrue\c_page_floats_some_waiting + \fi +\to \everyfloatscheck + +\protected\def\page_floats_flush#1#2% + {\clf_flushfloat{#1}#2\relax + \the\everyfloatscheck} + +\protected\def\page_floats_flush_by_label#1#2% + {\clf_flushlabeledfloat{#1}{#2}\relax + \the\everyfloatscheck} + +\protected\def\page_floats_save#1% + {\clf_savefloat{#1}\relax + \the\everyfloatscheck} + +\protected\def\page_floats_resave#1% + {\clf_resavefloat{#1}\relax + \the\everyfloatscheck} + +\protected\def\page_floats_push_saved + {\clf_pushfloat + \the\everyfloatscheck} + +\protected\def\page_floats_pop_saved + {\clf_popfloat + \the\everyfloatscheck} + +\protected\def\page_floats_get_info#1% + {\clf_consultfloat{#1}} + +\protected\def\page_floats_if_else#1% + {\clf_doifelsestackedfloats{#1}} + +\protected\def\page_floats_collect#1#2#3% + {\clf_collectfloat{#1}\dimexpr#2\relax\dimexpr#3\relax} + +\def\nofstackedfloatincategory#1% + {\clf_nofstackedfloats{#1}} + +\let\page_floats_column_push_saved\page_floats_push_saved % overloaded in page-mul +\let\page_floats_column_pop_saved \page_floats_pop_saved % overloaded in page-mul + +\protected\def\page_floats_save_page_float#1#2% + {\clf_savespecificfloat{#1}{specification{#2}}\relax} + +\protected\def\page_floats_save_somewhere_float#1#2% #1=method + {\clf_savespecificfloat{#1}{specification{#2}label{\floatlabel}}\relax} + +%D This is an experimental new feature (for Alan Braslau), a prelude to more: +%D +%D \starttyping +%D test \placefigure{}{} +%D test \placefigure[somewhere:alpha][whatever]{}{} +%D test \placefigure[somewhere:beta] [whatever]{}{} +%D test \placefigure[somewhere:gamma][whatever]{}{} +%D test \placefigure[somewhere:delta][whatever]{}{} +%D test \placefigure{}{} +%D +%D in \in{figure}[whatever] bla bla +%D +%D \placenamedfloat[figure][*l*] +%D \placenamedfloat[figure][gamma] +%D \placenamedfloat[figure][beta] +%D \stoptyping + +\permanent\tolerant\protected\def\placenamedfloat[#1]#*[#2]% + {\doloop + {\page_floats_flush_by_label\s!somewhere{#2}% + \ifvoid\floatbox + \exitloop + \else + \def\currentfloat{#1}% + \blank[\rootfloatparameter\c!spacebefore]% + \box\floatbox + \blank[\rootfloatparameter\c!spaceafter]% + \fi}} + +% \setupcaption [figure] [align=flushleft] +% \setupcaption [figure-1] [align=flushleft,leftmargin=10mm] +% \setupcaption [figure-2] [align=flushleft,leftmargin=10mm,rightmargin=-10mm,width=\textwidth] +% +% \startsetups somefigure +% \ifdim\floatsetupwidth>\textwidth +% \placesetupfloat[figure-2] +% \else +% \placesetupfloat[figure-1] +% \fi +% \stopsetups +% +% \placefloatwithsetups[somefigure]{}{\externalfigure[dummy][width=5cm,height=2cm]} + +\permanent\tolerant\protected\def\placefloatwithsetups[#1]#*[#2]#*[#3]#:#4% + {\def\floatsetupcaption{#4}% + \def\floatsetupcontent{\copy\nextbox}% + \def\floatsetupwidth {\wd\nextbox}% + \def\floatsetupheight {\ht\nextbox}% + \enforced\permanent\protected\def\placesetupfloat[##1]% + {\placefloat[##1][#2][#3]{#4}{\floatsetupcontent}}% #4 and not \floatsetupcaption (protected) + \dowithnextbox{\setups[#1]}\vbox} + +%D The following code is in transition as we don't want to break the current single +%D column, multi column, and columnset mechanism. +%D +%D First we reimplement some helpers. + +\def\page_floats_get_used_hsize{\hsize} + +\protected\def\page_floats_get + {\ifconditional\c_page_floats_some_waiting + \page_floats_flush\s!text\plusone + \ifconditional\c_page_floats_center_box + \ifdim\wd\globalscratchbox<\page_floats_get_used_hsize + \global\setbox\floatbox\hpack to \page_floats_get_used_hsize{\hss\box\floatbox\hss}% + \orelse\ifinsidecolumns + % retain special alignments + \ifdim\wd\floatbox>\makeupwidth + \wd\floatbox\makeupwidth + \fi + \fi + \fi + \else + \global\savednoffloats\zerocount + \global\setbox\floatbox\emptybox + \fi} + +\protected\def\page_floats_flush_saved + {\doloop + {\ifconditional\c_page_floats_some_waiting + \page_otr_command_check_if_float_fits + \ifconditional\c_page_floats_room + \page_floats_get + \doplacefloatbox + \else + \exitloop + \fi + \else + % \ifconditional\c_page_margin_blocks_present % not here, here just as many floats as fit + % \page_otr_command_flush_margin_blocks + % \else + \exitloop + % \fi + \fi}} + +%D This is a future mechamism that will be integrated once we're sure about it: +%D +%D \starttyping +%D \dorecurse{10} +%D {\input thuan +%D \placefigure{}{\framed[height=1.5cm]{test}} +%D \placefloatplaceholder} +%D \stoptyping + +\permanent\protected\def\placefloatplaceholder + {\ifconditional\c_page_floats_room \else + \ifdim\dimexpr\pagegoal-\pagetotal-3\lineheight\relax>\zeropoint + \startlinecorrection[blank] + \mhbox{\inframed{\labeltexts{placeholder}{\lastcaptiontag}}}% + \stoplinecorrection + \else + \allowbreak + \fi + \fi} + +\setuplabeltext + [placeholder={\Word{\lastplacedfloat}~, moved}] + +%D Page floats use different stacks. + +\newtoks\everybeforeflushedpagefloat + +\def\page_floats_flush_page_floats_indeed#1% future releases can do more clever things + {\page_floats_flush{#1}\plusone + \edef\floatspecification{\clf_getfloatvariable{specification}}% Is this okay? + \the\everybeforeflushedpagefloat + \vpack to \textheight + {\doifnotinset\v!high\floatspecification\vfill + \box\floatbox + \doifnotinset\v!low\floatspecification\vfill}% + \page_otr_fill_and_eject_page} + +\let\m_page_otr_checked_page_float\relax + +\protected\def\page_floats_flush_page_floats % used in postpone + {\edef\m_page_otr_checked_page_float{\clf_checkedpagefloat}% + \ifx\m_page_otr_checked_page_float\empty + % nothing + \orelse\ifx\m_page_otr_checked_page_float\v!empty + \emptyhbox \page_otr_fill_and_eject_page % why not dummy_page + \else + \page_floats_flush_page_floats_indeed\m_page_otr_checked_page_float + \fi} + +% temp hack, needed to prevent floatbox being forgotten during +% output, this will change to using another box for flushing +% +% \dorecurse{700}{text } \placefigure[top][]{First} {\framed{bla 1}} +% \placefigure[top][]{Second}{\framed{bla 2}} +% \dorecurse {40}{text } \placefigure[top][]{Third} {\framed{bla 3}} + +\appendtoks + \global\setbox\savedfloatbox\box\floatbox +\to \everybeforeoutput + +\appendtoks + \global\setbox\floatbox\box\savedfloatbox +\to \everyafteroutput + +\protect \endinput + +% hm, where is this one used (was in save/restore, see old implementation) +% +% \permanent\protected\def\uncenteredfloatbox +% {\ifconditional\c_page_floats_center_box +% \ifhbox\floatbox\relax % remove centering +% \ifdim\wd\floatbox=\hsize +% \ifhbox\floatbox +% \setbox\scratchbox\hbox +% {\unhbox\floatbox +% \unskip\unskip +% \global\setbox\globalscratchbox\lastbox}% +% \box\globalscratchbox +% \else +% \box\floatbox +% \fi +% \else +% \box\floatbox +% \fi +% \else +% \box\floatbox +% \fi +% \else +% \box\floatbox +% \fi} diff --git a/tex/context/base/mkxl/page-flw.mkxl b/tex/context/base/mkxl/page-flw.mkxl new file mode 100644 index 000000000..ef92b9b52 --- /dev/null +++ b/tex/context/base/mkxl/page-flw.mkxl @@ -0,0 +1,178 @@ +%D \module +%D [ file=page-flw, +%D version=2003.04.19, % from test-002 (1997) profile experiment +%D title=\CONTEXT\ Page Macros, +%D subtitle=Text Flows, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Text Flows} + +%D This is high experimental and especially flushing may change (proper spacing is +%D the driving force here). It's an old mechanism used for playing with stepping +%D through document threads. As it's a simple and effective mechanism we keep it +%D around. It's not to be confused with upcoming stream support. +%D +%D \starttyping +%D \setuppapersize [S6] +%D \setuptolerance [verytolerant,stretch] +%D \setupfooter [strut=no] +%D \setupwhitespace[big] +%D +%D \setuplayout +%D [rightedge=5cm,width=fit,margin=0pt,edgedistance=1cm, +%D footer=4cm,footerdistance=1cm,header=0cm] +%D +%D \setuptexttexts [edge][][\vbox{\flushtextflow{alpha}}] +%D \setupfootertexts[edge][][\vbox{\flushtextflow{beta}}] +%D \setupfootertexts [\vbox{\flushtextflow{gamma}}][] +%D +%D \definetextflow [alfa] [width=\rightedgewidth] +%D \definetextflow [beta] [width=\rightedgewidth] +%D \definetextflow [gamma] [width=\footerheight] +%D +%D \starttext +%D +%D \dorecurse{50} +%D {\getrandomnumber{\funny}{0}{8} +%D \ifcase\funny \starttextflow[alfa] \input tufte.tex \stoptextflow +%D \or \starttextflow[beta] \input knuth.tex \stoptextflow +%D \or \starttextflow[gamma] \input materie.tex \stoptextflow +%D \or {\bf TUFTE}\quad \input tufte \par +%D \or {\bf TUFTE}\quad \input tufte \par +%D \or {\bf KNUTH}\quad \input knuth \par +%D \or {\bf KNUTH}\quad \input knuth \par +%D \or {\bf MATERIE}\quad \input materie \par +%D \else {\bf MATERIE}\quad \input materie \par +%D \fi} +%D +%D \stoptext +%D \stoptyping + +\unprotect + +\installcorenamespace{textflow} +\installcorenamespace{textflowbox} + +\installcommandhandler \??textflow {textflow} \??textflow + +\setuptextflow + [%c!style=, + %c!color=, + \c!width=\availablehsize] + +\appendtoks + \ifcsname\??textflowbox\currenttextflow\endcsname + \setbox\csname\??textflowbox\currenttextflow\endcsname\emptybox + \else + \expandafter\newbox\csname\??textflowbox\currenttextflow\endcsname + \fi +\to \everydefinetextflow + +\newcount\b_page_textflow_box + +\permanent\def\textflowcollector#1% + {\begincsname\??textflowbox#1\endcsname} + +\permanent\protected\def\doifelsetextflowcollector#1% + {\ifcsname\??textflowbox#1\endcsname + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} + +\permanent\protected\def\doifelsetextflow#1% + {\unless\ifcsname\??textflowbox#1\endcsname + \expandafter\secondoftwoarguments + \orelse\ifvoid\csname\??textflowbox#1\endcsname + \expandafter\secondoftwoarguments + \else + \expandafter\firstoftwoarguments + \fi} + +\aliased\let\doiftextflowcollectorelse\doifelsetextflowcollector +\aliased\let\doiftextflowelse \doifelsetextflow + +\permanent\protected\def\starttextflow[#1]% + {\begingroup + \edef\currenttextflow{#1}% + \ifcsname\??textflowbox\currenttextflow\endcsname + \b_page_textflow_box\csname\??textflowbox\currenttextflow\endcsname + \global\setbox\b_page_textflow_box\vbox + \bgroup + \dontcomplain + \ifvoid\b_page_textflow_box\else + \unvbox\b_page_textflow_box + \fi + \hsize\textflowparameter\c!width\relax + \usetextflowstyleandcolor\c!style\c!color + \enforced\permanent\protected\def\stoptextflow{\endgraf\egroup\endgroup}% + \else + \enforced\aliased\let\stoptextflow\endgroup + \fi} + +\aliased\let\stoptextflow\relax + +\permanent\protected\def\flushtextflow#1% + {\begingroup + \edef\currenttextflow{#1}% + \ifcsname\??textflowbox\currenttextflow\endcsname + \b_page_textflow_box\csname\??textflowbox\currenttextflow\endcsname + \ifvoid\b_page_textflow_box + % sorry + \orelse\ifdim\ht\b_page_textflow_box>\vsize + \setbox\scratchbox\vsplit\b_page_textflow_box to \vsize + \ifvoid\scratchbox\else + \unvbox\scratchbox + \fi + \else + \unvbox\b_page_textflow_box + \fi + \fi + \endgroup} + +\protect \endinput + +% \setuppapersize [A6] +% \setupbodyfont [pagella, 12pt] +% +% \definetextflow [even] [width=\textwidth] +% \definetextflow [odd] [width=\textwidth] +% +% \starttextflow [even] \dorecurse{15}{\input bryson} \stoptextflow +% \starttextflow [odd] \dorecurse {5}{\input knuth } \stoptextflow +% +% \starttext +% +% \doloop { +% \ifodd\realpageno +% \doiftextflowelse{odd} { +% \bgroup +% \vsize\dimexpr\textheight-\strutdp\relax +% \flushtextflow{odd} +% \egroup +% } { +% \null +% } +% \page +% \else +% \doiftextflowelse{even} { +% \bgroup +% \vsize\dimexpr\textheight-\strutdp\relax +% \flushtextflow{even} +% \egroup +% } { +% \null +% } +% \page +% \fi +% \doiftextflowelse{even}\donothing{\doiftextflowelse{odd}\donothing\exitloop} +% } +% +% \stoptext + diff --git a/tex/context/base/mkxl/page-imp.mkxl b/tex/context/base/mkxl/page-imp.mkxl new file mode 100644 index 000000000..6ccab3e4e --- /dev/null +++ b/tex/context/base/mkxl/page-imp.mkxl @@ -0,0 +1,1410 @@ +%D \module +%D [ file=page-imp, % was: core-pag, +%D version=1998.01.15, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Pagebody Building (Imposition), +%D author=Hans Hagen & Willi Egger, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +% much of this can more to run time loading ! + +\writestatus{loading}{ConTeXt Page Macros / Pagebody Building} + +\unprotect + +%D \macros +%D {starttextdata} +%D +%D This is a user macro (appending to every last shipout is not really user +%D friendly). + +\newtoks\t_page_text_data + +\permanent\protected\def\starttextdata#1\stoptextdata + {\glet\page_shipouts_flush_text_data\page_shipouts_flush_text_data_indeed + \globaladdtotoks\t_page_text_data{#1}} + +\aliased\let\stoptextdata\relax + +\def\page_shipouts_flush_text_data_indeed + {\vsmashed{\the\t_page_text_data}% + \global\t_page_text_data\emptytoks + \glet\page_shipouts_flush_text_data\relax} + +\let\page_shipouts_flush_text_data\relax + +\prependtoks + \page_shipouts_flush_text_data +\to \everylastshipout + +%D Problem: we need to apply the finalizers to a to be shipped out page (as we can +%D have positioning involved). However, we can also add stuff in the imposition, +%D like cropmarks. Fortunately we do that with metapost so colors etc are dealt with +%D at that end. + +% \starttypen +% \def\pagestoshipout{1,3,5} +% \stoptypen + +\installcorenamespace{shipoutmethod} +\installcorenamespace{layoutarranger} +\installcorenamespace{layoutarrangeoption} + +\newcount \shippedoutpages +\newcount \combinedpagescounter +\newconstant \whichpagetoshipout % 0=all 1=odd 2=even +\newbox \shipoutscratchbox +\setnewconstant\shipoutfinalizemethod\plusone + +\mutable\let\pagestoshipout\empty % {1,3,6} + +\permanent\protected\def\shipoutrange#1#2% + {\begingroup + \scratchtoks\emptytoks + \dostepwiserecurse{#1}{\numexpr#2-\plusone\relax}\plusone{\etoksapp\scratchtoks{##1,}}% + \xdef\pagestoshipout{\the\scratchtoks,\number#2}% + \doglobal\appendtoks + \ifnum\realpageno>\numexpr#2+\plusone\relax + \global\everypar{\normalend}% + \fi + \to\everyaftershipout + \endgroup} + +\permanent\protected\def\installshipoutmethod#1#2% % a handler takes one argument: something to be boxed + {\setgvalue{\??shipoutmethod#1}##1{#2{##1}}} % and shipped out (don't depend on the exact package) + +\aliased\let\installpagehandler\installshipoutmethod % will go + +\permanent\protected\def\invokepagehandler#1% + {\expandnamespacevalue\??shipoutmethod{#1}\v!normal} + +\def\page_shipouts_handle + {\ifcsname\??shipoutmethod\v_page_target_method\endcsname + \expandafter\lastnamedcs + \else + \expandafter\page_shipouts_ignore + \fi} + +\installshipoutmethod \v!normal + {\ifarrangingpages + \expandafter\page_shipouts_arrange + \else + \expandafter\page_shipouts_normal + \fi} + +\installshipoutmethod \v!none + {\page_shipouts_ignore} + +% extension mechanism + +\newcount\c_page_boxes_flush_n % set at the lua end + +\let\page_boxes_flush_before\relax +\let\page_boxes_flush_after \relax + +% used here: + +\def\page_boxes_shipout#1% or: \page_shipouts_apply + {\dontcomplain % redundant + \ifcase\c_page_boxes_flush_n\else + \page_boxes_flush_before + \fi + \the\everybeforeshipout + \ifcase\shipoutfinalizemethod % not nice ... needs thinking + \page_shipouts_handle{#1}% + \else + \setbox\shipoutscratchbox\hpack + {#1}% just in case there are objects there, hook for testing (will go away) + \page_shipouts_handle + {\finalizeshipoutbox\shipoutscratchbox + \box\shipoutscratchbox}% + \fi + \setnextrealpageno % so this comes before \everyaftershipout so in fact: + \the\everyaftershipout % at this point we're already on the next realpage + \ifcase\c_page_boxes_flush_n\else + \page_boxes_flush_after + \fi} + +\def\page_shipouts_ignore#1% + {\begingroup + \writestatus\m!system + {\ifarrangingpages arranged \fi page + \ifarrangingpages\the\arrangeno\else\the\realpageno\fi\normalspace + not flushed}% + % \setbox\scratchbox\hpack + % {#1}% no finalize + \deadcycles\zerocount + \endgroup} + +\def\page_otr_flush_every_stuff + {\begingroup + \setbox\scratchbox\hpack + {% before the main one ! + \ifcase\realfolio \or + \the\everyfirstshipout + \global\everyfirstshipout\emptytoks + \fi + % the main one + \the\everyshipout\relax + % always last (and after the main one) + \ifnum\realpageno=\lastpage\relax + \the\everylastshipout + \global\everylastshipout\emptytoks + \fi}% + \smashbox\scratchbox + \box\scratchbox + \endgroup} + +%D Also in normal \MKIV\ we nos use the indirect way so that we benefit from timing +%D and tracing. + +\def\page_shipout_show_box{\showbox diagnose} + +\protected\def\page_shipout_box#1% + {\ifcase\tracingoutput\else + \page_shipout_show_box#1\relax + \fi + \clf_shipoutpage#1\relax + \global\setbox#1\emptybox + \global\deadcycles\zerocount} + +\def\page_shipouts_normal#1% + {\global\advance\shippedoutpages\plusone + % this is not resource safe! + \ifx\pagestoshipout\empty + \ifcase\whichpagetoshipout\relax + \donetrue + \or % 1 + \ifodd\shippedoutpages\relax\donetrue\else\donefalse\fi + \or % 2 + \ifodd\shippedoutpages\relax\donefalse\else\donetrue\fi + \else + \donetrue + \fi + \else % testen, aangepast / expanded nodig ? + \normalexpanded{\doifelseinset{\the\shippedoutpages}{\pagestoshipout}}\donetrue\donefalse + \fi + \ifdone + \setbox\shipoutscratchbox\hpack + {#1}% finalizes + \ifcase\shipoutfinalizemethod + \finalizeshipoutbox\shipoutscratchbox + \fi + \setbox\shipoutscratchbox\vpack + {\scratchdimen\clf_shipoutoffset\relax + \ifdim\scratchdimen=\zeropoint\else + \offinterlineskip + \vkern\scratchdimen + \hkern\scratchdimen + \fi + \hpack + {\page_otr_flush_every_stuff + \page_otr_flush_special_content + \box\shipoutscratchbox}}% + \page_shipout_box\shipoutscratchbox % takes a box number! + \else + \page_shipouts_ignore{#1}% + \fi} + +\newconditional\c_page_shipouts_use_objects \settrue\c_page_shipouts_use_objects + +\installcorenamespace {arrangedpage} + +\def\page_shipouts_arrange#1% + {\begingroup + \setbox\shipoutscratchbox\hpack + {#1}% finalizes + \setbox\shipoutscratchbox\hpack + {\page_otr_flush_every_stuff + \page_otr_flush_special_content + \box\shipoutscratchbox}% + % + \ifconditional\c_page_shipouts_use_objects + \setobject\??arrangedpage{\the\realpageno}\hpack{\box\shipoutscratchbox}% + \setbox\shipoutscratchbox\hpack{\getobject\??arrangedpage{\the\realpageno}}% + \fi + % + \pusharrangedpage\shipoutscratchbox + \deadcycles\zerocount + \endgroup} + +%D We need a couple of boxes for duplex printing \unknown + +\newbox\arrangedpageA \newbox\arrangedpageB +\newbox\arrangedpageC \newbox\arrangedpageD +\newbox\arrangedpageE \newbox\arrangedpageF +\newbox\arrangedpageG \newbox\arrangedpageH + +\newconditional\arrangedswapstate +\newconditional\arrangednegatestate +\newconditional\arrangedmirrorstate +\newconditional\arrangeddoublestate +\newconditional\arrangingdisabledstate +\newconditional\arrangedbackgroundstate + +\mutable\def\arrangedrotationO{0} +\mutable\def\arrangedrotationE{0} + +\newcount\arrangedpageN +\newcount\arrangedpageM + +\newcount\arrangedpageT \arrangedpageT\plusone +\newcount\arrangedpageX \arrangedpageX\plusone +\newcount\arrangedpageY \arrangedpageY\plusone + +\def\page_paper_set_offsets + {\global\paperoffset\v_page_target_offset + \global\advance\paperwidth -2\dimexpr\paperoffset/\arrangedpageX\relax + \global\advance\paperheight-2\dimexpr\paperoffset/\arrangedpageY\relax} + +\permanent\protected\def\doinstallarrangedoption#1#2% + {\setvalue{\??layoutarrangeoption#1}{#2}} + +\permanent\def\doinstalledarrangedoption#1% + {\ifcsname\??layoutarrangeoption#1\endcsname + \lastnamedcs + \else + \checkinstalledpagearrangement{#1}% this installs the arranger + \fi} + +\doinstallarrangedoption\empty + {} % no default and check if empty, we can have ,,, + +\doinstallarrangedoption\v!disable + {\global\settrue\arrangingdisabledstate} + +\doinstallarrangedoption\v!mirrored + {\global\settrue\arrangedmirrorstate} + +\doinstallarrangedoption\v!doublesided + {\global\settrue\arrangeddoublestate} + +\doinstallarrangedoption\v!negative + {\global\settrue\arrangednegatestate} + +\doinstallarrangedoption\v!rotated + {\gdef\arrangedrotationO {90}% + \gdef\arrangedrotationE{270}% + \swapcounts\c_page_marks_nx\c_page_marks_ny} + +\doinstallarrangedoption{90} + {\gdef\arrangedrotationO {90}% + \gdef\arrangedrotationE{270}% + \swapcounts\c_page_marks_nx\c_page_marks_ny} + +\doinstallarrangedoption{180} + {\gdef\arrangedrotationO{180}% + \gdef\arrangedrotationE {0}} + +\doinstallarrangedoption{270} + {\gdef\arrangedrotationO{270}% + \gdef\arrangedrotationE {90}% + \swapcounts\c_page_marks_nx\c_page_marks_ny} + +\doinstallarrangedoption\s!reset + {\global\arrangingpagesfalse} + +\doinstallarrangedoption\v!background + {\global\settrue\arrangedbackgroundstate} + +\permanent\protected\def\setuparranging[#1]% + {\ifconditional\arrangingdisabledstate \else + %global\setfalse\arrangingdisabledstate + \global\arrangingpagestrue % will be conditional + \global\setfalse\arrangednegatestate + \global\setfalse\arrangedmirrorstate + \global\setfalse\arrangeddoublestate + \global\setfalse\arrangedswapstate + \gdef\arrangedrotationO{0}% + \gdef\arrangedrotationE{180}% + \processcommalist[#1]\doinstalledarrangedoption + \ifdefined\handlearrangedpage\else + \global\arrangingpagesfalse + \fi + \setuppapersize + \ifarrangingpages + \ifconditional\c_page_shipouts_use_objects\else + \clf_disablejobsave + \clf_synctexdisable + %\disabledirective[job.save]% + \fi + \fi + \fi} + +\permanent\protected\def\installpagearrangement #1 % will change, no space + {\setgvalue{\??layoutarranger#1}} + +\permanent\def\checkinstalledpagearrangement#1% can be empty: aaa,,bbb + {\begincsname\??layoutarranger#1\endcsname} + +\aliased\let\poparrangedpages \relax +\aliased\let\pusharrangedpage \relax +\aliased\let\handlearrangedpage\relax + +\permanent\protected\def\dosetuparrangement#1#2#3#4#5#6#7#8% + {\global\arrangedpageX #1% + \global\arrangedpageY #2% + \global\arrangedpageT #3% + \global\c_page_marks_nx#4% + \global\c_page_marks_ny#5% + \enforced\permanent\glet\pusharrangedpage #6% + \enforced\permanent\glet\poparrangedpages #7% + \enforced\permanent\glet\handlearrangedpage#8} + +\installpagearrangement {\v!normal} + {\global\arrangingpagesfalse} + +%D (WS:) Watch out with 2UP and A4/A5: +%D +%D \definepapersize [A4] [width=210mm,height=297mm] +%D \definepapersize [A5] [width=148mm,height=210mm] +%D +%D 297 mm - 2 * 148 mm = 1 mm +%D +%D This is only visible when we have a full background. + +\installpagearrangement 2*16 + {\dosetuparrangement{4}{4}{16}{5}{5}% + \pusharrangedpageTHIRTYTWO\poparrangedpagesAB\relax} + +\installpagearrangement 2*8 + {\dosetuparrangement{4}{2}{8}{5}{3}% + \pusharrangedpageSIXTEEN\poparrangedpagesAB\relax} + +\installpagearrangement 2*4 + {\dosetuparrangement{2}{2}{4}{3}{3}% + \pusharrangedpageEIGHT\poparrangedpagesAB\relax} + +\installpagearrangement 2*2 + {\dosetuparrangement{2}{1}{2}{3}{2}% + \pusharrangedpageFOURA\poparrangedpagesAB\relax} + +\installpagearrangement 2**2 + {\dosetuparrangement{2}{1}{2}{3}{2}% + \pusharrangedpageFOURB\poparrangedpagesAB\relax} + +\installpagearrangement 2SIDE + {\dosetuparrangement{2}{1}{2}{3}{2}% + \pusharrangedpageSIDETOP\poparrangedpagesTWO\handlearrangedpageSIDE} + +\installpagearrangement 2TOP + {\dosetuparrangement{1}{2}{2}{2}{3}% + \pusharrangedpageSIDETOP\poparrangedpagesTWO\handlearrangedpageTOP} + +\installpagearrangement 2UP + {\dosetuparrangement{2}{1}{4}{3}{2}% + \pusharrangedpageTWO\poparrangedpagesTWO\handlearrangedpageTWOUP} + +\installpagearrangement 2DOWN + {\dosetuparrangement{1}{2}{4}{2}{3}% + \pusharrangedpageTWO\poparrangedpagesTWO\handlearrangedpageTWODOWN} + +\installpagearrangement 2*4*2 % one defined by Willy Egger: + {\dosetuparrangement{2}{2}{4}{3}{3}% + \pusharrangedpageSIXTEENTWO\poparrangedpagesAtoD\relax} + +\installpagearrangement 2*2*4 % another one of Willy Egger + {\dosetuparrangement{2}{1}{8}{3}{2}% + \pusharrangedpageSIXTEENFOUR\poparrangedpagesAtoH\relax} + +\installpagearrangement 2TOPSIDE + {\dosetuparrangement{1}{2}{4}{2}{3}% + \pusharrangedpageTWOTOPSIDE\poparrangedpagesTWOTOPSIDE\handlearrangedpageTOP} + +\permanent\protected\def\filluparrangedpages % beware: \realpageno is 1 ahead + {\ifarrangingpages + \scratchcounter\numexpr\realpageno-\plusone\relax + \dosetmodulo\scratchcounter\arrangedpageT\scratchcounter + \ifcase\scratchcounter\else + \advance\scratchcounter \plusone + \dostepwiserecurse\scratchcounter\arrangedpageT\plusone + {\noheaderandfooterlines\page_otr_insert_dummy_page}% + \fi + \fi} + +\permanent\protected\def\handlearrangedpageXandY#1#2#3#4#5% + {\global\setbox#5\hpack to \arrangedpageX\paperwidth + {\setbox\scratchbox\vpack to \arrangedpageY\paperheight + {\offinterlineskip + \vskip#4\paperheight + \hskip#3\paperwidth + \dorotatebox{\ifcase#2 0\else180\fi}\hpack{\box#1}% + \vfill}% + \wd\scratchbox\zeropoint + \box\scratchbox\box#5\hss}} + +\permanent\protected\def\gotonextarrangepage + {\global\advance\arrangeno \plusone + \def\pagecutmarksymbol{\the\arrangeno}} + +\permanent\protected\def\outputarrangedbox#1% + {\begingroup + \forgetall % somehow we're back and need to redo this + \dontcomplain + \gotonextarrangepage + \ifnum\arrangedrotationO\arrangedrotationE>\zerocount + \setbox#1\vpack + {\ifconditional\arrangeddoublestate + \ifodd\arrangeno + \dorotatebox\arrangedrotationO\hpack{\box#1}% + \else + \dorotatebox\arrangedrotationE\hpack{\box#1}% + \fi + \else + \dorotatebox\arrangedrotationO\hpack{\box#1}% + \fi}% + \fi + \ifconditional\arrangedmirrorstate + \page_boxes_apply_mirror{#1}% + \fi + \ifconditional\arrangednegatestate + \page_boxes_apply_negate{#1}% + \fi + \page_marks_add_more #1% + \page_boxes_apply_center #1% + \page_boxes_apply_mirror_print #1% + \page_boxes_apply_orientate_print#1% + \page_boxes_apply_offset #1% + \page_boxes_apply_negate_print #1% + % + \ifconditional\arrangedbackgroundstate + \page_backgrounds_add_to_print#1% + \fi + % + \page_shipouts_normal{\box#1}% + \endgroup} + +%D The format file can be 16K smaller when we postpone the +%D real arrangments. Some day ... + +\permanent\protected\def\reportarrangedpage#1% + {\showmessage\m!system{23}{\the\realpageno.\the\pageno\ifnum\subpageno>0 .\the\subpageno\fi,\number#1}} + +\permanent\protected\def\advancearrangedpageN + {\global\advance\arrangedpageN\plusone} + +% TOP + +% 32/16/8/4/SIDE + +\permanent\protected\def\poparrangedpagesAB + {\ifnum\arrangedpageN>\zerocount + \paperwidth\arrangedpageX\paperwidth + \paperheight\arrangedpageY\paperheight + \outputarrangedbox\arrangedpageA + \outputarrangedbox\arrangedpageB + \global\arrangedpageN\zerocount + \fi} + +\permanent\protected\def\pusharrangedpageTHIRTYTWO#1% taco's challenge + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}033\arrangedpageA % 1 + \or \handlearrangedpageXandY{#1}003\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}100\arrangedpageB % 3 + \or \handlearrangedpageXandY{#1}130\arrangedpageA % 4 + \or \handlearrangedpageXandY{#1}100\arrangedpageA % 5 + \or \handlearrangedpageXandY{#1}130\arrangedpageB % 6 + \or \handlearrangedpageXandY{#1}033\arrangedpageB % 7 + \or \handlearrangedpageXandY{#1}003\arrangedpageA % 8 + \or \handlearrangedpageXandY{#1}102\arrangedpageA % 9 + \or \handlearrangedpageXandY{#1}132\arrangedpageB % 10 + \or \handlearrangedpageXandY{#1}031\arrangedpageB % 11 + \or \handlearrangedpageXandY{#1}001\arrangedpageA % 12 + \or \handlearrangedpageXandY{#1}031\arrangedpageA % 13 + \or \handlearrangedpageXandY{#1}001\arrangedpageB % 14 + \or \handlearrangedpageXandY{#1}102\arrangedpageB % 15 + \or \handlearrangedpageXandY{#1}132\arrangedpageA % 16 + \or \handlearrangedpageXandY{#1}122\arrangedpageA % 17 + \or \handlearrangedpageXandY{#1}112\arrangedpageB % 18 + \or \handlearrangedpageXandY{#1}011\arrangedpageB % 19 + \or \handlearrangedpageXandY{#1}021\arrangedpageA % 20 + \or \handlearrangedpageXandY{#1}011\arrangedpageA % 21 + \or \handlearrangedpageXandY{#1}021\arrangedpageB % 22 + \or \handlearrangedpageXandY{#1}122\arrangedpageB % 23 + \or \handlearrangedpageXandY{#1}112\arrangedpageA % 24 + \or \handlearrangedpageXandY{#1}013\arrangedpageA % 25 + \or \handlearrangedpageXandY{#1}023\arrangedpageB % 26 + \or \handlearrangedpageXandY{#1}120\arrangedpageB % 27 + \or \handlearrangedpageXandY{#1}110\arrangedpageA % 28 + \or \handlearrangedpageXandY{#1}120\arrangedpageA % 29 + \or \handlearrangedpageXandY{#1}110\arrangedpageB % 30 + \or \handlearrangedpageXandY{#1}013\arrangedpageB % 31 + \or \handlearrangedpageXandY{#1}023\arrangedpageA % 32 + \poparrangedpages + \fi} + +\permanent\protected\def\pusharrangedpageSIXTEEN#1% changed to match the official way of doing + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}031\arrangedpageA % 1 + \or \handlearrangedpageXandY{#1}001\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}031\arrangedpageB % 3 + \or \handlearrangedpageXandY{#1}001\arrangedpageA % 4 + \or \handlearrangedpageXandY{#1}100\arrangedpageA % 5 + \or \handlearrangedpageXandY{#1}130\arrangedpageB % 6 + \or \handlearrangedpageXandY{#1}100\arrangedpageB % 7 + \or \handlearrangedpageXandY{#1}130\arrangedpageA % 8 + \or \handlearrangedpageXandY{#1}120\arrangedpageA % 9 + \or \handlearrangedpageXandY{#1}110\arrangedpageB % 10 + \or \handlearrangedpageXandY{#1}120\arrangedpageB % 11 + \or \handlearrangedpageXandY{#1}110\arrangedpageA % 12 + \or \handlearrangedpageXandY{#1}011\arrangedpageA % 13 + \or \handlearrangedpageXandY{#1}021\arrangedpageB % 14 + \or \handlearrangedpageXandY{#1}011\arrangedpageB % 15 + \or \handlearrangedpageXandY{#1}021\arrangedpageA % 16 + \poparrangedpages + \fi} + +\permanent\protected\def\pusharrangedpageEIGHT#1% changed to match the official way of doing + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}011\arrangedpageA % 1 + \or \handlearrangedpageXandY{#1}001\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}100\arrangedpageB % 3 + \or \handlearrangedpageXandY{#1}110\arrangedpageA % 4 + \or \handlearrangedpageXandY{#1}100\arrangedpageA % 5 + \or \handlearrangedpageXandY{#1}110\arrangedpageB % 6 + \or \handlearrangedpageXandY{#1}011\arrangedpageB % 7 + \or \handlearrangedpageXandY{#1}001\arrangedpageA % 8 + \poparrangedpages + \fi} + +\permanent\protected\def\pusharrangedpageFOURA{\pusharrangedpageFOURdo01} +\permanent\protected\def\pusharrangedpageFOURB{\pusharrangedpageFOURdo10} + +\permanent\protected\def\pusharrangedpageFOURdo#1#2#3% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#3}010\arrangedpageA % 1 + \or \handlearrangedpageXandY{#3}0{#1}0\arrangedpageB % 2/3 not {1} + \or \handlearrangedpageXandY{#3}0{#2}0\arrangedpageB % 3/2 not {1} + \or \handlearrangedpageXandY{#3}000\arrangedpageA % 4 + \poparrangedpages + \fi} + +\permanent\protected\def\pusharrangedpageSIDETOP#1% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 1 + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 2 + \poparrangedpages + \fi} + +\permanent\protected\def\handlearrangedpageSIDE + {\wd\arrangedpageA\paperwidth + \wd\arrangedpageB\paperwidth + \global\setbox\arrangedpageA\hpack + {\box\arrangedpageA\box\arrangedpageB}% + \ht\arrangedpageA\paperheight} + +\permanent\protected\def\handlearrangedpageTOP + {\ht\arrangedpageA\paperheight + \ht\arrangedpageB\paperheight + \global\setbox\arrangedpageA\vpack + {\offinterlineskip\vskip\paperheight + \box\arrangedpageA\box\arrangedpageB}% + \global\setbox\arrangedpageB\box\scratchbox} % ? + +% 2UP/2DOWN / 1pt prevents overflow + +\permanent\protected\def\splitoffarrangedpagesTWO + {\splittopskip\zeropoint + \global\setbox\arrangedpageA\vsplit\arrangedpageB to \onepoint + \scratchdimen\dimexpr\ht\arrangedpageB-\onepoint\relax + \ifdim\scratchdimen>\onepoint + \setbox\scratchbox\vsplit\arrangedpageB to \scratchdimen + \fi} + +\permanent\protected\def\handlearrangedpageTWOUP + {\splitoffarrangedpagesTWO + \ht\arrangedpageA\paperheight + \ht\arrangedpageB\paperheight + \ifconditional\arrangedswapstate + \global\setbox\arrangedpageA\hpack + {\page_boxes_apply_clip_print_left \arrangedpageA + \box\arrangedpageA + \page_boxes_apply_clip_print_right\arrangedpageB + \box\arrangedpageB}% + \setfalse\arrangedswapstate + \else + \global\setbox\arrangedpageA\hpack + {\page_boxes_apply_clip_print_left \arrangedpageB + \box\arrangedpageB + \page_boxes_apply_clip_print_right\arrangedpageA + \box\arrangedpageA}% + \settrue\arrangedswapstate + \fi + \global\setbox\arrangedpageB\box\scratchbox} + +\permanent\protected\def\handlearrangedpageTWODOWN + {\splitoffarrangedpagesTWO + \ht\arrangedpageA\paperheight + \ht\arrangedpageB\paperheight + \ifconditional\arrangedswapstate + \global\setbox\arrangedpageA\vpack + {\offinterlineskip + \vskip\paperheight + \box\arrangedpageA + \box\arrangedpageB}% + \setfalse\arrangedswapstate + \else + \global\setbox\arrangedpageA\vpack + {\offinterlineskip + \vskip\paperheight + \box\arrangedpageB + \box\arrangedpageA}% + \settrue\arrangedswapstate + \fi + \global\setbox\arrangedpageB\box\scratchbox} + +\permanent\protected\def\poparrangedpagesTWO + {\ifnum\arrangedpageN>\zerocount + \setfalse\arrangedswapstate + \doloop + {\handlearrangedpage + \bgroup + \paperwidth \arrangedpageX\paperwidth + \paperheight\arrangedpageY\paperheight + \ht\arrangedpageA\paperheight + \wd\arrangedpageA\paperwidth + \outputarrangedbox\arrangedpageA + \egroup + \ifdim\ht\arrangedpageB=\zeropoint + \exitloop + \fi}% + \global\arrangedpageN\zerocount + \fi} + +\permanent\protected\def\pusharrangedpageTWO#1% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \global\setbox\arrangedpageB\vpack + {\offinterlineskip + \unvbox\arrangedpageB + \allowbreak + \setbox#1\vpack{\box#1}% really needed in order to keep real dimensions + \ht#1\onepoint + \dp#1\zeropoint + \vpack{\box#1}}} + +\permanent\protected\def\poparrangedpagesTWOTOPSIDE + {\ifnum\arrangedpageN>\zerocount + \bgroup + \global\arrangedpageN\plustwo + \poparrangedpagesTWO + \let\arrangedpageA\arrangedpageC + \let\arrangedpageB\arrangedpageD + \global\arrangedpageN\plustwo + \poparrangedpagesTWO + \global\arrangedpageN\zerocount + \egroup + \fi} + +\permanent\protected\def\pusharrangedpageTWOTOPSIDE#1% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 1 + \or \handlearrangedpageXandY{#1}000\arrangedpageC % 2 + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 1 + \or \handlearrangedpageXandY{#1}000\arrangedpageD % 2 + \poparrangedpages + \fi} + +%D Willy Egger's sheet simulations: + +\permanent\protected\def\poparrangedpagesAtoH + {\ifnum\arrangedpageN>\zerocount + \paperwidth \arrangedpageX\paperwidth + \paperheight\arrangedpageY\paperheight + \outputarrangedbox\arrangedpageA + \outputarrangedbox\arrangedpageB + \outputarrangedbox\arrangedpageC + \outputarrangedbox\arrangedpageD + \outputarrangedbox\arrangedpageE + \outputarrangedbox\arrangedpageF + \outputarrangedbox\arrangedpageG + \outputarrangedbox\arrangedpageH + \global\arrangedpageN\zerocount + \fi} + +% to arrange 16 pages on 2 sheets to form one booklet + +\permanent\protected\def\poparrangedpagesAtoD + {\ifnum\arrangedpageN>\zerocount + \paperwidth\arrangedpageX\paperwidth + \paperheight\arrangedpageY\paperheight + \outputarrangedbox\arrangedpageA + \outputarrangedbox\arrangedpageB + \outputarrangedbox\arrangedpageC + \outputarrangedbox\arrangedpageD + \global\arrangedpageN\zerocount + \fi} + +% to arrange 16 pages on 4 sheets to form one booklet + +\permanent\protected\def\pusharrangedpageSIXTEENFOUR#1% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}010\arrangedpageA % 1 + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}010\arrangedpageC % 3 + \or \handlearrangedpageXandY{#1}000\arrangedpageD % 4 + \or \handlearrangedpageXandY{#1}010\arrangedpageE % 5 + \or \handlearrangedpageXandY{#1}000\arrangedpageF % 6 + \or \handlearrangedpageXandY{#1}010\arrangedpageG % 7 + \or \handlearrangedpageXandY{#1}000\arrangedpageH % 8 + \or \handlearrangedpageXandY{#1}010\arrangedpageH % 9 + \or \handlearrangedpageXandY{#1}000\arrangedpageG % 10 + \or \handlearrangedpageXandY{#1}010\arrangedpageF % 11 + \or \handlearrangedpageXandY{#1}000\arrangedpageE % 12 + \or \handlearrangedpageXandY{#1}010\arrangedpageD % 13 + \or \handlearrangedpageXandY{#1}000\arrangedpageC % 14 + \or \handlearrangedpageXandY{#1}010\arrangedpageB % 15 + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 16 + \poparrangedpages + \fi} + +% to arrange 16 pages on 2 sheets to form one booklet + +\permanent\protected\def\pusharrangedpageSIXTEENTWO#1% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}011\arrangedpageA % 1 + \or \handlearrangedpageXandY{#1}001\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}011\arrangedpageC % 3 + \or \handlearrangedpageXandY{#1}001\arrangedpageD % 4 + \or \handlearrangedpageXandY{#1}100\arrangedpageD % 5 + \or \handlearrangedpageXandY{#1}110\arrangedpageC % 6 + \or \handlearrangedpageXandY{#1}100\arrangedpageB % 7 + \or \handlearrangedpageXandY{#1}110\arrangedpageA % 8 + \or \handlearrangedpageXandY{#1}100\arrangedpageA % 9 + \or \handlearrangedpageXandY{#1}110\arrangedpageB % 10 + \or \handlearrangedpageXandY{#1}100\arrangedpageC % 11 + \or \handlearrangedpageXandY{#1}110\arrangedpageD % 12 + \or \handlearrangedpageXandY{#1}011\arrangedpageD % 13 + \or \handlearrangedpageXandY{#1}001\arrangedpageC % 14 + \or \handlearrangedpageXandY{#1}011\arrangedpageB % 15 + \or \handlearrangedpageXandY{#1}001\arrangedpageA % 16 + \poparrangedpages + \fi} + +%D Might be used if a printer is printing from a roll or creating mini-books from A4: +%D This section has 16 pages. The folding scheme is first a Z-fold and at the end +%D a final fold in the spine. +%D Coding: [2*8*Z] + +\installpagearrangement 2*8*Z + {\dosetuparrangement{2}{4}{8}{3}{5}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageSIXTEENZ\poparrangedpagesAB\relax} + +\permanent\protected\def\pusharrangedpageSIXTEENZ#1% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}010\arrangedpageA % 1 + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}101\arrangedpageB % 3 + \or \handlearrangedpageXandY{#1}111\arrangedpageA % 4 + \or \handlearrangedpageXandY{#1}012\arrangedpageA % 5 + \or \handlearrangedpageXandY{#1}002\arrangedpageB % 6 + \or \handlearrangedpageXandY{#1}103\arrangedpageB % 7 + \or \handlearrangedpageXandY{#1}113\arrangedpageA % 8 + \or \handlearrangedpageXandY{#1}103\arrangedpageA % 9 + \or \handlearrangedpageXandY{#1}113\arrangedpageB % 10 + \or \handlearrangedpageXandY{#1}012\arrangedpageB % 11 + \or \handlearrangedpageXandY{#1}002\arrangedpageA % 12 + \or \handlearrangedpageXandY{#1}101\arrangedpageA % 13 + \or \handlearrangedpageXandY{#1}111\arrangedpageB % 14 + \or \handlearrangedpageXandY{#1}010\arrangedpageB % 15 + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 16 + \poparrangedpages + \fi} + +%D Another Z-folded section with 12 pages +%D Coding: [2*6*Z] + +\installpagearrangement 2*6*Z + {\dosetuparrangement{2}{3}{6}{3}{4}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageTWELVEZ\poparrangedpagesAB\relax} + +\permanent\protected\def\pusharrangedpageTWELVEZ#1% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}010\arrangedpageA % 1: rotation (0=upright),x (0=first column),y (0=first row) + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}101\arrangedpageB % 3 + \or \handlearrangedpageXandY{#1}111\arrangedpageA % 4 + \or \handlearrangedpageXandY{#1}012\arrangedpageA % 5 + \or \handlearrangedpageXandY{#1}002\arrangedpageB % 6 + \or \handlearrangedpageXandY{#1}012\arrangedpageB % 7 + \or \handlearrangedpageXandY{#1}002\arrangedpageA % 8 + \or \handlearrangedpageXandY{#1}101\arrangedpageA % 9 + \or \handlearrangedpageXandY{#1}111\arrangedpageB % 10 + \or \handlearrangedpageXandY{#1}010\arrangedpageB % 11 + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 12 + \poparrangedpages + \fi} + +%D For Heinz' special greeting cards folding. This scheme is also used for the PocketDiary (module): +%D Coding: [1*8] + +\installpagearrangement 1*8 + {\dosetuparrangement{4}{2}{8}{5}{3}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageEIGHTSINGLESIDEDFOLDED\poparrangedpagesTWO\relax} + +\permanent\protected\def\pusharrangedpageEIGHTSINGLESIDEDFOLDED#1% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}010\arrangedpageA % 1 rot,hskip,vskip + \or \handlearrangedpageXandY{#1}020\arrangedpageA % 2 + \or \handlearrangedpageXandY{#1}030\arrangedpageA % 3 + \or \handlearrangedpageXandY{#1}131\arrangedpageA % 4 + \or \handlearrangedpageXandY{#1}121\arrangedpageA % 5 + \or \handlearrangedpageXandY{#1}111\arrangedpageA % 6 + \or \handlearrangedpageXandY{#1}101\arrangedpageA % 7 + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 8 + \poparrangedpages + \fi} + +%D This is not a section. \CONTEXT\ places 4 pages on a sheet of paper, singlesided +%D Coding: [1*4] + +\installpagearrangement 1*4 + {\dosetuparrangement{2}{2}{4}{3}{3}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageFOURSINGLESIDEDFOLDED\poparrangedpagesTWO\relax} + +\permanent\protected\def\pusharrangedpageFOURSINGLESIDEDFOLDED#1% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}100\arrangedpageA % 1 rot,hskip,vskip + \or \handlearrangedpageXandY{#1}001\arrangedpageA % 2 + \or \handlearrangedpageXandY{#1}011\arrangedpageA % 3 + \or \handlearrangedpageXandY{#1}110\arrangedpageA % 4 + \poparrangedpages + \fi} + +%D This imposition scheme was requested by Hraban Ramm, by Willi Egger 21-07-2003 +%D Coding: [3SIDE] + +\installpagearrangement 3SIDE + {\dosetuparrangement{3}{1}{3}{4}{2}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageTHREESIDE\poparrangedpagesAB\relax} + +\permanent\protected\def\pusharrangedpageTHREESIDE#1% Willi's approach + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 1 rot,hskip,vskip + \or \handlearrangedpageXandY{#1}010\arrangedpageA % 2 + \or \handlearrangedpageXandY{#1}020\arrangedpageA % 3 + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 4 + \or \handlearrangedpageXandY{#1}010\arrangedpageB % 5 + \or \handlearrangedpageXandY{#1}020\arrangedpageB % 6 + \poparrangedpages + \fi} + +%D FLYER in three parts and 6 pages 22-10-2010 +%D Coding: [TRYPTICHON] + +\installpagearrangement TRYPTICHON + {\dosetuparrangement{3}{1}{3}{4}{2}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageFLYERSIX\poparrangedpagesAB\relax} + +\permanent\protected\def\pusharrangedpageFLYERSIX#1% Willi's approach + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}020\arrangedpageA % 1 rot,hskip,vskip + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}010\arrangedpageB % 3 + \or \handlearrangedpageXandY{#1}020\arrangedpageB % 4 + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 5 + \or \handlearrangedpageXandY{#1}010\arrangedpageA % 6 + \poparrangedpages + \fi} + +%D FLYER in Z-fold with 8 pages 22-01-2010 +%D Coding: [ZFLYER-8] + +\installpagearrangement ZFLYER-8 + {\dosetuparrangement{4}{1}{4}{5}{2}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageZFLYEREIGHT\poparrangedpagesAB\relax} + +\permanent\protected\def\pusharrangedpageZFLYEREIGHT#1% Willi's approach + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}030\arrangedpageA % 1 rot,hskip,vskip + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}010\arrangedpageB % 3 + \or \handlearrangedpageXandY{#1}020\arrangedpageB % 4 + \or \handlearrangedpageXandY{#1}030\arrangedpageB % 5 + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 6 + \or \handlearrangedpageXandY{#1}010\arrangedpageA % 7 + \or \handlearrangedpageXandY{#1}020\arrangedpageA % 8 + \poparrangedpages + \fi} + +%D FLYER in Z-fold with 10 pages 04-08-2010 +%D Coding: [ZFLYER-10] + +\installpagearrangement ZFLYER-10 + {\dosetuparrangement{5}{1}{5}{6}{2}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageZFLYERTEN\poparrangedpagesAB\relax} + +\permanent\protected\def\pusharrangedpageZFLYERTEN#1% Willi's approach + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}040\arrangedpageA % 1 rot,hskip,vskip + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}010\arrangedpageB % 3 + \or \handlearrangedpageXandY{#1}020\arrangedpageB % 4 + \or \handlearrangedpageXandY{#1}030\arrangedpageB % 5 + \or \handlearrangedpageXandY{#1}040\arrangedpageB % 6 + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 7 + \or \handlearrangedpageXandY{#1}010\arrangedpageA % 8 + \or \handlearrangedpageXandY{#1}020\arrangedpageA % 9 + \or \handlearrangedpageXandY{#1}030\arrangedpageA % 10 + \poparrangedpages + \fi} + +%D FLYER in Z-fold with 12 pages 04-08-2010 +%D Coding: [ZFLYER-12] + +\installpagearrangement ZFLYER-12 + {\dosetuparrangement{6}{1}{6}{7}{2}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageZFLYERTWELVE\poparrangedpagesAB\relax} + +\permanent\protected\def\pusharrangedpageZFLYERTWELVE#1% Willi's approach + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}050\arrangedpageA % 1 rot,hskip,vskip + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}010\arrangedpageB % 3 + \or \handlearrangedpageXandY{#1}020\arrangedpageB % 4 + \or \handlearrangedpageXandY{#1}030\arrangedpageB % 5 + \or \handlearrangedpageXandY{#1}040\arrangedpageB % 6 + \or \handlearrangedpageXandY{#1}050\arrangedpageB % 7 + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 8 + \or \handlearrangedpageXandY{#1}010\arrangedpageA % 9 + \or \handlearrangedpageXandY{#1}020\arrangedpageA % 10 + \or \handlearrangedpageXandY{#1}030\arrangedpageA % 11 + \or \handlearrangedpageXandY{#1}040\arrangedpageA % 12 + \poparrangedpages + \fi} + +%D FLYER folded as a map with 6 pages per side. +%D Coding: [MAPFLYER-12] + +\installpagearrangement MAPFLYER-12 + {\dosetuparrangement{3}{2}{6}{4}{3}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageMFLYERTWELVE\poparrangedpagesAB\relax} + +\permanent\protected\def\pusharrangedpageMFLYERTWELVE#1% Willi's approach + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}020\arrangedpageA % 1 rot,hskip,vskip + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}001\arrangedpageB % 3 + \or \handlearrangedpageXandY{#1}010\arrangedpageB % 4 + \or \handlearrangedpageXandY{#1}011\arrangedpageB % 5 + \or \handlearrangedpageXandY{#1}020\arrangedpageB % 6 + \or \handlearrangedpageXandY{#1}021\arrangedpageB % 7 + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 8 + \or \handlearrangedpageXandY{#1}001\arrangedpageA % 9 + \or \handlearrangedpageXandY{#1}010\arrangedpageA % 10 + \or \handlearrangedpageXandY{#1}011\arrangedpageA % 11 + \or \handlearrangedpageXandY{#1}021\arrangedpageA % 12 + \poparrangedpages + \fi} + +%D FLYER folded as double window with 4 pages per side. +%D Coding: [DOUBLEWINDOW] + +\installpagearrangement DOUBLEWINDOW + {\dosetuparrangement{4}{1}{4}{5}{2}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageDOUBLEWINDOWEIGHT\poparrangedpagesAB\relax} + +\permanent\protected\def\pusharrangedpageDOUBLEWINDOWEIGHT#1% Willi's approach + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}020\arrangedpageA % 1 rot,hskip,vskip + \or \handlearrangedpageXandY{#1}030\arrangedpageA % 2 + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 3 + \or \handlearrangedpageXandY{#1}010\arrangedpageB % 4 + \or \handlearrangedpageXandY{#1}020\arrangedpageB % 5 + \or \handlearrangedpageXandY{#1}030\arrangedpageB % 6 + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 7 + \or \handlearrangedpageXandY{#1}010\arrangedpageA % 8 + \poparrangedpages + \fi} + +%D Imposition as requested by Jan Pohanka 26-08-2010, 4 pages, two verso, two recto, +%D uneven pages upright and down, even pages top and rotated 180. +%D Implementation with 2 pages for conference-name-display +%D Coding: [1*2-Conference] + +\installpagearrangement 1*2-Conference + {\dosetuparrangement{1}{2}{4}{3}{2}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageCONFERENCETWO\poparrangedpagesAB\relax} + +\permanent\protected\def\pusharrangedpageCONFERENCETWO#1% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}001\arrangedpageA % 1 rot,hskip,vskip + \or \handlearrangedpageXandY{#1}100\arrangedpageA % 2 + \poparrangedpages + \fi} + +%D Implementation with 4 pages for conference-name-display +%D Coding: [1*4-Conference] + +\installpagearrangement 1*4-Conference + {\dosetuparrangement{1}{2}{4}{3}{2}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageCONFERENCEFOUR\poparrangedpagesAB\relax} + +\permanent\protected\def\pusharrangedpageCONFERENCEFOUR#1% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}001\arrangedpageA % 1 rot,hskip,vskip + \or \handlearrangedpageXandY{#1}100\arrangedpageA % 2 + \or \handlearrangedpageXandY{#1}011\arrangedpageB % 3 + \or \handlearrangedpageXandY{#1}110\arrangedpageB % 4 + \poparrangedpages + \fi} + +%D There should be arrangements for sections made of heavy and thick paper. i.e. the heavier the paper +%D the fewer pages per section: +%D Section with 8 pages put on two sheets of paper. Each sheet carries recto 2 and verso 2 pages. +%D Coding: [2*2*2] + +\installpagearrangement 2*2*2 + {\dosetuparrangement{2}{1}{2}{3}{2}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageEIGHTTWO\poparrangedpagesAtoD\relax} + +\permanent\protected\def\pusharrangedpageEIGHTTWO#1% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}010\arrangedpageA % 1 rot,hskip,vskip + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}010\arrangedpageC % 3 + \or \handlearrangedpageXandY{#1}000\arrangedpageD % 4 + \or \handlearrangedpageXandY{#1}010\arrangedpageD % 5 + \or \handlearrangedpageXandY{#1}000\arrangedpageC % 6 + \or \handlearrangedpageXandY{#1}010\arrangedpageB % 7 + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 8 + \poparrangedpages + \fi} + +%D Section with 12 pages, built from three sheets of paper. +%D Each sheet carries 2 pages recto and verso. +%D Coding: [2*2*3] + +\permanent\protected\def\poparrangedpagesAtoF + {\ifnum\arrangedpageN>\zerocount + \paperwidth \arrangedpageX\paperwidth + \paperheight\arrangedpageY\paperheight + \outputarrangedbox\arrangedpageA + \outputarrangedbox\arrangedpageB + \outputarrangedbox\arrangedpageC + \outputarrangedbox\arrangedpageD + \outputarrangedbox\arrangedpageE + \outputarrangedbox\arrangedpageF + \global\arrangedpageN\zerocount + \fi} + +\installpagearrangement 2*2*3 + {\dosetuparrangement{2}{1}{2}{3}{2}% X,Y,Total,hcutmarks,vcutmarks + \pusharrangedpageTWELVETWO\poparrangedpagesAtoF\relax} + +\permanent\protected\def\pusharrangedpageTWELVETWO#1% + {\advancearrangedpageN + \reportarrangedpage\arrangedpageN + \ifcase\arrangedpageN + \or \handlearrangedpageXandY{#1}010\arrangedpageA % 1 rot,hskip,vskip + \or \handlearrangedpageXandY{#1}000\arrangedpageB % 2 + \or \handlearrangedpageXandY{#1}010\arrangedpageC % 3 + \or \handlearrangedpageXandY{#1}000\arrangedpageD % 4 + \or \handlearrangedpageXandY{#1}010\arrangedpageE % 5 + \or \handlearrangedpageXandY{#1}000\arrangedpageF % 6 + \or \handlearrangedpageXandY{#1}010\arrangedpageF % 7 + \or \handlearrangedpageXandY{#1}000\arrangedpageE % 8 + \or \handlearrangedpageXandY{#1}010\arrangedpageD % 9 + \or \handlearrangedpageXandY{#1}000\arrangedpageC % 10 + \or \handlearrangedpageXandY{#1}010\arrangedpageB % 11 + \or \handlearrangedpageXandY{#1}000\arrangedpageA % 12 + \poparrangedpages + \fi} + +% % From Wolfgang for Mari (mail on list) ... yes or no in core .. time for +% % delayed loading ... +% % +% % http://stamphenge.wordpress.com/minibooks/meander-accordion-folded-book/ +% +% \installpagearrangement MEANDER16 +% {\dosetuparrangement{4}{4}{16}{5}{5}% +% \pusharrangedpageMEANDERSIXTEEN\poparrangedpagesXY\relax} +% +% \permanent\protected\def\pusharrangedpageMEANDERSIXTEEN#1% +% {\advancearrangedpageN +% \reportarrangedpage\arrangedpageN +% \ifcase\arrangedpageN +% \or \handlearrangedpageXandY{#1}000\arrangedpageA +% \or \handlearrangedpageXandY{#1}010\arrangedpageA +% \or \handlearrangedpageXandY{#1}020\arrangedpageA +% \or \handlearrangedpageXandY{#1}030\arrangedpageA +% \or \handlearrangedpageXandY{#1}131\arrangedpageA +% \or \handlearrangedpageXandY{#1}121\arrangedpageA +% \or \handlearrangedpageXandY{#1}111\arrangedpageA +% \or \handlearrangedpageXandY{#1}101\arrangedpageA +% \or \handlearrangedpageXandY{#1}002\arrangedpageA +% \or \handlearrangedpageXandY{#1}012\arrangedpageA +% \or \handlearrangedpageXandY{#1}022\arrangedpageA +% \or \handlearrangedpageXandY{#1}032\arrangedpageA +% \or \handlearrangedpageXandY{#1}133\arrangedpageA +% \or \handlearrangedpageXandY{#1}123\arrangedpageA +% \or \handlearrangedpageXandY{#1}113\arrangedpageA +% \or \handlearrangedpageXandY{#1}103\arrangedpageA +% \poparrangedpages +% \fi} +% +% % \definepapersize[small][width=6cm,height=6cm] +% % \definepapersize[big][width=30cm,height=30cm] +% % \setuppapersize[small][big] +% % \setuppagenumbering[location=] +% % \setuparranging[MEANDER16] +% % \setuplayout +% % [location=middle, +% % marking=on] +% % \starttext +% % \dorecurse{32}{\centerbox{\ssd\recurselevel}} +% % \stoptext +% +% % By Willi: +% +% \installpagearrangement MEANDER9 +% {\dosetuparrangement{3}{3}{9}{4}{4}% +% \pusharrangedpageMEANDERNINE\poparrangedpagesXY\relax} +% +% \permanent\protected\def\pusharrangedpageMEANDERNINE#1% +% {\advancearrangedpageN +% \reportarrangedpage\arrangedpageN +% \ifcase\arrangedpageN +% \or \handlearrangedpageXandY{#1}000\arrangedpageA +% \or \handlearrangedpageXandY{#1}010\arrangedpageA +% \or \handlearrangedpageXandY{#1}020\arrangedpageA +% \or \handlearrangedpageXandY{#1}121\arrangedpageA +% \or \handlearrangedpageXandY{#1}111\arrangedpageA +% \or \handlearrangedpageXandY{#1}101\arrangedpageA +% \or \handlearrangedpageXandY{#1}002\arrangedpageA +% \or \handlearrangedpageXandY{#1}012\arrangedpageA +% \or \handlearrangedpageXandY{#1}022\arrangedpageA +% \poparrangedpages +% \fi} + +% % handy for stickers etc, this way we can treat them as page +% +% \setuppapersize [XY][A4] +% \setuppaper [topspace=5mm,backspace=5mm,dx=1mm,dy=1mm,nx=2,ny=6] +% \setuplayout [page] [topspace=5mm,backspace=5mm] +% \setuplayout [page] +% \setuplayout [location=middle] +% \setuparranging [XY] +% \showframe +% +% \starttext \dorecurse{30}{test \recurselevel \page} \stoptext + +\permanent\protected\protected\def\pusharrangedpageXY#1% + {\advancearrangedpageN + \global\advance\arrangedpageM\plusone + \reportarrangedpage\arrangedpageN + \global\setbox\arrangedpageB\hpack \ifdim\v_page_target_width>\zeropoint to \v_page_target_width \fi + {\ifvoid\arrangedpageB\else + \unhbox\arrangedpageB + \ifdim\v_page_target_dx>\zeropoint + \hskip\v_page_target_dx + \else + \hss + \hskip\v_page_target_dx + \hss + \fi + \fi + \box#1}% + \ifnum\arrangedpageM<\arrangedpageX\else + \global\setbox\arrangedpageA\vpack \ifdim\v_page_target_height>\zeropoint to \v_page_target_height \fi + {\offinterlineskip + \ifvoid\arrangedpageA\else + \unvbox\arrangedpageA + \ifdim\v_page_target_dy>\zeropoint + \vskip\v_page_target_dy + \else + \vss + \vskip\v_page_target_dy + \vss + \fi + \fi + \box\arrangedpageB}% + \global\arrangedpageM\zerocount + \fi + \ifnum\arrangedpageN<\arrangedpageT\else + \poparrangedpages + \fi} + +\permanent\protected\protected\def\poparrangedpagesXY + {\ifnum\arrangedpageN>\zerocount + \paperwidth \arrangedpageX\paperwidth + \paperheight\arrangedpageY\paperheight + \outputarrangedbox\arrangedpageA + \global\arrangedpageN\zerocount + \global\arrangedpageM\zerocount + \fi} + +\installpagearrangement XY + {\dosetuparrangement + \v_page_target_nx + \v_page_target_ny + \v_page_target_xy + \zerocount + \zerocount + \pusharrangedpageXY\poparrangedpagesXY\relax} + +%D A crazy definition, don't guess who pushed me for the landscape option. + +\def\page_imposition_xy_height + {\dimexpr + \dimexpr + \v_page_target_height + -\numexpr\v_page_target_ny-1\relax\v_page_target_dy + \relax + /\v_page_target_ny + \relax} + +\def\page_imposition_xy_width + {\dimexpr + \dimexpr + \v_page_target_width + -\numexpr\v_page_target_nx-1\relax\v_page_target_dx + \relax + /\v_page_target_nx + \relax} + +\definepapersize + [XY] + [\c!height=\page_imposition_xy_height, + \c!width =\page_imposition_xy_width] + +\setuppaper + [\c!width =\dimexpr\printpaperwidth -2\v_page_target_backspace\relax, + \c!height=\dimexpr\printpaperheight-2\v_page_target_topspace \relax] + +% \definepageshift[test][horizontal][10pt,20pt,30pt,40pt,50pt] +% \definepageshift[test][vertical] [10pt,20pt,30pt,40pt,50pt] +% +% \setuppageshift[test] +% \setuppageshift[test][test] +% \setuppageshift[test][none] +% \setuppageshift[none][test] +% \setuppageshift[paper][test][test] % arrange only +% \setuppageshift[paper][test] % arrange only +% \setuppageshift[print][test][test] +% +% \showframe \dorecurse{100}{\input tufte \par} + +% #1=name #2=horizontal|vertical #3=shiftlist + +% this will move to lua + +\installcorenamespace {pageshift} + +\permanent\protected\tolerant\def\definepageshift[#1]#*[#2]#*[#3]% + {\setvalue{\??pageshift#2:#1}{#3}} + +\let\page_boxes_h_shifts\empty +\let\page_boxes_v_shifts\empty + +\newcount\c_page_boxes_h_shifts +\newcount\c_page_boxes_v_shifts + +\newdimen\d_page_boxes_h_shifts +\newdimen\d_page_boxes_v_shifts + +\let\page_boxes_apply_shift_print\gobbleoneargument +\let\page_boxes_apply_shift_paper\gobbleoneargument + +\def\page_boxes_filter_shift#1#2#3% #1=\dimenx #2=\xpageshifts #3=\nofxpageshifts + {#1\zeropoint + \ifx#2\empty \else + \global\advance#3\plusone + \getfromcommacommand[#2][#3]% + \ifx\commalistelement\empty + \global#3\plusone % we cycle + \getfromcommacommand[#2][#3]% + \fi + \ifx\commalistelement\empty \else + #1\commalistelement\relax % the relax is really needed as there is an \if later on + \fi + \fi} + +\def\page_boxes_apply_shift#1% + {\page_boxes_filter_shift\d_page_boxes_h_shifts\page_boxes_h_shifts\c_page_boxes_h_shifts + \page_boxes_filter_shift\d_page_boxes_v_shifts\page_boxes_v_shifts\c_page_boxes_v_shifts + \ifzeropt\d_page_boxes_h_shifts + \ifzeropt\d_page_boxes_v_shifts + % nothing to shift + \else + \page_boxes_apply_shift_indeed#1% + \fi + \else + \page_boxes_apply_shift_indeed#1% + \fi} + +\def\page_boxes_apply_shift_indeed#1% + {\edef\next{\wd#1\the\wd#1\ht#1\the\ht#1\dp#1\the\dp#1}% + \setbox#1\vpack + {\offinterlineskip + \vskip\d_page_boxes_v_shifts + \hskip\d_page_boxes_h_shifts + \box#1}% + \next} + +\permanent\tolerant\protected\def\setuppageshift[#1]#*[#2]#*[#3]% page|paper horizontal vertical + {\ifarguments\or + \setuppageshift[\v!page][#1][#1]% + \or + \doifelseinset{#1}{\v!page,\v!paper} + {\setuppageshift[#1][#2][#2]} + {\setuppageshift[\v!page][#1][#2]}% + \or + %edef\page_boxes_h_shifts{\ifcsname\??pageshift\v!horizontal:#2\endcsname\csname\??pageshift\v!horizontal:#2\endcsname\fi}% + %edef\page_boxes_v_shifts{\ifcsname\??pageshift\v!vertical :#3\endcsname\csname\??pageshift\v!vertical :#3\endcsname\fi}% + \edef\page_boxes_h_shifts{\begincsname\??pageshift\v!horizontal:#2\endcsname}% + \edef\page_boxes_v_shifts{\begincsname\??pageshift\v!vertical :#3\endcsname}% + \doifelse{#1}\v!page {\let\page_boxes_apply_shift_print\page_boxes_apply_shift}{\let\page_boxes_apply_shift_print\gobbleoneargument}% + \doifelse{#1}\v!paper{\let\page_boxes_apply_shift_paper\page_boxes_apply_shift}{\let\page_boxes_apply_shift_paper\gobbleoneargument}% + \fi} + +\protect \endinput diff --git a/tex/context/base/mkxl/page-inf.mkxl b/tex/context/base/mkxl/page-inf.mkxl new file mode 100644 index 000000000..251e0c046 --- /dev/null +++ b/tex/context/base/mkxl/page-inf.mkxl @@ -0,0 +1,124 @@ +%D \module +%D [ file=page-inf, % moved from page-ini +%D version=2011.12.07, % 2000.10.20, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Tracing Info, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Tracing Info} + +% This needs a real cleanup .. will be a more detailed list. + +\unprotect + +\installcorenamespace{layoutinfo} + +\newtoks\everyresetversion +\newtoks\everysetupversion + +\mutable\let\currentversioninfo\empty +\mutable\let\currentversiontext\empty + +\aliased\let\version\setupversion + +\let\page_info_add_to_box\gobbleoneargument + +\permanent\tolerant\protected\def\setupversion[#1]% + {\the\everyresetversion + \doifelseassignment{#1}% + {\getdummyparameters[\c!alternative=,\c!text=,#1]% + \edef\currentversioninfo{\dummyparameter\c!alternative}% + \edef\currentversiontext{\dummyparameter\c!text}}% + {\edef\currentversioninfo{#1}% + \let \currentversiontext\empty}% + \ifcsname\??layoutinfo\currentversioninfo\endcsname + \let\page_info_add_to_box\page_info_add_to_box_indeed + \else + \let\currentversioninfo\empty + \let\page_info_add_to_box\gobbleoneargument + \fi + \the\everysetupversion} + +\protected\def\page_info_place_info % at the bottom of the page + {\begincsname\??layoutinfo\currentversioninfo\endcsname} + +\permanent\protected\def\installversioninfo#1#2% + {\setvalue{\??layoutinfo#1}{#2}} + +\permanent\protected\def\includeversioninfo#1% + {\begincsname\??layoutinfo#1\endcsname} + +\installversioninfo\v!final + {\let\currentversioninfo\empty + \let\page_info_add_to_box\gobbleoneargument} + +\installversioninfo\v!concept + {\vskip6\points + \hbox to \makeupwidth + {\infofont + \rlap{\v!concept:\space\currentdate}% + \hss + \currentversiontext + \hss + \llap{\page_adapts_status_info}}} + +\installversioninfo\v!file + {\vskip6\points + \hbox to \makeupwidth + {\infofont + \getmessage\m!system{27}:\space\currentdate\quad + \donefalse + \doif\currentproject\currentproduct{\doif\currentproduct\currentcomponent\donetrue}% + \ifdone + \donefalse + \else + \ifx\currentproject \empty \else \space\v!project :\space\currentproject \space \donetrue \fi + \ifx\currentproduct \empty \else \space\v!product :\space\currentproduct \space \donetrue \fi + \ifx\currentcomponent\empty \else \space\v!component:\space\currentcomponent\space \donetrue \fi + \fi + \ifdone \else \space\v!file :\space\jobname \space \fi + \hss + \currentversiontext + \quad + \page_adapts_status_info}} + +\installversioninfo\v!temporary + {\includeversioninfo\v!file} + +\appendtoks + \overfullrule\zeropoint +\to \everyresetversion + +\appendtoks + \ifx\currentversioninfo\v!temporary + \overfullrule5\points + \fi +\to \everysetupversion + +\newbox\b_page_versions + +\def\page_info_add_to_box_indeed#1% + {\scratchdimen\wd#1% + \setbox\b_page_versions\vpack to \ht#1% + {\vfill + \settexthoffset + \hsize\dimexpr\scratchdimen-2\texthoffset\relax + \hkern\texthoffset % brrrr + \vbox to \zeropoint{\vss\page_info_place_info}% + \vkern\bodyfontsize}% + \dp\b_page_versions\zeropoint + \wd\b_page_versions\scratchdimen + \setbox#1\hpack{\box#1\hkern-\scratchdimen\box\b_page_versions}} + +\setupversion % resets + [\v!final] + +\let\page_info_add_to_box\gobbleoneargument + +\protect \endinput diff --git a/tex/context/base/mkiv/page-ini.mkxl b/tex/context/base/mkxl/page-ini.mkxl index 481e5abd5..481e5abd5 100644 --- a/tex/context/base/mkiv/page-ini.mkxl +++ b/tex/context/base/mkxl/page-ini.mkxl diff --git a/tex/context/base/mkxl/page-inj.mklx b/tex/context/base/mkxl/page-inj.mklx new file mode 100644 index 000000000..19f01e6d3 --- /dev/null +++ b/tex/context/base/mkxl/page-inj.mklx @@ -0,0 +1,228 @@ +%D \module +%D [ file=page-inj, +%D version=2013.02.10, +%D title=\CONTEXT\ Page Module, +%D subtitle=Injections, +%D author=Wolfgang Schuster \& Hans Hagen, +%D date=\currentdate, +%D copyright=Wolfgang Schuster \& Hans Hagen, +%D license=see context related readme files (gpl)] + +%D This module is based on an idea and prototype by Wolfgang but instead of +%D injectioning into a page constructor we injection it into the regular shipout +%D handler because that way we get page numbering. It's a sort of variation on +%D postponing but the content does not end up in the regular page flow, so it's +%D closer to page figures but without the usual page builder. +%D +%D This module is following the mkvi way of rendering setups and configuration and +%D is somewhat experimental. Probably more alternatives will be added. This could +%D become a delayed loaded module at some point (no real consequences). + +\unprotect + +\registerctxluafile{page-inj}{} + +\installcorenamespace {pageinjection} +\installcorenamespace {pageinjectionalternative} +\installcorenamespace {pageinjectionrenderings} + +\installframedcommandhandler \??pageinjection {pageinjection} \??pageinjection +\installcommandhandler \??pageinjectionalternative {pageinjectionalternative} \??pageinjectionalternative + +\let\page_boxes_flush_before\clf_flushpageinjectionsbefore +\let\page_boxes_flush_after \clf_flushpageinjectionsafter + +\def\page_injections_flush_indeed + {\scrn_canvas_synchronize_set{\pageinjectionparameter\c!width}{\pageinjectionparameter\c!height}% + \invokepagehandler\v!normal{\inheritedpageinjectionframed{\texsetup\p_page_injectionalternative_rederingsetup}}% + \scrn_canvas_synchronize_reset} + +\def\page_injections_flush_saved#name#parameters% + {\begingroup + \edef\currentpageinjection{#name}% + \getdummyparameters[#parameters]% + \edef\currentpageinjectionalternative {\pageinjectionparameter \c!alternative }% + \edef\p_page_injectionalternative_rederingsetup{\pageinjectionalternativeparameter\c!renderingsetup}% + \page_injections_nextpage + \page_injections_flush_indeed + \endgroup} + +\permanent\tolerant\protected\def\pageinjection[#1]#*[#2]% name parameters | settings parameters | name | parameters + {\begingroup + \ifhastok={#1}% + \ifhastok={#2}% + \page_injections_direct_settings_parameters{#1}{#2}% + \else + \page_injections_direct_parameters{#1}% + \fi + \else + \ifhastok={#2}% + \page_injections_direct_name_parameters{#1}{#2}% + \else + \page_injections_direct_name{#1}% + \fi + \fi} + +\def\page_injections_direct_settings_parameters#settings% #parameters% + {\let\currentpageinjection\empty + \checkpageinjectionparent + \setupcurrentpageinjection[#settings]% + \page_injections_direct_indeed} + +\def\page_injections_direct_parameters% #parameters% + {\let\currentpageinjection\empty + \checkpageinjectionparent + \page_injections_direct_indeed} + +\def\page_injections_direct_name_parameters#name% #parameters% + {\edef\currentpageinjection{#name}% + \checkpageinjectionparent + \page_injections_direct_indeed} + +\def\page_injections_direct_name#name% + {\edef\currentpageinjection{#name}% + \checkpageinjectionparent + \page_injections_direct_indeed{}} + +\def\page_injections_direct_indeed% #parameters% + {\edef\p_page_injections_state{\pageinjectionparameter\c!state}% + \edef\p_page_injections_delay{\pageinjectionparameter\c!delay}% + \edef\p_page_injections_page {\pageinjectionparameter\c!page }% + \ifx\p_page_injections_delay\v!yes + \expandafter\page_injections_direct_indeed_yes + \else + \expandafter\page_injections_direct_indeed_nop + \fi} + +\def\page_injections_direct_indeed_yes#parameters% + {\clf_savepageinjections + name {\currentpageinjection}% + state {\p_page_injections_state}% + userdata {\normalunexpanded{#parameters}}% + \relax + \endgroup} + +\def\page_injections_direct_indeed_nop#parameters% + {\ifempty\p_page_injections_page + \page + \else + \page[\p_page_injections_page]% + \fi + \getdummyparameters[#parameters]% + \page_injections_place + \endgroup} + +\def\page_injections_place + {\edef\currentpageinjectionalternative {\pageinjectionparameter \c!alternative }% + \edef\p_page_injectionalternative_rederingsetup{\pageinjectionalternativeparameter\c!renderingsetup}% + \page_injections_nextpage + \ifx\currentpageinjectionalternative\v!none \else % increment counter but don’t generate output + \forgetparindent + \dontcomplain + \setconstant\shipoutfinalizemethod\zerocount % this is messy + \page_injections_flush_indeed + \fi} + +\def\page_injections_nextpage + {\edef\p_page_injections_pagestate{\pageinjectionparameter\c!pagestate}% + \ifx\p_page_injections_pagestate\v!stop \else + \edef\p_page_injections_n{\pageinjectionparameter\c!n}% + \ifx\p_page_injections_n\empty + \let\p_page_injections_n\plusone + \fi + \dorecurse\p_page_injections_n + {\incrementcounter[\s!realpage]% + \incrementcounter[\s!userpage]}% + \fi} + +\definepageinjectionalternative[\v!figure][\c!renderingsetup=\??pageinjectionrenderings:\v!figure] +\definepageinjectionalternative[\v!buffer][\c!renderingsetup=\??pageinjectionrenderings:\v!buffer] +\definepageinjectionalternative[\v!setups][\c!renderingsetup=\??pageinjectionrenderings:\s!setup ] + +\startsetups[\??pageinjectionrenderings:\v!figure] + \dontleavehmode\externalfigure[\dummyparameter\c!name][\c!factor=\v!max] +\stopsetups + +\startsetups[\??pageinjectionrenderings:\s!setup] + \setups[\dummyparameter\c!setups]% kind of redundant but fits in +\stopsetups + +\startsetups[\??pageinjectionrenderings:\v!buffer] + \getbuffer[\dummyparameter\c!name]% +\stopsetups + +% \setuppaper +% [\c!method=\v!pageinjection] + +\setuppageinjection + [ \c!width=\paperwidth, + \c!height=\paperheight, + \c!frame=\v!off, + \c!offset=\v!overlay, + \c!delay=\v!no, + \c!state=\v!next, + \c!alternative=\v!figure] + +\definepageinjection[\v!previouspage][\c!delay=\v!yes,\c!state=\v!previous] +\definepageinjection[\v!nextpage] [\c!delay=\v!yes,\c!state=\v!next] +\definepageinjection[\v!here] % direct +\definepageinjection[\v!empty] [\c!alternative=\v!none] + +%definepageinjection[\v!chapter] [\v!previouspage][\c!pagestate=\v!stop] + +\protect \endinput + +% \enabletrackers[pagebuilder.injections] +% +% \setuppageinjection[offset=2em] +% +% \definepageinjection[chapter][previouspage][pagestate=stop] +% \definepageinjection[later] [delay=yes,state=+2] +% +% \useMPlibrary[dum] +% +% \starttext +% +% \startchapter[title={Insert pages before/after the current page}] +% +% \dorecurse{10}{one: \input ward\par} +% +% \pageinjection[previouspage][name=dummy-1] +% +% \dorecurse{20}{two: \input ward\par} \page +% +% \pageinjection[nextpage][name=dummy-2] +% \pageinjection[later] [name=dummy-4] +% \pageinjection[delay=yes,state=+2][name=dummy-5] +% +% \dorecurse{100}{three: \input ward\par} +% +% \stopchapter +% +% \startbuffer[whatever] +% \dorecurse{10}{whatever #1 } +% \stopbuffer +% +% \startchapter[title={Insert pages at the current location}] +% +% \dorecurse{10}{\input ward\par} +% +% \pageinjection[direct][name=dummy-3] +% \pageinjection[direct][alternative=buffer,name=whatever] +% +% \dorecurse{10}{\input ward\par} +% +% \stopchapter +% +% \setuphead +% [chapter] +% [beforesection={\pageinjection[empty]}, +% insidesection={\pageinjection[chapter][name=\structureuservariable{image}]}] +% +% \startchapter[title={Combine both mechanism}][name=dummy-4] +% +% \dorecurse{10}{\input ward\par} +% +% \stopchapter +% +% \stoptext diff --git a/tex/context/base/mkxl/page-ins.mkxl b/tex/context/base/mkxl/page-ins.mkxl new file mode 100644 index 000000000..cb6e3e3f4 --- /dev/null +++ b/tex/context/base/mkxl/page-ins.mkxl @@ -0,0 +1,209 @@ +%D \module +%D [ file=page-ins, +%D version=2002.04.16, % was core-ins +%D title=\CONTEXT\ Insertion Macros, +%D subtitle=Insertions, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Core Macros / Insertions} + +%D Insertions are special data collections that are associated to \TEX's internal +%D page builder. When multiple footnote classes were introduced, I decided to +%D isolate some of the functionality in a module. + +\registerctxluafile{page-ins}{} + +\unprotect + +%D Because we need to deal with inserts at the \LUA\ end as well, we provide a +%D proper installer. + +\installcorenamespace{insertion} +\installcorenamespace{insertionnumber} + +\installcommandhandler \??insertion {insertion} \??insertion + +\setupinsertion + [%c!n=\plusone, + %c!distance=\zeropoint, + %c!maxheight=\maxdimen, + %c!factor=\plusthousand, + \c!location=\v!page] + +\newconstant\insertionmigrationmode + +\def\page_inserts_check_anchoring + {\edef\p_anchoring{\namedinsertionparameter\empty\c!anchoring}% + \insertionmigrationmode\ifx\p_anchoring\v!auto\plusone\else\zerocount\fi + \clf_setinsertmigration{\p_anchoring}} + +\appendtoks + \ifx\currentinsertionparent\empty + \page_inserts_check_anchoring + \fi +\to \everysetupinsertion + +\setupinsertion + [\c!anchoring=\v!auto] + +\appendtoks + \page_inserts_check_anchoring +\to \everystarttext % or \everyjob + +\newcount\currentinsertionnumber % This is a count and not a macro ! + +\newtoks\t_page_inserts_list + +\let\doprocessinsert\relax + +%D Maybe some day we will move settings here. + +\permanent\protected\def\setcurrentinsertion#1% + {\edef\currentinsertion{#1}% + \currentinsertionnumber\csname\??insertionnumber\currentinsertion\endcsname} + +\permanent\def\namedinsertionnumber#1{\csname\??insertionnumber#1\endcsname} + +\protected\def\page_inserts_synchronize_registers + {\currentinsertionnumber\csname\??insertionnumber\currentinsertion\endcsname} + +% for practical reasons we still set these elsewhere but that might change in the future +% +% \global\count\currentinsertionnumber\numexpr\insertionparameter\c!factor/\insertionparameter\c!n\relax +% \global\skip \currentinsertionnumber\insertionparameter\c!distance \relax +% \global\dimen\currentinsertionnumber\insertionparameter\c!maxheight\relax} +% \floatingpenalty\zerocount + +\appendtoks + \ifx\currentinsertionparent\empty \else + \page_inserts_synchronize_registers + \fi +\to \everysetupinsertion + +\protected\def\page_inserts_process#1% beware, this adapts currentinsertion ! + {\edef\currentinsertion{#1}% + \currentinsertionnumber\csname\??insertionnumber\currentinsertion\endcsname + \doprocessinsert\currentinsertionnumber} % old method + +\permanent\protected\def\processinsertions + {\the\t_page_inserts_list} + +\permanent\protected\def\synchronizeinsertions + {\let\doprocessinsert\page_inserts_synchronize + \processinsertions} + +\protected\def\page_inserts_synchronize#1% yes or no + {\ifvoid#1\else + \insert#1{\unvbox#1}% + \fi} + +\permanent\protected\def\doifelseinsertion#1% + {\ifcsname\??insertionnumber#1\endcsname + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} + +\aliased\let\doifinsertionelse\doifelseinsertion + +% \protected\def\startinsertion[#1]% +% {\insert\csname\??insertionnumber#1\endcsname\bgroup} +% +% \protected\def\stopinsertion +% {\egroup} + +% For the moment we use the regular insertion allocator so that users can still +% define their own insertions (not that they will play nicely with all context +% mechanisms then). We can use the dimensions at the \LUA\ end so we don't need to +% pass pass them explicitly. Actually, when we see an insertion node at that end, +% we already know the number. + +\appendtoks + \ifx\currentinsertionparent\empty + \ifcsname\??insertionnumber\currentinsertion\endcsname + % bad news + \else + \expandafter\newinsert\csname\??insertionnumber\currentinsertion\endcsname + \page_inserts_synchronize_registers + \clf_defineinsertion + {\currentinsertion}% + {% + number \currentinsertionnumber + }% + \relax + \t_page_inserts_list\expandafter\expandafter\expandafter + {\expandafter\the\expandafter\t_page_inserts_list + \expandafter\page_inserts_process\csname\??insertionnumber\currentinsertion\endcsname}% + \count\currentinsertionnumber\plusthousand + \skip \currentinsertionnumber\zeropoint + \dimen\currentinsertionnumber\maxdimen + \fi + \else + \letcsname\??insertionnumber\currentinsertion\expandafter\endcsname + \csname\??insertionnumber\currentinsertionparent\endcsname + \fi +\to \everydefineinsertion + +\appendtoks + \ifx\currentinsertionparent\empty \else + \clf_setupinsertion + {\currentinsertion} + {% + location {\insertionparameter\c!location}% + }% + \relax + \fi +\to \everysetupinsertion + +\protected\def\page_inserts_set_location#1#2% fast one + {\clf_setinsertionlocation{#1}{#2}} + +%D Auxiliary macros: + +\def\page_insert_insertion_height#1% + {\dimexpr\expandafter\page_insert_insertion_height_indeed\csname\??insertionnumber#1\endcsname\relax} + +\def\page_insert_insertion_height_indeed#1% + {\ifvoid#1\zeropoint\else1\skip#1+\ht#1\fi} + +%D Obsolete: + +% \installcorenamespace{insertionbackup} +% +% \protected\def\installbackupinsertion#1% +% {\ifcsname\??insertionbackup\string#1\endcsname \else +% \expandafter\newinsert\csname\??insertionbackup\string#1\endcsname +% \count\csname\??insertionbackup\string#1\endcsname\zerocount +% \skip \csname\??insertionbackup\string#1\endcsname\zeropoint +% \dimen\csname\??insertionbackup\string#1\endcsname\maxdimen +% \fi} +% +% \protected\def\saveinsertionbox#1% hm, actually unknown +% {\global\setbox\csname\??insertionbackup\string#1\endcsname +% \ifdim\ht#1>\zeropoint\box#1\else\emptybox\fi} +% +% \protected\def\restoreinsertionbox#1% +% {\ifvoid\backupinsertion#1\else % if void, we keep the content +% \global\setbox#1\box\csname\??insertionbackup\string#1\endcsname +% \fi} +% +% \protected\def\eraseinsertionbackup#1% +% {\global\setbox\csname\??insertionbackup\string#1\endcsname\emptybox} +% +% \protected\def\saveinsertiondata#1% +% {\global\skip \csname\??insertionbackup\string#1\endcsname\skip #1% +% \global\count\csname\??insertionbackup\string#1\endcsname\count#1% +% \global\dimen\csname\??insertionbackup\string#1\endcsname\dimen#1} +% +% \protected\def\restoreinsertiondata#1% +% {\global\skip #1\skip \csname\??insertionbackup\string#1\endcsname +% \global\count#1\count\csname\??insertionbackup\string#1\endcsname +% \global\dimen#1\dimen\csname\??insertionbackup\string#1\endcsname} + +\protect \endinput diff --git a/tex/context/base/mkiv/page-lay.mkxl b/tex/context/base/mkxl/page-lay.mkxl index 063268527..230315a03 100644 --- a/tex/context/base/mkiv/page-lay.mkxl +++ b/tex/context/base/mkxl/page-lay.mkxl @@ -769,12 +769,12 @@ \ifdefined\lastpage \else \let\lastpage\!!plusone \fi -\def\page_layouts_change#1% +\permanent\protected\def\page_layouts_change#1% {%\writestatus\m!layouts{changing to layout #1}% \xdef\currentlayout{#1}% \page_layouts_synchronize} -\let\changetolayout\page_layouts_change % also public +\aliased\let\changetolayout\page_layouts_change % also public \def\v_real_page_normal {\the\realpageno} \def\v_real_page_reverse{-\the\numexpr\lastpage-\realpageno\relax} @@ -847,14 +847,14 @@ % \v!normal % \fi\endcsname} -\def\page_layouts_check_next +\permanent\protected\def\page_layouts_check_next {\ifcsname\??layoutmethod\layoutparameter\c!method\endcsname \lastnamedcs \else \page_layouts_check_default \fi} -\let\checkcurrentlayout\page_layouts_check_next % public and used in naw, so this synonym will stay +\aliased\let\checkcurrentlayout\page_layouts_check_next % public and used in naw, so this synonym will stay % inheritance % @@ -1043,7 +1043,7 @@ \def\page_adapts_reset {\ifcsname\??pageadaptations\the\realpageno\endcsname - \global\letcsname\??pageadaptations\the\realpageno\endcsname\relax + \gletcsname\??pageadaptations\the\realpageno\endcsname\relax \fi} \def\page_adepts_push_indeed @@ -1192,14 +1192,14 @@ \def\page_layouts_if_odd_else_again#1{\doifelseoddpage} -\def\doifbothsidesoverruled +\permanent\def\doifbothsidesoverruled {\ifdoublesided \expandafter\page_layouts_if_odd_else_again \else \expandafter\firstofthreearguments \fi} -\def\doifbothsides% #1 #2 #3 +\permanent\def\doifbothsides% #1 #2 #3 {\ifdoublesided \expandafter\page_layouts_if_both_sides \else diff --git a/tex/context/base/mkxl/page-mak.mklx b/tex/context/base/mkxl/page-mak.mklx new file mode 100644 index 000000000..2a5cd4352 --- /dev/null +++ b/tex/context/base/mkxl/page-mak.mklx @@ -0,0 +1,280 @@ +%D \module +%D [ file=page-mak, % copied from main-001, +%D version=1997.03.31, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Simple MakeUp, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / MakeUp} + +\unprotect + +%D \macros +%D {definemakeup, setupmakeup, startmakeup} +%D +%D A makeup is a separate page, like a title page or colofon. There is one standard +%D makeup page, but you can define more if needed. +%D +%D \starttyping +%D \startstandardmakeup +%D My Fancy Title +%D \stopstandardmakeup +%D \stoptyping +%D +%D The associated commands are: +%D +%D \showsetup{definemakeup} +%D \showsetup{setupmakeup} +%D \showsetup{startmakeup} +%D +%D New is that we have a layout with the same name so one can set up a special +%D layout that then gets used. + +\installcorenamespace{makeup} +\installcorenamespace{makeupdoublesided} + +\installcommandhandler \??makeup {makeup} \??makeup + +\appendtoks + \frozen\instance\setuevalue{\e!start\currentmakeup\e!makeup}{\startmakeup[\currentmakeup]}% + \frozen\instance\setuevalue{\e!stop \currentmakeup\e!makeup}{\stopmakeup}% + \doifelselayoutdefined\currentmakeup\donothing{\definelayout[\currentmakeup]}% new +\to \everydefinemakeup + +%D The \type {\start}||\type {\stop} macros are used for both the direct and +%D indirect way. The parameterless call will build a simple box. + +\permanent\tolerant\protected\def\startmakeup[#1]#*[#2]% + {\ifparameters + \expandafter\page_makeup_start_nop + \else + \expandafter\page_makeup_start_yes + \fi[#1][#2]} + +\aliased\let\stopmakeup\relax + +%D The simple case: just a box with text dimensions. + +\protected\def\page_makeup_start_nop[#name][#settings]% dummies + {\page + \setupheader[\c!state=\v!empty]% + \setupfooter[\c!state=\v!empty]% + \bgroup + \forgetall % else indented flush + \dontcomplain + \vbox to \textheight \bgroup + \setsystemmode\v!makeup + \hsize\textwidth + \enforced\let\stopmakeup\page_makeup_stop_nop} + +\permanent\protected\def\page_makeup_stop_nop + {\egroup + \egroup + \page} + +%D The normal variant. + +\newbox \b_page_makeup +\newtoks\t_page_makeup_every_setup + +\def\page_makeup_start_yes[#name]% [#settings]% + {\doifelsecommandhandler\??makeup{#name}\page_makeup_start_indeed\page_makeup_start_nop[#name]}% + +% case 1: +% +% \setuplayout[height=5cm] +% +% case 2: +% +% \definelayout[crap][height=10cm] +% \definelayout[standard][crap] +% +% case 3: +% +% \setuplayout[standard][height=15cm] +% +% case 4: +% +% \definelayout[whatever][height=2cm] +% \setuplayout[whatever] + +\def\page_makeup_start_indeed[#name][#settings]% + {% the next grouping hack is somewhat messy: + \begingroup + % we need to figure out the current layout + \xdef\m_page_makeup_name{#name}% + \let\currentmakeup\m_page_makeup_name + \let\currentlayout\m_page_makeup_name + \xdef\m_page_makeup_layout_parent{\layoutparameter\s!parent}% + \setupcurrentmakeup[#settings]% + \edef\p_page{\makeupparameter\c!page}% + \ifempty\p_page + \endgroup + \page % new, so best not have dangling mess here like references (we could capture then and flush embedded) + \orelse\ifx\p_page\v!no + % nothing + \endgroup + \else + \normalexpanded{\endgroup\page[\p_page]}% + \fi + % some dirty trickery (sorry) for determining if we have + % - a layout definition at all + % - inherit from the parent of that definition + % - inherit from the current layout otherwise + \ifx\m_page_makeup_name\currentlayout + % we already use the layout + \orelse\ifx\m_page_makeup_layout_parent\??layout + % we inherit from the current layout + \normalexpanded{\setuplayout[#name][\s!parent=\??layout\currentlayout]}% is remembered but checked later anyway + % \else + % we have an inherited layout + \fi + \startlayout[#name]% includes \page + \bgroup + %\edef\currentmakeup{#name}% + \let\currentmakeup\m_page_makeup_name + \setupcurrentmakeup[#settings]% + \setsystemmode\v!makeup + \the\t_page_makeup_every_setup + \makeupparameter\c!commands % hm, what is this one doing here ? + \forgetall % else indented flush + \dontcomplain + \global\setbox\b_page_makeup\vbox to \makeupparameter\c!height \bgroup + \usemakeupstyleandcolor\c!style\c!color + \hsize\makeupparameter\c!width + \usealignparameter\makeupparameter + \usesetupsparameter\makeupparameter % lua(..),xml(...,..),tex(..) + \makeupparameter\c!top + \enforced\let\stopmakeup\page_makeup_stop_yes} + +\permanent\protected\def\page_makeup_stop_yes + {\endgraf + \makeupparameter\c!bottom + \egroup + \strc_pagenumbers_page_state_push % new + \makeupparameter\c!before\relax + \begingroup + \ifdim\ht\b_page_makeup>\vsize + \ht\b_page_makeup\vsize % is already set to \textheight (maybe set dp to 0) + \fi + \setuppagenumber[\c!state=\makeupparameter\c!pagestate]% + \doif{\makeupparameter\c!location}\v!top{\topskip\zeropoint}% + \edef\p_reference{\makeupparameter\c!reference}% + \dontleavehmode + \usereferenceparameter\makeupparameter + \box\b_page_makeup % could be whole box being destination + \the\t_page_makeup_every_setup + \page + \endgroup + \makeupparameter\c!after\relax + \ifdoublesided \ifodd\realpageno \else + \csname\??makeupdoublesided\makeupparameter\c!doublesided\endcsname + \fi \fi + \strc_pagenumbers_page_state_pop % new + \egroup + \stoplayout % includes \page + \ifx\m_page_makeup_name\currentlayout + \orelse\ifx\m_page_makeup_layout_parent\??layout + \normalexpanded{\setuplayout[\m_page_makeup_name][\s!parent=\??layout]}% is remembered but checked later anyway + \fi} + +\setvalue{\??makeupdoublesided\v!yes}% + {\emptyhbox + \page} + +\setvalue{\??makeupdoublesided\v!empty}% + {\the\t_page_makeup_every_setup + % == \page[\v!dummy] + \page[\v!blank]% + \emptyhbox + \page} + +%D Probably obsolete (but used in one manual by Taco): + +\permanent\protected\def\startcolumnmakeup % don't change + {\bgroup + \getrawnoflines\textheight % raw as we can have topskip + \setbox\scratchbox\vbox to \dimexpr\noflines\lineheight-\lineheight+\topskip\relax + \bgroup + \forgetall} + +\permanent\protected\def\stopcolumnmakeup + {\egroup + \dp\scratchbox\zeropoint + \wd\scratchbox\textwidth + \box\scratchbox + \egroup + \page_otr_command_synchronize_hsize} + +%D The text surrounding the main body text can be influenced by setting their +%D associated status variables. The connection between them is made by the following +%D macro: + +\appendtoks % this might need a revision + \setupfooter[\c!state=\makeupparameter\c!footerstate]% + \setupheader[\c!state=\makeupparameter\c!headerstate]% + \setuptext [\c!state=\makeupparameter\c!textstate]% + \setupbottom[\c!state=\makeupparameter\c!bottomstate]% + \setuptop [\c!state=\makeupparameter\c!topstate]% +\to \t_page_makeup_every_setup + +%D The standard page template is defined as follows: + +\setupmakeup + [\c!width=\innermakeupwidth, % example in manual / was \makeupwidth + \c!height=\textheight, % example in manual + %\c!commands=, + %\c!setups=, + %\c!color=, + %\c!align=, + %\c!before=, + %\c!after=, + %\c!location=, + \c!page=\v!right, + \c!doublesided=\v!empty, + \c!top=\vss, + \c!bottom=\vss, + \c!bottomstate=\v!normal, + \c!topstate=\v!normal, + \c!textstate=\v!normal, + \c!headerstate=\v!stop, + \c!footerstate=\v!stop, + \c!pagestate=\v!stop] % in manual ! ! ! +% \c!pagestate=\v!start] + +\definemakeup + [\v!standard] + [\c!width=\innermakeupwidth, + \c!height=\textheight, + \c!page=\v!right, + \c!doublesided=\v!empty] + +\definemakeup + [\v!text] + [\c!topstate=\v!start, + \c!headerstate=\v!start, + \c!textstate=\v!start, + \c!footerstate=\v!start, + \c!bottomstate=\v!start, + \c!doublesided=\v!no, + \c!page=\v!yes, + \c!top=\pseudostrut\ignorespaces, + \c!bottom=\obeydepth\vss] + +\definemakeup + [\v!page] + +\definemakeup + [\v!middle] + [\v!standard] + +% \definelayout[standard] +% \definelayout[text] + +\protect diff --git a/tex/context/base/mkxl/page-mbk.mklx b/tex/context/base/mkxl/page-mbk.mklx new file mode 100644 index 000000000..fcab1abf5 --- /dev/null +++ b/tex/context/base/mkxl/page-mbk.mklx @@ -0,0 +1,243 @@ +%D \module +%D [ file=page-mbk, % was part of page-mis.mkiv / 2008.11.17 +%D version=2011.11.23, % was part of page-flt.tex / 2000.10.20 +%D title=\CONTEXT\ Page Macros, +%D subtitle=Margin Floats, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Margin Floats} + +\unprotect + +%D This is an old mechanism that is quite independent of other floats. There is for +%D instance no save/restore used here. When there is need (and demand) we can use +%D the float cache and then flush them in the text when they are left over. On the +%D other hand, margin float are somewhat manual so it does not make too much sense +%D to complicate the code. As an alternative users can fall back on margin texts: +%D they do stack but don't float. +%D +%D \starttyping +%D \dorecurse{9} { +%D \placefigure[margin]{#1}{} +%D \input ward +%D } +%D \page \null % will flush them +%D \stoptyping + +% status=start: in margin +% status=stop : in text +% +% todo: flush margin floats at end of text +% todo: separate boxes for left and right + +\installcorenamespace{marginblock} +\installcorenamespace{marginblocklocation} + +\installcommandhandler \??marginblock {marginblock} \??marginblock + +\aliased\let\setupmarginblocks\setupmarginblock + +\newconditional\c_page_margin_blocks_enabled % not really needed as we can check each time +\newconditional\c_page_margin_blocks_present + +\newbox \b_page_margin_blocks +\newbox \b_page_margin_blocks_prepared + +\appendtoks + \doifelse{\rootmarginblockparameter\c!state}\v!start + \settrue\setfalse\c_page_margin_blocks_enabled +\to \everysetupmarginblock + +\setupmarginblocks + [\c!state=\v!start, + \c!location=\v!inmargin, + \c!width=\rightmarginwidth, + %\c!style=, + %\c!color=, + %\c!align=, + %\c!left=, + %\c!right=, + %\c!top=, + %\c!before=, + %\c!after=, + \c!inbetween=\blank, + \c!bottom=\vfill] + +\permanent\tolerant\protected\def\startmarginblock[#tag]% + {\begingroup + \edef\currentmarginblock{#tag}% + \doifelse{\marginblockparameter\c!state}\v!start + \page_margin_blocks_start_block_yes + \page_margin_blocks_start_block_nop} + +\permanent\protected\def\stopmarginblock + {\doifelse{\marginblockparameter\c!state}\v!start + \page_margin_blocks_stop_block_yes + \page_margin_blocks_stop_block_nop + \endgroup} + +\def\page_margin_blocks_start_block_yes % 2 maal \vbox ivm \unvbox elders + {\showmessage\m!layouts4\empty + \global\settrue\c_page_margin_blocks_present + \global\setbox\b_page_margin_blocks\vtop\bgroup\vbox\bgroup + \hsize\marginblockparameter\c!width + \ifvoid\b_page_margin_blocks\else + \unvbox\b_page_margin_blocks + \marginblockparameter\c!inbetween + \fi + \usealignparameter\marginblockparameter + \usemarginblockstyleandcolor\c!style\c!color + \begstrut + \ignorespaces} + +\def\page_margin_blocks_stop_block_yes + {\removeunwantedspaces + \endstrut + \egroup + \egroup} + +\def\page_margin_blocks_start_block_nop + {\showmessage\m!layouts5\empty + \marginblockparameter\c!before + \bgroup + \usemarginblockstyleandcolor\c!style\c!color} + +\def\page_margin_blocks_stop_block_nop + {\egroup + \marginblockparameter\c!after} + +\def\page_margin_blocks_reshape + {\ifdim\ht\b_page_margin_blocks_prepared>\zeropoint + \beginofshapebox + \unvbox\b_page_margin_blocks_prepared + \endofshapebox + \reshapebox + {\box\shapebox}% + \setbox\b_page_margin_blocks_prepared\vbox to \textheight + {\marginblockparameter\c!top + \flushshapebox + \marginblockparameter\c!bottom}% + \fi} + +\permanent\protected\def\checkmarginblocks + {\ifvoid\b_page_margin_blocks + \global\setfalse\c_page_margin_blocks_present + \else + \page_margin_blocks_check_indeed + \fi} + +\def\page_margin_blocks_check_indeed + {\ifcsname\??marginblocklocation\marginblockparameter\c!location\endcsname + \page_margin_blocks_prepare_box + \csname\??marginblocklocation\marginblockparameter\c!location\endcsname + \else + \global\setbox\b_page_margin_blocks\emptybox + \global\setfalse\c_page_margin_blocks_present + \fi} + +\def\page_margin_blocks_prepare_box + {\setbox\b_page_margin_blocks_prepared\vbox + {\forgetall + \splittopskip\topskip + \ifvoid\b_page_margin_blocks\else + \ifdim\ht\b_page_margin_blocks>\textheight + \vsplit\b_page_margin_blocks to \textheight + \else + \unvbox\b_page_margin_blocks + \fi + \fi}% + \page_margin_blocks_reshape + \setbox\b_page_margin_blocks_prepared\vbox + {\marginblockparameter\c!before + \box\b_page_margin_blocks_prepared + \marginblockparameter\c!after}} + +% inner outer + +\setvalue{\??marginblocklocation\v!left }{\page_margin_blocks_set_l_box} +\setvalue{\??marginblocklocation\v!right }{\page_margin_blocks_set_r_box} +\setvalue{\??marginblocklocation\v!inmargin}{\doifbothsidesoverruled + \page_margin_blocks_set_r_box + \page_margin_blocks_set_r_box + \page_margin_blocks_set_l_box} +\setvalue{\??marginblocklocation\v!middle }{\doifbothsidesoverruled + \page_margin_blocks_set_r_box + \page_margin_blocks_set_l_box + \page_margin_blocks_set_r_box} + +\protected\def\page_margin_blocks_place_r_yes + {\setbox\b_page_margin_blocks_prepared\hbox to \rightmarginwidth + {\marginblockparameter\c!left + \box\b_page_margin_blocks_prepared + \marginblockparameter\c!right}% + \vsmashbox\b_page_margin_blocks_prepared + \box\b_page_margin_blocks_prepared} + +\protected\def\page_margin_blocks_place_l_yes + {\setbox\b_page_margin_blocks_prepared\hbox to \leftmarginwidth + {\marginblockparameter\c!right + \box\b_page_margin_blocks_prepared + \marginblockparameter\c!left}% + \vsmashbox\b_page_margin_blocks_prepared + \box\b_page_margin_blocks_prepared} + +\protected\def\page_margin_blocks_place_r_nop{\hskip\rightmarginwidth} +\protected\def\page_margin_blocks_place_l_nop{\hskip\leftmarginwidth} + +\let\placerightmarginblock\page_margin_blocks_place_r_nop +\let\placeleftmarginblock \page_margin_blocks_place_l_nop + +\def\page_margin_blocks_set_r_box{\let\placerightmarginblock\page_margin_blocks_place_r_yes} +\def\page_margin_blocks_set_l_box{\let\placeleftmarginblock \page_margin_blocks_place_l_yes} + +% margin floats (keyword 'margin' in option list) + +\protected\def\page_margin_blocks_process_float + {\doifelse{\marginblockparameter\c!state}\v!start + \page_margin_blocks_process_float_yes + \page_margin_blocks_process_float_nop} + +\def\page_margin_blocks_process_float_yes + {\global\setbox\b_page_margin_blocks\vbox + {\hsize\marginblockparameter\c!width + \unvcopy\b_page_margin_blocks + \ifvoid\b_page_margin_blocks\else + \expandafter\marginblockparameter\expandafter\c!inbetween + \fi + \box\floatbox + \filbreak}% + \ifdim\ht\b_page_margin_blocks>\textheight + % page_floats_report_saved % no saving done anyway + \else + \page_floats_report_total + \fi} + +\def\page_margin_blocks_process_float_nop + {\handlefloatmethod\v!here} + +\def\page_margin_blocks_float_before + {\ifconditional\c_page_margin_blocks_enabled + \doifinset\v!margin\floatlocation\endgraf + \fi} + +\def\page_margin_blocks_float_set_hsize + {\ifconditional\c_page_margin_blocks_enabled + \doifinset\v!margin\floatlocation{\hsize\rootmarginblockparameter\c!width}% + \fi} + +\appendtoks + \ifvoid\b_page_margin_blocks \else + \writestatus\m!layouts{beware: there are left-over margin floats!}% + \fi +\to \everystoptext + +\permanent\protected\def\flushmarginblocks + {\page_otr_command_flush_margin_blocks} + +\protect \endinput diff --git a/tex/context/base/mkiv/page-mcl.mkxl b/tex/context/base/mkxl/page-mcl.mkxl index 112d9931d..3cac820c2 100644 --- a/tex/context/base/mkiv/page-mcl.mkxl +++ b/tex/context/base/mkxl/page-mcl.mkxl @@ -379,7 +379,7 @@ {%\global\setbox\currentcolumnbox\box\currentcolumnbox \ht\currentcolumnbox\ht\firstcolumnbox} -\tolerant\protected\def\startmulticolumns[#1]% +\permanent\tolerant\protected\def\startmulticolumns[#1]% {\bgroup \ifinsidecolumns \page_mcl_start_nop @@ -394,6 +394,8 @@ \fi \fi} +\aliased\let\stopmulticolumns\relax + \def\page_mcl_start_nop {\enforced\let\stopmulticolumns\page_mcl_stop_nop} diff --git a/tex/context/base/mkiv/page-mix.mkxl b/tex/context/base/mkxl/page-mix.mkxl index 20f4ff3ca..c94a1f252 100644 --- a/tex/context/base/mkiv/page-mix.mkxl +++ b/tex/context/base/mkxl/page-mix.mkxl @@ -85,14 +85,17 @@ %\c!splitmethod=\v!fixed, % will be default \c!direction=\v!normal, % new (also todo in the new columnsets) \c!notes=\v!yes, + \c!define=\v!yes, \c!method=\ifinner\s!box\else\s!otr\fi] % automatic as suggested by WS -\let\startmixedcolumns\relax % defined later -\let\stopmixedcolumns \relax % defined later + \let\startmixedcolumns\relax % defined later +\aliased\let\stopmixedcolumns \relax % defined later \appendtoks % could become an option - \setuevalue{\e!start\currentmixedcolumns}{\startmixedcolumns[\currentmixedcolumns]}% - \setuevalue{\e!stop \currentmixedcolumns}{\stopmixedcolumns}% + \ifcstok{\mixedcolumnsparameter\c!define}\v!yes + \frozen\instance\setuevalue{\e!start\currentmixedcolumns}{\startmixedcolumns[\currentmixedcolumns]}% + \frozen\instance\setuevalue{\e!stop \currentmixedcolumns}{\stopmixedcolumns}% + \fi \to \everydefinemixedcolumns %D In order to avoid a mixup we use quite some local registers. @@ -389,28 +392,25 @@ \installmacrostack\currentmixedcolumns \installmacrostack\currentmixedcolumnsmethod -\protected\def\startmixedcolumns - {\dodoubleempty\page_mix_start_columns} +\permanent\tolerant\protected\def\startmixedcolumns[#1]#*[#2]% + {\push_macro_currentmixedcolumns + \push_macro_currentmixedcolumnsmethod + \ifparameters + \expandafter\page_mix_start_columns_c + \or + \expandafter\page_mix_start_columns_b + \or + \expandafter\page_mix_start_columns_a + \fi[#1][#2]} \def\page_mix_start_columns_checked#1#2% {\edef\currentmixedcolumnsmethod{\mixedcolumnsparameter\c!method}% \ifx\currentmixedcolumnsmethod\v!box - \singleexpandafter#1% + \expandafter#1% \orelse\ifinsidecolumns - \doubleexpandafter#2% + \expandafter#2% \else - \doubleexpandafter#1% - \fi} - -\protected\def\page_mix_start_columns - {\push_macro_currentmixedcolumns - \push_macro_currentmixedcolumnsmethod - \ifsecondargument - \singleexpandafter\page_mix_start_columns_a - \orelse\iffirstargument - \doubleexpandafter\page_mix_start_columns_b - \else - \doubleexpandafter\page_mix_start_columns_c + \expandafter#1% \fi} \def\page_mix_start_columns_a[#1]% [#2]% @@ -426,37 +426,34 @@ \setupcurrentmixedcolumns[#1]% \page_mix_initialize_columns \begincsname\??mixedcolumnsstart\currentmixedcolumnsmethod\endcsname - \let\stopmixedcolumns\page_mix_columns_stop_yes} + \enforced\let\stopmixedcolumns\page_mix_columns_stop_yes} \def\page_mix_start_columns_a_nop[#1]% {\begingroup - \let\stopmixedcolumns\page_mix_columns_stop_nop} + \enforced\let\stopmixedcolumns\page_mix_columns_stop_nop} \def\page_mix_start_columns_b[#1][#2]% - {\doifelseassignment{#1}% - {\let\currentmixedcolumns\empty - \page_mix_error_b} - {\edef\currentmixedcolumns{#1}% - \firstargumentfalse}% - \page_mix_start_columns_checked - \page_mix_start_columns_b_yes - \page_mix_start_columns_b_nop - [#1]} + {\ifhastok={#1}% + \let\currentmixedcolumns\empty + \page_mix_error_b + \page_mix_start_columns_checked\page_mix_start_columns_b_yes\page_mix_start_columns_b_nop[#1]% + \else + \edef\currentmixedcolumns{#1}% + \page_mix_start_columns_checked\page_mix_start_columns_b_yes\page_mix_start_columns_b_nop[#2]% + \fi} \def\page_mix_start_columns_b_yes[#1]% {\mixedcolumnsparameter\c!before\relax % so, it doesn't listen to local settings ! \begincsname\??mixedcolumnsbefore\currentmixedcolumnsmethod\endcsname\relax \begingroup - \iffirstargument - \setupcurrentmixedcolumns[#1]% - \fi + \setupcurrentmixedcolumns[#1]% \page_mix_initialize_columns \begincsname\??mixedcolumnsstart\currentmixedcolumnsmethod\endcsname % no \relax - \let\stopmixedcolumns\page_mix_columns_stop_yes} + \enforced\let\stopmixedcolumns\page_mix_columns_stop_yes} \def\page_mix_start_columns_b_nop[#1]% {\begingroup - \let\stopmixedcolumns\page_mix_columns_stop_nop} + \enforced\let\stopmixedcolumns\page_mix_columns_stop_nop} \def\page_mix_error_b {\writestatus\m!columns{best use an instance of mixed columns}} @@ -473,11 +470,11 @@ \begingroup \page_mix_initialize_columns \begincsname\??mixedcolumnsstart\currentmixedcolumnsmethod\endcsname - \let\stopmixedcolumns\page_mix_columns_stop_yes} + \enforced\let\stopmixedcolumns\page_mix_columns_stop_yes} \def\page_mix_start_columns_c_nop {\begingroup - \let\stopmixedcolumns\page_mix_columns_stop_nop} + \enforced\let\stopmixedcolumns\page_mix_columns_stop_nop} \protected\def\page_mix_fast_columns_start#1% {\push_macro_currentmixedcolumns @@ -1034,13 +1031,10 @@ %D Moved here and dedicated: -\protected\def\page_mix_command_test_column - {\dodoubleempty\page_mix_command_test_column_indeed} - -\protected\def\page_mix_command_test_column_indeed[#1][#2]% works on last column +\tolerant\protected\def\page_mix_command_test_column[#1]#*[#2]% works on last column {\par \begingroup - \scratchdimen\dimexpr#1\lineheight\ifsecondargument+#2\fi\relax + \scratchdimen\dimexpr#1\lineheight\ifparameter#2\or+#2\fi\relax \ifdim\scratchdimen>\zeropoint \c_attr_checkedbreak\number\scratchdimen % why \number \penalty\c_page_mix_break_forced\relax diff --git a/tex/context/base/mkxl/page-mrk.mkxl b/tex/context/base/mkxl/page-mrk.mkxl new file mode 100644 index 000000000..697cafdea --- /dev/null +++ b/tex/context/base/mkxl/page-mrk.mkxl @@ -0,0 +1,238 @@ +%D \module +%D [ file=page-mrk, +%D version=2011.05.23, % moved from page-lay +%D title=\CONTEXT\ Page Macros, +%D subtitle=Cutmarks and Colorbars, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Cutmarks and Colorbars} + +\unprotect + +%D This module implements curmarks and depends on \METAPOST. +%D +%D \starttyping +%D \setuplayout[marking=on,location=middle] +%D \setuplayout[marking=page,location=middle] +%D \setuplayout[marking=empty,location=middle] +%D \setuplayout[marking={color,page},location=middle] +%D \setuplayout[marking={one,page},location=middle] +%D \setuplayout[marking={two,page},location=middle] +%D \setuplayout[marking={four,page},location=middle] +%D \stoptyping + +\mutable\def\pagecutmarklength {5mm} +\mutable\def\pagecutmarkoffset {3mm} % slightly larger than before, and now a fixed size +\mutable\def\pagecutmarkmargin{10cm} + +% maybe all these should be global + +\newconditional\c_page_marks_add_more_color +\newconditional\c_page_marks_add_more_marking +\newconditional\c_page_marks_add_more_lines +\newconditional\c_page_marks_add_page_lines +\newconditional\c_page_marks_add_more_number + +\newcount\c_page_marks_max +\newcount\c_page_marks_nx +\newcount\c_page_marks_ny + +\startuniqueMPgraphic{print:color}{w,h,l,o} + loadmodule "crop" ; + page_marks_add_color(\MPvar w,\MPvar h,\MPvar l,\MPvar o) ; +\stopuniqueMPgraphic + +\startuniqueMPgraphic{print:marking}{w,h,l,o} + loadmodule "crop" ; + page_marks_add_marking(\MPvar w,\MPvar h,\MPvar l,\MPvar o) ; +\stopuniqueMPgraphic + +\startuniqueMPgraphic{print:lines}{w,h,l,o,x,y} + loadmodule "crop" ; + page_marks_add_lines(\MPvar w,\MPvar h,\MPvar l,\MPvar o,\MPvar x,\MPvar y, + \ifconditional\c_page_marks_add_page_lines tru\else fals\fi e) ; +\stopuniqueMPgraphic + +\startuseMPgraphic{print:number}{w,h,l,o,n} + loadmodule "crop" ; + page_marks_add_number(\MPvar w,\MPvar h,\MPvar l,\MPvar o,\MPvar n) ; +\stopuseMPgraphic + +\def\page_marks_add_color + {\setlayoutcomponentattribute{\v!print:\v!color}% + \setbox\scratchbox\hpack \layoutcomponentboxattribute\bgroup + \uniqueMPgraphic + {print:color}% + {w=\the\scratchwidth,h=\the\scratchheight,% + l=\pagecutmarklength,o=\pagecutmarkoffset}% + \egroup + \wd\scratchbox\scratchwidth\ht\scratchbox\scratchheight\dp\scratchbox\scratchdepth + \hskip-\scratchwidth\box\scratchbox} + +\def\page_marks_add_marking + {\setlayoutcomponentattribute{\v!print:\v!marking}% + \setbox\scratchbox\hpack \layoutcomponentboxattribute\bgroup + \uniqueMPgraphic + {print:marking}% + {w=\the\scratchwidth,h=\the\scratchheight,% + l=\pagecutmarklength,o=\pagecutmarkoffset}% + \egroup + \wd\scratchbox\scratchwidth\ht\scratchbox\scratchheight\dp\scratchbox\scratchdepth + \hskip-\scratchwidth\box\scratchbox} + +\def\page_marks_add_lines + {\setlayoutcomponentattribute{\v!print:\v!lines}% + \setbox\scratchbox\hpack \layoutcomponentboxattribute\bgroup + \uniqueMPgraphic + {print:lines}% + {w=\the\scratchwidth,h=\the\scratchheight,% + l=\pagecutmarklength,o=\pagecutmarkoffset,% + x=\the\c_page_marks_nx,y=\the\c_page_marks_ny}% + \egroup + \wd\scratchbox\scratchwidth\ht\scratchbox\scratchheight\dp\scratchbox\scratchdepth + \hskip-\scratchwidth\box\scratchbox} + +\def\page_marks_add_number + {\setlayoutcomponentattribute{\v!print:\v!number}% + \setbox\scratchbox\hpack \layoutcomponentboxattribute\bgroup + \useMPgraphic + {print:number}% + {w=\the\scratchwidth ,h=\the\scratchheight,% + l=\pagecutmarklength,o=\pagecutmarkoffset,% + n=\number\ifcase\arrangeno\realpageno\else\arrangeno\fi}% + \egroup + \wd\scratchbox\scratchwidth\ht\scratchbox\scratchheight\dp\scratchbox\scratchdepth + \hskip-\scratchwidth\box\scratchbox} + +\def\page_marks_add_page_indeed#1% + {\setbox#1\hpack\bgroup + \resetvisualizers + \let\objectoffset\pagecutmarkmargin + %\infofont + \scratchwidth \wd#1% + \scratchheight\ht#1% + \scratchdepth \dp#1% + \box#1\relax + \page_marks_add_lines + \egroup} + +\def\page_marks_add_more_indeed#1% + {\setbox#1\hbox\bgroup + \resetvisualizers + \let\objectoffset\pagecutmarkmargin + \infofont + \scratchwidth \wd#1% these can move out + \scratchheight\ht#1% + \scratchdepth \dp#1% + \box#1\relax + \ifconditional\c_page_marks_add_more_color + \page_marks_add_color + \fi + \ifconditional\c_page_marks_add_more_marking + \page_marks_add_marking + \fi + \ifconditional\c_page_marks_add_more_lines + \page_marks_add_lines + \fi + \ifconditional\c_page_marks_add_more_number + \page_marks_add_number + \fi + \global\advance\c_page_marks_max\minusone + \ifnum\c_page_marks_max>\zerocount\else + \glet\page_marks_add_more\gobbleoneargument + \glet\page_marks_add_page\gobbleoneargument + \fi + \egroup} + +\let\page_marks_add_page\gobbleoneargument +\let\page_marks_add_more\gobbleoneargument + +\installcorenamespace{layoutmarking} + +\permanent\protected\def\installpagecutmark#1#2% + {\setvalue{\??layoutmarking#1}{#2}} + +% \installpagecutmark\v!off +% {} + +% \installpagecutmark\v!text +% {\settrue\c_page_marks_add_more_lines +% \settrue\c_page_marks_add_more_number +% \let\pagecutmarksymbol\empty +% \let\pagecutmarkbottomtext\extrapagecutmarkbottomtext} + +\installpagecutmark\v!on + {%settrue\c_page_marks_add_page_lines + \settrue\c_page_marks_add_more_lines + \settrue\c_page_marks_add_more_number} + +\installpagecutmark\v!page + {\settrue\c_page_marks_add_page_lines + \settrue\c_page_marks_add_more_lines + \settrue\c_page_marks_add_more_number} + +\installpagecutmark\v!empty + {%settrue\c_page_marks_add_page_lines + \settrue\c_page_marks_add_more_lines} + +\installpagecutmark\v!color + {%settrue\c_page_marks_add_page_lines + \settrue\c_page_marks_add_more_lines + \settrue\c_page_marks_add_more_color + \settrue\c_page_marks_add_more_marking + \settrue\c_page_marks_add_more_number} + +\installpagecutmark\v!one {\global\c_page_marks_max\plusone} % first page +\installpagecutmark\v!two {\global\c_page_marks_max\plustwo} % first two pages +\installpagecutmark\v!four{\global\c_page_marks_max\plusfour} % first four pages + +\permanent\protected\def\page_marks_set#1% + {\begincsname\??layoutmarking#1\endcsname} + +\appendtoks + \setfalse\c_page_marks_add_page_lines + \setfalse\c_page_marks_add_more_color + \setfalse\c_page_marks_add_more_marking + \setfalse\c_page_marks_add_more_lines + \setfalse\c_page_marks_add_more_number + \global\c_page_marks_max\maxcount + \rawprocesscommacommand[\layoutparameter\c!marking]\page_marks_set + \ifnum\c_page_marks_max<\maxcount + \ifconditional\c_page_marks_add_page_lines \orelse + \ifconditional\c_page_marks_add_more_color \orelse + \ifconditional\c_page_marks_add_more_marking\orelse + \ifconditional\c_page_marks_add_more_lines \orelse + \ifconditional\c_page_marks_add_more_number \else + \settrue\c_page_marks_add_page_lines + \settrue\c_page_marks_add_more_number + \fi + \fi + \ifconditional\c_page_marks_add_page_lines + \let\page_marks_add_page\page_marks_add_page_indeed + \else + \let\page_marks_add_page\gobbleoneargument + \fi + % we can get a double set of (overlayed) lines .. needs to be redone (too many objects anyway) + \ifconditional\c_page_marks_add_more_lines + \let\page_marks_add_more\page_marks_add_more_indeed + \orelse\ifconditional\c_page_marks_add_more_color + \let\page_marks_add_more\page_marks_add_more_indeed + \orelse\ifconditional\c_page_marks_add_more_marking + \let\page_marks_add_more\page_marks_add_more_indeed + \orelse\ifconditional\c_page_marks_add_more_number + \let\page_marks_add_more\page_marks_add_more_indeed + \else + \let\page_marks_add_more\gobbleoneargument + \fi +\to \everysetuplayout + +\setuplayout + [\c!marking=\v!off] + +\protect \endinput diff --git a/tex/context/base/mkiv/page-not.mkxl b/tex/context/base/mkxl/page-not.mkxl index 2d1c3fea6..82523cc66 100644 --- a/tex/context/base/mkiv/page-not.mkxl +++ b/tex/context/base/mkxl/page-not.mkxl @@ -21,7 +21,7 @@ \newdimen\totalinsertionheight -\protected\def\settotalinsertionheight +\permanent\protected\def\settotalinsertionheight {\calculatetotalnoteheight \totalinsertionheight\dimexpr \totalnoteheight diff --git a/tex/context/base/mkiv/page-one.mkxl b/tex/context/base/mkxl/page-one.mkxl index 3e7d3e2a8..3e7d3e2a8 100644 --- a/tex/context/base/mkiv/page-one.mkxl +++ b/tex/context/base/mkxl/page-one.mkxl diff --git a/tex/context/base/mkiv/page-otr.mklx b/tex/context/base/mkxl/page-otr.mklx index 797e31274..e93590bf6 100644 --- a/tex/context/base/mkiv/page-otr.mklx +++ b/tex/context/base/mkxl/page-otr.mklx @@ -34,7 +34,7 @@ \newtoks\t_page_otr_commands \newtoks\t_page_otr_tracers -\protected\def\defineoutputroutinecommand[#name]% doing multiple on one go saves syncing +\permanent\protected\def\defineoutputroutinecommand[#name]% doing multiple on one go saves syncing {\processcommalist[#name]\page_otr_commands_define} \protected\def\page_otr_commands_define#name% @@ -81,7 +81,7 @@ \let\page_otr_specifics_preset\page_otr_specifics_preset_normal -\protected\def\traceoutputroutines +\permanent\protected\def\traceoutputroutines {\the\t_page_otr_tracers} \appendtoks @@ -137,7 +137,7 @@ \penalty#penalty% \endgroup} -\protected\def\installoutputroutine#invoke#action% \invoke \action +\permanent\protected\def\installoutputroutine#invoke#action% \invoke \action {\global\advance\c_page_otr_trigger_penalty\minusone \frozen\protected\edef#invoke{\page_otr_trigger{\number\c_page_otr_trigger_penalty}}% \setvalue{\??otrtriggers\number\c_page_otr_trigger_penalty}{#action}} @@ -266,7 +266,7 @@ %D For those who've read the plain \TEX\ book, we provide the next %D macro: -\protected\def\bye +\permanent\protected\def\bye {\writestatus\m!system{Sorry, you're not done yet, so no goodbye!}} %D We define a few constants because that (1) provides some checking diff --git a/tex/context/base/mkxl/page-par.mkxl b/tex/context/base/mkxl/page-par.mkxl new file mode 100644 index 000000000..c198784dc --- /dev/null +++ b/tex/context/base/mkxl/page-par.mkxl @@ -0,0 +1,73 @@ +%D \module +%D [ file=page-par, % copied from page-lin +%D version=1997.03.31, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Line Numbering, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Paragraph Numbering} + +\unprotect + +\installcorenamespace {paragraphnumbering} +\installcorenamespace {paragraphnumberingvariants} + +\installsimplecommandhandler \??paragraphnumbering {paragraphnumbering} \??paragraphnumbering + +\definecounter[\v!paragraph] + +\permanent\let\showparagraphnumber\relax + +\appendtoks + \page_par_check_state +\to \everysetupparagraphnumbering + +\protected\def\page_par_check_state + {\rawprocesscommacommand[\paragraphnumberingparameter\c!state]\page_par_check_state_step} + +\def\page_par_check_state_step#1% + {\ifcsname\??paragraphnumberingvariants#1\endcsname + \lastnamedcs + \fi} + +\setvalue{\??paragraphnumberingvariants\v!start}% + {\enforced\let\showparagraphnumber\page_par_show_number_normal} + +\setvalue{\??paragraphnumberingvariants\v!stop}% + {\enforced\let\showparagraphnumber\relax} + +\setvalue{\??paragraphnumberingvariants\v!line}% + {\enforced\let\showparagraphnumber\page_par_show_number_lines} + +\setvalue{\??paragraphnumberingvariants\v!reset}% + {\strc_counters_reset\v!paragraph + \enforced\let\showparagraphnumber\page_par_show_number_normal} + +\permanent\protected\def\page_par_show_number_normal + {\strc_counters_increment\v!paragraph + \inleftmargin % todo: \c!location, only a few make sense + {\hfill % no complaints + \tf % \tf normalizes em + \useparagraphnumberingstyleandcolor\c!style\c!color + \convertedcounter[\v!paragraph]% + \kern\paragraphnumberingparameter\c!distance}} + +\permanent\protected\def\page_par_show_number_lines + {\ifnumberinglines + \page_par_show_number_normal + \fi} + +\setupparagraphnumbering + [\c!state=\v!stop, + %\c!location, + %\c!style=, + %\c!color=, + \c!distance=\ifcase\c_page_lines_location2\emwidth\else\zeropoint\fi] % will change + +\protect \endinput diff --git a/tex/context/base/mkxl/page-pcl.mkxl b/tex/context/base/mkxl/page-pcl.mkxl new file mode 100644 index 000000000..173fad91a --- /dev/null +++ b/tex/context/base/mkxl/page-pcl.mkxl @@ -0,0 +1,857 @@ +%D \module +%D [ file=page-pcl, +%D version=2017.11.08, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Page Columns, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Page Columns} + +%D This is very experimental code! We took a bit from the mixed columns and single +%D column page code. This one works acceptable with floats and is for whole double +%D column documents. We don't balance (yet). Footnotes are per column. One can have +%D side floats too. No balancing and other fancy features. +%D +%D Don't use this in production! Although the main approach will stay there might be +%D changes in the way floats are dealt with. Not much testing has been done but as +%D we stay close to the single column mode we expect most to just work. Only floats +%D are the (usual) pain. Backgrounds, line numbering, etc.\ not tested either. + +\unprotect + +\definemeasure[onecolumn] [\columnwidth] +\definemeasure[twocolumns] [\dimexpr\plustwo \columnwidth+ \columndistance\relax] +\definemeasure[threecolumns][\dimexpr\plusthree\columnwidth+\plustwo \columndistance\relax] +\definemeasure[fourcolumns] [\dimexpr\plusfour \columnwidth+\plusthree\columndistance\relax] + +\newcount \c_page_col_n_of_columns \c_page_col_n_of_columns\plusone +\newcount \c_page_col_current \c_page_col_current \plusone +\newdimen \d_page_col_distance +\newdimen \d_page_col_max_height +\newdimen \d_page_col_max_width +%newdimen \d_page_col_balance_step +\newdimen \d_page_col_column_width +\newdimen \d_page_col_top_height +\newdimen \d_page_col_top_width +\newdimen \d_page_col_available +\newdimen \d_page_col_sofar +\newconditional\c_page_col_page + +%D We need to step over empty columns. + +\protected\def\page_col_command_next_page + {\page_col_eject_page} + +\permanent\protected\def\page_col_column + {\page_otr_eject_page} + +\protected\def\page_col_eject_page + {\begingroup + \scratchcountertwo \realpageno + \page_otr_eject_page + \scratchcounterone \c_page_col_current + \scratchcounterthree\zerocount + \doloop{% + \ifnum\scratchcounterthree>\plushundred + % too many attempts + \exitloop + \orelse\ifnum\realpageno>\scratchcountertwo + % we advanced at least one page so we're done + \exitloop + \else + \ifnum\scratchcounterone=\c_page_col_current + \dontleavehmode\null + \fi + \page_otr_eject_page + \scratchcounterone\c_page_col_current + \advance\scratchcounterthree\plusone + \fi + }% + \endgroup} + +%D \unknown + +\protected\def\page_col_command_next_page_and_inserts + {\page_otr_eject_page_and_flush_inserts} + +%D \unknown + +\protected\def\page_col_command_set_hsize + {\global\hsize\d_page_col_column_width\relax + \global\d_page_col_available\dimexpr + \numexpr\c_page_col_n_of_columns-\c_page_col_current+\plusone\relax\d_page_col_column_width + + \numexpr\c_page_col_n_of_columns-\c_page_col_current \relax\d_page_col_distance + \relax + \global\d_page_col_sofar + \ifnum\c_page_col_n_of_columns=\plusone + \zeropoint + \else + \numexpr\c_page_col_n_of_columns-\plusone\relax + \dimexpr\d_page_col_column_width+\d_page_col_distance\relax + \fi + % consistent with mixed: + \textwidth\d_page_col_column_width} + +%D \unknown + +\protected\def\page_col_command_set_vsize % \page_one_command_set_vsize minus the pagegoal setting + {\ifgridsnapping + \ifcase\layoutlines + \getrawnoflines\textheight + \else + \noflines\layoutlines + \fi + \global\vsize\noflines\openlineheight + \else + \global\vsize\textheight + \fi} + +%D \unknown + +\def\page_col_registered_text_area_b#1% + {\begingroup + \makeupwidth\d_page_col_column_width + \page_one_registered_text_area_b{#1}% + \endgroup} + +\protected\def\page_col_command_package_contents#1#2% \box<n> \unvbox<n> % this one will be redone (checked) + {\bgroup + \setbox\b_page_one_contents\vbox to \textheight + {\page_one_registered_text_area_a#1#2}% + \page_one_command_package_show_state + \ht\b_page_one_contents\textheight + \page_col_registered_text_area_b + {\box\b_page_one_contents}% + \egroup} + +\protected\def\page_col_command_package_contents_one#1#2% \box<n> \unvbox<n> % this one will be redone (checked) + {\bgroup + \forgetall + % see one for comments as it is similar + \strc_notes_check_if_bottom_present + \d_page_one_natural_depth\dp#2\relax + \setbox\b_page_one_contents\vbox to \textheight + {\page_col_command_flush_top_insertions + \page_one_registered_text_area_a#1#2% + \hsize\d_page_col_column_width + \ifgridsnapping + \vskip\dimexpr\openstrutdepth-\d_page_one_natural_depth\relax + \prevdepth\openstrutdepth + \page_col_command_flush_bottom_insertions + \vfil + \orelse\ifcase\bottomraggednessmode + % ragged (default) + \vskip\dimexpr\openstrutdepth-\d_page_one_natural_depth\relax + \prevdepth\openstrutdepth + \page_col_command_flush_bottom_insertions + \vfil + \or + % align (normal) + \page_col_command_flush_bottom_insertions + \or + % baseline + \kern\dimexpr\maxdepth-\d_page_one_natural_depth\relax + \page_col_command_flush_bottom_insertions + \fi + \fakepagenotes}% + \page_one_command_package_show_state + \ifconditional\c_notes_bottom_present + \ifgridsnapping + \ifcase\layoutlines + \getrawnoflines\textheight + \else + \noflines\layoutlines + \fi + \scratchoffset\dimexpr\numexpr\noflines-\plusone\relax\lineheight+\topskip\relax + \else + \scratchoffset\ht\b_page_one_contents + \fi + \setbox\b_page_one_bottom_notes\hpack + {\hsize\d_page_col_column_width + \setupnotes[\c!width=\textwidth]% + \lower\scratchoffset\vbox{\placebottomnotes\par\kern\zeropoint}}% + \ht\b_page_one_contents \zeropoint + \wd\b_page_one_contents \zeropoint + \ht\b_page_one_bottom_notes\zeropoint + \wd\b_page_one_bottom_notes\zeropoint + \wd\b_page_one_bottom_notes\d_page_col_column_width + \page_col_registered_text_area_b + {\vpack to \textheight + {\hpack{\box\b_page_one_contents\box\b_page_one_bottom_notes}}}% + \else + \ht\b_page_one_contents\textheight + \wd\b_page_one_contents\d_page_col_column_width + \page_col_registered_text_area_b + {\box\b_page_one_contents}% + \fi + \egroup} + +%D \unknown + +\protected\def\page_col_command_side_float_output + {% % % + \ifvoid\namedinsertionnumber\s!topfloat\else + \scratchwidth\wd\namedinsertionnumber\s!topfloat + \ifdim\scratchwidth>\d_page_col_top_width + \global\d_page_col_top_width \scratchwidth + \fi + \global\d_page_col_top_height\ht\namedinsertionnumber\s!topfloat + \fi + % % % + \setbox\scratchbox\vbox\bgroup + \page_col_command_package_contents_one\unvbox\normalpagebox + \egroup + \putboxincache\s!pagecolumn{\number\c_page_col_current}\scratchbox + \ifnum\c_page_col_current=\c_page_col_n_of_columns + \page_col_routine_package + \page_otr_construct_and_shipout\box\normalpagebox\plusone + \global\c_page_col_current\plusone + \global\d_page_col_top_height\zeropoint + \global\d_page_col_top_width\zeropoint + % \page_col_command_flush_top_insertions + % \page_col_command_flush_floats + \else + \ifdim\d_page_col_top_width>\zeropoint + \ifdim\dimexpr\d_page_col_top_width>\d_page_col_sofar\relax + \begingroup + \floatingpenalty\zerocount + \insert\namedinsertionnumber\s!topfloat\bgroup + \vbox to \d_page_col_top_height{\vss} + % can be an option + \page_col_command_flush_top_insertions + \page_col_command_flush_floats + % so far till option + \egroup + \endgroup + \fi + \fi + \global\advance\c_page_col_current\plusone + \fi + % + \page_col_command_set_vsize + \page_col_command_set_hsize} + +% use \currentmixedcolumns instead of \recurselevel + +\def\page_col_routine_package_step + {% needs packaging anyway + \getboxfromcache{\s!pagecolumn}{\number\recurselevel}\scratchbox + \page_lines_add_numbers_to_box\scratchbox\recurselevel\c_page_col_n_of_columns\plusone % new + \page_marks_synchronize_column\plusone\c_page_col_n_of_columns\recurselevel\scratchbox + % backgrounds + \anch_mark_column_box\scratchbox\recurselevel + \mixedcolumnseparatorheight\ht\scratchbox + \mixedcolumnseparatordepth \dp\scratchbox + \inheritedpagecolumnsframedbox\recurselevel\scratchbox} + +\def\page_col_routine_package + {\global\setbox\normalpagebox\hbox to \makeupwidth\bgroup + \edef\p_separator{\pagecolumnsparameter\c!separator}% + \pagecolumnseparatorwidth\d_page_col_distance + \edef\p_direction{\pagecolumnsparameter\c!direction}% + \ifx\p_direction\v!reverse + \dostepwiserecurse\c_page_col_n_of_columns\plusone\minusone + {\page_col_routine_package_step + \ifnum\recurselevel>\plusone + \page_col_routine_package_separate + \fi}% + \else + \dorecurse\c_page_col_n_of_columns + {\page_col_routine_package_step + \ifnum\recurselevel<\c_page_col_n_of_columns + \page_col_routine_package_separate + \fi}% + \fi + \egroup + \resetboxesincache{\s!pagecolumn}} + +%D \unknown + +% \protected\def\page_col_command_check_if_float_fits +% {\ifconditional\c_page_floats_not_permitted +% \global\setfalse\c_page_floats_room +% %\orelse\ifabsdim\dimexpr\d_page_col_available-\naturalfloatwd\relax<\onepoint +% \orelse\ifdim\dimexpr\d_page_col_available-\naturalfloatwd\relax>-\onepoint +% \global\settrue\c_page_floats_room +% \else +% \global\setfalse\c_page_floats_room +% \fi +% \ifconditional\c_page_floats_room +% \begingroup +% \scratchdimen\dimexpr\pagetotal+\lineheight\relax +% \ifdim\scratchdimen>\pagegoal +% \goodbreak +% \ifdim\dimexpr\d_page_col_available-\naturalfloatwd\relax>\onepoint +% \global\setfalse\c_page_floats_room +% \else +% \global\settrue\c_page_floats_room +% \fi +% \fi +% \endgroup +% \fi +% \ifconditional\c_page_floats_room +% \ifdim\pagetotal>\zeropoint +% \scratchdimenone\dimexpr\pagetotal+\floatheight+\d_strc_floats_top-\pageshrink\relax +% \scratchdimentwo\pagegoal +% \relax % needed +% \ifcase\c_page_one_float_method +% % method 0 : raw +% \or +% % method 1 : safe +% \advance\scratchdimentwo -\strutdp +% \or +% % method 2 : tight +% \advance\scratchdimenone -\onepoint +% \fi +% \relax % really needed ! ! ! ! +% \ifdim\scratchdimenone>\scratchdimentwo +% \global\setfalse\c_page_floats_room +% \fi +% \fi +% \ifconditional\c_page_floats_room +% \global\setbox\floatbox\hpack to \d_page_col_available{\hss\box\floatbox\hss}% +% \fi +% \fi} + +\protected\def\page_col_command_check_if_float_fits + {\ifconditional\c_page_floats_not_permitted + % forget about it anyway + \global\setfalse\c_page_floats_room + \else + % first we check the current column +% \ifdim\dimexpr\d_page_col_width-\naturalfloatwd\relax>-\onepoint + \ifdim\dimexpr\hsize-\naturalfloatwd\relax>-\onepoint + \global\settrue\c_page_floats_room + \else + \global\setfalse\c_page_floats_room + \fi + \ifconditional\c_page_floats_room + % we fit in the column but do we have room + \ifdim\dimexpr\pagetotal+\lineheight\relax>\pagegoal + % try again later + \goodbreak + \fi + \ifdim\pagetotal>\zeropoint + \scratchdimenone\dimexpr\pagetotal+\floatheight+\d_strc_floats_top-\pageshrink\relax + \scratchdimentwo\pagegoal + \relax % needed + \ifcase\c_page_one_float_method + % method 0 : raw + \or + % method 1 : safe + \advance\scratchdimentwo -\strutdp + \or + % method 2 : tight + \advance\scratchdimenone -\onepoint + \fi + \relax % really needed ! ! ! ! + \ifdim\scratchdimenone>\scratchdimentwo + % there is no room, give up + \global\setfalse\c_page_floats_room + % now we can decide on a top float +% \fi + \else +% \ifconditional\c_page_floats_room +% \global\setbox\floatbox\hpack to \d_page_col_float_available{\hss\box\floatbox\hss}% +% \fi + \fi + \fi + \fi + \fi} + +%D \unknown + +\def\page_col_set_float_pack_hsize + {\ifnum\c_page_col_current=\c_page_col_n_of_columns + \c_page_col_current\plusone + \else + \advance\c_page_col_current\plusone + \fi + \page_col_command_set_hsize + \hsize\d_page_col_available} + +\protected\def\page_col_command_flush_floats + {\global\settrue\c_page_floats_flushing + \ifconditional\c_page_floats_some_waiting + \par + \page_col_set_float_pack_hsize + \page_col_command_flush_floats_indeed + \fi + \global\savednoffloats\zerocount + \global\setfalse\c_page_floats_some_waiting + \global\setfalse\c_page_floats_flushing} + +\def\page_floats_show_pack_state_indeed#1% + {\llap{\smash{\backgroundline[black]{\strut\smallinfofont\white#1\space\the\nofcollectedfloats\space of\space\the\savednoffloats:\the\hsize}}\hskip.25\emwidth}} + +\installtextracker + {floats.collecting} + {\let\page_floats_show_pack_state\page_floats_show_pack_state_indeed} + {\let\page_floats_show_pack_state\gobbleoneargument} + +\let\page_floats_show_pack_state\gobbleoneargument + +\def\page_col_command_flush_floats_indeed % much in common with OTRSET + {\ifconditional\c_page_floats_some_waiting + \ifconditional\c_page_floats_compress_flushed + \setfalse\c_page_floats_center_box % not needed as we do call directly + \page_floats_collect\s!text\hsize\d_page_floats_compress_distance + % + \ifnum\nofcollectedfloats=\plusone + \ifdim\naturalfloatwd>\hsize + \nofcollectedfloats\zerocount + \fi + \fi + \ifnum\nofcollectedfloats>\zerocount + \global\setbox\floatbox\hpack to \hsize + {\page_floats_show_pack_state F% + \hfil + \dorecurse\nofcollectedfloats + {\ifcase\columndirection % nog document wide + \page_floats_flush\s!text\plusone + \else + \page_floats_flush\s!text{\the\numexpr\nofcollectedfloats-\recurselevel+1\relax}% + \fi + % this could happen at the lua end instead + \scratchdimen\dimexpr\wd\floatbox-\naturalfloatwd\relax + \ifdim\scratchdimen<\zeropoint + \global\setbox\floatbox\hpack spread -\scratchdimen{\hss\box\floatbox\hss}% + \fi + % + \ifdim\wd\floatbox>\textwidth % \hsize + \hpack to \textwidth{\hss\box\floatbox\hss}% \textwidth + \else + \box\floatbox + \fi + \ifnum\recurselevel<\nofcollectedfloats + \hfil + \fi}% + \hfil}% + \doplacefloatbox + % \page_one_insert_top_float + \doubleexpandafter\page_col_command_flush_floats_indeed + \else + % todo + \fi + \else + \page_floats_get + % \page_one_insert_top_float + \doplacefloatbox + \doubleexpandafter\page_col_command_flush_floats_indeed + \fi + \fi} + +\protected\def\page_col_command_flush_saved_floats % like one + {\global\d_page_floats_inserted_top\zeropoint + \global\d_page_floats_inserted_bottom\zeropoint + \ifconditional\c_page_floats_flushing \else + \page_col_command_set_top_insertions + \page_col_command_set_bottom_insertions + \ifconditional\c_page_floats_some_waiting + \doif{\rootfloatparameter\c!cache}\v!no\page_col_command_flush_floats % could be _otr_ + \orelse\ifconditional\c_page_margin_blocks_present + \page_col_command_flush_floats + \fi + \fi} + +\protected\def\page_col_command_set_top_insertions + {\bgroup + \ifconditional\c_page_floats_some_waiting + \noffloatinserts\zerocount + \let\totaltopinserted\!!zeropoint + \page_col_set_float_pack_hsize + \page_col_command_set_top_insertions_indeed + \ifnum\rootfloatparameter\c!nbottom=\zerocount + \ifnum\rootfloatparameter\c!nlines>\zerocount + \ifdim\totaltopinserted>\zeropoint\relax + \ifdim\dimexpr\rootfloatparameter\c!nlines\lineheight+\totaltopinserted\relax>\textheight + \showmessage\m!floatblocks8{\rootfloatparameter\c!nlines}% + \page_otr_fill_and_eject_page % was tripple: vfilll + \fi + \fi + \fi + \fi + \fi + \egroup} + +\def\d_page_col_collected_top_float_height % pseudo + {\dimexpr + \d_page_floats_inserted_top + + \maxcollectedfloatstotal + + \ifdim\d_strc_floats_top>\d_strc_floats_bottom + \d_strc_floats_top + \else + \d_strc_floats_bottom + \fi + \relax} + +\def\page_col_command_set_top_insertions_indeed + {\ifnum\noffloatinserts<\c_page_floats_n_of_top + \ifcase\savednoffloats + \let\page_col_command_set_top_insertions_indeed\relax + \else + \page_floats_collect\s!text\hsize\emwidth + \ifdim\d_page_col_collected_top_float_height<\textheight + \global\setbox\floatbox\hpack to \hsize + {\page_floats_show_pack_state T% + \hfil + \dorecurse\nofcollectedfloats + {\ifcase\columndirection % nog document wide + \page_floats_flush\s!text\plusone + \else + \page_floats_flush\s!text{\the\numexpr\nofcollectedfloats-\recurselevel+1\relax}% + \fi + % this could happen at the lua end instead + \scratchdimen\dimexpr\wd\floatbox-\naturalfloatwd\relax + \ifdim\scratchdimen<\zeropoint + \global\setbox\floatbox\hpack spread -\scratchdimen{\hss\box\floatbox\hss}% + \fi + % + \ifdim\wd\floatbox>\makeupwidth % \hsize + \hpack to \makeupwidth{\hss\box\floatbox\hss}% + \else + \box\floatbox + \fi + \ifnum\recurselevel<\nofcollectedfloats + \hfil + \fi}% + \hfil}% + \page_one_prepare_top_float + \xdef\totaltopinserted{\the\d_page_floats_inserted_top}% + \page_one_insert_top_float + \ifconditional\c_page_floats_some_waiting + \advance\noffloatinserts \plusone + \else + \noffloatinserts\c_page_floats_n_of_top\relax + \fi + \page_floats_report_flushed + \else + \let\page_col_command_set_top_insertions_indeed\relax + \fi + \fi + \else + \ifconditional\c_page_floats_some_waiting + \showmessage\m!floatblocks6{\the\c_page_floats_n_of_top}% + \fi + \let\page_col_command_set_top_insertions_indeed\relax + \fi + \page_col_command_set_top_insertions_indeed} + +\let\page_col_command_flush_top_insertions \page_one_command_flush_top_insertions +\let\page_col_command_flush_bottom_insertions\page_one_command_flush_bottom_insertions + +%let\page_col_command_set_top_insertions \page_one_command_set_top_insertions +\let\page_col_command_set_bottom_insertions \page_one_command_set_bottom_insertions + +%let\page_col_command_set_top_insertions_indeed \page_one_command_set_top_insertions +\let\page_col_command_set_bottom_insertions_indeed \page_one_command_set_botttom_insertions + +\let\page_col_command_flush_float_box \page_one_command_flush_float_box +\let\page_col_command_synchronize_side_floats \page_one_command_synchronize_side_floats +\let\page_col_command_flush_side_floats \page_one_command_flush_side_floats +\let\page_col_command_flush_margin_blocks \page_one_command_flush_margin_blocks +\let\page_col_command_test_page \page_one_command_test_page + +%D The separator code is more or less the same as mixed columns but we need +%D to compensate for the top floats so we comment a bit for now. + +\newdimen\pagecolumnseparatorheight +\newdimen\pagecolumnseparatordepth +\newdimen\pagecolumnseparatorwidth + +% \installcorenamespace{pagecolumnsseparator} +% +% \protected\def\installpagecolumnseparator#1#2% +% {\setvalue{\??pagecolumnsseparator#1}{#2}} +% +% \installpagecolumnseparator\v!rule +% {\vrule +% \s!width \pagecolumnsparameter\c!rulethickness +% \s!height\pagecolumnseparatorheight +% \s!depth \pagecolumnseparatordepth +% \relax} +% +% \def\page_col_routine_package_separate +% {\ifcsname\??pagecolumnsseparator\p_separator\endcsname +% \page_col_command_inject_separator +% \else +% \hss +% \fi} +% +% \protected\def\page_col_command_inject_separator +% {\begingroup +% \setbox\scratchbox\hbox to \zeropoint \bgroup +% \hss +% \starttextproperties +% \usepagecolumnscolorparameter\c!rulecolor +% \begincsname\??pagecolumnsseparator\p_separator\endcsname % was \c!rule +% \stoptextproperties +% \hss +% \egroup +% \ht\scratchbox\zeropoint +% \dp\scratchbox\zeropoint +% \hss +% \box\scratchbox +% \hss +% \endgroup} + +\def\page_col_routine_package_separate + {\hss} + +%D \unknown + +\protected\def\page_col_command_routine + {\page_sides_output_routine} + +% % not: +% +% \protected\def\page_col_command_routine +% {\ifconditional\c_page_sides_short +% \page_sides_output_routine_yes_column +% \else +% \page_sides_output_routine_nop_column +% \fi} +% +% \let\page_sides_output_routine_nop_column\page_sides_output_routine +% +% \def\page_sides_output_routine_yes_column % this might become the main one too +% {\unvbox\normalpagebox % bah, and the discards? +% %\page_col_column +% \column % \page +% % why was this \global\holdinginserts\zerocount +% \global\setfalse\c_page_sides_short} + +\let\page_col_command_flush_all_floats\relax + +%D \unknown + +\defineoutputroutine + [\s!pagecolumn] + [\s!page_otr_command_routine =\page_col_command_routine, + \s!page_otr_command_package_contents =\page_col_command_package_contents, + \s!page_otr_command_set_vsize =\page_col_command_set_vsize, + \s!page_otr_command_set_hsize =\page_col_command_set_hsize, + % \s!page_otr_command_synchronize_hsize =\page_col_command_synchronize_hsize, % not done + \s!page_otr_command_next_page =\page_col_command_next_page, + \s!page_otr_command_next_page_and_inserts =\page_col_command_next_page_and_inserts, + \s!page_otr_command_set_top_insertions =\page_col_command_set_top_insertions, + \s!page_otr_command_set_bottom_insertions =\page_col_command_set_bottom_insertions, + \s!page_otr_command_flush_top_insertions =\page_col_command_flush_top_insertions, + \s!page_otr_command_flush_bottom_insertions=\page_col_command_flush_bottom_insertions, + \s!page_otr_command_check_if_float_fits =\page_col_command_check_if_float_fits, + % \s!page_otr_command_set_float_hsize =\page_col_command_set_float_hsize, % not done + \s!page_otr_command_flush_float_box =\page_col_command_flush_float_box, + \s!page_otr_command_side_float_output =\page_col_command_side_float_output, + \s!page_otr_command_synchronize_side_floats=\page_col_command_synchronize_side_floats, + \s!page_otr_command_flush_floats =\page_col_command_flush_floats, + \s!page_otr_command_flush_side_floats =\page_col_command_flush_side_floats, + \s!page_otr_command_flush_saved_floats =\page_col_command_flush_saved_floats, + \s!page_otr_command_flush_all_floats =\page_col_command_flush_all_floats, + \s!page_otr_command_flush_margin_blocks =\page_col_command_flush_margin_blocks, + \s!page_otr_command_test_column =\page_col_command_test_page + ] + +%D \unknown + +\installfloatmethod \s!pagecolumn \v!here \page_one_place_float_here +\installfloatmethod \s!pagecolumn \v!force \page_one_place_float_force +\installfloatmethod \s!pagecolumn \v!left \page_one_place_float_left +\installfloatmethod \s!pagecolumn \v!right \page_one_place_float_right +\installfloatmethod \s!pagecolumn \v!text \page_one_place_float_text +\installfloatmethod \s!pagecolumn \v!top \page_one_place_float_top +\installfloatmethod \s!pagecolumn \v!bottom \page_one_place_float_bottom +\installfloatmethod \s!pagecolumn \v!auto \page_one_place_float_auto +\installfloatmethod \s!pagecolumn \v!margin \page_one_place_float_margin +\installfloatmethod \s!pagecolumn \v!opposite \page_one_place_float_face +\installfloatmethod \s!pagecolumn \v!page \page_one_place_float_page +\installfloatmethod \s!pagecolumn \v!leftpage \page_one_place_float_leftpage +\installfloatmethod \s!pagecolumn \v!rightpage \page_one_place_float_rightpage +\installfloatmethod \s!pagecolumn \v!inmargin \page_one_place_float_inmargin +\installfloatmethod \s!pagecolumn \v!inleft \page_one_place_float_leftmargin +\installfloatmethod \s!pagecolumn \v!inright \page_one_place_float_rightmargin +\installfloatmethod \s!pagecolumn \v!leftmargin \page_one_place_float_leftmargin +\installfloatmethod \s!pagecolumn \v!rightmargin \page_one_place_float_rightmargin +\installfloatmethod \s!pagecolumn \v!leftedge \page_one_place_float_leftedge +\installfloatmethod \s!pagecolumn \v!rightedge \page_one_place_float_rightedge +\installfloatmethod \s!pagecolumn \v!somewhere \page_one_place_float_somewhere +\installfloatmethod \s!pagecolumn \v!backspace \page_one_place_float_backspace +\installfloatmethod \s!pagecolumn \v!cutspace \page_one_place_float_cutspace +%installfloatmethod \s!pagecolumn \s!tblr \page_one_place_float_top +%installfloatmethod \s!pagecolumn \s!lrtb \page_one_place_float_top +%installfloatmethod \s!pagecolumn \s!tbrl \page_one_place_float_top +%installfloatmethod \s!pagecolumn \s!fxtb \page_one_place_float_top +%installfloatmethod \s!pagecolumn \s!rltb \page_one_place_float_top +%installfloatmethod \s!pagecolumn \s!btlr \page_one_place_float_bottom +%installfloatmethod \s!pagecolumn \s!lrbt \page_one_place_float_bottom +%installfloatmethod \s!pagecolumn \s!btrl \page_one_place_float_bottom +%installfloatmethod \s!pagecolumn \s!rlbt \page_one_place_float_bottom +%installfloatmethod \s!pagecolumn \s!fxbt \page_one_place_float_bottom +%installfloatmethod \s!pagecolumn \s!fixd \page_one_place_float_force + +\installfloatmethod \s!pagecolumn \v!local \somelocalfloat + +%D The main interface: + +\installcorenamespace{pagecolumns} + +\installframedcommandhandler \??pagecolumns {pagecolumns} \??pagecolumns + +\setuppagecolumns + [\c!distance=1.5\bodyfontsize, + \c!n=\plustwo, + \c!page=\v!yes, + %\c!align=, % inherit (also replaces tolerance) + %\c!before=, + %\c!after=, + %\c!separator=\v!none, + %\c!setups=, + %\c!balance=\v!no, + %\c!blank={\v!line,\v!fixed}, yes or no + \c!frame=\v!off, + \c!strut=\v!no, + \c!offset=\v!overlay, + %\c!maxheight=\textheight, + \c!maxwidth=\makeupwidth, + %\c!grid=\v!tolerant, + %\c!internalgrid=\v!line, + \c!direction=\v!normal] + +\appendtoks % could become an option + \frozen\instance\setuevalue{\e!start\currentpagecolumns}{\startpagecolumns[\currentpagecolumns]}% + \frozen\instance\setuevalue{\e!stop \currentpagecolumns}{\stoppagecolumns}% +\to \everydefinepagecolumns + +\def\page_col_pickup_preceding + {\begingroup + \setupoutputroutine[\s!mixedcolumn]% + \c_page_mix_routine\c_page_mix_routine_intercept + \page_otr_trigger_output_routine + \ifvoid\b_page_mix_preceding \else + % moved here, before the packaging + \page_postprocessors_linenumbers_deepbox\b_page_mix_preceding + % we need to avoid unvboxing with successive balanced on one page + \global\setbox\b_page_mix_preceding\vbox\bgroup + % yes or no: \forcestrutdepth + \unvbox\b_page_mix_preceding + \forcestrutdepth + \egroup + \wd\b_page_mix_preceding\makeupwidth + \global\d_page_mix_preceding_height\ht\b_page_mix_preceding + \fi + \endgroup} + +\def\page_col_flush_preceding + {\ifvoid\b_page_mix_preceding \else + % this is just one method but ok for now + \begingroup + % we might need more but for now this is ok + \setupfloat[\c!spacebefore=,\c!spaceafter=]% + \startplacefigure[\c!location={\v!top,\v!none}]% + \box\b_page_mix_preceding + \stopplacefigure + \endgroup + \fi} + +\permanent\tolerant\protected\def\startpagecolumns[#1]% + {\begingroup + \begingroup + \doifelseassignment{#1}% + {\let\currentpagecolumns\empty + \setuppagecolumns[#1]}% + {\edef\currentpagecolumns{#1}}% + \edef\p_page{\pagecolumnsparameter\c!page}% + \ifx\p_page\empty + \setfalse\c_page_col_page + \orelse\ifx\p_page\v!no + \setfalse\c_page_col_page + \else + \settrue\c_page_col_page + \page[\p_page]% + \fi + \c_page_col_n_of_columns\pagecolumnsparameter\c!n\relax + \ifnum\c_page_col_n_of_columns>\plusone + \expandafter\page_col_start_yes + \else + \expandafter\page_col_start_nop + \fi} % public + +\aliased\let\stoppagecolumns\relax + +\protected\def\page_col_start_yes + {\d_page_col_distance \pagecolumnsparameter\c!distance\relax + % \d_page_col_max_height \pagecolumnsparameter\c!maxheight + \d_page_col_max_width \pagecolumnsparameter\c!maxwidth + % \d_page_col_balance_step \pagecolumnsparameter\c!step + \c_page_col_current \plusone + % + \d_page_col_column_width\dimexpr(\d_page_col_max_width-\d_page_col_distance*\numexpr(\c_page_col_n_of_columns-\plusone)\relax)/\c_page_col_n_of_columns\relax + % + \columnwidth \d_page_col_column_width + \columndistance \d_page_col_distance + \nofcolumns \c_page_col_n_of_columns + \textwidth \columnwidth % kind of redundant + % + \nopenalties + % + % \insidecolumnstrue % NO! + % + \enforced\let\column\page_col_column + % + \def\page_floats_get_used_hsize{\makeupwidth} % a bit of a hack + % + \usealignparameter \pagecolumnsparameter + \useblankparameter \pagecolumnsparameter + % \useprofileparameter\pagecolumnsparameter + % + \usepagecolumnscolorparameter\c!color + % + \setupnotes[\c!width=\textwidth]% + % + \usesetupsparameter\pagecolumnsparameter + % + % This will become a method but for now it's good enough + % + \ifconditional\c_page_col_page\else + \page_col_pickup_preceding + \fi + \setupoutputroutine[\s!pagecolumn]% + \ifconditional\c_page_col_page\else + \page_col_flush_preceding + \fi + % + \setupfloats[\c!ntop=\plusthousand]% + % \setupfloats[\c!nbottom=\plusthousand]% + % + \page_col_command_set_vsize + \page_col_command_set_hsize + % + \enforced\permanent\protected\def\startpagecolumns[##1]{\page_col_start_nop}% + % + \enforced\let\stoppagecolumns\page_col_stop_yes} + +\protected\def\page_col_start_nop + {\nofcolumns\c_page_mix_n_of_columns + \enforced\let\stoppagecolumns\page_col_stop_nop} + +\protected\def\page_col_stop_yes + {\column % \page_otr_eject_page + \page + \endgroup + % \setupoutputroutine[\s!singlecolumn]% + \page_otr_command_set_vsize + \page_otr_command_set_hsize + \page + \endgroup} + +\protected\def\page_col_stop_nop + {\page + \endgroup + \endgroup} + +\protect \endinput diff --git a/tex/context/base/mkxl/page-plg.mkxl b/tex/context/base/mkxl/page-plg.mkxl new file mode 100644 index 000000000..10cc1447b --- /dev/null +++ b/tex/context/base/mkxl/page-plg.mkxl @@ -0,0 +1,213 @@ +%D \module +%D [ file=page-pls, +%D version=2003.03.16, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Page Setup, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Extra Page Building} + +%D This still needs some work, especially the dimensions need to be checked cq.\ +%D optimized. Beware: method has become alternative! + +%D This feature has been present for a while but has never been exploited: pluggable +%D pagebuilders. The next example code demonstrates the application of one such a +%D plug-in. This variant support \type {page}, \type {leftpage} and \type +%D {rightpage} definitions where specific areas are placed with the \type +%D {\pagearea} command. +%D +%D \starttyping +%D \setupheadertexts[the header text] +%D \setupfootertexts[a pretty long left footer text][something right] +%D \setupbottomtexts[a not so long bottom text][another right thing] +%D \setuptexttexts [margin][something marginal][indeed] +%D +%D \startpagelayout[leftpage] +%D \setupTABLE[offset=overlay] +%D \setupTABLE[c][1][width=\leftmarginwidth] +%D \setupTABLE[c][2][width=\textwidth] +%D \setupTABLE[c][3][width=\rightmarginwidth] +%D \bTABLE +%D \bTR +%D \bTD[nx=3,background=color,backgroundcolor=green] +%D \pagearea[header][text][middle] +%D \eTD +%D \eTR +%D \bTR +%D \bTD \pagearea[text][margin][left] \eTD +%D \bTD[nx=2] \pagearea[text] \eTD +%D \eTR +%D \bTR +%D \bTD[nx=3,offset=overlay] +%D {\bTABLE +%D \bTR +%D \bTD \pagearea[footer][text][left] \eTD +%D \bTD \pagearea[bottom][text][left] \eTD +%D \eTR +%D \eTABLE} +%D \eTD +%D \eTR +%D \eTABLE +%D \stoppagelayout +%D +%D \startpagelayout[rightpage] +%D \setupTABLE[offset=overlay] +%D \setupTABLE[c][1][width=\leftmarginwidth] +%D \setupTABLE[c][2][width=\textwidth] +%D \setupTABLE[c][3][width=\rightmarginwidth] +%D \bTABLE +%D \bTR +%D \bTD[nx=3] \pagearea[header][text][middle] \eTD +%D \eTR +%D \bTR +%D \bTD \pagearea[text][margin][left] \eTD +%D \bTD[nx=2] \pagearea[text] \eTD +%D \eTR +%D \bTR +%D \bTD[nx=3,offset=overlay] +%D {\bTABLE +%D \bTR +%D \bTD \pagearea[bottom][text][right] \eTD +%D \bTD \pagearea[footer][text][right] \eTD +%D \eTR +%D \eTABLE} +%D \eTD +%D \eTR +%D \eTABLE +%D \stoppagelayout +%D +%D \setupcolors[state=start] +%D +%D \setuppagenumbering[alternative=doublesided,location=] +%D +%D \setuplayout[alternative=makeup] +%D +%D \definetextbackground +%D [test] +%D [state=start, +%D background=color, +%D backgroundcolor=yellow] +%D +%D \starttext +%D +%D \dorecurse{10}{\input tufte \par} +%D +%D \input tufte \starttest \input tufte \stoptest \input tufte +%D +%D \starttabulate +%D \NC test \NC \starttest \input tufte \stoptest \NC \NR +%D \stoptabulate +%D +%D \dorecurse{10}{\input tufte \par} +%D +%D \stoptext +%D \stoptyping + +\unprotect + +\installcorenamespace{layoutmakeupalternative} + +\def\page_boxes_construct_content_makeup#1#2#3% targetbox flusher box + {\setbox#1\hbox + {\vbox to \textheight + {\offinterlineskip + \vskip\dimexpr-1\topskip+\strutheight\relax % could be an option + \textwidth\makeupwidth + \hsize\textwidth + \boxmaxdepth\maxdepth + \noindent + \page_otr_command_package_contents#2#3}}% + \wd#1\makeupwidth + \ht#1\textheight + \dp#1\zeropoint + \hsize\paperwidth + \vsize\paperheight + \setbox#1\vbox{\csname\??layoutmakeupalternative\doifbothsidesoverruled\v!page\v!rightpage\v!leftpage\endcsname}% + \wd#1\paperwidth + \ht#1\paperheight + \dp#1\zeropoint} + +\installlayoutalternative\v!makeup{\page_boxes_construct_content_makeup} + +\newbox\b_page_area + +\permanent\tolerant\protected\def\pagearea[#1]#*[#2]#*[#3]% + {\ifarguments + \expandafter\gobblethreeoptionals + \or + \expandafter\page_area_one + \or + \expandafter\page_area_two + \or + \expandafter\page_area_three + \fi[#1][#2][#3]} + +\def\page_area_three[#1][#2][#3]% + {\edef\m_page_area_three{#3}% + \ifx\m_page_area_three\v!left + \let\m_page_area_three\c!lefttext + \orelse\ifx\m_page_area_three\v!right + \let\m_page_area_three\c!righttext + \else + \let\m_page_area_three\c!middletext + \fi + \page_area_indeed{#1}{#2}\m_page_area_three} + +\def\page_area_two[#1][#2][#3]% + {\edef\m_page_area_three{\doifbothsidesoverruled\c!righttext\c!righttext\c!lefttext}% + \page_area_indeed{#1}{#2}\m_page_area_three} + +\def\page_area_one[#1][#2][#3]% + {\edef\m_page_area_one{#1} + \ifx\m_page_area_one\v!text % copy due to trial runs in TABLE + \iftrialtypesetting + \fakebox\pagebox + \else + \page_backgrounds_add_to_text\pagebox + \page_grids_add_to_box\pagebox + \box\pagebox + \fi + \fi} + +\def\page_area_indeed#1#2#3% + {\setbox\b_page_area\vbox{\getspecificlayouttext{#1}{#2}{#3}}% + \iftrialtypesetting + \fakebox\b_page_area + \orelse\ifcsname\??layoutbackgrounds#1#2\endcsname + \page_area_indeed_yes{#1}{#2}% + \else + \box\b_page_area + \fi} + +\def\page_area_indeed_yes#1#2% + {% todo: \localbackgroundframed{\??layoutbackgrounds#1#2}{#1:#2} + \localframed % todo: + [\??layoutbackgrounds#1#2] + [\c!width=\wd\b_page_area, + \c!height=\ht\b_page_area, + \c!offset=\v!overlay] + {\box\b_page_area}} + +% to be done nicely (proper namespacing) + +\setvalue{\??layoutmakeupalternative\v!leftpage }{\csname\??layoutmakeupalternative\v!page\endcsname} +\setvalue{\??layoutmakeupalternative\v!rightpage}{\csname\??layoutmakeupalternative\v!page\endcsname} + +\permanent\protected\def\startpagelayout + {\bgroup + \catcode\endoflineasciicode\ignorecatcode + \page_layouts_start_layout} + +\aliased\let\stoppagelayout\relax + +\def\page_layouts_start_layout[#1]#2\stoppagelayout + {\egroup + \setvalue{\??layoutmakeupalternative#1}{#2}} + +\protect \endinput diff --git a/tex/context/base/mkxl/page-pst.mkxl b/tex/context/base/mkxl/page-pst.mkxl new file mode 100644 index 000000000..88e962805 --- /dev/null +++ b/tex/context/base/mkxl/page-pst.mkxl @@ -0,0 +1,110 @@ +%D \module +%D [ file=page-mis, +%D version=2008.11.17, % was part of page-flt.tex / 2000.10.20 +%D title=\CONTEXT\ Page Macros, +%D subtitle=Postponing, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Postponing} + +\registerctxluafile{page-pst}{} + +\unprotect + +% postponing + +\newevery\everytopofpage\relax + +\appendtoks + \the\everytopofpage +\to \everystarttext + +\appendtoks + \global\everytopofpage\emptytoks +\to \everystoptext + +% \startpostponing [pagenumber] [+pageoffset] +% +% \startpostponing[2] +% PAGE 2 \blank +% \stoppostponing +% +% \startpostponing[+1] +% PAGE +1 \blank +% \stoppostponing +% +% \startpostponing[+2] +% PAGE +2 \blank +% \stoppostponing +% +% \starttext \dorecurse{4}{\input tufte \page} \stoptext + +%D There is no real need to use \LUA\ here but the bookkeeping is somewhat easier +%D and we also can erase buffers easier when we keep a local cache, especially as we +%D can flush per page. + +\newcount \c_page_postponed_blocks_next_page % set at the lua end +\newconditional\c_page_postponed_busy + +\permanent\protected\setvalue{\e!start\v!postponing}% + {\bgroup + \obeylines + \doifelsenextoptional{\egroup\page_postponed_blocks_start}{\egroup\page_postponed_blocks_start[0]}} + +\permanent\protected\setvalue{\e!stop\v!postponing}% + {\clf_registerpostponedblock{\currentpostponedpage}\relax} + +\def\page_postponed_blocks_start[#1]% + {\edef\currentpostponedpage{#1}% + \grabbufferdatadirect{postponedblock}{\e!start\v!postponing}{\e!stop\v!postponing}} + +%D Officially we should flush again after a flush as there can be new future pages +%D but that will be looked into when we run into it. + +\c_page_postponed_mode\plusone + +\protected\def\page_postponed_blocks_flush_indeed + {\begingroup + \setsystemmode\v!postponing + \settrue\c_page_postponed_busy + \ifnum\c_page_postponed_mode=\plusone + \savepagecontent + \fi + \pagetotal\zeropoint % here? still needed? (was after flush pagefloats) + \the\everytopofpage\relax + %\flushrestfloats + \page_floats_flush_page_floats + \setnormalcatcodes % postponing in verbatim + \uncatcodespacetokens % postponing in startlines + \restoreglobalbodyfont % otherwise problems inside split verbatim + \clf_flushpostponedblocks + % page {123} + \relax + \page_otr_command_flush_floats % new but potential dangerous, maybe we need a classification + \ifnum\c_page_postponed_mode=\plusone + \flushpagecontent + \fi + \endgroup} % of blocks: with and without flush + +\protected\def\page_postponed_blocks_flush + {\ifconditional\c_page_postponed_busy + % probably a nested flush + \orelse\ifnum\c_page_postponed_blocks_next_page=\zerocount + % nothing in cache + \orelse\ifnum\c_page_postponed_blocks_next_page<\zerocount + % generic cache + \page_postponed_blocks_flush_indeed + \orelse\ifnum\c_page_postponed_blocks_next_page>\realpageno + % future content + \else + % pending content + \page_postponed_blocks_flush_indeed + \fi} + +\protect \endinput diff --git a/tex/context/base/mkxl/page-sel.mklx b/tex/context/base/mkxl/page-sel.mklx new file mode 100644 index 000000000..dfd4c27f3 --- /dev/null +++ b/tex/context/base/mkxl/page-sel.mklx @@ -0,0 +1,417 @@ +%D \module +%D [ file=page-sel, % moved from page-imp +%D version=1998.01.15, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Page Selection, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D This code relates to old texexec features and one can wonder if it needs +%D to be in the core. So, this could become runtime loaded code. Some of +%D the alternatives need checking. + +\writestatus{loading}{ConTeXt Page Macros / Page Selection} + +\unprotect + +%D One can (mis)use this mechanism to (re)arrange pages of already produced files. +%D +%D \starttyping +%D \insertpages[file.pdf][1,3][n=30,width=18cm] +%D \stoptyping +%D +%D The pages are inserted in the text area, and even pages are repositioned +%D according to the width. In this example empty pages are added after page 1 and 3. +%D +%D Selecting pages can be accomplished by: +%D +%D \starttyping +%D \filterpages[file.pdf][1,3,5][n=30,width=18cm] +%D \stoptyping +%D +%D One may pass \type {odd} or \type {even} instead of a comma separated list. A +%D third alternative is: +%D +%D \starttyping +%D \copypages[file.pdf][n=30,scale=950] +%D \stoptyping +%D +%D This macros inserts the page, according to the settings provided. + +%D Beware: width is not the width of the image, but height can be used to control +%D its dimensions. + +\installcorenamespace{withpages} + +\installsetuponlycommandhandler \??withpages {withpages} +% \installdirectcommandhandler \??withpages {withpages} + +\newcount\c_page_selectors_n + +\permanent\tolerant\protected\def\insertpages[#filename]#spacer[#emptylist]#spacer[#settings]% + {\doifelseassignment{#emptylist} + {\page_selectors_insert_indeed[#filename][][#emptylist]} + {\page_selectors_insert_indeed[#filename][#emptylist][#settings]}} + +\def\page_selectors_insert_indeed[#filename][#emptylist][#settings]% + {\bgroup + \dontcomplain + \getfiguredimensions[#filename]% + \setupcurrentwithpages + [\c!width=\zeropoint,% + \c!n=\noffigurepages,% + \c!category=,% + #settings]% + \global\c_page_selectors_n\directwithpagesparameter\c!n\relax + \scratchwidth\directwithpagesparameter\c!width\relax + \doifinset0{#emptylist} + {\emptyhbox\page}% + \dorecurse\c_page_selectors_n + {\page_selectors_filter_a_page{#filename}\recurselevel + \doifinset\recurselevel{#emptylist} + {\emptyhbox\page}}% + \egroup} + +\permanent\tolerant\protected\def\filterpages[#filename]#spacer[#selection]#spacer[#settings]% % \noffigurepages not yet supported + {\bgroup + \dontcomplain + \getfiguredimensions[#filename]% + \setupcurrentwithpages + [\c!width=\zeropoint,% + \c!n=\noffigurepages,% + \c!category=,% + #settings]% + \global\c_page_selectors_n\directwithpagesparameter\c!n\relax + \scratchwidth\directwithpagesparameter\c!width\relax + \edef\p_selection{#selection}% + \ifx\p_selection\v!even + \dorecurse\c_page_selectors_n + {\ifodd\recurselevel\else + \page_selectors_filter_a_page{#filename}\recurselevel + \fi}% + \orelse\ifx\p_selection\v!odd + \dorecurse\c_page_selectors_n + {\ifodd\recurselevel\relax + \page_selectors_filter_a_page{#filename}\recurselevel + \fi}% + \else + \def\page_selectors_filter_step_indeed#page% + {\ifnum#page>\c_page_selectors_n\else + \page_selectors_filter_a_page{#filename}{#page}% + \fi}% + \def\page_selectors_filter_step#step% + {\dowithrange{#step}\page_selectors_filter_step_indeed}% + \processcommacommand[\p_selection]\page_selectors_filter_step + \fi + \egroup} + +\def\page_selectors_filter_a_page#filename#page% + {\hpack to \textwidth + {\ifdim\scratchwidth>\zeropoint + \rightorleftpageaction{\scratchwidth\zeropoint}{\hfill}% + \fi + \setbox\scratchbox\hpack + {\hskip-\scratchwidth + \edef\p_category{\directwithpagesparameter\c!category}% \useexternalfigure[foo][width=\textwidth] + \ifx\p_category\empty + \externalfigure[#filename][\c!page=#page,\c!height=\textheight]% + \else + \externalfigure[#filename][\p_category][\c!page=#page]% + \fi + \hss}% + \wd\scratchbox\zeropoint + \box\scratchbox} + \page} + +\permanent\tolerant\protected\def\copypages[#filename]#spacer[#settings]#spacer[#figuresettings]% + {\bgroup + \getfiguredimensions[#filename]% + \setupcurrentwithpages + [\c!marking=\v!off,% + \c!offset=\zeropoint,% + \c!n=\noffigurepages,% + \c!category=,% + #settings]% + \global\c_page_selectors_n\directwithpagesparameter\c!n\relax + \scratchoffset\directwithpagesparameter\c!offset\relax + \dorecurse\c_page_selectors_n + {\vbox to \textheight + {\hsize\textwidth + \centeredbox + {\doifelse{\directwithpagesparameter\c!marking}\v!on\cuthbox\hpack % only place where cuthbox is used + {\ifdim\scratchoffset>\zeropoint\relax + \advance\vsize -2\scratchoffset + \advance\hsize -2\scratchoffset + \externalfigure[#filename][\c!page=\recurselevel,#figuresettings,\c!scale=,\c!factor=\v!max,\c!offset=\v!overlay]% + \else + \externalfigure[#filename][\c!page=\recurselevel,#figuresettings,\c!offset=\v!overlay]% + \fi}}} + \page}% + \egroup} + +%D \macros +%D {combinepages} +%D +%D Yet another way of postprocessing is handles by \type {\combinepages}. This macro +%D builds a matrix of pages from a file, for example: +%D +%D \starttyping +%D \setuppapersize +%D [A4][A4] % or [A4,landscape][A4,landscape] +%D +%D \setuplayout +%D [header=0pt,footer=1cm, +%D backspace=1cm,topspace=1cm, +%D width=middle,height=middle] +%D +%D \setupfootertexts +%D [presentation---\currentdate\space---\space\pagenumber] +%D +%D \starttext +%D \combinepages[slides][nx=2,ny=3,frame=on] +%D \stoptext +%D \stoptyping +%D +%D One can influence the way the pages are combined. (This will be explained some +%D time.) + +\installcorenamespace{combinepagesalternative} + +\permanent\tolerant\protected\def\combinepages[#filename]#spacer[#settings]% a=perpag b=free + {\bgroup + \dontcomplain + \getfiguredimensions[#filename]% + \setupcurrentwithpages + [\c!alternative=\v!a, + \c!n=\noffigurepages,\c!nx=\plustwo,\c!ny=\plustwo, + \c!start=\plusone,\c!stop=\maxcard, + \c!distance=\bodyfontsize, + \c!bottom=\vfill,\c!top=\vss,\c!left=\hss,\c!right=\hss, + \c!before=\page,\c!after=\page,\c!inbetween=\blank, + \c!frame=,\c!background=,\c!backgroundcolor=, + \c!name={#filename}, + \c!category=, + #settings]% + \global\c_page_selectors_n\directwithpagesparameter\c!n\relax + \directwithpagesparameter\c!before + \scratchnx\directwithpagesparameter\c!nx + \scratchny\directwithpagesparameter\c!ny + \scratchdistance\directwithpagesparameter\c!distance\relax + \scratchwidth\dimexpr(\textwidth-\scratchnx\scratchdistance+\scratchdistance)/\scratchnx\relax + \scratchheight\dimexpr(\textheight-\scratchny\scratchdistance+\scratchdistance)/\scratchny\relax + \expandnamespaceparameter\??combinepagesalternative\directwithpagesparameter\c!alternative\v!b + \directwithpagesparameter\c!after + \egroup} + +\setvalue{\??combinepagesalternative\v!a}% use hpacks + {\global\combinedpagescounter\directwithpagesparameter\c!start\relax + \doloop + {\vbox to \textheight + {\dorecurse\scratchny + {\hbox to \textwidth + {\dorecurse\scratchnx + {\vbox to \scratchheight + {\hsize\scratchwidth + \vsize\scratchheight + \directwithpagesparameter\c!top + \hbox to \hsize + {\directwithpagesparameter\c!left + \ifnum\combinedpagescounter>\directwithpagesparameter\c!stop\relax + \global\c_page_selectors_n\zerocount + \orelse\ifnum\combinedpagescounter>\c_page_selectors_n \else + \externalfigure + [\directwithpagesparameter\c!name] + [\c!object=\v!no, + \c!page=\number\combinedpagescounter, + \c!factor=\v!max, + \c!background=\directwithpagesparameter\c!background, + \c!backgroundcolor=\directwithpagesparameter\c!backgroundcolor, + \c!frame=\directwithpagesparameter\c!frame]% + \fi + \directwithpagesparameter\c!right} + \directwithpagesparameter\c!bottom}% + \global\advance\combinedpagescounter\plusone + \hfil}% + \hfilneg} + \vfil}% + \vfilneg}% + \page + \ifnum\combinedpagescounter>\c_page_selectors_n + \exitloop + \fi}} + +\setvalue{\??combinepagesalternative\v!c}% + {\global\combinedpagescounter\directwithpagesparameter\c!start\relax + \doloop + {\vbox to \textheight + {\hbox to \textwidth + {\dorecurse\scratchnx + {\directwithpagesparameter\c!left + \vbox to \textheight + {\hsize\scratchwidth + \dorecurse\scratchny + {\directwithpagesparameter\c!top + \hbox to \hsize + {\vbox to \scratchheight + {\hsize\scratchwidth + \vsize\scratchheight + \ifnum\combinedpagescounter>\directwithpagesparameter\c!stop\relax + \global\c_page_selectors_n\zerocount + \orunless\ifnum\combinedpagescounter>\c_page_selectors_n + \externalfigure + [\directwithpagesparameter\c!name] + [\c!object=\v!no, + \c!page=\number\combinedpagescounter, + \c!factor=\v!max, + \c!background=\directwithpagesparameter\c!background, + \c!backgroundcolor=\directwithpagesparameter\c!backgroundcolor, + \c!frame=\directwithpagesparameter\c!frame]% + \fi}} + \global\advance\combinedpagescounter\plusone + \directwithpagesparameter\c!bottom}}% + \hfil}% + \hfilneg}}% + \page + \ifnum\combinedpagescounter>\c_page_selectors_n + \exitloop + \fi}} + +\letcsname\??combinepagesalternative\v!horizontal\expandafter\endcsname\csname\??combinepagesalternative\v!a\endcsname +\letcsname\??combinepagesalternative\v!vertical \expandafter\endcsname\csname\??combinepagesalternative\v!c\endcsname + +\setvalue{\??combinepagesalternative\v!b}% + {\global\combinedpagescounter\directwithpagesparameter\c!start\relax + \doloop + {\startbaselinecorrection + \hbox to \textwidth + {\dorecurse\scratchnx + {\global\advance\combinedpagescounter\plusone + \ifnum\combinedpagescounter>\c_page_selectors_n \else + \normalexpanded{\externalfigure + [\directwithpagesparameter\c!name] + [\c!page=\number\combinedpagescounter, + \c!width=\the\scratchwidth, + \c!background=\directwithpagesparameter\c!background, + \c!backgroundcolor=\directwithpagesparameter\c!backgroundcolor, + \c!frame=\directwithpagesparameter\c!frame]}% + \hfill + \fi}% + \hfillneg}% + \stopbaselinecorrection + \ifnum\combinedpagescounter<\c_page_selectors_n\relax + \directwithpagesparameter\c!inbetween + \else + \exitloop + \fi}} + +% This macro cuts a page into n parts that can be pasted together. + +\permanent\tolerant\protected\def\slicepages[#filename]#spacer[#oddsettings]#spacer[#evensettings]% + {\ifparameter#evensettings\or + \page_selectors_slice_indeed[#filename][#oddsettings][#evensettings]% + \else + \page_selectors_slice_indeed[#filename][#oddsettings][#oddsettings]% + \fi} + +\mutable\let\slicedpagenumber\!!zerocount +\mutable\let\slicedpagestepx \!!zerocount +\mutable\let\slicedpagestepy \!!zerocount + +\def\page_selectors_slice_indeed[#filename][#oddsettings][#evensettings]% + {\bgroup + \dontcomplain + \glet\slicedpagenumber\!!zerocount + \getfiguredimensions[#filename]% + \setupcurrentwithpages + [\c!offset=\zeropoint,% + \c!hoffset=\zeropoint,% + \c!voffset=\zeropoint, + \c!width=\figurewidth,% + \c!height=\figureheight,% + \c!n=\noffigurepages,% + \c!category=,% + #oddsettings]% + \global\c_page_selectors_n\directwithpagesparameter\c!n\relax + \ifnum\c_page_selectors_n>\zerocount + \definepapersize + [\s!dummy][\c!height=\directwithpagesparameter\c!height,\c!width=\directwithpagesparameter\c!width]% + \setuppapersize + [\s!dummy][\s!dummy]% + \setuplayout + [\c!backspace=\zeropoint,\c!topspace=\zeropoint, + \c!height=\v!middle,\c!width=\v!middle, + \c!textdistance=\zeropoint, + \c!header=\zeropoint,\c!footer=\zeropoint]% + \fi + \dorecurse\noffigurepages + {\glet\slicedpagenumber\recurselevel + \ifnum\c_page_selectors_n>\plusone + \dorecurse\c_page_selectors_n + {\let\slicedpagestepx\recurselevel + \dorecurse\c_page_selectors_n + {\let\slicedpagestepy\recurselevel + \clip + [\c!nx=\c_page_selectors_n,\c!ny=\c_page_selectors_n,\c!x=\slicedpagestepx,\c!y=\slicedpagestepy] + {\scale + [\c!scale=\number\c_page_selectors_n000] + {\externalfigure[#filename][\c!page=\slicedpagenumber]}}% + \page}}% + \else + \ifodd\slicedpagenumber\relax + \setupcurrentwithpages[#oddsettings]% + \else + \setupcurrentwithpages[#evensettings]% + \fi + \hskip\directwithpagesparameter\c!offset\relax + \clip + [\c!hoffset=\directwithpagesparameter\c!hoffset,\c!voffset=\directwithpagesparameter\c!voffset, + \c!height=\directwithpagesparameter\c!height,\c!width=\directwithpagesparameter\c!width] + {\externalfigure[#filename][\c!page=\slicedpagenumber]}% + \page + \fi} + \egroup} + +% \starttext \slicepages[slice1.pdf][n=3] \stoptext + +\permanent\protected\def\trimpages[#1]% was for a over decade in p-pdf-51.tex + {\begingroup + \getdummyparameters + [\c!file=dummy, + \c!hoffset=\zeropoint, + \c!voffset=\zeropoint, + \c!width=17cm, + \c!height=24cm, + \c!x=\zeropoint, + \c!y=\zeropoint, + #1] + \getfiguredimensions + [\dummyparameter\c!file] + [\c!object=\v!no] + \dorecurse\noffigurepages + {\scale + [\c!width=\paperwidth, + \c!height=\paperheight] + {\offset + [\c!x=\dummyparameter\c!x, + \c!y=\dummyparameter\c!y] + {\clip + [\c!hoffset=\dummyparameter\c!hoffset, + \c!voffset=\dummyparameter\c!voffset, + \c!width=\dummyparameter\c!width, + \c!height=\dummyparameter\c!height] + {% we correct by default, if not needed, introduce option + \setbox\nextbox\hbox + {\externalfigure[\dummyparameter\c!file][\c!page=##1]}% + \ifdim\wd\nextbox>\ht\nextbox + \rotate[\c!rotation=90]{\box\nextbox}% + \else + \box\nextbox + \fi}}}}% + \endgroup} + +\protect \endinput diff --git a/tex/context/base/mkxl/page-sid.mkxl b/tex/context/base/mkxl/page-sid.mkxl new file mode 100644 index 000000000..d5032ddd0 --- /dev/null +++ b/tex/context/base/mkxl/page-sid.mkxl @@ -0,0 +1,1019 @@ +%D \module +%D [ file=page-sid, +%D version=2000.10.20, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Side Floats, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Side Floats} + +\unprotect + +%D These macro deal with side floats. We started with Daniel Comenetz macros as +%D published in TUGBoat Volume 14 (1993), No.\ 1: Anchored Figures at Either Margin. +%D I extended and patched the macros to suite our needs which results in a messy +%D module. +%D +%D A complication is that we need to deal with spacing differently before and after +%D the float. Also, whitespace can interfere as does the prevdepth. There is no real +%D universal solution. So, by now not much is left of that code, if only because we +%D need to match \CONTEXT\ spacing module, because we have more placement options +%D and control and because the math hackery is not suitable for \CONTEXT\ anyway. +%D +%D This code had been redone many times because we kept running into spacing issues +%D and it's not that much fun (or rewarding). It's probably the module that made +%D me go into distraciton mode most often (like watching amusing Walk of The +%D Earth, sophisticated Massive Attack video clips, impressive Davie504 movies +%D and so on). + +\newdimen \d_page_sides_margin +\newdimen \d_page_sides_height % includes the topskip +\newdimen \d_page_sides_width +\newdimen \d_page_sides_hsize +\newdimen \d_page_sides_vsize +\newdimen \d_page_sides_vsize_reset +\newdimen \d_page_sides_progress +\newdimen \d_page_sides_page_total + +\newdimen \d_page_sides_leftoffset +\newdimen \d_page_sides_rightoffset + +%newbox \b_page_sides_bottom + +\newcount \c_page_sides_lines_done +\newcount \c_page_sides_checks_done +\newcount \c_page_sides_n_of_lines +\newcount \c_page_sides_n_of_hang +\newconstant \c_page_sides_float_type +\newcount \c_page_sides_hangafter + +\newconditional \c_page_sides_short +\newconditional \c_page_sides_flag + +\newdimen \d_page_sides_shift +\newdimen \d_page_sides_extrashift +\newdimen \d_page_sides_leftshift +\newdimen \d_page_sides_rightshift +\newdimen \d_page_sides_leftskip +\newdimen \d_page_sides_rightskip +\newdimen \d_page_sides_maximum +\newdimen \d_page_sides_topskip +\newdimen \d_page_sides_bottomskip +\newdimen \d_page_sides_midskip +\newdimen \d_page_sides_downshift +\newdimen \d_page_sides_pagetotal +\newdimen \d_page_sides_topoffset +\newdimen \d_page_sides_bottomoffset +\newdimen \d_page_sides_toptotal +\newdimen \d_page_sides_bottomtotal + +\newconstant \c_page_sides_align +\newconstant \c_page_sides_skipmode +\newconstant \c_page_sides_tolerance + +\newconstant \c_page_sides_method % sort of obsolete + +\newdimen \d_page_sides_progression + +\newcount \c_page_sides_m_of_lines +\newconditional \c_page_sides_delayed + +\newconditional \c_page_sides_check_same_page + +\newif \iftracesidefloats % public (might change) + +%D Defaults: + +\d_page_sides_vsize_reset -\onepoint +%d_page_sides_vsize_reset \zeropoint % could be an option, needs testing + +%D We have some basic (and colorful) tracing: + +\def\page_sides_floats_legend + {\showmessage\m!floatblocks{16}\empty + \glet\page_sides_floats_legend\relax} + +\installtextracker{floats.anchoring} + {\page_sides_floats_legend + \tracesidefloatstrue} + {\tracesidefloatsfalse} + +%D The horizontal shifts depend on the location: left or right in the text, margin +%D or edge. These shifts are rather stable and don't interfere with the page flow +%D as much as the vertical ones do. + +\def\page_sides_process_float_backspace {\global\c_page_sides_float_type\plusone \page_sides_handle_float} +\def\page_sides_process_float_leftedge {\global\c_page_sides_float_type\plustwo \page_sides_handle_float} +\def\page_sides_process_float_leftmargin {\global\c_page_sides_float_type\plusthree\page_sides_handle_float} +\def\page_sides_process_float_left {\global\c_page_sides_float_type\plusfour \page_sides_handle_float} +\def\page_sides_process_float_right {\global\c_page_sides_float_type\plusfive \page_sides_handle_float} +\def\page_sides_process_float_rightmargin{\global\c_page_sides_float_type\plussix \page_sides_handle_float} +\def\page_sides_process_float_rightedge {\global\c_page_sides_float_type\plusseven\page_sides_handle_float} +\def\page_sides_process_float_cutspace {\global\c_page_sides_float_type\pluseight\page_sides_handle_float} +\def\page_sides_process_float_margin {\global\c_page_sides_float_type\pluseight\page_sides_handle_float} + +\def\page_sides_check_horizontal_skips + {\ifcase\c_page_sides_skipmode + \or % high + \or % low + \or % fit + \global\d_page_sides_margin\zeropoint + \fi} + +\def\page_sides_apply_horizontal_shift + {\ifdim\d_page_sides_maximum>\zeropoint + \ifcase\c_page_sides_float_type + % invalid + \or + % backspace + \or + \global\d_page_sides_shift\dimexpr + -\d_page_sides_maximum + -\rightorleftpageaction \leftedgedistance \rightedgedistance + -\rightorleftpageaction \leftmarginwidth \rightmarginwidth + -\rightorleftpageaction \leftmargindistance \rightmargindistance + -\compensatedinnermakeupmargin + \relax + \or + \global\d_page_sides_shift\dimexpr + -\d_page_sides_maximum + -\rightorleftpageaction \leftmargindistance \rightmargindistance + -\compensatedinnermakeupmargin + \relax + \or + % left + \or + % right + \or + \global\d_page_sides_shift\dimexpr + -\d_page_sides_maximum + -\rightorleftpageaction \leftmargindistance \rightmargindistance + -\compensatedinnermakeupmargin + \relax + \or + \global\d_page_sides_shift\dimexpr + -\d_page_sides_maximum + -\rightorleftpageaction \leftedgedistance \rightedgedistance + -\rightorleftpageaction \leftmarginwidth \rightmarginwidth + -\rightorleftpageaction \leftmargindistance \rightmargindistance + -\compensatedinnermakeupmargin + \relax + \or + % cutspace + \fi + \fi + \ifdim\d_page_sides_shift=\zeropoint \relax + \ifnum\c_page_sides_float_type=\plusfour + \global\advance\d_page_sides_shift\d_page_sides_extrashift + \global\d_page_sides_extrashift\zeropoint + \orelse\ifnum\c_page_sides_float_type=\plusfive + \global\advance\d_page_sides_shift\d_page_sides_extrashift + \global\d_page_sides_extrashift\zeropoint + \fi + \else + \ifnum\c_page_sides_float_type<\plusfour + \global\c_page_sides_float_type\plusfour + \orelse\ifnum\c_page_sides_float_type>\plusfive + \global\c_page_sides_float_type\plusfive + \fi + \fi} + +\def\page_sides_set_skips + {\global\d_page_sides_rightskip\zeropoint + \global\d_page_sides_leftskip \zeropoint + \ifcase\c_page_sides_float_type + \or % backspace + \global\d_page_sides_leftskip\dimexpr + +\rightorleftpageaction \backspace \cutspace + +\compensatedinnermakeupmargin + \relax + \or % leftedge + \global\d_page_sides_leftskip\dimexpr + +\rightorleftpageaction \leftmargindistance \rightmargindistance + +\rightorleftpageaction \leftmarginwidth \rightmarginwidth + +\rightorleftpageaction \leftedgedistance \rightedgedistance + +\compensatedinnermakeupmargin + \relax + \or % leftmargin + \global\d_page_sides_leftskip\dimexpr + +\rightorleftpageaction \leftmargindistance \rightmargindistance + +\compensatedinnermakeupmargin + \relax + \or % leftside + \or % rightside + \or % rightmargin + \global\d_page_sides_rightskip\dimexpr + +\rightorleftpageaction \rightmargindistance \leftmargindistance + +\compensatedinnermakeupmargin + \relax + \or % rightedge + \global\d_page_sides_rightskip\dimexpr + +\rightorleftpageaction \rightmargindistance \leftmargindistance + +\rightorleftpageaction \rightmarginwidth \leftmarginwidth + +\rightorleftpageaction \rightedgedistance \leftedgedistance + +\compensatedinnermakeupmargin + \relax + \or % cutspace + \global\d_page_sides_rightskip\dimexpr + +\rightorleftpageaction \cutspace \backspace + +\compensatedinnermakeupmargin + \relax + \fi + \global\d_page_sides_leftoffset \d_page_sides_rightskip + \global\d_page_sides_rightoffset\d_page_sides_leftskip + \ifdim\d_page_sides_rightskip>\zeropoint + \global\advance\d_page_sides_rightskip\rightskip + \fi + \ifdim\d_page_sides_leftskip >\zeropoint + \global\advance\d_page_sides_leftskip \leftskip + \fi} + +%D Shifts get applied to the float box: + +\def\page_sides_relocate_float#1% + {\global\setbox\floatbox\hpack + {\ifnum\c_page_sides_float_type=\plusfour + \kern\d_page_sides_leftshift + \orelse\ifnum\c_page_sides_float_type=\plusone + \kern\d_page_sides_leftshift + \fi + \ifnum\c_page_sides_float_type>\plusfour + \kern-\d_page_sides_extrashift + \else + \kern\d_page_sides_shift + \fi + \vbox{#1\ifnum\c_page_sides_align=\plusfour \removedepth \fi}% + \ifnum\c_page_sides_float_type>\plusfour + \kern\d_page_sides_shift + \else + \kern-\d_page_sides_extrashift + \fi + \ifnum\c_page_sides_float_type=\pluseight + \kern\d_page_sides_rightshift + \orelse\ifnum\c_page_sides_float_type=\plusfive + \kern\d_page_sides_rightshift + \fi}} + +%D The vertical skips are a nightmare and this mechanism is about as complex +%D as one can get it. + +\def\page_sides_check_vertical_skips + {\ifdim\d_page_sides_topskip <\zeropoint\d_page_sides_topskip \zeropoint\fi + \ifdim\d_page_sides_bottomskip<\zeropoint\d_page_sides_bottomskip\zeropoint\fi + \ifdim\d_page_sides_midskip <\zeropoint\d_page_sides_midskip \zeropoint\fi + % + \global\d_page_sides_toptotal \dimexpr\d_page_sides_topskip +\d_page_sides_topoffset \relax + \global\d_page_sides_bottomtotal\dimexpr\d_page_sides_bottomskip+\d_page_sides_bottomoffset\relax + \ifcase\c_page_sides_skipmode + \or % high + \global\d_page_sides_toptotal \d_page_sides_topoffset + \or % low + \global\d_page_sides_bottomtotal\d_page_sides_bottomoffset + \or % fit + \global\d_page_sides_toptotal \d_page_sides_topoffset + \global\d_page_sides_bottomtotal\d_page_sides_bottomoffset + \fi} + +%D These shifts get (selectively) applied with a bit of optional tracing. + +\def\page_sides_apply_vertical_shift_normal + {\global\setbox\floatbox\hpack % why extra box + {\vpack + {\forgetall + \hsize\wd\floatbox + \vskip\privatescratchdimen + \offinterlineskip + \box\floatbox + % somehow we need this \scratchbox magic, but at least it's the same as the + % tracer now + \setbox\scratchbox\emptybox + \wd\scratchbox\hsize + \ht\scratchbox\d_page_sides_bottomtotal + \box\scratchbox + \vskip-\d_page_sides_bottomtotal + \ifnum\c_page_sides_align=\plusfive + \vskip-\lineheight + \fi}}} + +\def\page_sides_apply_vertical_shift_traced + {\global\setbox\floatbox\hpack % why extra box + {\backgroundline[trace:r]{\ruledhpack{\vpack + {\forgetall + \hsize\wd\floatbox + \vskip\privatescratchdimen + \offinterlineskip + \backgroundline + [trace:g]% + {\ruledhpack{\box\floatbox}}% + \par + \blackrule + [\c!color=trace:s,% + \c!height=\d_page_sides_bottomtotal,% + \c!depth=\zeropoint,% + \c!width=\hsize]% + \vskip-\d_page_sides_bottomtotal + \ifnum\c_page_sides_align=\plusfive + \vskip-\lineheight + \fi}}}}} + +\def\page_sides_apply_vertical_shift + {\ifnum\c_page_sides_align=\plusfour + \getnoflines{\ht\floatbox}% + \privatescratchdimen\dimexpr\noflines\lineheight-\strutdp\relax + \getrawnoflines\d_page_sides_toptotal + \advance\privatescratchdimen\noflines\lineheight + \page_sides_force_depth + \ht\floatbox\privatescratchdimen + \dp\floatbox\zeropoint + \fi + \ifcase\c_page_sides_align \else + \global\d_page_sides_toptotal\zeropoint + \fi + \privatescratchdimen + \ifnum\c_page_sides_float_type<\plusfour + \d_page_sides_toptotal + \orelse\ifnum\c_page_sides_float_type>\plusfive + \d_page_sides_toptotal + \else + \zeropoint + \fi + % the top of the box is at the previous baseline + \ifcase\c_page_sides_align + % 0 normal + \advance\privatescratchdimen\strutdp % or \openstrutdepth + \or % 1 height + \advance\privatescratchdimen\strutdp % or \openstrutdepth + \or % 2 line + \or % 3 depth + \advance\privatescratchdimen\lineheight % or \openlineheight + \advance\privatescratchdimen\strutdp % or \openstrutdepth + \or % 4 grid + \privatescratchdimen\zeropoint + \or + \advance\privatescratchdimen\strutht % or \openstrutheight + \fi + % new + \global\c_page_sides_lines_done\zerocount + \ifnum\c_page_sides_n_of_lines>\zerocount + \advance\privatescratchdimen\c_page_sides_n_of_lines\lineheight + \fi + \iftracesidefloats + \page_sides_apply_vertical_shift_traced % uses \privatescratchdimen + \else + \page_sides_apply_vertical_shift_normal % uses \privatescratchdimen + \fi + \ifnum\c_page_sides_float_type<\plusfour + \global\d_page_sides_toptotal\zeropoint + \orelse\ifnum\c_page_sides_float_type>\plusfive + \global\d_page_sides_toptotal\zeropoint + \fi + \global\d_page_sides_downshift\zeropoint} + +%D We have a few virtual dimensions. I'm not sure what to do with \type +%D {\pagedepth} and \type {\pageshrink} in the next two. If we ever need +%D that it will become options. + +\def\e_page_sides_flush_criterium + {\dimexpr + \d_page_sides_vsize + -\d_page_sides_bottomtotal + -\pagetotal + \relax} + +\def\e_page_sides_room_criterium + {\dimexpr + \d_page_sides_vsize + -\d_page_sides_bottomtotal % added here too + -\pagetotal + \relax} + +%D In order to get a consistent spacing we force a strutdepth unless the +%D preceding material has more depth than that already. This way anchoring +%D becomes predictable. + +\protected\def\page_sides_force_depth + {\iftracesidefloats + \begingroup + \c_page_force_strut_depth_trace_mode\plusone + \ifconditional\c_page_sides_check_same_page + \forcestrutdepthplus + \else + \forcestrutdepth + \fi + \endgroup + \else + \ifconditional\c_page_sides_check_same_page + \forcestrutdepthplus + \else + \forcestrutdepth + \fi + \fi + \page_otr_command_set_vsize} % new + +\def\page_sides_flush_floats + {\par + \ifdim\e_page_sides_flush_criterium>\zeropoint + \page_sides_flush_floats_progress + \page_sides_flush_floats_after_next + \fi + \page_sides_flush_floats_reset} + +\def\page_sides_flush_floats_text + {\par + % what with \c_anch_backgrounds_text_level>\plusone + \ifdim\e_page_sides_flush_criterium>\zeropoint + \page_sides_flush_floats_progress + \page_sides_flush_floats_after_none + \fi + \page_sides_flush_floats_reset} + +\def\page_sides_flush_floats_reset + {\global\d_page_sides_vsize\d_page_sides_vsize_reset + % also here if used at all \global\holdinginserts\zerocount + \global\setfalse\c_page_sides_short + \global\setfalse\c_page_sides_flag + \global\c_page_sides_checks_done\zerocount} + +\def\page_sides_flush_floats_after_none % we force a flush + {\ifdim\d_page_sides_midskip>\zeropoint + \blank[\the\d_page_sides_midskip] + \fi + \ignoreparskip + \blank[\v!disable]} + +\def\page_sides_flush_floats_after_next % we have two successive ones + {\ifdim\d_page_sides_bottomskip>\zeropoint + \blank[\the\d_page_sides_bottomskip] + \fi + \ignoreparskip + \blank[\v!disable]} + +%D A rudimentary checker: + +\permanent\protected\def\doifelsesidefloat + {\par + \ifdim\e_page_sides_room_criterium>\zeropoint % -\pagedepth + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} + +\aliased\let\doifsidefloatelse\doifelsesidefloat + +%D Sometimes we need to fill up the space alongside a side float and this +%D is where we define the helpers. A user can enforce a smaller step. We use +%D large steps when possible. + +\installcorenamespace{sidefloatsteps} + +\setvalue{\??sidefloatsteps\v!line }{\strut} +\setvalue{\??sidefloatsteps\v!big }{\strut} +\setvalue{\??sidefloatsteps\v!medium}{\halflinestrut} % was \halfstrut +\setvalue{\??sidefloatsteps\v!small }{\noheightstrut} % was \quarterstrut + +\def\page_sides_flush_floats_tracer + {\dontleavehmode + \ruledhpack\bgroup\backgroundline[trace:b]{% + \llap{\smash{\vrule\s!width4\points\s!height.4\points\s!depth.4\points}}% + \ifnum\recurselevel=\plusone + \llap{\smash{\smallinfofont\the\scratchdimen}\hskip.5\leftmargindistance}% + \orelse\ifodd\recurselevel + \llap{\smash{\smallinfofont\recurselevel}\hskip.5\leftmargindistance}% + \fi + \page_sides_flush_floats_normal + \kern\hsize + \egroup}} + +\def\page_sides_flush_floats_normal + {\ifdim\scratchdimen>\htdp\strutbox + \strut + \else + \m_pages_strut + \fi} + +\def\page_sides_flush_floats_progress + {\begingroup + \page_sides_force_depth + \parskip\zeropoint + \let\page_sides_flush_floats\relax + \edef\m_pages_strut + {\ifcsname\??sidefloatsteps\rootfloatparameter\c!step\endcsname + \lastnamedcs + \else + \noheightstrut + \fi}% + \forgetall + \offinterlineskip + \doloop + {\scratchdimen\e_page_sides_flush_criterium + \ifdim\scratchdimen>\onepoint % good enough, can become configurable + \ifnum\recurselevel>\plushundred % safeguard, sort of deadcycles + \exitloop + \orelse\iftracesidefloats + \page_sides_flush_floats_tracer\par + \else + \page_sides_flush_floats_normal\par + \fi + \else + \page_sides_force_depth + \exitloop + \fi}% + \endgroup} + +%D We force a parskip and ignore it afterwards. We can nil it by setting the +%D \type {spacebeforeside} parameter. We can have a leading blank so we need +%D to make sure that we use blank to inject the parskip and then ignore +%D the one injected by the engine. + +\def\page_sides_inject_before + {\page_sides_force_depth + \ifdim\parskip>\zeropoint + \ifdim\parskip>\d_strc_floats_top + \ifdim\d_strc_floats_top>\zeropoint + \ignoreparskip + \blank[\v!white]% + \else + \checkedblank[\rootfloatparameter\c!spacebeforeside]% + \fi + \else + \checkedblank[\rootfloatparameter\c!spacebeforeside]% + \fi + \else + \checkedblank[\rootfloatparameter\c!spacebeforeside]% + \fi} + +%D We are now done with \type {spacebefore} and the parskip is already +%D injected. The dummy line makes sure that we anchor properly and it +%D also can serve as tracer. + +\def\page_sides_inject_dummy_line_normal + {\hpack to \availablehsize{\strut\hss}} + +\def\page_sides_inject_dummy_line_traced + {\ruledhpack to \availablehsize{\backgroundline[trace:c]{\page_sides_inject_dummy_line_normal}}} + +\def\page_sides_inject_dummy_lines + {\par + \nointerlineskip + % \ifnum\lastpenalty>\zerocount + % \penalty\plustenthousand + % \fi + \dontleavehmode + \iftracesidefloats + \page_sides_inject_dummy_line_traced + \else + \page_sides_inject_dummy_line_normal + \fi + \par + % on an empty page we have topskip, say 12pt + \ignoreparskip + % this can be 18.5pt + \kern-\dimexpr\lineheight+\strutdp\relax + % so we can actually have a -2.5pt skip on top + \ignoreparskip + \blank[\v!samepage] + \blank[\v!disable] + % now say we are negative now + \ifdim\pagetotal<\zeropoint + % then we're at the top of the page ... quite messy .. i really need to + % make the page builder a bit more flexible .. should we do something now? + \fi} + +%D Checkers: + +\def\page_sides_check_floats_after_par + {\page_sides_check_floats_indeed + \ifdim\d_page_sides_pagetotal=\pagetotal \else + \glet\page_sides_check_floats\page_sides_check_floats_indeed + \page_sides_flush_floats + \global\c_page_sides_n_of_lines\zerocount % here ! + \fi} + +\protected\def\page_sides_flush_floats_after_par + {\global\d_page_sides_pagetotal\pagetotal + \glet\page_sides_check_floats\page_sides_check_floats_after_par} + +\protected\def\page_sides_forget_floats + {\global\d_page_sides_vsize\d_page_sides_vsize_reset + \global\c_page_sides_n_of_lines\zerocount + % also here if used at all \global\holdinginserts\zerocount + \global\setfalse\c_page_sides_short + \global\setfalse\c_page_sides_flag} + +%D Here comes the output routine. We either go the fast route or we use the +%D normal one (stored in \type {\page_otr_command_side_float_output}. We no +%D longer have this fuzzy code around with penalties and indentation and +%D such. + +\def\page_sides_output_routine + {\page_otr_command_side_float_output + \ifconditional\c_page_sides_short + \global\setfalse\c_page_sides_short + \else + \global\d_page_sides_vsize\d_page_sides_vsize_reset + \global\c_page_sides_n_of_lines\zerocount + \fi} + +\def\page_sides_place_float + {\ifnum\c_page_sides_float_type=\plusfour \kern\d_page_sides_toptotal \fi + \ifnum\c_page_sides_float_type=\plusfive \kern\d_page_sides_toptotal \fi + \ifgridsnapping + \page_sides_place_float_grid + \else + \page_sides_place_float_normal + \fi + \par + \kern-\d_page_sides_height + \penalty10001 % oeps, this will change + \normalbaselines} + +\def\page_sides_place_float_normal + {\page_sides_push_float_inline\firstofoneargument} + +%D The following needs some more work .. consider this a quick hack. We probably +%D need an mkiv hanging grid option. + +\def\page_sides_place_snap_to_grid#1% + {\edef\p_grid{\floatparameter\c!grid}% + \ifx\p_grid\empty\else + \snaptogrid[\p_grid]% + \fi + \hpack{#1}} + +\def\page_sides_place_float_grid + {\getrawnoflines\d_page_sides_height % raw ? + \d_page_sides_height\noflines\lineheight + \page_sides_push_float_inline\page_sides_place_snap_to_grid} + +\let\strc_floats_mark_par_as_free\relax + +\def\page_sides_push_float_inline#1% + {\begingroup + \reseteverypar % needed ! + \parskip\zeropoint % needed ! + \nointerlineskip + \page_sides_set_skips + \page_floats_report_total + \relax + \lefttoright + \strc_floats_mark_par_as_free + \ifcase\c_page_sides_float_type + % invalid + \or % backspace + \noindent#1{\llap{\rlap{\box\floatbox}\kern\d_page_sides_leftskip}}\hfill + \or % leftedge + \noindent#1{\llap{\box\floatbox\kern\d_page_sides_leftskip}}\hfill + \or % leftmargin + \noindent#1{\llap{\box\floatbox\kern\d_page_sides_leftskip}}\hfill + \or % leftside + \noindent#1{\box\floatbox}\hfill + \or % rightside + \hfill#1{\box\floatbox}% + \or % rightmargin + \hfill#1{\rlap{\kern\d_page_sides_rightskip\box\floatbox}}% + \or % rightedge + \hfill#1{\rlap{\kern\d_page_sides_rightskip\box\floatbox}}% + \or % cutspace + \hfill#1{\rlap{\kern\d_page_sides_rightskip\llap{\box\floatbox}}}% + \fi + \endgroup} + +% \def\page_sides_analyse_progress +% {\d_page_sides_progress\d_page_sides_vsize +% \ifconditional\c_page_sides_flag +% \advance\d_page_sides_progress-\d_page_sides_page_total +% \global\setfalse\c_page_sides_flag +% \else +% \advance\d_page_sides_progress-\pagetotal +% \fi} + +% test case +% +% \usemodule[art-01] +% \starttext +% \dorecurse{40}{\line{#1}} +% \placefigure[left]{}{} +% \input ward +% \startitemize +% \item word \item word \item word \item word +% \stopitemize +% \input ward +% \page +% \stoptext + +\def\page_sides_analyse_progress + {%\page_otr_command_set_vsize % this is new, otherwise topfloats are not taken into account + \d_page_sides_progress\d_page_sides_vsize + \ifconditional\c_page_sides_flag + \advance\d_page_sides_progress-\d_page_sides_page_total + \global\setfalse\c_page_sides_flag + \else + \ifdim\dimexpr\d_page_sides_progress+\d_page_sides_bottomtotal\relax>\pagegoal + % we adapt pagegoal because we can already have placed something with + % everypar and we hope that it triggers a flush, see test above + \pagegoal\dimexpr\pagegoal-\d_page_sides_bottomtotal\relax + \fi + \advance\d_page_sides_progress-\pagetotal + \fi} + +\def\page_sides_analyse_space_stage_one + {\global\settrue\c_page_sides_flag +% \ifdim\pagegoal=\maxdimen +% \pagegoal\textheight % maybe +% \fi + \global\d_page_sides_page_total \pagetotal % global + \ifnum\c_page_sides_float_type<\plusfour + \global\d_page_sides_width \zeropoint + \orelse\ifnum\c_page_sides_float_type>\plusfive + \global\d_page_sides_width\zeropoint + \else + \global\d_page_sides_width\dimexpr\wd\floatbox+\d_page_sides_margin\relax + \fi + \ifdim\d_page_sides_width<\zeropoint + \global\d_page_sides_width\zeropoint + \fi + \global\d_page_sides_hsize \dimexpr\hsize-\d_page_sides_width\relax + \global\d_page_sides_height\dimexpr\ht\floatbox+\dp\floatbox+\d_page_sides_toptotal\relax + \global\d_page_sides_vsize \dimexpr\d_page_sides_height+\d_page_sides_page_total\relax + \scratchdimenone\d_page_sides_vsize + \scratchdimentwo\pagegoal + \ifcase\c_page_sides_tolerance + \ifcase\c_page_sides_method + % method 0 : raw + \or + % method 1 : safe (default) + \advance\scratchdimentwo -\strutdp + \or + % method 2 : tight (grid default) + \advance\scratchdimenone -\onepoint + \fi + \or + % tolerant + \advance\scratchdimentwo -.5\strutdp + \or + % verytolerant + % \advance\scratchdimenone -\onepoint (maybe) + \else + \advance\scratchdimentwo -\strutdp + \fi} + +\def\page_sides_analyse_space_stage_two + {% how about \pagedepth + \ifdim\scratchdimenone>\scratchdimentwo + \global\setfalse\c_page_floats_room + \else + \ifdim\dimexpr\pagegoal-\d_page_sides_vsize\relax<\d_page_sides_bottomtotal + % just weird: \global\advance\d_page_sides_vsize \scratchdimenone + \global\settrue\c_page_sides_short + % why was this \global\holdinginserts\plusone + \else + \global\advance\d_page_sides_vsize \d_page_sides_bottomtotal % wins over inbetween + \global\setfalse\c_page_sides_short + \fi + \global\settrue\c_page_floats_room + \fi} + +\def\page_sides_analyse_space + {\page_sides_analyse_space_stage_one + \ifconditional\c_page_sides_check_same_page + \ifdim\d_spac_prevcontent>\zeropoint + \ifdim\dimexpr\scratchdimenone+\d_spac_prevcontent>\scratchdimentwo + \clf_pushatsame + \setbox\scratchbox\vpack{\clf_popatsame}% + \page + \box\scratchbox + \vskip-\lineskip + \page_sides_analyse_space_stage_one + \fi + \fi + \fi + \page_sides_analyse_space_stage_two} + +%D As we have no clear end of one or more paragraphs we only have pre float +%D skips. + +\newconstant\c_page_sides_page_method % will be: \c_page_sides_page_method\plusone + +\def\page_otr_force_new_page_one + {\vskip\d_page_sides_height + \penalty\outputpenalty + \vskip-\dimexpr\d_page_sides_height-\strutdp\relax + \prevdepth\strutdp} + %\ignoreparskip} + +\def\page_sides_handle_float#1% + {\page_sides_initialize_checker + \page_sides_check_horizontal_skips + \page_sides_check_vertical_skips + \page_sides_apply_horizontal_shift + \page_sides_check_previous_float + \page_sides_inject_before + \page_sides_inject_dummy_lines + \page_sides_relocate_float{#1}% + \page_sides_apply_vertical_shift + \page_sides_analyse_space + \ifconditional\c_page_floats_room + \global\setfalse\c_page_sides_delayed + % we're ok + \else + \global\settrue\c_page_sides_delayed + \global\c_page_sides_m_of_lines\c_page_sides_n_of_lines + \ifcase\c_page_sides_page_method + \page_otr_fill_and_eject_page + \or + \page_otr_force_new_page_one + \else + \page_otr_fill_and_eject_page + \fi + \global\c_page_sides_n_of_lines\c_page_sides_m_of_lines + \page_sides_analyse_space + %\page_sides_inject_before + \page_sides_inject_dummy_lines + \fi + \page_sides_place_float + \global\setfalse\c_page_sides_delayed + \page_sides_check_floats_reset + \page_sides_wrapup} + +\def\page_sides_wrapup + {% we need to do this aftergroup + \aftergroup\par + \aftergroup\ignoreparskip + \aftergroup\ignorespaces} + +\def\page_sides_check_floats_indeed + {\page_sides_analyse_progress + \ifdim\d_page_sides_progress>\zeropoint + \page_sides_check_floats_set + \else + \page_sides_check_floats_reset + \fi + \parskip\s_spac_whitespace_parskip} % not needed + +% \let\page_sides_check_floats\page_sides_check_floats_indeed + +\let\page_sides_check_floats\relax + +\def\page_sides_initialize_checker + {\ifx\page_sides_check_floats\relax + \glet\page_sides_check_floats\page_sides_check_floats_indeed + \clf_enablesidefloatchecker + \glet\page_sides_initialize_checker\relax + \fi} + +\protected\def\page_sides_check_floats_tracer + {\begingroup + \dontleavehmode + \ifnum\c_page_sides_float_type>\plusfour + \rlap + {\hskip\availablehsize % d_page_sides_width % kern + \color[trace:o]% + {\rlap{\kern.25\bodyfontsize\showstruts\strut}% + \vrule\s!height.5\points\s!depth.5\points\s!width\d_page_sides_width}}% + \else + \hskip-\d_page_sides_width % kern + \color[trace:o]% + {\vrule\s!height.5\points\s!depth.5\points\s!width\d_page_sides_width + \llap{\showstruts\strut\kern.25\bodyfontsize}}% + \fi + \endgroup} + +% tricky test: + +% \starttext +% \dorecurse{33}{\line{#1}} +% \placefigure[left]{}{} +% \input ward +% \startitemize +% \item word \item word \item word \item word +% \stopitemize +% \input ward +% \page +% \placefigure[left]{}{} +% \dontleavehmode \begingroup \input ward \par \endgroup +% \dontleavehmode \begingroup \input ward \par \endgroup +% \dontleavehmode \begingroup \input ward \par \endgroup +% \input ward +% \stoptext + +\protected\def\page_sides_check_floats_set + {\edef\p_sidethreshold{\floatparameter\c!sidethreshold}% + \ifconditional\c_page_sides_delayed + % For Alan's hanging right float that moved to the next page. + \d_page_sides_progress\zeropoint + \fi + \ifx\p_sidethreshold\v!old + \d_page_sides_progression\dimexpr\d_page_sides_progress+\strutht-\roundingeps\relax + \c_page_sides_n_of_hang\d_page_sides_progression + \divide\c_page_sides_n_of_hang \baselineskip\relax + \else + \d_page_sides_progression + \ifx\p_sidethreshold\empty + \d_page_sides_progress + \else + \dimexpr\d_page_sides_progress-\p_sidethreshold\relax + \fi + \getnoflines\d_page_sides_progression + % this can be an option + \ifdim\dimexpr\noflines\lineheight>\dimexpr\pagegoal-\pagetotal\relax + \getrawnoflines\d_page_sides_progression + \fi + % + \c_page_sides_n_of_hang\noflines + \fi + \global\c_page_sides_hangafter\zerocount + \ifnum\c_page_sides_n_of_hang>\zerocount + \ifcase\c_page_sides_n_of_lines + \else + \ifcase\c_page_sides_lines_done + \global\c_page_sides_lines_done\c_page_sides_n_of_hang + \else + \privatescratchcounter\c_page_sides_lines_done + \advance\privatescratchcounter-\c_page_sides_n_of_hang + \global\advance\c_page_sides_n_of_lines-\privatescratchcounter + \fi + \fi + \ifnum\c_page_sides_n_of_lines>\zerocount + \privatescratchtoks\emptytoks + \privatescratchcounter\c_page_sides_n_of_lines + \privatescratchdimen\dimexpr\hsize-\d_page_sides_width\relax + \dorecurse\c_page_sides_n_of_lines + {\toksapp\privatescratchtoks{\zeropoint\hsize}}% + \ifnum\c_page_sides_n_of_hang>\c_page_sides_n_of_lines + \advance\c_page_sides_n_of_hang -\c_page_sides_n_of_lines\relax + \advance\privatescratchcounter\c_page_sides_n_of_hang + \dorecurse\c_page_sides_n_of_hang % weird, shouldn't that be scratchcounter + {\ifnum\c_page_sides_float_type>\plusfour + \toksapp\privatescratchtoks{\zeropoint\privatescratchdimen}% + \else + \toksapp\privatescratchtoks{\d_page_sides_width\privatescratchdimen}% + \fi}% + \fi + \parshape + \numexpr\privatescratchcounter+\plusone\relax + \the\privatescratchtoks + \zeropoint \hsize + \relax + \else + \hangindent \ifnum\c_page_sides_float_type>\plusfour -\fi\d_page_sides_width + \hangafter-\c_page_sides_n_of_hang + \global\c_page_sides_hangafter\hangafter + \fi + \fi + \global\advance\c_page_sides_checks_done \plusone + \iftracesidefloats + \page_sides_check_floats_tracer + \fi} + +\protected\def\page_sides_check_floats_reset + {\ifcase\c_page_sides_checks_done\else + \ifcase\c_page_sides_hangafter\else + % we need to deal with par's ending in a group which would restore + % hang parameters + \global\c_page_sides_hangafter\zerocount + \hangindent\zeropoint + \fi + % \global % no, otherwise a next hangindent won't work + \c_page_sides_checks_done\zerocount + \fi} + +\protected\def\page_sides_synchronize_floats + {\ifinner \else + \page_sides_check_floats + \fi} + +\protected\def\page_sides_check_previous_float + {\page_sides_analyse_progress + \ifdim\d_page_sides_progress>\zeropoint \relax + \ifconditional\c_page_sides_short + \global\setfalse\c_page_sides_short + \page_otr_fill_and_eject_page + \else + \kern\d_page_sides_progress + \fi + \fi} + +% \def\adjustsidefloatdisplaylines % public, will change +% {\aftergroup\page_sides_adjust_display_lines} +% +% \def\page_sides_adjust_display_lines +% {\par +% \noindent +% \ignorespaces} + +%D We need to hook it into the other otr's. This code will be adapted once we rename +%D the callers. We use \type {\def} as they can be redefined! Some will become obsolete + +\permanent\protected\def\checksidefloat {\page_sides_check_floats} +\permanent\protected\def\flushsidefloats {\page_sides_flush_floats_text} +\permanent\protected\def\flushsidefloatsafterpar{\page_sides_flush_floats_after_par} +\permanent\protected\def\forgetsidefloats {\page_sides_forget_floats} +%permanent\protected\def\synchronizesidefloats {\page_sides_synchronize_floats} + +\protect \endinput diff --git a/tex/context/base/mkxl/page-smp.mkxl b/tex/context/base/mkxl/page-smp.mkxl new file mode 100644 index 000000000..ccb0e989e --- /dev/null +++ b/tex/context/base/mkxl/page-smp.mkxl @@ -0,0 +1,56 @@ +%D \module +%D [ file=page-smp, % was: core-mul, page-mul +%D version=1998.03.15, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Simple Multi Column Output, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +%D The old one: + +\definemixedcolumns + [\v!columns] + % compatible with columns default : + [\c!balance=\v!yes, + \c!blank={\v!line,\v!fixed}] + +\permanent\protected\def\setupcolumns + {\setupmixedcolumns[\v!columns]} + +%D This will be replaced by mixed box. + +\permanent\tolerant\protected\def\startsimplecolumns[#1]% + {\bgroup + \setsimplecolumnshsize[#1]% + \nopenalties + \setbox\scratchbox\vbox\bgroup + \forgetall} % \blank[\v!disable] + +\permanent\protected\def\stopsimplecolumns + {\removebottomthings + \egroup + \rigidcolumnbalance\scratchbox + \egroup} + +\permanent\protected\def\setsimplecolumnshsize[#1]% + {\getdummyparameters + [\c!width=\hsize, + \c!distance=1.5\bodyfontsize, + \c!n=2, + \c!lines=0, + #1]% + \edef\rigidcolumnlines + {\directdummyparameter\c!lines}% + \setrigidcolumnhsize + {\directdummyparameter\c!width}% + {\directdummyparameter\c!distance}% + {\directdummyparameter\c!n}} + +\protect \endinput diff --git a/tex/context/base/mkiv/page-spr.mkxl b/tex/context/base/mkxl/page-spr.mkxl index 3a835a61c..49285c96f 100644 --- a/tex/context/base/mkiv/page-spr.mkxl +++ b/tex/context/base/mkxl/page-spr.mkxl @@ -75,17 +75,15 @@ \fi \fi } \permanent\protected\def\startspread - {\ifdoublesided - \ifconditional\c_page_spread_busy - \doubleexpandafter\page_spread_start_nop - \else - \doubleexpandafter\page_spread_start_yes - \fi - \else + {\unless\ifdoublesided + \expandafter\page_spread_start_nop + \orelse\ifconditional\c_page_spread_busy \expandafter\page_spread_start_nop + \else + \expandafter\page_spread_start_yes \fi} -\let\stopspread\relax +\aliased\let\stopspread\relax \protected\def\page_spread_start_yes {\bgroup @@ -93,9 +91,9 @@ %\setsystemmode{spread}% \settrue\c_page_spread_busy \expanded{\setuplayout[\c!textwidth=\the\dimexpr2\textwidth+2\backspace\relax]}% - \let\stopspread\page_spread_stop_yes} + \enforced\let\stopspread\page_spread_stop_yes} -\protected\def\page_spread_stop_yes +\permanent\protected\def\page_spread_stop_yes {\kern\zeropoint \page \setuplayout[\c!textwidth=\textwidth]% diff --git a/tex/context/base/mkxl/page-str.mkxl b/tex/context/base/mkxl/page-str.mkxl new file mode 100644 index 000000000..d6e01ea59 --- /dev/null +++ b/tex/context/base/mkxl/page-str.mkxl @@ -0,0 +1,128 @@ +%D \module +%D [ file=page-str, +%D version=2010.03.13, % 2006.03.21, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Page Streams, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Page Streams} + +%D The first version of this component of \CONTEXT\ was written for Thomas Schmitz +%D who asked for parallel page streams. While playing with the code, I decided to +%D make it into a component that can be used to construct all kind of stream related +%D mechanisms. Because I could apply this feature in a project, there is some +%D additional code here (related to graphics). +%D +%D These macros were written while listening to and watching the DVD \quotation +%D {Rush In Rio}. +%D +%D The reimplementation (or rather experimenting with the complete rewrite) was done +%D while looping over \quotation {Wende Snijders No.9}. +%D +%D Remark: marknotes are gone, at least for a while. + +\registerctxluafile{page-str}{} + +\unprotect + +\mutable\let\currentoutputstream\empty + +\newif \ifinoutputstream % will become a conditional or mode +\newtoks \everyenableoutputstream + +\appendtoks + \page_otr_command_flush_side_floats +\to \everyenableoutputstream + +\permanent\protected\def\initializeoutputstreams + {\clf_initializestream + \enforced\glet\initializeoutputstreams\relax} + +\permanent\protected\def\enableoutputstream[#1]% could be \startoutputsubstream + {\initializeoutputstreams + \the\everyenableoutputstream + \inoutputstreamtrue + \xdef\currentoutputstream{#1}% + \clf_enablestream{#1} + \prevdepth\zeropoint} % maybe more is needed i.e. we need to get rid of leading glue + +\permanent\protected\def\disableoutputstream + {\inoutputstreamfalse + \glet\currentoutputstream\s!default + \clf_disablestream} + +\permanent\protected\def\startoutputstream[#1]% + {\begingroup + \initializeoutputstreams + \the\everyenableoutputstream + \inoutputstreamtrue + \xdef\currentoutputstream{#1}% + \clf_startstream{#1}} + +\permanent\protected\def\stopoutputstream + {\clf_stopstream + \endgroup} + +\permanent\protected\def\startoutputsubstream[#1]% just push/pop instead + {\globalpushmacro\currentoutputstream + \enableoutputstream[#1]} + +\permanent\protected\def\stopoutputsubstream + {\globalpopmacro\currentoutputstream + \enableoutputstream[\currentoutputstream]} + +\permanent \protected\def\flushoutputstream [#1]{\clf_flushstream{#1}} +\permanent \protected\def\outputstreambox [#1]{\vbox{\clf_flushstream{#1}}} +\permanent \protected\def\outputstreamcopy [#1]{\vbox{\clf_flushstreamcopy{#1}}} +\permanent \protected\def\outputstreamunvbox [#1]{\clf_flushstream{#1}} +\permanent \protected\def\outputstreamunvcopy[#1]{\clf_flushstreamcopy{#1}} +\permanent \protected\def\synchronizestreams [#1]{\clf_synchronizestream{#1}} +\permanent\tolerant\protected\def\pushoutputstream [#1]{\clf_pushstream{#1}} + +\protect \endinput + +% \enabletrackers[streams.flushing] +% +% \setuplayout[grid=yes] \showgrid +% +% \starttext +% +% \input tufte +% +% \startoutputstream[nl] +% +% Wat doen we hier? +% +% \enableoutputstream[en] +% +% Are you sleeping, brother John?\footnote{xxx} +% +% \dorecurse{4}{x \footnote{note \recurselevel}\input tufte \par \pushoutputstream} +% +% \enableoutputstream[de] +% +% Bruder Jakob, schläfst du noch?\footnote{yyy} +% +% \dorecurse{4}{x \footnote{note \recurselevel}\input ward \par \pushoutputstream} +% +% \disableoutputstream +% +% \stopoutputstream +% +% Vader Jacob, slaap je nog?\footnote{zzz} +% +% \input tufte +% +% \synchronizestreams[en,de,nl] +% +% \page \flushoutputstream[en] \input knuth +% \page \flushoutputstream[de] \input knuth +% \page \flushoutputstream[nl] \input knuth +% +% \stoptext diff --git a/tex/context/base/mkiv/page-txt.mklx b/tex/context/base/mkxl/page-txt.mklx index 9058f893d..f8c77e572 100644 --- a/tex/context/base/mkiv/page-txt.mklx +++ b/tex/context/base/mkxl/page-txt.mklx @@ -91,11 +91,11 @@ \to \everysetuplayoutelement \def\page_layouts_reset_element_status#vertical% - {\global\defcsname\??layouttextsreset#vertical\endcsname{\page_layouts_set_element_status_normal#vertical}} + {\gdefcsname\??layouttextsreset#vertical\endcsname{\page_layouts_set_element_status_normal#vertical}} \def\page_layouts_set_element_status_normal#vertical% - {\global\letcsname\namedlayoutelementhash#vertical\c!state\endcsname\v!normal - \global\letcsname\??layouttextsreset#vertical\endcsname\relax + {\gletcsname\namedlayoutelementhash#vertical\c!state\endcsname\v!normal + \gletcsname\??layouttextsreset#vertical\endcsname\relax \page_layouts_synchronize_element{#vertical}} \def\page_layouts_synchronize_element#vertical% @@ -111,7 +111,7 @@ \ifx\previoustextstate\v!high \calculatevsizes\page_backgrounds_recalculate \orelse \ifx\currenttextstate \v!none \calculatevsizes\page_backgrounds_recalculate \orelse \ifx\previoustextstate\v!none \calculatevsizes\page_backgrounds_recalculate \fi - \letgvalue{\??layouttextssynchronize#vertical}\currenttextstate} + \gletcsname\??layouttextssynchronize#vertical\endcsname\currenttextstate} \permanent\protected\def\setuptop {\setuplayouttext[\v!top ]} \permanent\protected\def\setupheader{\setuplayouttext[\v!header]} @@ -272,13 +272,13 @@ \ifcase\c_page_layouts_element_state_n \edef\textlinestatus{\namedlayoutelementparameter#vertical\c!state}% \else - \setxvalue{\namedlayoutelementhash#vertical\c!n}{\the\numexpr\c_page_layouts_element_state_n+\minusone}% + \xdefcsname\namedlayoutelementhash#vertical\c!n\endcsname{\the\numexpr\c_page_layouts_element_state_n+\minusone}% \let\textlinestatus\v!stop \fi} \appendtoks - \doifinset\v!header\floatspecification{\setxvalue{\namedlayoutelementhash\v!header\c!n}{1}}% - \doifinset\v!footer\floatspecification{\setxvalue{\namedlayoutelementhash\v!footer\c!n}{1}}% + \doifinset\v!header\floatspecification{\xdefcsname\namedlayoutelementhash\v!header\c!n\endcsname{1}}% + \doifinset\v!footer\floatspecification{\xdefcsname\namedlayoutelementhash\v!footer\c!n\endcsname{1}}% \to \everybeforeflushedpagefloat \protected\def\page_layouts_place_text_line#vertical% @@ -292,11 +292,11 @@ \permanent\protected\def\doifelselayouttextline#vertical% shown or not {\edef\currentlayoutelementstate{\namedlayoutelementparameter{#vertical}\c!state}% \ifx\currentlayoutelementstate\v!normal - \expandafter\firstoftwoarguments + \expandafter\firstoftwoarguments \orelse\ifx\currentlayoutelementstate\v!start - \expandafter\firstoftwoarguments + \expandafter\firstoftwoarguments \else - \expandafter\secondoftwoarguments + \expandafter\secondoftwoarguments \fi} \permanent\protected\def\doifelselayoutsomeline#vertical% present or not @@ -309,8 +309,8 @@ \expandafter\firstoftwoarguments \fi} -\let\doiflayouttextlineelse\doifelselayouttextline -\let\doiflayoutsomelineelse\doifelselayoutsomeline +\aliased\let\doiflayouttextlineelse\doifelselayouttextline +\aliased\let\doiflayoutsomelineelse\doifelselayoutsomeline \newconditional\resyncaftertextline @@ -383,13 +383,13 @@ \permanent\tolerant\protected\def\settextcontent[#vertical]#spacer[#horizontal]#spacer[#one]#spacer[#two]#spacer[#three]% header text middle text/text {\ifarguments\or\or\or % 3 - \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\c!middletext}% + \defcsname\namedlayoutelementhash{#vertical:#horizontal}\c!middletext\endcsname {\page_layouts_process_element_double{#one}{#one}}% \or % 4 - \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\begincsname\??layouttextcontent\v!text:#one\endcsname\c!middletext}% + \defcsname\namedlayoutelementhash{#vertical:#horizontal}\begincsname\??layouttextcontent\v!text:#one\endcsname\c!middletext\endcsname {\page_layouts_process_element_double{#two}{#two}}% \or % 5 - \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\begincsname\??layouttextcontent\v!text:#one\endcsname\c!middletext}% + \defcsname\namedlayoutelementhash{#vertical:#horizontal}\begincsname\??layouttextcontent\v!text:#one\endcsname\c!middletext\endcsname {\page_layouts_process_element_double{#two}{#three}}% \fi} @@ -704,15 +704,15 @@ \permanent\tolerant\protected\def\definetext[#tag]#spacer[#vertical]#spacer[#horizontal]#spacer[#a]#spacer[#b]#spacer[#c]#spacer[#d]% {\ifnum\lastarguments<\plusfour - \setvalue{\namedlayoutelementhash {#vertical}#tag}{\setuptexts[#vertical][#horizontal]\relax}% 1, 2, 3 + \defcsname\namedlayoutelementhash {#vertical}#tag\endcsname{\setuptexts[#vertical][#horizontal]\relax}% 1, 2, 3 \orelse\ifarguments\or\or\or\or - \setvalue{\namedlayoutelementhash {#vertical}#tag}{\setuptexts[#vertical][#horizontal][#a]\relax}% 4 + \defcsname\namedlayoutelementhash {#vertical}#tag\endcsname{\setuptexts[#vertical][#horizontal][#a]\relax}% 4 \or - \setvalue{\namedlayoutelementhash{#vertical:#horizontal}#tag}{\setuptexts[#vertical][#horizontal][#a][#b]\relax}% 5 + \defcsname\namedlayoutelementhash{#vertical:#horizontal}#tag\endcsname{\setuptexts[#vertical][#horizontal][#a][#b]\relax}% 5 \or - \setvalue{\namedlayoutelementhash {#vertical}#tag}{\setuptexts[#vertical][#horizontal][#a][#b][#c]\relax}% 6 + \defcsname\namedlayoutelementhash {#vertical}#tag\endcsname{\setuptexts[#vertical][#horizontal][#a][#b][#c]\relax}% 6 \or - \setvalue{\namedlayoutelementhash{#vertical:#horizontal}#tag}{\setuptexts[#vertical][#horizontal][#a][#b][#c][#d]\relax}% 7 + \defcsname\namedlayoutelementhash{#vertical:#horizontal}#tag\endcsname{\setuptexts[#vertical][#horizontal][#a][#b][#c][#d]\relax}% 7 \fi} %D A few more page breakers: diff --git a/tex/context/base/mkxl/page-var.mkxl b/tex/context/base/mkxl/page-var.mkxl new file mode 100644 index 000000000..1c7fd5b25 --- /dev/null +++ b/tex/context/base/mkxl/page-var.mkxl @@ -0,0 +1,20 @@ +%D \module +%D [ file=page-var, +%D version=2011.12.05, % moved from other page-* files +%D title=\CONTEXT\ Page Macros, +%D subtitle=Variables, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Variables} + +\unprotect + +% just for temporary moved variables + +\protect \endinput diff --git a/tex/context/base/mkiv/phys-dim.mkxl b/tex/context/base/mkxl/phys-dim.mkxl index 3102650bf..3102650bf 100644 --- a/tex/context/base/mkiv/phys-dim.mkxl +++ b/tex/context/base/mkxl/phys-dim.mkxl diff --git a/tex/context/base/mkiv/publ-inc.mkxl b/tex/context/base/mkxl/publ-inc.mkxl index 8e6cd2bdf..8e6cd2bdf 100644 --- a/tex/context/base/mkiv/publ-inc.mkxl +++ b/tex/context/base/mkxl/publ-inc.mkxl diff --git a/tex/context/base/mkiv/publ-ini.mkxl b/tex/context/base/mkxl/publ-ini.mkxl index 7c1671528..6b520074a 100644 --- a/tex/context/base/mkiv/publ-ini.mkxl +++ b/tex/context/base/mkxl/publ-ini.mkxl @@ -212,10 +212,11 @@ \publ_specification_set{\btxparameter\c!specification}% \to \everyjob -\protected\def\startusingbtxspecification[#1]% +\permanent\protected\def\startusingbtxspecification[#1]% {\publ_specification_push{#1}} -\let\stopusingbtxspecification\publ_specification_pop +\permanent\protected\def\stopusingbtxspecification + {\publ_specification_pop} % \setupbtxlist[alternative=paragraph,width=auto,distance=\emwidth] % \setupbtxlist[alternative=paragraph,width=auto,distance=\emwidth,margin=2em] % useless @@ -273,19 +274,16 @@ \fi}% \edef\currentlist{\s!btx:\currentbtxlist}} -\permanent\protected\def\usebtxdataset +\tolerant\permanent\protected\def\usebtxdataset[#1]#*[#2]#*[#3]% {\begingroup - \dotripleempty\publ_use_dataset} - -\def\publ_use_dataset[#1][#2][#3]% - {\getdummyparameters[\c!specification=\currentbtxspecification,#3]% - \ifsecondargument + \getdummyparameters[\c!specification=\currentbtxspecification,#3]% + \ifparameter#2\or \clf_btxusedataset specification {\dummyparameter\c!specification}% dataset {#1}% filename {#2}% \relax - \orelse\iffirstargument + \orelse\ifparameter#1\or \clf_btxusedataset specification {\dummyparameter\c!specification}% dataset {\v!default}% @@ -353,10 +351,10 @@ \def\publ_command_nop#1% {\ifcsname#1\endcsname \showmessage\m!publications{10}{#1,#1}% - \global\letcsname\??btxcommand#1\expandafter\endcsname\csname#1\endcsname + \gletcsname\??btxcommand#1\expandafter\endcsname\csname#1\endcsname \orelse\ifcsname\utfupper{#1}\endcsname \showmessage\m!publications{10}{#1}{\utfupper{#1}}% - \global\letcsname\??btxcommand#1\expandafter\endcsname\csname\utfupper{#1}\endcsname + \gletcsname\??btxcommand#1\expandafter\endcsname\csname\utfupper{#1}\endcsname \else \showmessage\m!publications{11}{#1}% \setugvalue{\??btxcommand#1}{\underbar{\tttf#1}}% @@ -1792,7 +1790,7 @@ %D In-text entries: -\protected\def\placecitation{\citation[entry]} % [#1] +\permanent\protected\def\placecitation{\citation[entry]} % [#1] \permanent\protected\def\btxhandleciteentry {\dontleavehmode diff --git a/tex/context/base/mkxl/publ-old.mkxl b/tex/context/base/mkxl/publ-old.mkxl new file mode 100644 index 000000000..cf7e0c46b --- /dev/null +++ b/tex/context/base/mkxl/publ-old.mkxl @@ -0,0 +1,22 @@ +%D \module +%D [ file=publ-old, +%D version=2013.12.24, +%D title=\CONTEXT\ Publication Support, +%D subtitle=Old Fashioned \BIBTEX, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +% No protection because we have a module that overloads them! + +\protected\def\setupbibtex {\usemodule[oldbibtex]\setupbibtex} +\protected\def\setuppublications {\usemodule[oldbibtex]\setuppublications} +\protected\def\setuppublicationlist{\usemodule[oldbibtex]\setuppublicationlist} + +\protect diff --git a/tex/context/base/mkiv/publ-tra.mkxl b/tex/context/base/mkxl/publ-tra.mkxl index ccad4c22a..ccad4c22a 100644 --- a/tex/context/base/mkiv/publ-tra.mkxl +++ b/tex/context/base/mkxl/publ-tra.mkxl diff --git a/tex/context/base/mkiv/publ-xml.mkxl b/tex/context/base/mkxl/publ-xml.mkxl index 925ccff1a..74fb47e08 100644 --- a/tex/context/base/mkiv/publ-xml.mkxl +++ b/tex/context/base/mkxl/publ-xml.mkxl @@ -16,7 +16,7 @@ \unprotect \permanent\tolerant\protected\def\convertbtxdatasettoxml[#1]% - {\clf_convertbtxdatasettoxml{\ifparameter\or#1\else\s!default\fi}} % or current when not empty + {\clf_convertbtxdatasettoxml{\ifparameter#1\or#1\else\s!default\fi}} % or current when not empty % \startxmlsetups btx:initialize % \xmlregistereddocumentsetups{#1}{} @@ -75,7 +75,7 @@ % \stoppacked -% \unexpanded\def\btx_xml_list_handle_entry +% \protected\def\btx_xml_list_handle_entry % {\begingroup % \ignorespaces % \xmlfilter{btx:\currentbtxrendering}{/bibtex/entry[@tag='\currentbtxtag']/command(btx:format)}% @@ -101,11 +101,11 @@ % \xmlfilter{#1}{/entry/command(btx:format)} % \stopxmlsetups -% \unexpanded\def\btx_xml_doifelse#1{\xmldoifelse\currentbibxmlnode{/field[@name='#1']}} -% \unexpanded\def\btx_xml_doif #1{\xmldoif \currentbibxmlnode{/field[@name='#1']}} -% \unexpanded\def\btx_xml_doifnot #1{\xmldoifnot \currentbibxmlnode{/field[@name='#1']}} -% \def\btx_xml_flush #1{\xmlcontext \currentbibxmlnode{/field[@name='#1']}} -% \def\btx_xml_setup {\xmlsetup \currentbibxmlnode} % {#1} -% \unexpanded\def\btx_xml_todo #1{[#1]} +% \protected\def\btx_xml_doifelse#1{\xmldoifelse\currentbibxmlnode{/field[@name='#1']}} +% \protected\def\btx_xml_doif #1{\xmldoif \currentbibxmlnode{/field[@name='#1']}} +% \protected\def\btx_xml_doifnot #1{\xmldoifnot \currentbibxmlnode{/field[@name='#1']}} +% \def\btx_xml_flush #1{\xmlcontext \currentbibxmlnode{/field[@name='#1']}} +% \def\btx_xml_setup {\xmlsetup \currentbibxmlnode} % {#1} +% \protected\def\btx_xml_todo #1{[#1]} % \xmlfilter{#1}{/field[@name='\currentbtxfield']/btxconcat('\currentbtxfield')} diff --git a/tex/context/base/mkiv/regi-ini.mkxl b/tex/context/base/mkxl/regi-ini.mkxl index 31e8b4717..31e8b4717 100644 --- a/tex/context/base/mkiv/regi-ini.mkxl +++ b/tex/context/base/mkxl/regi-ini.mkxl diff --git a/tex/context/base/mkxl/scrn-bar.mklx b/tex/context/base/mkxl/scrn-bar.mklx new file mode 100644 index 000000000..f99f7569f --- /dev/null +++ b/tex/context/base/mkxl/scrn-bar.mklx @@ -0,0 +1,402 @@ +%D \module +%D [ file=scrn-bar, % was part of scrn-int +%D version=1995.01.01, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Progress Bars, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Screen Macros / Progress Bars} + +\unprotect + +%D The code is a bit upgraded to \MKIV\ but the output is mostly the same. In +%D retrospect this should have been a module. We can move some definitions to +%D scrn-run-bar.mkiv if needed. We can also make the code a bit more efficient. + +% todo: replace blackrule by stupid rules + +%D \starttyping +%D \setupinteraction +%D [state=start] +%D +%D \setupsubpagenumber +%D [state=start] +%D +%D \setuplayout +%D [middle] +%D +%D \setuppapersize +%D [S4][S4] +%D +%D \startsetups bars +%D \ruledvbox to \textheight \bgroup +%D a \ruledhbox{\interactionbar[a]}\vss +%D b \ruledhbox{\interactionbar[b]}\vss +%D c \ruledhbox{\interactionbar[c]}\vss +%D d \ruledhbox{\interactionbar[d]}\vss +%D e \ruledhbox{\interactionbar[e]}\vss +%D f \ruledhbox{\interactionbar[f]}\vss +%D g \ruledhbox{\interactionbar[g]}\vss +%D \egroup +%D \stopsetups +%D +%D \setuptexttexts[\setups{bars}] +%D +%D \starttext +%D \dorecurse {12} { +%D \startstandardmakeup +%D \stopstandardmakeup +%D } +%D \stoptext +%D \stoptyping + +\installcorenamespace{interactionbar} + +\installframedcommandhandler \??interactionbar {interactionbar} \??interactionbar + +\permanent\tolerant\protected\def\interactionbar[#tag]#spacer[#settings]% somewhat messy + {\iflocation + \begingroup + \ifhastok={#tag}% + \let\currentinteractionbar\empty + \setupcurrentinteractionbar[#tag]% + \edef\currentinteractionbar{\interactionbarparameter\c!alternative}% + \else + \edef\currentinteractionbar{#tag}% + \setupcurrentinteractionbar[#settings]% + \fi + \doif{\interactionbarparameter\c!state}\v!start + {\interactionbarparameter\c!command}% + \endgroup + \fi} + +\newdimen\d_scrn_bar_width +\newdimen\d_scrn_bar_height +\newdimen\d_scrn_bar_depth +\newdimen\d_scrn_bar_distance + +%D Interaction buttons, in fact a row of tiny buttons, are typically only used for +%D navigational purposed. The next macro builds such a row based on a specification +%D list. +%D +%D \startbuffer +%D \interactionbuttons[width=\hsize][page,PreviousJump,ExitViewer] +%D \stopbuffer +%D +%D \typebuffer +%D +%D gives +%D +%D \getbuffer +%D +%D Apart from individual entries, one can use \type{page} and \type {subpage} as +%D shortcuts to their four associated buttons. The symbols are derived from the +%D symbols linked to the entries. + +\permanent\tolerant\protected\def\interactionbuttons[#settings]#spacer[#list]% + {\iflocation + \ifcstok{\interactionbarparameter\c!state}\v!start + \ifparameter#list\or + \scrn_bar_buttons_indeed{#settings}{#list}% + \else + \scrn_bar_buttons_indeed{}{#settings}% + \fi + \fi + \fi} + +\def\scrn_bar_buttons_indeed#settings#list% + {\begingroup + %\let\currentinteractionbar\empty + \setupcurrentinteractionbar[#settings]% + \d_scrn_bar_width \interactionbarparameter\c!width\relax + \d_scrn_bar_distance\interactionbarparameter\c!distance\relax + \ifzeropt\d_scrn_bar_width + \d_scrn_bar_width1.5\emwidth + \fi + \doifnothing{\interactionbarparameter\c!height}{\letinteractionbarparameter\c!height\v!broad}% + \doifnothing{\interactionbarparameter\c!depth }{\letinteractionbarparameter\c!depth\zeropoint}%%% + \letinteractionbarparameter\c!background\empty + \setbox2\hbox{\inheritedinteractionbarframed{\symbol[\interactionparameter\c!symbolset][\v!previouspage]}}% + \scratchheight\ht2 % needed because we default to nothing + \letinteractionbarparameter\c!strut\v!no + % \letinteractionparameter\c!width\zeropoint + \scratchcounterone\zerocount % new, was 1 + \processallactionsinset + [#list] + [ \v!page=>\advance\scratchcounterone\plusfour, + \v!subpage=>\advance\scratchcounterone\plusfour, + \s!unknown=>\advance\scratchcounterone\plusone]% + \ifzeropt\d_scrn_bar_width + \scratchdimenone\dimexpr2\emwidth+\d_scrn_bar_distance\relax + \scratchdimentwo\dimexpr\scratchcounterone\scratchdimenone-\d_scrn_bar_distance\relax + \else + \scratchdimenone\d_scrn_bar_width + \scratchdimentwo\dimexpr\scratchcounterone\d_scrn_bar_distance-\d_scrn_bar_distance\relax + \advance\scratchdimenone -\scratchdimentwo + \divide\scratchdimenone \scratchcounterone + \scratchdimentwo\d_scrn_bar_width + \fi + \hbox to \scratchdimentwo + {\setnostrut + \startsymbolset[\interactionparameter\c!symbolset]% + \setupbuttons + [#settings,% + \c!height=\the\scratchheight,% + \c!width=\the\scratchdimenone]% + \processallactionsinset + [#list] + [ \v!page=>\scrn_bar_goto\v!firstpage + \scrn_bar_goto\v!nextpage + \scrn_bar_goto\v!previouspage + \scrn_bar_goto\v!lastpage, + \v!subpage=>\scrn_bar_goto\v!firstsubpage + \scrn_bar_goto\v!nextsubpage + \scrn_bar_goto\v!previoussubpage + \scrn_bar_goto\v!lastsubpage, + \s!unknown=>\scrn_bar_goto\commalistelement]% + \unskip + \stopsymbolset}% + \endgroup} + +\def\scrn_bar_goto#action% + {\button{\symbol[#action]}[#action]\hss} + +% todo: this will be \letblackruleparameter\c!width\scratchdimenone (faster) +% todo: make these setups + +\def\scrn_bar_alternative_a + {\d_scrn_bar_width \interactionbarparameter\c!width + \d_scrn_bar_distance\interactionbarparameter\c!distance + \d_scrn_bar_height \interactionbarparameter\c!height + \d_scrn_bar_depth \interactionbarparameter\c!depth + \noindent\hbox to \d_scrn_bar_width \bgroup + \dontcomplain + \setupblackrules[\c!height=\v!max,\c!depth=\v!max]% + \scratchdimentwo\dimexpr\d_scrn_bar_width-4\emwidth\relax + \processaction + [\interactionbarparameter\c!step] + [ \v!small=>\scratchcounter 20, + \v!medium=>\scratchcounter 10, + \v!big=>\scratchcounter 5, + \s!unknown=>\scratchcounter 10]% + \scratchdimenone\dimexpr\scratchdimentwo/\scratchcounter\relax + \setupblackrules[\c!width=\scratchdimenone]% + \setbox\scratchbox\hbox to \d_scrn_bar_width + {\hskip2\emwidth + \setbox\scratchbox\hpack{\blackrule[\c!color=\interactionbarparameter\c!backgroundcolor]}% + \dorecurse\scratchcounter + {\hss\normalexpanded{\directgotodumbbox{\copy\scratchbox}[page(\the\numexpr\recurselevel*\lastpage/\scratchcounter\relax)]}}% + \hss + \hskip2\emwidth}% + \wd\scratchbox\zeropoint + \box \scratchbox + \setupblackrules[\c!width=\emwidth]% + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[\v!firstpage]}% + \hskip\emwidth + \ifnum\realpageno>\plusone + \hskip\zeropoint\s!plus\numexpr\realpageno-\plustwo\relax \s!sp\relax % cm gives overflow + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[\v!previouspage)]}% + \fi + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[page(\number\realpageno)]}% todo: \v!currentpage + \ifnum\realpageno<\lastpage\relax + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[\v!nextpage]}% + \hskip\zeropoint\s!plus\numexpr\lastpage-\realpageno-\plusone\relax \s!sp\relax % cm gives overflow + \fi + \hskip\emwidth + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[\v!lastpage]}% + \egroup} + +\def\scrn_bar_alternative_b + {\ifnum\lastpage>\firstpage\relax + \interactionbuttons[\v!firstpage,\v!previouspage,\v!nextpage,\v!lastpage]% + \fi} + +\def\scrn_bar_alternative_c + {\ifnum\lastpage>\plusone + \d_scrn_bar_width\interactionbarparameter\c!width + \hbox to \d_scrn_bar_width + {\setupblackrules[\c!height=\interactionbarparameter\c!height,\c!depth=\interactionbarparameter\c!depth,\c!width=\emwidth]% + \scratchdimen\dimexpr(\d_scrn_bar_width-4\emwidth)/\numexpr\lastpage+\minusone\relax\relax + \scratchdimenone\numexpr\realpageno+\minusone\relax\scratchdimen + \scratchdimentwo\numexpr\lastpage-\realpageno\relax\scratchdimen + \directgotospecbox\interactionbarparameter{\blackrule}[\v!firstpage]% + \hss + \directgotospecbox\interactionbarparameter{\blackrule[\c!width=\scratchdimenone]}[\v!previouspage]% + \blackrule[\c!color=\interactionbarparameter\c!contrastcolor]% + \directgotospecbox\interactionbarparameter{\blackrule[\c!width=\scratchdimentwo]}[\v!nextpage]% + \hss + \directgotospecbox\interactionbarparameter{\blackrule}[\v!lastpage]}% + \fi} + +\protected\def\scrn_bar_goto_a#whereto% + {\symbol[\ifcase#whereto\v!previous\or\v!somewhere\or\v!next\fi]} + +\protected\def\scrn_bar_goto_b#whereto% + {\vrule\s!height\d_scrn_bar_height\s!depth\d_scrn_bar_depth\s!width\scratchdimenone\relax} + +\protected\def\scrn_bar_goto_c#whereto% + {\symbol[\ifcase#whereto\v!previous\or\v!somewhere\or\v!somewhere\or\v!somewhere\or\v!next\fi} + +\protected\def\scrn_bar_goto_d#whereto% + {\vrule \s!width\scratchdimenone \ifcase#whereto% + \s!height \d_scrn_bar_height \s!depth \d_scrn_bar_depth \or + \s!height.5\d_scrn_bar_height \s!depth.5\d_scrn_bar_depth \or + \s!height \d_scrn_bar_height \s!depth \d_scrn_bar_depth \or + \s!height.5\d_scrn_bar_height \s!depth.5\d_scrn_bar_depth \else + \s!height \d_scrn_bar_height \s!depth \d_scrn_bar_depth \fi} + +\newconstant\c_scrn_bar_mode + +\protected\def\scrn_bar_goto_x#command% + {\doifelse{\interactionbarparameter\c!symbol}\v!yes + {\setupsymbolset[\interactionparameter\c!symbolset]% + \let\scrn_bar_goto_indeed\scrn_bar_goto_a} + {\let\scrn_bar_goto_indeed\scrn_bar_goto_b}% + \dorecurse\nofsubpages + %{\scratchcounter\numexpr\recurselevel+\firstsubpage+\minusone\relax + {\scratchcounter\therealsubpageno\recurselevel + \c_scrn_bar_mode + \ifnum\scratchcounter<\realpageno \zerocount \else + \ifnum\scratchcounter=\realpageno \plusone \else + \plustwo \fi\fi + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\scrn_bar_goto_indeed\c_scrn_bar_mode}[page(\the\scratchcounter)]}% + #command}% + \unskip} + +\def\scrn_bar_alternative_d + {\ifnum\nofsubpages>\plusone \doif{\namedcounterparameter\s!subpage\c!state}\v!start{% + \d_scrn_bar_width \interactionbarparameter\c!width + \d_scrn_bar_distance\interactionbarparameter\c!distance + \d_scrn_bar_height \interactionbarparameter\c!height + \d_scrn_bar_depth \interactionbarparameter\c!depth + \scratchdimenone\d_scrn_bar_width + \noindent\hbox{\scrn_bar_goto_x{\hskip\d_scrn_bar_distance}}% \hpack ? + }\fi} + +\def\scrn_bar_alternative_e + {\ifnum\nofsubpages>\plusone \doif{\namedcounterparameter\s!subpage\c!state}\v!start{% + \d_scrn_bar_width \interactionbarparameter\c!width + \d_scrn_bar_distance\interactionbarparameter\c!distance + \d_scrn_bar_height \interactionbarparameter\c!height + \d_scrn_bar_depth \interactionbarparameter\c!depth + \scratchdimentwo\dimexpr\nofsubpages\d_scrn_bar_distance-\d_scrn_bar_distance\relax % (n-1) + \scratchdimenone\dimexpr(\d_scrn_bar_width-\scratchdimentwo)/\nofsubpages\relax + \ifdim\scratchdimenone<\d_scrn_bar_distance + \scrn_bar_alternative_f + \else + \noindent\hbox to \d_scrn_bar_width{\scrn_bar_goto_x{\hss}\unskip}% \hpack ? + \fi + }\fi} + +\def\scrn_bar_alternative_f + {\ifnum\nofsubpages>\plusone \doif{\namedcounterparameter\s!subpage\c!state}\v!start{% + \d_scrn_bar_width \interactionbarparameter\c!width + \d_scrn_bar_distance\interactionbarparameter\c!distance + \d_scrn_bar_height \interactionbarparameter\c!height + \d_scrn_bar_depth \interactionbarparameter\c!depth + \noindent \hbox to \d_scrn_bar_width \bgroup + \doloop + {\scratchcounterthree\numexpr(\nofsubpages/\recurselevel)+\plusone\relax % rounding + \scratchdimentwo\d_scrn_bar_distance + \multiply\scratchdimentwo \scratchcounterthree + \advance\scratchdimentwo -\d_scrn_bar_distance + \scratchdimenone\d_scrn_bar_width + \advance\scratchdimenone -\scratchdimentwo + \divide\scratchdimenone \scratchcounterthree + \ifdim\scratchdimenone<\d_scrn_bar_distance\else + \scratchcountertwo\recurselevel + \exitloop + \fi}% + \ifnum\scratchcounterthree>\plusone + % this is not that well tested + \advance\scratchcounterthree \minustwo + \scratchdimenone-\d_scrn_bar_distance + \scratchdimenone\scratchcounterthree\scratchdimenone + \advance\scratchdimenone \d_scrn_bar_width + \advance\scratchcounterthree \plusone + \divide\scratchdimenone \scratchcounterthree + \fi + \doifelse{\interactionbarparameter\c!symbol}\v!yes + {\setupsymbolset[\interactionparameter\c!symbolset]% + \let\scrn_bar_goto_indeed\scrn_bar_goto_c}% + {\let\scrn_bar_goto_indeed\scrn_bar_goto_d}% + \scratchcounterthree\numexpr\realpageno-\plustwo\relax + \scratchcounterfour\numexpr\realpageno+\plustwo\relax + \ifnum\scratchcounterthree<\plusone \scratchcounterthree\plusone \fi + \scratchcounterfive\zerocount + \dostepwiserecurse\firstsubpage\lastsubpage\plusone + {\donefalse + \advance\scratchcounterfive \plusone + \ifnum\recurselevel=\firstsubpage\relax \donetrue \fi + \ifnum\recurselevel=\lastsubpage \relax \donetrue \fi + \scratchcountersix\therealsubpageno\recurselevel\relax + \c_scrn_bar_mode + \ifdone + \ifnum\scratchcountersix<\realpageno + \zerocount + \orelse\ifnum\scratchcountersix>\realpageno + \plustwo + \else + \plusfour + \fi + \else + \ifnum\scratchcounterfive=\scratchcountertwo + \ifnum\scratchcountersix<\realpageno + \plusone + \orelse\ifnum\scratchcountersix>\realpageno + \plusthree + \else + \plustwo + \fi + \else + \minusone + \fi + \fi + \ifnum\c_scrn_bar_mode<\zerocount\else + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\scrn_bar_goto_indeed\c_scrn_bar_mode}[realpage(\the\scratchcountersix)]}% + \hss + \scratchcounterfive\zerocount + \fi}% + \unskip + \egroup + }\fi} + +\def\scrn_bar_alternative_g + {\ifnum\lastsubpage>\firstsubpage\relax % no test for state? + \interactionbuttons[\v!firstsubpage,\v!previoussubpage,\v!nextsubpage,\v!lastsubpage]% + \fi} + +\setupinteractionbar + [\c!state=\v!start, + \c!alternative=a, + \c!symbol=\v!no, + \c!width=10\emwidth, + \c!height=.5\emwidth, + \c!depth=\zeropoint, + \c!distance=.5\emwidth, + \c!step=\v!medium, + \c!foregroundcolor=\interactionbarparameter\c!color, + \c!foregroundstyle=\interactionbarparameter\c!style, + \c!color=\interactionparameter\c!color, + \c!contrastcolor=\interactionparameter\c!contrastcolor, + \c!style=, + \c!frame=\v!on, + \c!background=color, + \c!backgroundcolor=gray, + \c!samepage=\v!yes] + +\defineinteractionbar[a][\c!command=\scrn_bar_alternative_a] +\defineinteractionbar[b][\c!command=\scrn_bar_alternative_b,\c!height=\v!broad] +\defineinteractionbar[c][\c!command=\scrn_bar_alternative_c,\c!height=\v!max,\c!depth=\v!max] +\defineinteractionbar[d][\c!command=\scrn_bar_alternative_d,\c!width=.5\emwidth] +\defineinteractionbar[e][\c!command=\scrn_bar_alternative_e] +\defineinteractionbar[f][\c!command=\scrn_bar_alternative_f] +\defineinteractionbar[g][\c!command=\scrn_bar_alternative_g,\c!height=\v!broad] + +\protect \endinput diff --git a/tex/context/base/mkxl/scrn-but.mklx b/tex/context/base/mkxl/scrn-but.mklx new file mode 100644 index 000000000..60073a6b7 --- /dev/null +++ b/tex/context/base/mkxl/scrn-but.mklx @@ -0,0 +1,1031 @@ +%D \module +%D [ file=scrn-but, % moved code +%D version=1995.01.01, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Interaction, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Screen Macros / Buttons} + +\registerctxluafile{scrn-but}{} + +%D This really needs testing in lmtx ... + +\unprotect + +%D Buttons are just what their names says: things that can be clicked (pushed) on. +%D They are similar to \type{\goto}, except that the text argument is not +%D interpreted. Furthermore one can apply anything to them that can be done with +%D \type {\framed}. +%D +%D \startbuffer +%D \button[width=3cm,height=1.5cm]{Exit}[ExitViewer] +%D \stopbuffer +%D +%D \typebuffer +%D +%D gives +%D +%D \getbuffer +%D +%D This command is formally specified as: +%D +%D \showsetup{button} +%D +%D The characteristics can be set with: +%D +%D \showsetup{setupbuttons} + +\installcorenamespace{button} +\installcorenamespace{buttonlocation} + +\installframedcommandhandler \??button {button} \??button + +\aliased\let\setupbuttons\setupbutton + +\appendtoks + \frozen\instance\setuevalue\currentbutton{\scrn_button_direct{\currentbutton}}% +\to \everydefinebutton + +\protected\def\scrn_button_direct#tag% + {\begingroup + \edef\currentbutton{#tag}% + \iflocation + \expandafter\scrn_button_direct_status + \else + \expandafter\scrn_button_direct_ignore + \fi} + +\def\scrn_button_direct_status + {\ifcstok{\buttonparameter\c!state}\v!start + \expandafter\scrn_button_direct_indeed + \else + \expandafter\scrn_button_direct_ignore + \fi} + +% empty=yes +% +% \button[settings]{}[action] % normally used at the tex end + +\tolerant\def\scrn_button_direct_indeed[#settings]#:#text[#action]% + {\setupcurrentbutton[#settings]% + % no \dontleavehmode as it will force a vbox to \hsize which then + % spoils a tight box + \hpack\bgroup + \scrn_button_make + \buttonparameter + \inheritedbuttonframed + \letbuttonparameter + \setbuttonparameter + {#text}% + {#action}% + \egroup + \endgroup} + +\tolerant\def\scrn_button_direct_ignore[#settings]#:#text[#destination]% + {\endgroup} + +\definebutton[button] % english + +\setupbuttons + [\c!state=\v!start, + \c!width=\v!fit, + \c!height=\v!broad, + \c!offset=0.25\emwidth, + \c!frame=\v!on, + \c!background=, + \c!backgroundcolor=, + \c!foregroundstyle=\buttonparameter\c!style, + \c!foregroundcolor=\buttonparameter\c!color, + \c!style=\interactionparameter\c!style, + \c!color=\interactionparameter\c!color, + \c!contrastcolor=\interactionparameter\c!contrastcolor, + \c!samepage=\v!yes, + \c!unknownreference=\v!yes, + \c!distance=\zeropoint] % for menubuttons + +%D \macros +%D {overlaybutton} +%D +%D For converience we provide: +%D +%D \starttyping +%D \overlaybutton[reference] +%D \stoptyping +%D +%D This command can be used to define overlays an/or can be used in the whatevertext +%D areas, like: +%D +%D \starttyping +%D \defineoverlay[PrevPage][\overlaybutton{PrevPage}] +%D \setupbackgrounds[page][background=PrevPage] +%D \setuptexttexts[\overlaybutton{NextPage}] +%D \stoptyping +%D +%D For practical reasons, this macro accepts square brackets as well as braces. + +\permanent\tolerant\protected\def\overlaybutton[#1]#;#=% + {\iflocation + \gotobox{\overlayfakebox}[#1]% + \fi} + +%D The renderers: + +\aliased\letcsname\??buttonlocation\v!yes \endcsname\zerocount +\aliased\letcsname\??buttonlocation\v!empty \endcsname\plusone +\aliased\letcsname\??buttonlocation\v!no \endcsname\plustwo +\aliased\letcsname\??buttonlocation\v!none \endcsname\plusthree +\aliased\letcsname\??buttonlocation\v!normal \endcsname\plusone % default +\aliased\letcsname\??buttonlocation\s!default\endcsname\plusone % default +\aliased\letcsname\??buttonlocation \endcsname\plusone % default + +\newconditional\c_scrn_button_skipped + +\def\scrn_button_make#currentparameter#inheritedframed#letparameter#setparameter#text#action% + {\begingroup + \c_attr_reference\attributeunsetvalue + \global\setfalse\c_scrn_button_skipped + \chardef\locationboxpagestate\csname\??buttonlocation#currentparameter\c!samepage\endcsname % ?? bt: todo + \doifelsereferencefound{#action}\scrn_button_make_yes\scrn_button_make_nop + #currentparameter% + #inheritedframed% + #letparameter% + #setparameter + {#text}% + \endgroup} + +\def\scrn_button_make_yes + {\scratchcounter\referencerealpage\relax % called in otr + \ifcase\scratchcounter + \expandafter\scrn_button_make_normal % no state : something else than a page reference + \orelse\ifnum\scratchcounter=\realpageno + \expandafter\scrn_button_make_yes_same + \else + \expandafter\scrn_button_make_yes_other + \fi} + +\def\scrn_button_make_yes_same + {\ifcase\locationboxpagestate\relax + \expandafter\scrn_button_make_contrast % same page: yes: same page or not ... todo + \or + \expandafter\scrn_button_make_empty % same page: empty but frame: no click + \or + \expandafter\scrn_button_make_nothing % same page: empty no frame: no + \else + \expandafter\scrn_button_make_skipped % same page: nothing at all + \fi} + +\def\scrn_button_make_yes_other + {\ifcase\locationboxpagestate\relax + \expandafter\scrn_button_make_normal % other page: yes: same page or not ... todo + \or + \expandafter\scrn_button_make_normal % other page: empty but frame: no click + \or + \expandafter\scrn_button_make_normal % other page: empty no frame: no + \else + \expandafter\scrn_button_make_skipped % other page: nothing at all + \fi} + +\def\scrn_button_make_nop + {\ifcase\locationboxpagestate\relax + \expandafter\scrn_button_make_framed + \or + \expandafter\scrn_button_make_empty + \or + \expandafter\scrn_button_make_nothing + \or + \expandafter\scrn_button_make_skipped + \fi} + +\def\scrn_button_make_framed#currentparameter#inheritedframed#letparameter#setparameter#text% + {#inheritedframed{\ignorespaces#text\removeunwantedspaces}} + +\def\scrn_button_make_skipped#currentparameter#inheritedframed#letparameter#setparameter#text% + {\global\settrue\c_scrn_button_skipped} + +\def\scrn_button_make_normal#currentparameter#inheritedframed#letparameter#setparameter#text% + {\clf_injectcurrentreference + \hbox attr \referenceattribute \lastreferenceattribute + {#inheritedframed{\ignorespaces#text\removeunwantedspaces}}} + +\def\scrn_button_make_contrast#currentparameter#inheritedframed#letparameter#setparameter#text% + {\clf_injectcurrentreference + \hbox attr \referenceattribute \lastreferenceattribute + {#setparameter\c!foregroundcolor{#currentparameter\c!contrastcolor}% + #inheritedframed{\ignorespaces#text\removeunwantedspaces}}} + +\def\scrn_button_make_empty#currentparameter#inheritedframed#letparameter#setparameter#text% + {#letparameter\c!empty\v!yes + #inheritedframed{\ignorespaces#text\removeunwantedspaces}} + +\def\scrn_button_make_nothing#currentparameter#inheritedframed#letparameter#setparameter#text% + {#letparameter\c!empty\v!yes + #letparameter\c!frame\empty + #letparameter\c!background\empty + #inheritedframed{\ignorespaces#text\removeunwantedspaces}} + +%D Menus: +%D +%D \starttyping +%D \setuppapersize +%D [S6][S6] +%D +%D \setuplayout +%D [backspace=6cm, cutspace=6cm, +%D leftedge=3cm, rightedge=3cm, +%D leftmargin=1cm, rightmargin=1cm, +%D margindistance=5mm, edgedistance=5mm, +%D topspace=4cm, bottomspace=4cm, +%D header=0pt, footer=0pt, +%D top=1cm, bottom=1cm, +%D topdistance=5mm, bottomdistance=5mm, +%D width=middle, height=middle] +%D +%D \setupinteraction +%D [state=start, +%D menu=on] +%D +%D \setupinteractionmenu +%D [right] +%D [state=start,background=color,frame=off,backgroundcolor=red,color=white,contrastcolor=blue] +%D \setupinteractionmenu +%D [left] +%D [state=start,background=color,frame=off,backgroundcolor=green,color=white] +%D \setupinteractionmenu +%D [top] +%D [state=start,background=color,frame=off,backgroundcolor=blue,color=white] +%D \setupinteractionmenu +%D [bottom] +%D [state=start,background=color,frame=off,backgroundcolor=yellow,color=white] +%D +%D \setupinteractionmenu +%D [left] +%D [state=local] +%D \setupinteractionmenu +%D [bottom] +%D [state=local] +%D +%D \startinteractionmenu[right] +%D \startbut [page(2)] Page 2 \stopbut +%D \startbut [page(1)] Page 1 \stopbut +%D \includemenu[left] +%D \includemenu[bottom] +%D \stopinteractionmenu +%D +%D \startinteractionmenu[left] +%D \startbut [page(1)] Page 1 \stopbut +%D \startbut [page(2)] Page 2 \stopbut +%D \stopinteractionmenu +%D +%D \startinteractionmenu[top] +%D \startbut [page(1)] Page 1 \stopbut +%D \startbut [page(2)] Page 2 \stopbut +%D \stopinteractionmenu +%D +%D \startinteractionmenu[bottom] +%D \startbut [page(2)] Page 2 \stopbut +%D \startbut [page(1)] Page 1 \stopbut +%D \stopinteractionmenu +%D \stoptyping +%D +%D \starttyping +%D \startinteractionmenu[rechts] +%D \startbut [eerste] eerste \stopbut +%D \starttxt hello world \stoptxt +%D \startbut [tweede] tweede \stopbut +%D \startnop \stopnop +%D \startbut [tweede] tweede \stopbut +%D \startrul whow \stoprul +%D \startbut [tweede] tweede \stopbut +%D \startraw hello world \stopraw +%D \startbut [tweede] tweede \stopbut +%D \startcom \vfill \stopcom +%D \startbut [derde] derde \stopbut +%D \stopinteractionmenu +%D \stoptyping +%D +%D \starttyping +%D \setupinteractionmenu[right][samepage=yes, unknownreference=yes] +%D \setupinteractionmenu[right][samepage=empty,unknownreference=empty] +%D \setupinteractionmenu[right][samepage=no, unknownreference=no] +%D \setupinteractionmenu[right][samepage=none, unknownreference=none] +%D \stoptyping + +\installcorenamespace{menu} +\installcorenamespace{menutoks} +\installcorenamespace{menustate} +\installcorenamespace{menupacker} +\installcorenamespace{menualign} + +\installframedcommandhandler \??menu {interactionmenu} \??menu + +\aliased\let\setupinteractionmenus\setupinteractionmenu + +\let\scrn_menu_action\relax + +\let\scrn_menu_define_original\defineinteractionmenu + +\pushoverloadmode + +\permanent\tolerant\protected\def\defineinteractionmenu[#tag]#spacer[#category]#spacer[#settings]% category reflects location, settings can be parent + {\ifarguments\or + \scrn_menu_define_original[#tag]% % root definition + \or + \ifhastok={#category}% + \scrn_menu_define_original[#tag][#category]% % root definition + \else + \scrn_menu_define_original[#tag][#category][\c!category=#category]% % child definition + \scrn_menu_register{#tag}{#category}% + \fi + \or + \ifhastok={#settings}% + \scrn_menu_define_original[#tag][#category][\c!category=#category,#settings]% child definition + \else + \scrn_menu_define_original[#tag][#settings][\c!category=#category]% % child definition + \fi + \scrn_menu_register{#tag}{#category}% + \fi} + +\popoverloadmode + +\def\scrn_menu_register#tag#category% + {\ifcsname\??menutoks#category\endcsname \else + \expandafter\newtoks \csname\??menutoks#category\endcsname + \expandafter\setfalse\csname\??menustate#category\endcsname + \fi + % \normalexpanded{\csname\??menutoks#category\endcsname{\the\csname\??menutoks#category\endcsname\scrn_menu_action{#tag}}}} + \toksapp\csname\??menutoks#category\endcsname{\scrn_menu_action{#tag}}} % needs testing + +\def\scrn_menu_actions#category% + {\the\csname\??menutoks#category\endcsname} + +%D Fill menus: + +\aliased\letcsname\e!stop\v!interactionmenu\endcsname\relax + +%normalexpanded{\permanent\defcsname\e!start\v!interactionmenu\endcsname[#tag]#content\expandafter\noexpand\csname\e!stop\v!interactionmenu\endcsname}% +% \normalexpanded{\permanent\expandafter\def\expandafter\noexpand\csname\e!start\v!interactionmenu\endcsname[#tag]#content\expandafter\noexpand\csname\e!stop\v!interactionmenu\endcsname}% +\normalexpanded{\permanent\expandafter\def\expandafter\noexpand\csname\e!start\v!interactionmenu\endcsname[#tag]#content\csname\e!stop\v!interactionmenu\endcsname}% + {\def\currentinteractionmenu{#tag}% + \expandafter\settrue\csname\??menustate\interactionmenuparameter\c!category\endcsname + \setinteractionmenuparameter\c!menu{#content}} + +\permanent\protected\def\resetinteractionmenu[#tag]% + {\def\currentinteractionmenu{#tag}% + \resetinteractionmenuparameter\c!menu} + +%D Placement of menus: +%D +%D The offset mechanism is not the same as in in \MKII. There we adapted +%D automatically to offsets in the text backgrounds. Here we have a bit more (but +%D manual) control. +%D +%D \starttyping +%D \setupbackgrounds +%D [text][text] +%D [background=color,backgroundcolor=gray,backgroundoffset=2mm] +%D +%D \setupbackgrounds +%D [text] +%D [rightedge,leftedge] +%D [background=color,backgroundcolor=gray] +%D +%D \setupbackgrounds +%D [top,bottom] +%D [text] +%D [background=color,backgroundcolor=gray] +%D +%D \setupinteractionmenu +%D [right] +%D [topoffset=0mm,bottomoffset=0mm] +%D +%D \setupinteractionmenu +%D [top] +%D [topoffset=2mm,bottomoffset=2mm,rightoffset=2mm,leftoffset=2mm] +%D \stoptyping +%D +%D The no longer hard coded text areas offset compensation makes tuning easier. +%D After all, menus need some setup anyway. The offsets are added to the width or +%D height (this is different from \MKII). + +\newbox \b_scrn_menu + +\newdimen\d_scrn_menu_next_distance +\newdimen\d_scrn_menu_final_width +\newdimen\d_scrn_menu_final_height +\newdimen\d_scrn_menu_used_width +\newdimen\d_scrn_menu_used_height +\newdimen\d_scrn_menu_asked_width +\newdimen\d_scrn_menu_asked_height +\newdimen\d_scrn_menu_offset_top +\newdimen\d_scrn_menu_offset_bottom +\newdimen\d_scrn_menu_offset_left +\newdimen\d_scrn_menu_offset_right + +\newconditional\c_scrn_menu_zerodimensions + +\def\scrn_menu_set_used + {\doassigncheckedframeoffset\d_scrn_menu_offset_left {\interactionmenuparameter\c!leftoffset }% + \doassigncheckedframeoffset\d_scrn_menu_offset_right {\interactionmenuparameter\c!rightoffset }% + \doassigncheckedframeoffset\d_scrn_menu_offset_top {\interactionmenuparameter\c!topoffset }% + \doassigncheckedframeoffset\d_scrn_menu_offset_bottom{\interactionmenuparameter\c!bottomoffset}% + \d_scrn_menu_asked_width \interactionmenuparameter\c!maxwidth + \d_scrn_menu_asked_height \interactionmenuparameter\c!maxheight + \d_scrn_menu_used_width\dimexpr + \d_scrn_menu_asked_width + \d_scrn_menu_offset_left + \d_scrn_menu_offset_right + \relax + \d_scrn_menu_used_height\dimexpr + \d_scrn_menu_asked_height + \d_scrn_menu_offset_top + \d_scrn_menu_offset_bottom + \relax} + +\def\scrn_menu_set_final + {\d_scrn_menu_final_width \namedinteractionmenuparameter\askedinteractionmenulocation\c!maxwidth + \d_scrn_menu_final_height\namedinteractionmenuparameter\askedinteractionmenulocation\c!maxheight} + +\def\scrn_menu_apply_final + {\ifconditional\c_scrn_menu_zerodimensions + \wd\b_scrn_menu\zeropoint + \ht\b_scrn_menu\zeropoint + \else + \wd\b_scrn_menu\d_scrn_menu_final_width + \ht\b_scrn_menu\d_scrn_menu_final_height + \fi + \dp\b_scrn_menu\zeropoint} + +\def\scrn_menu_apply_used + {\ifzeropt\d_scrn_menu_offset_left \else + \setbox\b_scrn_menu\hbox{\hskip-\d_scrn_menu_offset_left \box\b_scrn_menu}% + \fi + \ifzeropt\d_scrn_menu_offset_bottom \else + \setbox\b_scrn_menu\hbox{\lower \d_scrn_menu_offset_bottom \box\b_scrn_menu}% + \fi + \wd\b_scrn_menu\d_scrn_menu_asked_width + \ht\b_scrn_menu\d_scrn_menu_asked_height + \dp\b_scrn_menu\zeropoint} + +\setvalue{\??menualign\v!right }{\let\scrn_menu_left_align\raggedright} +\setvalue{\??menualign\v!left }{\let\scrn_menu_left_align\raggedleft} +\setvalue{\??menualign\v!flushright}{\let\scrn_menu_left_align\raggedleft} +\setvalue{\??menualign\v!flushleft }{\let\scrn_menu_left_align\raggedright} +\setvalue{\??menualign\v!middle }{\let\scrn_menu_left_align\raggedcenter} +\setvalue{\??menualign\v!low }{\let\scrn_menu_top_align\vss\let\scrn_menu_bottom_align\relax} +\setvalue{\??menualign\v!high }{\let\scrn_menu_top_align\relax\let\scrn_menu_bottom_align\vss} +\setvalue{\??menualign\v!lohi }{\let\scrn_menu_top_align\vss\let\scrn_menu_bottom_align\vss} + +\let\scrn_menu_left_align \relax +\let\scrn_menu_right_align \relax +\let\scrn_menu_top_align \relax +\let\scrn_menu_bottom_align\relax + +\def\scrn_menu_set_align + {\csname\??menualign\interactionmenuparameter\c!itemalign\endcsname} + +%D Hook into the pagebuilder (as less testing as possible): + +\def\scrn_menu_insert + {\iflocation + \expandafter\scrn_menu_insert_checked + \else + \expandafter\gobbleoneargument + \fi} + +\def\scrn_menu_insert_checked#location% + {\ifconditional\csname\??menustate#location\endcsname + \scrn_menu_insert_indeed{#location}% + \fi} + +\def\scrn_menu_insert_indeed#location% + {\begingroup + \xdef\askedinteractionmenulocation{#location}% + \scrn_menu_set_final + \ifcase\d_scrn_menu_final_width \orelse \ifcase\d_scrn_menu_final_height \else + \forgetall + \global\d_scrn_menu_next_distance\zeropoint + \let\scrn_menu_action\scrn_menu_package_indeed + \the\everysetmenucommands + \csname\??menupacker\namedinteractionmenuparameter\askedinteractionmenulocation\c!alternative\endcsname + \fi + \endgroup} + +%D This calls: % can be \c!command for vertical/horizontal + +\setvalue{\??menupacker\v!vertical}% all menus + {\let\scrn_menu_packager\scrn_menu_packager_vertical + \setbox\b_scrn_menu\hbox{\scrn_menu_actions\askedinteractionmenulocation}% + \scrn_menu_apply_final + \box\b_scrn_menu} + +\setvalue{\??menupacker\v!horizontal}% all menus + {\let\scrn_menu_packager\scrn_menu_packager_horizontal + \setbox\b_scrn_menu\vbox{\scrn_menu_actions\askedinteractionmenulocation}% + \scrn_menu_apply_final + \box\b_scrn_menu} + +% stop : skipped +% start: processed +% local: skipped but can be included +% empty: processed but invisible + +\protected\def\scrn_menu_package_indeed#tag% one menu + {\begingroup + \edef\currentinteractionmenu{#tag}% + \edef\currentinteractionmenustate{\interactionmenuparameter\c!state}% + \ifx\currentinteractionmenustate\v!start + \scrn_menu_packager + \orelse\ifx\currentinteractionmenustate\v!empty + \scrn_menu_packager + \fi + \endgroup} + +%D With the packager being one of: + +\let\currentinteractionmenudistance\!!zeropoint + +\def\scrn_menu_packager_vertical + {\scrn_menu_set_used + \hskip\d_scrn_menu_next_distance + \setbox\b_scrn_menu\hbox to \d_scrn_menu_used_width + {\ifx\currentinteractionmenustate\v!empty \else + \interactionmenuparameter\c!left + \scrn_menu_package_vertical{\directinteractionmenuparameter\c!menu}% + \interactionmenuparameter\c!right + \fi}% + \edef\currentinteractionmenudistance{\interactionmenuparameter\c!distance}% + \ifx\currentinteractionmenudistance\v!overlay + \global\d_scrn_menu_next_distance\zeropoint + \wd\b_scrn_menu\zeropoint + \else + \global\d_scrn_menu_next_distance\currentinteractionmenudistance + \scrn_menu_apply_used + \fi + \box\b_scrn_menu} + +\def\scrn_menu_packager_horizontal + {\scrn_menu_set_used + \vskip\d_scrn_menu_next_distance + \scrn_menu_set_align + \setbox\b_scrn_menu\vbox to \d_scrn_menu_used_height + {\ifx\currentinteractionmenustate\v!none \else + \scrn_menu_top_align + \interactionmenuparameter\c!before + \scrn_menu_package_horizontal{\directinteractionmenuparameter\c!menu}% + \interactionmenuparameter\c!after + \scrn_menu_bottom_align + \fi}% + \edef\currentinteractionmenudistance{\interactionmenuparameter\c!distance}% + \ifx\currentinteractionmenudistance\v!overlay + \global\d_scrn_menu_next_distance\zeropoint + \offinterlineskip + \dp\b_scrn_menu\zeropoint + \ht\b_scrn_menu\zeropoint + \else + \global\d_scrn_menu_next_distance\currentinteractionmenudistance + \scrn_menu_apply_used + \fi + \box\b_scrn_menu} + +%D For a right menu, a sequence of calls to \type {right_menu_button} is generated. +%D +%D \starttyping +%D right_menu_button (n, p, s=0/1/2, x, y, w, h, d) ; +%D \stoptyping +%D +%D Here, n is the number of the button, s a status variable, while the rest is +%D positional info. The status variable is 0, 1 or~2: not found, found and found but +%D current page. + +\newcount \c_scrn_menu_position +\newconstant \c_scrn_menu_page_mode % 0=notfound 1=found 2=currentpage +\newconditional\c_scrn_menu_positioning +\newtoks \t_scrn_menu_meta_data + +\def\scrn_menu_button_meta_template + {\askedinteractionmenulocation _menu_button(% + \number\c_scrn_menu_position,% + \number\c_scrn_menu_page_mode,% + \MPpos{\askedinteractionmenulocation:\number\c_scrn_menu_position}% + );} + +\permanent\def\MPmenubuttons#1{\the\t_scrn_menu_meta_data} + +\appendtoks + \global\t_scrn_menu_meta_data\emptytoks +\to \everyshipout + +\def\scrn_menu_whole_position % cannot happen in previous due to align + {\setbox\b_scrn_menu\hbox \bgroup + \hpos{menu:\askedinteractionmenulocation:\the\realpageno}{\box\b_scrn_menu}% + \egroup} + +% removed: \restorestandardblank (vspacing) ... should happen elsewhere + +\def\scrn_menu_package_vertical#content% + {\begingroup + \global\c_scrn_menu_position\zerocount + \def\scrn_menu_between_action_indeed{\interactionmenuparameter\c!inbetween}% + \doifelse{\interactionmenuparameter\c!position}\v!yes\settrue\setfalse\c_scrn_menu_positioning + \scrn_menu_set_align + \setbox\b_scrn_menu\vbox to \d_scrn_menu_used_height \bgroup + \hsize\d_scrn_menu_used_width + \scrn_menu_left_align + \interactionmenuparameter\c!before\relax + \ignorespaces#content\unskip + \interactionmenuparameter\c!after + \scrn_menu_right_align + \egroup + \ifconditional\c_scrn_menu_positioning + \scrn_menu_whole_position + \fi + \box\b_scrn_menu + \endgroup} + +\def\scrn_menu_package_horizontal#content% + {\begingroup + \global\c_scrn_menu_position\zerocount + \def\scrn_menu_between_action_indeed{\interactionmenuparameter\c!middle}% + \doifelse{\interactionmenuparameter\c!position}\v!yes\settrue\setfalse\c_scrn_menu_positioning + \setbox\b_scrn_menu\hbox to \d_scrn_menu_used_width \bgroup + \interactionmenuparameter\c!left\relax + \ignorespaces#content\unskip + \interactionmenuparameter\c!right + \egroup + \ifconditional\c_scrn_menu_positioning + \scrn_menu_whole_position + \fi + \box\b_scrn_menu + \endgroup} + +\def\scrn_menu_action_start + {\dontleavehmode + \begingroup} + +\def\scrn_menu_action_stop + {\ifconditional\c_scrn_button_skipped \else + \scrn_menu_between_action_indeed + \fi + \endgroup + \ignorespaces} + +\protected\def\scrn_menu_raw_start[#action]#text\stopraw + {\scrn_menu_action_start + \gotobox{\ignorespaces#text\unskip}[#action]% + \scrn_menu_action_stop} + +\protected\def\scrn_menu_but_start[#action]#text\stopbut + {\scrn_menu_action_start + \ifconditional\c_scrn_menu_positioning + \expandafter\scrn_button_make_position + \else + \expandafter\scrn_button_make + \fi + \interactionmenuparameter + \inheritedinteractionmenuframed + \letinteractionmenuparameter + \setinteractionmenuparameter + {#text}% + {#action}% + \scrn_menu_action_stop} + +\def\scrn_button_make_position#currentparameter#inheritedframed#letparameter#setparameter#text#action% + {\global\advance\c_scrn_menu_position\plusone + \doifelsereferencefound{#action}% 0=not found, 1=same page, >1=elsewhere + {\c_scrn_menu_page_mode\ifnum\currentreferencerealpage=\realpageno\plusone\else\plustwo\fi}% + {\c_scrn_menu_page_mode\plustwo}% + \xtoksapp\t_scrn_menu_meta_data{\scrn_menu_button_meta_template}% + \hpos + {\askedinteractionmenulocation:\number\c_scrn_menu_position}% + {\scrn_button_make + #currentparameter% + #inheritedframed% + #letparameter% + #setparameter% + {#text}% + {#action}}} + +\permanent\protected\def\scrn_menu_got_start[#action]#text\stopgot + {\scrn_menu_action_start + \letinteractionmenuparameter\c!frame\v!off + \letinteractionmenuparameter\c!background\empty + \scrn_button_make + \interactionmenuparameter + \inheritedinteractionmenuframed + \letinteractionmenuparameter + \setinteractionmenuparameter + {#text}% + {#action}% + \scrn_menu_action_stop} + +\permanent\protected\def\scrn_menu_nop_start#text\stopnop + {\scrn_menu_action_start + \letinteractionmenuparameter\c!frame\v!off + \letinteractionmenuparameter\c!background\empty + \letinteractionmenuparameter\c!empty\v!yes + \inheritedinteractionmenuframed{\ignorespaces#text\removeunwantedspaces}% + \scrn_menu_action_stop} + +\permanent\protected\def\scrn_menu_txt_start#text\stoptxt + {\scrn_menu_action_start + \letinteractionmenuparameter\c!frame\v!off + \letinteractionmenuparameter\c!background\empty + \inheritedinteractionmenuframed{\ignorespaces#text\removeunwantedspaces}% + \scrn_menu_action_stop} + +\permanent\protected\def\scrn_menu_rul_start#text\stoprul + {\scrn_menu_action_start + \inheritedinteractionmenuframed{\ignorespaces#text\removeunwantedspaces}% + \scrn_menu_action_stop} + +\permanent\protected\def\scrn_menu_com_start#text\stopcom + {\ignorespaces#text\removeunwantedspaces + \ignorespaces} + +\permanent\protected\def\scrn_menu_raw#content\\{\scrn_menu_raw_start#content\stopraw} \aliased\let\stopraw\relax +\permanent\protected\def\scrn_menu_but#content\\{\scrn_menu_but_start#content\stopbut} \aliased\let\stopbut\relax +\permanent\protected\def\scrn_menu_got#content\\{\scrn_menu_got_start#content\stopgot} \aliased\let\stopgot\relax +\permanent\protected\def\scrn_menu_nop#content\\{\scrn_menu_nop_start#content\stopnop} \aliased\let\stopnop\relax +\permanent\protected\def\scrn_menu_txt#content\\{\scrn_menu_txt_start#content\stoptxt} \aliased\let\stoptxt\relax +\permanent\protected\def\scrn_menu_rul#content\\{\scrn_menu_rul_start#content\stoprul} \aliased\let\stoprul\relax +\permanent\protected\def\scrn_menu_com#content\\{\scrn_menu_com_start#content\stopcom} \aliased\let\stopcom\relax + +\newtoks\everysetmenucommands % public + +\appendtoks + \enforced\let\raw\scrn_menu_raw \enforced\let\startraw\scrn_menu_raw_start \enforced\let\stopraw\relax + \enforced\let\but\scrn_menu_but \enforced\let\startbut\scrn_menu_but_start \enforced\let\stopbut\relax + \enforced\let\got\scrn_menu_got \enforced\let\startgot\scrn_menu_got_start \enforced\let\stopgot\relax + \enforced\let\nop\scrn_menu_nop \enforced\let\startnop\scrn_menu_nop_start \enforced\let\stopnop\relax + \enforced\let\txt\scrn_menu_txt \enforced\let\starttxt\scrn_menu_txt_start \enforced\let\stoptxt\relax + \enforced\let\rul\scrn_menu_rul \enforced\let\startrul\scrn_menu_rul_start \enforced\let\stoprul\relax + \enforced\let\com\scrn_menu_com \enforced\let\startcom\scrn_menu_com_start \enforced\let\stopcom\relax +\to \everysetmenucommands + +%D Sometimes handy: +%D +%D \starttyping +%D \setupinteractionmenu +%D [left] +%D [state=local] +%D +%D \startinteractionmenu[right] +%D ... +%D \includemenu[left] +%D ... +%D \stopinteractionmenu +%D \stoptyping + +\permanent\protected\def\includemenu[#tag]% + {\begingroup + \edef\currentinteractionmenu{#tag}% + \doif{\interactionmenuparameter\c!state}\v!local + {\letinteractionmenuparameter\c!state\v!start + \directinteractionmenuparameter\c!menu}% + \endgroup} + +%D Direct call (todo): + +\permanent\tolerant\protected\def\interactionmenu[#tag]#spacer[#settings]% + {\begingroup + \edef\currentinteractionmenu{#tag}% + \setupcurrentinteractionmenu[#settings]% + \scrn_menu_insert{#tag}% + \endgroup} + +%D Plugin handler: + +\protected\def\scrn_menu_insert_content_indeed + {\iflocation % here as we can have a fast turn-off + \expandafter\firstofoneargument + \else + \expandafter\gobbleoneargument + \fi} + +\let\scrn_menu_insert_content_ignore\gobbleoneargument + +\appendtoks + \doifelse{\interactionparameter\c!menu}\v!on + {\let\scrn_menu_insert_content\scrn_menu_insert_content_indeed}% + {\let\scrn_menu_insert_content\scrn_menu_insert_content_ignore}% +\to \everysetupinteraction + +%D Plugs into the page builder: + +\protected\def\scrn_menu_leftedge + {\hbox to \leftedgewidth \bgroup + \hsize\leftedgewidth + \settrue\c_scrn_menu_zerodimensions + \scrn_menu_insert\v!left + \egroup + \hskip-\leftedgewidth} + +\protected\def\scrn_menu_rightedge + {\hbox to \rightedgewidth \bgroup + \hsize\rightedgewidth + \settrue\c_scrn_menu_zerodimensions + \scrn_menu_insert\v!right + \egroup + \hskip-\rightedgewidth} + +\protected\def\scrn_menu_top + {\vbox to \topheight \bgroup + \vsize\topheight + \settrue\c_scrn_menu_zerodimensions + \scrn_menu_insert\v!top + \kern\zeropoint + \egroup + \vskip-\topheight} + +\protected\def\scrn_menu_bottom + {\vbox to \bottomheight \bgroup + \vsize\bottomheight + \settrue\c_scrn_menu_zerodimensions + \scrn_menu_insert\v!bottom + \kern\zeropoint + \egroup + \vskip-\bottomheight} + +\appendtoks \scrn_menu_insert_content\scrn_menu_leftedge \to \leftedgetextcontent +\appendtoks \scrn_menu_insert_content\scrn_menu_rightedge \to \rightedgetextcontent +\appendtoks \scrn_menu_insert_content\scrn_menu_top \to \toptextcontent +\appendtoks \scrn_menu_insert_content\scrn_menu_bottom \to \bottomtextcontent + +%D Initialization (root definitions, main builders): + +\defineinteractionmenu [\v!vertical] [\c!alternative=\v!vertical] +\defineinteractionmenu [\v!horizontal] [\c!alternative=\v!horizontal] + +%D Initialization (parent definitions, 4 area builders): + +\defineinteractionmenu [\v!right ] [\v!right ] [\v!vertical ] +\defineinteractionmenu [\v!left ] [\v!left ] [\v!vertical ] +\defineinteractionmenu [\v!top ] [\v!top ] [\v!horizontal] +\defineinteractionmenu [\v!bottom] [\v!bottom] [\v!horizontal] + +\setupinteraction + [\c!menu=\v!off] + +\setupinteractionmenu + [\c!offset=.25em, + \c!position=\v!no, + \c!frame=\v!on, + \c!maxwidth=\hsize, + \c!maxheight=\vsize, + \c!background=, + \c!backgroundcolor=, + \c!foregroundstyle=\interactionmenuparameter\c!style, + \c!foregroundcolor=\interactionmenuparameter\c!color, + \c!style=\interactionparameter\c!style, + \c!color=\interactionparameter\c!color, + \c!contrastcolor=\interactionparameter\c!contrastcolor, + \c!state=\v!start, + \c!samepage=\v!yes, + \c!unknownreference=\v!empty, + \c!distance=\bodyfontsize, + \c!topoffset=\zeropoint, + \c!bottomoffset=\zeropoint, + \c!leftoffset=\zeropoint, + \c!rightoffset=\zeropoint] + +\setupinteractionmenu + [\v!vertical] % not really a menu + [\c!inbetween=\blank, + \c!before=, + \c!after=\vfil, + %\c!width=\v!fit, + \c!height=\v!broad] + +\setupinteractionmenu + [\v!horizontal] % not really a menu + [\c!middle=\hfil, + %\c!left=\hss, + %\c!right=\hss, + \c!width=\v!fit, + \c!height=\v!broad] + +\setupinteractionmenu + [\v!left] + [\c!itemalign=\v!flushright, + \c!maxwidth=\leftedgewidth, + \c!maxheight=\makeupheight] + +\setupinteractionmenu + [\v!right] + [\c!itemalign=\v!flushleft, + \c!maxwidth=\rightedgewidth, + \c!maxheight=\makeupheight] + +\setupinteractionmenu + [\v!top] + [\c!itemalign=\v!high, + \c!maxwidth=\makeupwidth, + \c!maxheight=\topheight] + +\setupinteractionmenu + [\v!bottom] + [\c!itemalign=\v!low, + \c!maxwidth=\makeupwidth, + \c!maxheight=\bottomheight] + +%D Lists: + +\definelistalternative [\v!left ] [\c!renderingsetup=strc:lists:rendering:menu] +\definelistalternative [\v!right ] [\c!renderingsetup=strc:lists:rendering:menu] +\definelistalternative [\v!top ] [\c!renderingsetup=strc:lists:rendering:menu] +\definelistalternative [\v!bottom] [\c!renderingsetup=strc:lists:rendering:menu] + +\startsetups[strc:lists:rendering:menu] + \startbut[internal(\currentlistentrylocation)] + \limitatetext\currentlistentrytitle{\listparameter\c!maxwidth}\unknown + \stopbut +\stopsetups + +%D Sometimes handy: + +\def\scrn_button_direct_status + {\doifelse{\buttonparameter\c!state}\v!start + {\dosingleempty\scrn_button_direct_indeed}% + {\dosingleempty\scrn_button_direct_ignore}} + +\permanent\protected\def\menubutton % tag settings text action + {\iflocation + \expandafter\scrn_menu_menu_button_indeed + \else + \expandafter\scrn_menu_menu_button_ignore + \fi} + +\tolerant\def\scrn_menu_menu_button_indeed[#menutag]#spacer[#settings]#:#text[#action]% + {\ifcstok{\interactionmenuparameter\c!state}\v!start + \ifparameter#settings\or + \expandafter\scrn_menu_menu_button_a + \orelse\ifhastok={#menutag}% + \expandafter\scrn_menu_menu_button_b + \else + \expandafter\scrn_menu_menu_button_c + \fi{#menutag}{#settings}{#text}{#action}% + \fi} + +\tolerant\def\scrn_menu_menu_button_ignore[#menutag]#spacer[#settings]#:#text[#action]% + {} + +\def\scrn_menu_menu_button_a#tag#settings#text#action% + {\dontleavehmode \begingroup + \edef\currentinteractionmenu{#tag}% + \setupcurrentinteractionmenu[#settings]% + \scrn_button_make + \interactionmenuparameter + \inheritedinteractionmenuframed + \letinteractionmenuparameter + \setinteractionmenuparameter + {#text}% + {#action}% + \endgroup} + +\def\scrn_menu_menu_button_b#settings#dummy#text#action% + {\dontleavehmode \begingroup + \let\currentbutton\empty + \setupcurrentbutton[#settings]% + \scrn_button_make + \buttonparameter + \inheritedbuttonframed + \letbuttonparameter + \setbuttonparameter + {#text}% + {#action}% + \endgroup} + +\def\scrn_menu_menu_button_c#tag#dummy#text#action% + {\dontleavehmode \begingroup + \edef\currentinteractionmenu{#tag}% + \scrn_button_make + \interactionmenuparameter + \inheritedinteractionmenuframed + \letinteractionmenuparameter + \setinteractionmenuparameter + {#text}% + {#action}% + \endgroup} + +%D Untested: + +\permanent\tolerant\protected\def\registermenubuttons[#menu]#spacer[#register]% + {\begingroup + \ifparameter#register\or + \clf_registerbuttons{#menu}{#register}{\currentlanguage}% + \else + \clf_registerbuttons{}{#menu}{\currentlanguage}% + \fi + \removeunwantedspaces + \endgroup} + +\def\doregistermenubutton#1#2#3% used at lua end + {\ifcstok{\interactionmenuparameter\c!state}\v!start + \scrn_menu_menu_button_c{#1}{}{#2}{#3}% + \fi + \space} + +\protect \endinput diff --git a/tex/context/base/mkxl/scrn-fld.mklx b/tex/context/base/mkxl/scrn-fld.mklx new file mode 100644 index 000000000..fb249c01f --- /dev/null +++ b/tex/context/base/mkxl/scrn-fld.mklx @@ -0,0 +1,1013 @@ +%D \module +%D [ file=scrn-fld, +%D version=1997.05.18, +%D title=\CONTEXT\ Screen Macros, +%D subtitle=Fields, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D There is still some leftover code from mkii, where we need to be sparse with hash +%D entries and so have a somewhat complex setup mechanism. It doesn't pay off to +%D waste time on improving this because one never knows what happens with widgets +%D in \PDF; it has a history of dropping features like this. Also, the implementation +%D of fields fluctuates with versions. + +% interaction checking + +\writestatus{loading}{ConTeXt Screen Macros / Fields} + +\unprotect + +\registerctxluafile{scrn-fld}{} + +%D In \MKII\ we had to cheat a bit with setups in order not to run out of memory +%D with thousands of fields, which we happen to need at that time. In \MKIV\ we can +%D store some data at the \LUA\ end and use a somewhat slower but quite okay +%D inheritance mechanism. For this reason we now have split definitions, although +%D the old method is still somewhat supported. The clone and copy commands are +%D somewhat obsolete for several reasons: we can now use inheritance and autocloning +%D has been supported for a while. In most cases cloning (especially with check +%D boxes) the acrobat browser is not stable enough with respect to appearance +%D handling. +%D +%D A fieldcategory is nothing more than a collection of settings. +%D +%D \starttyping +%D \definefieldcategory +%D [all-email] +%D [height=1cm, +%D width=14cm, +%D style=sstf] +%D \stoptyping +%D +%D A definition can refer to this category: +%D +%D \starttyping +%D \definefieldbody [email] [type=line,category=all-email,default=pragma@xs4all.nl] +%D \stoptyping +%D +%D A copy of a field is made as follows: +%D +%D \starttyping +%D \definefieldbody [xmail] [email] +%D \stoptyping +%D +%D You can also be more specific: +%D +%D \starttyping +%D \definefieldbody[buttona][type=check,values={one,two}] +%D \definefieldbody[buttonb][type=check,values={three,four}] +%D \definefieldbody[buttonc][buttona][values={three,four}] +%D \stoptyping +%D +%D Actually typesetting a field happens this way: +%D +%D \starttyping +%D \fieldbody [Email] +%D \fieldbody [Email] [width=6cm] +%D \fieldbody [eMAIL] +%D \fieldbody [eMAIL] [width=7cm] +%D +%D \fieldbody [buttona] +%D \fieldbody [buttona] +%D \fieldbody [buttonb] +%D \fieldbody [buttonb] +%D \fieldbody [buttonc] +%D \fieldbody [buttonc] +%D \stoptyping +%D +%D So, you can call up a field many times and quite some parameters can be set. +%D +%D Because there are persistent problems with acrobat rendering associated +%D appearance streams (some messy /MK interferende) we also support native (built-in +%D dingbat) symbols: check, circle, cross, diamond, square and star. +%D +%D \starttyping +%D \definefield[test1][check] +%D \definefield[test2][check] +%D +%D \fieldbody[test1][width=1em,height=\strutht,depth=\strutdp,symbol=check] +%D \fieldbody[test1][width=1em,height=\strutht,depth=\strutdp,symbol=circle] +%D \fieldbody[test2][width=1em,height=\strutht,depth=\strutdp,symbol=square] +%D \stoptyping +%D +%D When submitting a form, we need to tell the driver module that we want \FDF\ or +%D \HTML. + +\installcorenamespace {forms} + +\installdirectcommandhandler \??forms {forms} + +\appendtoks + \clf_setformsmethod{\formsparameter\c!method}% +\to \everysetupforms + +\setupforms + [\c!method=XML] % no need for everyjob initialization as this is the default + +\appendtoks + \iflocation + \clf_exportformdata{\formsparameter\c!export}% + \fi +\to \everystoptext + +%D We need to initialize symbols in a special way so that they can be used as +%D rendering for a widget. + +\permanent\protected\def\presetfieldsymbols[#list]% slow + {\processcommacommand[#list]\scrn_symbols_preset} + +\def\scrn_symbols_preset#set% + {\processcommalist[#set]\scrn_symbols_preset_indeed}% + +\permanent\protected\def\scrn_symbols_preset_indeed#tag% + {\doifelseobjectfound{SYM}{#tag} + {} + {\settightobject{SYM}{#tag}\hbox{\symbol[#tag]}% % todo: set this as immediate xform + \page_otr_add_special_content{\hskip-\maxdimen\getobject{SYM}{#tag}}}} % and then force it into the file + +\aliased\let\dosetfieldsymbol\scrn_symbols_preset_indeed + +\permanent\def\dogetfieldsymbol#tag% + {\getobject{SYM}{#tag}} + +\permanent\protected\def\definedefaultsymbols % used ? + {\definesymbol[defaultyes][\mathematics{\times}]% + \definesymbol[defaultno] [\mathematics{\cdot }]} + +%D Now comes the real code: + +\installcorenamespace{fieldcategory} +\installcorenamespace{fieldbody} + +\installcommandhandler \??fieldcategory {fieldcategory} \??fieldcategory +\installcommandhandler \??fieldbody {fieldbody} \??fieldbody + +\newbox\b_scrn_field_body + +\setupfieldcategory + [\c!alternative=\v!normal, % normal clone copy + \c!type=\v!line, % line text ... + \c!width=5em, + \c!height=1em, + \c!depth=\zeropoint, + \c!align=\v!flushleft, + \c!option=\v!printable, % maybe we need a globaloptions and marge them + \c!n=1024] + +\def\scrn_field_check_category + {\edef\currentfieldbodycategory{\fieldbodyparameter\c!category}% + \ifempty\currentfieldbodycategory + \letfieldbodyparameter\s!parent\??fieldcategory + %\setevalue{\currentfieldbodyhash\s!parent}{\namedfieldcategoryhash\empty}% to WS: not hash ! + \else + \normalexpanded{\setfieldbodyparameter{\s!parent}{\??fieldcategory\currentfieldbodycategory}}% + %\setevalue{\currentfieldbodyhash\s!parent}{\namedfieldcategoryhash\currentfieldbodycategory}% to WS: not hash ! + \fi} + +\appendtoks % we cannot use parent .. maybe s!parent has to change + \ifempty\currentfieldbodyparent + \scrn_field_check_category + \clf_definefield + name {\currentfieldbody}% + alternative {normal}% + type {\fieldbodyparameter\c!type}% + category {\fieldbodyparameter\c!category}% + values {\fieldbodyparameter\c!values}% + default {\fieldbodyparameter\c!default}% + \relax + \else + \clf_clonefield + children {\currentfieldbody}% + alternative {clone}% + parent {\currentfieldbodyparent}% + category {\fieldbodyparameter\c!category}% + values {\fieldbodyparameter\c!values}% + default {\fieldbodyparameter\c!default}% + \relax + \fi +\to \everydefinefieldbody + +\permanent\tolerant\protected\def\fieldbody[#tag]#spacer[#settings]% + {\iflocation + \hbox\bgroup + \edef\currentfieldbody{#tag}% + \setupcurrentfieldbody[#settings]% + \scrn_field_body_typeset + \box\b_scrn_field_body + \egroup + \fi} + +\def\scrn_field_body_typeset % todo: fieldsymbol (checkfields /MK mess) + {\edef\currentfieldframecolor{\fieldbodyparameter\c!fieldframecolor}% + \ifempty\currentfieldframecolor\else + \getcolorattributevalue\currentfieldframecolor\currentfieldframecolorvalue + % == \edef\currentfieldframecolorvalue{\thecolorattribute\currentfieldframecolor}% + \fi + \edef\currentfieldbackgroundcolor{\fieldbodyparameter\c!fieldbackgroundcolor}% + \ifempty\currentfieldbackgroundcolor\else + \getcolorattributevalue\currentfieldbackgroundcolor\currentfieldbackgroundcolorvalue + % == \edef\currentfieldbackgroundcolorvalue{\thecolorattribute\currentfieldbackgroundcolor}% + \fi + \usefieldbodystyleandcolor\c!style\c!color + \clf_insertfield + {\currentfieldbody}% + {% + title {\currentfieldbody} + width \dimexpr\fieldbodyparameter\c!width \relax + height \dimexpr\fieldbodyparameter\c!height\relax + depth \dimexpr\fieldbodyparameter\c!depth \relax + align {\fieldbodyparameter\c!align}% + length {\fieldbodyparameter\c!n}% + fontstyle {\fontstyle}% + fontalternative {\fontalternative}% + fontsize {\fontbody}% + fontsymbol {\fieldbodyparameter\c!symbol}% + color {\fieldbodyparameter\c!color}% + colorvalue \c_attr_color + \ifempty\currentfieldbackgroundcolor \else + backgroundcolor {\currentfieldbackgroundcolor}% + backgroundcolorvalue \numexpr\currentfieldbackgroundcolorvalue\relax + \fi + \ifempty\currentfieldframecolor \else + framecolor {\currentfieldframecolor}% + framecolorvalue \numexpr\currentfieldframecolorvalue\relax + \fi + layer {\fieldbodyparameter\c!fieldlayer}% + option {\fieldbodyparameter\c!option}% + clickin {\fieldbodyparameter\c!clickin}% + clickout {\fieldbodyparameter\c!clickout}% + regionin {\fieldbodyparameter\c!regionin}% + regionout {\fieldbodyparameter\c!regionout}% + afterkey {\fieldbodyparameter\c!afterkey}% + format {\fieldbodyparameter\c!format}% + validate {\fieldbodyparameter\c!validate}% + calculate {\fieldbodyparameter\c!calculate}% + focusin {\fieldbodyparameter\c!focusin}% + focusout {\fieldbodyparameter\c!focusout}% + openpage {\fieldbodyparameter\c!openpage}% + closepage {\fieldbodyparameter\c!closepage}% + }% + \relax} + +%D The sets are used in grouped calculations. +%D +%D [name] [set] + +\permanent\tolerant\protected\def\definefieldbodyset[#tag]#spacer[#list]% + {\clf_definefieldset{#tag}{#list}} + +\aliased\let\dodefinefieldset\definefieldbodyset % compatibility + +%D A few testing macros (expandable for historic reasons): + +\permanent\def\doifelsefieldbody #tag{\clf_doifelsefield{#tag}} +\permanent\def\doifelsefieldcategory#tag{\clf_doifelsefieldcategory{#tag}} + +\aliased\let\doiffieldbodyelse \doifelsefieldbody +\aliased\let\doiffieldcategoryelse\doifelsefieldcategory + +\aliased\let\doiffieldelse \doifelsefieldbody % compatibility / will be dropped +\aliased\let\doifelsefield \doifelsefieldbody % compatibility / will be dropped + +%D We still support the traditional method of defining fields: +%D +%D \starttyping +%D \definefield [name] [type] [category] [values] [default] +%D +%D \definefield [WWWW] [text] [textsetup] [default text] +%D \definefield [XXXX] [push] [pushsetup] [yes,no] [yes] +%D \definefield [XXXX] [check] [checksetup] [yes,no] [yes] +%D \definefield [YYYY] [combo] [combosetup] [a,b,c,d] [b] +%D \definefield [ZZZZ] [radio] [radiosetup] [W,X,Y,Z] [Y] +%D +%D \definesubfield [W] [subsetup] [p,q] +%D \definesubfield [X,Y] [subsetup] [p,r] +%D \definesubfield [Z] [subsetup] [y,z] +%D +%D evt \definemainfield ... wanneer geplaatst voor subs gegeven +%D +%D \clonefield [XXXX] [XX,YY] [mysetup] [on,off] +%D \clonefield [Z] [AA,BB] [somesetup] [true,false] +%D \clonefield [Z] [CC,DD] [anothersetup] +%D +%D \copyfield [XXXX] [PP,QQ,RR] +%D \stoptyping +%D +%D Keep in mind that you can also use \type {\definefieldbody} to achieve the same. + +\permanent\tolerant\protected\def\definefield[#tag]#spacer[#type]#spacer[#category]#spacer[#values]#spacer[#default]% + {\definefieldbody[#tag][\c!type=#type,\c!category=#category,\c!values={#values},\c!default={#default}]} + +\permanent\tolerant\protected\def\definesubfield[#tag]#spacer[#category]#spacer[#values]% + {\definefieldbody[#tag][\c!type=sub,\c!category=#category,\c!values={#values}]} + +\permanent\tolerant\protected\def\clonefield[#parent]#spacer[#tag]#spacer[#category]#spacer[#values]% + {\definefieldbody[#tag][#parent][\c!category=#category,\c!values={#values}]} + +\permanent\tolerant\protected\def\copyfield[#parent]#spacer[#tag]% + {\definefieldbody[#tag][#parent]} + +\aliased\let\definemainfield\definefield % obsolete ! + +%D We hook fields into the (viewer based) layering mechanism +%D (implemented as properties). + +\appendtoks + \let\currentfieldcategory\empty + \doifelse{\interactionparameter\c!fieldlayer}\v!auto + {\setupcurrentfieldcategory[\c!fieldlayer=\currentviewerlayer]}% + {\setupcurrentfieldcategory[\c!fieldlayer=]}% +\to \everysetupinteraction + +\setupinteraction + [\c!fieldlayer=\v!auto] % auto by default + +%D The \type {\fieldbody} is the more bare one. One step further goes \type +%D {\fitfield}, in fact it (now) uses a dedicated instance of framed: \type +%D {fitfieldframed}. +%D +%D \starttyping +%D \ruledhbox{\fieldbody[Email][height=\strutht,depth=\strutdp,style=normal]} +%D \ruledhbox{\fitfield[Email][height=\strutht,depth=\strutdp,style=normal]} +%D \ruledhbox{\fitfield[buttona]} +%D \stoptyping + +\newbox\b_scrn_field_fit_symbol + +\defineframed + [fitfieldframed] + [\c!strut=\v!no, + \c!frame=off, + \c!offset=\v!overlay, + \c!align=] + +\permanent\tolerant\protected\def\fitfield[#tag]#spacer[#settings]% + {\iflocation + \begingroup + \edef\currentdefaultfieldvalue{\clf_getdefaultfieldvalue{#tag}}% + \setbox\b_scrn_field_fit_symbol\hbox{\symbol[\currentdefaultfieldvalue]}% + \fitfieldframed + {\fieldbody[#tag] + [\c!width=\wd\b_scrn_field_fit_symbol, + \c!height=\ht\b_scrn_field_fit_symbol, + \c!depth=\dp\b_scrn_field_fit_symbol, + #settings]}% + \endgroup + \fi} + +%D The traditional field command does some labeling and boxing: + +\installcorenamespace{fieldlabel} +\installcorenamespace{fieldcontent} +\installcorenamespace{fieldtotal} + +\installparameterhandler \??fieldlabel {fieldlabelframed} +\installparameterhandler \??fieldcontent {fieldcontentframed} +\installparameterhandler \??fieldtotal {fieldtotalframed} + +\installsetuphandler \??fieldlabel {fieldlabelframed} +\installsetuphandler \??fieldcontent {fieldcontentframed} +\installsetuphandler \??fieldtotal {fieldtotalframed} + +\installinheritedframed {fieldlabelframed} +\installinheritedframed {fieldcontentframed} +\installinheritedframed {fieldtotalframed} + +\setupfieldcontentframed + [\c!align=\v!flushleft, + \c!strut=\v!no, + \s!parent=\??regularframed] % needs checking + +\setupfieldcontentframed % independent + [\c!alternative=\v!normal, + \c!type=\v!line, + \c!width=5em, + \c!height=\lineheight, + \c!depth=\zeropoint, + \c!align=\v!flushleft, + \c!option=\v!printable, + \c!n=1024] + +\setupfieldlabelframed + [\c!style=, + \c!color=, + \c!align=\v!flushleft, + \s!parent=\??regularframed] % needs checking + +\setupfieldtotalframed + [%\c!alternative={\v!label,\v!frame,\v!horizontal}, + \c!strut=\v!no, + \c!align=, + \s!parent=\??regularframed] % needs checking + +% \setupcurrent + +\permanent\tolerant\protected\def\setupfield[#tag]#spacer[#variant]#spacer[#totalsettings]#spacer[#labelsettings]#spacer[#fieldsettings]% + {\ifarguments\or\or + \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#variant]% + \setupfieldtotalframed [#tag][\s!parent=\??fieldtotal]% + \setupfieldlabelframed [#tag][\s!parent=\??fieldlabel]% + \setupfieldcontentframed[#tag][\s!parent=\??fieldcontent,#variant]% + \or + \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#totalsettings]% + \setupfieldtotalframed [#tag][\s!parent=\??fieldtotal,\c!alternative={#variant}]% + \setupfieldlabelframed [#tag][\s!parent=\??fieldlabel]% + \setupfieldcontentframed[#tag][\s!parent=\??fieldcontent,#totalsettings]% + \or + \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#labelsettings]% + \setupfieldtotalframed [#tag][\s!parent=\??fieldtotal,\c!alternative={#variant},#totalsettings]% + \setupfieldlabelframed [#tag][\s!parent=\??fieldlabel]% + \setupfieldcontentframed[#tag][\s!parent=\??fieldcontent,#labelsettings]% + \or + \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#fieldsettings]% + \setupfieldtotalframed [#tag][\s!parent=\??fieldtotal,\c!alternative={#variant},#totalsettings]% + \setupfieldlabelframed [#tag][\s!parent=\??fieldlabel,#labelsettings]% + \setupfieldcontentframed[#tag][\s!parent=\??fieldcontent,#fieldsettings]% + \fi} + +\permanent\tolerant\protected\def\setupfields[#variant]#spacer[#totalsettings]#spacer[#labelsettings]#spacer[#fieldsettings]% + {\ifarguments\or + \setupfieldtotalframed [#variant]% + \or + \setupfieldtotalframed [#variant]% + \setupfieldcontentframed[#totalsettings]% + \or + \setupfieldtotalframed [#variant]% + \setupfieldlabelframed [#totalsettings]% + \setupfieldcontentframed[#labelsettings]% + \or + \setupfieldtotalframed [\c!alternative={#variant},#totalsettings]% + \setupfieldlabelframed [#labelsettings]% + \setupfieldcontentframed[#fieldsettings]% + \fi} + +% just to get the chain right for no category: + +\definefieldcategory [][\s!parent=\??fieldcontent] +%setupfieldtotalframed [][\s!parent=\??fieldtotal] +%setupfieldlabelframed [][\s!parent=\??fieldlabel] +%setupfieldcontentframed[][\s!parent=\??fieldcontent] + +% no longer supported: + +% \let\resetfields\relax + +\def\scrn_field_load_scripts{\useJSscripts[fld]\glet\scrn_field_load_scripts\relax} + +\newconditional\fieldlabelshown +\newconditional\fieldframeshown +\newconditional\fieldisvertical +\newconditional\fieldishorizontal + +\permanent\tolerant\protected\def\field[#tag]#spacer[#label]% can be sped up with \setupcurrentfieldtotalframed etc + {\iflocation + \dontleavehmode + \begingroup + \scrn_field_load_scripts + \edef\currentfieldbody {#tag}% + \edef\currentfieldlabel {#label}% + \edef\currentfieldcategory{\clf_getfieldcategory{#tag}}% + \ifempty\currentfieldlabel + \let\currentfieldlabel\currentfieldbody + \fi + \ifempty\currentfieldcategory + \setupfieldtotalframed [\currentfieldbody][\s!parent=\??fieldtotal]% + \setupfieldlabelframed [\currentfieldbody][\s!parent=\??fieldlabel]% + \setupfieldcontentframed[\currentfieldbody][\s!parent=\??fieldcontent]% + \definefieldcategory [\currentfieldbody]% + \setupfieldbody [\currentfieldbody][\c!category=\currentfieldbody]% + \let\currentfieldcategory\currentfieldbody + \fi + \let\currentfieldtotalframed \currentfieldcategory + \let\currentfieldlabelframed \currentfieldcategory + \let\currentfieldcontentframed\currentfieldcategory + \scrn_field_analyze_setups + \ifconditional\fieldframeshown + \inheritedfieldtotalframedframed % lower framedoffset + \bgroup + \else + \vbox + \bgroup + \fi + \dontcomplain + \ifconditional\fieldlabelshown + \scrn_field_set_label_box + \fi + \scrn_field_set_content_box + \ifconditional\fieldlabelshown + \ifconditional\fieldisvertical + \scrn_field_flush_vertical + \else + \scrn_field_flush_horizontal + \fi + \else + \scrn_field_flush_content + \fi + \egroup + \endgroup + \fi} + +% opties: veld, label, kader, vertikaal/horizontaal + +\newbox\b_scrn_field_label +\newbox\b_scrn_field_content + +% lower framedoffset + +\def\scrn_field_set_label_box + {\setbox\b_scrn_field_label\hbox + {\reshapeframeboxtrue % else wrong dimensions % still needed? + \inheritedfieldlabelframedframed{\currentfieldlabel}}} + +% \c!fieldoffset=-\framedoffset,\c!fieldbackgroundcolor=, +% \hbox{\lower\@@fdfieldoffset\hbox{\typesetfield}} + +\def\scrn_field_set_content_box + {\setbox\b_scrn_field_content\hbox + {\reshapeframeboxtrue % else wrong dimensions (to be checked) + \doifnothing{\fieldcontentframedparameter\c!height} + {\ifconditional\fieldisvertical + \setfieldcontentframedparameter\c!height{6ex}% + \orelse\ifconditional\fieldishorizontal + \setfieldcontentframedparameter\c!height{\vsize}% + \else + \setfieldcontentframedparameter\c!height{2cm}% + \fi}% + \doifnothing{\fieldcontentframedparameter\c!width} + {\ifconditional\fieldisvertical + \setfieldcontentframedparameter\c!width{\hsize}% + \orelse\ifconditional\fieldishorizontal + \setfieldcontentframedparameter\c!width{20em}% + \else + \setfieldcontentframedparameter\c!width{2cm}% + \fi}% + \inheritedfieldcontentframedframed % lower framedoffset + {\fieldbody + [\currentfieldbody] + [\c!width=\framedwidth,\c!height=\framedheight]}}} + + +\def\scrn_field_flush_vertical + {\vbox + {\copy\b_scrn_field_label + \fieldtotalframedparameter\c!inbetween + \copy\b_scrn_field_content}} + +\def\scrn_field_flush_horizontal + {\hbox + {\vbox \ifdim\ht\b_scrn_field_content>\ht\b_scrn_field_label to \ht\b_scrn_field_content \fi + {\fieldtotalframedparameter\c!before + \copy\b_scrn_field_label + \fieldtotalframedparameter\c!after}% + \hskip\fieldtotalframedparameter\c!distance + \vbox \ifdim\ht\b_scrn_field_label>\ht\b_scrn_field_content to \ht\b_scrn_field_label \fi + {\fieldtotalframedparameter\c!before + \box\b_scrn_field_content + \fieldtotalframedparameter\c!after}}} + +\def\scrn_field_flush_content + {\box\b_scrn_field_content} + +%D todo: replace \processallactionsinset + +\def\scrn_field_analyze_setups + {\setfalse\fieldlabelshown + \setfalse\fieldframeshown + \setfalse\fieldishorizontal + \setfalse\fieldisvertical + \normalexpanded{\processallactionsinset[\fieldtotalframedparameter\c!alternative]} + [ \v!reset=>\setfalse\fieldlabelshown + \setfalse\fieldframeshown + \setfalse\fieldishorizontal + \setfalse\fieldisvertical, + \v!label=>\settrue\fieldlabelshown, + \v!frame=>\settrue\fieldframeshown, + \v!horizontal=>\settrue\fieldishorizontal, + \v!vertical=>\settrue\fieldisvertical]% + \ifconditional\fieldisvertical + \setupfieldtotalframed[\c!distance=\zeropoint,\c!inbetween=\vskip\d_framed_local_offset,\c!align=\v!right,\c!width=20em]% + \orelse\ifconditional\fieldishorizontal + \setupfieldtotalframed[\c!distance=\d_framed_local_offset,\c!inbetween=,\c!align=\c!left,\c!height=10ex]% + \else + \setupfieldtotalframed[\c!distance=\zeropoint,\c!inbetween=,\c!align=\c!left]% + \fi + \setupfieldtotalframed[\c!n=,\c!before=,\c!after=\vss,\c!style=,\c!color=]} + +%D Common stuff (obsolete) + +\newcount\c_scrn_field_system_n + +\permanent\def\currentsystemfield{sys::\number\c_scrn_field_system_n} + +\permanent\protected\def\nextsystemfield + {\global\advance\c_scrn_field_system_n\plusone} + +%D \CONTEXT\ had tooltips right from the moment that it supported fields. Due to the +%D at that moment somewhat limited \PDF\ specification, they were implemented using +%D \JAVASCRIPT, but nowadays more kind of actions are supported, so we can do +%D without. The \MKIV\ version also supports definition of tooltips and +%D configuration. +%D +%D \starttyping +%D before \tooltip[right]{inbetween}{a very nice tip} after\par +%D before \tooltip[align=normal]{inbetween}{a very\\nice tip} after\par +%D before \tooltip[middle]{inbetween}{a very nice tip} after\par +%D before \tooltip[left]{inbetween}{a very nice tip} after\par +%D \stoptyping + +\newbox \b_scrn_tooltip_anchor +\newbox \b_scrn_tooltip_text +\newcount\c_scrn_tooltip_n + +\installcorenamespace{tooltip} + +\installframedcommandhandler \??tooltip {tooltip} \??tooltip + +\setuptooltip + [\c!location=\v!right, + \c!frame=\v!off, + \c!offset=.1ex, + \c!background=\v!color, + \c!backgroundcolor=gray] + +\appendtoks + \frozen\instance\setuevalue\currenttooltip{\scrn_tooltip_direct{\currenttooltip}}% +\to \everydefinetooltip + +\protected\def\scrn_tooltip_direct#tag% + {\def\currenttooltip{#tag}% + \iflocation + \expandafter\scrn_tooltip_indeed + \else + \expandafter\scrn_tooltip_ignore + \fi} + +\tolerant\def\scrn_tooltip_ignore[#settings]#:#anchortext#tiptext% + {#anchortext} + +\tolerant\def\scrn_tooltip_indeed[#settings]#:#anchortext#tiptext% a more modern aproach (push buttons) + {\dontleavehmode \hbox \bgroup + \dontcomplain + \global\advance\c_scrn_tooltip_n\plusone + \edef\currenttooltipname{tooltip:\number\c_scrn_tooltip_n}% + \setbox\b_scrn_tooltip_anchor\hbox + {\strut#anchortext}% + \doifelseassignment{#settings} + {\setupcurrenttooltip[#settings]}% + {\setupcurrenttooltip[\c!location=#settings]}% + \setbox\b_scrn_tooltip_text\hbox + {\lettooltipparameter\c!location\empty + \inheritedtooltipframed{#tiptext}}% + \definesymbol + [\currenttooltipname:txt] + [\copy\b_scrn_tooltip_text]% + \definefieldbody + [\currenttooltipname:txt] + [\c!type=push, + \c!width=\wd\b_scrn_tooltip_text, + \c!height=\ht\b_scrn_tooltip_text, + \c!depth=\dp\b_scrn_tooltip_text, + \c!option=\v!hidden, + \c!values=\currenttooltipname:txt]% + \setbox\b_scrn_tooltip_text\hbox + {\fieldbody[\currenttooltipname:txt]}% + \setbox\b_scrn_tooltip_text\hbox + {\strut\lower\dimexpr.25ex+\ht\b_scrn_tooltip_text\relax\box\b_scrn_tooltip_text}% + \edef\currenttooltiplocation{\tooltipparameter\c!location}% + \ifx\currenttooltiplocation\v!left + \hsmashed{\hskip\wd\b_scrn_tooltip_anchor\llap{\box\b_scrn_tooltip_text}}% + \orelse\ifx\currenttooltiplocation\v!middle + \hsmashed to \wd\b_scrn_tooltip_anchor{\hss\box\b_scrn_tooltip_text\hss}% + \else + \hsmashed{\box\b_scrn_tooltip_text}% + \fi + \definesymbol + [\currenttooltipname:but] + [\hphantom{\copy\b_scrn_tooltip_anchor}]% + \definefieldbody + [\currenttooltipname:but] + [\c!type=push, + \c!regionin=action(show{\currenttooltipname:txt}), + \c!regionout=action(hide{\currenttooltipname:txt}), + \c!width=\wd\b_scrn_tooltip_anchor, + \c!height=\ht\b_scrn_tooltip_anchor, + \c!depth=\dp\b_scrn_tooltip_anchor]% + \hsmashed{\fieldbody[\currenttooltipname:but]}% + \egroup + #anchortext}% when hyphenated the text wil stick out ... such are fields and we cannot use a link here + +\definetooltip[tooltip] + +%D From messages on the mailing list we can conclude that fieldstacks are used so we +%D keep them in the core: +%D +%D \starttyping +%D \definesymbol[one] [one] +%D \definesymbol[two] [two] +%D \definesymbol[three][three] +%D +%D \definefieldstack[mine][one,two,three] +%D \fieldstack[mine] +%D \fieldstack[mine] +%D +%D \goto{walk field}[Walk{mine}] +%D \stoptyping + +% todo: expand #symbols + +\installcorenamespace {fieldstack} + +\permanent\tolerant\protected\def\definefieldstack[#tag]#spacer[#symbols]#spacer[#settings]% + {\ifcsname\??fieldstack#tag\endcsname + % already done + \else + %setgvalue{\??fieldstack#tag}{\scrn_fieldstack_construct[#tag][#symbols][#settings]}% + \setxvalue{\??fieldstack#tag}{\scrn_fieldstack_construct[#tag][#symbols][\normalunexpanded{#settings}]}% + \fi} + +\permanent\tolerant\protected\def\fieldstack[#tag]#spacer[#symbols]#spacer[#settings]% + {\ifparameter#symbols\or + \scrn_fieldstack_define[#tag][#symbols][#settings]% + \fi + \csname\??fieldstack#tag\endcsname} + +\newbox\b_scrn_fieldstack_box + +\definesymbol[\s!empty][] + +\def\scrn_fieldstack_add#tag#settings#symbol% + {\advance\scratchcounter\plusone + \edef\currentfieldstackname{#tag:\number\scratchcounter}% + \ifnum\scratchcounter=\fieldcategoryparameter\c!start\relax + \definefieldbody[\currentfieldstackname][\c!type=check,\c!values={#symbol,\s!empty},\c!default={#symbol}]% + \else + \definefieldbody[\currentfieldstackname][\c!type=check,\c!values={#symbol,\s!empty},\c!default=\s!empty]% + \fi + \setbox\b_scrn_fieldstack_box\hbox{\symbol[#symbol]}% + \setcollector + [fieldstack] + {\fieldbody + [\currentfieldstackname] + [\c!option={\v!readonly}, + \c!width=\wd\b_scrn_fieldstack_box, + \c!height=\ht\b_scrn_fieldstack_box, + \c!depth=\dp\b_scrn_fieldstack_box, + #settings]}} + +\protected\def\scrn_fieldstack_construct[#tag][#symbols][#settings]% start=n, 0 == leeg + {\iflocation + \dontleavehmode + \begingroup + \setupfieldcategory[\c!start=1,#settings]% was just \??fieldcategory + \scrn_field_load_scripts + \definecollector + [fieldstack]% + [\c!corner=\v!middle, + \c!location=\v!middle]% + \scratchcounter\zerocount + \processcommalist[#symbols]{\scrn_fieldstack_add{#tag}{#settings}}% + \flushcollector[fieldstack]% + \endgroup + \fi} + +%D Another goodie. Two actions can be hookes into an overlay. +%D +%D \starttyping +%D \defineviewerlayer[test] +%D +%D \startviewerlayer[test]Hide Me\stopviewerlayer +%D +%D \defineoverlay +%D [WithTest] +%D [{\overlayrollbutton[HideLayer{test}][VideLayer{test}]}] +%D +%D \framed[background=WithTest]{toggle} +%D \stoptyping + +\newcount\c_scrn_rollbutton_n + +\permanent\tolerant\protected\def\overlayrollbutton[#1]#*[#2]#;#=#=% + {\iflocation + \bgroup + \global\advance\c_scrn_rollbutton_n_button\plusone + \global\advance\c_scrn_rollbutton_n_symbol\plusone + \definesymbol + [rollsymbol:\number\c_scrn_rollbutton_n_symbol] + [{\framed[\c!frame=\v!off,\c!width=\overlaywidth,\c!height=\overlayheight]{}}]% + % \definefieldbody + % [rollbutton:\number\c_scrn_rollbutton_n_button] + % [\c!type=push, + % \c!values=rollsymbol:\number\c_scrn_rollbutton_n_symbol, + % \c!default=rollsymbol:\number\c_scrn_rollbutton_n_symbol]% + % \fitfield + % [rollbutton:\number\c_scrn_rollbutton_n_button]% + % [\c!regionin={#regionin}, + % \c!regionout={#regionout}]% + % + \definefield + [rollbutton:\number\c_scrn_rollbutton_n_button][push][rollbutton] + [rollsymbol:\number\c_scrn_rollbutton_n_symbol]% + \fitfield + [rollbutton:\number\c_scrn_rollbutton_n_button]% + [\c!regionin={#1#3},\c!regionout={#2#4}]% + % + \egroup + \fi} + +% \protect \endinput % THE FOLLOWING CODE IS NOT CHECKED + +%D I will redo these when I need them. + +% \setupinteraction[state=start] +% +% \definepushbutton [reset] +% +% \startuniqueMPgraphic{whatever}{color} +% fill fullcircle xysized (OverlayWidth,OverlayHeight) withcolor \MPvar{color} ; +% \stopuniqueMPgraphic +% +% \definepushsymbol [reset] [n] [\uniqueMPgraphic{whatever}{color=red}] +% \definepushsymbol [reset] [r] [\uniqueMPgraphic{whatever}{color=green}] +% \definepushsymbol [reset] [d] [\uniqueMPgraphic{whatever}{color=blue}] +% +% \starttext +% \startTEXpage +% \pushbutton [reset] [page(2)] +% \stopTEXpage +% \startTEXpage +% \pushbutton [reset] [page(1)] +% \stopTEXpage +% \stoptext + +\newcount\c_scrn_pushbutton_n + +\permanent\tolerant\protected\def\definepushbutton[#tag]#spacer[#settings]% + {\scrn_pushbutton_define_variant{#tag}{n}{push}% + \scrn_pushbutton_define_variant{#tag}{r}{\symbol[pushsymbol:#tag:n]}% + \scrn_pushbutton_define_variant{#tag}{d}{\symbol[pushsymbol:#tag:r]}% + \setvalue{pushbutton:#tag}{\scrn_pushbutton_handle{#tag}{#settings}}} + +\def\scrn_pushbutton_define_variant#tag#variant#content% + {\doifelsesymboldefined{pushsymbol:#tag:#variant} + \donothing + {\definesymbol[pushsymbol:#tag:#variant][{#content}]}} + +\def\scrn_pushbutton_handle#tag#settings#reference% + {\bgroup + \global\advance\c_scrn_pushbutton_n\plusone + \setupfield + [pushbutton]% + [\c!frame=\v!overlay,% + \c!offset=\v!overlay,% + \c!clickout={#reference},% + #settings]% + \definefield + [pushbutton:\number\c_scrn_pushbutton_n]% + [push]% + [pushbutton]% + [pushsymbol:#tag:n,pushsymbol:#tag:r,pushsymbol:#tag:d]% + \fitfield + [pushbutton:\number\c_scrn_pushbutton_n]% + \egroup} + +\permanent\tolerant\protected\def\definepushsymbol[#tag]#spacer[#variant]% [#reference] + {\definesymbol[pushsymbol:#tag:#variant]} + +\permanent\tolerant\def\pushbutton[#tag]#spacer[#variant]% + {\executeifdefined{pushbutton:#tag}\gobbleoneargument{#variant}} + +%D We plug into the menu system + +\permanent\permanent\protected\def\scrn_menu_psh_start[#reference]#text\stoppsh + {\starttxt\pushbutton[\currentinteractionmenu][#reference]\stoptxt} + +\permanent\permanent\protected\def\scrn_menu_psh_direct[#reference]#text\\ + {\scrn_menu_psh_start[#reference]\stoprob} + +\aliased\let\stoppsh\relax + +\appendtoks + \enforced\let\startpsh\scrn_menu_psh_start + \enforced\let\stoppsh \relax + \enforced\let\psh \scrn_menu_psh_direct +\to \everysetmenucommands + +%D Another goodie: (unchecked in \MKIV) + +% calls: +% {..} [JS..] +% [left] {..} [JS..] +% [a=b] {..} [JS..] +% [left] [a=b] {..} [JS..] +% +% \setupbuttons[offset=0pt,frame=off] % alternative=hidden +% +% \rollbutton {Manuals} [JS(Goto_File{show-man.pdf})] +% \rollbutton {Articles} [JS(Goto_File{show-art.pdf})] +% \rollbutton {Papers} [JS(Goto_File{show-pap.pdf})] +% \rollbutton {Presentations} [JS(Goto_File{show-pre.pdf})] +% \rollbutton {Resources} [JS(Goto_File{show-res.pdf})] +% +% \rob [JS(...)] bla bla \\ + +% \definecolor[rollover:n][red] +% \definecolor[rollover:r][green] +% \definecolor[rollover:d][blue] + +\definepalet + [rollover] + [n=red, + r=green, + d=blue] + +\newcount\c_scrn_rollbutton_n_button +\newcount\c_scrn_rollbutton_n_symbol + +\permanent\def\lastrollbuttonindex{\the\c_scrn_rollbutton_n_button} + +\setupfield + [rollbutton] + [\c!frame=\v!off, + \c!offset=\v!overlay] + +\def\scrn_rollbutton_symbol_m + {\scrn_rollbutton_symbol_indeed + \interactionmenuparameter + \inheritedinteractionmenuframed + \setinteractionmenuparameter + \useinteractionmenustyleandcolor} + +\def\scrn_rollbutton_symbol_b + {\scrn_rollbutton_symbol_indeed + \buttonparameter + \inheritedbuttonframed + \setbuttonparameter + \usebuttonstyleandcolor} + +\permanent\tolerant\protected\def\rollbutton[#tag]#spacer[#settings]#:#text[#reference]% + {\dontleavehmode + \bgroup + \global\advance\c_scrn_rollbutton_n_button\plusone + \global\advance\c_scrn_rollbutton_n_symbol\plusone + \ifparameter#tag\or + \ifparameter#settings\or + \edef\currentinteractionmenu{#tag}% + \setupcurrentinteractionmenu[#settings]% + \let\scrn_rollbutton_symbol\scrn_rollbutton_symbol_m + \orelse\ifhastok={#tag}% + \let\currentbutton\empty + \setupcurrentbutton[#tag]% + \let\scrn_rollbutton_symbol\scrn_rollbutton_symbol_b + \else + \edef\currentinteractionmenu{#tag}% + \let\scrn_rollbutton_symbol\scrn_rollbutton_symbol_m + \fi + \else + \let\scrn_rollbutton_symbol\scrn_rollbutton_symbol_b + \fi + % todo: share symbols, tricky since different dimensions (maybe \unique...) + \definesymbol[rollsymbol:\number\c_scrn_rollbutton_n_symbol:n][\scrn_rollbutton_symbol{n}{#text}]% + \definesymbol[rollsymbol:\number\c_scrn_rollbutton_n_symbol:r][\scrn_rollbutton_symbol{r}{#text}]% + \definesymbol[rollsymbol:\number\c_scrn_rollbutton_n_symbol:d][\scrn_rollbutton_symbol{d}{#text}]% + \definefield + [rollbutton:\number\c_scrn_rollbutton_n_button][push][rollbutton] + [rollsymbol:\number\c_scrn_rollbutton_n_symbol:n,% + rollsymbol:\number\c_scrn_rollbutton_n_symbol:r,% + rollsymbol:\number\c_scrn_rollbutton_n_symbol:d]% + \fitfield + [rollbutton:\number\c_scrn_rollbutton_n_button]% + [\c!clickout={#reference}]% + \egroup} + +\protected\def\scrn_rollbutton_symbol_indeed#getparameter#inheritedframed#setparameter#usestyleandcolor#what#text% + {\definecolor[rollover][rollover:#what]% + \doifelse{#what}{n}% ? + {\doifelse{#getparameter\c!alternative}\v!hidden\phantom\hbox}\hbox + {#setparameter\c!framecolor {rollover}% + #setparameter\c!backgroundcolor{rollover}% + #setparameter\c!color {rollover}% + #inheritedframed{#usestyleandcolor\c!style\c!color{#text}}}} + +%D We plug into the menu system + +\permanent\protected\def\scrn_menu_rob_start[#reference]#text\stoprob + {\starttxt\rollbutton[\currentinteractionmenu]{\ignorespaces#text\unskip}[#reference]\stoptxt} + +\permanent\protected\def\scrn_menu_rob_direct[#reference]#text\\ + {\scrn_menu_rob_start[#reference]#text\stoprob} + +\aliased\let\stoprob\relax + +\appendtoks + \enforced\let\startrob\scrn_menu_rob_start + \enforced\let\stoprob \relax + \enforced\let\rob \scrn_menu_rob_direct +\to \everysetmenucommands + +\protect \endinput diff --git a/tex/context/base/mkxl/scrn-hlp.mklx b/tex/context/base/mkxl/scrn-hlp.mklx new file mode 100644 index 000000000..ad50486a3 --- /dev/null +++ b/tex/context/base/mkxl/scrn-hlp.mklx @@ -0,0 +1,162 @@ +%D \module +%D [ file=scrn-hlp, +%D version=1998.10.10, +%D title=\CONTEXT\ Screen Macros, +%D subtitle=Help (Experimental), +%D author={Hans Hagen \& Ton Otten}, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Screen Macros / Help popups} + +%D As this functionality was in the core and as I don't know how often it is used, +%D we'll keep it around. However, it is upgraded and usage has changed a bit. We +%D also use some \LUA\ magic in order to avoid multiple passes. + +\registerctxluafile{scrn-hlp}{} + +%D Using help boils down to plugging the placement macro someplace visible, like: +%D +%D \starttyping +%D \setuptexttexts[\centerbox{\placehelp}] +%D \stoptyping +%D +%D When this is done, the following should work out okay: +%D +%D \starttyping +%D test \helptext{word}{tip top 1 is somewhat longer} test +%D test \helptext{word}{tip top 2} test +%D +%D \starthelptext[oeps] +%D \input tufte +%D \stophelptext +%D +%D test test \showhelp{some help}[oeps] test +%D test test \button[location=depth]{\helpsignal{oeps}OEPS}[oeps] test +%D +%D test test \button[location=depth]{next}[page(2)] test +%D +%D \page +%D +%D test \helptext{word}{tip top one} test +%D test \helptext{word}{tip top two} test +%D \stoptyping +%D +%D Currently you need to use the signal in custom macros but that might change at +%D some point. + +\unprotect + +% also status + +\newbox \b_scrn_help_box +\newcount\c_scrn_help_n + +\definesystemattribute[help][public] + +\installcorenamespace{popuphelp} + +\installframedcommandhandler \??popuphelp {help} \??popuphelp + +\setuphelp + [\c!frame=\v!off, + \c!align=\v!normal, + \c!background=\v!color, + \c!backgroundcolor=gray] + +\appendtoks + \frozen\instance\setuevalue \currenthelp {\scrn_help_argument{\currenthelp}}% + \frozen\instance\setuevalue{\e!start\currenthelp}{\scrn_help_start {\currenthelp}}% + \frozen\instance\setuevalue{\e!stop \currenthelp}{\scrn_help_stop }% +\to \everydefinehelp + +\protected\def\scrn_help_argument#category% + {\def\currenthelp{#category}% + \global\advance\c_scrn_help_n\plusone + \edef\currenthelpname{help:\number\c_scrn_help_n}% + \doifelselocation + {\dosingleempty\scrn_help_argument_indeed} + {\dosingleempty\scrn_help_argument_ignore}} + +\def\scrn_help_argument_indeed[#reference]#text#target% + {\edef\currenthelpreference{#reference}% + \dontleavehmode \hbox \bgroup + \dontcomplain + \setbox\b_scrn_help_box\hbox{\strut#text}% + \scrn_help_register{#target}% + \egroup % can be usernode instead + \goto + {\helpsignal{\number\c_scrn_help_n}#target}% + [\helpaction{\number\c_scrn_help_n}]} + +\def\scrn_help_argument_ignore[#reference]#text#target% + {#target} + +\protected\def\scrn_help_start#category% + {\def\currenthelp{#category}% + \global\advance\c_scrn_help_n\plusone + \edef\currenthelpname{help:\number\c_scrn_help_n}% + \dosingleempty\scrn_help_start_indeed} + +\def\scrn_help_start_indeed[#reference]% + {\edef\currenthelpreference{#reference}% + \grabbufferdatadirect\currenthelp{\e!start\currenthelp}{\e!stop\currenthelp}} + +\protected\def\scrn_help_stop + {\iflocation + \scrn_help_register{\getbuffer[\currenthelp]}% + \fi} + +\def\scrn_help_register#text% + {\setbox\b_scrn_help_box\hbox{\inheritedhelpframed{#text}}% \hpack ? + \definesymbol + [\currenthelpname] + [\copy\b_scrn_help_box]% + \definefieldbody + [\currenthelpname] + [\c!type=push, + \c!width=\wd\b_scrn_help_box, + \c!height=\ht\b_scrn_help_box, + \c!depth=\dp\b_scrn_help_box, + \c!option=\v!hidden, + \c!clickin=action(hide{\currenthelpname}), + \c!closepage=action(hide{\currenthelpname}), + \c!values=\currenthelpname]% + \setbox\b_scrn_help_box\hbox + {\fieldbody[\currenthelpname]}% + \clf_registerhelp + number \c_scrn_help_n + name {\currenthelpreference}% + box \b_scrn_help_box + \relax} + +\permanent\protected\def\doifelsehelp + {\ifcase\c_scrn_help_n + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} + +\aliased\let\doifhelpelse\doifelsehelp + +\permanent\protected\def\placehelp % was \helpdata + {\ifinpagebody\ifcase\c_scrn_help_n\else + \clf_collecthelp\normalpagebox + \fi\fi} + +\permanent\def\helpreference#category{\clf_helpreference{#category}} % could be public implementors +\permanent\def\helpaction #category{\clf_helpaction {#category}} % could be public implementors + +\permanent\protected\def\helpsignal#category% + {\hbox attr \helpattribute \helpreference{#category}{}} + +\permanent\protected\def\showhelp#target[#category]% + {\goto{\helpsignal{#category}#target}[#category]} + +\definehelp[\v!helptext] + +\protect \endinput diff --git a/tex/context/base/mkiv/scrn-ini.mklx b/tex/context/base/mkxl/scrn-ini.mklx index 40b099cfc..aef9bb33e 100644 --- a/tex/context/base/mkiv/scrn-ini.mklx +++ b/tex/context/base/mkxl/scrn-ini.mklx @@ -39,12 +39,12 @@ \fi \to \everysetupinteraction -\protected\def\checkinteractionstate +\permanent\protected\def\checkinteractionstate {\doifelse{\interactionparameter\c!state}\v!start {\locationtrue \setsystemmode \v!interaction}% {\locationfalse \resetsystemmode\v!interaction}} -\def\doifelselocation % expandable +\permanent\def\doifelselocation % expandable {\iflocation \expandafter\firstoftwoarguments \else diff --git a/tex/context/base/mkiv/scrn-pag.mklx b/tex/context/base/mkxl/scrn-pag.mklx index ef3923f56..ef3923f56 100644 --- a/tex/context/base/mkiv/scrn-pag.mklx +++ b/tex/context/base/mkxl/scrn-pag.mklx diff --git a/tex/context/base/mkxl/scrn-ref.mklx b/tex/context/base/mkxl/scrn-ref.mklx new file mode 100644 index 000000000..df395e550 --- /dev/null +++ b/tex/context/base/mkxl/scrn-ref.mklx @@ -0,0 +1,102 @@ +%D \module +%D [ file=scrn-ref, +%D version=1998.01.15, +%D title=\CONTEXT\ Screen Macros, +%D subtitle=References, % moved code +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Screen Macros / References} + +\registerctxluafile{scrn-ref}{} + +\unprotect + +\appendtoks + \doifsomething{\interactionparameter\c!calculate}% + {\clf_setfieldcalculationset{\interactionparameter\c!calculate}}% + \doifelse{\interactionparameter\c!click }\v!yes + \settrue\setfalse\highlighthyperlinks + \doifelse{\interactionparameter\c!display}\v!new + \settrue\setfalse\gotonewwindow + \doifnot {\interactionparameter\c!page}\v!no + \scrn_reference_enable_page_destinations +\to \everysetupinteraction + +\def\scrn_reference_enable_page_destinations % no reset + {\clf_setreferencelinkmethod{\interactionparameter\c!page}} + +\setupinteraction % start fit page and reset form + [\c!page=\v!no, + \c!click=\v!yes, + \c!display=\v!normal, + \c!focus=\v!fit, + %\c!focusoffset=\zeropoint, % when tested with al views it will become 5\points + \c!focusoffset=5\points, + \c!calculate=, + % rendering: + \c!width=\emwidth, + \c!height=\zeropoint, + \c!depth=\zeropoint, + \c!symbolset=] + +% for now here, might become per link + +\appendtoks + \enabledirectives[destinations.offset=\the\dimexpr\interactionparameter\c!focusoffset\relax]% +\to \everysetupinteraction + +%D We have to make sure of some settings: + +\def\scrn_reference_set_text_actions + {\iflocation + \edef\currentinteractionopenaction {\interactionparameter\c!openaction }% + \edef\currentinteractioncloseaction{\interactionparameter\c!closeaction}% + \ifx\currentinteractionopenaction\empty \else + \clf_setopendocumentaction{\currentinteractionopenaction}% + \fi + \ifx\currentinteractioncloseaction\empty \else + \clf_setclosedocumentaction{\currentinteractioncloseaction}% + \fi + \glet\scrn_reference_set_text_actions\relax + \fi} + +\def\scrn_reference_set_page_actions + {\iflocation + \edef\currentinteractionopenpageaction {\interactionparameter\c!openpageaction }% + \edef\currentinteractionclosepageaction{\interactionparameter\c!closepageaction}% + \ifx\currentinteractionopenpageaction\empty \else + \clf_setopenpageaction{\currentinteractionopenpageaction}% + \fi + \ifx\currentinteractionclosepageaction\empty \else + \clf_setclosepageaction{\currentinteractionclosepageaction}% + \fi + \fi} + +\appendtoks \scrn_reference_set_text_actions \to \everyshipout +\appendtoks \scrn_reference_set_page_actions \to \everyshipout + +%D delayed ... + +% \def\scrn_reference_enable_references +% {\ifproductionrun +% \clf_enableinteraction % only once anyway +% \glet\scrn_reference_enable_references\relax +% \fi} +% +% \appendtoks +% \scrn_reference_enable_references +% \to \everysetupinteraction + +\setupinteraction % start fit page and reset form + [\c!openaction=, + \c!closeaction=, + \c!openpageaction=, + \c!closepageaction=] + +\protect \endinput diff --git a/tex/context/base/mkxl/scrn-wid.mklx b/tex/context/base/mkxl/scrn-wid.mklx new file mode 100644 index 000000000..40bf95cf5 --- /dev/null +++ b/tex/context/base/mkxl/scrn-wid.mklx @@ -0,0 +1,744 @@ +%D \module +%D [ file=scrn-int, +%D version=2011.02.27, % moved from scrn-int +%D title=\CONTEXT\ Core Macros, +%D subtitle=Widgets, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Interaction Macros / Widgets} + +\registerctxluafile{scrn-wid}{} + +% todo: expansion in comments (default is expanded) +% todo: check renderings ... acrobat crashes too easily on missing one + +\unprotect + +%D Attachments (mkiv upgraded): +%D +%D As usual in \CONTEXT\ we separate the general definition (frontend) +%D and the rendering (backend). + +% hack: x\footnote{x\inleftmargin[scope=local]{\attachment[location=high,file=i-context.pdf]}}x + +% old but stil valid method: +% +% \useattachment[test.tex] +% \useattachment[whatever][test.tex] +% \useattachment[whatever][newname][test.tex] +% \useattachment[whatever][title][newname][test.tex] +% +% new method: +% +% \registerattachment[sometag][specification] % name file author title subtitle +% +% \attachment[sometag][extra specs] +% \attachment[test.tex] +% \attachment[file=test.tex] +% \attachment[file=test.tex,method=hidden] +% \attachment[name=newname,file=test.tex] +% \attachment[title=mytitle,name=newname,file=test.tex] +% +% indirect +% +% \defineattachment[whatever5][file=test.tex] \attachment[whatever5][method=hidden] +% \defineattachment[whatever5][file=test.tex,method=hidden] \attachment[whatever5] +% +% direct (no definitions) +% +% \attachment[test][file=oeps.tex,title=Oeps,author=Hans,subtitle=TeX File,method=hidden] +% \attachment[label=test,file=oeps.tex,title=Oeps,author=Hans,subtitle=TeX File,method=hidden] +% +% autolabel: +% +% \attachment[file=oeps.tex,title=Oeps,author=Hans,subtitle=TeX File,method=hidden] +% +% % \setupattachments[\c!symbol={symbol-normal,symbol-down}] + +% startattachment -> temp file + +\newbox\b_scrn_attachment_collect +\newbox\b_scrn_attachment_link +\newbox\b_scrn_attachment_symbol + +\installcorenamespace{attachment} +\installcorenamespace{attachmentlocation} +\installcorenamespace{attachmentmethod} + +\installcommandhandler \??attachment {attachment} \??attachment + +\aliased\let\setupattachments\setupattachment % convenience and compatibility + +\setupattachment + [\c!state=\v!start, + \c!color=\interactionparameter\c!color, + %\c!textlayer=, + %\c!symbol=, + %\c!title=, + %\c!subtitle=, + %\c!file=, % input filename + %\c!name=, % new filename + %\c!author=, + %\c!method=, % \v!hidden = not in menu + %\c!buffer= + \c!symbol=, + \c!distance=\emwidth, + \c!width=\v!fit, + \c!height=\v!fit, + \c!depth=\v!fit, + \c!location=\v!high] + +\permanent\tolerant\protected\def\registerattachment[#tag]#spacer[#settings]% we save (globally) at the lua end + {\ifarguments\else + \begingroup + \def\currentattachment{_}% + \setupcurrentattachment[#settings,\s!parent=\??attachment]% + \clf_registerattachment + tag {#tag}% + registered {#tag}% + title {\attachmentparameter\c!title}% + subtitle {\attachmentparameter\c!subtitle}% + author {\attachmentparameter\c!author}% + file {\attachmentparameter\c!file}% + name {\attachmentparameter\c!name}% + buffer {\attachmentparameter\c!buffer}% + mimetype {\attachmentparameter\c!type}% + \relax + \endgroup + \fi} + +\appendtoks + \frozen\instance\setuevalue \currentattachment {\scrn_attachment_direct[\currentattachment]}% + \frozen\instance\setuevalue{\e!start\currentattachment}{\scrn_attachment_start [\currentattachment]}% + \frozen\instance\setuevalue{\e!stop \currentattachment}{\scrn_attachment_stop }% +\to \everydefineattachment + +\permanent\tolerant\protected\def\scrn_attachment_direct[#tag]#spacer[#registered]#spacer[#settings]% + {\iflocation + \bgroup + \edef\currentattachment{#tag}% + \ifcstok{\attachmentparameter\c!state}\v!start + \iftok{#registered}\emptytoks + \scrn_attachment_inject[\v!auto][]% + \orelse\ifhastok={#registered}% + \scrn_attachment_inject[\v!auto][#registered]% + \else + \scrn_attachment_inject[#registered][#settings]% + \fi + \fi + \egroup + \fi} + +\tolerant\protected\def\scrn_attachment_start[#tag]#spacer[#registered]#spacer[#settings]% + {\edef\currentattachment{#tag}% + \unless\iflocation + \expandafter\scrn_attachment_start_ignore + \orelse\ifcstok{\attachmentparameter\c!state}\v!start + \expandafter\scrn_attachment_start_indeed + \else + \expandafter\scrn_attachment_start_ignore + \fi[#registered][#settings]} + +\protected\def\scrn_attachment_stop + {} + +\def\scrn_attachment_start_indeed[#registered][#settings]% + {\bgroup + \doifelsenothing{#registered} + {\def\scrn_attachment_stop{\scrn_attachment_inject[\v!auto][\c!buffer=\v!attachment]\egroup}}% + {\doifelseassignment{#registered} + {\def\scrn_attachment_stop{\scrn_attachment_inject[\v!auto][\c!buffer=\v!attachment,#registered]\egroup}}% + {\def\scrn_attachment_stop{\scrn_attachment_inject[#registered][\c!buffer=\v!attachment,#settings]\egroup}}}% + \grabbufferdatadirect\v!attachment{\e!start\currentattachment}{\e!stop\currentattachment}} + +\def\scrn_attachment_start_ignore + {\expandafter\gobbleuntil\csname\e!stop\currentattachment\endcsname} + +\def\scrn_attachment_inject[#registered][#settings]% + {\edef\currentattachmentregistered{#registered}% + \setupattachment[\currentattachment][#settings]% + \expandnamespaceparameter\??attachmentmethod\attachmentparameter\c!method\v!normal} + +\setvalue{\??attachmentmethod\v!normal}% + {\edef\currentattachmentsymbol{\attachmentparameter\c!symbol}% + \edef\currentattachmentwidth {\attachmentparameter\c!width }% + \edef\currentattachmentheight{\attachmentparameter\c!height}% + \edef\currentattachmentdepth {\attachmentparameter\c!depth }% + \ifx\currentattachmentsymbol\empty + \ifx\currentattachmentwidth \v!fit\edef\currentattachmentwidth {.5\emwidth}\fi + \ifx\currentattachmentheight\v!fit\edef\currentattachmentheight{.5\emwidth}\fi + \ifx\currentattachmentdepth \v!fit\let \currentattachmentdepth \zeropoint\fi + \else + \clf_presetsymbollist{\attachmentparameter\c!symbol}% + % we cannot yet ask for the wd/ht/dp of an xform else we could use those + \setbox\b_scrn_attachment_symbol\hbox{\symbol[\lastpredefinedsymbol]}% + \ifx\currentattachmentwidth \v!fit\edef\currentattachmentwidth {\wd\b_scrn_attachment_symbol}\fi + \ifx\currentattachmentheight\v!fit\edef\currentattachmentheight{\ht\b_scrn_attachment_symbol}\fi + \ifx\currentattachmentdepth \v!fit\edef\currentattachmentdepth {\dp\b_scrn_attachment_symbol}\fi + \fi + \clf_insertattachment + tag {\currentattachment}% + registered {\currentattachmentregistered}% + width \dimexpr\currentattachmentwidth \relax + height \dimexpr\currentattachmentheight\relax + depth \dimexpr\currentattachmentdepth \relax + color {\attachmentparameter\c!color}% + colormodel \c_attr_colormodel + colorvalue \numexpr\thecolorattribute{\attachmentparameter\c!color}\relax % or are these chardefs + transparencyvalue \numexpr\thetransparencyattribute{\attachmentparameter\c!color}\relax % or are these chardefs + symbol {\currentattachmentsymbol}% + layer {\attachmentparameter\c!textlayer}% + % these will be overloaded by registered when available + title {\attachmentparameter\c!title}% + subtitle {\attachmentparameter\c!subtitle}% + author {\attachmentparameter\c!author}% + file {\attachmentparameter\c!file}% + name {\attachmentparameter\c!name}% + buffer {\attachmentparameter\c!buffer}% + mimetype {\attachmentparameter\c!type}% + \relax + \wd\b_scrn_attachment_link\currentattachmentwidth + \ht\b_scrn_attachment_link\currentattachmentheight + \dp\b_scrn_attachment_link\currentattachmentdepth + \expandnamespaceparameter\??attachmentlocation\attachmentparameter\c!location\s!unknown} + +\setvalue{\??attachmentmethod\v!hidden}% + {\clf_insertattachment + tag {\currentattachment}% + registered {\currentattachmentregistered}% + method {\v!hidden}% + title {\attachmentparameter\c!title}% + subtitle {\attachmentparameter\c!subtitle}% + author {\attachmentparameter\c!author}% + file {\attachmentparameter\c!file}% + name {\attachmentparameter\c!name}% + buffer {\attachmentparameter\c!buffer}% + mimetype {\attachmentparameter\c!type}% + \relax} + +\protected\def\scrn_attachment_flush_traced + {\hpack\bgroup + \blackrule % can be a fast one + [ \c!color=trace:r, + \c!width=\wd\b_scrn_attachment_link, + \c!height=\ht\b_scrn_attachment_link, + \c!depth=\dp\b_scrn_attachment_link]% + \kern-\wd\b_scrn_attachment_link + \box\b_scrn_attachment_link + \egroup} + +\protected\def\scrn_attachment_flush_normal + {\box\b_scrn_attachment_link} + +\installtextracker + {attachments.anchors} + {\let\scrn_attachment_flush\scrn_attachment_flush_traced} + {\let\scrn_attachment_flush\scrn_attachment_flush_normal} + +\let\scrn_attachment_flush\scrn_attachment_flush_normal + +\setvalue{\??attachmentlocation\v!inmargin }{\inmargin {\scrn_attachment_flush}} +\setvalue{\??attachmentlocation\v!leftedge }{\inleftedge {\scrn_attachment_flush}} +\setvalue{\??attachmentlocation\v!rightedge }{\inrightedge {\scrn_attachment_flush}} +\setvalue{\??attachmentlocation\v!leftmargin }{\inleftmargin {\scrn_attachment_flush}} +\setvalue{\??attachmentlocation\v!rightmargin}{\inrightmargin{\scrn_attachment_flush}} +\setvalue{\??attachmentlocation\v!high }{\high {\scrn_attachment_flush}} + +\setvalue{\??attachmentlocation\v!none}% + {\global\setbox\b_scrn_attachment_collect\hbox\bgroup + \ifvoid\b_scrn_attachment_collect\else + \box\b_scrn_attachment_collect + \hskip\attachmentparameter\c!distance\relax + \fi + \scrn_attachment_flush + \egroup} + +\setvalue{\??attachmentlocation\s!unknown}% + {\ifvoid\b_scrn_attachment_collect\else + \box\b_scrn_attachment_collect + \fi} + +\permanent\protected\def\placeattachments + {\ifvoid\b_scrn_attachment_collect\else + \box\b_scrn_attachment_collect + \fi} + +\defineattachment[attachment] + +% \ifx\currentinterface\defaultinterface \else +% \defineattachment[\v!attachment] +% \fi + +% backward compatible: + +\permanent\tolerant\protected\def\useattachment[#tag]#spacer[#title]#spacer[#name]#spacer[#file]% + {\ifarguments\or + \registerattachment[#tag][title=#tag,name=#tag,file=#tag]% + \or + \registerattachment[#tag][title=#title,name=#title,file=#title]% + \or + \registerattachment[#tag][title=#title,name=#title,file=#name]% + \or + \registerattachment[#tag][title=#title,name=#name,file=#file]% + \fi} + +%D Comments: + +% test +% +% \startcomment +% hello beautiful\\world +% \stopcomment +% +% test +% +% \startcomment[hello] +% hello << eerste >> +% beautiful +% world +% \stopcomment +% +% test +% +% \startcomment[hello][color=green,width=10cm,height=3cm] +% hello +% beautiful +% world +% \stopcomment +% +% test +% +% \startcomment[hello][color=red,width=4cm,height=3cm] +% hello +% +% beautiful +% +% world +% \stopcomment +% +% test +% +% \startcomment[symbol=Help] +% Do we want this kind of rubish? +% \stopcomment +% +% test +% +% \definesymbol [comment-normal][{\externalfigure[cow.pdf]}] +% \definesymbol [comment-down] [{\externalfigure[cow.pdf]}] +% +% \def\CowSymbol#1#2% +% {\scale +% [\c!height=#1] +% {\startMPcode +% loadfigure "koe.mp" number 1 ; +% refill currentpicture withcolor #2 ; +% \stopMPcode}} +% +% \definesymbol [comment-normal] +% [\CowSymbol{4ex}{red}] +% +% \definesymbol [comment-down] +% [\CowSymbol{4ex}{green}] +% +% \setupcomment +% [\c!symbol={comment-normal,comment-down}, +% \c!option=\v!buffer] +% +% \startcomment[hello] +% oeps +% \stopcomment +% +% test +% +% \setupcomment +% [\c!symbol=normal, +% \c!option=max,width=10cm] +% +% \startcomment[hello] +% oeps +% \stopcomment +% +% test + +%D The implementation is mostly the same as for attachments but sharing code +%D will not make it cleaner. + +\installcorenamespace{comment} +\installcorenamespace{commentlocation} + +\installcommandhandler \??comment {comment} \??comment + +\newbox\b_scrn_comment_collect +\newbox\b_scrn_comment_rendering +\newbox\b_scrn_comment_link +\newbox\b_scrn_comment_symbol + +\setupcomment + [\c!state=\v!start, + \c!distance=\emwidth, + \c!color=\interactionparameter\c!color, + \c!space=\v!no, + \c!symbol=, + %\c!title=, + %\c!option=, + %\c!textlayer=, + \c!width=\v!fit, + \c!height=\v!fit, + \c!depth=\v!fit, + \c!nx=40, + \c!ny=10, + \c!buffer=\v!comment, + \c!location=\v!high] + +\appendtoks + \frozen\instance\setuevalue \currentcomment {\scrn_comment_argument[\currentcomment]}% + \frozen\instance\setuevalue{\e!start\currentcomment}{\scrn_comment_start [\currentcomment]}% + \frozen\instance\setuevalue{\e!stop \currentcomment}{\scrn_comment_stop }% +\to \everydefinecomment + +\tolerant\protected\def\scrn_comment_argument[#category]#spacer[#title]#spacer[#settings]#:#text%% + {\iflocation + \def\currentcomment{#category}% + \ifcstok{\commentparameter\c!state}\v!start + \ifhastok={#title} + \setupcurrentcomment[#title]% + \else + \setupcurrentcomment[\c!title=#title,#settings]% + \fi + \clf_assignbuffer{\v!comment}{#text}\catcodetable\relax% todo: expansion control, but expanded by default (xml) + \scrn_comment_inject + \fi + \fi + \ignorespaces} + +\tolerant\protected\def\scrn_comment_start[#category]#spacer[#title]#spacer[#settings]% + {\def\currentcomment{#category}% + \unless\iflocation + \expandafter\scrn_comment_start_ignore + \orelse\ifcstok{\commentparameter\c!state}\v!start + \expandafter\scrn_comment_start_indeed + \else + \expandafter\scrn_comment_start_ignore + \fi[#title][#settings]} + +\def\scrn_comment_start_indeed[#title][#settings]% + {\bgroup + \doifelseassignment{#title} + {\setupcurrentcomment[#title]} + {\setupcurrentcomment[\c!title=#title,#settings]}% + \protected\def\scrn_comment_stop{\scrn_comment_inject\egroup}% + \grabbufferdatadirect\v!comment{\e!start\currentcomment}{\e!stop\currentcomment}} + +\def\scrn_comment_start_ignore + {\expandafter\gobbleuntil\csname\e!stop\currentcomment\endcsname} + +\protected\def\scrn_comment_stop + {} + +\installcorenamespace{commentmethods} + +\protected\def\scrn_comment_inject + {\expandnamespaceparameter\??commentmethods\commentparameter\c!method\v!normal} + +%D Beware: comments symbols don't scale in acrobat (cf. spec but somewhat +%D weird, esp because for instance attachment symbols do scale). + +\setvalue{\??commentmethods\v!normal}% + {\edef\currentcommentsymbol{\commentparameter\c!symbol}% + \edef\currentcommentwidth {\commentparameter\c!width }% + \edef\currentcommentheight{\commentparameter\c!height}% + \edef\currentcommentdepth {\commentparameter\c!depth }% + \ifempty\currentcommentsymbol + \ifx\currentcommentwidth \v!fit\edef\currentcommentwidth {.5\emwidth}\fi + \ifx\currentcommentheight\v!fit\edef\currentcommentheight{.5\emwidth}\fi + \ifx\currentcommentdepth \v!fit\let \currentcommentdepth \zeropoint\fi + \else + \clf_presetsymbollist{\commentparameter\c!symbol}% + % we cannot yet ask for the wd/ht/dp of an xform else we could use those + \setbox\b_scrn_comment_symbol\hbox{\symbol[\lastpredefinedsymbol]}% + \ifx\currentcommentwidth \v!fit\edef\currentcommentwidth {\wd\b_scrn_comment_symbol}\fi + \ifx\currentcommentheight\v!fit\edef\currentcommentheight{\ht\b_scrn_comment_symbol}\fi + \ifx\currentcommentdepth \v!fit\edef\currentcommentdepth {\dp\b_scrn_comment_symbol}\fi + \fi + \clf_insertcomment + tag {\currentcomment}% + title {\commentparameter\c!title}% + subtitle {\commentparameter\c!subtitle}% + author {\commentparameter\c!author}% + width \dimexpr\currentcommentwidth\relax + height \dimexpr\currentcommentheight\relax + depth \dimexpr\currentcommentdepth\relax + nx {\commentparameter\c!nx}% + ny {\commentparameter\c!ny}% + colormodel \c_attr_colormodel + colorvalue \numexpr\thecolorattribute{\commentparameter\c!color}\relax + transparencyvalue \numexpr\thetransparencyattribute{\commentparameter\c!color}\relax + option {\commentparameter\c!option}% % todo + symbol {\commentparameter\c!symbol}% + buffer {\commentparameter\c!buffer}% {\v!comment}% + layer {\commentparameter\c!textlayer}% + space {\commentparameter\c!space}% + \relax + \wd\b_scrn_comment_link\currentcommentwidth + \ht\b_scrn_comment_link\currentcommentheight + \dp\b_scrn_comment_link\currentcommentdepth + \expandnamespaceparameter\??commentlocation\commentparameter\c!location\s!unknown} + +\letvalue{\??commentmethods\v!hidden}\donothing + +\protected\def\scrn_comment_flush_traced + {\hpack\bgroup + \blackrule % can be a fast one + [ \c!color=trace:y, + \c!width=\wd\b_scrn_comment_link, + \c!height=\ht\b_scrn_comment_link, + \c!depth=\dp\b_scrn_comment_link]% + \kern-\wd\b_scrn_comment_link + \box\b_scrn_comment_link + \egroup} + +\protected\def\scrn_comment_flush_normal + {\box\b_scrn_comment_link} + +\installtextracker + {comments.anchors} + {\let\scrn_comment_flush\scrn_comment_flush_traced} + {\let\scrn_comment_flush\scrn_comment_flush_normal} + +\let\scrn_comment_flush\scrn_comment_flush_normal + +% todo: dedicated margin classes + +\setvalue{\??commentlocation\v!inmargin }{\inmargin {\scrn_comment_flush}} +\setvalue{\??commentlocation\v!leftedge }{\inleftedge {\scrn_comment_flush}} +\setvalue{\??commentlocation\v!rightedge }{\inrightedge {\scrn_comment_flush}} +\setvalue{\??commentlocation\v!leftmargin }{\inleftmargin {\scrn_comment_flush}} +\setvalue{\??commentlocation\v!rightmargin}{\inrightmargin{\scrn_comment_flush}} +\setvalue{\??commentlocation\v!high }{\high {\scrn_comment_flush}} + +\setvalue{\??commentlocation\v!none}% + {\global\setbox\b_scrn_comment_collect\hbox\bgroup + \ifvoid\b_scrn_comment_collect\else + \box\b_scrn_comment_collect + \hskip\commentparameter\c!distance\relax + \fi + \scrn_comment_flush + \egroup} + +\setvalue{\??commentlocation\s!unknown}% + {\ifvoid\b_scrn_comment_collect\else + \box\b_scrn_comment_collect + \fi} + +\permanent\protected\def\placecomments + {\ifvoid\b_scrn_comment_collect\else + \box\b_scrn_comment_collect + \fi} + +\definecomment[comment] + +% \ifx\currentinterface\defaultinterface \else +% \definecomment[\v!comment] +% \fi + +%D Soundclips: +%D +%D Defining sound tracks: +%D +%D \starttyping +%D \useexternalsoundtrack[label][file] +%D \stoptyping +%D +%D associated actions: StartSound StopSound PauseSound ResumeSound +%D +%D Todo: like external figures, also search on path, +%D although, they need to be present ar viewing time, so ... + +\installcorenamespace{externalsoundtracks} + +\installsetuponlycommandhandler \??externalsoundtracks {externalsoundtracks} + +\setupexternalsoundtracks + [\c!option=] + +\permanent\tolerant\protected\def\useexternalsoundtrack[#tag]#spacer[#filename]% + {\clf_registersoundclip + tag {#tag}% + file {#filename}% + \relax} + +\permanent\def\checksoundtrack#tag% yet untested in mkiv (also move management to lua) + {\iflocation + \clf_insertsoundclip + tag {#tag}% + repeat {\directexternalsoundtracksparameter\c!option}% + \relax + \fi} + +%D Renderings (not yet tested in mkvi): + +% Todo: multiple instances and inheritance .. will be done when needed i.e. when I +% see usage. Probaly by that time this feature is dropped (as are other media +% rel;ated ones). + +\let\currentrendering\empty + +\definereference[StartCurrentRendering] [\v!StartRendering {\currentrendering}] +\definereference[StopCurrentRendering] [\v!StopRendering {\currentrendering}] +\definereference[PauseCurrentRendering] [\v!PauseRendering {\currentrendering}] +\definereference[ResumeCurrentRendering][\v!ResumeRendering{\currentrendering}] + +\permanent\tolerant\protected\def\useexternalrendering[#tag]#spacer[#mime]#spacer[#file]#spacer[#option]% + {\clf_registerrendering + type {external}% + label {#tag}% + mime {#mime}% + filename {#file}% + option {#option}% + \relax} + +\permanent\tolerant\protected\def\setinternalrendering[#tag]#spacer[#option]% {content} % crappy + {\bgroup + \dowithnextbox + {\clf_registerrendering + type {internal}% + label {#tag}% + mime {IRO}% brrr + filename {#tag}% + option {#option}% + \relax + \let\objectoffset\zeropoint + \setobject{IRO}{#tag}\hpack{\box\nextbox}% + \egroup}% + \hbox} + +\permanent\def\renderingtype #tag{\clf_renderingvar{#tag}{type}} +\permanent\def\renderingoption#tag{\clf_renderingvar{#tag}{option}} + +\newdimen\d_scrn_rendering_width \d_scrn_rendering_width 8cm +\newdimen\d_scrn_rendering_height \d_scrn_rendering_height 6cm + +\let\m_scrn_rendering_page\!!zerocount + +\installcorenamespace{renderingwindow} + +\installframedcommandhandler \??renderingwindow {renderingwindow} \??renderingwindow + +\appendtoks + \letrenderingwindowparameter\c!openpageaction \empty + \letrenderingwindowparameter\c!closepageaction\empty + \setrenderingwindowparameter\c!width {\d_scrn_rendering_width }% + \setrenderingwindowparameter\c!height {\d_scrn_rendering_height}% +\to \everypresetrenderingwindow + +\permanent\tolerant\protected\def\placerenderingwindow[#window]#spacer[#rendering]% do all in lua + {\bgroup + \edef\currentrendering{\ifparameter#rendering\or#rendering\else#window\fi}% + % create fall back if needed + \edef\currentrenderingwindow{\namedrenderingwindowparameter{#window}\c!width}% stupid test, we need a proper one here + \ifempty\currentrenderingwindow + \let\currentrenderingwindow\s!default + \definerenderingwindow[\currentrenderingwindow]% why not global + \else + \edef\currentrenderingwindow{#window}% + \fi + \edef\currentrenderingtype{\renderingtype\currentrendering}% + \ifx\currentrenderingtype\s!internal + \getobjectdimensions{IRO}\currentrendering + \d_scrn_rendering_height\dimexpr\objectheight+\objectdepth\relax + \d_scrn_rendering_width\objectwidth\relax + \getobjectreferencepage{IRO}\currentrendering\m_scrn_rendering_page + \orelse\ifx\currentrenderingwindow\s!default + \d_scrn_rendering_height\vsize + \d_scrn_rendering_width \hsize + \let\m_scrn_rendering_page\realpageno + \else + \d_scrn_rendering_height\renderingwindowparameter\c!height + \d_scrn_rendering_width \renderingwindowparameter\c!width + \let\m_scrn_rendering_page\realpageno + \fi + % todo: + % \handlereferenceactions{\renderingwindowparameter\c!openpageaction }\dosetuprenderingopenpageaction + % \handlereferenceactions{\renderingwindowparameter\c!closepageaction}\dosetuprenderingclosepageaction + \letrenderingwindowparameter\c!offset\v!overlay + \inheritedrenderingwindowframed + {\vfilll + \dontleavehmode + \clf_insertrenderingwindow + label {\currentrendering}% + width \d_scrn_rendering_width + height \d_scrn_rendering_height + option {\renderingoption\currentrendering}% + page \m_scrn_rendering_page + \relax + \hfill}% + \egroup} + +%D Linkedlists (not tested in mkvi): + +% %D The next mechanism, linked lists, is quite old and +% %D is \MKIV'd for completeness. I will finish the +% %D configuration part when I need it. +% %D +% %D \starttyping +% %D \setupinteraction[state=start] +% %D \definelinkedlist[demo] +% %D \dorecurse{10}{\linkedlistelement[demo]{link \recurselevel} \page} +% %D \stoptyping +% +% \definesystemvariable {lk} % LinK +% +% \installcommandhandler\??lk{linkedlist}\??lk +% +% \let\setupbutton\setuplinkedlists\setuplinkedlist +% +% \appendtoks +% \clf_definelinkedlist{\currentlinkedlist}% +% \to \everydefinelinkedlist +% +% \def\setlinkedlistproperties#1#2#3#4#5#6% +% {\def\currentlink {#1}% +% \def\noflinks {#2}% +% \def\firstlink {#3}% +% \def\previouslink{#4}% +% \def\nextlink {#5}% +% \def\lastlink {#6}} +% +% \def\linkedlistelement[#1]#2% currently no view support +% {\dontleavehmode\hbox\bgroup +% #2% +% \iflocation +% \edef\currentlinkedlist{#1}% +% \ifcsname\??lk\currentlinkedlist\s!parent\endcsname +% \hskip\linkedlistparameter\c!distance\relax +% \clf_addlinklistelement{\currentlinkedlist}% +% \expanded{\ctxlatecommand{enhancelinkedlist("\currentlinkedlist",\currentlink)}}% can also be done at the lua end +% \dogotosomepage {\??lk\currentlinkedlist}\gotobegincharacter \firstlink +% \ifnum\noflinks>\plustwo +% \dogotosomepage{\??lk\currentlinkedlist}\gobackwardcharacter\previouslink +% \dogotosomepage{\??lk\currentlinkedlist}\goforwardcharacter \nextlink +% \fi +% \dogotosomepage {\??lk\currentlinkedlist}\gotoendcharacter \lastlink +% \else +% \writestatus\m!interactions{no such linked list: \currentlinkedlist}% +% \fi +% \fi +% \egroup} +% +% \setuplinkedlists +% [\c!distance=.25em, +% \c!width=\v!fit, +% \c!location=\v!low, +% \c!color=\interactionparameter\c!color, +% \c!frame=\v!off, +% \c!background=, +% \c!backgroundcolor=] + +\protect \endinput diff --git a/tex/context/base/mkxl/scrp-ini.mkxl b/tex/context/base/mkxl/scrp-ini.mkxl new file mode 100644 index 000000000..2c3ae2bb6 --- /dev/null +++ b/tex/context/base/mkxl/scrp-ini.mkxl @@ -0,0 +1,109 @@ +%D \module +%D [ file=scrp-ini, +%D version=2009.02.06, +%D title=\CONTEXT\ Script Macros, +%D subtitle=Initialization, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D The script handler has been upgraded mid June 2020 so there might be issues as I +%D didn't test everything (yet). It should all be a bit more efficient now in +%D \LUAMETATEX, although not spectacular. We use no attributes in \LUAMETATEX\ and +%D only one in \LUATEX\ now. +%D +%D A glyph can have (an dget) all kind of properties. Except from the state, these +%D are assigned within \TEX's grouping model! +%D +%D \startitemize +%D \startitem font \stopitem +%D \startitem character \stopitem +%D \startitem language (4 properties packed in an unsigned integer) \stopitem +%D \startitem data (used for dynamics) \stopitem +%D \startitem script (used for special script processing) \stopitem +%D \startitem state (used for analyzing, related to font features) \stopitem +%D \stopitemize +%D +%D Additional properties are set via node list handlers. The state is stored in the +%D glyph, but additional properties are stored in a node's property table. In the +%D future the state might get used for something else, in which case we will stire +%D the state in the property table too. On the other hand, we can now (if we want) +%D influence the state at the\TEX\ end (not that we do that yet). + +%D Todo: as in bidi mode we need a way to globally keep the setting. + +\registerctxluafile{scrp-ini}{} +\registerctxluafile{scrp-cjk}{} +\registerctxluafile{scrp-eth}{} +\registerctxluafile{scrp-tha}{} +\registerctxluafile{scrp-tib}{} + +%D Since scripts need specific \LUA\ code we use hard coded attribute values, but we +%D might have more tricks at some time, so we use a proper define macro too. + +\unprotect + +\installcorenamespace{script} + +\installcommandhandler \??script {script} \??script + +\aliased\let\setupscripts\setupscript % be nice + +% presets are global and are currently defined in lua + +% \appendtoks +% \setuevalue\currentscript{\setscript[\currentscript]}% +% \to \everydefinescript + +\permanent\protected\def\setlocalscript[#1]% + {\edef\currentscript{#1}% + \clf_setscript{\currentscript}{\scriptparameter\c!method}{\scriptparameter\c!preset}} + +\permanent\protected\def\setglobalscript[#1]% + {\setlocalscript[#1]% + \pickupscriptattribute} + +\aliased\let\setscript\setlocalscript + +\permanent\protected\def\resetscript + {\clf_resetscript} + +\permanent\protected\def\startscript[#1]% + {\begingroup + \setlocalscript[#1]} + +\permanent\protected\def\stopscript + {\endgroup} + +% \setscript[hangul] \startscript[hangul] + +\definescript [hangul] [\c!method=hangul] +\definescript [hanzi] [\c!method=hanzi] +\definescript [nihongo] [\c!method=nihongo] +\definescript [ethiopic] [\c!method=ethiopic] +\definescript [thai] [\c!method=thai] +\definescript [tibetan] [\c!method=tibetan] + +\definescript [latin] [\c!method=] % resets the attribute (also currentscript) + +\definescript [test] [\c!method=test] + +% a new trick (at some point we will predefine more scripts and consider a link with the above) + +\appendtoks + \ifempty\currentscript + \doifelse{\scriptparameter\s!features}\v!auto\enableautofontscript\disableautofontscript + \fi +\to \everysetupscript + +\permanent\protected\def\enableautofontscript {\clf_enableautofontscript } % can be public implementor +\permanent\protected\def\disableautofontscript{\clf_disableautofontscript} % can be public implementor + +\definefontfeature[latn][script=latn] +\definefontfeature[grek][script=grek] + +\protect \endinput diff --git a/tex/context/base/mkxl/sort-ini.mkxl b/tex/context/base/mkxl/sort-ini.mkxl new file mode 100644 index 000000000..d9f9628d5 --- /dev/null +++ b/tex/context/base/mkxl/sort-ini.mkxl @@ -0,0 +1,19 @@ +%D \module +%D [ file=sort-ini, +%D version=2005.08.08, +%D title=\CONTEXT\ Sort Macros, +%D subtitle=Initialization, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Sorting Macros / Initialization} + +\registerctxluafile{sort-ini}{} +\registerctxluafile{sort-lan}{} + +\endinput diff --git a/tex/context/base/mkiv/spac-ali.mkxl b/tex/context/base/mkxl/spac-ali.mkxl index 5cb494682..88bdd44eb 100644 --- a/tex/context/base/mkiv/spac-ali.mkxl +++ b/tex/context/base/mkxl/spac-ali.mkxl @@ -161,12 +161,12 @@ inline: \ifconditional\inlinelefttoright l2r\else r2l\fi\space ]\endgroup} -\permanent\protected\def\righttolefthbox#1#{\reversehbox#1\bgroup\righttoleft\let\next} \let\rtlhbox\righttolefthbox -\permanent\protected\def\lefttorighthbox#1#{\naturalhbox#1\bgroup\lefttoright\let\next} \let\ltrhbox\lefttorighthbox -\permanent\protected\def\righttoleftvbox#1#{\reversevbox#1\bgroup\righttoleft\let\next} \let\rtlvbox\righttoleftvbox -\permanent\protected\def\lefttorightvbox#1#{\naturalvbox#1\bgroup\lefttoright\let\next} \let\ltrvbox\lefttorightvbox -\permanent\protected\def\righttoleftvtop#1#{\reversevtop#1\bgroup\righttoleft\let\next} \let\rtlvtop\righttoleftvtop -\permanent\protected\def\lefttorightvtop#1#{\naturalvtop#1\bgroup\lefttoright\let\next} \let\ltrvtop\lefttorightvtop +\permanent\protected\def\righttolefthbox#1#{\reversehbox#1\bgroup\righttoleft\let\next} \aliased\let\rtlhbox\righttolefthbox +\permanent\protected\def\lefttorighthbox#1#{\naturalhbox#1\bgroup\lefttoright\let\next} \aliased\let\ltrhbox\lefttorighthbox +\permanent\protected\def\righttoleftvbox#1#{\reversevbox#1\bgroup\righttoleft\let\next} \aliased\let\rtlvbox\righttoleftvbox +\permanent\protected\def\lefttorightvbox#1#{\naturalvbox#1\bgroup\lefttoright\let\next} \aliased\let\ltrvbox\lefttorightvbox +\permanent\protected\def\righttoleftvtop#1#{\reversevtop#1\bgroup\righttoleft\let\next} \aliased\let\rtlvtop\righttoleftvtop +\permanent\protected\def\lefttorightvtop#1#{\naturalvtop#1\bgroup\lefttoright\let\next} \aliased\let\ltrvtop\lefttorightvtop \permanent\protected\def\autodirhbox#1#{\hbox#1\bgroup\synchronizeinlinedirection\let\next} \permanent\protected\def\autodirvbox#1#{\vbox#1\bgroup\synchronizeinlinedirection\let\next} % maybe also pardir or maybe just a \vbox @@ -568,8 +568,8 @@ }}% kept, nice for tracing \edef\raggedcommand {\the\t_spac_align_collected }% \edef\updateraggedskips{\spac_align_flush_horizontal}% - \global\letcsname\??alignmentnormalcache\m_spac_align_asked\endcsname\raggedcommand - \global\letcsname\??alignmentraggedcache\m_spac_align_asked\endcsname\updateraggedskips} + \gletcsname\??alignmentnormalcache\m_spac_align_asked\endcsname\raggedcommand + \gletcsname\??alignmentraggedcache\m_spac_align_asked\endcsname\updateraggedskips} \def\spac_align_collect#1% {\csname\??aligncommand#1\endcsname} diff --git a/tex/context/base/mkiv/spac-chr.mkxl b/tex/context/base/mkxl/spac-chr.mkxl index 8d7bba42e..57700704f 100644 --- a/tex/context/base/mkiv/spac-chr.mkxl +++ b/tex/context/base/mkxl/spac-chr.mkxl @@ -29,31 +29,6 @@ %D them in a string. So this needs thinking. Not that we can compare the %D nobreakspace now anyway. -% \unexpanded\def\specialspacecharacter#1{\begingroup\c_attr_characters#1\ \endgroup} -% -% \unexpanded\edef\nobreakspace {\specialspacecharacter{"00A0}} % 1 = left -% \unexpanded\edef\ideographicspace {\specialspacecharacter{"2000}} -% \unexpanded\edef\ideographichalffillspace{\specialspacecharacter{"2001}} -% \unexpanded\edef\twoperemspace {\specialspacecharacter{"2002}} -% \unexpanded\edef\threeperemspace {\specialspacecharacter{"2004}} -% \unexpanded\edef\fourperemspace {\specialspacecharacter{"2005}} -% \unexpanded\edef\sixperemspace {\specialspacecharacter{"2006}} -% \unexpanded\edef\figurespace {\specialspacecharacter{"2007}} -% \unexpanded\edef\punctuationspace {\specialspacecharacter{"2008}} -% \unexpanded\edef\breakablethinspace {\specialspacecharacter{"2009}} -% \unexpanded\edef\hairspace {\specialspacecharacter{"200A}} -% \unexpanded\edef\zerowidthspace {\specialspacecharacter{"200B}} -% \unexpanded\edef\zwnj {\specialspacecharacter{"200C}} -% \unexpanded\edef\zwj {\specialspacecharacter{"200D}} -% \unexpanded\edef\narrownobreakspace {\specialspacecharacter{"202F}} - -% This does not work as spaceskip is only inserted in the case of raggedleft -% and we need to be able to figure out all of them. Which makes me wonder ... -% can't we just always set spaceskip to some value? - -% Making them active is also not an option unless we do that in every -% catcode vector. - \pushoverloadmode %immutable\edef\nobreakspace {\begingroup\setalignstateattribute\normalUchar"00A0\endgroup} % 1 = left diff --git a/tex/context/base/mkxl/spac-def.mkxl b/tex/context/base/mkxl/spac-def.mkxl new file mode 100644 index 000000000..bba0d47f2 --- /dev/null +++ b/tex/context/base/mkxl/spac-def.mkxl @@ -0,0 +1,91 @@ +%D \module +%D [ file=spac-def, +%D version=2009.10.16, % 1997.03.31, was core-spa.tex +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Definitions, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Definitions} + +%D Ideally these definitions should be moved to where they first appear and this +%D will happen at some point. + +\unprotect + +% maybe \everysynchronizeglobalspacing +% maybe \everysynchronizelocalspacing + +\appendtoks + \forgetverticalstretch + \presetnormallineheight + \setnormalbaselines % check if redundant (\forgetverticalstretch does it too) + \setstrut % check if redundant (\forgetverticalstretch does it too) + \settopskip % factors set in \forgetverticalstretch + \setmaxdepth % factors set in \forgetverticalstretch + \synchronizeindenting + \synchronizeskipamounts + \synchronizeblank + \synchronizewhitespace + \synchronizespacecodes % not needed, frozen factors + \setrelativeinterlinespace +\to \everybodyfont + +% why exception + +\appendtoks + \updateraggedskips % under test +\to \everyfontswitch + +% maybe more + +\prependtoks + \let\par\normalpar +\to \everybeforepagebody % see \fillinline (was endgraf) + +% needs checking: + +\appendtoks + \synchronizespacecodes +\to \everydefinedfont % not needed, frozen factors + +\setupinterlinespace + [\c!minheight=\zeropoint, % only special purpose + \c!mindepth=\zeropoint, % only special purpose + \c!height=.72, + \c!depth=.28, + \c!top=1.0, + \c!bottom=0.4, + \c!distance=\onepoint, % \dimexpr\openlineheight/10\relax + \c!line=2.8\exheight, + \c!stretch=\zerocount, + \c!shrink=\zerocount] + +\setupblank + [\v!big] + +\setuptolerance + [\v!horizontal,\v!verystrict] + +\setuptolerance + [\v!vertical,\v!strict] + +\setupalign + [\v!bottom, + \v!width] + +\setupspacing + [\v!packed] + +\indenting + [\v!never] + +\setupindenting + [\v!none] + +\protect \endinput diff --git a/tex/context/base/mkxl/spac-flr.mkxl b/tex/context/base/mkxl/spac-flr.mkxl new file mode 100644 index 000000000..3bf1aa800 --- /dev/null +++ b/tex/context/base/mkxl/spac-flr.mkxl @@ -0,0 +1,194 @@ +%D \module +%D [ file=spac-fil, +%D version=2013.01.13, +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Fillers, +%D author={Hans Hagen and Wolfgang Schuster}, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Fillers} + +\unprotect + +%D A bit more extensive variant of a prototype posted by Wolfgang to the development +%D list. Instead of dealing with a few leader types it makes sense to support them +%D all as well as simple rule fillers. Eventually we can also use in for the +%D mathfillers. We distinguish between alternatives and with them methods, and a +%D checker is provided for use in applying e.g.\ fillers in lists. + +\installcorenamespace{filler} +\installcorenamespace{filleralternative} +\installcorenamespace{fillerleadermethod} + +\installcommandhandler \??filler {filler} \??filler + +\aliased\let\setupfillers\setupfiller + +\permanent\protected\def\checkedfiller#1% + {\ifcsname\namedfillerhash{#1}\s!parent\endcsname + \filler[#1]% + \expandafter\gobbleoneargument + \else + \expandafter\firstofoneargument + \fi{#1}} + +\permanent\tolerant\protected\def\filler[#1]% + {\removeunwantedspaces + \begingroup + \edef\currentfiller{#1}% + \usefillerstyleandcolor\c!style\c!color + \scratchdimen\fillerparameter\c!leftmargin\relax + \ifzeropt\scratchdimen\else + \hskip\scratchdimen + \fi + \fillerparameter\c!left\relax + \expandnamespaceparameter\??filleralternative\fillerparameter\c!alternative\s!unknown\relax + \fillerparameter\c!right\relax + \scratchdimen\fillerparameter\c!rightmargin\relax + \ifzeropt\scratchdimen\else + \hskip\scratchdimen + \fi + \endgroup + \ignorespaces} + +% \definefiller +% [MyFiller] +% [offset=.25\emwidth, +% rightmargindistance=-\rightskip, +% method=middle] +% +% \startitemize[packed,joinedup][rightmargin=5em] +% \startitem +% \input sapolsky \fillupto[MyFiller]{RS} +% \stopitem +% \stopitemize + +\permanent\tolerant\protected\def\fillupto[#1]#:#2% + {\removeunwantedspaces + \begingroup + \edef\currentfiller{#1}% + \scratchdimen\dimexpr\fillerparameter\c!rightmargindistance\relax + \ifzeropt\scratchdimen\else + \parfillskip \scratchdimen\s!plus \plusone\s!fil\relax + \fi + \spac_fillers_indeed[#1]% + \doifsomething{#2}{\hbox{#2}}% + \par + \endgroup + \ignorespaces} + +\setvalue{\??filleralternative\s!unknown}% + {} + +\setvalue{\??filleralternative\v!symbol}% + {\expandnamespaceparameter\??fillerleadermethod\fillerparameter\c!method\v!local + \ifdim\fillerparameter\c!offset>\zeropoint + \simplealignedspreadbox + {2\dimexpr\fillerparameter\c!offset\relax}% + {\fillerparameter\c!align}% + {\fillerparameter\c!symbol}% + \else + \simplealignedbox + {\fillerparameter\c!width}% + {\fillerparameter\c!align}% + {\fillerparameter\c!symbol}% + \fi + \hfill} + +\setvalue{\??filleralternative\v!stretch}% + {\hfill} + +\setvalue{\??filleralternative\v!space}% + {\hskip\fillerparameter\c!distance\relax} + +\setvalue{\??filleralternative\v!rule}% + {\expandnamespaceparameter\??fillerleadermethod\fillerparameter\c!method\v!local + \hrule + \s!height\fillerparameter\c!height + \s!depth \fillerparameter\c!depth + \hfill} + +\letvalue{\??fillerleadermethod\s!local }\normalleaders % overflow ends up inbetween (current box) +\letvalue{\??fillerleadermethod\v!global}\normalgleaders % overflow ends up inbetween (outermost box) +\letvalue{\??fillerleadermethod\v!middle}\normalcleaders % overflow ends up before, after (current box) +\letvalue{\??fillerleadermethod\v!broad }\normalxleaders % overflow ends up before, inbetween, after (current box) + +\setupfillers + [\c!width=\emwidth, + \c!symbol=., + \c!distance=\emwidth, + \c!offset=\zeropoint, + \c!align=\v!middle, + \c!height=.1\exheight, + \c!depth=\zeropoint, + \c!leftmargin=\zeropoint, + \c!rightmargin=\zeropoint, + \c!rightmargindistance=\zeropoint, + \c!alternative=\v!symbol, + \c!method=\s!local] + +\definefiller + [\v!sym] + [\c!method=\v!global, + \c!width=.5\emwidth, + \c!leftmargin=.5\emwidth, + \c!rightmargin=.5\emwidth] + +\definefiller + [\v!symbol] + [\c!method=\v!global, + \c!offset=.125\emwidth, + \c!leftmargin=.5\emwidth, + \c!rightmargin=.5\emwidth] + +\definefiller + [\v!rule] + [\c!alternative=\v!rule, + \c!leftmargin=.5\emwidth, + \c!rightmargin=.5\emwidth] + +\definefiller + [\v!width] + [\c!alternative=\v!stretch] + +\definefiller + [\v!space] + [\c!alternative=\v!space, + \c!distance=3\emwidth] + +% bonus: + +\definefiller + [dotfill] + [\c!symbol=\textperiod, + \c!style=\v!normal, + \c!method=\v!middle, + \c!width=.5\emwidth, + \c!leftmargin=.2\emwidth, + \c!rightmargin=.2\emwidth] + +\aliased\let\mathdotfill\dotfill + +\permanent\protected\def\textdotfill{\filler[dotfill]} + +\permanent\protected\def\dotfill{\mathortext\mathdotfill\textdotfill} + +% maybe box -> symbol + +\protect \endinput + +% \definefiller[test-a][alternative=stretch] +% \definefiller[test-b][alternative=symbol,symbol=!] +% \definefiller[test-c][alternative=rule,height=.1ex,leftmargin=.5em,rightmargin=.25em] + +% \starttext +% text\filler[test-a]text \par +% text\filler[test-b]text \par +% text\filler[test-c]text \par +% text\checkedfiller{<nothing>}text \par +% \stoptext diff --git a/tex/context/base/mkiv/spac-grd.mkxl b/tex/context/base/mkxl/spac-grd.mkxl index fbb02f50c..fbb02f50c 100644 --- a/tex/context/base/mkiv/spac-grd.mkxl +++ b/tex/context/base/mkxl/spac-grd.mkxl diff --git a/tex/context/base/mkiv/spac-hor.mkxl b/tex/context/base/mkxl/spac-hor.mkxl index b6f92947e..e7263ae76 100644 --- a/tex/context/base/mkiv/spac-hor.mkxl +++ b/tex/context/base/mkxl/spac-hor.mkxl @@ -39,13 +39,13 @@ \permanent\protected\def\setupindenting {\doifelsenextoptionalcs\spac_indentation_setup_options\spac_indentation_setup_size} -\protected\def\spac_indentation_setup_size +\permanent\protected\def\spac_indentation_setup_size {\assigndimension\v_spac_indentation_current\d_spac_indentation_par{1\emwidth}{1.5\emwidth}{2\emwidth}% \ifzeropt\parindent\else \parindent\d_spac_indentation_par\relax % new per 2019-04-12 : just in case it has been set beforehand \fi} -\let\synchronizeindenting\spac_indentation_setup_size +\aliased\let\synchronizeindenting\spac_indentation_setup_size \let\m_spac_indentation_options\empty @@ -80,22 +80,6 @@ \spac_indentation_setup_indeed \fi} -% \def\spac_indentation_apply_step_one#1% -% {\ifcsname\??indentingmethod#1\endcsname -% % case two -% \else -% \edef\v_spac_indentation_current{#1}% single entry in list -% \let\normalindentation\v_spac_indentation_current -% \spac_indentation_setup_size -% \fi} -% -% \def\spac_indentation_apply_step_two#1% -% {\ifcsname\??indentingmethod#1\endcsname -% \csname\??indentingmethod#1\endcsname -% \else -% % case one -% \fi} - % \defineindenting[whatever][yes,2cm] % %defineindenting[whatever][yes,-2cm] % @@ -185,11 +169,26 @@ \installmacrostack\checkindentation +%D Actually we can forget about indent and let everypar insert a kern or so, +%D but on the other hand it's kind of consistent to keep it and make the +%D width zero. We can do it in \LUA\ or do it natively (which actually makes +%D sense. + +% \permanent\protected\def\undent +% {\begingroup +% % todo: check subtype too +% \ifnum\lastnodetype=\gluenodecode +% \unskip % we also need to check for the subtype +% \orelse\ifnum\lastnodetype=\hlistnodecode +% \setbox\scratchbox\lastbox % we also need to check for the subtype +% \else +% % forget about it +% \fi +% \endgroup} + \def\spac_indentation_remove {\ifzeropt\parindent \else - \begingroup - \setbox\scratchbox\lastbox - \endgroup + \undent \fi} \def\spac_indentation_kill_indeed @@ -589,7 +588,7 @@ \permanent\protected\def\negenspace{\kern-.5\emwidth} \permanent\protected\def\negemspace{\kern- \emwidth} -\let\emspace\quad +\aliased\let\emspace\quad \permanent\protected\def\charspace{ } % the unexpandable \space (as space can also be delimiter for numbers) @@ -724,11 +723,6 @@ \fi }} -%% \permanent\protected\def\startnarrower -%% {\dosingleempty\spac_narrower_start_basic} -%% -%% \protected\def\spac_narrower_start_basic[#1]% - \permanent\tolerant\protected\def\startnarrower[#1]% {\begingroup \let\currentnarrower\empty @@ -738,20 +732,7 @@ \spac_narrower_start_apply{\narrowerparameter\v!default}% \fi} -\let\stopnarrower\spac_narrower_stop - -%% \protected\def\startnarrow % current how -%% {\begingroup -%% \dodoubleempty\spac_narrower_start_named} -%% -%% \def\spac_narrower_start_named -%% {\ifsecondargument -%% \expandafter\spac_narrower_start_named_two -%% \else -%% \expandafter\spac_narrower_start_named_one -%% \fi} - -% can be cleaned up more ... todo +\aliased\let\stopnarrower\spac_narrower_stop \permanent\tolerant\protected\def\startnarrow[#1]#*[#2]% current how {\begingroup @@ -791,20 +772,20 @@ {\edef\currentnarrower{#1}% \spac_narrower_start_apply{#2}} -\let\stopnarrow\spac_narrower_stop +\aliased\let\stopnarrow\spac_narrower_stop -\newdimen\d_spac_effective_hsize \def\effectivehsize {\hsize} -\newdimen\d_spac_effective_leftskip \def\effectiveleftskip {\dimexpr\leftskip \relax} -\newdimen\d_spac_effective_rightskip \def\effectiverightskip{\dimexpr\rightskip\relax} +\newdimen\d_spac_effective_hsize \permanent\protected\def\effectivehsize {\hsize} +\newdimen\d_spac_effective_leftskip \permanent\protected\def\effectiveleftskip {\dimexpr\leftskip \relax} +\newdimen\d_spac_effective_rightskip \permanent\protected\def\effectiverightskip{\dimexpr\rightskip\relax} \permanent\protected\def\seteffectivehsize {\setlocalhsize - \d_spac_effective_hsize \localhsize + \d_spac_effective_hsize \localhsize \d_spac_effective_leftskip 1\leftskip \d_spac_effective_rightskip1\rightskip - \let\effectivehsize \d_spac_effective_hsize - \let\effectiveleftskip \d_spac_effective_leftskip - \let\effectiverightskip\d_spac_effective_rightskip} + \enforced\let\effectivehsize \d_spac_effective_hsize + \enforced\let\effectiveleftskip \d_spac_effective_leftskip + \enforced\let\effectiverightskip\d_spac_effective_rightskip} \installcorenamespace{skipadaptionleft} \installcorenamespace{skipadaptionright} @@ -998,11 +979,8 @@ {\enforced\let\crlf\justonespace \enforced\let\\\crlf} -\permanent\protected\def\definehspace - {\dotripleempty\spac_hspaces_define} - -\def\spac_hspaces_define[#1][#2][#3]% #1 = optional namespace - {\ifthirdargument +\permanent\tolerant\protected\def\definehspace[#1]#*[#2]#*[#3]% #1 = optional namespace + {\ifparameter#3\or \setvalue{\??hspace#1:#2}{#3}% \else \setvalue{\??hspace:#1}{#2}% @@ -1245,15 +1223,15 @@ %D \macros %D {obeyfollowingtoken} -\def\obeyfollowingtoken{{}} % end \cs scanning +\permanent\def\obeyfollowingtoken{{}} % end \cs scanning %D Something new: -\protected\def\interwordspacebefore{\wordboundary\zwnj\hskip\interwordspace\relax} -\protected\def\interwordspaceafter {\hskip\interwordspace\relax\zwnj\wordboundary} +\permanent\protected\def\interwordspacebefore{\wordboundary\zwnj\hskip\interwordspace\relax} +\permanent\protected\def\interwordspaceafter {\hskip\interwordspace\relax\zwnj\wordboundary} -\protected\def\interwordspacesbefore#1{\dofastloopcs{#1}\interwordspacebefore} -\protected\def\interwordspacesafter #1{\dofastloopcs{#1}\interwordspaceafter} -\protected\def\interwordspaces #1{\wordboundary\zwnj\dofastloopcs{\numexpr#1+\minusone}\interwordspaceafter} +\permanent\protected\def\interwordspacesbefore#1{\dofastloopcs{#1}\interwordspacebefore} +\permanent\protected\def\interwordspacesafter #1{\dofastloopcs{#1}\interwordspaceafter} +\permanent\protected\def\interwordspaces #1{\wordboundary\zwnj\dofastloopcs{\numexpr#1+\minusone}\interwordspaceafter} \protect \endinput diff --git a/tex/context/base/mkxl/spac-lin.mkxl b/tex/context/base/mkxl/spac-lin.mkxl new file mode 100644 index 000000000..53da64923 --- /dev/null +++ b/tex/context/base/mkxl/spac-lin.mkxl @@ -0,0 +1,211 @@ +%D \module +%D [ file=spac-lin, +%D version=2012.01.08, % 2009.10.16 (core-ver) 1997.03.31 (core-spa) +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Vertical, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Lines} + +\unprotect + +%D When spacing is active we need to handle commands in a special way: +%D +%D \starttyping +%D \setuplines[space=on] +%D +%D \startlines +%D Let's talk about this{\ttsl\gobbleoneargument or}that. +%D \stoplines +%D +%D \startlines +%D Let's talk about this{\getvalue{ttsl}or}that. +%D \stoplines +%D \stoptyping +%D +%D One can indent in several ways: +%D +%D \starttyping +%D \setupindenting[medium] \setuplines[indenting=odd] % no yes odd even +%D +%D \startlines +%D first +%D second +%D third +%D fourth +%D \stoplines +%D \stoptyping + +%D Contrary to \MKII\ we can now define classes of lines (generalized by +%D Wolfgang). I will probably rewrite bits in \LUA. + +\installcorenamespace{lines} + +\installcommandhandler \??lines {lines} \??lines + +\setuplines + [\c!option=, + \c!command=, + \c!before=\blank, + \c!after=\blank, + \c!inbetween=\blank, + \c!indenting=\v!no, + \c!space=\v!default] + +\appendtoks + \frozen\instance\setuevalue{\e!start\currentlines}{\spac_lines_start[\currentlines]}% + \frozen\instance\letvalue {\e!stop \currentlines }\spac_lines_stop +\to \everydefinelines + +\let\p_lines_option\empty + +\let\spac_lines_break \relax +\let\spac_after_first_obeyed_line\relax +\let\spac_lines_indent \relax + +%D See \type {indentation-005.tex}: +%D +%D \starttyping +%D \setuplines[indentlist={0pt,10pt,15pt,20pt}] +%D +%D \setupindenting[yes,1em] +%D \setuplines[indentlist={0pt,*,*}] +%D +%D \setuplines[indentlist={0pt,1em,*}] +%D \starttyping + +\newcount\c_spac_lines_indent_cnt +\newcount\c_spac_lines_indent_max +\newdimen\d_spac_lines_indent + +\def\spac_lines_indent_indeed + {\ifnum\c_spac_lines_indent_cnt=\c_spac_lines_indent_max + \c_spac_lines_indent_cnt\plusone + \else + \advance\c_spac_lines_indent_cnt\plusone + \fi + \getfromcommacommand[\m_spac_lines_indentlist][\c_spac_lines_indent_cnt]% + \ifx\commalistelement\wildcardsymbol + \hskip\d_spac_lines_indent + \else + \scratchdimen\dimexpr\commalistelement\relax + \hskip + \ifdim\scratchdimen=\zeropoint + \zeropoint + \else + \scratchdimen + \d_spac_lines_indent\scratchdimen + \fi + \fi + \relax} + +\permanent\tolerant\protected\def\spac_lines_start[#1]% + {\bgroup + \edef\currentlines{#1}% + \obeylines + \spac_lines_start_indeed} + +\tolerant\def\spac_lines_start_indeed[#1]% new: optional second argument (WS) + {\ifarguments\or + \setupcurrentlines[#1]% + \fi + \edef\p_lines_option{\linesparameter\c!option}% + \ifx\p_lines_option\v!packed + \let\spac_lines_break\nobreak + \else + \let\spac_lines_break\relax + \fi + \linesparameter\c!before + \push_macro_checkindentation + \whitespace + \dostarttaggedchained\t!lines\currentlines\??lines + \begingroup + \uselinesstyleandcolor\c!style\c!color + \useindentingparameter\linesparameter + \usealignparameter\linesparameter + \typesettinglinestrue + \setupwhitespace[\v!none]% todo use fast variant + %\obeylines % move upwards to keep spaces in the first line due to optional argument + % + \edef\m_spac_lines_indentlist{\linesparameter\c!indentlist}% + \getcommacommandsize[\m_spac_lines_indentlist]% + \c_spac_lines_indent_max\commalistsize + \c_spac_lines_indent_cnt\zerocount + \ifnum\c_spac_lines_indent_max>\plusone + \let\spac_lines_indent\spac_lines_indent_indeed + \d_spac_lines_indent\d_spac_indentation_par + \else + \let\spac_lines_indent\relax + \fi + % + \ignorespaces + \glet\spac_after_first_obeyed_line\spac_lines_after_first_obeyed_line_a + \enforced\let\obeyedline\spac_lines_obeyed_line + \activatespacehandler{\linesparameter\c!space}% + \dostarttagged\t!line\empty + \ignorepars} + + +% we could have states instead and handle option in there + +\def\spac_lines_after_first_obeyed_line_a % tzt two pass, like itemize + {\linesparameter\c!command + \spac_lines_indent + \linesparameter\c!left + \glet\spac_after_first_obeyed_line\spac_lines_after_first_obeyed_line_b} + +\def\spac_lines_after_first_obeyed_line_b + {\spac_lines_break + \linesparameter\c!command + \spac_lines_indent + \linesparameter\c!left} + +\def\spac_lines_obeyed_line + {\ifdone\linesparameter\c!right\fi + \dostoptagged % can be a dummy one as we don't look ahead + \par + \dostarttagged\t!line\empty + \futurelet\nexttoken\spac_lines_between} + +\protected\def\spac_lines_stop + {\dostoptagged + \endgroup + \dostoptagged + \pop_macro_checkindentation + \linesparameter\c!after + \egroup} + +\def\spac_lines_between + {\ifx\nexttoken\spac_lines_stop + \donefalse + \else + \doifelsemeaning\nexttoken\obeyedline % brrr + {\donefalse\linesparameter\c!inbetween} + {\donetrue\spac_after_first_obeyed_line}% + \fi} + +\definelines[\v!lines] + +\permanent\tolerant\protected\def\emptylines[#1]% + {\endgraf + \begingroup + %\forgetall % debatable + \ifhmode + \crlf % finish the current line + \fi + \scratchcounter\ifparameter#1\or#1\else3\fi\relax + \dorecurse\scratchcounter{\strut\crlf}% + \endgroup} + +\ifdefined\startlines \else + \aliased\expandafter\let\expandafter\startlines\csname\e!start\v!lines\endcsname + \aliased\expandafter\let\expandafter\stoplines \csname\e!stop \v!lines\endcsname +\fi + +\protect \endinput diff --git a/tex/context/base/mkxl/spac-pag.mkxl b/tex/context/base/mkxl/spac-pag.mkxl new file mode 100644 index 000000000..dbee431af --- /dev/null +++ b/tex/context/base/mkxl/spac-pag.mkxl @@ -0,0 +1,182 @@ +%D \module +%D [ file=spac-pag, +%D version=2009.10.16, % 1997.03.31, was core-spa.tex +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Pages, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Pages} + +\unprotect + +%D The code here has evolved over time and might not be the best +%D around. Maybe much will be gone a some point. + +\installcorenamespace {alignswitch} + +\letvalue{\??alignswitch\v!left }\zerocount +\letvalue{\??alignswitch\v!middle}\plusone +\letvalue{\??alignswitch\v!right }\plustwo + +\permanent\protected\def\setalignmentswitch#1% + {\chardef\alignmentswitch\csname\??alignswitch\ifcsname\??alignswitch#1\endcsname#1\else\v!left\fi\endcsname} + +\newif \ifpagestatemismatch +\newcount \realpagestateno +\newconstant\frozenpagestate + +\permanent\protected\def\dotrackpagestate#1#2% + {\ifdoublesided \ifinpagebody \else + \doforcedtrackpagestate{#1}{#2}% + \fi \fi} + +\permanent\protected\def\doforcedtrackpagestate#1#2% + {\ifcase\frozenpagestate + \global\advance#2\plusone + \setpagestate[#1][\number#2]% + \fi} + +\let\m_spac_pagestates_realpage\empty + +\newconditional\c_spac_pagestates_found + +\permanent\protected\def\docheckpagestate#1#2% + {\ifcase\frozenpagestate + \setpagestaterealpageno{#1}{\number#2}% + \fi} + +\permanent\protected\def\doifelserightpagestate#1#2% not expandable ! + {\ifcase\frozenpagestate + \pagestatemismatchfalse + \realpagestateno\realfolio + \ifinpagebody + \ifdoublesided + \ifodd\realpageno\relax + \settrue\c_spac_pagestates_found + \else + \setfalse\c_spac_pagestates_found + \fi + \else + \settrue\c_spac_pagestates_found + \fi + \orelse\ifdoublesided + \edef\m_spac_pagestates_realpage{\pagestaterealpage{#1}{\number#2}}% + \ifempty\m_spac_pagestates_realpage + \ifodd\realpageno\relax + \settrue\c_spac_pagestates_found + \else + \setfalse\c_spac_pagestates_found + \fi + \else + \realpagestateno\m_spac_pagestates_realpage\relax + \ifnum\realpagestateno=\realpageno \else + \pagestatemismatchtrue + \fi + \ifodd\realpagestateno\relax + \settrue\c_spac_pagestates_found + \else + \setfalse\c_spac_pagestates_found + \fi + \fi + \else + \settrue\c_spac_pagestates_found + \fi + \else + \ifodd\realpagestateno\relax + \settrue\c_spac_pagestates_found + \else + \setfalse\c_spac_pagestates_found + \fi + \fi + \ifconditional\c_spac_pagestates_found + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} + +\permanent\protected\def\doifelseforcedrightpagestate#1#2% + {\ifcase\frozenpagestate + \pagestatemismatchfalse + \realpagestateno\realfolio + \edef\m_spac_pagestates_realpage{\pagestaterealpage{#1}{\number#2}}% + \ifempty\m_spac_pagestates_realpage + \ifodd\realpageno\relax + \settrue\c_spac_pagestates_found + \else + \setfalse\c_spac_pagestates_found + \fi + \else + \realpagestateno\m_spac_pagestates_realpage\relax + \ifnum\realpagestateno=\realpageno \else + \pagestatemismatchtrue + \fi + \ifodd\realpagestateno\relax + \settrue\c_spac_pagestates_found + \else + \setfalse\c_spac_pagestates_found + \fi + \fi + \else + \ifodd\realpagestateno\relax + \settrue\c_spac_pagestates_found + \else + \setfalse\c_spac_pagestates_found + \fi + \fi + \ifconditional\c_spac_pagestates_found + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} + +\aliased\let\doifrightpagestateelse \doifelserightpagestate +\aliased\let\doifforcedrightpagestateelse\doifelseforcedrightpagestate + +\permanent\protected\def\freezepagestate {\frozenpagestate\plusone } +\permanent\protected\def\defrostpagestate{\frozenpagestate\zerocount} + +% we can make more of these on top, but how to deal with mixed frozen states + +% \dorecurse{500}{\dontleavehmode\signalrightpage\doifrightpageelse{right}{left}\par} % given doublesided + +\newcount\nofraggedparagraphs + +\definepagestate[\s!paragraph] + +\permanent\protected\def\signalrightpage {\dotrackpagestate \s!paragraph\nofraggedparagraphs} % use \dontleavehmode if needed +\permanent\protected\def\doifelserightpage{\doifelserightpagestate\s!paragraph\nofraggedparagraphs} +\permanent\protected\def\rightpageorder {\pagestaterealpageorder\s!paragraph\nofraggedparagraphs} + +\aliased\let\doifrightpageelse\doifelserightpage + +\installcorenamespace{pagechanges} + +\newif\ifpagechanged \mutable\let\lastchangedpage\empty + +\def\spac_pagechanges_check#1#2#3% + {\pagechangedfalse + \doforcedtrackpagestate{#2}{#3}% + \edef\m_spac_pagestates_realpage{\pagestaterealpage{#2}{\number#3}}% + \ifempty\m_spac_pagestates_realpage \orelse\ifnum\m_spac_pagestates_realpage>0\csname\??pagechanges#2:#1\endcsname\relax + \pagechangedtrue + \fi + \ifpagechanged + \letgvalue{\??pagechanges#2:#1}\m_spac_pagestates_realpage + \glet\lastchangedpage\m_spac_pagestates_realpage + \else + \glet\lastchangedpage\realfolio + \fi} + +\permanent\protected\def\changedpagestate#1#2% + {\executeifdefined{\??pagechanges#2:#1}0} + +\permanent\protected\def\checkpagechange#1{\spac_pagechanges_check{#1}\s!paragraph\nofraggedparagraphs} +\permanent\protected\def\changedpage #1{\changedpagestate{#1}\s!paragraph} + +\protect \endinput diff --git a/tex/context/base/mkiv/spac-par.lmt b/tex/context/base/mkxl/spac-par.lmt index 3af8ea415..3af8ea415 100644 --- a/tex/context/base/mkiv/spac-par.lmt +++ b/tex/context/base/mkxl/spac-par.lmt diff --git a/tex/context/base/mkiv/spac-par.mkxl b/tex/context/base/mkxl/spac-par.mkxl index 524e31bc5..524e31bc5 100644 --- a/tex/context/base/mkiv/spac-par.mkxl +++ b/tex/context/base/mkxl/spac-par.mkxl diff --git a/tex/context/base/mkxl/spac-prf.mklx b/tex/context/base/mkxl/spac-prf.mklx new file mode 100644 index 000000000..585437ac4 --- /dev/null +++ b/tex/context/base/mkxl/spac-prf.mklx @@ -0,0 +1,113 @@ +%D \module +%D [ file=spac-prf, +%D version=2015.11.16, % moved from test module mathplus +%D title=\CONTEXT\ Spacing Macros, +%D subtitle=Profiling, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Spacing Macros / Profiling} + +%D This is experimental code that we need for a project. The interface and details +%D can change. I moved it into the core because that way we can use it on servers. + +% framed: first reflow then profile + +\unprotect + +\registerctxluafile{spac-prf}{} + +\definesystemattribute[profilemethod][public] + +\installcorenamespace {profile} % beware, profiles are not like in mkii at all +\installcorenamespace {profiles} + +\installcommandhandler \??profile {profile} \??profile + +\setupprofile + [\c!height=\strutht, + \c!depth=\strutdp, + \c!distance=\normallineskip, + \c!lines=\zerocount, + \c!factor=\plusone] + +\defineprofile + [\v!strict] + [\c!method=\v!strict] + +\defineprofile + [\v!fixed] + [\c!method=\v!fixed] + +\defineprofile + [\v!none] + [\c!method=\v!none, + \c!height=\zeropoint, + \c!depth=\zeropoint, + \c!distance=\zeropoint, + \c!factor=\plusone] + +\defineprofile[halffixed] [\v!fixed][\c!factor=\plustwo] +\defineprofile[quarterfixed][\v!fixed][\c!factor=\plusfour] +\defineprofile[eightsfixed] [\v!fixed][\c!factor=\pluseight] + +\permanent\protected\def\setprofile[#profile]% + {\edef\currentprofile{#profile}% + \clf_setprofile + name {\currentprofile}% + height \dimexpr\profileparameter\c!height\relax + depth \dimexpr\profileparameter\c!depth\relax + distance \dimexpr\profileparameter\c!distance\relax + factor \numexpr\profileparameter\c!factor\relax + lines \numexpr\profileparameter\c!lines\relax + method {\profileparameter\c!method}% + \relax} + +\permanent\protected\def\resetprofile + {\c_attr_profilemethod\attributeunsetvalue} + +\permanent\protected\def\useprofileparameter#getparameter% + {\edef\m_spac_profile_asked{#getparameter\c!profile}% + \ifempty\m_spac_profile_asked + \resetprofile + \else + \setprofile[\m_spac_profile_asked]% + \fi} + +\permanent\tolerant\protected\def\profiledbox[#profile]#spacer[#settings]% + {\vbox\bgroup + \ifparameter#settings\or + \edef\currentprofile{#profile}% + \setupcurrentprofile[#settings]% + \else + \doifassignmentelse{#profile} + {\let\currentprofile\v!none + \setupcurrentprofile[#profile]}% + {\edef\currentprofile{#profile}}% + \fi + \dowithnextbox + {\profilegivenbox\currentprofile\nextbox + \unvbox\nextbox + \egroup}% + \vbox} + +\permanent\protected\def\profilegivenbox#profile#box% + {\begingroup + \edef\currentprofile{#profile}% + \clf_profilebox + box \numexpr#box\relax + height \dimexpr\profileparameter\c!height\relax + depth \dimexpr\profileparameter\c!depth\relax + distance \dimexpr\profileparameter\c!distance\relax + factor \numexpr\profileparameter\c!factor\relax + lines \numexpr\profileparameter\c!lines\relax + method {\profileparameter\c!method}% + \relax + \endgroup} + +\protect \endinput diff --git a/tex/context/base/mkiv/spac-ver.lmt b/tex/context/base/mkxl/spac-ver.lmt index 90eeacf26..90eeacf26 100644 --- a/tex/context/base/mkiv/spac-ver.lmt +++ b/tex/context/base/mkxl/spac-ver.lmt diff --git a/tex/context/base/mkiv/spac-ver.mkxl b/tex/context/base/mkxl/spac-ver.mkxl index 92adce2c6..3e68016cc 100644 --- a/tex/context/base/mkiv/spac-ver.mkxl +++ b/tex/context/base/mkxl/spac-ver.mkxl @@ -229,7 +229,7 @@ \pop_macro_currentinterlinespace \localinterlinespacefalse} -\let\switchtointerlinespace\setuplocalinterlinespace +\aliased\let\switchtointerlinespace\setuplocalinterlinespace %D Helpers @@ -241,15 +241,13 @@ % \permanent\overloaded\protected\def\removelastskip % {\ifvmode\ifzeropt\lastskip\else\vskip-\lastskip\fi\fi} -\def\doifoutervmode - {\ifvmode - \ifinner - \doubleexpandafter\gobbleoneargument - \else - \doubleexpandafter\firstofoneargument - \fi - \else +\permanent\def\doifoutervmode + {\unless\ifvmode \expandafter\gobbleoneargument + \orelse\ifinner + \expandafter\gobbleoneargument + \else + \expandafter\firstofoneargument \fi} \protected\def\dosomebreak#1% @@ -351,22 +349,6 @@ %def\v_spac_whitespace_current{\zeropoint} \let\v_spac_whitespace_current\v!none -% \permanent\tolerant\protected\def\setupwhitespace[#1]% -% {\ifarguments -% \spac_whitespace_setup_nop -% \or -% \spac_whitespace_setup_yes{#1}% -% \fi} -% -% \def\spac_whitespace_setup_yes#1% -% {\edef\m_spac_whitespace_asked{#1}% -% \ifempty\m_spac_whitespace_asked -% \spac_whitespace_setup_nop -% \else -% \let\v_spac_whitespace_current\m_spac_whitespace_asked -% \spac_whitespace_setup -% \fi} - \permanent\tolerant\protected\def\setupwhitespace[#1]% {\ifarguments \spac_whitespace_setup_nop @@ -377,12 +359,12 @@ \spac_whitespace_setup \fi} -\def\spac_whitespace_setup_nop +\permanent\protected\def\spac_whitespace_setup_nop {\ifx\v_spac_whitespace_current\v!none\else \spac_whitespace_setup \fi} -\let\synchronizewhitespace\spac_whitespace_setup_nop +\aliased\let\synchronizewhitespace\spac_whitespace_setup_nop \def\spac_whitespace_setup % quick test for no list {\ifcsname\??whitespacemethod\v_spac_whitespace_current\endcsname @@ -529,7 +511,7 @@ \permanent\tolerant\protected\def\startlinecorrection [#1]{\spac_lines_start_correction\plusone{#1}} \permanent\tolerant\protected\def\startlocallinecorrection[#1]{\spac_lines_start_correction\plustwo{#1}} -\protected\def\spac_lines_start_correction#1#2% +\permanent\protected\def\spac_lines_start_correction#1#2% {\endgraf \begingroup \setconstant\c_spac_lines_correction_mode#1% @@ -551,7 +533,7 @@ \fi \ignorespaces} -\protected\def\spac_lines_stop_correction +\permanent\protected\def\spac_lines_stop_correction {\removeunwantedspaces \egroup \ifgridsnapping @@ -614,8 +596,8 @@ \prevdepth\strutdp \spac_lines_action_around} -\let\stoplinecorrection \spac_lines_stop_correction -\let\stoplocallinecorrection\spac_lines_stop_correction +\aliased\let\stoplinecorrection \spac_lines_stop_correction +\aliased\let\stoplocallinecorrection\spac_lines_stop_correction % todo: @@ -1389,28 +1371,28 @@ \overloaded\global\resetpenalties\interlinepenalties \global\c_spac_keep_lines_together\zerocount} -\protected\def\keeplinestogether#1% +\permanent\protected\def\keeplinestogether#1% {\ifnum#1>\c_spac_keep_lines_together \global\c_spac_keep_lines_together#1% \overloaded\global\setpenalties\interlinepenalties\c_spac_keep_lines_together\plustenthousand \global\enforced\let\restoreinterlinepenalty\spac_penalties_restore \fi} -\def\defaultdisplaywidowpenalty {50} -\def\defaultwidowpenalty {2000} % was: 1000 -\def\defaultclubpenalty {2000} % was: 800 -\def\defaultbrokenpenalty {100} -\def\defaultdoublehyphendemerits {10000} -\def\defaultfinalhyphendemerits {5000} -\def\defaultadjdemerits {10000} - -\def\defaultgriddisplaywidowpenalty {0} -\def\defaultgridwidowpenalty {0} -\def\defaultgridclubpenalty {0} -\def\defaultgridbrokenpenalty {0} -\def\defaultgriddoublehyphendemerits{10000} % always was so -\def\defaultgridfinalhyphendemerits {5000} % always was so -\def\defaultgridadjdemerits {10000} % always was so +\immutable\integerdef\defaultdisplaywidowpenalty 50 +\immutable\integerdef\defaultwidowpenalty 2000 % was: 1000 +\immutable\integerdef\defaultclubpenalty 2000 % was: 800 +\immutable\integerdef\defaultbrokenpenalty 100 +\immutable\integerdef\defaultdoublehyphendemerits 10000 +\immutable\integerdef\defaultfinalhyphendemerits 5000 +\immutable\integerdef\defaultadjdemerits 10000 + +\immutable\integerdef\defaultgriddisplaywidowpenalty 0 +\immutable\integerdef\defaultgridwidowpenalty 0 +\immutable\integerdef\defaultgridclubpenalty 0 +\immutable\integerdef\defaultgridbrokenpenalty 0 +\immutable\integerdef\defaultgriddoublehyphendemerits 10000 % always was so +\immutable\integerdef\defaultgridfinalhyphendemerits 5000 % always was so +\immutable\integerdef\defaultgridadjdemerits 10000 % always was so \permanent\protected\def\nopenalties {\frozen\widowpenalty \zerocount @@ -1982,10 +1964,7 @@ % The main spacer: -% \protected\def\vspacing -% {\doifelsenextoptionalcs\spac_vspacing_yes\spac_vspacing_nop} - -\tolerant\protected\def\vspacing[#1]% +\permanent\tolerant\protected\def\vspacing[#1]% {\ifarguments \spac_vspacing_yes[\currentvspacing]% in the new mechanism no [] needed \else @@ -2205,13 +2184,18 @@ \permanent\protected\def\inhibitblank{\ifmmode\else\par\ifvmode\clf_injectdisable\fi\fi} -\let\doinhibitblank\inhibitblank % keep this command, used in styles +\aliased\let\doinhibitblank\inhibitblank % keep this command for a while, used in styles + +%D We use \type {vspacing} because at some point we had the blank mechanism alongside +%D a new experimental variant and I aliased it locally till it all worked out well. So, +%D we're kind of stuck with synonyms now. Some day we will drop the vspacing and use the +%D old aliases instead. -\let\defineblank \definevspacing -\let\setupblank \setupvspacing -\let\blank \vspacing -\let\synchronizeblank \synchronizevspacing -\let\defineblankmethod\definevspacingamount +\aliased\let\defineblank \definevspacing +\aliased\let\setupblank \setupvspacing +\aliased\let\blank \vspacing +\aliased\let\synchronizeblank \synchronizevspacing +\aliased\let\defineblankmethod\definevspacingamount %D The following command is for Wolfgang. It has to be used with care as it does %D {\em not} work in tandem with the other spacing commands. @@ -2341,7 +2325,7 @@ \installcorenamespace{fixedalternatives} -\let\stopfixed\relax +\aliased\let\stopfixed\relax \permanent\protected\def\startfixed {\bgroup diff --git a/tex/context/base/mkiv/strc-bkm.mkxl b/tex/context/base/mkxl/strc-bkm.mkxl index c5bd87324..c5bd87324 100644 --- a/tex/context/base/mkiv/strc-bkm.mkxl +++ b/tex/context/base/mkxl/strc-bkm.mkxl diff --git a/tex/context/base/mkiv/strc-blk.mkxl b/tex/context/base/mkxl/strc-blk.mkxl index 4cfbd51eb..4cfbd51eb 100644 --- a/tex/context/base/mkiv/strc-blk.mkxl +++ b/tex/context/base/mkxl/strc-blk.mkxl diff --git a/tex/context/base/mkiv/strc-con.mklx b/tex/context/base/mkxl/strc-con.mklx index 08420a7ef..54397ce3a 100644 --- a/tex/context/base/mkiv/strc-con.mklx +++ b/tex/context/base/mkxl/strc-con.mklx @@ -117,8 +117,8 @@ \letvalue{\??constructionmain\currentconstruction}\currentconstructionparent \definelist[\currentconstruction][\currentconstructionparent]% goodie \fi - \instance\setevalue{\??constructionlevel\currentconstruction}{\number\constructionparameter\c!level}% - \instance\setevalue{\??constructionclass\currentconstruction}{\constructionparameter\s!handler}% + \setevalue{\??constructionlevel\currentconstruction}{\number\constructionparameter\c!level}% + \setevalue{\??constructionclass\currentconstruction}{\constructionparameter\s!handler}% \to \everydefineconstruction % todo: inhibit this when we have a different handle .. current we cannot do \frozen @@ -434,7 +434,7 @@ % \endgroup \dorechecknextindentation} -\protected\def\boxedconstructionhead#1% +\permanent\protected\def\boxedconstructionhead#1% {\doifelse{\constructionalternativeparameter\c!alignbottom}{\v!yes}\vbox\vtop {\hsize\constructionsheadwidth \edef\p_strc_constructions_headalign{\constructionparameter\c!headalign}% diff --git a/tex/context/base/mkxl/strc-def.mkxl b/tex/context/base/mkxl/strc-def.mkxl new file mode 100644 index 000000000..52b3b3ad9 --- /dev/null +++ b/tex/context/base/mkxl/strc-def.mkxl @@ -0,0 +1,338 @@ +%D [ file=strc-def, +%D version=2008.10.20, +%D title=\CONTEXT\ Structure Macros, +%D subtitle=Definitions, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Structure Macros / Definitions} + +%registerctxluafile{strc-def}{} + +\unprotect + +% \setupsectionblock[appendix][sectionconversionset=appendix] +% \setuphead[chapter][sectionconversionset=\sectionblockparameter\c!sectionconversionset] % \sectionblockparameter] + +% \defineresetset[default][0,1,1,0][1] % this will not reset parts and subsections +% \setuphead[part][sectionresetset=default] +% \starttext +% \placelist[chapter,section,subsection][criterium=all,width=3cm] +% \part{first} \chapter{alpha} \section{a} \section{b} \subsection{x} \subsection{y} \chapter{beta} +% \part{second} \chapter{gamma} \section{a} \section{b} \subsection{x} \subsection{y} \chapter{delta} +% \stoptext + +\defineseparatorset [\s!default] [] [.] +\defineconversionset [\s!default] [] [numbers] +\defineresetset [\s!default] [] [1] % each level +\defineprefixset [\s!default] [section-1,section-2,section-3] [] + +\defineconversionset [\v!number] [] [numbers] +\defineconversionset [\v!pagenumber] [] [numbers] + +\defineprefixset [\v!all] [section-1,section-2,section-3,section-4,section-5,section-6,section-7,section-8] [] +\defineprefixset [\v!none] [] [] + +\defineprefixset [\v!part] [section-1] [] +\defineprefixset [\v!chapter] [section-2] [] + +\defineseparatorset [\v!appendix:\s!default] [] [.] +\defineconversionset [\v!appendix:\s!default] [Romannumerals,Characters] [numbers] +\defineresetset [\v!appendix:\s!default] [] [1] % why was this 0 + +\setupuserpagenumber + [\c!numberconversionset=\v!pagenumber] + +\setupcounters + [\c!numberconversionset=\v!number] + +% \startsetups defaults:frontpart:pagenumbers:roman +% \defineconversionset[\c!frontpart:\c!pagenumber][][romannumerals] +% \setupuserpagenumber[\c!way=\v!by\v!block] +% \stopsetups + +% \definesectionblock + +\definesectionblock [\v!frontpart] [\v!frontmatter] [\c!number=\v!no] +\definesectionblock [\v!bodypart] [\v!bodymatter] [\c!number=\v!yes] +\definesectionblock [\v!appendix] [\v!appendices] [\c!number=\v!yes] +\definesectionblock [\v!backpart] [\v!backmatter] [\c!number=\v!no] + +\setsectionblock [\v!bodypart] % default + +% \setuphead[sectionsegments=\currentheadlevel] +% \setuphead[sectionsegments=current] +% +% \startchapter[title=One,ownnumber={A}] +% \startsection[title=OneOne,ownnumber={A.B}] +% \startsubsection[title=OneOneOne,ownnumber={A.B.C}] +% test +% \stopsubsection +% \stopsection +% \stopchapter + +% \appendtoks +% \setsectionblock[\v!bodypart]% default +% \to \everyjob +% +% \appendtoks +% \clf_setinitialsectionblock{\v!bodypart}% +% \to \everystarttext + +\appendtoks + \clf_setinitialsectionblock{\v!bodypart}% +\to \everyjob + +% \definesection (could become \definehead with one parameter) + +\definesection[\s!section-1] % part +\definesection[\s!section-2] % chapter +\definesection[\s!section-3] % section +\definesection[\s!section-4] % subsection +\definesection[\s!section-5] % subsubsection +\definesection[\s!section-6] % subsubsubsection +\definesection[\s!section-7] % subsubsubsubsection +\definesection[\s!section-8] % subsubsubsubsubsection +\definesection[\s!section-9] % subsubsubsubsubsubsection +\definesection[\s!section-10] % subsubsubsubsubsubsubsection +\definesection[\s!section-11] % subsubsubsubsubsubsubsubsection +\definesection[\s!section-12] % subsubsubsubsubsubsubsubsubsection + +% \definehead + +\definehead + [\v!part] + [\c!section=\s!section-1] + +\definehead + [\v!chapter] + [\c!section=\s!section-2] + +\definehead + [\v!section] + [\c!section=\s!section-3] + +\definehead + [\v!subsection] + [\c!section=\s!section-4, + \c!default=\v!section] + +\definehead + [\v!subsubsection] + [\c!section=\s!section-5, + \c!default=\v!subsection] + +\definehead + [\v!subsubsubsection] + [\c!section=\s!section-6, + \c!default=\v!subsubsection] + +\definehead + [\v!subsubsubsubsection] + [\c!section=\s!section-7, + \c!default=\v!subsubsubsection] + +\definehead + [\v!subsubsubsubsubsection] + [\c!section=\s!section-8, + \c!default=\v!subsubsubsubsection] + +\definehead + [\v!subsubsubsubsubsubsection] + [\c!section=\s!section-9, + \c!default=\v!subsubsubsubsubsection] + +\definehead + [\v!subsubsubsubsubsubsubsection] + [\c!section=\s!section-10, + \c!default=\v!subsubsubsubsubsubsection] + +\definehead + [\v!subsubsubsubsubsubsubsubsection] + [\c!section=\s!section-11, + \c!default=\v!subsubsubsubsubsubsubsection] + +\definehead + [\v!subsubsubsubsubsubsubsubsubsection] + [\c!section=\s!section-12, + \c!default=\v!subsubsubsubsubsubsubsubsection] + +\definehead + [\v!title] + [\c!coupling=\v!chapter, + \c!default=\v!chapter, + \c!incrementnumber=\v!no] + +\definehead + [\v!subject] + [\c!coupling=\v!section, + \c!default=\v!section, + \c!incrementnumber=\v!no] + +\definehead + [\v!subsubject] + [\c!coupling=\v!subsection, + \c!default=\v!subsection, + \c!incrementnumber=\v!no] + +\definehead + [\v!subsubsubject] + [\c!coupling=\v!subsubsection, + \c!default=\v!subsubsection, + \c!incrementnumber=\v!no] + +\definehead + [\v!subsubsubsubject] + [\c!coupling=\v!subsubsubsection, + \c!default=\v!subsubsubsection, + \c!incrementnumber=\v!no] + +\definehead + [\v!subsubsubsubsubject] + [\c!coupling=\v!subsubsubsubsection, + \c!default=\v!subsubsubsubsection, + \c!incrementnumber=\v!no] + +\definehead + [\v!subsubsubsubsubsubject] + [\c!coupling=\v!subsubsubsubsubsection, + \c!default=\v!subsubsubsubsubsection, + \c!incrementnumber=\v!no] + +\definehead + [\v!subsubsubsubsubsubsubject] + [\c!coupling=\v!subsubsubsubsubsubsection, + \c!default=\v!subsubsubsubsubsubsection, + \c!incrementnumber=\v!no] + +\definehead + [\v!subsubsubsubsubsubsubsubject] + [\c!coupling=\v!subsubsubsubsubsubsubsection, + \c!default=\v!subsubsubsubsubsubsubsection, + \c!incrementnumber=\v!no] + +\definehead + [\v!subsubsubsubsubsubsubsubsubject] + [\c!coupling=\v!subsubsubsubsubsubsubsubsection, + \c!default=\v!subsubsubsubsubsubsubsubsection, + \c!incrementnumber=\v!no] + +\definehead + [\v!subsubsubsubsubsubsubsubsubsubject] + [\c!coupling=\v!subsubsubsubsubsubsubsubsubsection, + \c!default=\v!subsubsubsubsubsubsubsubsubsection, + \c!incrementnumber=\v!no] + +% setups + +\setuphead + [\v!part] + [\c!placehead=\v!no] + +\setuphead + [\v!chapter] + [\v!appendix\c!label=\v!appendix, + \v!bodypart\c!label=\v!chapter] % bijlageconversie=\Character + +\setuphead + [\v!section] + [\v!appendix\c!label=\v!section, + \v!bodypart\c!label=\v!section] % bijlageconversie=\Character + +\setuphead + [\v!subsection] + [\v!appendix\c!label=\v!subsection, + \v!bodypart\c!label=\v!subsection] % bijlageconversie=\Character + +\setuphead + [\v!subsubsection] + [\v!appendix\c!label=\v!subsubsection, + \v!bodypart\c!label=\v!subsubsection] % bijlageconversie=\Character + +% prefixes + +\defineprefixset + [\v!all] + [section-1,section-2,section-3,section-4,section-5,section-6,section-7,% + section-8,section-9,section-10,section-11,section-12] + [] + +% \setuphead + +\setuphead + [\v!part,\v!chapter] + [%\c!align=, + %\c!indentnext=\v!no, + \c!continue=\v!no, + \c!page=\v!right, + \c!marking=\v!page, + \c!header=, + \c!style=\tfc, + \c!distance=.75\emwidth, + \c!textdistance=\emwidth plus \emwidth minus .25\emwidth, + \c!before={\blank[2*\v!big]}, + \c!after={\blank[2*\v!big]}] + +\setuphead + [\v!section] + [%\c!align=, + %\c!indentnext=\v!no, + \c!style=\tfa, + \c!distance=.75\emwidth, + \c!textdistance=\emwidth plus \emwidth minus .25\emwidth, + \c!before={\blank[2*\v!big]}, + \c!after=\blank] + +\setuphead % nieuw + [\v!subsection] + [\c!page=] + +% brrr + +% \definecounter[\v!page][\c!start=1] % todo: setup + +% lists + +\definecombinedlist + [\v!content] + [\v!part, + \v!chapter, + \v!section, + \v!subsection, + \v!subsubsection, + \v!subsubsubsection, + \v!subsubsubsubsection] + [\c!level=\v!subsubsubsubsection, + \c!criterium=\v!local] + +\setuplist + [\v!part] + [\c!before={\blank[\v!preference,\v!big]}, % sort of mkii compatible, watch columns + \c!after=\blank, + \c!label=\v!yes, + \c!distance=\emwidth] + +\setuplist + [\v!chapter] + [\c!before={\blank[\v!preference,\v!big]}, % sort of mkii compatible, watch columns + \c!after=] + +\setuplist [\v!part] [\c!width=0\emwidth] +\setuplist [\v!chapter] [\c!width=2\emwidth] +\setuplist [\v!section] [\c!width=3\emwidth] +\setuplist [\v!subsection] [\c!width=4\emwidth] +\setuplist [\v!subsubsection] [\c!width=5\emwidth] +\setuplist [\v!subsubsubsection] [\c!width=6\emwidth] +\setuplist [\v!subsubsubsubsection] [\c!width=7\emwidth] +\setuplist [\v!subsubsubsubsubsection] [\c!width=8\emwidth] +\setuplist [\v!subsubsubsubsubsubsection] [\c!width=9\emwidth] +\setuplist [\v!subsubsubsubsubsubsubsection] [\c!width=10\emwidth] +\setuplist [\v!subsubsubsubsubsubsubsubsection] [\c!width=11\emwidth] +\setuplist [\v!subsubsubsubsubsubsubsubsubsection] [\c!width=12\emwidth] + +\protect \endinput diff --git a/tex/context/base/mkiv/strc-des.mklx b/tex/context/base/mkxl/strc-des.mklx index e63512c7f..e63512c7f 100644 --- a/tex/context/base/mkiv/strc-des.mklx +++ b/tex/context/base/mkxl/strc-des.mklx diff --git a/tex/context/base/mkiv/strc-doc.mkxl b/tex/context/base/mkxl/strc-doc.mkxl index 046f0b086..046f0b086 100644 --- a/tex/context/base/mkiv/strc-doc.mkxl +++ b/tex/context/base/mkxl/strc-doc.mkxl diff --git a/tex/context/base/mkiv/strc-enu.mklx b/tex/context/base/mkxl/strc-enu.mklx index c593a65b0..d568247eb 100644 --- a/tex/context/base/mkiv/strc-enu.mklx +++ b/tex/context/base/mkxl/strc-enu.mklx @@ -219,7 +219,7 @@ \protected\def\strc_enumerations_next {\strc_constructions_next_indeed \namedenumerationparameter} % #1#2 \protected\def\strc_enumerations_reset{\strc_constructions_reset_indeed\namedenumerationparameter} % #1#2 -%unexpanded\def\strc_enumerations_set {\strc_constructions_set_indeed \namedenumerationparameter} % #1#2 +%protected\def\strc_enumerations_set {\strc_constructions_set_indeed \namedenumerationparameter} % #1#2 %D Counters (maybe we can share this code): (not ok yet, messy with notes) diff --git a/tex/context/base/mkiv/strc-flt.mklx b/tex/context/base/mkxl/strc-flt.mklx index 994ca288a..33794d137 100644 --- a/tex/context/base/mkiv/strc-flt.mklx +++ b/tex/context/base/mkxl/strc-flt.mklx @@ -256,15 +256,15 @@ \def\strc_floats_define_commands#1#2% {\frozen\instance\setuevalue{\e!place\e!listof#2}{\strc_lists_place[#1]}% call will change \frozen\instance\setuevalue{\e!complete\e!listof#2}{\strc_lists_complete[#1][#2]}% call will change - \frozen\instance\setuevalue{\e!place#1}{\strc_floats_place[#1]}% - \frozen\instance\setuevalue{\e!start\e!place#1}{\strc_floats_start_place[#1]}% - \frozen\instance\setuevalue{\e!stop\e!place#1}{\strc_floats_stop_place}% + \frozen\instance\setuevalue{\e!place#1}{\placefloat[#1]}% + \frozen\instance\setuevalue{\e!start\e!place#1}{\startplacefloat[#1]}% + \frozen\instance\setuevalue{\e!stop\e!place#1}{\stopplacefloat}% \frozen\instance\setuevalue{\e!start#1\e!text}{\strc_floats_start_text[#1]}% \frozen\instance\setuevalue{\e!stop#1\e!text}{\strc_floats_stop_text}% % these will become obsolete: - \setuevalue{\e!reserve#1}{\strc_floats_reserve[#1]}% - \setuevalue{\e!start\e!reserve#1\e!text}{\strc_floats_start_reserve_text[#1]}% - \setuevalue{\e!stop\e!reserve#1\e!text}{\strc_floats_stop_reserve_text}} + \frozen\instance\setuevalue{\e!reserve#1}{\strc_floats_reserve[#1]}% + \frozen\instance\setuevalue{\e!start\e!reserve#1\e!text}{\strc_floats_start_reserve_text[#1]}% + \frozen\instance\setuevalue{\e!stop\e!reserve#1\e!text}{\strc_floats_stop_reserve_text}} %D Fallback float body: @@ -620,13 +620,7 @@ \ifdefined\dotagregisterfloat \else \let\dotagregisterfloat\gobbletwoarguments \fi -\protected\def\strc_floats_place - {\flushnotes - \page_otr_command_flush_side_floats % here ! - \strc_floats_begin_group - \strc_floats_place_indeed} - -\tolerant\def\strc_floats_place_indeed[#tag]#spacer[#location]#spacer[#reference]#:#caption% +\tolerant\def\strc_floats_place[#tag]#spacer[#location]#spacer[#reference]#:#caption% {\strc_floats_set_current_tag{#tag}% \strc_floats_reset_variables \xdef\askedfloatoptions{#location}% @@ -642,11 +636,11 @@ \setupcurrentfloatcaption[\c!reference={#reference},\c!title={#caption},\c!marking=,\c!list=,\c!bookmark=]% \doifelseinset\v!split\floatlocation\strc_floats_place_next_box_split\strc_floats_place_next_box_normal} -\permanent\protected\def\placefloat% [#tag]% +\permanent\protected\def\placefloat {\flushnotes \page_otr_command_flush_side_floats % here ! \strc_floats_begin_group - \strc_floats_place_indeed} + \strc_floats_place} % start-stop @@ -660,17 +654,14 @@ \let\m_strc_floats_saved_userdata\empty % todo: reset this in non start|stop cases -\protected\def\strc_floats_start_place - {\flushnotes - \page_otr_command_flush_side_floats % here ! - \strc_floats_begin_group - \strc_floats_start_place_indeed} - %D We abuse the settings to pick up some float parameters too which makes it %D messy. -\tolerant\protected\def\strc_floats_start_place_indeed[#tag]#spacer[#settings]#spacer[#userdata]% - {\strc_floats_set_current_tag{#tag}% +\permanent\tolerant\protected\def\startplacefloat[#tag]#spacer[#settings]#spacer[#userdata]% + {\flushnotes + \page_otr_command_flush_side_floats % here ! + \strc_floats_begin_group + \strc_floats_set_current_tag{#tag}% \strc_floats_reset_variables % save \edef\m_location {\floatcaptionparameter\c!location}% @@ -717,25 +708,17 @@ \bgroup \ignorespaces} -\protected\def\strc_floats_stop_place +\permanent\protected\def\stopplacefloat {\removeunwantedspaces \egroup} -\permanent\protected\def\startplacefloat - {\flushnotes - \page_otr_command_flush_side_floats % here ! - \strc_floats_begin_group - \strc_floats_start_place_indeed} - -\aliased\let\stopplacefloat\strc_floats_stop_place - % reserve \protected\def\strc_floats_reserve {\flushnotes \page_otr_command_flush_side_floats % here ! \strc_floats_begin_group - \strc_floats_place_indeed} + \strc_floats_place} \def\strc_floats_reserve_box#settings% {\begingroup @@ -752,7 +735,7 @@ \strc_floats_start_text_indeed} \tolerant\protected\def\strc_floats_start_text_indeed[#tag]#spacer[#location]#spacer[#reference]% - {\strc_floats_place_indeed[#tag][\v!text,#location,\v!left][#reference]} + {\strc_floats_place[#tag][\v!text,#location,\v!left][#reference]} \protected\def\strc_floats_stop_text {\strc_floats_stop_text_indeed} @@ -763,7 +746,7 @@ {\flushnotes \page_otr_command_flush_side_floats \strc_floats_begin_text_group - \strc_floats_place_indeed[#tag][\v!text,#location,\v!left][#reference]{#caption}{\strc_floats_reserve_box{#settings}}} + \strc_floats_place[#tag][\v!text,#location,\v!left][#reference]{#caption}{\strc_floats_reserve_box{#settings}}} \protected\def\strc_floats_stop_reserve_text {\strc_floats_stop_text_indeed} @@ -889,12 +872,12 @@ % \edef\askedfloatskip{\rootfloatparameter#skip}% % \ifempty\askedfloatskip % \global#target\zeropoint -% \else\ifx\askedfloatskip\v!none +% \orelse\ifx\askedfloatskip\v!none % \global#target\zeropoint % \else % \setbox\scratchbox\vbox{\whitespace\blank[\askedfloatskip]}% todo: move whitespace inside blank % \global#target\ht\scratchbox -% \fi\fi +% \fi % \endgroup} \def\strc_floats_calculate_skip#target#skip% @@ -1034,18 +1017,16 @@ \global\floatcaptionht\ht#box\relax \global\floatcaptiondp\dp#box\relax} -\def\doifelsemainfloatbody - {\ifinsidesplitfloat - \ifconditional\splitfloatfirstdone - \doubleexpandafter\secondoftwoarguments - \else - \doubleexpandafter\firstoftwoarguments - \fi +\permanent\def\doifelsemainfloatbody + {\unless\ifinsidesplitfloat + \expandafter\firstoftwoarguments + \orelse\ifconditional\splitfloatfirstdone + \expandafter\secondoftwoarguments \else \expandafter\firstoftwoarguments \fi} -\let\doifmainfloatbodyelse\doifelsemainfloatbody +\aliased\let\doifmainfloatbodyelse\doifelsemainfloatbody % todo: optional user pars diff --git a/tex/context/base/mkiv/strc-ind.mkxl b/tex/context/base/mkxl/strc-ind.mkxl index 31d7eb575..31d7eb575 100644 --- a/tex/context/base/mkiv/strc-ind.mkxl +++ b/tex/context/base/mkxl/strc-ind.mkxl diff --git a/tex/context/base/mkiv/strc-ini.mklx b/tex/context/base/mkxl/strc-ini.mklx index 3897c1d2a..3897c1d2a 100644 --- a/tex/context/base/mkiv/strc-ini.mklx +++ b/tex/context/base/mkxl/strc-ini.mklx diff --git a/tex/context/base/mkiv/strc-itm.mklx b/tex/context/base/mkxl/strc-itm.mklx index e2388eeec..a1de95195 100644 --- a/tex/context/base/mkiv/strc-itm.mklx +++ b/tex/context/base/mkxl/strc-itm.mklx @@ -341,16 +341,16 @@ %D Global states \def\strc_itemgroups_store_continue_state#options#settings% - {\global\edefcsname\??itemgroupoption \currentitemgroup\endcsname{\strc_itemgroups_process_options{#options}}% - \global\defcsname \??itemgroupsetting\currentitemgroup\endcsname{\setupcurrentitemgroup[#settings]}} + {\xdefcsname\??itemgroupoption \currentitemgroup\endcsname{\strc_itemgroups_process_options{#options}}% + \gdefcsname\??itemgroupsetting\currentitemgroup\endcsname{\setupcurrentitemgroup[#settings]}} \def\strc_itemgroups_fetch_continue_state {\csname\??itemgroupoption \currentitemgroup\endcsname \csname\??itemgroupsetting\currentitemgroup\endcsname} \def\strc_itemgroups_reset_continue_state - {\global\letcsname\??itemgroupoption \currentitemgroup\endcsname\relax - \global\letcsname\??itemgroupsetting\currentitemgroup\endcsname\relax} + {\gletcsname\??itemgroupoption \currentitemgroup\endcsname\relax + \gletcsname\??itemgroupsetting\currentitemgroup\endcsname\relax} % These will become keywords. We will also add a feature to keep the while set % together. @@ -1579,6 +1579,27 @@ %D The local commands: +\ifdefined\item \else \let\item \relax \fi +\ifdefined\sub \else \let\sub \relax \fi +\ifdefined\sym \else \let\sym \relax \fi +\ifdefined\ran \else \let\ran \relax \fi +\ifdefined\its \else \let\its \relax \fi +\ifdefined\mar \else \let\mar \relax \fi +\ifdefined\noitem \else \let\noitem \relax \fi +\ifdefined\itm \else \let\itm \relax \fi +\ifdefined\but \else \let\but \relax \fi +\ifdefined\nop \else \let\nop \relax \fi +\ifdefined\txt \else \let\txt \relax \fi +\ifdefined\head \else \let\head \relax \fi +\ifdefined\headsym \else \let\headsym \relax \fi +\ifdefined\startitem \else \let\startitem \relax \fi +\ifdefined\stopitem \else \let\stopitem \relax \fi +\ifdefined\starthead \else \let\starthead \relax \fi +\ifdefined\stophead \else \let\stophead \relax \fi +\ifdefined\startspecialitem \else \let\startspecialitem\relax \fi +\ifdefined\stopspecialitem \else \let\stopspecialitem \relax \fi + + \appendtoks \enforced\let\item \strc_itemgroups_start_do_item \enforced\let\sub \strc_itemgroups_start_subitem diff --git a/tex/context/base/mkiv/strc-lab.mkxl b/tex/context/base/mkxl/strc-lab.mkxl index 95bfa82df..389f868a8 100644 --- a/tex/context/base/mkiv/strc-lab.mkxl +++ b/tex/context/base/mkxl/strc-lab.mkxl @@ -54,19 +54,19 @@ \protected\def\strc_define_commands_label#1#2#3% current level parent {\doifelsenothing{#3} {\normalexpanded{\defineconstruction[#1][\s!handler=\v!label,\c!level=#2]}% - \setevalue{\??label#1:\s!parent}{\??label}}% + \edefcsname\??label#1:\s!parent\endcsname{\??label}}% {\normalexpanded{\defineconstruction[#1][#3][\s!handler=\v!label,\c!level=#2]}% - \setevalue{\??label#1:\s!parent}{\??label#3}}% + \edefcsname\??label#1:\s!parent\endcsname{\??label#3}}% \ifconditional\c_strc_constructions_define_commands - \frozen\instance\setuevalue{\e!next #1}{\strc_labels_next {#1}{\number#2}}% obsolete - \frozen\instance\setuevalue{\v!reset#1}{\strc_labels_reset{#1}{\number#2}}% obsolete % should be \e!reset anyway + \frozen\instance\protected\edefcsname\e!next #1\endcsname{\strc_labels_next {#1}{\number#2}}% obsolete + \frozen\instance\protected\edefcsname\v!reset#1\endcsname{\strc_labels_reset{#1}{\number#2}}% obsolete % should be \e!reset anyway %frozen\instance\setuevalue{\c!set #1}{\strc_labels_set {#1}{\number#2}}% obsolete \ifcsname\v!current#1\endcsname % we play safe \else - \setuevalue{\v!current#1}{\strc_labels_current{#1}}% % obsolete % should be \e!current anyway + \protected\edefcsname\v!current#1\endcsname{\strc_labels_current{#1}}% % obsolete % should be \e!current anyway \fi - \frozen\instance\setuevalue{#1}{\strc_labels_command[#1]}% + \frozen\instance\protected\edefcsname#1\endcsname{\strc_labels_command[#1]}% \fi} % todo: \strc_labels_command for user diff --git a/tex/context/base/mkiv/strc-lev.mklx b/tex/context/base/mkxl/strc-lev.mklx index b8b633c32..08688ee04 100644 --- a/tex/context/base/mkiv/strc-lev.mklx +++ b/tex/context/base/mkxl/strc-lev.mklx @@ -23,33 +23,31 @@ \unprotect -\unexpanded\def\definesectionlevels{\dodoubleargument\strc_levels_define} -\unexpanded\def\startsectionlevel {\dosingleempty \strc_levels_start_section} -\unexpanded\def\startsubjectlevel {\dosingleempty \strc_levels_start_subject} +\permanent\tolerant\protected\def\definesectionlevels[#category]#spacer[#list]% + {\clf_definesectionlevels{#category}{#list}} % we could scan/use public at the lua end -\unexpanded\def\strc_levels_define[#category][#list]{\clf_definesectionlevels{#category}{#list}} -\unexpanded\def\stopsectionlevel {\clf_stopsectionlevel} -\unexpanded\def\stopsubjectlevel {\clf_stopsectionlevel} - -\unexpanded\def\nostarthead{\dotripleargument\strc_levels_start_nop} % used at the lua end -\unexpanded\def\nostophead {\dosingleargument\strc_levels_stop_nop } % used at the lua end - -\unexpanded\def\strc_levels_start_section[#category]% +\permanent\tolerant\protected\def\startsectionlevel[#category]% {\doifelseassignment{#category}% {\clf_startsectionlevel\plusone{\v!default}{\currentnamedsection}[#category]}% {\clf_startsectionlevel\plusone {#category}{\currentnamedsection}}} -\unexpanded\def\strc_levels_start_subject[#category]% +\permanent\protected\def\stopsectionlevel + {\clf_stopsectionlevel} % we could use public at the lua end + +\permanent\tolerant\protected\def\startsubjectlevel[#category]% {\doifelseassignment{#category}% {\clf_startsectionlevel\plustwo{\v!default}{\currentnamedsection}[#category]}% {\clf_startsectionlevel\plustwo {#category}{\currentnamedsection}}} -\unexpanded\def\strc_levels_start_nop[#category][#settings][#userdata]% +\permanent\protected\def\stopsubjectlevel + {\clf_stopsectionlevel} % we could use public at the lua end + +\permanent\tolerant\protected\def\nostarthead[#category]#spacer[#settings]#spacer[#userdata]% {\blank \noindentation{\tttf[start missing section level #category]} \blank} -\unexpanded\def\strc_levels_stop_nop[#category]% +\permanent\tolerant\protected\def\nostophead[#category]% {\blank \noindentation{\tttf[stop missing section level #category]} \blank} @@ -63,9 +61,9 @@ {\v!subsubsubsection,\v!subsubsubject}, {\v!subsubsubsubsection,\v!subsubsubject}] -\let\definestructurelevels\definesectionlevels -\let\startstructurelevel \startsectionlevel -\let\stopstructurelevel \stopsectionlevel +\aliased\let\definestructurelevels\definesectionlevels +\aliased\let\startstructurelevel \startsectionlevel +\aliased\let\stopstructurelevel \stopsectionlevel \protect \endinput @@ -98,4 +96,3 @@ % \stopsectionlevel % % \stoptext - diff --git a/tex/context/base/mkiv/strc-lnt.mklx b/tex/context/base/mkxl/strc-lnt.mklx index f24c93ee4..2a06d3c79 100644 --- a/tex/context/base/mkiv/strc-lnt.mklx +++ b/tex/context/base/mkxl/strc-lnt.mklx @@ -148,8 +148,8 @@ \letnotationparameter\c!numbercommand\linenotelinenumber% todo: deep hook \letnoteparameter \c!textcommand \gobbleoneargument % todo: deep hook \csname\??linenote\currentnotation\endcsname{#3}% - \global\letcsname\??linenotespreviousfrom\currentnotation\endcsname\m_page_lines_current_from - \global\letcsname\??linenotespreviousto \currentnotation\endcsname\m_page_lines_current_to + \gletcsname\??linenotespreviousfrom\currentnotation\endcsname\m_page_lines_current_from + \gletcsname\??linenotespreviousto \currentnotation\endcsname\m_page_lines_current_to \endgroup} % compression @@ -213,8 +213,8 @@ % where to hook this one in? resetcounter has no hook: \permanent\protected\def\doresetlinenotecompression#1% \strc_linenotes_reset_previous - {\global\letcsname\??linenotespreviousfrom#1\endcsname\empty - \global\letcsname\??linenotespreviousto #1\endcsname\empty} + {\gletcsname\??linenotespreviousfrom#1\endcsname\empty + \gletcsname\??linenotespreviousto #1\endcsname\empty} \definesymbol [\v!compressseparator] diff --git a/tex/context/base/mkiv/strc-lst.mklx b/tex/context/base/mkxl/strc-lst.mklx index 2e088766a..df2eb6e0f 100644 --- a/tex/context/base/mkiv/strc-lst.mklx +++ b/tex/context/base/mkxl/strc-lst.mklx @@ -214,7 +214,7 @@ \strc_lists_write_data_to_nop} \tolerant\def\strc_lists_write_data_to_yes[#settings]#spacer[#userdata]% - {\ifthirdargument % no need to have an extra step ... used seldom + {\ifparameter#userdata\or % no need to have an extra step ... used seldom \strc_lists_inject_yes[#settings,\c!type=\s!userdata][#userdata]% \else \strc_lists_inject_yes[\c!type=\s!userdata][#settings]% @@ -307,6 +307,11 @@ \strc_lists_place[#singular][#settings]% \stopnamedsection} +\permanent\tolerant\def\strc_lists_combined_complete[#tag]#spacer[#settings]% + {\normalexpanded{\startnamedsection[\v!title][\c!title={\headtext{#tag}},\c!reference=#tag]}% + \placecombinedlist[#tag][#settings]% + \stopnamedsection} + %D Combined list provide a nice level of abstraction. %D %D \starttyping @@ -317,7 +322,7 @@ {\definelist[#tag][\c!criterium=\v!local,\c!reference=,\c!alternative=,\c!list={#list},#settings]% inherits from root \frozen\instance\setvalue{\e!setup#tag\e!endsetup}{\setupcombinedlist[#tag]}% \frozen\instance\setvalue{\e!place#tag}{\placecombinedlist[#tag]}% - \frozen\instance\setvalue{\e!complete#tag}{\strc_lists_complete[#tag]}} + \frozen\instance\setvalue{\e!complete#tag}{\strc_lists_combined_complete[#tag]}} \permanent\tolerant\protected\def\setupcombinedlist[#tag]#spacer[#settings]% {\ifarguments\or\or diff --git a/tex/context/base/mkiv/strc-mar.mkxl b/tex/context/base/mkxl/strc-mar.mkxl index a15db8265..eb095a2a5 100644 --- a/tex/context/base/mkiv/strc-mar.mkxl +++ b/tex/context/base/mkxl/strc-mar.mkxl @@ -87,16 +87,17 @@ {} \tolerant\def\strc_markings_get_yes[#1]#*[#2]#*[#3]% - {\doif{\namedmarkingparameter{#1}\c!state}\v!start - {\begingroup - \setsystemmode\v!marking - \the\everymarking - \ifparameter#3\or - \clf_getmarking{#1}{#2}{#3}% - \else - \clf_getmarking{#1}{\v!page}{#2}% - \fi - \endgroup}} + {\ifcstok{\namedmarkingparameter{#1}\c!state}\v!start + \begingroup + \setsystemmode\v!marking + \the\everymarking + \ifparameter#3\or + \clf_getmarking{#1}{#2}{#3}% + \else + \clf_getmarking{#1}{\v!page}{#2}% + \fi + \endgroup + \fi} % the fetchers are fully expandable: [name][method] diff --git a/tex/context/base/mkiv/strc-mat.mkxl b/tex/context/base/mkxl/strc-mat.mkxl index e72be7d3e..a9efa8d25 100644 --- a/tex/context/base/mkiv/strc-mat.mkxl +++ b/tex/context/base/mkxl/strc-mat.mkxl @@ -151,8 +151,8 @@ \let\strc_formulas_stop_formula \relax % defined later \permanent\tolerant\protected\def\defineformulaalternative[#1]#*[#2]#*[#3]% - {\setvalue{\e!start#1\v!formula}{#2}% - \setvalue{\e!stop #1\v!formula}{#3}} + {\frozen\instance\setvalue{\e!start#1\v!formula}{#2}% + \frozen\instance\setvalue{\e!stop #1\v!formula}{#3}} % sp = single line paragraph sd = single line display % mp = multi line paragraph md = multy line display @@ -870,9 +870,12 @@ \protected\def\strc_math_align_here{\ifmmode\penalty\plusone\fi}% \protected\def\strc_math_break_here{\ifmmode\hfill\break \fi}% +\ifdefined\alignhere \else \aliased\let\alignhere\relax \fi +\ifdefined\breakhere \else \aliased\let\breakhere\relax \fi + \appendtoks - \let\alignhere\strc_math_align_here - \let\breakhere\strc_math_break_here + \enforced\let\alignhere\strc_math_align_here + \enforced\let\breakhere\strc_math_break_here \to \everymathematics \protected\def\strc_formulas_start_formula_indeed[#1][#2]% setting leftskip adaption is slow ! @@ -892,14 +895,14 @@ \d_strc_formulas_display_width \formulaparameter\c!width\relax \d_strc_formulas_display_margin_left \formulaparameter\c!leftmargin\relax \d_strc_formulas_display_margin_right\formulaparameter\c!rightmargin\relax - \ifsecondargument - \doifelseassignment{#2}% this is new, so that we can also set the grid - {\setupcurrentformula[#2]% - \edef\p_option{\formulaparameter\c!option}}% - {\edef\p_option{\formulaparameter\c!option}% - \edef\p_option{\ifempty\p_option\else\p_option,\fi#2}}% + \iftok{#2}\emptytoks + \edef\p_option{\formulaparameter\c!option}% + \orelse\ifhastok={#2}% this is new, so that we can also set the grid + \setupcurrentformula[#2]% + \edef\p_option{\formulaparameter\c!option}% \else \edef\p_option{\formulaparameter\c!option}% + \edef\p_option{\ifempty\p_option\else\p_option,\fi#2}% \fi \ifempty\p_option \else \rawprocesscommacommand[\p_option]\strc_formulas_option diff --git a/tex/context/base/mkiv/strc-not.mklx b/tex/context/base/mkxl/strc-not.mklx index 299873830..ec8cf849f 100644 --- a/tex/context/base/mkiv/strc-not.mklx +++ b/tex/context/base/mkxl/strc-not.mklx @@ -24,8 +24,8 @@ \ifdefined\dotagsetnotesymbol \else \let\dotagsetnotesymbol\relax \fi \ifdefined\dotagsetnotation \else \let\dotagsetnotation \relax \fi -\protected\def\unvboxed {\ifvmode\unvbox \else\box \fi} % will change or used more often -\protected\def\unvcopied{\ifvmode\unvcopy\else\copy\fi} % will change or used more often +\permanent\protected\def\unvboxed {\ifvmode\unvbox \else\box \fi} % will change or used more often +\permanent\protected\def\unvcopied{\ifvmode\unvcopy\else\copy\fi} % will change or used more often %D \LMTX\ testcase: %D @@ -1506,7 +1506,7 @@ \fi \fi} -\let\flushnotes\relax +\aliased\let\flushnotes\relax % also \ifcase\insertionmigrationmode here, needs testing: @@ -1755,13 +1755,13 @@ \ifdefined\currentnofcolumns\else \def\currentnofcolumns{\nofcolumns} \fi - \protected\def\fakenotes + \permanent\protected\def\fakenotes {\ifhmode\endgraf\fi\ifvmode \calculatetotalclevernoteheight \ifdim\totalnoteheight>\zeropoint \kern\totalnoteheight \fi \fi} - \protected\def\fakepagenotes + \permanent\protected\def\fakepagenotes {\ifhmode\endgraf\fi\ifvmode \calculatetotalpagenoteheight \ifdim\totalnoteheight>\zeropoint \kern\totalnoteheight \fi @@ -1771,7 +1771,7 @@ \newdimen\totalnoteheight - \protected\def\additionaltotalnoteheight#insert% temp hacks anyway + \permanent\protected\def\additionaltotalnoteheight#insert% temp hacks anyway {\dimexpr \ifdim\ht#insert>\zeropoint \ifcase\count#insert % @@ -1784,22 +1784,22 @@ \fi \relax} - \def\docalculatetotalnoteheight + \permanent\def\docalculatetotalnoteheight {\ifcase\c_strc_notes_page_location % tricky here ! ! ! to be sorted out ! ! ! \advance\totalnoteheight\normalexpanded{\additionaltotalnoteheight\currentnoteinsertionnumber}% \fi} - \def\docalculatetotalclevernoteheight + \permanent\def\docalculatetotalclevernoteheight {\ifcase\c_strc_notes_page_location \else % tricky here ! ! ! to be sorted out ! ! ! \advance\totalnoteheight\normalexpanded{\additionaltotalnoteheight\currentnoteinsertionnumber}% \fi} - \def\docalculatetotalpagenoteheight + \permanent\def\docalculatetotalpagenoteheight {\advance\totalnoteheight\normalexpanded{\additionaltotalnoteheight\currentnoteinsertionnumber}} - \def\calculatetotalnoteheight {\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalnoteheight} - \def\calculatetotalclevernoteheight{\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalclevernoteheight} - \def\calculatetotalpagenoteheight {\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalpagenoteheight} + \permanent\def\calculatetotalnoteheight {\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalnoteheight} + \permanent\def\calculatetotalclevernoteheight{\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalclevernoteheight} + \permanent\def\calculatetotalpagenoteheight {\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalpagenoteheight} %D Now how can this mechanism be hooked into \CONTEXT\ without explictly postponing %D footnotes? The solution turned out to be rather simple: diff --git a/tex/context/base/mkiv/strc-num.mkxl b/tex/context/base/mkxl/strc-num.mkxl index 1ddbd511d..041e2c138 100644 --- a/tex/context/base/mkiv/strc-num.mkxl +++ b/tex/context/base/mkxl/strc-num.mkxl @@ -227,9 +227,9 @@ \protected\def\strc_counters_incremented #1{\clf_incrementedcounter {\namedcounterparameter{#1}\s!name}} \protected\def\strc_counters_decremented #1{\clf_decrementedcounter {\namedcounterparameter{#1}\s!name}} -\protected\def\showcounter [#1]{\clf_showcounter {\namedcounterparameter{#1}\s!name}} -\protected\def\incrementedcounter[#1]{\clf_incrementedcounter{\namedcounterparameter{#1}\s!name}} % no \dosingleargument -\protected\def\decrementedcounter[#1]{\clf_decrementedcounter{\namedcounterparameter{#1}\s!name}} % no \dosingleargument +\permanent\protected\def\showcounter [#1]{\clf_showcounter {\namedcounterparameter{#1}\s!name}} +\permanent\protected\def\incrementedcounter[#1]{\clf_incrementedcounter{\namedcounterparameter{#1}\s!name}} % no \dosingleargument +\permanent\protected\def\decrementedcounter[#1]{\clf_decrementedcounter{\namedcounterparameter{#1}\s!name}} % no \dosingleargument % public variants ... beware, for old cases, from now on the value variants are the % ones that are expandable diff --git a/tex/context/base/mkiv/strc-pag.mkxl b/tex/context/base/mkxl/strc-pag.mkxl index 07ac30d26..07ac30d26 100644 --- a/tex/context/base/mkiv/strc-pag.mkxl +++ b/tex/context/base/mkxl/strc-pag.mkxl diff --git a/tex/context/base/mkiv/strc-ref.mklx b/tex/context/base/mkxl/strc-ref.mklx index 2f3475e50..e25cb49f1 100644 --- a/tex/context/base/mkiv/strc-ref.mklx +++ b/tex/context/base/mkxl/strc-ref.mklx @@ -822,7 +822,7 @@ \letvalue{\??savedinternalreference\s!default}\!!zerocount \permanent\protected\def\storeinternalreference#1#2% - {\setxvalue{\??savedinternalreference\currentstructurename}{\number#2}} + {\xdefcsname\??savedinternalreference\currentstructurename\endcsname{\number#2}} \newconditional\preferpagereferences @@ -964,8 +964,8 @@ \ifdefined\over \let\normalmathover \over \protected\def\over {\mathortext\normalmathover \strc_references_about} \else \let\over \strc_references_about \fi \to \everydump -\permanent \def\filterreference #key{\clf_filterreference{#key}} % no checking, expanded -\permanent\protected\def\getreferenceentry#key{\clf_filterreference{#key}} % no checking, unexpanded +\permanent \def\filterreference #key{\clf_filterreference{#key}} % no checking, expandable +\permanent\protected\def\getreferenceentry#key{\clf_filterreference{#key}} % no checking, not expandable \def\currentreferencenumber {\clf_filterreference{number}} \def\currentreferencepage {\clf_filterreference{page}} @@ -1244,29 +1244,28 @@ {\the\everyresetinatreference \endgroup} -\def\strc_references_pickup_goto - {\dodoublegroupempty\strc_references_pickup_goto_indeed} +% NEEDS TESTING: -\def\strc_references_pickup_goto_indeed#left#right#dummy[#label]% #dummy gobbles spaces (really needed) +\tolerant\def\strc_references_pickup_goto#=#=#:#*[#3]% {\leftreferencetoks - \iffirstargument - {#left}% + \ifparameter#1\or + {#1}% \else \defaultleftreferencetoks \enforced\let\leftofreferencecontent\empty \fi \rightreferencetoks - \ifsecondargument - {#right}% + \ifparameter#2\or + {#2}% \else \defaultrightreferencetoks \enforced\let\rightofreferencecontent\empty \fi % inefficient: double resolve - \doifelsereferencefound{#label} % we need to resolve the text - {\goto{\referencesequence}[#label]} + \doifelsereferencefound{#3} % we need to resolve the text + {\goto{\referencesequence}[#3]} {\let\currentreferencecontent\strc_references_dummy - \goto{\referencesequence}[#label]}% + \goto{\referencesequence}[#3]}% \strc_references_stop_goto} \protected\def\strc_references_in @@ -1936,9 +1935,7 @@ %D is interpreted as the file to jump to, that is, when one clicks on the title. \permanent\tolerant\protected\def\coupledocument[#name]#spacer[#file]#spacer[#sections]#spacer[#description]% - {\ifthirdargument - % this will be done differently (when it's needed) - \fi} + {} % this will be done differently (when it's needed) %D \macros %D {dotextprefix} diff --git a/tex/context/base/mkiv/strc-reg.mkxl b/tex/context/base/mkxl/strc-reg.mkxl index 97933ffb8..f44819bc1 100644 --- a/tex/context/base/mkiv/strc-reg.mkxl +++ b/tex/context/base/mkxl/strc-reg.mkxl @@ -107,7 +107,8 @@ \definemixedcolumns [\v!register] - [\c!n=\registerparameter\c!n, + [\c!define=\v!no, + \c!n=\registerparameter\c!n, \c!balance=\registerparameter\c!balance, \c!align=\registerparameter\c!align, \c!tolerance=\registerparameter\c!tolerance] @@ -502,8 +503,8 @@ \permanent\tolerant\protected\def\stopstructurepageregister[#1]#*[#2]% {\normalexpanded{\ctxlatecommand{structures.registers.extend("#1","#2")}}} -\let\openstructurepageregisterrange \startstructurepageregister -\let\closestructurepageregisterrange\stopstructurepageregister +\aliased\let\openstructurepageregisterrange \startstructurepageregister +\aliased\let\closestructurepageregisterrange\stopstructurepageregister % So far. diff --git a/tex/context/base/mkiv/strc-ren.mkxl b/tex/context/base/mkxl/strc-ren.mkxl index 2d553964b..2d553964b 100644 --- a/tex/context/base/mkiv/strc-ren.mkxl +++ b/tex/context/base/mkxl/strc-ren.mkxl diff --git a/tex/context/base/mkiv/strc-sbe.mkxl b/tex/context/base/mkxl/strc-sbe.mkxl index bb6ba789a..4ff1263bf 100644 --- a/tex/context/base/mkiv/strc-sbe.mkxl +++ b/tex/context/base/mkxl/strc-sbe.mkxl @@ -128,12 +128,10 @@ \protected\def\strc_sectionblock_get_environment#1% {\csname\??sectionblockenvironment#1\endcsname} -\protected\setvalue{\e!start\v!sectionblockenvironment}% - {\dosingleargument\strc_sectionblock_environment_start} +\permanent\tolerant\protected\setvalue{\e!start\v!sectionblockenvironment}[#1]% evt \pushendofline \popendofline + {\grabuntil{\e!stop\v!sectionblockenvironment}{\strc_sectionblock_set_environment{#1}}} -\letvalue{\e!stop\v!sectionblockenvironment}\relax +\aliased\letvalue{\e!stop\v!sectionblockenvironment}\relax -\def\strc_sectionblock_environment_start[#1]% evt \pushendofline \popendofline - {\grabuntil{\e!stop\v!sectionblockenvironment}{\strc_sectionblock_set_environment{#1}}} \protect \endinput diff --git a/tex/context/base/mkiv/strc-sec.mkxl b/tex/context/base/mkxl/strc-sec.mkxl index 9a0ebbb54..e5371d1e9 100644 --- a/tex/context/base/mkiv/strc-sec.mkxl +++ b/tex/context/base/mkxl/strc-sec.mkxl @@ -1033,16 +1033,16 @@ \egroup} \protected\def\strc_rendering_place_head_hidden % maybe trialtypesetting check - {\setxvalue{\??hiddenheadattr\currenthead}% + {\xdefcsname\??hiddenheadattr\currenthead\endcsname {\headreferenceattributes}% can be used when making a box - \setxvalue{\??hiddenheadsync\currenthead}% + \xdefcsname\??hiddenheadsync\currenthead\endcsname {\noexpand\letgvalue{\??hiddenheadsync\currenthead}\relax \noexpand\setmarking[\currentheadcoupling]{li::\currentstructurelistnumber}% \hpack\headreferenceattributes{}% otherwise no destination ... maybe tag ref as hidden and fall back on page reference \theheadsynchonization}} % and it's a node anyway -\permanent\def\synchronizehead #1{\csname\??hiddenheadsync#1\endcsname} -\permanent\def\theheadreferenceattributes#1{\csname\??hiddenheadattr#1\endcsname} +\permanent\def\synchronizehead #1{\begincsname\??hiddenheadsync#1\endcsname} +\permanent\def\theheadreferenceattributes#1{\begincsname\??hiddenheadattr#1\endcsname} \permanent\protected\def\placerawheaddata [#1]{\synchronizehead{#1}} \permanent\protected\def\placerawheadtext [#1]{\getspecificstructuretitle{\thenamedheadlevel{#1}}} diff --git a/tex/context/base/mkiv/strc-syn.mkxl b/tex/context/base/mkxl/strc-syn.mkxl index d658e5467..6f2f255d5 100644 --- a/tex/context/base/mkiv/strc-syn.mkxl +++ b/tex/context/base/mkxl/strc-syn.mkxl @@ -260,9 +260,9 @@ % % These will go away. Actually the overloads catched this empty case! % - \instance\setuvalue{\e!setup #2\e!endsetup}{\setupsynonyms[#1]}% obsolete definition - \instance\setuvalue{\e!place \e!listof#2}{\placelistofsynonyms[#1]}% accepts extra argument - \instance\setuvalue{\e!complete\e!listof#2}{\completelistofsynonyms[#1]}% + \frozen\instance\setuvalue{\e!setup #2\e!endsetup}{\setupsynonyms[#1]}% obsolete definition + \frozen\instance\setuvalue{\e!place \e!listof#2}{\placelistofsynonyms[#1]}% accepts extra argument + \frozen\instance\setuvalue{\e!complete\e!listof#2}{\completelistofsynonyms[#1]}% \fi} \permanent\tolerant\protected\def\definesynonym[#1]#*[#2]#*[#3]% @@ -492,11 +492,11 @@ % These will go away. Actually the overloads catched this empty case! % % - \presetheadtext[#2=\Word{#2}]% after \ifthirdargument -) + \presetheadtext[#2=\Word{#2}]% % - \instance\setuvalue{\e!setup #2\e!endsetup}{\setupsorting[#1]}% obsolete definition - \instance\setuvalue{\e!place \e!listof#2}{\placelistofsorts[#1]}% - \instance\setuvalue{\e!complete\e!listof#2}{\completelistofsorts[#1]}% + \frozen\instance\setuvalue{\e!setup #2\e!endsetup}{\setupsorting[#1]}% obsolete definition + \frozen\instance\setuvalue{\e!place \e!listof#2}{\placelistofsorts[#1]}% + \frozen\instance\setuvalue{\e!complete\e!listof#2}{\completelistofsorts[#1]}% \fi} \permanent\tolerant\protected\def\definesort[#1]#*[#2]#*[#3]% diff --git a/tex/context/base/mkiv/strc-tag.lmt b/tex/context/base/mkxl/strc-tag.lmt index 11049abe0..11049abe0 100644 --- a/tex/context/base/mkiv/strc-tag.lmt +++ b/tex/context/base/mkxl/strc-tag.lmt diff --git a/tex/context/base/mkiv/strc-tag.mkxl b/tex/context/base/mkxl/strc-tag.mkxl index 08d8fef6c..08d8fef6c 100644 --- a/tex/context/base/mkiv/strc-tag.mkxl +++ b/tex/context/base/mkxl/strc-tag.mkxl diff --git a/tex/context/base/mkiv/strc-tnt.mkxl b/tex/context/base/mkxl/strc-tnt.mkxl index 4129117f0..4129117f0 100644 --- a/tex/context/base/mkiv/strc-tnt.mkxl +++ b/tex/context/base/mkxl/strc-tnt.mkxl diff --git a/tex/context/base/mkiv/strc-usr.mkxl b/tex/context/base/mkxl/strc-usr.mkxl index 28d398194..28d398194 100644 --- a/tex/context/base/mkiv/strc-usr.mkxl +++ b/tex/context/base/mkxl/strc-usr.mkxl diff --git a/tex/context/base/mkiv/supp-box.lmt b/tex/context/base/mkxl/supp-box.lmt index 41013da9a..41013da9a 100644 --- a/tex/context/base/mkiv/supp-box.lmt +++ b/tex/context/base/mkxl/supp-box.lmt diff --git a/tex/context/base/mkiv/supp-box.mkxl b/tex/context/base/mkxl/supp-box.mkxl index fe08876ac..88fd5c9fb 100644 --- a/tex/context/base/mkiv/supp-box.mkxl +++ b/tex/context/base/mkxl/supp-box.mkxl @@ -35,13 +35,11 @@ %D not, you're in trouble). These shortcuts can be used like a dimension, opposite %D to the core macros \type {\strutdepth} and alike, which are values. -%D These will be overloaded in spac-ver: - -\def\strutdp {\dp\strutbox} -\def\strutht {\ht\strutbox} -\def\strutwd {\wd\strutbox} -\def\struthtdp{\htdp\strutbox} -\def\strutgap {\dimexpr\ht\strutbox-\dp\strutbox\relax} + \def\strutdp {\dp\strutbox} % overloaded in spac-ver + \def\strutht {\ht\strutbox} % overloaded in spac-ver +\permanent\protected\def\strutwd {\wd\strutbox} +\permanent\protected\def\struthtdp{\dimexpr\strutht+\strutdp\relax} +\permanent\protected\def\strutgap {\dimexpr\strutht-\strutdp\relax} %D \macros %D {voidbox,nextbox} @@ -125,7 +123,7 @@ \dp\c_boxes_register\zeropoint \box\c_boxes_register} -\let\smashboxed\smashedbox +\aliased\let\smashboxed\smashedbox %D \macros %D {hsmash,vsmash, @@ -377,31 +375,8 @@ %D \stoptyping %D %D Er wordt gedeeld door \type {\openlineheight} en een hoogte van~0pt komt overeen -%D met 0~regels. The raw alternative does not round. -%D -%D For a long time we had: -%D -%D \starttyping -%D \newcount\noflines -%D \newdimen\noflinesheight -%D -%D \def\dogetnoflines#1#2% -%D {\noflinesheight#2\relax -%D \ifzeropt\noflinesheight -%D \noflines\zerocount -%D \else -%D \divide\noflinesheight \openlineheight -%D \noflines\noflinesheight -%D #1\ifdim\noflines\openlineheight=#2\relax \else -%D \advance\noflines\ifdim#2>\zeropoint\plusone\else\minusone\fi -%D \fi\fi -%D \fi} -%D -%D \def\getnoflines {\dogetnoflines\iftrue } % compensated -%D \def\getrawnoflines{\dogetnoflines\iffalse} % no compensation -%D \stoptyping -%D -%D A more recent variant is: +%D met 0~regels. The raw alternative does not round. See the \MKII\ and \MKIV\ files +%D for historic variants. \ifx\roundingeps\undefined \newdimen\roundingeps \roundingeps=10sp \fi @@ -546,7 +521,7 @@ % % \nospacing#1}% -\let\doiftextelse\doifelsetext +\aliased\let\doiftextelse\doifelsetext %D \macros %D {dowithnextbox,nextbox} @@ -665,11 +640,11 @@ % \afterassignment\syst_boxes_with_next_box_content_indeed % \setbox\nextbox} -\permanent\unexpanded\def\dowithnextboxcontent#1#2% inside, after +\permanent\protected\def\dowithnextboxcontent#1#2% inside, after {\afterassigned{#1\aftergrouped{#2}}% \setbox\nextbox} -\permanent\unexpanded\def\dowithnextboxcontentcs#1#2% inside, after +\permanent\protected\def\dowithnextboxcontentcs#1#2% inside, after {\afterassigned{#1\aftergroup#2}% \setbox\nextbox} @@ -1552,7 +1527,7 @@ \newbox\rigidcolumnbox -\let\rigidcolumnlines\!!zerocount +\mutable\let\rigidcolumnlines\!!zerocount \permanent\protected\def\rigidcolumnbalance#1% {\ifnum\rigidcolumns=1 % tzt ook h/d correctie @@ -1940,10 +1915,10 @@ \permanent\protected\def\startoverlay {\bgroup - \let\stopoverlay\egroup + \enforced\aliased\let\stopoverlay\egroup \processboxes\syst_boxes_overlay_process} -\let\stopoverlay\relax +\aliased\let\stopoverlay\relax %D \macros %D {fakebox} @@ -2052,9 +2027,9 @@ \permanent\protected\def\mhbox{\dowithnextboxcs\syst_boxes_mhbox\hbox} \permanent\protected\def\rhbox{\dowithnextboxcs\syst_boxes_rhbox\hbox} -\let\lefthbox \lhbox -\let\midhbox \mhbox -\let\righthbox\rhbox +\aliased\let\lefthbox \lhbox +\aliased\let\midhbox \mhbox +\aliased\let\righthbox\rhbox %D \macros %D {boxofsize} @@ -2166,10 +2141,10 @@ \permanent\protected\def\leftbottombox {\hpack\bgroup\dowithnextboxcs\syst_boxes_leftbottombox_finish \placedbox} \permanent\protected\def\rightbottombox{\hpack\bgroup\dowithnextboxcs\syst_boxes_rightbottombox_finish\placedbox} -\let\topleftbox \lefttopbox -\let\toprightbox \righttopbox -\let\bottomleftbox \leftbottombox -\let\bottomrightbox\rightbottombox +\aliased\let\topleftbox \lefttopbox +\aliased\let\toprightbox \righttopbox +\aliased\let\bottomleftbox \leftbottombox +\aliased\let\bottomrightbox\rightbottombox \def\syst_boxes_rightbox_finish {\global\boxhdisplacement\boxoffset @@ -2355,13 +2330,11 @@ \letgvalueempty{\??stacklst#1}} \permanent\protected\def\savebox#1#2% stack name - {% beware, \setxvalue defines the cs beforehand so we cannot use the - % test inside the { } + {% beware, \setxvalue defines the cs beforehand so we cannot use the test inside the { } \ifcsname\??stacklst#1\endcsname - %\setxvalue{\??stacklst#1}{\csname\??stacklst#1\endcsname,#2}% - \expandafter\xdef\csname\??stacklst#1\expandafter\endcsname\expandafter{\lastnamedcs,#2}% + \xdefcsname\??stacklst#1\expandafter\endcsname\expandafter{\lastnamedcs,#2}% \else - \expandafter\xdef\csname\??stacklst#1\endcsname{#2}% + \xdefcsname\??stacklst#1\endcsname{#2}% \fi \setstackbox{#1}{#2}} @@ -2386,17 +2359,15 @@ \fi}} \permanent\protected\def\doifelsebox#1#2% - {\ifcsname\??stackbox#1:#2\endcsname - \ifvoid\lastnamedcs - \doubleexpandafter\secondoftwoarguments - \else - \doubleexpandafter\firstoftwoarguments - \fi - \else + {\unless\ifcsname\??stackbox#1:#2\endcsname + \expandafter\secondoftwoarguments + \orelse\ifvoid\lastnamedcs \expandafter\secondoftwoarguments + \else + \expandafter\firstoftwoarguments \fi} -\let\doifboxelse\doifelsebox +\aliased\let\doifboxelse\doifelsebox %D This one is cheaper (the above is no longer used that much): @@ -2561,7 +2532,7 @@ %D And even rawer: -\let\naturalvcenter\normalvtop % will go away +\aliased\let\naturalvcenter\normalvtop % will go away % \appendtoks \let\vcenter\normalvcenter \to \everymathematics @@ -2589,8 +2560,8 @@ \permanent\protected\def\setboxllx #1#2{\edefcsname\??box_x\number#1\endcsname{\the\dimexpr#2\relax}} \permanent\protected\def\setboxlly #1#2{\edefcsname\??box_y\number#1\endcsname{\the\dimexpr#2\relax}} -\permanent\protected\def\gsetboxllx#1#2{\global\edefcsname\??box_x\number#1\endcsname{\the\dimexpr#2\relax}} -\permanent\protected\def\gsetboxlly#1#2{\global\edefcsname\??box_y\number#1\endcsname{\the\dimexpr#2\relax}} +\permanent\protected\def\gsetboxllx#1#2{\xdefcsname\??box_x\number#1\endcsname{\the\dimexpr#2\relax}} +\permanent\protected\def\gsetboxlly#1#2{\xdefcsname\??box_y\number#1\endcsname{\the\dimexpr#2\relax}} \permanent\def\getboxllx#1{\ifcsname\??box_x\number#1\endcsname\lastnamedcs\else\zeropoint\fi} \permanent\def\getboxlly#1{\ifcsname\??box_y\number#1\endcsname\lastnamedcs\else\zeropoint\fi} @@ -2673,7 +2644,7 @@ %D Even more dirty: -\let\hyphenatedhbox\hbox +\aliased\let\hyphenatedhbox\hbox % was a macro in mkii %D We can do this: %D @@ -2691,15 +2662,15 @@ \newdimen\lastnaturalboxht \newdimen\lastnaturalboxdp -\let\getnaturaldimensions\clf_getnaturaldimensions % sets three dimensions -\let\naturalwd \clf_naturalwd % calculates and returns wd +\aliased\let\getnaturaldimensions\clf_getnaturaldimensions % sets three dimensions +\aliased\let\naturalwd \clf_naturalwd % calculates and returns wd -\let\getnaturalwd\clf_getnaturalwd % no intermediate -\let\setnaturalwd\clf_setnaturalwd % no intermediate +\aliased\let\getnaturalwd\clf_getnaturalwd % no intermediate +\aliased\let\setnaturalwd\clf_setnaturalwd % no intermediate \permanent\protected\def\doifelserighttoleftinbox{\clf_doifelserighttoleftinbox} -\let\doifrighttoleftinboxelse\doifelserighttoleftinbox +\aliased\let\doifrighttoleftinboxelse\doifelserighttoleftinbox %D New, used in high/low: @@ -2709,9 +2680,9 @@ %D To complement lua (yet undocumented): -\permanent\protected\def\beginhbox{\hbox\bgroup} \let\endhbox\egroup -\permanent\protected\def\beginvbox{\vbox\bgroup} \let\endvbox\egroup -\permanent\protected\def\beginvtop{\vtop\bgroup} \let\endvtop\egroup +\permanent\protected\def\beginhbox{\hbox\bgroup} \aliased\let\endhbox\egroup +\permanent\protected\def\beginvbox{\vbox\bgroup} \aliased\let\endvbox\egroup +\permanent\protected\def\beginvtop{\vtop\bgroup} \aliased\let\endvtop\egroup \permanent\protected\def\sethboxregister#1{\setbox#1\hbox} \permanent\protected\def\setvboxregister#1{\setbox#1\vbox} @@ -2719,9 +2690,9 @@ \permanent\protected\def\flushboxregister#1{\box\numexpr#1\relax} -\permanent\protected\def\starthboxregister#1{\setbox#1\hbox\bgroup} \let\stophboxregister\egroup -\permanent\protected\def\startvboxregister#1{\setbox#1\vbox\bgroup} \let\stopvboxregister\egroup -\permanent\protected\def\startvtopregister#1{\setbox#1\vtop\bgroup} \let\stopvtopregister\egroup +\permanent\protected\def\starthboxregister#1{\setbox#1\hbox\bgroup} \aliased\let\stophboxregister\egroup +\permanent\protected\def\startvboxregister#1{\setbox#1\vbox\bgroup} \aliased\let\stopvboxregister\egroup +\permanent\protected\def\startvtopregister#1{\setbox#1\vtop\bgroup} \aliased\let\stopvtopregister\egroup %D For whatever third party package needs it: %D @@ -2768,7 +2739,7 @@ %D This one has been moved from a 2 decade old file. It makes something boxed %D sit on the baseline. -\protected\def\linebox +\permanent\protected\def\linebox {\hpack\bgroup\dowithnextbox {\scratchdimen\dimexpr\dimexpr\htdp\nextbox-\lineheight\relax/2+\dp\strutbox\relax \setbox\nextbox\hpack{\lower\scratchdimen\box\nextbox}% diff --git a/tex/context/base/mkxl/supp-dir.mkxl b/tex/context/base/mkxl/supp-dir.mkxl new file mode 100644 index 000000000..d2500d236 --- /dev/null +++ b/tex/context/base/mkxl/supp-dir.mkxl @@ -0,0 +1,44 @@ +%D \module +%D [ file=supp-dir, +%D version=2004.11.11, +%D title=\CONTEXT\ Support Macros, +%D subtitle=Directional Things, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +\aliased\let\directionlefttoright\zerocount +\aliased\let\directionrighttoleft\plusone + +\immutable\edef\??bdir{\ifdefined\bodydir bdir\else direction\fi} + +\permanent\protected\edef\naturalhbox {\hbox \??bdir\directionlefttoright} +\permanent\protected\edef\naturalvbox {\vbox \??bdir\directionlefttoright} +\permanent\protected\edef\naturalvtop {\vtop \??bdir\directionlefttoright} +\permanent\protected\edef\naturalhpack {\hpack \??bdir\directionlefttoright} +\permanent\protected\edef\naturalvpack {\vpack \??bdir\directionlefttoright} +\permanent\protected\edef\naturaltpack {\tpack \??bdir\directionlefttoright} + +\permanent\protected\edef\reversehbox {\hbox \??bdir\directionrighttoleft} +\permanent\protected\edef\reversevbox {\vbox \??bdir\directionrighttoleft} +\permanent\protected\edef\reversevtop {\vtop \??bdir\directionrighttoleft} +\permanent\protected\edef\reversehpack {\hpack \??bdir\directionrighttoleft} +\permanent\protected\edef\reversevpack {\vpack \??bdir\directionrighttoleft} +\permanent\protected\edef\reversetpack {\tpack \??bdir\directionrighttoleft} + +% \expanded{\defineactivecharacter \number"2000E} {\textdirection\directionrighttoleft\relax} +% \expanded{\defineactivecharacter \number"2000F} {\textdirection\directionlefttoright\relax} + +\def\syst_direction_string#1{\ifcase#1=\plusone r2l\else l2r\fi} + +\permanent\protected\def\showdirsinmargin + {\normalexpanded{\inleft{\naturalhbox + {\ttxx[\syst_direction_string\pardirection,\syst_direction_string\textdirection]}}}} + +\protect \endinput diff --git a/tex/context/base/mkiv/supp-mat.mkxl b/tex/context/base/mkxl/supp-mat.mkxl index 7e0086fc8..7e0086fc8 100644 --- a/tex/context/base/mkiv/supp-mat.mkxl +++ b/tex/context/base/mkxl/supp-mat.mkxl diff --git a/tex/context/base/mkxl/supp-ran.mkxl b/tex/context/base/mkxl/supp-ran.mkxl new file mode 100644 index 000000000..e70c3d437 --- /dev/null +++ b/tex/context/base/mkxl/supp-ran.mkxl @@ -0,0 +1,49 @@ +%D \module +%D [ file=supp-ran, +%D version=2008-10-31, +%D title=\CONTEXT\ Support Macros, +%D subtitle=Random Number Generation, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Support Macros / Random Number Generation} + +%D This module is downward compatible in the sense that we've kept the user +%D interface (which uses intermediate variables). +%D +%D \starttyping +%D \type{new}: \dorecurse{10}{\randomnumber{1}{100} }\par +%D \setrandomseed{24}\type{set}: \dorecurse{10}{\randomnumber{1}{100} }\par +%D \setrandomseed{24}\type{set}: \dorecurse{10}{\randomnumber{1}{100} }\par +%D \setrandomseed{24}\type{set}: \dorecurse{10}{\randomnumber{1}{100} }\par +%D \pushrandomseed \type{new}: \dorecurse{10}{\randomnumber{1}{100} }\par +%D \poprandomseed \type{old}: \dorecurse{10}{\randomnumber{1}{100} }\par +%D \type{new}: \dorecurse{10}{\randomnumber{1}{100} }\par +%D \stoptyping + +\registerctxluafile{supp-ran}{} + +\unprotect + +\permanent\protected\def\getrandomcount #1#2#3{#1=\clf_getrandomnumber\numexpr#2\relax\numexpr#3\relax\relax} +\permanent\protected\def\getrandomdimen #1#2#3{#1=\clf_getrandomdimen\dimexpr#2\relax\dimexpr#3\relax\scaledpoint\relax} +\permanent\protected\def\getrandomnumber#1#2#3{\edef#1{\clf_getrandomnumber\numexpr#2\relax\numexpr#3\relax}} +\permanent\protected\def\getrandomfloat #1#2#3{\edef#1{\clf_getrandomfloat\dimexpr#2\relax\dimexpr#3\relax}} +\permanent\protected\def\setrandomseed #1{\clf_setrandomseed\numexpr#1\relax} +\permanent\protected\def\getrandomseed #1{\edef#1{\clf_getrandomseed}} +%permanent\protected\def\pushrandomseed {\clf_pushrandomseed} +%permanent\protected\def\poprandomseed {\clf_poprandomseed} +%permanent\protected\def\reuserandomseed {\clf_reuserandomseed} % within push/pop + +\aliased\let\freezerandomseed \pushrandomseed +\aliased\let\defrostrandomseed\poprandomseed + +\permanent\def\randomnumber #1#2{\clf_getrandomnumber\numexpr#1\relax\numexpr#2\relax} +\permanent\def\mprandomnumber {\clf_getmprandomnumber} + +\protect \endinput diff --git a/tex/context/base/mkiv/symb-emj.mkxl b/tex/context/base/mkxl/symb-emj.mkxl index 96c4c0859..96c4c0859 100644 --- a/tex/context/base/mkiv/symb-emj.mkxl +++ b/tex/context/base/mkxl/symb-emj.mkxl diff --git a/tex/context/base/mkiv/symb-ini.mkxl b/tex/context/base/mkxl/symb-ini.mkxl index 53a1f8979..1d1f66c17 100644 --- a/tex/context/base/mkiv/symb-ini.mkxl +++ b/tex/context/base/mkxl/symb-ini.mkxl @@ -74,10 +74,10 @@ \permanent\tolerant\protected\def\definesymbol[#1]#*[#2]#*[#3]% {\ifparameter#3\or - \setvalue{\??symbol#1:#2}{#3}% + \defcsname\??symbol#1:#2\endcsname{#3}% \doifsomething{#1}{\addvalue{\??symbolset#1}{#2}}% \else - \setvalue{\??symbol\m_symb_current_set:#1}{#2}% + \defcsname\??symbol\m_symb_current_set:#1\endcsname{#2}% \addvalue{\??symbolset\m_symb_current_set}{#1}% \fi} @@ -174,8 +174,7 @@ \ifdim\wd\scratchbox>\zeropoint \unhbox\scratchbox \endgroup - \setxvalue{\??symbol#1:\currentsymbol}% - {\symb_place_named_indeed{#1}{\currentsymbol}}% + \xdefcsname\??symbol#1:\currentsymbol\endcsname{\symb_place_named_indeed{#1}{\currentsymbol}}% \settrue\c_symb_found \else \endgroup @@ -297,7 +296,7 @@ \getdummyparameters[\s!font=,#2]% \edef\p_font{\dummyparameter\s!font}% \ifempty\p_font\else - \letvalue{\??symboldefault#1}\p_font + \letcsname\??symboldefault#1\endcsname\p_font \fi \fi} @@ -312,7 +311,7 @@ \def\symb_setup_symbol_set {\normalexpanded{\t_symb_setups{\symb_fetch{\currentsymbolset}\the\t_symb_setups}}% - \letvalue{\??symbolsets\currentsymbolset}\empty} % speedup + \letcsname\??symbolsets\currentsymbolset\endcsname\empty} % speedup \permanent\protected\def\resetsymbolset {\t_symb_setups\emptytoks} diff --git a/tex/context/base/mkiv/syst-aux.lmt b/tex/context/base/mkxl/syst-aux.lmt index c0de8a953..c0de8a953 100644 --- a/tex/context/base/mkiv/syst-aux.lmt +++ b/tex/context/base/mkxl/syst-aux.lmt diff --git a/tex/context/base/mkiv/syst-aux.mkxl b/tex/context/base/mkxl/syst-aux.mkxl index 5410590a6..8fc9d6e02 100644 --- a/tex/context/base/mkiv/syst-aux.mkxl +++ b/tex/context/base/mkxl/syst-aux.mkxl @@ -48,6 +48,10 @@ %D This overloads the \ETEX\ primitive but as we already had an \MKII\ solution we %D keep the same name for a similar mechanism. So, effectively we have two ways to %D protect a macro. +%D +%D In \LMTX\ we try to avoid this and use \type {\protected} instead, which is +%D possible because over time we got rid of using the \CONTEXT\ macro with that +%D name. \pushoverloadmode @@ -83,7 +87,7 @@ \writestatus\m!system{duplicate system namespace '#1'}\wait \else \global\advance\c_syst_helpers_n_of_namespaces\plusone - \expandafter\edef\csname ??#1\endcsname{\v_interfaces_prefix_template_system}% + \edefcsname ??#1\endcsname{\v_interfaces_prefix_template_system}% \fi} %D \macros @@ -364,21 +368,21 @@ %D As we will see, \CONTEXT\ uses these commands many times, which is mainly due to %D its object oriented and parameter driven character. -\permanent\def\setvalue #1{\expandafter\defcsname#1\endcsname} -\permanent\def\setgvalue #1{\global\defcsname#1\endcsname} +\permanent\def\setvalue #1{\defcsname #1\endcsname} +\permanent\def\setgvalue #1{\gdefcsname#1\endcsname} \permanent\def\setevalue #1{\edefcsname#1\endcsname} -\permanent\def\setxvalue #1{\global\edefcsname#1\endcsname} +\permanent\def\setxvalue #1{\xdefcsname#1\endcsname} \permanent\def\getvalue #1{\csname#1\endcsname} % maybe: \begincsname#1\endcsname -\permanent\def\letvalue #1{\letcsname#1\endcsname} -\permanent\def\letgvalue #1{\global\letcsname#1\endcsname} +\permanent\def\letvalue #1{\letcsname #1\endcsname} +\permanent\def\letgvalue #1{\gletcsname#1\endcsname} \permanent\def\resetvalue #1{\letcsname#1\endcsname\empty} \permanent\def\undefinevalue#1{\letcsname#1\endcsname\undefined} \permanent\def\ignorevalue#1#2{\letcsname#1\endcsname\empty} -\permanent\def\setuvalue #1{\protected\defcsname#1\endcsname} +\permanent\def\setuvalue #1{\protected\defcsname #1\endcsname} \permanent\def\setuevalue #1{\protected\edefcsname#1\endcsname} -\permanent\def\setugvalue #1{\protected\global\defcsname#1\endcsname} -\permanent\def\setuxvalue #1{\protected\global\edefcsname#1\endcsname} +\permanent\def\setugvalue #1{\protected\gdefcsname#1\endcsname} +\permanent\def\setuxvalue #1{\protected\xdefcsname#1\endcsname} \permanent\protected\def\getuvalue#1{\csname#1\endcsname} @@ -467,7 +471,7 @@ {\ifcsname#1\endcsname\letcsname#1\endcsname\undefined\fi} \permanent\protected\def\globalundefine#1% conditional - {\ifcsname#1\endcsname\global\letcsname#1\endcsname\undefined\fi} + {\ifcsname#1\endcsname\gletcsname#1\endcsname\undefined\fi} %D Beware, being \type {\undefined} in \ETEX\ means that the macro {\em is} defined! %D @@ -617,10 +621,10 @@ %D These are normally only used for keywords, i.e.\ strings so we can delegate %D the work to \LUA: -%unexpanded\def\doifelseinset#1#2{\clf_doifelseinset{#1}{#2}} -%unexpanded\def\doifinset #1#2{\clf_doifinset {#1}{#2}} -%unexpanded\def\doifnotinset #1#2{\clf_doifnotinset {#1}{#2}} -% % \let\firstinset \clf_firstinset +%protected\def\doifelseinset#1#2{\clf_doifelseinset{#1}{#2}} +%protected\def\doifinset #1#2{\clf_doifinset {#1}{#2}} +%protected\def\doifnotinset #1#2{\clf_doifnotinset {#1}{#2}} +% % \let\firstinset \clf_firstinset % These don't accept spaces after commas: % @@ -779,7 +783,7 @@ %D arguments state. Again it permits leaner and meaner macro definitions with a bit %D less clutter in tracing. -\let\commalistcommand\empty +\mutable\let\commalistcommand\empty \protected\def\syst_helpers_process_comma_item#+,% {\ifarguments @@ -902,6 +906,8 @@ \let\syst_helpers_comma_list_step\relax +\mutable\let\currentcommalistitem\empty + \permanent\protected\def\startprocesscommalist[#1]#2\stopprocesscommalist {\def\syst_helpers_comma_list_step##1{\def\currentcommalistitem{##1}#2}% \processcommalist[#1]\syst_helpers_comma_list_step} @@ -956,6 +962,8 @@ %D this more hip and a bit faster now but \unknown\ it's seldom used nowadays as we %D have better ways now. +\mutable\let\commalistelement\empty + \protected\def\syst_helpers_do_compare_process_action_a[#1=>#2][#3]% {\edef\m_syst_string_two{#1}% \ifx\m_syst_string_two\s!default @@ -1072,8 +1080,8 @@ %D A two step expansion is used to prevent problems with complicated arguments, for %D instance arguments that consist of two or more expandable tokens. -\let\firstcharacter \empty -\let\remainingcharacters\empty +\mutable\let\firstcharacter \empty +\mutable\let\remainingcharacters\empty \permanent\protected\def\getfirstcharacter #1{\clf_getfirstcharacter{#1}} \permanent\protected\def\doifelsefirstchar #1#2{\clf_doifelsefirstchar{#1}{#2}} @@ -1252,7 +1260,7 @@ \expandafter\firstofoneargument \fi} -\let\doifnumberelse\doifelsenumber +\aliased\let\doifnumberelse\doifelsenumber %D \macros %D {setpercentdimen} @@ -1338,7 +1346,7 @@ \expandafter\secondoftwoarguments \fi} -\protected\def\rawdoifelseinset#1% +\permanent\protected\def\rawdoifelseinset#1% {\edef\m_syst_sub_string{#1}% expand #1 here \ifempty\m_syst_sub_string \expandafter\thirdofthreearguments @@ -1468,7 +1476,7 @@ \protected\def\showassignerror#1#2% {\writestatus{setup}{missing or ungrouped '=' after '#1' in line #2}} -\protected\def\doassignempty[#1][#2=#3]% +\permanent\protected\def\doassignempty[#1][#2=#3]% kind of obsolete {\ifcsname#1#2\endcsname\else\dosetvalue{#1}{#2}{#3}\fi} %D \macros @@ -1590,9 +1598,9 @@ %D We now just alias these as there is no need for a speedup. These have not been used %D for a long time in core code. -\let\doassign \getparameters -\let\doeassign \geteparameters -\let\undoassign\forgetparameters +\aliased\let\doassign \getparameters % obsolete, these will go +\aliased\let\doeassign \geteparameters % obsolete, these will go +\aliased\let\undoassign\forgetparameters % obsolete, these will go %D \macros %D {processassignmentlist,processassignmentcommand, @@ -1608,6 +1616,10 @@ %D We can optimize this one if needed but it's not a core macro so hardly worth the %D trouble and tokens. +\mutable\let\currentassignmentlistcommand\gobbletwoarguments +\mutable\let\currentassignmentlistkey \empty +\mutable\let\currentassignmentlistvalue \empty + \permanent\protected\def\processassignmentlist[#1]#2% #2 == \command{key}{value] {\def\syst_helpers_process_assignment_entry##1{#2}% {##2}{##3} % namespace is ignored \dogetparameters\syst_helpers_process_assignment_entry[][#1]} @@ -1619,10 +1631,14 @@ {\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}% \processassignmentlist[#1]\currentassignmentlistcommand} +\aliased\let\stopprocessassignmentlist\relax + \permanent\protected\def\startprocessassignmentcommand[#1]#2\stopprocessassignmentcommand {\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}% \normalexpanded{\processassignmentlist[#1]}\currentassignmentlistcommand} +\aliased\let\stopprocessassignmentcommand\relax + %D \macros %D {currentvalue} %D @@ -1718,7 +1734,7 @@ \newcount\commalistcounter -\def\commalistsize{0} +\mutable\def\commalistsize{0} \def\syst_helpers_get_comma_list_size#0,% no #- as we need to count {\ifarguments\or @@ -1726,7 +1742,7 @@ \expandafter\syst_helpers_get_comma_list_size \fi} -\protected\def\getcommalistsize[% +\permanent\protected\def\getcommalistsize[% {\futureexpand]\syst_helpers_get_comma_list_size_nop\syst_helpers_get_comma_list_size_yes} \def\syst_helpers_get_comma_list_size_yes#+]% @@ -2746,10 +2762,10 @@ \permanent\protected\def\letempty #1{\let #1\empty} \permanent\protected\def\globalletempty#1{\glet#1\empty} -\permanent\protected\def\letvalueempty #1{\letcsname #1\endcsname\empty} -\permanent\protected\def\letgvalueempty#1{\global\letcsname#1\endcsname\empty} -\permanent\protected\def\letvaluerelax #1{\letcsname #1\endcsname\relax} -\permanent\protected\def\letgvalurelax #1{\global\letcsname#1\endcsname\relax} +\permanent\protected\def\letvalueempty #1{\letcsname #1\endcsname\empty} +\permanent\protected\def\letgvalueempty#1{\gletcsname#1\endcsname\empty} +\permanent\protected\def\letvaluerelax #1{\letcsname #1\endcsname\relax} +\permanent\protected\def\letgvalurelax #1{\gletcsname#1\endcsname\relax} \permanent\protected\def\relaxvalueifundefined#1% {\ifcsname#1\endcsname \else @@ -3108,11 +3124,11 @@ \newcount\outerrecurse \newcount\innerrecurse -\def\recursedepth{\the\outerrecurse} -\def\recurselevel{0} +\mutable\def\recursedepth{\the\outerrecurse} +\mutable\def\recurselevel{0} -\let\recurseaction\relax -\let\recursestring\empty +\mutable\let\recurseaction\relax +\mutable\let\recursestring\empty % \let\syst_helpers_stepwise_next\relax @@ -3461,16 +3477,18 @@ %D \def\MyMacro#1{(#1)} \ctxluamatch \MyMacro {(.)} {abcd} %D \stoptyping +\aliased\let\matchloopcommand\relax + \permanent\protected\def\doloopovermatch#1#2#3% {\pushmacro\matchloopcommand - \def\matchloopcommand##1##2##3##4##5##6##7##8##9{#3}% + \enforced\def\matchloopcommand##1##2##3##4##5##6##7##8##9{#3}% \ctxluamatch\matchloopcommand{#1}{#2}% \popmacro\matchloopcommand} \permanent\def\doloopovermatched#1#2#3% {\beginlocalcontrol \pushmacro\matchloopcommand - \def\matchloopcommand##1##2##3##4##5##6##7##8##9{#3}% + \enforced\def\matchloopcommand##1##2##3##4##5##6##7##8##9{#3}% \endlocalcontrol \the\ctxluamatch\matchloopcommand{#1}{#2}% \beginlocalcontrol @@ -4058,26 +4076,26 @@ %D {\groupedcommand{\raggedcenter\bf}{\par}} %D \stoptyping -%D \macros -%D {checkdefined} -%D -%D The bigger the system, the greater the change that user defined commands collide -%D with those that are part of the system. The next macro gives a warning when a -%D command is already defined. We considered blocking the definition, but this is -%D not always what we want. -%D -%D \starttyping -%D \checkdefined {category} {class} {command} -%D \stoptyping -%D -%D The user is warned with the suggestion to use \type {CAPITALS}. This suggestion -%D is feasible, because \CONTEXT only defines lowcased macros. - -\protected\def\showdefinederror#1#2% - {\writestatus\m!system{#1 #2 replaces a macro, use CAPITALS!}} - -\protected\def\checkdefined#1#2#3% - {\doifdefined{#3}{\showdefinederror{#2}{#3}}} +% %D \macros +% %D {checkdefined} +% %D +% %D The bigger the system, the greater the change that user defined commands collide +% %D with those that are part of the system. The next macro gives a warning when a +% %D command is already defined. We considered blocking the definition, but this is +% %D not always what we want. +% %D +% %D \starttyping +% %D \checkdefined {category} {class} {command} +% %D \stoptyping +% %D +% %D The user is warned with the suggestion to use \type {CAPITALS}. This suggestion +% %D is feasible, because \CONTEXT only defines lowcased macros. These are obsolete: +% +% \protected\def\showdefinederror#1#2% +% {\writestatus\m!system{#1 #2 replaces a macro, use CAPITALS!}} +% +% \protected\def\checkdefined#1#2#3% +% {\doifdefined{#3}{\showdefinederror{#2}{#3}}} %D \macros %D {GotoPar,GetPar} @@ -4416,6 +4434,9 @@ \newtoks \collectingtoks +\aliased\let\stopcollect \relax +\aliased\let\stopexpandedcollect\relax + \permanent\protected\def\startcollect #1\stopcollect {\toksapp \collectingtoks{#1}} \permanent\protected\def\startexpandedcollect#1\stopexpandedcollect{\etoksapp\collectingtoks{#1}} @@ -4766,7 +4787,7 @@ \newcount\c_syst_helpers_comma_list_index \let \m_syst_helpers_comma_list_target\empty -\let\newcommalistelement\empty +\mutable\let\newcommalistelement\empty \def\syst_helpers_replace_in_comma_list_step#1% we can use #+ here too {\ifnum\commalistcounter=\c_syst_helpers_comma_list_index\relax @@ -4941,7 +4962,7 @@ \newdimen\localhsize -\protected\def\setlocalhsize % don't change ! +\permanent\protected\def\setlocalhsize % don't change ! {\doifelsenextoptional \syst_helpers_set_local_hsize_yes \syst_helpers_set_local_hsize_nop} @@ -5565,7 +5586,7 @@ %D %D But, as we run a recent version of \TEX, we can use the new primitive: -\ifdefined\normalquitvmode \let\dontleavehmode\normalquitvmode \fi +\aliased\let\dontleavehmode\quitvmode %D \macros %D {utfupper, utflower, uppercasestring, lowercasestring} @@ -5905,6 +5926,8 @@ \let\syst_helpers_serialize_comma_list_step\relax +\mutable\let\serializedcommalist\empty + \def\syst_helpers_serialize_comma_list_step#1% {\edef\serializedcommalist{\serializedcommalist#1}} @@ -6006,10 +6029,10 @@ \permanent\tolerant\protected\def\definemeasure[#1]#*[#2]{\defcsname \??measure#1\endcsname{#2}} \permanent\tolerant\protected\def\freezemeasure[#1]#*[#2]{\edefcsname\??measure#1\endcsname{\the\dimexpr#2}} -\permanent\protected\def\setmeasure #1#2{\defcsname \??measure#1\endcsname{#2}} % quick way -\permanent\protected\def\setgmeasure#1#2{\global\defcsname \??measure#1\endcsname{#2}} % quick way -\permanent\protected\def\setemeasure#1#2{\edefcsname \??measure#1\endcsname{\the\dimexpr#2}} % quick way -\permanent\protected\def\setxmeasure#1#2{\global\edefcsname\??measure#1\endcsname{\the\dimexpr#2}} % quick way +\permanent\protected\def\setmeasure #1#2{\defcsname \??measure#1\endcsname{#2}} % quick way +\permanent\protected\def\setgmeasure#1#2{\gdefcsname\??measure#1\endcsname{#2}} % quick way +\permanent\protected\def\setemeasure#1#2{\edefcsname\??measure#1\endcsname{\the\dimexpr#2}} % quick way +\permanent\protected\def\setxmeasure#1#2{\xdefcsname\??measure#1\endcsname{\the\dimexpr#2}} % quick way \permanent\def\measure {\the\measured} \permanent\def\measured#1{\dimexpr\ifcsname\??measure#1\endcsname\lastnamedcs\else\zeropoint\fi\relax} @@ -6030,10 +6053,10 @@ \permanent\tolerant\protected\def\definequantity[#1]#*[#2]{\defcsname \??quantity#1\endcsname{#2}} \permanent\tolerant\protected\def\freezequantity[#1]#*[#2]{\edefcsname\??quantity#1\endcsname{\the\numexpr#2}} -\permanent\protected\def\setquantity #1#2{\defcsname \??quantity#1\endcsname{#2}} % quick way -\permanent\protected\def\setgquantity#1#2{\global\defcsname \??quantity#1\endcsname{#2}} % quick way -\permanent\protected\def\setequantity#1#2{\edefcsname \??quantity#1\endcsname{\the\numexpr#2}} % quick way -\permanent\protected\def\setxquantity#1#2{\global\edefcsname\??quantity#1\endcsname{\the\numexpr#2}} % quick way +\permanent\protected\def\setquantity #1#2{\defcsname \??quantity#1\endcsname{#2}} % quick way +\permanent\protected\def\setgquantity#1#2{\gdefcsname\??quantity#1\endcsname{#2}} % quick way +\permanent\protected\def\setequantity#1#2{\edefcsname\??quantity#1\endcsname{\the\numexpr#2}} % quick way +\permanent\protected\def\setxquantity#1#2{\xdefcsname\??quantity#1\endcsname{\the\numexpr#2}} % quick way \permanent\def\quantity {\the\quantitied} \permanent\def\quantitied #1{\numexpr\ifcsname\??quantity#1\endcsname\lastnamedcs\else\zeropoint\fi\relax} @@ -6159,7 +6182,7 @@ \permanent\protected\def\unspaceargument#1\to#2% {\edef#2{\tokenized \s!catcodetable \ctdcatcodes {#1}}} -\protected\def\unspaceafter#1#2% +\permanent\protected\def\unspaceafter#1#2% {\expandafter#1\expandafter{\tokenized \s!catcodetable \ctdcatcodes {#2}}} \permanent\protected\def\doifelsehasspace#1% @@ -6175,8 +6198,8 @@ \installsystemnamespace{flag} -\protected\def\setflag #1{\dodoglobal\letcsname\??flag#1\endcsname\zerocount} -\protected\def\resetflag#1{\dodoglobal\letcsname\??flag#1\endcsname\plusone} +\permanent\protected\def\setflag #1{\dodoglobal\letcsname\??flag#1\endcsname\zerocount} +\permanent\protected\def\resetflag#1{\dodoglobal\letcsname\??flag#1\endcsname\plusone} \permanent\def\flag#1{\csname\??flag#1\endcsname} @@ -6255,7 +6278,7 @@ \def\syst_helpers_unprotected#1\par {#1\protect} -\protected\def\unprotected +\permanent\protected\def\unprotected {\unprotect \syst_helpers_unprotected} @@ -6335,6 +6358,8 @@ %D \if-\whatever \else-\whatever\fi => else => -whatever %D \if--\whatever\else-\whatever\fi => then => whatever %D \stoptyping +%D +%D Do we still need this? If not it will go away: \permanent\def\negated#1{\if-#1\else-#1\fi} % does only work in macros or text @@ -6343,17 +6368,18 @@ \permanent\def\assigndimen#1#2% {\afterassignment\gobbleassigndimen#1=#2\zeropoint\\} -\permanent\protected\def\appended#1#2#3{\expandafter#1\expandafter#2\expandafter{#2#3}} -\permanent\protected\def\appendvalue #1{\expandafter\appended\expandafter \def\csname#1\endcsname} -\permanent\protected\def\appendgvalue#1{\expandafter\appended\expandafter\gdef\csname#1\endcsname} +%D Maybe ... toksapp should deal with this ... + +\permanent\protected\def\appendvalue #1#2% + {\defcsname#1\expandafter\expandafter\expandafter\endcsname\expandafter\expandafter\expandafter + {\begincsname#1\endcsname#2}} -\protected\def\prepended#1#2#3% - {\t_syst_helpers_scratch{#3}% - \expandafter\expandafter\expandafter#1\expandafter\expandafter\expandafter#2\expandafter\expandafter\expandafter - {\expandafter\the\expandafter\t_syst_helpers_scratch#2}} +\permanent\protected\def\prependvalue #1#2% + {\edefcsname#1\endcsname + {\normalunexpanded{#2}\expandafter\expandafter\expandafter\empty\begincsname#1\endcsname}} -\permanent\protected\def\prependvalue #1{\expandafter\prepended\expandafter \def\csname#1\endcsname} -\permanent\protected\def\prependgvalue#1{\expandafter\prepended\expandafter\gdef\csname#1\endcsname} +\permanent\protected\def\appendgvalue #1#2{\global\appendvalue} +\permanent\protected\def\prependgvalue#1#2{\global\prependvalue} %D \macros %D {dowithrange} diff --git a/tex/context/base/mkxl/syst-cmp.mkxl b/tex/context/base/mkxl/syst-cmp.mkxl new file mode 100644 index 000000000..a5ebdd8e3 --- /dev/null +++ b/tex/context/base/mkxl/syst-cmp.mkxl @@ -0,0 +1,22 @@ +%D \module +%D [ file=syst-cmp, +%D version=2018.12.05, +%D title=\CONTEXT\ System Macros, +%D subtitle=Compatibility, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Some code that has been laying around for generic compatibility is (and will be) +%D moved here, for instance because tikz needs it. At some point I will make an +%D indirect interface for generic code (if needed). + +\registerctxluafile{syst-cmp}{} + +\unprotect + +\protect \endinput diff --git a/tex/context/base/mkiv/syst-con.mkxl b/tex/context/base/mkxl/syst-con.mkxl index ed4a4f3c5..ed4a4f3c5 100644 --- a/tex/context/base/mkiv/syst-con.mkxl +++ b/tex/context/base/mkxl/syst-con.mkxl diff --git a/tex/context/base/mkiv/syst-fnt.mkxl b/tex/context/base/mkxl/syst-fnt.mkxl index f0f023f6e..f0f023f6e 100644 --- a/tex/context/base/mkiv/syst-fnt.mkxl +++ b/tex/context/base/mkxl/syst-fnt.mkxl diff --git a/tex/context/base/mkiv/syst-ini.mkxl b/tex/context/base/mkxl/syst-ini.mkxl index d495e12af..50fe1c1bb 100644 --- a/tex/context/base/mkiv/syst-ini.mkxl +++ b/tex/context/base/mkxl/syst-ini.mkxl @@ -144,16 +144,16 @@ function tex.enableprimitives() end % so we kind of protect what's there } -\permanent\def\space{ } -\permanent\def\empty{} +\immutable\def\space{ } +\immutable\def\empty{} -\permanent\letcharcode \formfeedasciicode \par % \def ^^L{\par} formfeed -\permanent\letcharcode \tildeasciicode \ % tilde -\permanent\letcharcode \spaceasciicode \space % space +\immutable\letcharcode \formfeedasciicode \par % \def ^^L{\par} formfeed +\immutable\letcharcode \tildeasciicode \ % tilde +\immutable\letcharcode \spaceasciicode \space % space -\permanent\defcsname\Uchar\tabasciicode \endcsname {\ } % \def\^^I{\ } tab -\permanent\defcsname\Uchar\formfeedasciicode \endcsname {\par} % \def\^^L{\par} formfeed -\permanent\defcsname\Uchar\endoflineasciicode\endcsname {\ } % \def\^^M{\ } return +\immutable\defcsname\Uchar\tabasciicode \endcsname {\ } % \def\^^I{\ } tab +\immutable\defcsname\Uchar\formfeedasciicode \endcsname {\par} % \def\^^L{\par} formfeed +\immutable\defcsname\Uchar\endoflineasciicode\endcsname {\ } % \def\^^M{\ } return %D For now: @@ -347,7 +347,7 @@ %D is reserved for special purposes (this might change). Attributes in the range %D 128-1023 are private and should not be touched. -\permanent\integerdef\attributeunsetvalue\c_syst_min_counter_value % used to be \minusone +\immutable\integerdef\attributeunsetvalue\c_syst_min_counter_value % used to be \minusone % \permanent\protected\def\newattribute{\syst_basics_allocate\c_syst_last_allocated_attribute\attribute\attributedef\c_syst_max_allocated_register} @@ -470,37 +470,37 @@ %D but can use chardefs for positive ones. Actually, because we have plenty of counters we %D can also use counts for those. -%permanent\integerdef\minusone -1 -\permanent\integerdef\minustwo -2 -%permanent\integerdef\zerocount 0 -%permanent\integerdef\plusone 1 -\permanent\integerdef\plustwo 2 -\permanent\integerdef\plusthree 3 -\permanent\integerdef\plusfour 4 -\permanent\integerdef\plusfive 5 -\permanent\integerdef\plussix 6 -\permanent\integerdef\plusseven 7 -\permanent\integerdef\pluseight 8 -\permanent\integerdef\plusnine 9 -\permanent\integerdef\plusten 10 -\permanent\integerdef\pluseleven 11 -\permanent\integerdef\plustwelve 12 -\permanent\integerdef\plussixteen 16 -\permanent\integerdef\plusfifty 50 -\permanent\integerdef\plushundred 100 -\permanent\integerdef\plusonehundred 100 -\permanent\integerdef\plustwohundred 200 -\permanent\integerdef\plusfivehundred 500 -\permanent\integerdef\pluscxxvii 127 -\permanent\integerdef\pluscxxviii 128 -\permanent\integerdef\pluscclv 255 -\permanent\integerdef\pluscclvi 256 -\permanent\integerdef\plusthousand 1000 -\permanent\integerdef\plustenthousand 10000 -\permanent\integerdef\plustwentythousand 20000 -\permanent\integerdef\medcard 32768 -\permanent\integerdef\maxcard 65536 % pdftex has less mathchars -\permanent\integerdef\maxcardminusone 65535 +%immutable\integerdef\minusone -1 +\immutable\integerdef\minustwo -2 +%immutable\integerdef\zerocount 0 +%immutable\integerdef\plusone 1 +\immutable\integerdef\plustwo 2 +\immutable\integerdef\plusthree 3 +\immutable\integerdef\plusfour 4 +\immutable\integerdef\plusfive 5 +\immutable\integerdef\plussix 6 +\immutable\integerdef\plusseven 7 +\immutable\integerdef\pluseight 8 +\immutable\integerdef\plusnine 9 +\immutable\integerdef\plusten 10 +\immutable\integerdef\pluseleven 11 +\immutable\integerdef\plustwelve 12 +\immutable\integerdef\plussixteen 16 +\immutable\integerdef\plusfifty 50 +\immutable\integerdef\plushundred 100 +\immutable\integerdef\plusonehundred 100 +\immutable\integerdef\plustwohundred 200 +\immutable\integerdef\plusfivehundred 500 +\immutable\integerdef\pluscxxvii 127 +\immutable\integerdef\pluscxxviii 128 +\immutable\integerdef\pluscclv 255 +\immutable\integerdef\pluscclvi 256 +\immutable\integerdef\plusthousand 1000 +\immutable\integerdef\plustenthousand 10000 +\immutable\integerdef\plustwentythousand 20000 +\immutable\integerdef\medcard 32768 +\immutable\integerdef\maxcard 65536 % pdftex has less mathchars +\immutable\integerdef\maxcardminusone 65535 %D \macros %D {doubleexpandafter,tripleexpandafter,expanded,startexpanded} @@ -595,8 +595,8 @@ % We wrap all into one macro (the frozen stuff adds 10% runtime): \permanent\protected\def\newif#1% - {\permanent\protected\global\defcsname\expandafter\new_if_check\csstring#1true\endcsname {\overloaded\frozen\let#1\iftrue }% - \permanent\protected\global\defcsname\expandafter\new_if_check\csstring#1false\endcsname{\overloaded\frozen\let#1\iffalse}% + {\permanent\protected\gdefcsname\expandafter\new_if_check\csstring#1true\endcsname {\overloaded\frozen\let#1\iftrue }% + \permanent\protected\gdefcsname\expandafter\new_if_check\csstring#1false\endcsname{\overloaded\frozen\let#1\iffalse}% \csname\expandafter\new_if_check\csstring#1false\endcsname} \normalexpanded{\gdef\noexpand\new_if_check\string i\string f{}} @@ -614,22 +614,33 @@ %D A few shortcuts: -\permanent\protected\def\udef {\protected\def } -\permanent\protected\def\ugdef{\protected\gdef} -\permanent\protected\def\uedef{\protected\edef} -\permanent\protected\def\uxdef{\protected\xdef} +% \permanent\protected\def\udef {\protected\def } +% \permanent\protected\def\ugdef{\protected\gdef} +% \permanent\protected\def\uedef{\protected\edef} +% \permanent\protected\def\uxdef{\protected\xdef} -%D For a while we keep the following, as systems like tikz need it. Best -%D not use that one \CONTEXT. +% For now: + +\permanent\protected\def\defUmathtopaccent #1#2#3#4{\global\immutable\protected\def#1{\Umathaccent "#2 "#3 "#4 }} +\permanent\protected\def\defUmathbotaccent #1#2#3#4{\global\immutable\protected\def#1{\Umathbotaccent "#2 "#3 "#4 }} +\permanent\protected\def\defUdelimiterover #1#2#3#4{\global\immutable\protected\def#1{\Udelimiterover "#2 "#3 }} +\permanent\protected\def\defUdelimiterunder #1#2#3#4{\global\immutable\protected\def#1{\Udelimiterunder "#2 "#3 }} +\permanent\protected\def\defUdelimiter #1#2#3#4{\global\immutable\protected\def#1{\Udelimiter "#2 "#3 "#4 }} +\permanent\protected\def\defUradical #1#2#3{\global\immutable\protected\def#1{\Uradical "#2 "#3 }} +\permanent\protected\def\defUroot #1#2#3{\global\immutable\protected\def#1{\Uroot "#2 "#3 }} +\permanent\protected\def\defUmathchar #1#2#3#4{\global\immutable\Umathchardef #1 "#2 "#3 "#4 } + +%D For a while we keep the following, as systems like tikz need it. Best not use +%D that one \CONTEXT. \aliased\let\active\activecatcode %D Constants to be used with \type {\interactionmode}. -\permanent\integerdef\batchmodecode \zerocount -\permanent\integerdef\nonstopmodecode \plusone -\permanent\integerdef\scrollmodecode \plustwo -\permanent\integerdef\errorstopmodecode \plusthree +\immutable\integerdef\batchmodecode \zerocount +\immutable\integerdef\nonstopmodecode \plusone +\immutable\integerdef\scrollmodecode \plustwo +\immutable\integerdef\errorstopmodecode \plusthree %D Of course we want even bigger log files, so we copied this from the \ETEX\ %D source files. diff --git a/tex/context/base/mkiv/syst-lua.lmt b/tex/context/base/mkxl/syst-lua.lmt index 673c99ae3..673c99ae3 100644 --- a/tex/context/base/mkiv/syst-lua.lmt +++ b/tex/context/base/mkxl/syst-lua.lmt diff --git a/tex/context/base/mkiv/syst-lua.mkxl b/tex/context/base/mkxl/syst-lua.mkxl index 615562200..158682399 100644 --- a/tex/context/base/mkiv/syst-lua.mkxl +++ b/tex/context/base/mkxl/syst-lua.mkxl @@ -45,7 +45,11 @@ \immutable\edef\!!bs{[\luastringsep[} \immutable\edef\!!es{]\luastringsep]} -\permanent\overloaded\protected\def\writestatus#1#2{\clf_writestatus{#1}{#2}} +\pushoverloadmode + +\permanent\protected\def\writestatus#1#2{\clf_writestatus{#1}{#2}} + +\popoverloadmode %D We can omit the tex.ctxcatcodes here as nowadays we seldom change the regime at %D the \TEX\ end: diff --git a/tex/context/base/mkiv/syst-mac.lmt b/tex/context/base/mkxl/syst-mac.lmt index 410a49f8b..410a49f8b 100644 --- a/tex/context/base/mkiv/syst-mac.lmt +++ b/tex/context/base/mkxl/syst-mac.lmt diff --git a/tex/context/base/mkxl/syst-mes.mkxl b/tex/context/base/mkxl/syst-mes.mkxl new file mode 100644 index 000000000..166be16e3 --- /dev/null +++ b/tex/context/base/mkxl/syst-mes.mkxl @@ -0,0 +1,20 @@ +%D \module +%D [ file=syst-mes, +%D version=2010.06.03, +%D title=\CONTEXT\ System Macros, +%D subtitle=Messages, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +% These will be overloaded later on: + +\protected\def\writestring{\immediate\write\statuswrite} +\protected\def\writeline {\writestring{}} +% \let\message \normalmessage + +\endinput diff --git a/tex/context/base/mkxl/syst-pln.mkxl b/tex/context/base/mkxl/syst-pln.mkxl new file mode 100644 index 000000000..38ec9c4c1 --- /dev/null +++ b/tex/context/base/mkxl/syst-pln.mkxl @@ -0,0 +1,119 @@ +%D \module +%D [ file=syst-pln, +%D version=2001.11.16, % 1999.03.17, % an oldie: 1995.10.10 +%D title=\CONTEXT\ System Macros, +%D subtitle=Efficient \PLAIN\ \TEX\ loading, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +%D This module set a couple of variables to the plain \TEX\ values. Later they might +%D be overloaded. There is not much difference between \MKII\ and \MKIV\ but at some +%D point they might diverge. + +%D Build||in numeric variables. + +\adjdemerits = 10000 +\binoppenalty = 700 +\brokenpenalty = 100 +\clubpenalty = 150 +%day = 0 +\defaulthyphenchar = `\- +\defaultskewchar = -1 +\delimiterfactor = 901 +\displaywidowpenalty = 50 +\doublehyphendemerits = 10000 +%endlinechar = `\^^M +\errorcontextlines = 5 +%escapechar = `\\ +\exhyphenpenalty = 50 +%fam = 0 +\finalhyphendemerits = 5000 +%floatingpenalty = 0 +%globaldefs = 0 +\hangafter = 1 % automatically set to 1 (no zero assignment) +\hbadness = 1000 +%holdinginserts = 0 +\hyphenpenalty = 50 +%interlinepenalty = 0 +%language = 0 +\lefthyphenmin = 2 +\linepenalty = 10 +%looseness = 0 +%mag = 1000 +%maxdeadcycles = 25 +%month = 0 +%newlinechar = -1 % commented i.e. no plain value +%outputpenalty = 0 +%pausing = 0 +%postdisplaypenalty = 0 +\predisplaypenalty = 10000 +\pretolerance = 100 +\relpenalty = 500 +\righthyphenmin = 3 +\showboxbreadth = 5 +\showboxdepth = 3 +%time = 0 +\tolerance = 200 +%tracingcommands = 0 +\tracinglostchars = 1 +%tracingmacros = 0 +%tracingonline = 0 +%tracingoutput = 0 +%tracingpages = 0 +%tracingparagraphs = 0 +%tracingrestores = 0 +%tracingstats = 0 +\uchyph = 1 +\vbadness = 1000 +\widowpenalty = 150 +%year = 0 + +%D Build in dimension variables. + +\abovedisplayshortskip = 0pt plus 3pt +\abovedisplayskip = 12pt plus 3pt minus 9pt +%baselineskip = 0pt +\belowdisplayshortskip = 7pt plus 3pt minus 4pt +\belowdisplayskip = 12pt plus 3pt minus 9pt +\boxmaxdepth = \maxdimen +\delimitershortfall = 5pt +%displayindent = 0pt +%displaywidth = 0pt +%hangindent = 0pt +\hfuzz = 0.1pt +%hoffset = 0pt +\hsize = 6.5in +%leftskip = 0pt +%lineskip = 0pt +%lineskiplimit = 0pt +%mathsurround = 0pt +\maxdepth = 4pt +\medmuskip = 4mu plus 2mu minus 4mu +\nulldelimiterspace = 1.2pt +\overfullrule = 5pt +\parfillskip = 0pt plus 1fil +\parindent = 20pt +\parskip = 0pt plus 1pt +%predisplaysize = 0pt +%rightskip = 0pt +\scriptspace = 0.5pt +%spaceskip = 0pt +\splitmaxdepth = \maxdimen +\splittopskip = 10pt +%tabskip = 0pt +\thickmuskip = 5mu plus 5mu +\thinmuskip = 3mu +\topskip = 10pt +\vfuzz = 0.1pt +%voffset = 0pt +\vsize = 8.9in +%xspaceskip = 0pt + +\protect \endinput diff --git a/tex/context/base/mkxl/syst-rtp.mkxl b/tex/context/base/mkxl/syst-rtp.mkxl new file mode 100644 index 000000000..73aa59ba9 --- /dev/null +++ b/tex/context/base/mkxl/syst-rtp.mkxl @@ -0,0 +1,18 @@ +%D \module +%D [ file=syst-rtp, +%D version=2006.10.13, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Run Time Processes, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +\aliased\let\executesystemcommand\clf_execute % can be public implementor + +\protect \endinput diff --git a/tex/context/base/mkiv/tabl-com.mkxl b/tex/context/base/mkxl/tabl-com.mkxl index 791db656b..791db656b 100644 --- a/tex/context/base/mkiv/tabl-com.mkxl +++ b/tex/context/base/mkxl/tabl-com.mkxl diff --git a/tex/context/base/mkiv/tabl-frm.mkxl b/tex/context/base/mkxl/tabl-frm.mkxl index 9bbc510c5..9bbc510c5 100644 --- a/tex/context/base/mkiv/tabl-frm.mkxl +++ b/tex/context/base/mkxl/tabl-frm.mkxl diff --git a/tex/context/base/mkiv/tabl-ltb.mkxl b/tex/context/base/mkxl/tabl-ltb.mkxl index 5058e26f8..f4558d797 100644 --- a/tex/context/base/mkiv/tabl-ltb.mkxl +++ b/tex/context/base/mkxl/tabl-ltb.mkxl @@ -525,7 +525,7 @@ \def\docommand##1% {\global\advance\c_tabl_lines_n_of_parts\plusone \advance\scratchcounter##1% - \setxvalue{\??linetablepart\number\c_tabl_lines_n_of_parts}{\the\scratchcounter}}% + \xdefcsname\??linetablepart\number\c_tabl_lines_n_of_parts\endcsname{\the\scratchcounter}}% \processcommacommand[\linetableparameter\c!n]\docommand \initializetableboxes\c_tabl_lines_n_of_parts \global\c_tabl_lines_part\ifcase\c_tabl_lines_repeat\plusone\else\zerocount\fi % repeater @@ -673,31 +673,18 @@ \settrialtypesetting \startlinetablerun} -% \protected\def\stoplinetableanalysis -% {\stoplinetablerun -% \egroup -% \global\c_tabl_lines_n_of_rows\c_tabl_lines_rows -% \dorecurse\c_tabl_lines_n_of_rows % global, from last run {\linetableparameter\c!n} -% {\setevalue{\??linetable r:\recurselevel x\c!height}{\getvalue{\??linetableheight\recurselevel}}% -% \setevalue{\??linetable r:\recurselevel x\c!depth }{\getvalue{\??linetabledepth \recurselevel}}% -% \letgvalue{\??linetableheight\recurselevel}\!!zeropoint -% \letgvalue{\??linetabledepth \recurselevel}\!!zeropoint} -% \dorecurse\c_tabl_lines_n_of_columns % global, from last run {\linetableparameter\c!n} -% {\setevalue{\??linetable c:\recurselevel\c!width}{\getvalue{\??linetablewidth\recurselevel}}% -% \letgvalue{\??linetablewidth\recurselevel}\!!zeropoint}} % init next table - \permanent\protected\def\stoplinetableanalysis {\stoplinetablerun \egroup \global\c_tabl_lines_n_of_rows\c_tabl_lines_rows \dorecurse\c_tabl_lines_n_of_rows % global, from last run {\linetableparameter\c!n} - {\setevalue{\??linetable r:##1x\c!height}{\csname\??linetableheight##1\endcsname}% - \setevalue{\??linetable r:##1x\c!depth }{\csname\??linetabledepth ##1\endcsname}% - \letgvalue{\??linetableheight##1}\zeropoint - \letgvalue{\??linetabledepth ##1}\zeropoint} + {\edefcsname\??linetable r:##1x\c!height\endcsname{\csname\??linetableheight##1\endcsname}% + \edefcsname\??linetable r:##1x\c!depth \endcsname{\csname\??linetabledepth ##1\endcsname}% + \gletcsname\??linetableheight##1\endcsname\zeropoint + \gletcsname\??linetabledepth ##1\endcsname\zeropoint} \dorecurse\c_tabl_lines_n_of_columns % global, from last run {\linetableparameter\c!n} - {\setevalue{\??linetable c:##1\c!width}{\csname\??linetablewidth##1\endcsname}% - \letgvalue{\??linetablewidth##1}\zeropoint}} % init next table + {\edefcsname\??linetable c:##1\c!width\endcsname{\csname\??linetablewidth##1\endcsname}% + \gletcsname\??linetablewidth##1\endcsname\zeropoint}} % init next table % todo: store in box instead of macro @@ -732,10 +719,7 @@ \permanent\let\startlinetablebody\relax \permanent\let\stoplinetablebody \relax -\protected\def\processlinetablebuffer - {\dosingleempty\tabl_lines_process_buffer} - -\def\tabl_lines_process_buffer[#1]% +\permanent\tolerant\protected\def\processlinetablebuffer[#1]% {\bgroup \enforced\let\startlinetable\relax \enforced\let\stoplinetable \relax diff --git a/tex/context/base/mkiv/tabl-mis.mkxl b/tex/context/base/mkxl/tabl-mis.mkxl index 14bd08b46..14bd08b46 100644 --- a/tex/context/base/mkiv/tabl-mis.mkxl +++ b/tex/context/base/mkxl/tabl-mis.mkxl diff --git a/tex/context/base/mkiv/tabl-ntb.mkxl b/tex/context/base/mkxl/tabl-ntb.mkxl index 8883a29e3..51e718b9a 100644 --- a/tex/context/base/mkiv/tabl-ntb.mkxl +++ b/tex/context/base/mkxl/tabl-ntb.mkxl @@ -279,10 +279,10 @@ \letvalue{\??naturaltablesqueeze\v!broad}\donetrue \letvalue{\??naturaltablesqueeze\v!local}\donetrue -\def\tabl_ntb_let_gal{\global\letcsname\??naturaltablegal\m_tabl_tbl_level\endcsname} +\def\tabl_ntb_let_gal{\gletcsname\??naturaltablegal\m_tabl_tbl_level\endcsname} \def\tabl_ntb_get_gal{\csname\??naturaltablegal\m_tabl_tbl_level\endcsname} -\def\tabl_ntb_let_tal#1{\global\letcsname\??naturaltabletal\m_tabl_tbl_level:\number#1\endcsname} +\def\tabl_ntb_let_tal#1{\gletcsname\??naturaltabletal\m_tabl_tbl_level:\number#1\endcsname} \def\tabl_ntb_get_tal#1{\csname\??naturaltabletal\m_tabl_tbl_level:\number#1\endcsname} \def\tabl_ntb_set_nob#1{\letcsname\??naturaltablenob\m_tabl_tbl_level:\number#1\endcsname\plusone} @@ -296,11 +296,11 @@ \def\tabl_ntb_let_col#1#2{\letcsname\??naturaltablecol\m_tabl_tbl_level:\number#1:\number#2\endcsname} \def\tabl_ntb_let_row#1#2{\letcsname\??naturaltablerow\m_tabl_tbl_level:\number#1:\number#2\endcsname} -%def\tabl_ntb_set_wd#1#2{\global\edefcsname\??naturaltablewd\m_tabl_tbl_level:\number#1:\number#2\endcsname} % global ! -\def\tabl_ntb_set_ht#1#2{\global\edefcsname\??naturaltableht\m_tabl_tbl_level:\number#1:\number#2\endcsname} % global ! +%def\tabl_ntb_set_wd#1#2{\xdefcsname\??naturaltablewd\m_tabl_tbl_level:\number#1:\number#2\endcsname} % global ! +\def\tabl_ntb_set_ht#1#2{\xdefcsname\??naturaltableht\m_tabl_tbl_level:\number#1:\number#2\endcsname} % global ! -%def\tabl_ntb_let_wd#1#2{\global\letcsname\??naturaltablewd\m_tabl_tbl_level:\number#1:\number#2\endcsname} % global ! -\def\tabl_ntb_let_ht#1#2{\global\letcsname\??naturaltableht\m_tabl_tbl_level:\number#1:\number#2\endcsname} % global ! +%def\tabl_ntb_let_wd#1#2{\letcsname\??naturaltablewd\m_tabl_tbl_level:\number#1:\number#2\endcsname} % global ! +\def\tabl_ntb_let_ht#1#2{\letcsname\??naturaltableht\m_tabl_tbl_level:\number#1:\number#2\endcsname} % global ! \def\tabl_ntb_get_tag#1#2{\csname\??naturaltabletag\m_tabl_tbl_level:\number#1:\number#2\endcsname} \def\tabl_ntb_get_col#1#2{\csname\??naturaltablecol\m_tabl_tbl_level:\number#1:\number#2\endcsname} @@ -309,15 +309,15 @@ %def\tabl_ntb_get_wd#1#2{\csname\??naturaltablewd\m_tabl_tbl_level:\number#1:\number#2\endcsname} \def\tabl_ntb_get_ht#1#2{\csname\??naturaltableht\m_tabl_tbl_level:\number#1:\number#2\endcsname} -\def\tabl_ntb_set_wid#1{\global\edefcsname\??naturaltablewid\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! -\def\tabl_ntb_set_hei#1{\global\edefcsname\??naturaltablehei\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! -\def\tabl_ntb_set_dis#1{\global\edefcsname\??naturaltabledis\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! -\def\tabl_ntb_set_aut#1{\global\edefcsname\??naturaltableaut\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! +\def\tabl_ntb_set_wid#1{\xdefcsname\??naturaltablewid\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! +\def\tabl_ntb_set_hei#1{\xdefcsname\??naturaltablehei\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! +\def\tabl_ntb_set_dis#1{\xdefcsname\??naturaltabledis\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! +\def\tabl_ntb_set_aut#1{\xdefcsname\??naturaltableaut\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! -\def\tabl_ntb_let_wid#1{\global\letcsname\??naturaltablewid\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! -\def\tabl_ntb_let_hei#1{\global\letcsname\??naturaltablehei\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! -\def\tabl_ntb_let_dis#1{\global\letcsname\??naturaltabledis\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! -\def\tabl_ntb_let_aut#1{\global\letcsname\??naturaltableaut\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! +\def\tabl_ntb_let_wid#1{\gletcsname\??naturaltablewid\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! +\def\tabl_ntb_let_hei#1{\gletcsname\??naturaltablehei\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! +\def\tabl_ntb_let_dis#1{\gletcsname\??naturaltabledis\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! +\def\tabl_ntb_let_aut#1{\gletcsname\??naturaltableaut\m_tabl_tbl_level:\number#1\endcsname} % {#2} global ! \def\tabl_ntb_get_wid#1{\ifcsname\??naturaltablewid\m_tabl_tbl_level:\number#1\endcsname\lastnamedcs\else\zeropoint\fi} \def\tabl_ntb_get_hei#1{\ifcsname\??naturaltablehei\m_tabl_tbl_level:\number#1\endcsname\lastnamedcs\else\zeropoint\fi} @@ -353,8 +353,8 @@ % \c_tabl_ntb_none % \fi} -\def\tabl_ntb_let_ref #1#2{\global\letcsname\??naturaltableref\m_tabl_tbl_level:\number#1:\number#2\endcsname} -\def\tabl_ntb_set_ref #1#2{\global\edefcsname\??naturaltableref\m_tabl_tbl_level:\number#1:\number#2\endcsname} +\def\tabl_ntb_let_ref #1#2{\gletcsname\??naturaltableref\m_tabl_tbl_level:\number#1:\number#2\endcsname} +\def\tabl_ntb_set_ref #1#2{\xdefcsname\??naturaltableref\m_tabl_tbl_level:\number#1:\number#2\endcsname} %def\tabl_ntb_get_ref #1#2{\ifcsname\??naturaltableref\m_tabl_tbl_level:\number#1:\number#2\endcsname\csname\??naturaltableref\m_tabl_tbl_level:\number#1:\number#2\endcsname\fi} \def\tabl_ntb_get_ref #1#2{\begincsname\??naturaltableref\m_tabl_tbl_level:\number#1:\number#2\endcsname} @@ -398,9 +398,9 @@ \protected\def\tabl_ntb_cell_process#1#2[#3]{} -\permanent\protected\def\bTC#1\eTC{\bTD#1\eTD} \let\eTC\relax -\permanent\protected\def\bTX#1\eTX{\bTD#1\eTD} \let\eTX\relax -\permanent\protected\def\bTY#1\eTY{\bTR#1\eTR} \let\eTY\relax +\permanent\protected\def\bTC#1\eTC{\bTD#1\eTD} \aliased\let\eTC\relax +\permanent\protected\def\bTX#1\eTX{\bTD#1\eTD} \aliased\let\eTX\relax +\permanent\protected\def\bTY#1\eTY{\bTR#1\eTR} \aliased\let\eTY\relax \let\tabl_ntb_parameters_get\setupcurrentnaturaltablelocal @@ -468,14 +468,14 @@ {\ifappendTBLsetups \ifcsname\??naturaltableset\m_tabl_tbl_level:#1\endcsname \enforced\def\tabl_ntb_parameters_get[##1]% - {\setvalue{\??naturaltableset\m_tabl_tbl_level:#1}{\tabl_ntb_parameters_get[##1,#2]}}% + {\defcsname\??naturaltableset\m_tabl_tbl_level:#1\endcsname{\tabl_ntb_parameters_get[##1,#2]}}% \csname\??naturaltableset\m_tabl_tbl_level:#1\endcsname \enforced\let\tabl_ntb_parameters_get\setupcurrentnaturaltablelocal \else - \setvalue{\??naturaltableset\m_tabl_tbl_level:#1}{\tabl_ntb_parameters_get[#2]}% + \defcsname\??naturaltableset\m_tabl_tbl_level:#1\endcsname{\tabl_ntb_parameters_get[#2]}% \fi \else - \setvalue{\??naturaltableset\m_tabl_tbl_level:#1}{\tabl_ntb_parameters_get[#2]}% + \defcsname\??naturaltableset\m_tabl_tbl_level:#1\endcsname{\tabl_ntb_parameters_get[#2]}% \fi} % % \setupTABLE [y] [first][background=color,backgroundcolor=blue,frame=off,bottomframe=on,topframe=on,framecolor=white] @@ -649,29 +649,29 @@ % \bTR \bTD left \eTD\bTD right \eTD\eTR % \eTABLE -\protected\def\tabl_ntb_tr +\tolerant\protected\def\tabl_ntb_tr[#1]% {\c_tabl_ntb_running_col\zerocount \c_tabl_ntb_encountered_col\zerocount \advance\c_tabl_ntb_maximum_row\plusone - \iffirstargument + \ifparameter#1\or \expandafter\tabl_ntb_tr_yes \else \expandafter\gobbleoneoptional - \fi} + \fi[#1]} \def\tabl_ntb_tr_yes[#1]% - {\setvalue{\??naturaltableset\m_tabl_tbl_level:\c!y++\the\c_tabl_ntb_maximum_row}{\setupcurrentnaturaltablelocal[#1]}} + {\defcsname\??naturaltableset\m_tabl_tbl_level:\c!y++\the\c_tabl_ntb_maximum_row\endcsname{\setupcurrentnaturaltablelocal[#1]}} \def\m_tabl_ntb_default_nr{\naturaltableparameter\c!nr} \def\m_tabl_ntb_default_nc{\naturaltableparameter\c!nc} -\protected\def\tabl_ntb_td +\tolerant\protected\def\tabl_ntb_td[#1]% {\advance\c_tabl_ntb_encountered_col\plusone - \iffirstargument + \ifparameter#1\or \expandafter\tabl_ntb_td_yes \else \expandafter\tabl_ntb_td_nop - \fi} + \fi[#1]} \def\tabl_ntb_td_yes[#1]#2\eTD {\letnaturaltableparameter\c!ny \m_tabl_ntb_default_nr @@ -838,10 +838,10 @@ %D %D \typebuffer \getbuffer -\def\tabl_ntb_th[#1]#2\eTH +\tolerant\def\tabl_ntb_th[#1]#2\eTH {\tabl_ntb_td[#1,\c!color=\naturaltablelocalparameter\c!headcolor,\c!style=\naturaltablelocalparameter\c!headstyle,\c!aligncharacter=\v!no]#2\eTD} -\def\tabl_ntb_tn[#1]#2\eTN +\tolerant\def\tabl_ntb_tn[#1]#2\eTN {\tabl_ntb_td[#1]\digits#2\relax\eTD} %D Vit Zyka needed the option to create a distance between columns, so I added @@ -890,10 +890,10 @@ % to be done: head <raw> foot, dus state var -\let\eTABLEhead\relax -\let\eTABLEnext\relax -\let\eTABLEbody\relax -\let\eTABLEfoot\relax +\aliased\let\eTABLEhead\relax +\aliased\let\eTABLEnext\relax +\aliased\let\eTABLEbody\relax +\aliased\let\eTABLEfoot\relax \permanent\tolerant\protected\def\bTABLEhead[#1]#:#2\eTABLEhead{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_head} \permanent\tolerant\protected\def\bTABLEnext[#1]#:#2\eTABLEnext{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_next} @@ -978,10 +978,10 @@ % todo with tolerant: -\permanent\protected\def\tabl_ntb_bTR{\dosingleempty\tabl_ntb_tr} % also used in tabl-nte -\permanent\protected\def\tabl_ntb_bTD{\dosingleempty\tabl_ntb_td} % also used in tabl-nte -\permanent\protected\def\tabl_ntb_bTH{\dosingleempty\tabl_ntb_th} % also used in tabl-nte -\permanent\protected\def\tabl_ntb_bTN{\dosingleempty\tabl_ntb_tn} % also used in tabl-nte +\permanent\tolerant\protected\def\tabl_ntb_bTR{\tabl_ntb_tr} % also used in tabl-nte +\permanent\tolerant\protected\def\tabl_ntb_bTD{\tabl_ntb_td} % also used in tabl-nte +\permanent\tolerant\protected\def\tabl_ntb_bTH{\tabl_ntb_th} % also used in tabl-nte +\permanent\tolerant\protected\def\tabl_ntb_bTN{\tabl_ntb_tn} % also used in tabl-nte % permits \expanded{\bTD ... \eTD} @@ -990,7 +990,7 @@ \permanent\let\bTH\relax \permanent\protected\def\eTH{\ignorespaces} \permanent\let\bTN\relax \permanent\protected\def\eTN{\ignorespaces} -\protected\def\eTABLE % beware, we need to get rid of spurious spaces when in hmode +\permanent\protected\def\eTABLE % beware, we need to get rid of spurious spaces when in hmode {% tricky and dirty order -) \setfalse\c_tabl_ntb_okay % head @@ -2156,7 +2156,7 @@ \installcorenamespace{naturaltablesetup} \permanent\tolerant\protected\def\defineTABLEsetup[#1]#*[#2]% - {\ifarguments\else\setvalue{\??naturaltablesetup#1}{#2}\fi} + {\ifarguments\else\defcsname\??naturaltablesetup#1\endcsname{#2}\fi} \permanent\let\eTDs\relax \permanent\let\eTRs\relax diff --git a/tex/context/base/mkiv/tabl-nte.mkxl b/tex/context/base/mkxl/tabl-nte.mkxl index e79e2a004..e79e2a004 100644 --- a/tex/context/base/mkiv/tabl-nte.mkxl +++ b/tex/context/base/mkxl/tabl-nte.mkxl diff --git a/tex/context/base/mkiv/tabl-tab.mkxl b/tex/context/base/mkxl/tabl-tab.mkxl index e6449396c..5b053abb5 100644 --- a/tex/context/base/mkiv/tabl-tab.mkxl +++ b/tex/context/base/mkxl/tabl-tab.mkxl @@ -1547,7 +1547,7 @@ \forgetall \tabl_table_first_stage} -\permanent\let\stoptables\relax % needed for \noalign +\aliased\let\stoptables\relax % needed for \noalign \def\table_table_stop_s % not \protected as we need the lookahead (brrr) {\tabl_tables_chuck_auto_row % AM: before the tail, else noalign problem @@ -1634,13 +1634,15 @@ {\gdef\tabl_table_tail{\begincsname\??tabletail#1\endcsname}% new \setvalue{\??tabletail#1}{\noalign{\global\settrue\hassometabletail}#3}} -\normalexpanded - {\def\csname\e!start\v!tablehead\endcsname#1\csname\e!stop\v!tablehead\endcsname% - {\settablehead#1\noexpand\end}} +\normalexpanded { + \aliased\letcsname\e!stop\v!tablehead\endcsname\relax + \aliased\letcsname\e!stop\v!tabletail\endcsname\relax +} -\normalexpanded - {\def\csname\e!start\v!tabletail\endcsname#1\csname\e!stop\v!tabletail\endcsname% - {\settabletail#1\noexpand\end}} +\normalexpanded { + \permanent\protected\def\csname\e!start\v!tablehead\endcsname#1\csname\e!stop\v!tablehead\endcsname{\settablehead#1\noexpand\end} + \permanent\protected\def\csname\e!start\v!tabletail\endcsname#1\csname\e!stop\v!tabletail\endcsname{\settabletail#1\noexpand\end} +} %D Redundant \type{\HL}'s are removed automatically, so mid||lines can be used %D without problems. diff --git a/tex/context/base/mkiv/tabl-tbl.mkxl b/tex/context/base/mkxl/tabl-tbl.mkxl index 723758fb8..9b3ec4750 100644 --- a/tex/context/base/mkiv/tabl-tbl.mkxl +++ b/tex/context/base/mkxl/tabl-tbl.mkxl @@ -515,8 +515,8 @@ %\let\gettabulateexit\dogettabulateexit % still needed ? \d_tabl_tabulate_width\zeropoint} -\protected\def\installtabulatepreambleoption#1#2% - {\setvalue{\??tabulatepreamble\string#1}{#2}}% +\permanent\protected\def\installtabulatepreambleoption#1#2% + {\defcsname\??tabulatepreamble\string#1\endcsname{#2}}% \installtabulatepreambleoption{x}{\c_tabl_tabulate_align\zerocount \tabl_tabulate_set_preamble} % internal @@ -623,11 +623,11 @@ {\s_tabl_tabulate_pre.5\d_tabl_tabulate_unit\s_tabl_tabulate_post\s_tabl_tabulate_pre\tabl_tabulate_set_preamble#1}} \def\tabl_tabulate_set_setups#1% - {\setvalue{\??tabulatesetup\the\c_tabl_tabulate_columns}{\setups[#1]}% + {\defcsname\??tabulatesetup\the\c_tabl_tabulate_columns\endcsname{\setups[#1]}% \tabl_tabulate_set_preamble} \def\tabl_tabulate_set_hook#1% - {\setvalue{\??tabulatehook\the\c_tabl_tabulate_columns}{#1}% + {\defcsname\??tabulatehook\the\c_tabl_tabulate_columns\endcsname{#1}% \tabl_tabulate_set_preamble} % begin of character align plugin @@ -1057,14 +1057,14 @@ \fi} \appendtoks - \enforced\edefcsname\e!start \currenttabulation\endcsname{\tabl_start_defined[\currenttabulation]}% - \enforced\letcsname \e!stop \currenttabulation\endcsname\relax - \enforced\letcsname \??tabulatehead\currenttabulation\endcsname\empty - \enforced\letcsname \??tabulatefoot\currenttabulation\endcsname\empty + \enforced\permanent\protected\edefcsname\e!start \currenttabulation\endcsname{\tabl_start_defined[\currenttabulation]}% + \enforced\aliased \letcsname \e!stop \currenttabulation\endcsname\relax + \enforced\aliased \letcsname \??tabulatehead\currenttabulation\endcsname\empty + \enforced\aliased \letcsname \??tabulatefoot\currenttabulation\endcsname\empty \to \everydefinetabulation -\let\tabulateparameter\tabulationparameter % will stay for a while -\def\currenttabulate {\currenttabulation} % will stay for a while +\aliased \let\tabulateparameter\tabulationparameter % will stay for a while +\permanent\def\currenttabulate {\currenttabulation} % will stay for a while % Here begins the implementation. @@ -1478,7 +1478,7 @@ {\begincsname\??tabulatevrule\the\c_tabl_tabulate_column\endcsname} \def\tabl_tabulate_column_vruled_nop - {\global\letcsname\??tabulatevrule\the\c_tabl_tabulate_column\endcsname\tabl_tabulate_column_vruled_preset + {\gletcsname\??tabulatevrule\the\c_tabl_tabulate_column\endcsname\tabl_tabulate_column_vruled_preset \tabl_tabulate_column_normal} \def\tabl_tabulate_column_vruled_step#1% @@ -1487,7 +1487,7 @@ {\xdef\m_tabl_tabulate_vrule_color_local{#1}}} \def\tabl_tabulate_column_vruled_yes#1#2[#3]% - {\global\defcsname\??tabulatevrule\the\c_tabl_tabulate_column\endcsname + {\gdefcsname\??tabulatevrule\the\c_tabl_tabulate_column\endcsname {\tabl_tabulate_column_vruled_preset \rawprocesscommalist[#3]\tabl_tabulate_column_vruled_step}% \tabl_tabulate_column_normal#1#2} @@ -1502,7 +1502,7 @@ \global\c_tabl_tabulate_max_vrulecolumn\zerocount} \def\tabl_tabulate_vrule_reset_step % undefined or relax - {\global\letcsname\??tabulatevrule\the\fastloopindex\endcsname\undefined} + {\gletcsname\??tabulatevrule\the\fastloopindex\endcsname\undefined} \appendtoks \tabl_tabulate_vrule_reset @@ -1663,7 +1663,7 @@ \ifnum\c_tabl_tabulate_column>\c_tabl_tabulate_max_colorcolumn \global\c_tabl_tabulate_max_colorcolumn\c_tabl_tabulate_column \fi - \global\edefcsname\??tabulatecolor\the\c_tabl_tabulate_column\endcsname{#1}% + \xdefcsname\??tabulatecolor\the\c_tabl_tabulate_column\endcsname{#1}% \hpack \thealignbackgroundcolorattr{#1}{}% pack ? \endgroup} @@ -1694,7 +1694,7 @@ {\dofastloopcs\c_tabl_tabulate_max_colorcolumn\tabl_tabulate_color_reset_step} \def\tabl_tabulate_color_reset_step % undefined or empty? - {\global\letcsname\??tabulatecolor\number\fastloopindex\endcsname\undefined} + {\gletcsname\??tabulatecolor\number\fastloopindex\endcsname\undefined} \appendtoks \tabl_tabulate_color_reset @@ -2129,10 +2129,10 @@ % This needs checking: -\def\tabulaterule {\HR} % a rule with lineheight -\def\tabulateline {\HL} % just a spaced rule -\def\tabulateautorule{\HR}% -\def\tabulateautoline{\HL} % no longer different (to be looked into) +\permanent\def\tabulaterule {\HR} % a rule with lineheight +\permanent\def\tabulateline {\HL} % just a spaced rule +\permanent\def\tabulateautorule{\HR}% +\permanent\def\tabulateautoline{\HL} % no longer different (to be looked into) %D When support for vertical rules we needed a way to pick up the specification for %D the final rule and a \type {|{}} interface was chosen. As a result parsing had to @@ -2293,8 +2293,8 @@ % \ifx\p_line\v!line \enforced\let\HL\HR - \let\tabulateautoline\tabulateautorule - \let\tabulateline\tabulaterule + \enforced\let\tabulateautoline\tabulateautorule + \enforced\let\tabulateline \tabulaterule \fi % \ifcase\c_tabl_tabulate_repeathead diff --git a/tex/context/base/mkiv/tabl-tsp.mkxl b/tex/context/base/mkxl/tabl-tsp.mkxl index f09a5d9d8..f09a5d9d8 100644 --- a/tex/context/base/mkiv/tabl-tsp.mkxl +++ b/tex/context/base/mkxl/tabl-tsp.mkxl diff --git a/tex/context/base/mkiv/tabl-xnt.mklx b/tex/context/base/mkxl/tabl-xnt.mklx index f2a41c500..f2a41c500 100644 --- a/tex/context/base/mkiv/tabl-xnt.mklx +++ b/tex/context/base/mkxl/tabl-xnt.mklx diff --git a/tex/context/base/mkiv/tabl-xtb.mklx b/tex/context/base/mkxl/tabl-xtb.mklx index 906355d42..267168ac1 100644 --- a/tex/context/base/mkiv/tabl-xtb.mklx +++ b/tex/context/base/mkxl/tabl-xtb.mklx @@ -700,18 +700,18 @@ \permanent\protected\def\startxtablenext{\begingroup\c_tabl_x_mode\plusthree\tabl_x_start_partition} \permanent\protected\def\startxtablebody{\begingroup\c_tabl_x_mode\plusfour \tabl_x_start_partition} -\permanent\tolerant\protected\def\tabl_x_start_partition[#settings]% +\permanent\tolerant\protected\def\tabl_x_start_partition[#settings]#spacer% {\ifarguments\or \tabl_x_set_checked{#settings}% \fi} -\protected\def\tabl_x_stop_partition +\permanent\protected\def\tabl_x_stop_partition {\endgroup} -\permanent\aliased\let\stopxtablehead\tabl_x_stop_partition -\permanent\aliased\let\stopxtablefoot\tabl_x_stop_partition -\permanent\aliased\let\stopxtablenext\tabl_x_stop_partition -\permanent\aliased\let\stopxtablebody\tabl_x_stop_partition +\aliased\let\stopxtablehead\tabl_x_stop_partition +\aliased\let\stopxtablefoot\tabl_x_stop_partition +\aliased\let\stopxtablenext\tabl_x_stop_partition +\aliased\let\stopxtablebody\tabl_x_stop_partition %D This is an experiment! Beware: you can create loops by using nested %D references to already chained settings. @@ -793,14 +793,14 @@ {\begingroup \doifelsenextoptionalcs\tabl_x_start_cell_delayed_one\tabl_x_start_cell_nop} -\protected\def\tabl_x_start_cell_delayed_one[#tag]% +\tolerant\protected\def\tabl_x_start_cell_delayed_one[#tag]#spacer% {\ifcsname\??xtablecheck\detokenize\expandafter{\normalexpanded{#tag}}\endcsname \expandafter\tabl_x_start_cell_delayed_two \else \expandafter\tabl_x_start_cell_yes \fi[#tag]} -\protected\def\tabl_x_start_cell_delayed_two[#tag]% +\tolerant\protected\def\tabl_x_start_cell_delayed_two[#tag]#spacer% {\ifempty\currentxtable \else \chaintocurrentxtable{#tag}% \fi @@ -908,7 +908,7 @@ \gtoksapp\t_tabl_x_swapped\expandafter{\expandafter\tabl_x_c_cell_start\expandafter{\m_tabl_x_swapped_settings}#content\tabl_x_c_cell_stop}% \fi} -\def\tabl_x_collect_cell_start_yes[#settings]#content\stopxcell +\tolerant\def\tabl_x_collect_cell_start_yes[#settings]#spacer#content\stopxcell {\tabl_x_collect_advance \ifempty\m_tabl_x_swapped_settings \gtoksapp\t_tabl_x_swapped{\tabl_x_c_cell_start{}[#settings]#content\tabl_x_c_cell_stop}% @@ -921,12 +921,12 @@ \dorecurse\scratchcounter\tabl_x_collect_advance \fi} -\permanent\tolerant\protected\def\startxcolumn[#1]% +\permanent\tolerant\protected\def\startxcolumn[#settings]#spacer% {\begingroup \global\c_tabl_x_swapped\zerocount \enforced\let\startxcell\tabl_x_collect_cell_start \enforced\let\stopxcell \relax - \xdef\m_tabl_x_swapped_settings{#1}} + \xdef\m_tabl_x_swapped_settings{#settings}} \permanent\protected\def\stopxcolumn {\endgroup} diff --git a/tex/context/base/mkiv/task-ini.mkxl b/tex/context/base/mkxl/task-ini.mkxl index 77e4fa985..77e4fa985 100644 --- a/tex/context/base/mkiv/task-ini.mkxl +++ b/tex/context/base/mkxl/task-ini.mkxl diff --git a/tex/context/base/mkiv/toks-aux.lmt b/tex/context/base/mkxl/toks-aux.lmt index 03f4dc2c1..03f4dc2c1 100644 --- a/tex/context/base/mkiv/toks-aux.lmt +++ b/tex/context/base/mkxl/toks-aux.lmt diff --git a/tex/context/base/mkxl/toks-aux.mkxl b/tex/context/base/mkxl/toks-aux.mkxl new file mode 100644 index 000000000..4563014ec --- /dev/null +++ b/tex/context/base/mkxl/toks-aux.mkxl @@ -0,0 +1,68 @@ +%D \module +%D [ file=toks-aux, +%D version=2018.11.29, +%D title=\CONTEXT\ Token Support, +%D subtitle=Helpers, +%D author=Wolfgang Schuster, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Token Support / Helpers} + +\unprotect + +%D The older \type {\scantokens} overload has been replace by a more modern one (in +%D \LMTX): +%D +%D \starttyping +%D \protected\def\whatever#1[#2](#3)\relax{oeps #1 and #2 and #3 done ## error} +%D \scratchtoks{foo \framed{\red 123}456} +%D +%D \showluatokens{123\what} +%D \showluatokens\whatever +%D \showluatokens\framed +%D +%D \showluatokens\scratchtoks +%D \showluatokens\everypar +%D \stoptyping + +\registerctxluafile{toks-aux}{autosuffix} + +\installcorenamespace {tokenlist} + +\permanent\protected\def\definetokenlist[#1]% + {\ifcsname\??tokenlist#1\endcsname + \global\lastnamedcs\emptytoks + \else + \expandafter\newtoks\csname\??tokenlist#1\endcsname + \fi} + +\permanent\protected\def\starttokenlist[#1]#2\stoptokenlist + {\ifcsname\??tokenlist#1\endcsname \else + \expandafter\newtoks\csname\??tokenlist#1\endcsname + \fi + \toksapp\lastnamedcs{#2}} + +\aliased\let\stoptokenlist\relax + +\permanent\def\gettokenlist[#1]% + {\ifcsname\??tokenlist#1\endcsname + \the\lastnamedcs + \fi} + +\permanent\protected\def\settokenlist[#1]#2% + {\ifcsname\??tokenlist#1\endcsname \else + \expandafter\newtoks\csname\??tokenlist#1\endcsname + \fi + \toksapp\lastnamedcs{#2}} + +\permanent\protected\def\resettokenlist[#1]% + {\ifcsname\??tokenlist#1\endcsname + \lastnamedcs\emptytoks + \fi} + +\protect diff --git a/tex/context/base/mkiv/toks-ini.lmt b/tex/context/base/mkxl/toks-ini.lmt index 4b2d1facc..4b2d1facc 100644 --- a/tex/context/base/mkiv/toks-ini.lmt +++ b/tex/context/base/mkxl/toks-ini.lmt diff --git a/tex/context/base/mkiv/toks-ini.mkxl b/tex/context/base/mkxl/toks-ini.mkxl index c7d7bceb3..c7d7bceb3 100644 --- a/tex/context/base/mkiv/toks-ini.mkxl +++ b/tex/context/base/mkxl/toks-ini.mkxl diff --git a/tex/context/base/mkiv/toks-scn.lmt b/tex/context/base/mkxl/toks-scn.lmt index 93e0af09a..93e0af09a 100644 --- a/tex/context/base/mkiv/toks-scn.lmt +++ b/tex/context/base/mkxl/toks-scn.lmt diff --git a/tex/context/base/mkiv/toks-scn.mkxl b/tex/context/base/mkxl/toks-scn.mkxl index 12abf0cb8..12abf0cb8 100644 --- a/tex/context/base/mkiv/toks-scn.mkxl +++ b/tex/context/base/mkxl/toks-scn.mkxl diff --git a/tex/context/base/mkiv/trac-ctx.mkxl b/tex/context/base/mkxl/trac-ctx.mkxl index 656a7a9aa..656a7a9aa 100644 --- a/tex/context/base/mkiv/trac-ctx.mkxl +++ b/tex/context/base/mkxl/trac-ctx.mkxl diff --git a/tex/context/base/mkiv/trac-deb.lmt b/tex/context/base/mkxl/trac-deb.lmt index b9827c3a9..b9827c3a9 100644 --- a/tex/context/base/mkiv/trac-deb.lmt +++ b/tex/context/base/mkxl/trac-deb.lmt diff --git a/tex/context/base/mkiv/trac-deb.mkxl b/tex/context/base/mkxl/trac-deb.mkxl index 37a901aa3..37a901aa3 100644 --- a/tex/context/base/mkiv/trac-deb.mkxl +++ b/tex/context/base/mkxl/trac-deb.mkxl diff --git a/tex/context/base/mkiv/trac-inf.lmt b/tex/context/base/mkxl/trac-inf.lmt index 9207d5b45..9207d5b45 100644 --- a/tex/context/base/mkiv/trac-inf.lmt +++ b/tex/context/base/mkxl/trac-inf.lmt diff --git a/tex/context/base/mkiv/trac-jus.mkxl b/tex/context/base/mkxl/trac-jus.mkxl index 0eacc886d..3375e5ee7 100644 --- a/tex/context/base/mkiv/trac-jus.mkxl +++ b/tex/context/base/mkxl/trac-jus.mkxl @@ -19,6 +19,6 @@ \definesystemattribute [justification] [public] -\protected\def\showjustification{\clf_showjustification} % currently no argument (default 1), todo: public implementor +\permanent\protected\def\showjustification{\clf_showjustification} % currently no argument (default 1), todo: public implementor \protect \endinput diff --git a/tex/context/base/mkiv/trac-tex.mkxl b/tex/context/base/mkxl/trac-tex.mkxl index f9c763c4f..f9c763c4f 100644 --- a/tex/context/base/mkiv/trac-tex.mkxl +++ b/tex/context/base/mkxl/trac-tex.mkxl diff --git a/tex/context/base/mkiv/trac-tim.lmt b/tex/context/base/mkxl/trac-tim.lmt index fcba7f132..fcba7f132 100644 --- a/tex/context/base/mkiv/trac-tim.lmt +++ b/tex/context/base/mkxl/trac-tim.lmt diff --git a/tex/context/base/mkiv/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt index 7ac5964da..7ac5964da 100644 --- a/tex/context/base/mkiv/trac-vis.lmt +++ b/tex/context/base/mkxl/trac-vis.lmt diff --git a/tex/context/base/mkiv/trac-vis.mkxl b/tex/context/base/mkxl/trac-vis.mkxl index dd69e0bb8..dd69e0bb8 100644 --- a/tex/context/base/mkiv/trac-vis.mkxl +++ b/tex/context/base/mkxl/trac-vis.mkxl diff --git a/tex/context/base/mkxl/type-def.mkxl b/tex/context/base/mkxl/type-def.mkxl new file mode 100644 index 000000000..a80b4f7bd --- /dev/null +++ b/tex/context/base/mkxl/type-def.mkxl @@ -0,0 +1,48 @@ +%D \module +%D [ file=type-def, +%D version=2005.02.04, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Default Definitions, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\starttypescriptcollection[simplification] + +\starttypescript [\s!serif] [\s!simple] [\s!name] + \definefontsynonym [\s!Serif] [\s!Simple] + \definefontsynonym [\s!SerifBold] [\s!Serif] + \definefontsynonym [\s!SerifItalic] [\s!Serif] + \definefontsynonym [\s!SerifSlanted] [\s!Serif] + \definefontsynonym [\s!SerifBoldItalic] [\s!Serif] + \definefontsynonym [\s!SerifBoldSlanted] [\s!Serif] + \definefontsynonym [\s!SerifCaps] [\s!Serif] +\stoptypescript + +\starttypescript [\s!sans] [\s!simple] [\s!name] + \definefontsynonym [\s!Sans] [\s!Simple] + \definefontsynonym [\s!SansBold] [\s!Sans] + \definefontsynonym [\s!SansItalic] [\s!Sans] + \definefontsynonym [\s!SansSlanted] [\s!Sans] + \definefontsynonym [\s!SansBoldItalic] [\s!Sans] + \definefontsynonym [\s!SansBoldSlanted] [\s!Sans] + \definefontsynonym [\s!SansCaps] [\s!Sans] +\stoptypescript + +\starttypescript [\s!mono] [\s!simple] [\s!name] + \definefontsynonym [\s!Mono] [\s!Simple] + \definefontsynonym [\s!MonoBold] [\s!Mono] + \definefontsynonym [\s!MonoItalic] [\s!Mono] + \definefontsynonym [\s!MonoSlanted] [\s!Mono] + \definefontsynonym [\s!MonoBoldItalic] [\s!Mono] + \definefontsynonym [\s!MonoBoldSlanted] [\s!Mono] + \definefontsynonym [\s!MonoCaps] [\s!Mono] +\stoptypescript + +\stoptypescriptcollection + +\endinput diff --git a/tex/context/base/mkxl/type-fbk.mkxl b/tex/context/base/mkxl/type-fbk.mkxl new file mode 100644 index 000000000..4ac381787 --- /dev/null +++ b/tex/context/base/mkxl/type-fbk.mkxl @@ -0,0 +1,70 @@ +%D \module +%D [ file=type-sfbk, +%D version=2005.02.04, % moved from ini/def/set +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Fallbacks, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +\definetypescriptprefix [\s!serif] [\s!Serif] +\definetypescriptprefix [\s!sans] [\s!Sans] +\definetypescriptprefix [\s!mono] [\s!Mono] + +\definefontsynonym [\s!DefaultFont] [\s!file:lmmonoproplt10-regular] + +\startsetups [\s!font:\s!fallback:\s!serif] + \definefontsynonym[\s!Serif] [\s!DefaultFont] + \definefontsynonym[\s!SerifBold] [\s!Serif] + \definefontsynonym[\s!SerifItalic] [\s!Serif] + \definefontsynonym[\s!SerifSlanted] [\s!SerifItalic] + \definefontsynonym[\s!SerifBoldItalic] [\s!Serif] + \definefontsynonym[\s!SerifBoldSlanted][\s!SerifBoldItalic] + \definefontsynonym[\s!SerifCaps] [\s!Serif] [\s!features=\s!smallcaps] +\stopsetups + +\startsetups [\s!font:\s!fallback:\s!sans] + \definefontsynonym[\s!Sans] [\s!DefaultFont] + \definefontsynonym[\s!SansBold] [\s!Sans] + \definefontsynonym[\s!SansItalic] [\s!Sans] + \definefontsynonym[\s!SansSlanted] [\s!SansItalic] + \definefontsynonym[\s!SansBoldItalic] [\s!Sans] + \definefontsynonym[\s!SansBoldSlanted][\s!SansBoldItalic] + \definefontsynonym[\s!SansCaps] [\s!Sans] [\s!features=\s!smallcaps] +\stopsetups + +\startsetups [\s!font:\s!fallback:\s!mono] + \definefontsynonym[\s!Mono] [\s!DefaultFont] + \definefontsynonym[\s!MonoBold] [\s!Mono] + \definefontsynonym[\s!MonoItalic] [\s!Mono] + \definefontsynonym[\s!MonoSlanted] [\s!MonoItalic] + \definefontsynonym[\s!MonoBoldItalic] [\s!Mono] + \definefontsynonym[\s!MonoBoldSlanted][\s!MonoBoldItalic] + \definefontsynonym[\s!MonoCaps] [\s!Mono] [\s!features=\s!smallcaps] +\stopsetups + +\starttypescript [\s!serif,\s!sans,\s!mono] [\s!fallback] + \setups[\s!font:\s!fallback:\typescriptone] +\stoptypescript + +\startsetups [\s!font:allbold:\s!serif] + \definefontsynonym[\s!Serif] [\s!SerifBold] + \definefontsynonym[\s!SerifItalic] [\s!SerifBoldItalic] + \definefontsynonym[\s!SerifSlanted][\s!SerifBoldSlanted] + %definefontsynonym[\s!SerifCaps] [\s!SerifBold] +\stopsetups + +\startsetups [\s!font:allbold:\s!sans] + \definefontsynonym[\s!Sans] [\s!SansBold] + \definefontsynonym[\s!SansItalic] [\s!SansBoldItalic] + \definefontsynonym[\s!SansSlanted][\s!SansBoldSlanted] + %definefontsynonym[\s!SansCaps] [\s!SansBold] +\stopsetups + +\protect \endinput diff --git a/tex/context/base/mkiv/type-ini.mklx b/tex/context/base/mkxl/type-ini.mklx index afbbfea47..23c277f99 100644 --- a/tex/context/base/mkiv/type-ini.mklx +++ b/tex/context/base/mkxl/type-ini.mklx @@ -39,21 +39,21 @@ \newtoks \everybeforedefinetypeface \newtoks \everyafterdefinetypeface -\let\typescriptfiles \empty -\let\currenttypescripts\empty -\let\currenttypefile \empty +\mutable\let\typescriptfiles \empty +\mutable\let\currenttypescripts\empty +\mutable\let\currenttypefile \empty \installmacrostack\currenttypefile -\let\typescriptone \empty % public, used in typescripts -\let\typescripttwo \empty % public, used in typescripts -\let\typescriptthree\empty % public, used in typescripts +\mutable\let\typescriptone \empty % public, used in typescripts +\mutable\let\typescripttwo \empty % public, used in typescripts +\mutable\let\typescriptthree\empty % public, used in typescripts \installmacrostack\typescriptone \installmacrostack\typescripttwo \installmacrostack\typescriptthree -\let\fontclassstyle \empty +\mutable\let\fontclassstyle \empty \installmacrostack\fontclassstyle @@ -196,14 +196,14 @@ \permanent\protected\def\font_typescripts_start_store#definitions\stoptypescript {\global\advance\c_font_typescripts_n_of_preloaded\plusone - \global\defcsname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname + \gdefcsname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname {\starttypescript#definitions\stoptypescript}% \gtoksapp\t_font_typescripts\expandafter {\csname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname}} \permanent\protected\def\font_typescripts_collection_start_store#definitions\stoptypescriptcollection {\global\advance\c_font_typescripts_n_of_preloaded\plusone - \global\defcsname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname + \gdefcsname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname {\starttypescriptcollection#definitions\stoptypescriptcollection}% \gtoksapp\t_font_typescripts\expandafter {\csname\??typescriptcache\the\c_font_typescripts_n_of_preloaded\endcsname}} @@ -254,7 +254,7 @@ % \definetypescriptsynonym[lbr][cmr] \permanent\tolerant\protected\def\definetypescriptsynonym[#name]#spacer[#synonym]% - {\ifarguments\or\or\setevalue{\??typescriptsynonyms#name}{#synonym}\fi} + {\ifarguments\or\or\edefcsname\??typescriptsynonyms#name\endcsname{#synonym}\fi} \permanent\def\truetypescript#name% recursive so no \lastnamedcs {\ifcsname\??typescriptsynonyms#name\endcsname @@ -392,19 +392,13 @@ % \definetypescriptprefix[mono] [Mono] % % \starttypescript [serif,sans,mono] [handling,hanging,hz] [pure,normal,hz,quality] -% \setupfontsynonym [\typescriptprefix\typescriptone] [handling=\typescriptthree] +% \setupfontsynonym [\typescriptprefix\typescriptone] [handling=\typescriptthree] % \stoptypescript -% \protected\def\definetypescriptprefix -% {\dodoubleargument\font_typescripts_define_prefix} -% -% \def\font_typescripts_define_prefix[#name][#prefix]% -% {\setgvalue{\??typescriptprefix#name}{#prefix}} % made global - \permanent\tolerant\protected\def\definetypescriptprefix[#name]#spacer[#prefix]% - {\setgvalue{\??typescriptprefix#name}{#prefix}} % made global + {\gdefcsname\??typescriptprefix#name\endcsname{#prefix}} % made global -\def\typescriptprefix#name% +\permanent\def\typescriptprefix#name% %{\ifcsname\??typescriptprefix#name\endcsname\csname\??typescriptprefix#name\endcsname\else#name\fi} {\ifcsname\??typescriptprefix#name\endcsname\lastnamedcs\else#name\fi} @@ -496,53 +490,12 @@ {\doifsomething{#name} {\ifcsname\??typescriptdefaultstyles#name\endcsname \else \registerfontclass{#name}% - \setxvalue{\??typescriptdefaultstyles#name}{#style}% + \gdefcsname\??typescriptdefaultstyles#name\endcsname{#style}% \fi \ifcsname#name\endcsname \else - \setugvalue{#name}{\switchtotypeface[#name][#style]}% + \protected\gdefcsname#name\endcsname{\switchtotypeface[#name][#style]}% \fi}} -% needs testing first ... let'd do it stepwise - -% \permanent\tolerant\protected\def\definetypeface[#name]#spacer[#style]#spacer[#fontshape]#spacer[#fontname]#spacer[#fontsize]#spacer[#settings]% -% {\ifarguments -% \or -% \clf_definetypeface{#name}{#specification}% -% \or -% \clf_definetypeface{#name}{#specification}% -% \or -% \font_typefaces_define_simplex[#name][#style]% -% \or -% \font_typefaces_define_complex[#name][#style][#fontshape][#fontname][\s!default][#discard]% -% \else -% \font_typefaces_define_complex[#name][#style][#fontshape][#fontname][#fontsize][#settings]% -% \fi} -% -% \def\font_typefaces_define_complex[#name][#style][#fontshape][#fontname][#fontsize][#settings]% -% {\iftracetypescripts\writestatus\m!fonts{define: [#name] [#style] [#fontshape] [#fontname]}\fi -% \font_typefaces_define_simplex[#name][#style]% -% \font_typefaces_defining_start{#name}{#style}{#settings}% -% \font_typescripts_use_one[#fontshape][#fontname][\s!name]% [\s!name,\s!default]% -% \iftypescriptfound -% % we're okay -% \orelse\ifconditional\autotypescripts -% \iftracetypescripts\writestatus\m!fonts{auto load typescript file 2: [#fontname]}\fi -% \usetypescriptfile[#fontname]% -% \font_typescripts_use_one[#fontshape][#fontname][\s!name]% [\s!name,\s!default]% -% \fi -% \font_typescripts_use_one[#fontshape][#fontsize][\s!size]% -% \font_typefaces_defining_stop} -% -% \def\font_typefaces_define_simplex[#name][#style]% saveguard against redefinition -% {\doifsomething{#name} -% {\ifcsname\??typescriptdefaultstyles#name\endcsname \else -% \registerfontclass{#name}% -% \setxvalue{\??typescriptdefaultstyles#name}{#style}% -% \fi -% \ifcsname#name\endcsname \else -% \setugvalue{#name}{\switchtotypeface[#name][#style]}% -% \fi}} - \def\font_typefaces_defining_start#name#style#settings% {\let\m_ts_rscale \!!plusone % as we push/pop \let\m_ts_features \empty @@ -575,42 +528,6 @@ \font_typescripts_use_one[#fontshape][#fontsize][\s!size]% \font_typefaces_defining_stop} -% \protected\def\setuptypeface% [class] [settings] -% {\dodoubleempty\font_typefaces_setup} -% -% \protected\def\switchtotypeface% [class] [settings] -% {\dodoubleempty\font_typefaces_switch} -% -% \def\font_typefaces_setup[#class][#settings]% -% {\setcurrentfontclass{#class}% -% \let\globalfontclass\fontclass -% \ifsecondargument -% \setupbodyfont[#settings]% -% \orelse\ifempty\fontclass -% \setupbodyfont[\s!rm]% -% \orelse\ifcsname\??typescriptdefaultstyles\fontclass\endcsname -% %\setupbodyfont[\csname\??typescriptdefaultstyles\fontclass\endcsname]% -% \expandafter\setupbodyfont\expandafter[\lastnamedcs]% -% \else -% \setupbodyfont[\s!rm]% -% \fi -% \ifmmode\mr\else\tf\fi} % needed ? -% -% \def\font_typefaces_switch[#class]#spacer[#settings]% -% {\setcurrentfontclass{#class}% -% \let\globalfontclass\globalfontclass -% \ifsecondargument -% \switchtobodyfont[#settings]% -% \orelse\ifempty\fontclass -% \switchtobodyfont[\s!rm]% -% \orelse\ifcsname\??typescriptdefaultstyles\fontclass\endcsname -% %\switchtobodyfont[\csname\??typescriptdefaultstyles\fontclass\endcsname]% -% \expandafter\switchtobodyfont\expandafter[\lastnamedcs]% -% \else -% \switchtobodyfont[\s!rm]% -% \fi -% \ifmmode\mr\else\tf\fi} % needed ? - \permanent\tolerant\protected\def\setuptypeface[#class]#spacer[#settings]% {\ifarguments \or @@ -663,7 +580,7 @@ \font_typescripts_inherit_indeed[#name][\s!rm,\s!ss,\s!tt,\s!mm][\fontclass]% \orelse\iftok{#name}{#parentclass}\else \glet\font_typescripts_inherit_check\font_typescripts_inherit_check_indeed - \def\font_typescripts_inherit_check_step#style{\setevalue{\??typescriptinheritances#name:#style}{#parentclass}}% + \def\font_typescripts_inherit_check_step#style{\edefcsname\??typescriptinheritances#name:#style\endcsname{#parentclass}}% \processcommalist[#styles]\font_typescripts_inherit_check_step \fi} @@ -679,16 +596,6 @@ \let\font_typescripts_inherit_check\gobbleoneargument -% not yet: -% -% \def\font_helpers_check_relative_font_id -% {\ifcsname\??typescriptrelatives\fontclass\endcsname -% \expandafter\let\expandafter\relativefontid\csname\??typescriptrelatives\fontclass\endcsname -% \else -% \expandafter\normalxdef\csname\??typescriptrelatives\fontclass\endcsname{\the\lastfontid}% -% \let\relativefontid\minusone -% \fi} - \def\v_font_string_d % default fontstyle (expands to \s!Serif in font-ini) {\expandafter\ifx\csname\??typescriptdefaultstyles\fontclass\endcsname\s!rm \s!Serif \else % no \orelse ! \expandafter\ifx\csname\??typescriptdefaultstyles\fontclass\endcsname\s!ss \s!Sans \else % no \orelse ! diff --git a/tex/context/base/mkxl/type-lua.mkxl b/tex/context/base/mkxl/type-lua.mkxl new file mode 100644 index 000000000..fac6c3867 --- /dev/null +++ b/tex/context/base/mkxl/type-lua.mkxl @@ -0,0 +1,86 @@ +%D \module +%D [ file=type-lua, +%D version=2009.11.27, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=\MKIV\ goodies, +%D author=Hans Hagen \& Wolfgang Schuster, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\starttypescriptcollection [luatex] + +\starttypescript [specserif] [\s!all] [\s!name] + \definefontsynonym [\s!Serif] [spec:\cleanfontname\typescripttwo-\s!normal-\s!normal] [\s!features=\s!default] + \definefontsynonym [\s!SerifItalic] [spec:\cleanfontname\typescripttwo-\s!normal-\s!italic] [\s!features=\s!default] + \definefontsynonym [\s!SerifSlanted] [spec:\cleanfontname\typescripttwo-\s!normal-\s!italic] [\s!features=\s!default] + \definefontsynonym [\s!SerifBold] [spec:\cleanfontname\typescripttwo-\s!bold -\s!normal] [\s!features=\s!default] + \definefontsynonym [\s!SerifBoldItalic] [spec:\cleanfontname\typescripttwo-\s!bold -\s!italic] [\s!features=\s!default] + \definefontsynonym [\s!SerifBoldSlanted] [spec:\cleanfontname\typescripttwo-\s!bold -\s!italic] [\s!features=\s!default] + \definefontsynonym [\s!SerifCaps] [spec:\cleanfontname\typescripttwo-\s!normal-\s!normal] [\s!features=\s!smallcaps] +\stoptypescript + +\starttypescript [specsans] [\s!all] [\s!name] + \definefontsynonym [\s!Sans] [\s!spec:\cleanfontname\typescripttwo-\s!normal-\s!normal] [\s!features=\s!default] + \definefontsynonym [\s!SansItalic] [\s!spec:\cleanfontname\typescripttwo-\s!normal-\s!italic] [\s!features=\s!default] + \definefontsynonym [\s!SansSlanted] [\s!spec:\cleanfontname\typescripttwo-\s!normal-\s!italic] [\s!features=\s!default] + \definefontsynonym [\s!SansBold] [\s!spec:\cleanfontname\typescripttwo-\s!bold -\s!normal] [\s!features=\s!default] + \definefontsynonym [\s!SansBoldItalic] [\s!spec:\cleanfontname\typescripttwo-\s!bold -\s!italic] [\s!features=\s!default] + \definefontsynonym [\s!SansBoldSlanted] [\s!spec:\cleanfontname\typescripttwo-\s!bold -\s!italic] [\s!features=\s!default] + \definefontsynonym [\s!SansCaps] [\s!spec:\cleanfontname\typescripttwo-\s!normal-\s!normal] [\s!features=\s!smallcaps] +\stoptypescript + +\starttypescript [specmono] [\s!all] [\s!name] + \definefontsynonym [\s!Mono] [\s!spec:\cleanfontname\typescripttwo-\s!normal-\s!normal] [\s!features=\s!default] + \definefontsynonym [\s!MonoItalic] [\s!spec:\cleanfontname\typescripttwo-\s!normal-\s!italic] [\s!features=\s!default] + \definefontsynonym [\s!MonoSlanted] [\s!spec:\cleanfontname\typescripttwo-\s!normal-\s!italic] [\s!features=\s!default] + \definefontsynonym [\s!MonoBold] [\s!spec:\cleanfontname\typescripttwo-\s!bold -\s!normal] [\s!features=\s!default] + \definefontsynonym [\s!MonoBoldItalic] [\s!spec:\cleanfontname\typescripttwo-\s!bold -\s!italic] [\s!features=\s!default] + \definefontsynonym [\s!MonoBoldSlanted] [\s!spec:\cleanfontname\typescripttwo-\s!bold -\s!italic] [\s!features=\s!default] + \definefontsynonym [\s!MonoCaps] [\s!spec:\cleanfontname\typescripttwo-\s!normal-\s!normal] [\s!features=\s!smallcaps] +\stoptypescript + +% we could combine these in the normal serif settings + +\starttypescript [specserif] [\s!default] [\s!size] + \definebodyfont + [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] + [\s!rm] [\s!default] +\stoptypescript + +\starttypescript [specsans] [\s!default] [\s!size] + \definebodyfont + [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] + [\s!ss] [\s!default] +\stoptypescript + +\starttypescript [specmono] [\s!default] [\s!size] + \definebodyfont + [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] + [\s!tt] [\s!default] +\stoptypescript + +\starttypescript [specserif] [\s!dtp] [\s!size] + \definebodyfont + [5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,13pt,14pt,16pt,18pt,22pt,28pt] + [\s!rm] [\s!default] +\stoptypescript + +\starttypescript [specsans] [\s!dtp] [\s!size] + \definebodyfont + [5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,13pt,14pt,16pt,18pt,22pt,28pt] + [\s!ss] [\s!default] +\stoptypescript + +\starttypescript [specmono] [\s!dtp] [\s!size] + \definebodyfont + [5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,13pt,14pt,16pt,18pt,22pt,28pt] + [\s!tt] [\s!default] +\stoptypescript + +\stoptypescriptcollection + +\endinput diff --git a/tex/context/base/mkxl/type-set.mkxl b/tex/context/base/mkxl/type-set.mkxl new file mode 100644 index 000000000..4a22b59a5 --- /dev/null +++ b/tex/context/base/mkxl/type-set.mkxl @@ -0,0 +1,139 @@ +%D \module +%D [ file=type-set, +%D version=2005.02.04, % moved from ini/def +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Default Settings, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +\ifnum\typescriptstate=\plustwo + + % we store some typescripts in the format + + % \loadmarkfile{type-def} + % \loadmarkfile{type-lua} + % \loadmarkfile{type-siz} + % \loadmarkfile{type-fbk} + % \loadmarkfile{type-imp-latinmodern} + + % but ... let's make sure that newlines are gone + + % beware: these are low level calls, so not user commands ! + + \loadfoundtypescriptfile\empty{type-def.mkxl} + \loadfoundtypescriptfile\empty{type-lua.mkxl} + \loadfoundtypescriptfile\empty{type-siz.mkxl} + \loadfoundtypescriptfile\empty{type-fbk.mkxl} + \loadfoundtypescriptfile\empty{type-imp-latinmodern.mkiv} + + % and not: + + % \loadtypescriptfile[def] % meant for local usage only + % \loadtypescriptfile[fbk] % meant for local usage only + % \loadtypescriptfile[lua] % meant for local usage only + % \loadtypescriptfile[siz] % meant for local usage only + % \usetypescriptfile[latinmodern] + + \usetypescriptfile[loc] + + % We want these names preset but they conflict with later loads so from now on + % one has to define a proper typeface if they are needed. + % + % \usetypescript[serif,sans,mono,math] [latin-modern] + +\else + + \usetypescriptfile[def] + \usetypescriptfile[fbk] + \usetypescriptfile[lua] + \usetypescriptfile[siz] + \usetypescriptfile[latinmodern] + \usetypescriptfile[loc] + +\fi + +\definefilesynonym [type-imp-latin-modern.mkiv] [type-imp-latinmodern.mkiv] +\definefilesynonym [type-imp-modern-latin.mkiv] [type-imp-modernlatin.mkiv] + +\definefilesynonym [type-imp-lucida.mkiv] [type-imp-lucida-typeone.mkiv] +\definefilesynonym [type-imp-lucidaot.mkiv] [type-imp-lucida-opentype.mkiv] +\definefilesynonym [type-imp-lucidadk.mkiv] [type-imp-lucida-opentype.mkiv] + +\definefilesynonym [type-imp-dejavu-condensed.mkiv] [type-imp-dejavu.mkiv] + +\definefilesynonym [type-imp-palatino.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-courier.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-avantgarde.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-helvetica.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-chancery.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-bookman.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-schoolbook.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-times.mkiv] [type-imp-texgyre.mkiv] + +\definefilesynonym [type-imp-cursor.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-adventor.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-heros.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-chorus.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-bonum.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-schola.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-pagella.mkiv] [type-imp-texgyre.mkiv] +\definefilesynonym [type-imp-termes.mkiv] [type-imp-texgyre.mkiv] + +\definefilesynonym [type-imp-mscoretimes.mkiv] [type-imp-mscore.mkiv] +\definefilesynonym [type-imp-mscorearial.mkiv] [type-imp-mscore.mkiv] +\definefilesynonym [type-imp-mscorecourier.mkiv] [type-imp-mscore.mkiv] +\definefilesynonym [type-imp-mscoreverdana.mkiv] [type-imp-mscore.mkiv] + +\definefilesynonym [type-imp-candara.mkiv] [type-imp-cleartype.mkiv] +\definefilesynonym [type-imp-consolas.mkiv] [type-imp-cleartype.mkiv] +\definefilesynonym [type-imp-constantia.mkiv] [type-imp-cleartype.mkiv] +\definefilesynonym [type-imp-corbel.mkiv] [type-imp-cleartype.mkiv] +\definefilesynonym [type-imp-calibri.mkiv] [type-imp-cleartype.mkiv] + +\definefilesynonym [type-imp-antykwa-poltawskiego.mkiv] [type-imp-antykwapoltawskiego.mkiv] + +%definefilesynonym [type-imp-mac.mkiv] [type-imp-osx.mkiv] +%definefilesynonym [type-imp-win.mkiv] [type-imp-mscore.mkiv] + +\definefilesynonym [type-imp-eulernovum.mkiv] [type-imp-euler.mkiv] +\definefilesynonym [type-imp-eulernova.mkiv] [type-imp-euler.mkiv] + +\definefilesynonym [type-imp-euler-with-pagella.mkiv] [type-imp-euler.mkiv] +\definefilesynonym [type-imp-pagella-with-euler.mkiv] [type-imp-euler.mkiv] + +\definefilesynonym [type-imp-mdbch.mkiv] [type-imp-mathdesign.mkiv] +\definefilesynonym [type-imp-mdugm.mkiv] [type-imp-mathdesign.mkiv] +\definefilesynonym [type-imp-mdput.mkiv] [type-imp-mathdesign.mkiv] +\definefilesynonym [type-imp-mdici.mkiv] [type-imp-mathdesign.mkiv] +\definefilesynonym [type-imp-mdpgd.mkiv] [type-imp-mathdesign.mkiv] +\definefilesynonym [type-imp-mdpus.mkiv] [type-imp-mathdesign.mkiv] + +\definefilesynonym [type-imp-mathdesignch.mkiv] [type-imp-mathdesign.mkiv] +\definefilesynonym [type-imp-mathdesigngm.mkiv] [type-imp-mathdesign.mkiv] +\definefilesynonym [type-imp-mathdesignut.mkiv] [type-imp-mathdesign.mkiv] +\definefilesynonym [type-imp-mathdesignci.mkiv] [type-imp-mathdesign.mkiv] +\definefilesynonym [type-imp-mathdesigngd.mkiv] [type-imp-mathdesign.mkiv] +\definefilesynonym [type-imp-mathdesignus.mkiv] [type-imp-mathdesign.mkiv] + +\definefilesynonym [type-imp-mathdesigncharter.mkiv] [type-imp-mathdesign.mkiv] +\definefilesynonym [type-imp-mathdesigngaramond.mkiv] [type-imp-mathdesign.mkiv] +\definefilesynonym [type-imp-mathdesignutopia.mkiv] [type-imp-mathdesign.mkiv] + +\definefilesynonym [type-imp-cows.mkiv] [type-imp-koeielettersot.mkiv] +\definefilesynonym [type-imp-sheep.mkiv] [type-imp-koeielettersot.mkiv] +\definefilesynonym [type-imp-coloredcows.mkiv] [type-imp-koeielettersot.mkiv] +\definefilesynonym [type-imp-coloredsheep.mkiv] [type-imp-koeielettersot.mkiv] +\definefilesynonym [type-imp-koeieletters.mkiv] [type-imp-koeielettersot.mkiv] + +\definefilesynonym [type-imp-stixtwo.mkiv] [type-imp-stix.mkiv] + +\definefilesynonym [type-imp-ibmplex.mkiv] [type-imp-plex.mkiv] + +\protect \endinput diff --git a/tex/context/base/mkxl/type-siz.mkxl b/tex/context/base/mkxl/type-siz.mkxl new file mode 100644 index 000000000..d4c90b182 --- /dev/null +++ b/tex/context/base/mkxl/type-siz.mkxl @@ -0,0 +1,169 @@ +%D \module +%D [ file=type-siz, +%D version=2001.04.12, +%D title=\CONTEXT\ Typescript Macros, +%D subtitle=Sizing scripts, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +% beware: no \s! before keys as these are interpreted + +\starttypescriptcollection[\s!size] + +\starttypescript [\s!serif] [\s!default] [\s!size] + \definebodyfont + [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] + [\s!rm] [\s!default] +\stoptypescript + +\starttypescript [\s!sans] [\s!default] [\s!size] + \definebodyfont + [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] + [\s!ss] [\s!default] +\stoptypescript + +\starttypescript [\s!mono] [\s!default] [\s!size] + \definebodyfont + [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] + [\s!tt] [\s!default] +\stoptypescript + +\starttypescript [\s!math] [\s!default] [\s!size] + \definebodyfont + [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] + [\s!mm] [\s!default] +\stoptypescript + +\starttypescript [\s!handwriting] [\s!default] [\s!size] + \definebodyfont + [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] + [\s!hw] [\s!default] +\stoptypescript + +\starttypescript [\s!calligraphy] [\s!default] [\s!size] + \definebodyfont + [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] + [\s!cg] [\s!default] +\stoptypescript + +\starttypescript [\s!casual] [\s!default] [\s!size] + \definebodyfont + [4pt,5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,14.4pt,17.3pt] + [\s!rm] [\s!default] +\stoptypescript + +\starttypescript [\s!all] [\s!dtp] [\s!size] + + \definebodyfontenvironment + [4pt] + [\s!text=4pt,\s!script=4pt,\s!scriptscript=4pt, + \s!x=4pt,\s!xx=4pt,\v!big=6pt,\v!small=4pt] + + \definebodyfontenvironment + [5pt] + [\s!text=5pt,\s!script=5pt,\s!scriptscript=5pt, + \s!x=5pt,\s!xx=5pt,\v!big=7pt,\v!small=5pt] + + \definebodyfontenvironment + [6pt] + [\s!text=6pt,\s!script=5pt,\s!scriptscript=5pt, + \s!x=5pt,\s!xx=5pt,\v!big=8pt,\v!small=5pt] + + \definebodyfontenvironment + [7pt] + [\s!text=7pt,\s!script=6pt,\s!scriptscript=5pt, + \s!x=6pt,\s!xx=5pt,\v!big=9pt,\v!small=5pt] + + \definebodyfontenvironment + [8pt] + [\s!text=8pt,\s!script=6pt,\s!scriptscript=5pt, + \s!x=6pt,\s!xx=5pt,\v!big=10pt,\v!small=6pt] + + \definebodyfontenvironment + [9pt] + [\s!text=9pt,\s!script=7pt,\s!scriptscript=5pt, + \s!x=7pt,\s!xx=5pt,\v!big=11pt,\v!small=7pt] + + \definebodyfontenvironment + [10pt] + [\s!text=10pt,\s!script=7pt,\s!scriptscript=5pt, + \s!x=8pt,\s!xx=6pt,\v!big=12pt,\v!small=8pt] + + \definebodyfontenvironment + [11pt] + [\s!text=11pt,\s!script=8pt,\s!scriptscript=6pt, + \s!x=9pt,\s!xx=7pt,\v!big=13pt,\v!small=9pt] + + \definebodyfontenvironment + [12pt] + [\s!text=12pt,\s!script=9pt,\s!scriptscript=7pt, + \s!x=10pt,\s!xx=8pt,\v!big=14pt,\v!small=10pt] + + \definebodyfontenvironment + [13pt] + [\s!text=13pt,\s!script=10pt,\s!scriptscript=8pt, + \s!x=11pt,\s!xx=9pt,\v!big=16pt,\v!small=11pt] + + \definebodyfontenvironment + [14pt] + [\s!text=14pt,\s!script=10pt,\s!scriptscript=7pt, + \s!x=12pt,\s!xx=10pt,\v!big=16pt,\v!small=12pt] + + \definebodyfontenvironment + [16pt] + [\s!text=16pt,\s!script=12pt,\s!scriptscript=9pt, + \s!x=13pt,\s!xx=11pt,\v!big=18pt,\v!small=14pt] + + % suboptimal math sizes + + \definebodyfontenvironment + [18pt] + [\s!text=18pt,\s!script=16pt,\s!scriptscript=14pt, + \s!x=16pt,\s!xx=14pt,\v!big=22pt,\v!small=16pt] + + \definebodyfontenvironment + [22pt] + [\s!text=22pt,\s!script=22pt,\s!scriptscript=18pt, + \s!x=18pt,\s!xx=16pt,\v!big=28pt,\v!small=18pt] + + \definebodyfontenvironment + [28pt] + [\s!text=28pt,\s!script=22pt,\s!scriptscript=18pt, + \s!x=22pt,\s!xx=18pt,\v!big=28pt,\v!small=22pt] + +\stoptypescript + +\starttypescript [\s!serif] [\s!dtp] [\s!size] + \definebodyfont + [5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,13pt,14pt,16pt,18pt,22pt,28pt] + [\s!rm] [\s!default] +\stoptypescript + +\starttypescript [\s!sans] [\s!dtp] [\s!size] + \definebodyfont + [5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,13pt,14pt,16pt,18pt,22pt,28pt] + [\s!ss] [\s!default] +\stoptypescript + +\starttypescript [\s!mono] [\s!dtp] [\s!size] + \definebodyfont + [5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,13pt,14pt,16pt,18pt,22pt,28pt] + [\s!tt] [\s!default] +\stoptypescript + +\starttypescript [\s!math] [\s!dtp] [\s!size] + \definebodyfont + [5pt,6pt,7pt,8pt,9pt,10pt,11pt,12pt,13pt,14pt,16pt,18pt,22pt,28pt] + [\s!mm] [\s!default] +\stoptypescript + +\stoptypescriptcollection + +\protect \endinput diff --git a/tex/context/base/mkxl/typo-bld.mkxl b/tex/context/base/mkxl/typo-bld.mkxl new file mode 100644 index 000000000..d170397fc --- /dev/null +++ b/tex/context/base/mkxl/typo-bld.mkxl @@ -0,0 +1,62 @@ +%D \module +%D [ file=typo-bld, % was node-par, +%D version=2008.09.30, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Paragraph Building, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Paragraph Building} + +%D This is very experimental, undocumented, subjected to changes, etc. just as +%D the underlying interfaces. But at least it's cleaned as part of the status-mkiv +%D cleanup. + +% \enabletrackers[builders.hpack.overflow] +% \enabletrackers[builders.hpack.quality] +% \enabletrackers[builders.vpack.quality] + +% \startparbuilder[default] +% \input tufte \par +% \startparbuilder[oneline] +% \input tufte \par +% \stopparbuilder +% \input tufte \par +% \stopparbuilder +% +% \startparbuilder[oneline] +% \dorecurse{100}{\input ward \par} +% \stopparbuilder + +\unprotect + +\registerctxluafile{typo-bld}{} + +\definesystemattribute[parbuilder][public] + +\installcorenamespace {parbuilder} + +\permanent\protected\def\defineparbuilder [#1]{\clf_defineparbuilder{#1}} +\permanent\protected\def\setmainparbuilder[#1]{\clf_setparbuilder{#1}} + +\permanent\protected\def\startparbuilder [#1]{\ifhmode\par\fi\clf_startparbuilder{#1}} +\permanent\protected\def\stopparbuilder {\ifhmode\par\fi\clf_stopparbuilder} + +%D There is no high level interface because after all implementing a linebreaker +%D is not something that the average user will do. + +\defineparbuilder[default] % just for testing +\defineparbuilder[oneline] % just for testing +\defineparbuilder[basic] % just for testing + +%D This hooks in otr so we need to pickup. + +\permanent\protected\def\enableparbuilders {\clf_enableparbuilder } % can be public implementor +\permanent\protected\def\disableparbuilders{\clf_disableparbuilder} % can be public implementor + +\protect \endinput diff --git a/tex/context/base/mkiv/typo-brk.mkxl b/tex/context/base/mkxl/typo-brk.mkxl index 51abc1034..51abc1034 100644 --- a/tex/context/base/mkiv/typo-brk.mkxl +++ b/tex/context/base/mkxl/typo-brk.mkxl diff --git a/tex/context/base/mkiv/typo-cap.mkxl b/tex/context/base/mkxl/typo-cap.mkxl index 587ab62ef..587ab62ef 100644 --- a/tex/context/base/mkiv/typo-cap.mkxl +++ b/tex/context/base/mkxl/typo-cap.mkxl diff --git a/tex/context/base/mkxl/typo-chr.mkxl b/tex/context/base/mkxl/typo-chr.mkxl new file mode 100644 index 000000000..c4fbeba17 --- /dev/null +++ b/tex/context/base/mkxl/typo-chr.mkxl @@ -0,0 +1,87 @@ +%D \module +%D [ file=typo-chr, +%D version=2015.01.01, % or about that time +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Cleaning Up Mess, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Characters} + +\unprotect + +%D This is a very experimental feature, mostly for Alan and me to play with in +%D publication hell. +%D +%D \startbuffer +%D before, after\par +%D before,\removepunctuation after\par +%D before\markcontent[gone]{\darkred gone}\removemarkedcontent[gone]after\par +%D before\markcontent[kept]{\darkgreen kept}\removemarkedcontent[gone]after\par +%D \markcontent[gone]{\darkred gone}\removemarkedcontent[gone]after\par +%D \markcontent[kept]{\darkgreen kept}\removemarkedcontent[gone]after\par +%D \stopbuffer +%D +%D \typebuffer \blank \getbuffer\blank +%D +%D This feature is paragraph based and is only to be used for small snippets of text, +%D for instance when combining bit and pieces where keeping a state is complex compared +%D to cleaning up unwanted stuff. + +\registerctxluafile{typo-chr}{} + +\definesystemattribute[marked][public] + +\permanent\protected\def\removepunctuation{\clf_pickuppunctuation action{remove}\relax} +\permanent\protected\def\pushpunctuation {\clf_pickuppunctuation action{push}\relax} +\permanent\protected\def\poppunctuation {\clf_pickuppunctuation action{pop}\relax} + +\permanent\tolerant\protected\def\markcontent[#1]#:#2% + {\dontleavehmode + \bgroup + \clf_markcontent{#1}% + \bgroup + #2% double grouping makes aftergroups work ok + \egroup + \egroup} + +\permanent\tolerant\protected\def\startmarkedcontent[#1]% + {\dontleavehmode + \bgroup + \clf_markcontent{#1}% + % double grouping makes aftergroups work ok + \bgroup} + +\permanent\protected\def\stopmarkedcontent + {\egroup + \egroup} + +\permanent\tolerant\protected\def\removemarkedcontent[#1]% + {\clf_pickupmarkedcontent action{remove}mark{#1}\relax} + +\permanent\protected\def\doifelsemarkedcontent#1% + {\clf_doifelsemarkedcontent{#1}} + +%D A few helpers (put here for convenience): +%D +%D \starttyping +%D test test\doifelselastnode{boundary}{word}{YES}{NOP}test +%D test test\wordboundary \doifelselastnode{boundary}{word}{YES}{NOP}test +%D test test\wordboundary \doifelseatwordboundary{YES}{NOP}test +%D test test \lastnodeidstring test +%D test test\lastnodeidstring test +%D test test\number\lastnodeid test +%D \stoptyping + +\newcount\c_syst_last_node_id + +\permanent\protected\def\doifelselastnode {\clf_lastnodeequals} % can be public implementors +\permanent\protected\def\doifelseatwordboundary{\clf_atwordboundary} % can be public implementors +\permanent\protected\def\lastnodeid {\clf_lastnodeid\c_syst_last_node_id} % can be public implementors + +\protect \endinput diff --git a/tex/context/base/mkiv/typo-cln.mkxl b/tex/context/base/mkxl/typo-cln.mkxl index 84fc1d235..84fc1d235 100644 --- a/tex/context/base/mkiv/typo-cln.mkxl +++ b/tex/context/base/mkxl/typo-cln.mkxl diff --git a/tex/context/base/mkiv/typo-del.mkxl b/tex/context/base/mkxl/typo-del.mkxl index 3550626aa..ab25f72d8 100644 --- a/tex/context/base/mkiv/typo-del.mkxl +++ b/tex/context/base/mkxl/typo-del.mkxl @@ -225,11 +225,6 @@ %D \typebuffer %D \getbuffer -%unexpanded\def\startsubsentence{\beginofsubsentence\prewordbreak\beginofsubsentencespacing\typo_subsentence_cleanup_start} -%unexpanded\def\stopsubsentence {\typo_subsentence_cleanup_stop\endofsubsentencespacing\prewordbreak\endofsubsentence} -%unexpanded\def\subsentence {\groupedcommandcs\startsubsentence\stopsubsentence} -%unexpanded\def\midsubsentence {\typo_subsentence_cleanup_start\prewordbreak\midsentence\prewordbreak\typo_subsentence_cleanup_stop} - \permanent\protected\def\startsubsentence{\beginofsubsentence\wordboundary\beginofsubsentencespacing\wordboundary\typo_subsentence_cleanup_start} \permanent\protected\def\stopsubsentence {\typo_subsentence_cleanup_stop\wordboundary\endofsubsentencespacing\wordboundary\endofsubsentence} \permanent\protected\def\subsentence {\groupedcommandcs\startsubsentence\stopsubsentence} @@ -381,9 +376,9 @@ \appendtoks \expandafter\newcount\csname\??delimitedtextlevel\currentdelimitedtext\endcsname - \setuevalue{\currentdelimitedtext }{\delimitedtext[\currentdelimitedtext]}% - \setuevalue{\e!start\currentdelimitedtext}{\startdelimitedtext[\currentdelimitedtext]}% - \setuevalue{\e!stop \currentdelimitedtext}{\stopdelimitedtext}% + \frozen\instance\setuevalue{\currentdelimitedtext }{\delimitedtext[\currentdelimitedtext]}% + \frozen\instance\setuevalue{\e!start\currentdelimitedtext}{\startdelimitedtext[\currentdelimitedtext]}% + \frozen\instance\setuevalue{\e!stop \currentdelimitedtext}{\stopdelimitedtext}% \to \everydefinedelimitedtext \setupdelimitedtext diff --git a/tex/context/base/mkxl/typo-dig.mkxl b/tex/context/base/mkxl/typo-dig.mkxl new file mode 100644 index 000000000..822fa0d34 --- /dev/null +++ b/tex/context/base/mkxl/typo-dig.mkxl @@ -0,0 +1,58 @@ +%D \module +%D [ file=typo-dig, +%D version=2010.01.18, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Digits, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Digits} + +\unprotect + +\registerctxluafile{typo-dig}{} + +\definesystemattribute[digits][public] + +%D This could as well be a dynamic font feature but why bother. +%D +%D \macros +%D {\equaldigits} +%D +%D \startbuffer +%D test test \ruledhbox{123} test test\par +%D test test \ruledhbox{\equaldigits{123}} test test\par +%D test test \equaldigits{123} test test\par +%D \stopbuffer +%D +%D \typebuffer +%D +%D This calls result in: +%D +%D \startlines +%D \getbuffer +%D \stoplines + +\permanent\protected\def\setdigitsmanipulation[#1]% can be public implementor + {\clf_setdigitsmanipulation{#1}} + +\permanent\protected\def\resetdigitsmanipulation + {\c_attr_digits\attributeunsetvalue} + +\appendtoks + \resetdigitsmanipulation +\to \everyresettypesetting + +\permanent\protected\def\equaldigits{\groupedcommand{\setdigitsmanipulation[\number\plusone]}{}} +\permanent\protected\def\dummydigit {\hphantom {\setdigitsmanipulation[\number\plusone]0}} + +\appendtoks + \resetdigitsmanipulation +\to \everyinitializeverbatim + +\protect \endinput diff --git a/tex/context/base/mkiv/typo-dir.mkxl b/tex/context/base/mkxl/typo-dir.mkxl index 55fabffc0..a8ba1fc70 100644 --- a/tex/context/base/mkiv/typo-dir.mkxl +++ b/tex/context/base/mkxl/typo-dir.mkxl @@ -33,18 +33,13 @@ \installsimplecommandhandler \??directions {directions} \??directions % no \define... yet -\permanent\edef\lefttorightmark{\normalUchar"200E} \let\lrm\lefttorightmark % expandable -\permanent\edef\righttoleftmark{\normalUchar"200F} \let\rlm\righttoleftmark % expandable +\immutable\edef\lefttorightmark{\normalUchar"200E} \aliased\let\lrm\lefttorightmark % expandable +\immutable\edef\righttoleftmark{\normalUchar"200F} \aliased\let\rlm\righttoleftmark % expandable \permanent\protected\def\setdirection[#1]% todo: symbolic names {\clf_setdirection#1\relax} -% \protected\def\resetdirection -% {\clf_setdirection\zerocount} -% -% is in fact: - -\protected\def\resetdirection +\permanent\protected\def\resetdirection {\c_attr_directions\attributeunsetvalue} \newconstant\directionsbidimode % this one might become pivate @@ -62,7 +57,7 @@ method {\directionsparameter\c!method}% fences {\directionsparameter\c!fences}% }% - \global\letcsname\??directionsbidimode\currentbidistamp\endcsname\currentbidimode} + \gletcsname\??directionsbidimode\currentbidistamp\endcsname\currentbidimode} \appendtoks \edef\p_bidi{\directionsparameter\c!bidi}% diff --git a/tex/context/base/mkxl/typo-drp.mkxl b/tex/context/base/mkxl/typo-drp.mkxl new file mode 100644 index 000000000..9a6ae7603 --- /dev/null +++ b/tex/context/base/mkxl/typo-drp.mkxl @@ -0,0 +1,129 @@ +%D \module +%D [ file=typo-drp, % was typo-par +%D version=2011.10.27, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Initials, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Initials} + +%D This will change ... par specific attribute set and such. + +\unprotect + +\registerctxluafile{typo-drp}{} + +\definesystemattribute[initial][public] + +\appendtoks + \c_attr_initial\attributeunsetvalue +\to \everyforgetall + +%D For the moment here: dropped caps redone. In addition to the parameters shown in +%D the example you can use the \type {style} and more low level \type {font} keys to +%D set up the font where the first one wins. If you don't like the behaviour you can +%D always roll out your own command. +%D +%D \starttyping +%D \placeinitial \input ward \par \input ward \par \placeinitial \input tufte +%D +%D \setupinitial +%D [location=text, +%D n=2, +%D color=darkred, +%D distance=-1em, +%D hoffset=1em, +%D voffset=-3ex, +%D before=\blank] +%D +%D \placeinitial \input ward \par \input ward \placeinitial \input tufte +%D \stoptyping + +% todo: angle (once we can set parshape at the Lua end) + +\installcorenamespace{initial} + +\installcommandhandler \??initial {initial} \??initial + +\definemeasure[initial:n][\lineheight*\initialparameter\c!n - \strutdp] + +\setupinitial + [\c!location=\v!text, + \c!n=3, + \c!m=1, + \c!method=\v!none, + % \c!font=Bold sa 4, + % \c!font=Bold ht \measure{initial:n}, + \c!font=Bold cp \measure{initial:n}, + \c!distance=.125\emwidth, + \c!hoffset=\zeropoint, + \c!voffset=\v!line, % \dimexp\lineheight*\initialparameter\c!n-\lineheight\relax] + \c!style=, + \c!color=, + \c!before=\blank] + +\permanent\tolerant\protected\def\placeinitial[#1]% old command + {\par + \namedinitialparameter{#1}\c!before + \edef\typo_initial_handle{\typo_initial_handle_indeed{#1}{}}} + +\permanent\tolerant\protected\def\setinitial[#1]#*[#2]% + {\edef\typo_initial_handle{\typo_initial_handle_indeed{#1}{#2}}} + +\protected\def\typo_initial_handle_indeed#1#2% + {\dontleavehmode + \begingroup + \edef\currentinitial{#1}% + \setupcurrentinitial[#2]% + \resetfontfeature % might be needed in more places + \doifelsenothing{\initialparameter\c!style} + {\definedfont[\initialparameter\c!font]} + {\useinitialstyleparameter\c!style}% + \useinitialcolorparameter\c!color + \edef\p_voffset{\initialparameter\c!voffset}% + \scratchcounter \initialparameter\c!n\relax + \scratchvoffset\dimexpr\ifx\p_voffset\v!line\scratchcounter\lineheight-\lineheight\else\p_voffset\fi\relax + \clf_setinitial + location {\initialparameter\c!location}% + enabled true\space + n \scratchcounter + m \numexpr\initialparameter\c!m\relax + method {\initialparameter\c!method}% + distance \dimexpr\initialparameter\c!distance\relax + hoffset \dimexpr\initialparameter\c!hoffset\relax + voffset \scratchvoffset + ma \c_attr_colormodel + ca \c_attr_color + ta \c_attr_transparency + font \fontid\font + dynamic \font_dynamic_value % it's a bit over the top to support this here + \relax + \c_attr_initial\plusone + \initialparameter\c!text + \endgroup + \glet\typo_initial_handle\relax} + +\let\typo_initial_handle\relax + +% \setupbodyfont[dejavu,9pt] +% +% \startbuffer +% \setinitial[two] D. E. Knuth \ignorespaces\input knuth \par +% \setinitial[two] Knuth \ignorespaces\input knuth \par +% \setinitial[two] \quotation{D. E. Knuth} \ignorespaces\input knuth \par +% \setinitial[two] \quotation {Knuth} \ignorespaces\input knuth \par +% \setinitial[two] [text={D.E. Knuth}] \ignorespaces\input knuth \par +% \setinitial[two] [m=4] D. E. Knuth \ignorespaces\input knuth \par +% \stopbuffer +% +% \type{m=2} \start \defineinitial[two][m=2,method=none] \getbuffer \page \stop +% \type{m=1,method=auto} \start \defineinitial[two][m=1,method=auto] \getbuffer \page \stop +% \type{m=1,method={auto,first,last}} \start \defineinitial[two][m=1,method={first,auto,last}] \getbuffer \page \stop + +\protect \endinput diff --git a/tex/context/base/mkxl/typo-fkr.mkxl b/tex/context/base/mkxl/typo-fkr.mkxl new file mode 100644 index 000000000..f56294dc0 --- /dev/null +++ b/tex/context/base/mkxl/typo-fkr.mkxl @@ -0,0 +1,38 @@ +%D \module +%D [ file=typo-fkr, +%D version=2016.10.10, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Additional Font Kerning, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Additional Font Kerning} + +\registerctxluafile{typo-fkr}{} + +\definesystemattribute[extrafontkern][public] + +\unprotect + +% none : not across fonts (but still within) +% min : min value across fonts +% max : max value across fonts +% mixed : mean value across fonts +% reset : disable + +\permanent\protected\def\setextrafontkerns[#1]% % can be public implementor + {\clf_setextrafontkerns{#1}} + +\permanent\protected\def\resetextrafontkerns + {\c_attr_extrafontkern\attributeunsetvalue} + +\appendtoks + \resetextrafontkerns +\to \everyresettypesetting + +\protect diff --git a/tex/context/base/mkxl/typo-fln.mkxl b/tex/context/base/mkxl/typo-fln.mkxl new file mode 100644 index 000000000..2696dd06b --- /dev/null +++ b/tex/context/base/mkxl/typo-fln.mkxl @@ -0,0 +1,109 @@ +%D \module +%D [ file=typo-fln, +%D version=2013.08.22, % comes from the few years older m-newstuff +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=First Lines, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / First Lines} + +%D I had this code laying around for a while \unknown\ probably as a side effect +%D of cleaning up the supp-fun modules. There is probably room for improvement +%D and more features. + +% \setupbodyfont[pagella] +% +% \starttext +% +% \setupindenting[medium,yes] +% +% \definefirstline +% [smallcaps] +% [alternative=line, +% color=darkred, +% style=\setfontfeature{smallcaps}] +% +% \setfirstline[smallcaps] \input tufte \par +% \setfirstline[smallcaps] \input ward \par +% \setfirstline[smallcaps] \input knuth \par +% \setfirstline[smallcaps] \input bryson \par +% +% \definefirstline +% [smallcaps] +% [alternative=word, +% color=darkblue, +% style=bold, +% n=2] +% +% \setfirstline[smallcaps] \input tufte \par +% \setfirstline[smallcaps] \input ward \par +% \setfirstline[smallcaps] \input knuth \par +% \setfirstline[smallcaps] \input bryson \par +% +% \stoptext + +\unprotect + +\registerctxluafile{typo-fln}{} + +\definesystemattribute[firstline][public] + +\appendtoks + \c_attr_firstline\attributeunsetvalue +\to \everyforgetall + +\installcorenamespace {firstline} + +\installcommandhandler \??firstline {firstline} \??firstline + +\setupfirstline + [\c!alternative=\v!line, + %\c!style=, + %\c!color=, + \c!n=1] + +\permanent\tolerant\protected\def\setfirstline[#1]% + {\edef\typo_firstline_handle{\typo_firstline_handle_indeed{#1}}} + +\protected\def\typo_firstline_handle_indeed#1% + {\dontleavehmode + \begingroup + \edef\currentfirstline{#1}% + \usefirstlinestyleandcolor\c!style\c!color + \clf_setfirstline + alternative {\firstlineparameter\c!alternative}% + ma \c_attr_colormodel + ca \c_attr_color + ta \c_attr_transparency + n \numexpr\firstlineparameter\c!n\relax + font \fontid\font + dynamic \font_dynamic_value + \relax +% \kern\zeropoint % we need a node +% \hskip\zeropoint\s!plus\emwidth\relax % can be an option + \endgroup + \glet\typo_firstline_handle\relax} + +\let\typo_firstline_handle\relax + +% goodie, question on list +% +% \defineframed[ChapterFramed][location=low,background=color,backgroundcolor=red,frame=off] +% +% \setuphead[chapter][deeptextcommand=\applytofirstcharacter\ChapterFramed] + +\permanent\protected\def\applytofirstcharacter#1% + {\begingroup + \dowithnextbox + {\clf_applytofirstcharacter\nextbox{\csstring#1}% + \unhbox\nextbox + \endgroup}% + \hbox} + +\protect \endinput diff --git a/tex/context/base/mkiv/typo-ini.mkxl b/tex/context/base/mkxl/typo-ini.mkxl index 3e0790af0..3e0790af0 100644 --- a/tex/context/base/mkiv/typo-ini.mkxl +++ b/tex/context/base/mkxl/typo-ini.mkxl diff --git a/tex/context/base/mkiv/typo-inj.mkxl b/tex/context/base/mkxl/typo-inj.mkxl index 7bd01aac0..7bd01aac0 100644 --- a/tex/context/base/mkiv/typo-inj.mkxl +++ b/tex/context/base/mkxl/typo-inj.mkxl diff --git a/tex/context/base/mkiv/typo-itc.mklx b/tex/context/base/mkxl/typo-itc.mklx index f979261c8..f979261c8 100644 --- a/tex/context/base/mkiv/typo-itc.mklx +++ b/tex/context/base/mkxl/typo-itc.mklx diff --git a/tex/context/base/mkxl/typo-itm.mkxl b/tex/context/base/mkxl/typo-itm.mkxl new file mode 100644 index 000000000..3a2e2ce17 --- /dev/null +++ b/tex/context/base/mkxl/typo-itm.mkxl @@ -0,0 +1,270 @@ +%D \module +%D [ file=typo-itm, % comes from core-mis +%D version=2012.06.28, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Item Lists, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Node Macros / Item Lists} + +\unprotect + +%D This is a real old mechanism that we once used for questionaries. As it is documented +%D we keep it around. A more modern implementation would probably use another approach +%D but I don't want to spend too much time on it now. There are a couple of changes: +%D +%D \startitemize +%D \startitem textwidth sets the combined width \stopitem +%D \startitem width sets the symbolwidth \stopitem +%D \startitem alternative is used instead of location \stopitem +%D \stopitemize +%D +%D \startbuffer +%D \items[alternative=left]{a,b,c} +%D \items[alternative=left,align=middle,textalign=flushright,distance=1em]{a,b,c} +%D \items[alternative=right]{a,b,c} +%D \items[alternative=inmargin]{a,b,c} +%D \items[alternative=top]{a,b,c} +%D \items[alternative=bottom]{a,b,c} +%D \items[alternative=bottom,align=flushleft,textstyle=bold,color=red,textcolor=green]{a,b,c} +%D \stopbuffer +%D +%D \typebuffer +%D +%D This renders as: +%D +%D \getbuffer + +\installcorenamespace{items} +\installcorenamespace{itemsalternatives} +\installcorenamespace{itemshorizontal} +\installcorenamespace{itemsvertical} + +\installcommandhandler \??items {items} \??items + +\setupitems + [\c!alternative=\v!left, + \c!symbol=5, + \c!textwidth=\availablehsize, + \c!align=\v!middle, + \c!textalign=\v!flushleft, + \c!distance=\zeropoint, + %\c!n=, + \c!before=\blank, + \c!inbetween={\blank[\v!medium]}, + \c!after=\blank] + +\newcount\c_typo_items_n +\newcount\c_typo_items_m +\newdimen\d_typo_items_text_width +\newdimen\d_typo_items_symbol_width +\newdimen\d_typo_items_distance +\newbox \b_typo_items_symbols +\newbox \b_typo_items_texts + +\permanent\tolerant\protected\def\items[#1]#:#2% + {\bgroup + \setupitems[#1]% + \edef\p_typo_items_alternative{\itemsparameter\c!alternative}% + \ifcsname\??itemsalternatives\p_typo_items_alternative\endcsname \else + \let\p_typo_items_alternative\v!left + \fi + \let\currentitems\p_typo_items_alternative + \setupcurrentitems[#1]% + % + \edef\p_typo_items_textwidth{\itemsparameter\c!textwidth}% + \ifempty\p_typo_items_textwidth + \d_typo_items_text_width\availablehsize + \else + \d_typo_items_text_width\p_typo_items_textwidth\relax + \fi + % + \edef\p_typo_items_width{\itemsparameter\c!width}% + \ifempty\p_typo_items_width + \d_typo_items_symbol_width1.5\emwidth + \else + \d_typo_items_symbol_width\p_typo_items_width\relax + \fi + % + \edef\p_typo_items_distance{\itemsparameter\c!distance}% + \ifempty\p_typo_items_distance + \d_typo_items_distance\zeropoint + \else + \d_typo_items_distance\p_typo_items_distance\relax + \fi + % + \edef\p_typo_items_symbol{\itemsparameter\c!symbol}% + \ifempty\p_typo_items_symbol + \let\m_typo_items_symbol\firstofoneargument + \orelse\ifx\p_typo_items_symbol\v!none + \let\p_typo_items_symbol\empty + \let\m_typo_items_symbol\firstofoneargument + \else + \doifelseconversiondefined\p_typo_items_symbol + {\def\m_typo_items_symbol{\convertnumber\p_typo_items_symbol}} + {\doifelsesymboldefined\p_typo_items_symbol + {\def\m_typo_items_symbol{\symbol[\p_typo_items_symbol]\gobbleoneargument}} + {\let\m_typo_items_symbol\firstofoneargument}}% + \fi + % + \edef\p_typo_items_align{\itemsparameter\c!align}% + \edef\p_typo_items_textalign{\itemsparameter\c!textalign}% + % + \edef\p_typo_items_n{\itemsparameter\c!n}% + \ifempty\p_typo_items_n + \getcommalistsize[#2]% + \c_typo_items_n\commalistsize\relax % \commalistcounter + \else + \c_typo_items_n\p_typo_items_n\relax + \fi + % + \parindent\zeropoint + \dontcomplain + % + \itemsparameter\c!before + \csname\??itemsalternatives\p_typo_items_alternative\endcsname{#2}% + \itemsparameter\c!after + \egroup} + +% rendering + +\setvalue{\??itemshorizontal\v!margin}#1% + {\ifnum\c_typo_items_m=\plusone\hss\else\hfill\fi + \strut#1% + \ifnum\c_typo_items_m=\c_typo_items_n\hss\else\hfill\fi} + +\setvalue{\??itemshorizontal\s!unknown}% + {\simplealignedbox\scratchwidth\m_typo_items_align} + +\def\typo_items_item_horizontal + {\advance\c_typo_items_m\plusone + \csname\??itemshorizontal + \ifcsname\??itemshorizontal\p_typo_items_align\endcsname + \p_typo_items_align + \else + \s!unknown + \fi + \endcsname} + +\setvalue{\??itemsvertical\s!unknown}% + {\simplealignedbox\scratchwidth\m_typo_items_align} + +\def\typo_items_item_vertical + {\advance\c_typo_items_m\plusone + \csname\??itemsvertical + \ifcsname\??itemsvertical\p_typo_items_align\endcsname + \p_typo_items_align + \else + \s!unknown + \fi + \endcsname} + +\def\typo_items_make_horizontal#1% + {\divide\scratchwidth\c_typo_items_n + \hbox{#1}} + +\def\typo_items_make_vertical#1% + {\vbox{#1}} + +\def\typo_items_construct_items_boxes#1% + {\setbox\b_typo_items_texts\hbox + {\c_typo_items_m\zerocount + \let\m_typo_items_align\p_typo_items_textalign + \scratchwidth\d_typo_items_text_width + \useitemsstyleandcolor\c!textstyle\c!textcolor + \typo_items_make{\processcommalist[#1]\typo_items_item}}% + \ifempty\p_typo_items_symbol + \setbox\b_typo_items_symbols\emptyhbox + \else + \setbox\b_typo_items_symbols\hbox + {\c_typo_items_m\zerocount + \let\m_typo_items_align\p_typo_items_align + \scratchwidth\d_typo_items_symbol_width + \useitemsstyleandcolor\c!style\c!color + \typo_items_make{\dorecurse\c_typo_items_n{\typo_items_item{\strut\m_typo_items_symbol\recurselevel}}}}% + \fi} + +% alternatives: + +\defineitems[\v!top][\c!width=\d_typo_items_text_width,\c!textalign=\itemsparameter\c!align] + +\setvalue{\??itemsalternatives\v!top}#1% + {\let\typo_items_make\typo_items_make_horizontal + \let\typo_items_item\typo_items_item_horizontal + \typo_items_construct_items_boxes{#1}% + \noindent\vbox\bgroup + \forgetall + \ifvoid\b_typo_items_symbols \else + \box\b_typo_items_symbols + \itemsparameter\c!inbetween + \nointerlineskip + \fi + \box\b_typo_items_texts\ + \egroup} + +\defineitems[\v!bottom][\c!width=\d_typo_items_text_width,\c!textalign=\itemsparameter\c!align] + +\setvalue{\??itemsalternatives\v!bottom}#1% + {\let\typo_items_make\typo_items_make_horizontal + \let\typo_items_item\typo_items_item_horizontal + \typo_items_construct_items_boxes{#1}% + \noindent\vbox\bgroup + \forgetall + \box\b_typo_items_texts + \ifvoid\b_typo_items_symbols \else + \itemsparameter\c!inbetween + \nointerlineskip + \box\b_typo_items_symbols + \fi + \egroup} + +\defineitems[\v!inmargin][\c!width=1.5\emwidth,\c!align=\v!flushright,\c!distance=\leftmargindistance] + +\setvalue{\??itemsalternatives\v!inmargin}#1% + {\let\typo_items_make\typo_items_make_vertical + \let\typo_items_item\typo_items_item_vertical + \typo_items_construct_items_boxes{#1}% + \noindent\hbox\bgroup + \ifvoid\b_typo_items_symbols \else + \llap{\box\b_typo_items_symbols\hskip\d_typo_items_distance}% + \fi + \box\b_typo_items_texts + \egroup} + +\defineitems[\v!left][\c!width=1.5\emwidth,\c!align=\v!flushleft] + +\setvalue{\??itemsalternatives\v!left}#1% + {\let\typo_items_make\typo_items_make_vertical + \let\typo_items_item\typo_items_item_vertical + \advance\d_typo_items_text_width-\dimexpr\d_typo_items_symbol_width+\d_typo_items_distance\relax + \typo_items_construct_items_boxes{#1}% + \noindent\hbox\bgroup + \ifvoid\b_typo_items_symbols \else + \box\b_typo_items_symbols + \kern\d_typo_items_distance + \fi + \box\b_typo_items_texts + \egroup} + +\defineitems[\v!right][\c!width=1.5\emwidth,\c!align=\v!flushright] + +\setvalue{\??itemsalternatives\v!right}#1% + {\let\typo_items_make\typo_items_make_vertical + \let\typo_items_item\typo_items_item_vertical + \advance\d_typo_items_text_width-\dimexpr\d_typo_items_symbol_width+\d_typo_items_distance\relax + \typo_items_construct_items_boxes{#1}% + \noindent\hbox\bgroup + \box\b_typo_items_texts + \ifvoid\b_typo_items_symbols \else + \kern\d_typo_items_distance + \box\b_typo_items_symbols + \fi + \egroup} + +\protect \endinput diff --git a/tex/context/base/mkiv/typo-krn.mkxl b/tex/context/base/mkxl/typo-krn.mkxl index 5573fc529..5573fc529 100644 --- a/tex/context/base/mkiv/typo-krn.mkxl +++ b/tex/context/base/mkxl/typo-krn.mkxl diff --git a/tex/context/base/mkiv/typo-lan.mkxl b/tex/context/base/mkxl/typo-lan.mkxl index 9d137f5a5..9d137f5a5 100644 --- a/tex/context/base/mkiv/typo-lan.mkxl +++ b/tex/context/base/mkxl/typo-lan.mkxl diff --git a/tex/context/base/mkiv/typo-lig.mkxl b/tex/context/base/mkxl/typo-lig.mkxl index e30774d8e..e30774d8e 100644 --- a/tex/context/base/mkiv/typo-lig.mkxl +++ b/tex/context/base/mkxl/typo-lig.mkxl diff --git a/tex/context/base/mkiv/typo-lin.lmt b/tex/context/base/mkxl/typo-lin.lmt index e49f13b60..e49f13b60 100644 --- a/tex/context/base/mkiv/typo-lin.lmt +++ b/tex/context/base/mkxl/typo-lin.lmt diff --git a/tex/context/base/mkiv/typo-lin.mkxl b/tex/context/base/mkxl/typo-lin.mkxl index 6b142b32d..6b142b32d 100644 --- a/tex/context/base/mkiv/typo-lin.mkxl +++ b/tex/context/base/mkxl/typo-lin.mkxl diff --git a/tex/context/base/mkiv/typo-mar.mkxl b/tex/context/base/mkxl/typo-mar.mkxl index 5d6f15f21..5d6f15f21 100644 --- a/tex/context/base/mkiv/typo-mar.mkxl +++ b/tex/context/base/mkxl/typo-mar.mkxl diff --git a/tex/context/base/mkxl/typo-ovl.mkxl b/tex/context/base/mkxl/typo-ovl.mkxl new file mode 100644 index 000000000..8ad4cce26 --- /dev/null +++ b/tex/context/base/mkxl/typo-ovl.mkxl @@ -0,0 +1,116 @@ +%D \module +%D [ file=lang-ovl, +%D version=2016.02.03, % about that time (maybe earlier) +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Overloads, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Overloads} + +\unprotect + +%D See \LUA\ file for comments. I'll probably never use this code outside the +%D project where it had some experimental use. (Occasionally we do some spell +%D checking and suspicious word usage marking.) So there is not much documentation +%D here. Keep in mind that overloading only makes sense for content that gets +%D replaced as otherwise normal attributes make more sense. Using this otherwise +%D is weird but one never knows what users come up with. + +\registerctxluafile{typo-ovl}{} + +\definesystemattribute[overloads][public,global] + +\installcorenamespace{overloads} + +%D Watch how we abuse highlights. + +\newcount\c_typo_overload_font_id + +\protected\def\typo_overloads_define#1% + {\begingroup + % we pack so we avoid interference (and for sure don't process!) + \setbox\scratchbox\hpack\bgroup + \global\c_typo_overload_font_id\fontid\font + \resetallattributes % so we only change what gets set + \highlight[#1]% + \signalcharacter + \global\c_typo_overload_font_id + \ifnum\c_typo_overload_font_id=\fontid\font + \zerocount + \else + \fontid\font + \fi + \egroup + \global\expandafter\chardef\csname\??overloads#1\endcsname + \clf_overloadsattribute{#1}\c_typo_overload_font_id\scratchbox + \endgroup} + +\permanent\protected\def\setoverloads[#1]% + {\ifcsname\??overloads#1\endcsname\else + \typo_overloads_define{#1}% + \fi + \c_attr_overloads\csname\??overloads#1\endcsname} + +\permanent\protected\def\registeroverloads[#1]% + {\ifcsname\??overloads#1\endcsname\else + \typo_overloads_define{#1}% + \fi} + +\permanent\protected\def\resetoverloads + {\c_attr_overloads\attributeunsetvalue} + +%D We hook this into the replacement module, probably the only place where it makes +%D sense. Here is an adapted version of an example: +%D +%D \starttyping +%D \replaceword[basics][new] [old] +%D \replaceword[basics][now] [hl3->never] +%D \replaceword[basics][never][now] +%D \replaceword[basics][heck] [] +%D +%D \definehighlight[hl1][style={\setbar[underbar]\red\setcharactercasing[WORD]\bf}] +%D \definehighlight[hl2][style={\setbar[overbar]\blue\setcharactercasing[Words]}] +%D \definehighlight[hl3][style={\setbar[overstrike]\green\bs}] +%D +%D \registeroverloads[hl1] +%D \registeroverloads[hl2] +%D \registeroverloads[hl3] +%D +%D \start \setreplacements[basics][hl1] What the heck, it's now or never, isn't it new? \stop \par +%D \start \setreplacements[basics][hl2] What the heck, it's now or never, isn't it new? \stop \par +%D \start \setreplacements[basics][hl1] What the heck, it's now or never, isn't it new? \stop \par +%D \start \setreplacements[basics] What the heck, it's now or never, isn't it new? \stop \par +%D \stoptyping +%D +%D We used it to mark synonyms that should not be corrected by the editor. Sort of the +%D reverse of not having a word in a vetted wordlist. A bit out of place in a typesetting +%D system. If really needed we can support multiple words seperataed by spaces but I didn't +%D need it. And \unknown\ fonts are supported but at fixed size! + +\ifdefined\setreplacements + + \pushoverloadmode + + \permanent\tolerant\protected\def\setreplacements[#1]#*[#2]% + {\clf_setreplacements{#1}% + \ifparameter#2\or + \setoverloads[#2]% + \else + \resetoverloads + \fi} + + \popoverloadmode + +\else + + % something weird + +\fi + +\protect diff --git a/tex/context/base/mkxl/typo-pag.mkxl b/tex/context/base/mkxl/typo-pag.mkxl new file mode 100644 index 000000000..07443eb16 --- /dev/null +++ b/tex/context/base/mkxl/typo-pag.mkxl @@ -0,0 +1,20 @@ +%D \module +%D [ file=typo-pag, +%D version=2011.11.02, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Pages, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Pages} + +\unprotect + +\registerctxluafile{typo-pag}{} + +\protect \endinput diff --git a/tex/context/base/mkxl/typo-par.mkxl b/tex/context/base/mkxl/typo-par.mkxl new file mode 100644 index 000000000..de40c6568 --- /dev/null +++ b/tex/context/base/mkxl/typo-par.mkxl @@ -0,0 +1,30 @@ +%D \module +%D [ file=typo-par, +%D version=2008.09.30, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Paragraph Building, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Node Macros / Paragraph Building} + +%D This is very experimental, undocumented, subjected to changes, etc. just as +%D the underlying interfaces. But at least it's cleaned as part of the status-mkiv +%D cleanup. + +% \startparbuilder[basic] +% \input tufte \par +% \stopparbuilder + +\unprotect + +%registerctxluafile{node-ltp}{optimize} +\registerctxluafile{node-ltp}{} +\registerctxluafile{trac-par}{} + +\protect \endinput diff --git a/tex/context/base/mkxl/typo-plc.mkxl b/tex/context/base/mkxl/typo-plc.mkxl new file mode 100644 index 000000000..e6e90db73 --- /dev/null +++ b/tex/context/base/mkxl/typo-plc.mkxl @@ -0,0 +1,39 @@ +%D \module +%D [ file=typo-plc, +%D version=2020.07.01, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Placeholders, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Placeholders} + +\unprotect + +\installcorenamespace {placeholder} + +\installcommandhandler \??placeholder {placeholder} \??placeholder + +\permanent\protected\def\placeholder[#1]% + {\begingroup + \edef\currentplaceholder{#1}% + \placeholderparameter\c!before + \useplaceholderstyleandcolor\c!style\c!color + \placeholderparameter\c!text + \placeholderparameter\c!after + \endgroup} + +\defineplaceholder + [todo] + %[\c!text={Still to be written!}, + [\c!text=todo, % labeltext ? + \c!style=\v!bold, + \c!before=\blank, + \c!after=\blank] + +\protect \endinput diff --git a/tex/context/base/mkiv/typo-pnc.mkxl b/tex/context/base/mkxl/typo-pnc.mkxl index b5b1a17d6..b5b1a17d6 100644 --- a/tex/context/base/mkiv/typo-pnc.mkxl +++ b/tex/context/base/mkxl/typo-pnc.mkxl diff --git a/tex/context/base/mkxl/typo-prc.mklx b/tex/context/base/mkxl/typo-prc.mklx new file mode 100644 index 000000000..fa8bf2c07 --- /dev/null +++ b/tex/context/base/mkxl/typo-prc.mklx @@ -0,0 +1,99 @@ +%D \module +%D [ file=typo-prc, +%D version=2008.10.20, +%D title=\CONTEXT\ Structure Macros, +%D subtitle=Processors, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Processors} + +%D For the moment manipulators are loaded here too, as they're in the same category +%D as processors. This might change. (They are used in publications.) + +\registerctxluafile{typo-prc}{} +\registerctxluafile{typo-man}{} + +\unprotect + +%D Processors are used when we cannot easily associate typesetting directives with +%D (for instance) structural elements. Instead of ending up with numerous additional +%D definitions we can group treatments in so called processors. +%D +%D An example of where processors can be used is in separator sets (these are +%D related to typesetting numbers using structure). +%D +%D \starttyping +%D \defineprocessor[demo][style=\bfb,color=red] +%D \stoptyping +%D +%D This defines a processor named \type {demo}. Such a name ends up as prefix in for +%D instance: +%D +%D \starttyping +%D \defineseparatorset [demosep] [demo->!,demo->?,demo->!,demo->?] [demo->@] +%D \stoptyping +%D +%D Here the \type {!} and \type {?} are just the seperator characters that end up +%D between part, chapter, section, etc.\ numbers. The third argument defines the +%D default. When a separator is inserted, the \type{demo} processor will be applied. +%D Here the number will be separated by red slightly bigger than normal bold +%D exclamation marks and questionmarks. +%D +%D Valid keys for defining a processor are \type {style}, \type {color}, \type +%D {left}, \type {right}, and \type {command} (the given command takes one +%D argument). + +\installcorenamespace{processor} +\installcorenamespace{processorcheck} + +\installcommandhandler \??processor {processor} \??processor + +\appendtoks + \letvalue{\??processorcheck\currentprocessor}\relax + \clf_registerstructureprocessor{\currentprocessor}% global, but it permits using processor that are yet undefined +\to \everydefineprocessor + +%D The following command can be used by users but normally it will be invoked behind +%D the screens. After all, processor prefixes need to be split off first. At the +%D \LUA\ end we do check for a processor being registered anyway. + +\permanent\protected\def\applyprocessor#tag% + {\def\currentprocessor{#tag}% + \ifcsname\??processorcheck\currentprocessor\endcsname + \expandafter\typo_processor_apply + \else + \expandafter\firstofoneargument + \fi} + +\def\typo_processor_apply + {\edef\p_state{\processorparameter\c!state}% + \ifx\p_state\v!stop + \expandafter\firstofoneargument + \else + \expandafter\typo_processor_apply_indeed + \fi} + +\def\typo_processor_apply_indeed#content% + {\begingroup + \useprocessorstyleandcolor\c!style\c!color + \processorparameter\c!left + \processorparameter\c!command{#content}% + \processorparameter\c!right + \endgroup} + +%D \startbuffer +%D \defineprocessor[first] [style=bold] +%D \defineprocessor[last] [first] [color=red] +%D +%D \applyprocessor{first}{hans} \applyprocessor{last}{hagen} +%D \stopbuffer +%D +%D \typebuffer \start \blank \getbuffer \blank \stop + +\protect \endinput diff --git a/tex/context/base/mkxl/typo-rep.mkxl b/tex/context/base/mkxl/typo-rep.mkxl new file mode 100644 index 000000000..6e0a9a22c --- /dev/null +++ b/tex/context/base/mkxl/typo-rep.mkxl @@ -0,0 +1,42 @@ +%D \module +%D [ file=typo-rep, +%D version=2010.05.23, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Stripping, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Stripping} + +%D Here we implement an experimental stripper. I might cook up a few more +%D variants when there is real demand. It might even go away. +%D +%D \starttyping +%D \definefontfeature[default][default][mode=node,formatters=strip] +%D +%D \setcharacterstripping[1] +%D \stoptyping + +\unprotect + +\registerctxluafile{typo-rep}{} + +\definesystemattribute[stripping][public] + +\permanent\protected\def\setcharacterstripping[#1]% + {\clf_setcharacterstripping{#1}} + +\permanent\protected\def\resetcharacterstripping + {\c_attr_stripping\attributeunsetvalue} + +% maybe .. this might disappear, but is handy for testing + +\permanent\protected\def\forcecharacterstripping % secret command + {\ctxlua{fonts.handlers.otf.features.register("formatters",true)}} + +\protect \endinput diff --git a/tex/context/base/mkxl/typo-rub.mkxl b/tex/context/base/mkxl/typo-rub.mkxl new file mode 100644 index 000000000..b7265a9c8 --- /dev/null +++ b/tex/context/base/mkxl/typo-rub.mkxl @@ -0,0 +1,173 @@ +%D \module +%D [ file=typo-rub, +%D version=2016.10.10, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Rubies, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Experimental and unfinished. + +% todo: distance + +\writestatus{loading}{ConTeXt Typesetting Macros / Rubies} + +\unprotect + +\registerctxluafile{typo-rub}{} + +\definesystemattribute[ruby][public] + +\installcorenamespace {ruby} +\installcorenamespace {rubyanalyze} +\installcorenamespace {rubyplacement} +\installcorenamespace {rubynumber} + +\installcommandhandler \??ruby {ruby} \??ruby + +% \appendtoks +% \clf_defineruby +% align {\rubyparameter\c!align} +% stretch {\rubyparameter\c!stretch} +% hoffset \rubyparameter\c!hoffset +% voffset \rubyparameter\c!voffset +% \relax +% \to \everydefineruby + +\permanent\tolerant\protected\def\ruby[#1]#:#2#3% + {\dontleavehmode + \begingroup + \enforced\let\ruby\noruby + \edef\currentruby{#1}% + \edef\p_location{\rubyparameter\c!location}% + \enforced\let|\relax + \ifcsname\??rubyanalyze\p_location\endcsname + \expandafter\lastnamedcs\else\expandafter\typo_ruby_analyze + \fi{#2}{#3}% + \endgroup} + +\permanent\tolerant\protected\def\noruby[#1]#:#2#3% + {#2} + +\def\typo_ruby_analyze#1#2% + {\clf_ruby + base {#1}% + comment {#2} + \relax} + +\setvalue{\??rubyanalyze\v!top}#1#2% + {\clf_ruby + align {\rubyparameter\c!align}% + stretch {\rubyparameter\c!stretch}% + hoffset \rubyparameter\c!hoffset + voffset \rubyparameter\c!voffset + base {#1}% + comment {#2} + \relax} + +\setvalue{\??rubyplacement\v!top}#1#2% + {\setbox\scratchbox\hbox\bgroup + \userubystyleandcolor\c!style\c!color + #2% + \egroup + \clf_setruby \scratchbox + \relax + #1} + +\setvalue{\??rubyplacement\v!right}#1#2% + {#1% + \edef\p_distance{\rubyparameter\c!distance}% + \ifx\p_distance\empty\orelse\ifx\p_distance\v!none\else\hskip\p_distance\fi + \begingroup + \userubystyleandcolor\c!style\c!color + \rubyparameter\c!left#2\rubyparameter\c!right + \endgroup} + +\setvalue{\??rubyplacement\v!left}#1#2% + {\begingroup + \userubystyleandcolor\c!style\c!color + \rubyparameter\c!left#2\rubyparameter\c!right + \endgroup + \edef\p_distance{\rubyparameter\c!distance}% + \ifx\p_distance\empty\orelse\ifx\p_distance\v!none\else\hskip\p_distance\fi + #1} + +\permanent\protected\def\setruby#1#2% + {\begingroup + \ifcsname\??rubyplacement\p_location\endcsname + \lastnamedcs{#1}{#2}% + \else + #1% + \fi + \endgroup} + +\permanent\tolerant\protected\def\startruby[#1]% + {\dontleavehmode + \begingroup + \enforced\aliased\startruby\begingroup + \edef\currentruby{#1}% + \clf_startruby + align {\rubyparameter\c!align}% + stretch {\rubyparameter\c!stretch}% + hoffset \rubyparameter\c!hoffset + voffset \rubyparameter\c!voffset + \relax} + +\permanent\protected\def\stopruby + {\endgroup} + +\setupruby + [\c!style=\txx, + \c!location=\v!top, + \c!left=(, + \c!right=), + \c!distance=\zeropoint, % \v!none means no skip at all so no break either + \c!hoffset=\zeropoint, + \c!voffset=-2\exheight] + +%D Experiment too: + +\permanent\protected\def\numberedruby[#1]#2% + {\doifnotcounter{\??rubynumber#1}{\definecounter[\??rubynumber#1]\setcounter[\??rubynumber#1][1]}% + \ruby[#1]{#2}{\convertedcounter[\??rubynumber#1]}% + \incrementcounter[\??rubynumber#1]% + \relax} + +\protect \endinput + +% \usemodule[art-01]\setupbodyfont[dejavu,12pt] +% +% \defineruby[auto] [align=auto,color=darkred] +% \defineruby[left] [align=flushleft,color=darkred] +% \defineruby[right] [align=flushright,color=darkred] +% \defineruby[spread][stretch=yes] +% +% \showframe \showglyphs \showfontkerns \setupinterlinespace[22pt] +% +% \starttext +% +% \startbuffer +% \dorecurse{20}{\ruby{XYZ}{a|bc|d} }\par +% \dorecurse{20}{\ruby{PQR}{p|q|r} }\par +% \dorecurse{20}{\ruby{XYZ}{1|22|333} }\par +% \dorecurse{20}{\ruby{XYZ}{111|222|333} }\par +% \dorecurse{20}{\ruby{XYZ}{foobar} }\par +% \dorecurse{20}{\ruby{XYZ}{fooledbar} }\par +% \dorecurse{20}{\ruby[spread]{XYZ}{fooledbar} }\par +% \dorecurse{20}{\ruby{extremely}{wide} }\par +% \dorecurse{20}{\ruby{wide}{extremely} }\par +% stopbuffer +% +% \testfeatureonce{1}{\start \setupinterlinespace[16pt] \setupruby[location=none] \getbuffer \stop \page} +% \testfeatureonce{1}{\start \setupinterlinespace[16pt] \setupruby[location=right] \getbuffer \stop \page} +% \testfeatureonce{1}{\start \setupinterlinespace[28pt] \setupruby[align=auto,color=darkred] \getbuffer \stop \page} +% \testfeatureonce{1}{\start \setupinterlinespace[28pt] \setupruby[align=flushleft,color=darkgreen] \getbuffer \stop \page} +% \testfeatureonce{1}{\start \setupinterlinespace[28pt] \setupruby[align=flushright,color=darkblue] \getbuffer \stop \page} +% \testfeatureonce{1}{\start \setupinterlinespace[28pt] \setupruby[align=middle,color=darkyellow] \getbuffer \stop \page} +% +% \stoptext diff --git a/tex/context/base/mkiv/typo-scr.mkxl b/tex/context/base/mkxl/typo-scr.mkxl index 36e2997e2..36e2997e2 100644 --- a/tex/context/base/mkiv/typo-scr.mkxl +++ b/tex/context/base/mkxl/typo-scr.mkxl diff --git a/tex/context/base/mkxl/typo-spa.mkxl b/tex/context/base/mkxl/typo-spa.mkxl new file mode 100644 index 000000000..4daaac100 --- /dev/null +++ b/tex/context/base/mkxl/typo-spa.mkxl @@ -0,0 +1,78 @@ +%D \module +%D [ file=typo-spa, +%D version=2009.03.27, % code moved from cors-spa.mkiv +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Spacing, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Spacing} + +\unprotect + +\registerctxluafile{typo-spa}{} + +\definesystemattribute[spacing][public] + +% experimental spacing +% +% test: oeps {\setcharacterspacing[frenchpunctuation]x: xx \bfd x: xx} oeps: test +% +% todo: page | text => pagebody or text only + +\installcorenamespace{characterspacing} + +\installsetuponlycommandhandler \??characterspacing {_p_characterspacing} % private + +\setup_p_characterspacing + [\c!left=0, + \c!right=0, + \c!alternative=0] + +\permanent\protected\def\definecharacterspacing[#1]% + {\clf_definecharacterspacing{#1}} + +\permanent\tolerant\protected\def\setupcharacterspacing[#1]#*[#2]#*[#3]% todo: #2 list + {\begingroup + \setupcurrent_p_characterspacing[#3]% + \clf_setupcharacterspacing + {#1}% + \numexpr#2\relax + {% + left \direct_p_characterspacingparameter\c!left\space + right \direct_p_characterspacingparameter\c!right\space + alternative \direct_p_characterspacingparameter\c!alternative + }% + \relax + \endgroup} + +\permanent\protected\def\setcharacterspacing[#1]% we can store the attribute if we want speed + {\clf_setcharacterspacing{#1}} + +\permanent\protected\def\resetcharacterspacing % fast one + {\c_attr_spacing\attributeunsetvalue} + +\appendtoks + \resetcharacterspacing +\to \everyresettypesetting + +% \setcharacterspacing[frenchpunctuation] +% «\type{bla}»\crlf « \type{bla}»\crlf +% «bla »\crlf « bla»\crlf « bla »\crlf +% bla: bla\crlf bla : bla + +\definecharacterspacing [frenchpunctuation] % name may change / unit is em + +\setupcharacterspacing [frenchpunctuation] ["003A] [\c!left =.25,\c!alternative=1] % : % strip preceding space(char) +\setupcharacterspacing [frenchpunctuation] ["003B] [\c!left =.25,\c!alternative=1] % ; % strip preceding space(char) +\setupcharacterspacing [frenchpunctuation] ["003F] [\c!left =.25,\c!alternative=1] % ? % strip preceding space(char) +\setupcharacterspacing [frenchpunctuation] ["0021] [\c!left =.25,\c!alternative=1] % ! % strip preceding space(char) +\setupcharacterspacing [frenchpunctuation] ["00AB] [\c!right=.25,\c!alternative=1] % guillemotleft/leftguillemot % strip following space(char) +\setupcharacterspacing [frenchpunctuation] ["00BB] [\c!left =.25,\c!alternative=1] % guillemotright/rightguillemot % strip preceding space(char) + +\protect \endinput diff --git a/tex/context/base/mkxl/typo-sus.mkxl b/tex/context/base/mkxl/typo-sus.mkxl new file mode 100644 index 000000000..7b62b8aca --- /dev/null +++ b/tex/context/base/mkxl/typo-sus.mkxl @@ -0,0 +1,51 @@ +%D \module +%D [ file=typo-sus, +%D version=2014.11.06, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Checking Suspects, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Checking Suspects} + +%D This is a rather special module, mostly needed by ourselves for +%D projects where copy||editing is not that precise. + +\registerctxluafile{typo-sus}{} + +\permanent\protected\def\showsuspects{\enabletrackers[typesetters.suspects]} + +%D The suspicious spacing will be colored in the text. There can be false +%D positives but this features is mostly used when proofreading. So, we +%D don't worry too much about interference (and efficiency). +%D +%D \protected\def\showsample#1% +%D {\NC \type{#1}% +%D \NC \enabletrackers[typesetters.suspects]#1\disabletrackers[typesetters.spacing]% +%D \NC \NR} +%D +%D \starttabulate[|||][before=,after=] +%D \showsample{foo$x$} +%D \showsample{$x$bar} +%D \showsample{foo$x$bar} +%D \showsample{$f+o+o$:} +%D \showsample{;$f+o+o$} +%D \showsample{; bar} +%D \showsample{foo:bar} +%D \showsample{\quote{ foo }} +%D \showsample{\quote{bar }} +%D \showsample{\quote{ bar}} +%D \showsample{(foo )} +%D \showsample{\{foo \}} +%D \showsample{foo{\bf gnu}bar} +%D \showsample{foo$x^2$bar} +%D \showsample{foo\nobreakspace bar} +%D \stoptabulate + +\endinput + diff --git a/tex/context/base/mkxl/typo-tal.mkxl b/tex/context/base/mkxl/typo-tal.mkxl new file mode 100644 index 000000000..86a90020c --- /dev/null +++ b/tex/context/base/mkxl/typo-tal.mkxl @@ -0,0 +1,303 @@ +%D \module +%D [ file=typo-tal, % spac-cha (2012.06.08) supp-ali (2000.04.17) +%D version=2013.10.04, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Character Alignment, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Character Alignment} + +%D This module replaces the \MKII\ character alignment code which hooked into +%D table mechanisms but used parsing. In fact, this might be one of these cases +%D where a \TEX\ based solution is faster, but a \LUA\ one a bit more robust. +%D Anyway, as I had to fix something (to fit the newer table mechanisms) I +%D decided to go the mixed route, a rather easy going effort in the aftermath of +%D the 2013 \CONTEXT\ meeting. + +\unprotect + +\registerctxluafile{typo-tal}{} + +\definesystemattribute[characteralign][public] + +%D This mechanism is mostly meant for tables: +%D +%D \startbuffer +%D \starttabulate[|l|g{,}|r|] +%D \NC test \NC 1.234.456,99 \NC \NC test \NR +%D \NC test \NC 234.456,9 \NC \NC test \NR +%D \NC test \NC 234.456 \NC \NC test \NR +%D \NC test \NC 456 \NC \NC test \NR +%D \NC test \NC \bf whatever \NC \NC test \NR +%D \stoptabulate +%D \stopbuffer +%D +%D \typebuffer \blank \getbuffer \blank + +% D \startbuffer +% D \bTABLE +% D \bTR \bTD[aligncharacter=yes] € 1,1 \eTD \eTR +% D \bTR \bTD[aligncharacter=yes] € 11,11 \eTD \eTR +% D \bTR \bTD[aligncharacter=yes] € 12\punctuationspace111,11 \eTD \eTR +% D \bTR \bTD[aligncharacter=yes] € 12 111,11 \eTD \eTR +% D \bTR \bTD[aligncharacter=yes] € 1.234.451,22222 \eTD \eTR +% D \bTR \bTD[aligncharacter=yes] € 234.451,2 \eTD \eTR +% D \bTR \bTD[aligncharacter=yes] € 234.451 \eTD \eTR +% D \bTR \bTD[aligncharacter=yes] € 451 \eTD \eTR +% D \bTR \bTD \bf some text \eTD \eTR +% D \eTABLE +% D \stopbuffer +% D +% D \typebuffer \blank \getbuffer \blank + +\permanent\protected\def\signalcharacteralign #1#2{\c_attr_characteralign\numexpr#1*\maxcardminusone+#2\relax} % 0xFFFF +\permanent\protected\def\setcharacteralign #1#2{\clf_setcharacteralign#1{#2}} +\permanent\protected\def\resetcharacteralign {\clf_resetcharacteralign} +\permanent\protected\def\nocharacteralign {\c_attr_characteralign\attributeunsetvalue} +\permanent\protected\def\setcharacteraligndetail#1#2#3#4{\clf_setcharacteraligndetail#1{#2}#3#4\relax} + +%D Mostly downward compatible: +%D +%D \startbuffer +%D \startcharacteralign +%D \checkcharacteralign{123.456,78} +%D \checkcharacteralign{456} +%D \checkcharacteralign{23.456} +%D \checkcharacteralign{78,9} +%D \stopcharacteralign +%D \stopbuffer +%D +%D \typebuffer \blank \getbuffer \blank +%D +%D \startbuffer +%D \startcharacteralign[leftsample=123.456,rightsample=00,character={,}] +%D \checkcharacteralign{123.456,78}\par +%D \checkcharacteralign {456}\par +%D \checkcharacteralign {23.456}\par +%D \checkcharacteralign {78,9}\par +%D \checkcharacteralign {78}\par +%D \stopcharacteralign +%D \stopbuffer +%D +%D \typebuffer \blank \getbuffer \blank +%D +%D \startbuffer +%D \startcharacteralign[leftwidth=123.456,rightwidth=00,character={,}] +%D \checkcharacteralign{123.456,78}\par +%D \checkcharacteralign {456}\par +%D \checkcharacteralign {23.456}\par +%D \checkcharacteralign {78,9}\par +%D \checkcharacteralign {78}\par +%D \stopcharacteralign +%D \stopbuffer +%D +%D \typebuffer \blank \getbuffer \blank +%D +%D We have (currently) two modes: \type {text} and \type {number}. The handler tries +%D to determine the mode automatically. When using periods and commas as separators +%D the \type {number} mode is chosen. If you use for instance a \type {-} as +%D separator, \type {text} is chosen, but you can enforce \type {number} with \type +%D {number->-} (as with other mechanisms, the arrow indicates a method to apply). +%D +%D One can use \type {\nocharacteralign} to disable this mechanism, for instance in +%D a table cell. + +\mutable\def\alignmentcharacter{,} + +\installcorenamespace{characteralign} + +\installparameterhandler\??characteralign {characteralign} +\installsetuphandler \??characteralign {characteralign} + +\setupcharacteralign + [\c!leftwidth =\zeropoint, + \c!rightwidth =\zeropoint, + \c!leftsample =, + \c!rightsample=, + \c!character =\alignmentcharacter] + +\permanent\protected\def\typo_charalign_pass_one + {\advance\scratchcounter\plusone + \setbox\scratchbox\typo_charalign_pass} + +\permanent\protected\def\typo_charalign_pass_two + {\advance\scratchcounter\plusone + \typo_charalign_pass} + +\def\typo_charalign_pass + {\hbox\bgroup\signalcharacteralign\plusone\scratchcounter\let\next} + +\permanent\tolerant\protected\def\startcharacteralign[#1]% + {\doifelseassignment{#1}\typo_charalign_start_one\typo_charalign_start_two{#1}} + +\def\typo_charalign_start_one#1#2\stopcharacteralign + {\bgroup + % for now no instances + \setupcurrentcharacteralign[#1]% + \edef\p_left {\characteralignparameter\c!leftsample}% + \edef\p_right{\characteralignparameter\c!rightsample}% + \ifempty\p_left + \scratchdimenone\dimexpr\characteralignparameter\c!leftwidth\relax + \else + \setbox\scratchbox\hbox{\p_left}% + \scratchdimenone\wd\scratchbox + \fi + \ifempty\p_right + \scratchdimentwo\dimexpr\characteralignparameter\c!rightwidth\relax + \else + \setbox\scratchbox\hbox{\p_right}% + \scratchdimentwo\wd\scratchbox + \fi + \ifzeropt\scratchdimenone + \ifzeropt\scratchdimentwo + \donefalse + \else + \donetrue + \fi + \else + \donetrue + \fi + \edef\alignmentcharacter{\characteralignparameter\c!character}% + \ifdone + \clf_setcharacteraligndetail + \plusone + \alignmentcharacter + \scratchdimenone + \scratchdimentwo + \else + \clf_setcharacteralign + \plusone + \alignmentcharacter + \begingroup + \scratchcounter\zerocount + \enforced\let\checkcharacteralign\typo_charalign_pass_one + \settrialtypesetting + #2\relax + \endgroup + \fi + \begingroup + \scratchcounter\zerocount + \enforced\let\checkcharacteralign\typo_charalign_pass_two + #2\relax + \endgroup + \resetcharacteralign + \egroup} + +\def\typo_charalign_start_two#1#2\stopcharacteralign + {\bgroup + \edef\m_temp{#1}% + \ifempty\m_temp \else + \let\alignmentcharacter\m_temp + \fi + \clf_setcharacteralign + \plusone + \alignmentcharacter + \begingroup + \scratchcounter\zerocount + \enforced\let\checkcharacteralign\typo_charalign_pass_one + \settrialtypesetting + #2\relax + \endgroup + \begingroup + \scratchcounter\zerocount + \enforced\let\checkcharacteralign\typo_charalign_pass_two + #2\relax + \endgroup + \resetcharacteralign + \egroup} + +\aliased\let\stopcharacteralign \relax +\aliased\let\checkcharacteralign\gobbleoneargument + +\permanent\protected\def\setfirstpasscharacteralign {\enforced\let\checkcharacteralign\gobbleoneargument} +\permanent\protected\def\setsecondpasscharacteralign{\enforced\let\checkcharacteralign\firstofoneargument} + +%D We need fonts to provide tabular digits that is, the digits need to have the same +%D width. +%D +%D \startbuffer +%D \startbuffer[demo] +%D \switchtobodyfont[pagella] +%D \setupTABLE[column][1][alignmentcharacter=.,aligncharacter=yes] +%D \bTABLE +%D \bTR \bTD 11.111 \eTD \bTD 11.111 \eTD \eTR +%D \bTR \bTD 2.2 \eTD \bTD 2.2 \eTD \eTR +%D \bTR \bTD 444.444 \eTD \bTD 444.444 \eTD \eTR +%D \eTABLE +%D \stopbuffer +%D +%D \start inlinenumbers: \crlf \addfeature[inlinenumbers] \getbuffer \stop +%D \start tabularnumbers: \crlf \addfeature[tabularnumbers] \getbuffer \stop +%D \start oldstylenumbers:\crlf \addfeature[oldstylenumbers] \getbuffer \stop +%D \stopbuffer +%D +%D \enabledirectives[typesetters.characteralign.autofont] +%D \typebuffer \blank \getbuffer \blank +%D \disabledirectives[typesetters.characteralign.autofont] +%D \typebuffer \blank \getbuffer \blank +%D \enabledirectives[typesetters.characteralign.autofont] + +\definefontfeature + [system:tabnum] + [tnum=yes, + lnum=no] + +\newconditional\c_tabl_ntb_char_align_auto_font \settrue\c_tabl_ntb_char_align_auto_font + +\installtexdirective % yes or no ? + {typesetters.characteralign.autofont} + {\settrue \c_tabl_ntb_char_align_auto_font} + {\setfalse\c_tabl_ntb_char_align_auto_font} + +\def\m_font_feature_auto_tabnum{system:tabnum} + +\protected\def\typo_charalign_adapt_font_indeed + {\let\m_font_feature_asked\m_font_feature_auto_tabnum + \font_feature_reset_add_indeed} + +\def\typo_charalign_adapt_font % slow but seldom used (expanded in preamble) + {\ifconditional\c_tabl_ntb_char_align_auto_font + \typo_charalign_adapt_font_indeed + \fi} + +%D Another example: +%D +%D \starttyping +%D \setupTABLE[c][2][alignmentcharacter={number->,},aligncharacter=yes,align={flushleft}] +%D \bTABLE +%D \bTR \bTD 1 \eTD \bTD 125 cm \eTD \eTR +%D \bTR \bTD 2 \eTD \bTD 1 125,80 cm \eTD \eTR +%D \bTR \bTD 6 \eTD \bTD 1 125,80 $\pi^2$ \eTD \eTR +%D \bTR \bTD 7 \eTD \bTD 129,3 \unit{square centimeter} \eTD \eTR +%D \eTABLE +%D +%D \setupTABLE[c][2][alignmentcharacter={number->,},aligncharacter=yes,align={flushleft}] +%D \bTABLE +%D \bTR \bTD 1 \eTD \bTD 125 cm \eTD \eTR +%D \bTR \bTD 2 \eTD \bTD 1 125,80 cm \eTD \eTR +%D \bTR \bTD 6 \eTD \bTD 1 125,80 $\pi^2$ \eTD \eTR +%D \bTR \bTD 7 \eTD \bTD 129,3 \unit{square centimeter} \eTD \eTR +%D \eTABLE +%D +%D \setupTABLE[c][2][alignmentcharacter={number->,},aligncharacter=yes,align={middle}] +%D \bTABLE +%D \bTR \bTD 1 \eTD \bTD 125 \eTD \eTR +%D \bTR \bTD 6 \eTD \bTD 1 125,80 \eTD \eTR +%D \bTR \bTD 7 \eTD \bTD 129,3 \eTD \eTR +%D \eTABLE +%D +%D \setupTABLE[c][2][alignmentcharacter={text->,},aligncharacter=yes,align={middle}] +%D \bTABLE +%D \bTR \bTD 1 \eTD \bTD 125 \eTD \eTR +%D \bTR \bTD 6 \eTD \bTD 1 125,80 \eTD \eTR +%D \bTR \bTD 7 \eTD \bTD 129,3 \eTD \eTR +%D \eTABLE +%D \stoptyping + +\protect \endinput diff --git a/tex/context/base/mkxl/typo-txt.mklx b/tex/context/base/mkxl/typo-txt.mklx new file mode 100644 index 000000000..bb92c8cd3 --- /dev/null +++ b/tex/context/base/mkxl/typo-txt.mklx @@ -0,0 +1,240 @@ +%D \module +%D [ file=typo-txt, +%D version=2011.10.27, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Text Hacks, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D This module replaces the by now rather old supp-fun module. + +\writestatus{loading}{ConTeXt Typesetting Macros / Text Hacks} + +\unprotect + +% registerctxluafile{typo-txt}{} + +%D \macros +%D {normalizefontheight,normalizefontwidth,normalizedfontsize} +%D +%D Next we introduce some font manipulation macros. When we want to typeset some +%D text spread in a well defined area, it can be considered bad practice to +%D manipulate character and word spacing. In such situations the next few macros can +%D be of help: +%D +%D \starttyping +%D \normalizefontheight \name {sample text} {height} {font} +%D \normalizefontwidth \name {sample text} {width} {font} +%D \stoptyping +%D +%D Consider for instance: +%D +%D \startbuffer[a] +%D \normalizefontheight \TempFont {X} {2\baselineskip} {Serif} +%D \stopbuffer +%D +%D \startbuffer[b] +%D \ruledhbox{\TempFont To Be Or Not To Be} +%D \stopbuffer +%D +%D \typebuffer[a,b] \getbuffer[a] +%D +%D This shows up as: +%D +%D \startlinecorrection +%D \ruledhbox{\getbuffer[b]} +%D \stoplinecorrection +%D +%D The horizontal counterpart is: +%D +%D \startbuffer[a] +%D \normalizefontwidth \TempFont {This Line Fits} {\hsize} {Serif} +%D \stopbuffer +%D +%D \startbuffer[b] +%D \ruledhbox{\TempFont This Line Fits} +%D \stopbuffer +%D +%D \typebuffer[a,b] \getbuffer[a] +%D +%D This gives: +%D +%D \startlinecorrection +%D \ruledhbox{\getbuffer[b]} +%D \stoplinecorrection +%D +%D The calculated font scale is avaliable in \type {\normalizedfontsize}. + +\newbox\b_typo_normalizers + +\def\typo_normalizers_size#axis#size% + {\dimexpr\ifdim#1\b_typo_normalizers=\zeropoint + \bodyfontsize + \else + \luaexpr{\number\dimexpr10pt\relax*\number\dimexpr#size\relax/\number#axis\b_typo_normalizers}\scaledpoint + \fi\relax} + +\def\typo_normalizers_font_at_size#axis#cs#text#size#font% avoid overflow by using lua + {\begingroup + \setbox\b_typo_normalizers\hbox{\definedfont[#font at 10pt]\settrialtypesetting#text}% + \normalexpanded{\endgroup\enforced\edef\noexpand\normalizedfontsize{\the\typo_normalizers_size{#axis}{#size}}}% + \definefont[\strippedcsname#cs][#font at \normalizedfontsize]} + +\protected\def\typo_normalizers_text_at_size#axis#font#size#text% + {\dontleavehmode + \begingroup + \setbox\b_typo_normalizers\hbox{\definedfont[#font at 10pt]\settrialtypesetting#text}% + \definedfont[#font at \the\typo_normalizers_size{#axis}{#size}]#text% + \endgroup} + +\mutable\def\normalizedfontsize{\bodyfontsize} + +\permanent\protected\def\normalizetextwidth {\typo_normalizers_text_at_size\wd} +\permanent\protected\def\normalizetextheight{\typo_normalizers_text_at_size\ht} +\permanent\protected\def\normalizetextdepth {\typo_normalizers_text_at_size\dp} +\permanent\protected\def\normalizetextline {\typo_normalizers_text_at_size\htdp} + +\permanent\protected\def\normalizefontwidth {\typo_normalizers_font_at_size\wd} +\permanent\protected\def\normalizefontheight{\typo_normalizers_font_at_size\ht} +\permanent\protected\def\normalizefontdepth {\typo_normalizers_font_at_size\dp} +\permanent\protected\def\normalizefontline {\typo_normalizers_font_at_size\htdp} + +\permanent\protected\def\widthspanningtext #text#size#specification{\hbox{\normalizefontwidth \temp{#text}{#size}{#specification}\temp#text}} +\permanent\protected\def\heightspanningtext#text#size#specification{\hbox{\normalizefontheight\temp{#text}{#size}{#specification}\temp#text}} +\permanent\protected\def\depthspanningtext #text#size#specification{\hbox{\normalizefontdepth \temp{#text}{#size}{#specification}\temp#text}} +\permanent\protected\def\linespanningtext #text#size#specification{\hbox{\normalizefontline \temp{#text}{#size}{#specification}\temp#text}} + +%D Traditionally we use UpperCasedNames for this kind of functionality. + +\aliased\let\NormalizeFontHeight \normalizefontheight +\aliased\let\NormalizeFontWidth \normalizefontwidth +\aliased\let\NormalizeTextHeight \normalizetextheight +\aliased\let\NormalizeTextWidth \normalizetextwidth + +\aliased\let\WidthSpanningText \widthspanningtext + +\permanent\def\TheNormalizedFontSize{\normalizedfontsize} + +%D \macros +%D {vulgarfraction} +%D +%D This code is moved from \type {cor-mis.mkiv}. We show three versions. First +%D the simple one using \type {\low} and \type {high}: +%D +%D \startbuffer +%D \def\vfrac#1#2% +%D {\hbox{\high{\tx#1\kern-.25em}/\low{\kern-.25em\tx#2}}} +%D +%D test \vfrac{1}{2} test \vfrac{123}{456} test +%D \stopbuffer +%D +%D \typebuffer {\showmakeup\getbuffer} +%D +%D A better way to handle the kerning is the following, here we kind of assume +%D that tye slash is symmetrical and has nearly zero width. +%D +%D \startbuffer +%D \def\vfract#1#2% +%D {\hbox{\high{\tx#1}\hbox to \zeropoint{\hss/\hss}\low{\tx#2}}} +%D \stopbuffer +%D +%D \typebuffer {\showmakeup\getbuffer} +%D +%D The third and best alternative is the following: +%D +%D {\showmakeup\getbuffer}\crlf\getbuffer +%D +%D This time we measure the height of the \type {/} and shift over the maximum +%D height and depths of this character and the fractional digits (we use 57 as +%D sample). Here we combine all methods in one macros. + +\setnewconstant\vulgarfractionmethod\plusthree + +\definehspace[\v!vulgarfraction][.25em] % [.15em] +\definesymbol[\v!vulgarfraction][/] % [\raise.2ex\hbox{/}] + +\permanent\protected\def\vulgarfraction#1#2% + {\dontleavehmode + \hbox + {\def\vulgarfraction{vulgarfraction}% + \ifcase\vulgarfractionmethod + #1\symbol[\v!vulgarfraction]#2% + \or + \high{\tx#1\kern-\hspaceamount\empty\v!vulgarfraction}% + \symbol[\vulgarfraction]% + \low {\kern-\hspaceamount\empty\v!vulgarfraction\tx#2}% + \or + \high{\tx#1}% + \hbox to \zeropoint{\hss\symbol[\v!vulgarfraction]\hss}% + \low{\tx#2}% + \or + \setbox0\hbox{\symbol[\vulgarfraction]}% + \setbox2\hbox{\txx57}% + \raise\ht0\hbox{\lower\ht2\hbox{\txx#1}}% + \hbox to \zeropoint{\hss\symbol[\v!vulgarfraction]\hss}% + \lower\dp0\hbox{\raise\dp2\hbox{\txx#2}}% + \fi}} + +\ifdefined\vfrac \else \let\vfrac\vulgarfraction \fi % \aliased ? + +%D \starttabulate[|l|l|] +%D \HL +%D \NC \bf method \NC \bf visualization \NC\NR +%D \HL +%D \NC 0 \NC \vulgarfractionmethod0 \vulgarfraction{1}{2} \NC\NR +%D \NC 1 \NC \vulgarfractionmethod1 \vulgarfraction{1}{2} \NC\NR +%D \NC 2 \NC \vulgarfractionmethod2 \vulgarfraction{1}{2} \NC\NR +%D \NC 3 \NC \vulgarfractionmethod3 \vulgarfraction{1}{2} \NC\NR +%D \HL +%D \stoptabulate + +%D This is used in the beginners manual. One needs to set the font size to an +%D acceptable value for this to work. + +\permanent\tolerant\protected\def\startnicelyfilledbox[#1]% + {\vbox\bgroup + \forgetall + \letdummyparameter\c!width \hsize + \letdummyparameter\c!height\vsize + \letdummyparameter\c!offset\exheight % we obey to the outer exheight + \letdummyparameter\c!strut \v!yes % we obey to the inner strut ! + \getdummyparameters[#1]% + \scratchoffset\dummyparameter\c!offset\relax + \setbox\scratchbox\vbox to \dummyparameter\c!height \bgroup + \hsize\dummyparameter\c!width\relax + \emergencystretch10\scratchoffset + \parfillskip\zeropoint + \baselineskip\zeropoint plus \onepoint minus \onepoint + \beginofshapebox + \leftskip \scratchoffset + \rightskip\scratchoffset} + +\permanent\protected\def\stopnicelyfilledbox + {\doifelse{\dummyparameter\c!strut}\v!yes + {\xdef\doflushnicelyfilledbox + {\ht\shapebox\the\strutht + \dp\shapebox\the\strutdp + \box\shapebox}}% + {\gdef\doflushnicelyfilledbox + {\box\shapebox}}% + \endofshapebox + \doreshapebox + {\doflushnicelyfilledbox} + {\penalty\shapepenalty} + {\kern\shapekern} + {\vfil}% + \kern\scratchoffset + \vfilneg + \flushshapebox + \vfilneg + \kern\scratchoffset + \egroup + \box\scratchbox + \egroup} + +\protect \endinput diff --git a/tex/context/base/mkxl/typo-wrp.mkxl b/tex/context/base/mkxl/typo-wrp.mkxl new file mode 100644 index 000000000..b552c151a --- /dev/null +++ b/tex/context/base/mkxl/typo-wrp.mkxl @@ -0,0 +1,58 @@ +%D \module +%D [ file=typo-wrp, +%D version=2014.11.09, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Wrappers, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Typesetting Macros / Wrapping} + +\unprotect + +\registerctxluafile{typo-wrp}{} + +\permanent\protected\def\crlf + {\ifhmode + \expandafter\spac_crlf + \fi} + +\protected\def\spac_crlf + {\clf_enablecrlf % once + \unskip + \spac_crlf_placeholder + \ifcase\raggedstatus\hfil\or\or\or\hfil\fi + % in bad usage this can lead to: [break -10000] [wordboundary] [line(break)penalty] [parfillskip] + \break + \wordboundary + % which we then remove (maybe we should flag the wordboundary with an attribute but not now + \ignorespaces} + +\protected\def\spac_crlf_placeholder + {\strut} + +\protected\def\spac_crlf_placeholder_show + {\wordboundary + %\nobreak + \hpack to \zeropoint{\strut{\infofont\kern.25\emwidth}\lohi{\infofont CR}{\infofont LF}\hss}} + +\permanent\protected\def\settestcrlf + {\let\spac_crlf_placeholder\spac_crlf_placeholder_show} + +\permanent\protected\def\crlfplaceholder % for old times sake + {\spac_crlf_placeholder} + +\appendtoks + \let\spac_crlf_placeholder\empty +\to \everysetnostrut + +\appendtoks + \let\spac_crlf\space +\to \everysimplifycommands + +\protect \endinput diff --git a/tex/context/base/mkiv/unic-ini.mkxl b/tex/context/base/mkxl/unic-ini.mkxl index 3fccd2feb..3fccd2feb 100644 --- a/tex/context/base/mkiv/unic-ini.mkxl +++ b/tex/context/base/mkxl/unic-ini.mkxl diff --git a/tex/context/interface/mkii/keys-de.xml b/tex/context/interface/mkii/keys-de.xml index ec8c15ee2..fb3969277 100644 --- a/tex/context/interface/mkii/keys-de.xml +++ b/tex/context/interface/mkii/keys-de.xml @@ -780,6 +780,7 @@ <cd:constant name='deepnumbercommand' value='deepnumbercommand'/> <cd:constant name='deeptextcommand' value='deeptextcommand'/> <cd:constant name='default' value='default'/> + <cd:constant name='define' value='define'/> <cd:constant name='delay' value='wartezeit'/> <cd:constant name='depth' value='tiefe'/> <cd:constant name='depthcorrection' value='tiefekorrektur'/> @@ -2085,7 +2086,7 @@ <cd:command name='startnarrower' value='startenger'/> <cd:command name='startopposite' value='startgegenueber'/> <cd:command name='startoverlay' value='startoverlay'/> - <cd:command name='startoverzicht' value='startueberblick'/> + <cd:command name='startoverview' value='startueberblick'/> <cd:command name='startpacked' value='startkleinerdurchschuss'/> <cd:command name='startpositioning' value='startpositionieren'/> <cd:command name='startproduct' value='startprodukt'/> @@ -2128,7 +2129,7 @@ <cd:command name='stopnarrower' value='stopenger'/> <cd:command name='stopopposite' value='stopgegenueber'/> <cd:command name='stopoverlay' value='stopoverlay'/> - <cd:command name='stopoverzicht' value='stopueberblick'/> + <cd:command name='stopoverview' value='stopueberblick'/> <cd:command name='stoppacked' value='stopkleinerdurchschuss'/> <cd:command name='stoppositioning' value='stoppositionieren'/> <cd:command name='stopproduct' value='stopprodukt'/> diff --git a/tex/context/interface/mkiv/context-en.xml b/tex/context/interface/mkiv/context-en.xml index 6cf0cfa0f..59ecba8ec 100644 --- a/tex/context/interface/mkiv/context-en.xml +++ b/tex/context/interface/mkiv/context-en.xml @@ -3089,6 +3089,14 @@ <cd:content/> </cd:arguments> </cd:command> + <cd:command category="boxes" file="supp-box.lmt" level="system" name="reversevboxcontent"> + <cd:arguments> + <cd:keywords delimiters="none"> + <cd:constant type="cd:csname"/> + <cd:constant type="cd:number"/> + </cd:keywords> + </cd:arguments> + </cd:command> </cd:interface> <cd:interface file="i-buffer.xml"> <cd:command category="buffer" file="buff-ini.mkiv" keywords="conditional" level="system" name="doifelsebuffer"> @@ -3796,7 +3804,7 @@ <cd:command category="fonts" file="typo-cap.mkiv" level="document" name="randomized" type="environment"/> </cd:interface> <cd:interface file="i-catcodes.xml"> - <cd:command category="catcode" file="catc-ctx.mkiv" level="system" name="texcode" type="environment"/> + <cd:command category="catcode" file="catc-ctx.mkxl" level="system" name="texcode" type="environment"/> <cd:command category="catcode" file="catc-ctx.mkiv" level="system" name="contextcode" type="environment"/> <cd:command category="catcode" file="catc-ctx.mkiv" level="system" name="contextdefinitioncode" type="environment"/> <cd:command begin="un" category="catcode" end="" file="catc-def.mkiv" level="system" name="protect" type="environment"/> @@ -5387,6 +5395,60 @@ </cd:arguments> </cd:command> </cd:interface> + <cd:interface file="i-columns.xml"> + <cd:command category="tables" file="page-mcl.mkxl" level="style" name="definemulticolumns"> + <cd:arguments> + <cd:keywords> + <cd:constant type="cd:name"/> + </cd:keywords> + <cd:keywords optional="yes"> + <cd:constant type="cd:name"/> + </cd:keywords> + <cd:assignments list="yes" optional="yes"> + <cd:inherit name="setupmulticolumns"/> + </cd:assignments> + </cd:arguments> + </cd:command> + <cd:command category="columns" file="page-mcl.mkxl" level="style" name="setupmulticolumns"> + <cd:arguments> + <cd:keywords list="yes" optional="yes"> + <cd:constant type="cd:name"/> + </cd:keywords> + <cd:assignments list="yes"> + <cd:parameter name="n"> + <cd:constant type="cd:number"/> + </cd:parameter> + <cd:parameter name="distance"> + <cd:constant type="cd:dimension"/> + </cd:parameter> + <cd:parameter name="direction"> + <cd:constant default="yes" type="right"/> + <cd:constant type="reverse"/> + </cd:parameter> + <cd:parameter name="balance"> + <cd:constant default="yes" type="yes"/> + <cd:constant type="no"/> + </cd:parameter> + <cd:parameter name="blank"> + <cd:inherit name="blank"/> + </cd:parameter> + <cd:parameter name="align"> + <cd:inherit name="setupalign"/> + </cd:parameter> + <cd:parameter name="ntop"> + <cd:constant type="cd:number"/> + </cd:parameter> + </cd:assignments> + </cd:arguments> + </cd:command> + <cd:command category="tables" file="page-mcl.mkxl" level="document" name="multicolumns" type="environment"> + <cd:arguments> + <cd:assignments list="yes" optional="yes"> + <cd:inherit name="setupmulticolumns"/> + </cd:assignments> + </cd:arguments> + </cd:command> + </cd:interface> <cd:interface file="i-combination.xml"> <cd:command category="tables" file="pack-com.mkiv" level="style" name="definecombination"> <cd:arguments> @@ -7109,6 +7171,9 @@ <cd:parameter name="start"> <cd:constant type="cd:number"/> </cd:parameter> + <cd:parameter name="number"> + <cd:constant type="cd:number"/> + </cd:parameter> <cd:parameter name="counter"> <cd:constant type="cd:name"/> </cd:parameter> @@ -8438,6 +8503,32 @@ <cd:command category="structure" file="file-job.mkvi" level="system" name="currentcomponent"/> <cd:command category="structure" file="file-job.mkvi" level="document" name="document" type="environment"> <cd:arguments> + <cd:keywords optional="yes"> + <cd:constant type="cd:name"/> + </cd:keywords> + <cd:assignments list="yes" optional="yes"> + <cd:inherit name="setupdocument"/> + </cd:assignments> + </cd:arguments> + </cd:command> + <cd:command category="structure" file="file-job.mkvi" generated="yes" level="document" name="document" type="environment" variant="example"> + <cd:arguments> + <cd:keywords optional="yes"> + <cd:constant type="cd:name"/> + </cd:keywords> + <cd:assignments list="yes" optional="yes"> + <cd:inherit name="setupdocument"/> + </cd:assignments> + </cd:arguments> + </cd:command> + <cd:command category="structure" file="file-job.mkvi" level="style" name="definedocument"> + <cd:arguments> + <cd:keywords> + <cd:constant type="cd:name"/> + </cd:keywords> + <cd:keywords optional="yes"> + <cd:constant type="cd:name"/> + </cd:keywords> <cd:assignments list="yes" optional="yes"> <cd:inherit name="setupdocument"/> </cd:assignments> @@ -8445,6 +8536,9 @@ </cd:command> <cd:command category="structure" file="file-job.mkvi" level="style" name="setupdocument"> <cd:arguments> + <cd:keywords list="yes" optional="yes"> + <cd:constant type="cd:name"/> + </cd:keywords> <cd:assignments list="yes"> <cd:parameter name="before"> <cd:constant type="cd:command"/> @@ -8472,6 +8566,9 @@ </cd:command> <cd:command category="structure" file="file-job.mkvi" level="style" name="presetdocument"> <cd:arguments> + <cd:keywords optional="yes"> + <cd:constant type="cd:name"/> + </cd:keywords> <cd:assignments list="yes"> <cd:inherit name="setupdocument"/> </cd:assignments> @@ -10157,104 +10254,6 @@ </cd:arguments> </cd:command> <cd:command category="rules" file="spac-flr.mkiv" level="document" name="dotfill"/> - <cd:command category="rules" file="node-rul.mkiv" keywords="metapost" level="style" name="definelinefiller"> - <cd:arguments> - <cd:keywords> - <cd:constant type="cd:name"/> - </cd:keywords> - <cd:keywords optional="yes"> - <cd:constant type="cd:name"/> - </cd:keywords> - <cd:assignments list="yes" optional="yes"> - <cd:inherit name="setuplinefiller"/> - </cd:assignments> - </cd:arguments> - </cd:command> - <cd:command category="rules" file="node-rul.mkiv" keywords="metapost" level="style" name="setuplinefiller"> - <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:constant type="cd:name"/> - </cd:keywords> - <cd:assignments list="yes"> - <cd:parameter name="location"> - <cd:constant type="left"/> - <cd:constant type="right"/> - <cd:constant default="yes" type="both"/> - </cd:parameter> - <cd:parameter name="scope"> - <cd:constant type="left"/> - <cd:constant type="right"/> - <cd:constant default="yes" type="local"/> - </cd:parameter> - <cd:parameter name="mp"> - <cd:constant type="cd:name"/> - </cd:parameter> - <cd:parameter name="height"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="depth"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="distance"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="threshold"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="rulethickness"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="before"> - <cd:constant type="cd:command"/> - </cd:parameter> - <cd:parameter name="after"> - <cd:constant type="cd:command"/> - </cd:parameter> - <cd:parameter name="color"> - <cd:constant type="cd:color"/> - </cd:parameter> - <cd:parameter name="textstyle"> - <cd:constant type="cd:style"/> - <cd:constant type="cd:command"/> - </cd:parameter> - <cd:parameter name="textcolor"> - <cd:constant type="cd:color"/> - </cd:parameter> - <cd:parameter name="align"> - <cd:inherit name="setupalign"/> - </cd:parameter> - </cd:assignments> - </cd:arguments> - </cd:command> - <cd:command category="rules" file="node-rul.mkiv" keywords="metapost" level="style" name="setuplinefillers"> - <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:constant type="cd:name"/> - </cd:keywords> - <cd:assignments list="yes"> - <cd:inherit name="setuplinefiller"/> - </cd:assignments> - </cd:arguments> - </cd:command> - <cd:command category="rules" file="node-rul.mkiv" keywords="metapost" level="style" name="linefiller" type="environment"> - <cd:arguments> - <cd:keywords> - <cd:constant type="filler"/> - <cd:constant type="cd:name"/> - </cd:keywords> - <cd:assignments list="yes" optional="yes"> - <cd:inherit name="setuplinefiller"/> - </cd:assignments> - </cd:arguments> - </cd:command> - <cd:command category="rules" file="node-rul.mkiv" keywords="metapost" level="style" name="setlinefiller"> - <cd:arguments> - <cd:keywords> - <cd:constant type="filler"/> - <cd:constant type="cd:name"/> - </cd:keywords> - </cd:arguments> - </cd:command> </cd:interface> <cd:interface file="i-fillinline.xml"> <cd:command category="rules" file="pack-mrl.mkiv" level="style" name="setupfillinlines"> @@ -13166,7 +13165,6 @@ <cd:command category="fonts" file="font-pre.mkiv" level="document" name="normal"/> <cd:command category="fonts" file="font-pre.mkiv" level="document" name="bold"/> <cd:command category="fonts" file="font-pre.mkiv" level="document" name="mono"/> - <cd:command category="fonts" file="font-pre.mkiv" level="document" name="monobold"/> <cd:command category="fonts" file="font-pre.mkiv" level="document" name="slanted"/> <cd:command category="fonts" file="font-pre.mkiv" level="document" name="italic"/> <cd:command category="fonts" file="font-pre.mkiv" level="document" name="boldslanted"/> @@ -14511,6 +14509,9 @@ <cd:constant type="frame"/> <cd:constant type="cd:dimension"/> </cd:parameter> + <cd:parameter name="backgroundcolor"> + <cd:resolve name="cd:color"/> + </cd:parameter> <cd:parameter name="component"> <cd:constant type="cd:name"/> </cd:parameter> @@ -14636,6 +14637,10 @@ <cd:parameter name="yanchor"> <cd:constant type="cd:dimension"/> </cd:parameter> + <cd:parameter name="linedirection"> + <cd:constant default="yes" type="normal"/> + <cd:constant type="reverse"/> + </cd:parameter> </cd:assignments> </cd:arguments> </cd:command> @@ -16229,7 +16234,6 @@ <cd:command category="whitespace" file="spac-hor.mkiv" level="system" name="fixedspaces"/> <cd:command category="whitespace" file="spac-hor.mkiv" level="system" name="keepunwantedspaces"/> <cd:command category="whitespace" file="spac-hor.mkiv" level="system" name="removeunwantedspaces"/> - <cd:command category="whitespace" file="spac-hor.mkiv" level="style" name="thinspace"/> <cd:command category="whitespace" file="spac-hor.mkiv" level="style" name="negthinspace"/> <cd:command category="whitespace" file="spac-hor.mkiv" level="style" name="enspace"/> <cd:command category="whitespace" file="spac-hor.mkiv" level="style" name="negenspace"/> @@ -16245,9 +16249,9 @@ </cd:keywords> </cd:arguments> </cd:command> - <cd:command category="whitespace" file="spac-hor.mkiv" keywords="layout" level="system" name="leftskipadaption"/> - <cd:command category="whitespace" file="spac-hor.mkiv" keywords="layout" level="system" name="rightskipadaption"/> - <cd:command category="whitespace" file="spac-hor.mkiv" keywords="layout" level="system" name="dosetleftskipadaption"> + <cd:command category="whitespace" file="spac-hor.mkxl" keywords="layout" level="system" name="leftskipadaption"/> + <cd:command category="whitespace" file="spac-hor.mkxl" keywords="layout" level="system" name="rightskipadaption"/> + <cd:command category="whitespace" file="spac-hor.mkxl" keywords="layout" level="system" name="dosetleftskipadaption"> <cd:arguments> <cd:keywords delimiters="braces"> <cd:constant type="yes"/> @@ -16257,7 +16261,7 @@ </cd:keywords> </cd:arguments> </cd:command> - <cd:command category="whitespace" file="spac-hor.mkiv" keywords="layout" level="system" name="dosetrightskipadaption"> + <cd:command category="whitespace" file="spac-hor.mkxl" keywords="layout" level="system" name="dosetrightskipadaption"> <cd:arguments> <cd:keywords delimiters="braces"> <cd:constant type="yes"/> @@ -16267,7 +16271,7 @@ </cd:keywords> </cd:arguments> </cd:command> - <cd:command category="whitespace" file="spac-hor.mkiv" keywords="layout" level="system" name="doadaptleftskip"> + <cd:command category="whitespace" file="spac-hor.mkxl" keywords="layout" level="system" name="doadaptleftskip"> <cd:arguments> <cd:keywords delimiters="braces"> <cd:constant type="yes"/> @@ -16277,7 +16281,7 @@ </cd:keywords> </cd:arguments> </cd:command> - <cd:command category="whitespace" file="spac-hor.mkiv" keywords="layout" level="system" name="doadaptrightskip"> + <cd:command category="whitespace" file="spac-hor.mkxl" keywords="layout" level="system" name="doadaptrightskip"> <cd:arguments> <cd:keywords delimiters="braces"> <cd:constant type="yes"/> @@ -16287,7 +16291,7 @@ </cd:keywords> </cd:arguments> </cd:command> - <cd:command category="whitespace" file="spac-hor.mkiv" level="system" name="activatespacehandler"> + <cd:command category="whitespace" file="spac-hor.mkxl" level="system" name="activatespacehandler"> <cd:arguments> <cd:keywords delimiters="braces"> <cd:constant type="on"/> @@ -16297,30 +16301,30 @@ </cd:keywords> </cd:arguments> </cd:command> - <cd:command category="whitespace" file="spac-hor.mkiv" level="style" name="quads"> + <cd:command category="whitespace" file="spac-hor.mkxl" level="style" name="quads"> <cd:arguments> <cd:keywords optional="yes"> <cd:constant type="cd:number"/> </cd:keywords> </cd:arguments> </cd:command> - <cd:command category="whitespace" file="spac/hor.mkiv" level="system" name="interwordspacebefore"/> - <cd:command category="whitespace" file="spac/hor.mkiv" level="system" name="interwordspaceafter"/> - <cd:command category="whitespace" file="spac/hor.mkiv" level="system" name="interwordspacesbefore"> + <cd:command category="whitespace" file="spac-hor.mkxl" level="system" name="interwordspacebefore"/> + <cd:command category="whitespace" file="spac-hor.mkxl" level="system" name="interwordspaceafter"/> + <cd:command category="whitespace" file="spac-hor.mkxl" level="system" name="interwordspacesbefore"> <cd:arguments> <cd:keywords delimiters="braces"> <cd:constant type="cd:number"/> </cd:keywords> </cd:arguments> </cd:command> - <cd:command category="whitespace" file="spac/hor.mkiv" level="system" name="interwordspacesafter"> + <cd:command category="whitespace" file="spac-hor.mkxl" level="system" name="interwordspacesafter"> <cd:arguments> <cd:keywords delimiters="braces"> <cd:constant type="cd:number"/> </cd:keywords> </cd:arguments> </cd:command> - <cd:command category="whitespace" file="spac/hor.mkiv" level="system" name="interwordspaces"> + <cd:command category="whitespace" file="spac-hor.mkxl" level="system" name="interwordspaces"> <cd:arguments> <cd:keywords delimiters="braces"> <cd:constant type="cd:number"/> @@ -16603,6 +16607,14 @@ </cd:keywords> </cd:arguments> </cd:command> + <cd:command category="language" file="lang-ini.mkxl" level="style" name="dohyphens"/> + <cd:command category="language" file="lang-ini.mkxl" level="style" name="nohyphens"/> + <cd:command category="language" file="lang-ini.mkxl" level="system" name="usehyphensparameter"> + <cd:arguments> + <cd:csname _error_="""/> + </cd:arguments> + </cd:command> + <cd:command category="language" file="lang-mis.mkxl" level="system" name="compounddiscretionary"/> </cd:interface> <cd:interface file="i-imposition.xml"> <cd:command category="layout" file="page-imp.mkiv" level="system" name="installshipoutmethod"> @@ -17981,181 +17993,6 @@ </cd:arguments> </cd:command> </cd:interface> - <cd:interface file="i-interlinespace.xml"> - <cd:command category="whitespace" file="spac-ver.mkiv" level="style" name="defineinterlinespace"> - <cd:arguments> - <cd:keywords> - <cd:constant type="cd:name"/> - </cd:keywords> - <cd:keywords optional="yes"> - <cd:constant type="cd:name"/> - </cd:keywords> - <cd:assignments list="yes" optional="yes"> - <cd:inherit name="setupinterlinespace"/> - </cd:assignments> - </cd:arguments> - </cd:command> - <cd:command category="whitespace" file="spac-ver.mkiv" level="style" name="setupinterlinespace"> - <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:constant type="cd:name"/> - </cd:keywords> - <cd:assignments list="yes"> - <cd:parameter name="line"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="height"> - <cd:constant type="cd:number"/> - </cd:parameter> - <cd:parameter name="depth"> - <cd:constant type="cd:number"/> - </cd:parameter> - <cd:parameter name="minheight"> - <cd:constant type="cd:number"/> - </cd:parameter> - <cd:parameter name="mindepth"> - <cd:constant type="cd:number"/> - </cd:parameter> - <cd:parameter name="distance"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="top"> - <cd:constant type="cd:number"/> - <cd:constant type="height"/> - </cd:parameter> - <cd:parameter name="bottom"> - <cd:constant type="cd:number"/> - </cd:parameter> - <cd:parameter name="stretch"> - <cd:constant type="cd:number"/> - </cd:parameter> - <cd:parameter name="shrink"> - <cd:constant type="cd:number"/> - </cd:parameter> - </cd:assignments> - </cd:arguments> - </cd:command> - <cd:command category="whitespace" file="spac-ver.mkiv" level="style" name="setupinterlinespace" variant="argument"> - <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:constant type="on"/> - <cd:constant type="off"/> - <cd:constant type="reset"/> - <cd:constant type="auto"/> - <cd:constant type="small"/> - <cd:constant type="medium"/> - <cd:constant type="big"/> - <cd:constant type="cd:number"/> - <cd:constant type="cd:dimension"/> - </cd:keywords> - </cd:arguments> - </cd:command> - <cd:command category="whitespace" file="spac-ver.mkiv" level="style" name="setupinterlinespace" variant="name"> - <cd:arguments> - <cd:keywords> - <cd:constant type="cd:name"/> - </cd:keywords> - </cd:arguments> - </cd:command> - <cd:command category="whitespace" file="spac-ver.mkiv" level="style" name="setuplocalinterlinespace"> - <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:constant type="cd:name"/> - </cd:keywords> - <cd:assignments list="yes"> - <cd:inherit name="setupinterlinespace"/> - </cd:assignments> - </cd:arguments> - </cd:command> - <cd:command category="whitespace" file="spac-ver.mkiv" level="style" name="setuplocalinterlinespace" variant="argument"> - <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:constant type="on"/> - <cd:constant type="off"/> - <cd:constant type="reset"/> - <cd:constant type="auto"/> - <cd:constant type="small"/> - <cd:constant type="medium"/> - <cd:constant type="big"/> - <cd:constant type="cd:number"/> - <cd:constant type="cd:dimension"/> - </cd:keywords> - </cd:arguments> - </cd:command> - <cd:command category="whitespace" file="spac-ver.mkiv" level="style" name="setuplocalinterlinespace" variant="name"> - <cd:arguments> - <cd:keywords> - <cd:constant type="cd:name"/> - </cd:keywords> - </cd:arguments> - </cd:command> - <cd:command category="whitespace" file="spac-ver.mkiv" level="style" name="switchtointerlinespace"> - <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:constant type="cd:name"/> - </cd:keywords> - <cd:assignments list="yes"> - <cd:inherit name="setupinterlinespace"/> - </cd:assignments> - </cd:arguments> - </cd:command> - <cd:command category="whitespace" file="spac-ver.mkiv" level="style" name="switchtointerlinespace" variant="argument"> - <cd:arguments> - <cd:keywords list="yes" optional="yes"> - <cd:constant type="on"/> - <cd:constant type="off"/> - <cd:constant type="reset"/> - <cd:constant type="auto"/> - <cd:constant type="small"/> - <cd:constant type="medium"/> - <cd:constant type="big"/> - <cd:constant type="cd:number"/> - <cd:constant type="cd:dimension"/> - </cd:keywords> - </cd:arguments> - </cd:command> - <cd:command category="whitespace" file="spac-ver.mkiv" level="style" name="switchtointerlinespace" variant="name"> - <cd:arguments> - <cd:keywords> - <cd:constant type="cd:name"/> - </cd:keywords> - </cd:arguments> - </cd:command> - <cd:command category="whitespace" file="spac-ver.mkiv" level="system" name="dosetupcheckedinterlinespace"> - <cd:arguments> - <cd:assignments delimiters="braces" list="yes"> - <cd:inherit name="setupinterlinespace"/> - </cd:assignments> - </cd:arguments> - </cd:command> - <cd:command category="whitespace" file="spac-ver.mkiv" level="system" name="dosetupcheckedinterlinespace" variant="argument"> - <cd:arguments> - <cd:keywords delimiters="braces" list="yes"> - <cd:constant type="on"/> - <cd:constant type="off"/> - <cd:constant type="reset"/> - <cd:constant type="auto"/> - <cd:constant type="small"/> - <cd:constant type="medium"/> - <cd:constant type="big"/> - <cd:constant type="cd:number"/> - <cd:constant type="cd:dimension"/> - </cd:keywords> - </cd:arguments> - </cd:command> - <cd:command category="whitespace" file="spac-ver.mkiv" level="system" name="dosetupcheckedinterlinespace" variant="name"> - <cd:arguments> - <cd:keywords delimiters="braces"> - <cd:constant type="cd:name"/> - </cd:keywords> - </cd:arguments> - </cd:command> - <cd:command category="whitespace" file="spac-ver.mkiv" level="system" name="useinterlinespaceparameter"> - <cd:arguments> - <cd:csname/> - </cd:arguments> - </cd:command> - </cd:interface> <cd:interface file="i-italiccorrection.xml"> <cd:command category="fonts" file="typo-itc.mkvi" level="system" name="setitaliccorrection"> <cd:arguments> @@ -18380,6 +18217,8 @@ <cd:parameter name="placestopper"> <cd:constant default="yes" type="yes"/> <cd:constant type="no"/> + <cd:constant type="display"/> + <cd:constant type="inline"/> </cd:parameter> <cd:parameter name="style"> <cd:constant type="cd:style"/> @@ -18602,6 +18441,8 @@ <cd:parameter name="placestopper"> <cd:constant default="yes" type="yes"/> <cd:constant type="no"/> + <cd:constant type="display"/> + <cd:constant type="inline"/> </cd:parameter> <cd:parameter name="style"> <cd:constant type="cd:style"/> @@ -18824,6 +18665,8 @@ <cd:parameter name="placestopper"> <cd:constant default="yes" type="yes"/> <cd:constant type="no"/> + <cd:constant type="display"/> + <cd:constant type="inline"/> </cd:parameter> <cd:parameter name="style"> <cd:constant type="cd:style"/> @@ -19051,6 +18894,8 @@ <cd:parameter name="placestopper"> <cd:constant default="yes" type="yes"/> <cd:constant type="no"/> + <cd:constant type="display"/> + <cd:constant type="inline"/> </cd:parameter> <cd:parameter name="style"> <cd:constant type="cd:style"/> @@ -20955,8 +20800,8 @@ <cd:constant default="yes" type="local"/> <cd:constant type="global"/> </cd:parameter> - <cd:parameter name="color"> - <cd:constant type="cd:color"/> + <cd:parameter name="mp"> + <cd:constant type="cd:name"/> </cd:parameter> <cd:parameter name="height"> <cd:constant type="cd:dimension"/> @@ -20973,6 +20818,15 @@ <cd:parameter name="rulethickness"> <cd:constant type="cd:dimension"/> </cd:parameter> + <cd:parameter name="before"> + <cd:constant type="cd:command"/> + </cd:parameter> + <cd:parameter name="after"> + <cd:constant type="cd:command"/> + </cd:parameter> + <cd:parameter name="color"> + <cd:constant type="cd:color"/> + </cd:parameter> <cd:parameter name="textstyle"> <cd:constant type="cd:style"/> <cd:constant type="cd:command"/> @@ -20983,15 +20837,6 @@ <cd:parameter name="align"> <cd:inherit name="setupalign"/> </cd:parameter> - <cd:parameter name="mp"> - <cd:constant type="cd:name"/> - </cd:parameter> - <cd:parameter name="before"> - <cd:constant type="cd:command"/> - </cd:parameter> - <cd:parameter name="after"> - <cd:constant type="cd:command"/> - </cd:parameter> </cd:assignments> </cd:arguments> </cd:command> @@ -22646,6 +22491,16 @@ <cd:variable value="ctxfunctiondefinition"/> </cd:sequence> </cd:command> + <cd:command category="lua" file="luat-ini.mkiv" level="system" name="setctxluafunction"> + <cd:arguments> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:name"/> + </cd:keywords> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:number"/> + </cd:keywords> + </cd:arguments> + </cd:command> <cd:command category="lua" file="luat-ini.mkiv" level="system" name="ctxfunction" type="environment"> <cd:arguments> <cd:keywords delimiters="none"> @@ -22660,11 +22515,45 @@ </cd:keywords> </cd:arguments> </cd:command> + <cd:command category="lua" file="luat-ini.mkiv" level="system" name="installctxfunction"> + <cd:arguments> + <cd:csname/> + <cd:content/> + </cd:arguments> + </cd:command> <cd:command category="lua" file="luat-ini.mkiv" generated="yes" level="system" name="ctxfunction" variant="example"> <cd:sequence> <cd:variable value="ctxfunction"/> </cd:sequence> </cd:command> + <cd:command category="lua" file="luat-ini.mkiv" level="system" name="installctxscanner"> + <cd:arguments> + <cd:csname/> + <cd:content/> + </cd:arguments> + </cd:command> + <cd:command category="lua" file="luat-ini.mkiv" generated="yes" level="system" name="ctxscanner" variant="example"> + <cd:sequence> + <cd:variable value="ctxscanner"/> + </cd:sequence> + </cd:command> + <cd:command category="lua" file="luat-ini.mkiv" level="system" name="installprotectedctxfunction"> + <cd:arguments> + <cd:csname/> + <cd:content/> + </cd:arguments> + </cd:command> + <cd:command category="lua" file="luat-ini.mkiv" level="system" name="installprotectedctxscanner"> + <cd:arguments> + <cd:csname/> + <cd:content/> + </cd:arguments> + </cd:command> + <cd:command category="lua" file="luat-ini.mkiv" level="system" name="resetctxscanner"> + <cd:arguments> + <cd:csname/> + </cd:arguments> + </cd:command> </cd:interface> <cd:interface file="i-luatable.xml"> <cd:command category="lua" file="cldf-int.mkxl" level="system" name="newluatable"> @@ -23223,6 +23112,7 @@ <cd:command category="structure" file="strc-mar.mkiv" level="system" name="resetmarking"> <cd:arguments> <cd:keywords> + <cd:constant type="all"/> <cd:constant type="cd:mark"/> </cd:keywords> </cd:arguments> @@ -24695,15 +24585,22 @@ <cd:instances> <cd:constant value="matrix"/> <cd:constant value="mathmatrix"/> + <cd:constant value="thematrix"/> </cd:instances> </cd:command> - <cd:command category="mathematics" file="math-ali.mkiv" generated="yes" keywords="tables" level="document" name="mathmatrix"> + <cd:command category="mathematics" file="math-ali.mkiv" generated="yes" keywords="tables" level="document" name="mathmatrix" variant="instance"> <cd:sequence> - <cd:variable value="mathmatrix"/> + <cd:instance value="mathmatrix"/> </cd:sequence> <cd:arguments> + <cd:assignments list="yes" optional="yes"> + <cd:inherit name="setupmathmatrix"/> + </cd:assignments> <cd:content/> </cd:arguments> + <cd:instances> + <cd:constant value="thematrix"/> + </cd:instances> </cd:command> <cd:command category="mathematics" file="math-ali.mkiv" keywords="tables" level="document" name="matrices" type="environment"> <cd:arguments> @@ -27701,7 +27598,7 @@ </cd:assignments> </cd:arguments> </cd:command> - <cd:command category="structure" file="strc-tnt.mkiv" generated="yes" keywords="notes" level="document" name="textnote"> + <cd:command category="structure" file="strc-tnt.mkiv" generated="yes" keywords="notes" level="document" name="textnote" variant="example"> <cd:arguments> <cd:assignments list="yes" optional="yes"> <cd:inherit name="setuptextnote"/> @@ -29117,6 +29014,7 @@ <cd:constant type="inmargin"/> <cd:constant type="atmargin"/> <cd:constant type="marginedge"/> + <cd:constant type="none"/> </cd:parameter> <cd:parameter name="style"> <cd:constant type="cd:style"/> @@ -30253,6 +30151,82 @@ </cd:arguments> </cd:command> </cd:interface> + <cd:interface file="i-parwrapper.xml"> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="freezeparagraphproperties"/> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="defrostparagraphproperties"/> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="updateparagraphproperties"/> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="updateparagraphpenalties"/> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="updateparagraphdemerits"/> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="updateparagraphshapes"/> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="setparagraphfreezing"/> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="forgetparagraphfreezing"/> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="registerparwrapper"> + <cd:arguments> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:name"/> + </cd:keywords> + <cd:content/> + <cd:content/> + </cd:arguments> + </cd:command> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="registerparwrapperreverse"> + <cd:arguments> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:name"/> + </cd:keywords> + <cd:content/> + <cd:content/> + </cd:arguments> + </cd:command> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="directparwrapper"> + <cd:arguments> + <cd:content/> + <cd:content/> + </cd:arguments> + </cd:command> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="forgetparwrapper"/> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="unregisterparwrapper"> + <cd:arguments> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:name"/> + </cd:keywords> + </cd:arguments> + </cd:command> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="doifelseparwrapper"> + <cd:arguments> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:name"/> + </cd:keywords> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:true"/> + </cd:keywords> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:false"/> + </cd:keywords> + </cd:arguments> + </cd:command> + <cd:command category="whitespace" file="spac-par.mkxl" level="system" name="showparwrapperstate"> + <cd:arguments> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:name"/> + </cd:keywords> + </cd:arguments> + </cd:command> + <cd:command category="whitespace" file="spac-par.lmt" level="system" name="getparwrapper"> + <cd:arguments> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:name"/> + </cd:keywords> + </cd:arguments> + </cd:command> + <cd:command category="whitespace" file="spac-par.lmt" level="system" name="lastparwrapper"> + <cd:arguments> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:name"/> + </cd:keywords> + </cd:arguments> + </cd:command> + </cd:interface> <cd:interface file="i-pdf.xml"> <cd:command category="pdf" file="back-pdf.mkiv" level="system" name="pdfbackendsetcatalog"> <cd:arguments> @@ -37024,7 +36998,7 @@ <cd:keywords> <cd:constant type="cd:name"/> </cd:keywords> - <cd:keywords> + <cd:keywords optional="yes"> <cd:constant type="cd:text"/> </cd:keywords> <cd:keywords> @@ -37038,6 +37012,9 @@ <cd:constant type="reset"/> <cd:constant type="cd:name"/> </cd:keywords> + <cd:keywords optional="yes"> + <cd:constant type="cd:name"/> + </cd:keywords> </cd:arguments> </cd:command> <cd:command category="language" file="lang-rep.mkiv" level="style" name="resetreplacements"/> @@ -39842,6 +39819,10 @@ <cd:parameter name="inbetween"> <cd:constant type="cd:command"/> </cd:parameter> + <cd:parameter name="hyphens"> + <cd:constant default="yes" type="yes"/> + <cd:constant type="no"/> + </cd:parameter> </cd:assignments> </cd:arguments> </cd:command> @@ -42230,7 +42211,6 @@ </cd:keywords> </cd:arguments> </cd:command> - <cd:command category="catcode" file="syst-aux.mkiv" level="system" name="texcode" type="environment"/> <cd:command category="counter" file="syst-aux.mkiv" level="system" name="newcounter"> <cd:arguments> <cd:csname/> @@ -42463,6 +42443,20 @@ <cd:delimiter name="fi"/> </cd:arguments> </cd:command> + <cd:command category="system" file="syst-aux.mkiv" keywords="conditional" level="system" name="validassignment"> + <cd:arguments> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:text"/> + </cd:keywords> + </cd:arguments> + </cd:command> + <cd:command category="system" file="syst-aux.mkiv" keywords="conditional" level="system" name="nonvalidassignment"> + <cd:arguments> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:text"/> + </cd:keywords> + </cd:arguments> + </cd:command> <cd:command category="system" file="syst-aux.mkiv" keywords="conditional" level="system" name="doifelseassignmentcs"> <cd:arguments> <cd:keywords delimiters="braces"> @@ -48848,6 +48842,16 @@ </cd:keywords> </cd:arguments> </cd:command> + <cd:command category="whitespace" file="spac-ver.mkxl" keywords="conditional" level="document" name="doifoutervmode"> + <cd:arguments> + <cd:content/> + </cd:arguments> + </cd:command> + <cd:command category="whitespace" file="spac-ver.mkxl" level="document" name="dosomebreak"> + <cd:arguments> + <cd:csname/> + </cd:arguments> + </cd:command> <cd:command category="whitespace" file="spac-ver.mkiv" level="document" name="godown"> <cd:arguments> <cd:keywords> @@ -49999,16 +50003,6 @@ </cd:keywords> </cd:arguments> </cd:command> - <cd:command category="xml" file="lxml-ini.mkiv" level="style" name="xmlregisterns"> - <cd:arguments> - <cd:keywords delimiters="braces"> - <cd:constant type="cd:name"/> - </cd:keywords> - <cd:keywords delimiters="braces"> - <cd:constant type="cd:name"/> - </cd:keywords> - </cd:arguments> - </cd:command> <cd:command category="xml" file="lxml-ini.mkiv" level="style" name="xmlremapname"> <cd:arguments> <cd:keywords delimiters="braces"> diff --git a/tex/context/interface/mkiv/i-boxes.xml b/tex/context/interface/mkiv/i-boxes.xml index e18243811..b13c8c3ab 100644 --- a/tex/context/interface/mkiv/i-boxes.xml +++ b/tex/context/interface/mkiv/i-boxes.xml @@ -1256,4 +1256,10 @@ </cd:arguments> </cd:command> + <cd:command name="reversevboxcontent" level="system" category="boxes" file="supp-box.lmt"> + <cd:arguments> + <cd:resolve name="string-box"/> + </cd:arguments> + </cd:command> + </cd:interface> diff --git a/tex/context/interface/mkiv/i-catcodes.xml b/tex/context/interface/mkiv/i-catcodes.xml index 4e112c491..561cd9af6 100644 --- a/tex/context/interface/mkiv/i-catcodes.xml +++ b/tex/context/interface/mkiv/i-catcodes.xml @@ -4,7 +4,7 @@ <cd:interface xmlns:cd="http://www.pragma-ade.com/commands"> - <cd:command name="texcode" type="environment" level="system" category="catcode" file="catc-ctx.mkiv"/> + <cd:command name="texcode" type="environment" level="system" category="catcode" file="catc-ctx.mkxl"/> <cd:command name="contextcode" type="environment" level="system" category="catcode" file="catc-ctx.mkiv"/> diff --git a/tex/context/interface/mkiv/i-columns.xml b/tex/context/interface/mkiv/i-columns.xml index 72260b820..9890ec46f 100644 --- a/tex/context/interface/mkiv/i-columns.xml +++ b/tex/context/interface/mkiv/i-columns.xml @@ -4,8 +4,19 @@ <cd:interface xmlns:cd="http://www.pragma-ade.com/commands"> - <cd:command name="setupcolumns" level="style" category="columns" file="page-mul.mkiv"> + <cd:command name="definemulticolumns" level="style" category="tables" file="page-mcl.mkxl"> <cd:arguments> + <cd:resolve name="keyword-name"/> + <cd:resolve name="keyword-name-optional"/> + <cd:assignments optional="yes" list="yes"> + <cd:inherit name="setupmulticolumns"/> + </cd:assignments> + </cd:arguments> + </cd:command> + + <cd:command name="setupmulticolumns" level="style" category="columns" file="page-mcl.mkxl"> + <cd:arguments> + <cd:resolve name="keyword-name-list-optional"/> <cd:assignments list="yes"> <cd:parameter name="n"> <cd:constant type="cd:number"/> @@ -13,112 +24,31 @@ <cd:parameter name="distance"> <cd:constant type="cd:dimension"/> </cd:parameter> - <cd:parameter name="option"> - <cd:constant type="background"/> - </cd:parameter> - <cd:parameter name="offset"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="command"> - <cd:constant type="cd:oneargument"/> - </cd:parameter> - <cd:parameter name="height"> - <cd:constant type="cd:dimension"/> - </cd:parameter> <cd:parameter name="direction"> - <cd:constant type="left"/> <cd:constant type="right" default="yes"/> + <cd:constant type="reverse"/> </cd:parameter> <cd:parameter name="balance"> <cd:constant type="yes" default="yes"/> <cd:constant type="no"/> </cd:parameter> - <cd:parameter name="align"> - <cd:inherit name="setupalign"/> - </cd:parameter> - <cd:parameter name="tolerance"> - <cd:inherit name="setuptolerance"/> - </cd:parameter> <cd:parameter name="blank"> <cd:inherit name="blank"/> </cd:parameter> - <cd:parameter name="ntop"> - <cd:constant type="cd:number"/> - </cd:parameter> - <cd:parameter name="rule"> - <cd:constant type="on"/> - <cd:constant type="off" default="yes"/> - <cd:constant type="cd:command"/> + <cd:parameter name="align"> + <cd:inherit name="setupalign"/> </cd:parameter> - </cd:assignments> - </cd:arguments> - </cd:command> - - <cd:command name="columns" type="environment" level="document" category="columns" file="page-mul.mkiv"> - <cd:arguments> - <cd:assignments list="yes" optional="yes"> - <cd:inherit name="setupcolumns"/> - </cd:assignments> - </cd:arguments> - </cd:command> - - <cd:command name="setupcolumnspan" level="style" category="columns" file="page-mul.mkiv"> - <cd:arguments> - <cd:assignments list="yes"> - <cd:parameter name="n"> + <cd:parameter name="ntop"> <cd:constant type="cd:number"/> </cd:parameter> - <cd:inherit name="setupframed"/> </cd:assignments> </cd:arguments> </cd:command> - <cd:command name="columnspan" type="environment" level="document" category="columns" file="page-mul.mkiv"> + <cd:command name="multicolumns" type="environment" level="document" category="tables" file="page-mcl.mkxl"> <cd:arguments> - <cd:assignments list="yes" optional="yes"> - <cd:inherit name="setupcolumnspan"/> - </cd:assignments> - </cd:arguments> - </cd:command> - - <!-- - - <cd:command name="setsimplecolumnshsize" level="system" category="columns" file="page-mul.mkiv"> - <cd:arguments> - <cd:assignments list="yes"> - <cd:parameter name="n"> - <cd:constant type="cd:number"/> - </cd:parameter> - <cd:parameter name="width"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="distance"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="lines"> - <cd:constant type="cd:number"/> - </cd:parameter> - </cd:assignments> - </cd:arguments> - </cd:command> - - --> - - <cd:command name="simplecolumns" type="environment" level="system" category="columns" file="page-mul.mkiv"> - <cd:arguments> - <cd:assignments list="yes" optional="yes"> - <cd:parameter name="n"> - <cd:constant type="cd:number"/> - </cd:parameter> - <cd:parameter name="width"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="distance"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="lines"> - <cd:constant type="cd:number"/> - </cd:parameter> + <cd:assignments optional="yes" list="yes"> + <cd:inherit name="setupmulticolumns"/> </cd:assignments> </cd:arguments> </cd:command> diff --git a/tex/context/interface/mkiv/i-common-argument.xml b/tex/context/interface/mkiv/i-common-argument.xml index 5741a1c8a..c1b2f8cb3 100644 --- a/tex/context/interface/mkiv/i-common-argument.xml +++ b/tex/context/interface/mkiv/i-common-argument.xml @@ -594,4 +594,15 @@ </cd:keywords> </cd:define> + <!-- * --> + <!-- \... {...} --> + <!-- --> + <!-- * URL --> + + <cd:define name="argument-url"> + <cd:keywords delimiters="braces"> + <cd:constant type="cd:url"/> + </cd:keywords> + </cd:define> + </cd:interface> diff --git a/tex/context/interface/mkiv/i-common-instance.xml b/tex/context/interface/mkiv/i-common-instance.xml index 025dafc4a..07ca3ac15 100644 --- a/tex/context/interface/mkiv/i-common-instance.xml +++ b/tex/context/interface/mkiv/i-common-instance.xml @@ -182,6 +182,11 @@ <cd:define name="instance-mathmatrix"> <cd:constant value="matrix"/> <cd:constant value="mathmatrix"/> + <cd:constant value="thematrix"/> + </cd:define> + + <cd:define name="instance-simplematrix"> + <cd:constant value="thematrix"/> </cd:define> <cd:define name="instance-mixedcolumns"> diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex 7950faf9f..f1ee11be3 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-context.xml b/tex/context/interface/mkiv/i-context.xml index 2afbdfee2..a1f53f470 100644 --- a/tex/context/interface/mkiv/i-context.xml +++ b/tex/context/interface/mkiv/i-context.xml @@ -53,6 +53,7 @@ <cd:interfacefile filename="i-clipping.xml"/> <cd:interfacefile filename="i-collector.xml"/> <cd:interfacefile filename="i-color.xml"/> + <cd:interfacefile filename="i-columns.xml"/> <cd:interfacefile filename="i-combination.xml"/> <cd:interfacefile filename="i-commandhandler.xml"/> <cd:interfacefile filename="i-comment.xml"/> @@ -107,7 +108,6 @@ <cd:interfacefile filename="i-interactionscreen.xml"/> <cd:interfacefile filename="i-interface.xml"/> <cd:interfacefile filename="i-interlinespace.xml"/> - <cd:interfacefile filename="i-interlinespace.xml"/> <cd:interfacefile filename="i-italiccorrection.xml"/> <cd:interfacefile filename="i-itemgroup.xml"/> <cd:interfacefile filename="i-items.xml"/> @@ -177,6 +177,7 @@ <cd:interfacefile filename="i-paragraphs.xml"/> <cd:interfacefile filename="i-parallel.xml"/> <cd:interfacefile filename="i-parbuilder.xml"/> + <cd:interfacefile filename="i-parwrapper.xml"/> <cd:interfacefile filename="i-pdf.xml"/> <cd:interfacefile filename="i-penalty.xml"/> <cd:interfacefile filename="i-periods.xml"/> diff --git a/tex/context/interface/mkiv/i-counter.xml b/tex/context/interface/mkiv/i-counter.xml index 7879fe27d..f3e622e5f 100644 --- a/tex/context/interface/mkiv/i-counter.xml +++ b/tex/context/interface/mkiv/i-counter.xml @@ -26,6 +26,9 @@ <cd:parameter name="start"> <cd:constant type="cd:number"/> </cd:parameter> + <cd:parameter name="number"> + <cd:constant type="cd:number"/> + </cd:parameter> <cd:parameter name="counter"> <cd:constant type="cd:name"/> </cd:parameter> diff --git a/tex/context/interface/mkiv/i-document.xml b/tex/context/interface/mkiv/i-document.xml index 5886aa8eb..3ea0d0eeb 100644 --- a/tex/context/interface/mkiv/i-document.xml +++ b/tex/context/interface/mkiv/i-document.xml @@ -164,6 +164,26 @@ <cd:command name="document" type="environment" level="document" category="structure" file="file-job.mkvi"> <cd:arguments> + <cd:resolve name="keyword-name-optional"/> + <cd:assignments list="yes" optional="yes"> + <cd:inherit name="setupdocument"/> + </cd:assignments> + </cd:arguments> + </cd:command> + + <cd:command name="document" type="environment" generated="yes" variant="example" level="document" category="structure" file="file-job.mkvi"> + <cd:arguments> + <cd:resolve name="keyword-name-optional"/> + <cd:assignments list="yes" optional="yes"> + <cd:inherit name="setupdocument"/> + </cd:assignments> + </cd:arguments> + </cd:command> + + <cd:command name="definedocument" level="style" category="structure" file="file-job.mkvi"> + <cd:arguments> + <cd:resolve name="keyword-name"/> + <cd:resolve name="keyword-name-optional"/> <cd:assignments list="yes" optional="yes"> <cd:inherit name="setupdocument"/> </cd:assignments> @@ -172,6 +192,7 @@ <cd:command name="setupdocument" level="style" category="structure" file="file-job.mkvi"> <cd:arguments> + <cd:resolve name="keyword-name-list-optional"/> <cd:assignments list="yes"> <cd:parameter name="before"> <cd:constant type="cd:command"/> @@ -200,6 +221,7 @@ <cd:command name="presetdocument" level="style" category="structure" file="file-job.mkvi"> <cd:arguments> + <cd:resolve name="keyword-name-optional"/> <cd:assignments list="yes"> <cd:inherit name="setupdocument"/> </cd:assignments> diff --git a/tex/context/interface/mkiv/i-filler.xml b/tex/context/interface/mkiv/i-filler.xml index 078dc4b7a..2e425a3f7 100644 --- a/tex/context/interface/mkiv/i-filler.xml +++ b/tex/context/interface/mkiv/i-filler.xml @@ -129,98 +129,4 @@ <cd:command name="dotfill" level="document" category="rules" file="spac-flr.mkiv"/> - <cd:command name="definelinefiller" level="style" category="rules" keywords="metapost" file="node-rul.mkiv"> - <cd:arguments> - <cd:resolve name="keyword-name"/> - <cd:resolve name="keyword-name-optional"/> - <cd:assignments list="yes" optional="yes"> - <cd:inherit name="setuplinefiller"/> - </cd:assignments> - </cd:arguments> - </cd:command> - - <cd:command name="setuplinefiller" level="style" category="rules" keywords="metapost" file="node-rul.mkiv"> - <cd:arguments> - <cd:resolve name="keyword-name-list-optional"/> - <cd:assignments list="yes"> - <cd:parameter name="location"> - <cd:constant type="left"/> - <cd:constant type="right"/> - <cd:constant type="both" default="yes"/> - </cd:parameter> - <cd:parameter name="scope"> - <cd:constant type="left"/> - <cd:constant type="right"/> - <cd:constant type="local" default="yes"/> - </cd:parameter> - <cd:parameter name="mp"> - <cd:constant type="cd:name"/> - </cd:parameter> - <cd:parameter name="height"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="depth"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="distance"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="threshold"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="rulethickness"> - <cd:constant type="cd:dimension"/> - </cd:parameter> - <cd:parameter name="before"> - <cd:constant type="cd:command"/> - </cd:parameter> - <cd:parameter name="after"> - <cd:constant type="cd:command"/> - </cd:parameter> - <cd:parameter name="color"> - <cd:constant type="cd:color"/> - </cd:parameter> - <cd:parameter name="textstyle"> - <cd:resolve name="value-style"/> - </cd:parameter> - <cd:parameter name="textcolor"> - <cd:constant type="cd:color"/> - </cd:parameter> - <cd:parameter name="align"> - <cd:inherit name="setupalign"/> - </cd:parameter> - </cd:assignments> - </cd:arguments> - </cd:command> - - <cd:command name="setuplinefillers" level="style" category="rules" keywords="metapost" file="node-rul.mkiv"> - <cd:arguments> - <cd:resolve name="keyword-name-list-optional"/> - <cd:assignments list="yes"> - <cd:inherit name="setuplinefiller"/> - </cd:assignments> - </cd:arguments> - </cd:command> - - <cd:command name="linefiller" type="environment" level="style" category="rules" keywords="metapost" file="node-rul.mkiv"> - <cd:arguments> - <cd:keywords> - <cd:constant type="filler"/> - <cd:constant type="cd:name"/> - </cd:keywords> - <cd:assignments list="yes" optional="yes"> - <cd:inherit name="setuplinefiller"/> - </cd:assignments> - </cd:arguments> - </cd:command> - - <cd:command name="setlinefiller" level="style" category="rules" keywords="metapost" file="node-rul.mkiv"> - <cd:arguments> - <cd:keywords> - <cd:constant type="filler"/> - <cd:constant type="cd:name"/> - </cd:keywords> - </cd:arguments> - </cd:command> - </cd:interface> diff --git a/tex/context/interface/mkiv/i-fonts.xml b/tex/context/interface/mkiv/i-fonts.xml index 7cb1cbe99..a32aa1672 100644 --- a/tex/context/interface/mkiv/i-fonts.xml +++ b/tex/context/interface/mkiv/i-fonts.xml @@ -1153,8 +1153,6 @@ <cd:command name="mono" level="document" category="fonts" file="font-pre.mkiv"/> - <cd:command name="monobold" level="document" category="fonts" file="font-pre.mkiv"/> - <cd:command name="slanted" level="document" category="fonts" file="font-pre.mkiv"/> <cd:command name="italic" level="document" category="fonts" file="font-pre.mkiv"/> diff --git a/tex/context/interface/mkiv/i-framed.xml b/tex/context/interface/mkiv/i-framed.xml index d57a66969..ad8080a9d 100644 --- a/tex/context/interface/mkiv/i-framed.xml +++ b/tex/context/interface/mkiv/i-framed.xml @@ -103,6 +103,9 @@ <cd:constant type="frame"/> <cd:constant type="cd:dimension"/> </cd:parameter> + <cd:parameter name="backgroundcolor"> + <cd:resolve name="cd:color"/> + </cd:parameter> <cd:parameter name="component"> <cd:constant type="cd:name"/> </cd:parameter> @@ -234,6 +237,10 @@ <cd:parameter name="yanchor"> <cd:constant type="cd:dimension"/> </cd:parameter> + <cd:parameter name="linedirection"> + <cd:constant type="normal" default="yes"/> + <cd:constant type="reverse"/> + </cd:parameter> </cd:assignments> </cd:arguments> </cd:command> diff --git a/tex/context/interface/mkiv/i-hspace.xml b/tex/context/interface/mkiv/i-hspace.xml index 878063106..222317468 100644 --- a/tex/context/interface/mkiv/i-hspace.xml +++ b/tex/context/interface/mkiv/i-hspace.xml @@ -87,8 +87,6 @@ <cd:command name="removeunwantedspaces" level="system" category="whitespace" file="spac-hor.mkiv"/> - <cd:command name="thinspace" level="style" category="whitespace" file="spac-hor.mkiv"/> - <cd:command name="negthinspace" level="style" category="whitespace" file="spac-hor.mkiv"/> <cd:command name="enspace" level="style" category="whitespace" file="spac-hor.mkiv"/> @@ -111,11 +109,11 @@ </cd:arguments> </cd:command> - <cd:command name="leftskipadaption" level="system" category="whitespace" keywords="layout" file="spac-hor.mkiv"/> + <cd:command name="leftskipadaption" level="system" category="whitespace" keywords="layout" file="spac-hor.mkxl"/> - <cd:command name="rightskipadaption" level="system" category="whitespace" keywords="layout" file="spac-hor.mkiv"/> + <cd:command name="rightskipadaption" level="system" category="whitespace" keywords="layout" file="spac-hor.mkxl"/> - <cd:command name="dosetleftskipadaption" level="system" category="whitespace" keywords="layout" file="spac-hor.mkiv"> + <cd:command name="dosetleftskipadaption" level="system" category="whitespace" keywords="layout" file="spac-hor.mkxl"> <cd:arguments> <cd:keywords delimiters="braces"> <cd:resolve name="value-leftskip"/> @@ -123,7 +121,7 @@ </cd:arguments> </cd:command> - <cd:command name="dosetrightskipadaption" level="system" category="whitespace" keywords="layout" file="spac-hor.mkiv"> + <cd:command name="dosetrightskipadaption" level="system" category="whitespace" keywords="layout" file="spac-hor.mkxl"> <cd:arguments> <cd:keywords delimiters="braces"> <cd:resolve name="value-rightskip"/> @@ -131,7 +129,7 @@ </cd:arguments> </cd:command> - <cd:command name="doadaptleftskip" level="system" category="whitespace" keywords="layout" file="spac-hor.mkiv"> + <cd:command name="doadaptleftskip" level="system" category="whitespace" keywords="layout" file="spac-hor.mkxl"> <cd:arguments> <cd:keywords delimiters="braces"> <cd:resolve name="value-leftskip"/> @@ -139,7 +137,7 @@ </cd:arguments> </cd:command> - <cd:command name="doadaptrightskip" level="system" category="whitespace" keywords="layout" file="spac-hor.mkiv"> + <cd:command name="doadaptrightskip" level="system" category="whitespace" keywords="layout" file="spac-hor.mkxl"> <cd:arguments> <cd:keywords delimiters="braces"> <cd:resolve name="value-rightskip"/> @@ -147,7 +145,7 @@ </cd:arguments> </cd:command> - <cd:command name="activatespacehandler" level="system" category="whitespace" file="spac-hor.mkiv"> + <cd:command name="activatespacehandler" level="system" category="whitespace" file="spac-hor.mkxl"> <cd:arguments> <cd:keywords delimiters="braces"> <cd:constant type="on"/> @@ -161,29 +159,29 @@ </cd:arguments> </cd:command> - <cd:command name="quads" level="style" category="whitespace" file="spac-hor.mkiv"> + <cd:command name="quads" level="style" category="whitespace" file="spac-hor.mkxl"> <cd:arguments> <cd:resolve name="keyword-number-optional"/> </cd:arguments> </cd:command> - <cd:command name="interwordspacebefore" level="system" category="whitespace" file="spac/hor.mkiv"/> + <cd:command name="interwordspacebefore" level="system" category="whitespace" file="spac-hor.mkxl"/> - <cd:command name="interwordspaceafter" level="system" category="whitespace" file="spac/hor.mkiv"/> + <cd:command name="interwordspaceafter" level="system" category="whitespace" file="spac-hor.mkxl"/> - <cd:command name="interwordspacesbefore" level="system" category="whitespace" file="spac/hor.mkiv"> + <cd:command name="interwordspacesbefore" level="system" category="whitespace" file="spac-hor.mkxl"> <cd:arguments> <cd:resolve name="argument-number"/> </cd:arguments> </cd:command> - <cd:command name="interwordspacesafter" level="system" category="whitespace" file="spac/hor.mkiv"> + <cd:command name="interwordspacesafter" level="system" category="whitespace" file="spac-hor.mkxl"> <cd:arguments> <cd:resolve name="argument-number"/> </cd:arguments> </cd:command> - <cd:command name="interwordspaces" level="system" category="whitespace" file="spac/hor.mkiv"> + <cd:command name="interwordspaces" level="system" category="whitespace" file="spac-hor.mkxl"> <cd:arguments> <cd:resolve name="argument-number"/> </cd:arguments> diff --git a/tex/context/interface/mkiv/i-hyphenation.xml b/tex/context/interface/mkiv/i-hyphenation.xml index 4ab4fe1d8..5437c81c0 100644 --- a/tex/context/interface/mkiv/i-hyphenation.xml +++ b/tex/context/interface/mkiv/i-hyphenation.xml @@ -261,4 +261,16 @@ </cd:arguments> </cd:command> + <cd:command name="dohyphens" level="style" category="language" file="lang-ini.mkxl"/> + + <cd:command name="nohyphens" level="style" category="language" file="lang-ini.mkxl"/> + + <cd:command name="usehyphensparameter" level="system" category="language" file="lang-ini.mkxl"> + <cd:arguments> + <cd:csname"/> + </cd:arguments> + </cd:command> + + <cd:command name="compounddiscretionary" level="system" category="language" file="lang-mis.mkxl"/> + </cd:interface> diff --git a/tex/context/interface/mkiv/i-itemgroup.xml b/tex/context/interface/mkiv/i-itemgroup.xml index 6d687f381..81fc3ba5a 100644 --- a/tex/context/interface/mkiv/i-itemgroup.xml +++ b/tex/context/interface/mkiv/i-itemgroup.xml @@ -163,6 +163,8 @@ <cd:parameter name="placestopper"> <cd:constant type="yes" default="yes"/> <cd:constant type="no"/> + <cd:constant type="display"/> + <cd:constant type="inline"/> </cd:parameter> <cd:parameter name="style"> <cd:resolve name="value-style"/> @@ -353,6 +355,8 @@ <cd:parameter name="placestopper"> <cd:constant type="yes" default="yes"/> <cd:constant type="no"/> + <cd:constant type="display"/> + <cd:constant type="inline"/> </cd:parameter> <cd:parameter name="style"> <cd:resolve name="value-style"/> diff --git a/tex/context/interface/mkiv/i-linefiller.xml b/tex/context/interface/mkiv/i-linefiller.xml index aeb14046d..74803cbe5 100644 --- a/tex/context/interface/mkiv/i-linefiller.xml +++ b/tex/context/interface/mkiv/i-linefiller.xml @@ -29,9 +29,14 @@ <cd:constant type="local" default="yes"/> <cd:constant type="global"/> </cd:parameter> - <cd:parameter name="color"> - <cd:constant type="cd:color"/> + <cd:parameter name="mp"> + <cd:constant type="cd:name"/> </cd:parameter> + <!-- + cd:parameter name="method"> + <cd:constant type="cd:number"/> + </cd:parameter + --> <cd:parameter name="height"> <cd:constant type="cd:dimension"/> </cd:parameter> @@ -47,9 +52,15 @@ <cd:parameter name="rulethickness"> <cd:constant type="cd:dimension"/> </cd:parameter> - <!-- cd:parameter name="method"> - <cd:constant type="cd:number"/> - </cd:parameter --> + <cd:parameter name="before"> + <cd:constant type="cd:command"/> + </cd:parameter> + <cd:parameter name="after"> + <cd:constant type="cd:command"/> + </cd:parameter> + <cd:parameter name="color"> + <cd:constant type="cd:color"/> + </cd:parameter> <cd:parameter name="textstyle"> <cd:resolve name="value-style"/> </cd:parameter> @@ -59,15 +70,6 @@ <cd:parameter name="align"> <cd:inherit name="setupalign"/> </cd:parameter> - <cd:parameter name="mp"> - <cd:constant type="cd:name"/> - </cd:parameter> - <cd:parameter name="before"> - <cd:constant type="cd:command"/> - </cd:parameter> - <cd:parameter name="after"> - <cd:constant type="cd:command"/> - </cd:parameter> </cd:assignments> </cd:arguments> </cd:command> diff --git a/tex/context/interface/mkiv/i-lua.xml b/tex/context/interface/mkiv/i-lua.xml index 94f25d0f7..424622507 100644 --- a/tex/context/interface/mkiv/i-lua.xml +++ b/tex/context/interface/mkiv/i-lua.xml @@ -172,6 +172,13 @@ </cd:sequence> </cd:command> + <cd:command name="setctxluafunction" level="system" category="lua" file="luat-ini.mkiv"> + <cd:arguments> + <cd:resolve name="argument-name"/> + <cd:resolve name="argument-number"/> + </cd:arguments> + </cd:command> + <cd:command name="ctxfunction" type="environment" level="system" category="lua" file="luat-ini.mkiv"> <cd:arguments> <cd:resolve name="string-name"/> @@ -184,10 +191,50 @@ </cd:arguments> </cd:command> + <cd:command name="installctxfunction" level="system" category="lua" file="luat-ini.mkiv"> + <cd:arguments> + <cd:csname/> + <cd:content/> + </cd:arguments> + </cd:command> + <cd:command name="ctxfunction" generated="yes" variant="example" level="system" category="lua" file="luat-ini.mkiv"> <cd:sequence> <cd:variable value="ctxfunction"/> </cd:sequence> </cd:command> + <cd:command name="installctxscanner" level="system" category="lua" file="luat-ini.mkiv"> + <cd:arguments> + <cd:csname/> + <cd:content/> + </cd:arguments> + </cd:command> + + <cd:command name="ctxscanner" generated="yes" variant="example" level="system" category="lua" file="luat-ini.mkiv"> + <cd:sequence> + <cd:variable value="ctxscanner"/> + </cd:sequence> + </cd:command> + + <cd:command name="installprotectedctxfunction" level="system" category="lua" file="luat-ini.mkiv"> + <cd:arguments> + <cd:csname/> + <cd:content/> + </cd:arguments> + </cd:command> + + <cd:command name="installprotectedctxscanner" level="system" category="lua" file="luat-ini.mkiv"> + <cd:arguments> + <cd:csname/> + <cd:content/> + </cd:arguments> + </cd:command> + + <cd:command name="resetctxscanner" level="system" category="lua" file="luat-ini.mkiv"> + <cd:arguments> + <cd:csname/> + </cd:arguments> + </cd:command> + </cd:interface> diff --git a/tex/context/interface/mkiv/i-marking.xml b/tex/context/interface/mkiv/i-marking.xml index 84273ee3b..8eb17f6ed 100644 --- a/tex/context/interface/mkiv/i-marking.xml +++ b/tex/context/interface/mkiv/i-marking.xml @@ -52,7 +52,10 @@ <cd:command name="resetmarking" level="system" category="structure" file="strc-mar.mkiv"> <cd:arguments> - <cd:resolve name="keyword-mark"/> + <cd:keywords> + <cd:constant type="all"/> + <cd:constant type="cd:mark"/> + </cd:keywords> </cd:arguments> </cd:command> diff --git a/tex/context/interface/mkiv/i-mathmatrix.xml b/tex/context/interface/mkiv/i-mathmatrix.xml index d22e8141f..3b8076407 100644 --- a/tex/context/interface/mkiv/i-mathmatrix.xml +++ b/tex/context/interface/mkiv/i-mathmatrix.xml @@ -70,13 +70,19 @@ </cd:instances> </cd:command> - <cd:command name="mathmatrix" generated="yes" level="document" category="mathematics" keywords="tables" file="math-ali.mkiv"> + <cd:command name="mathmatrix" generated="yes" variant="instance" level="document" category="mathematics" keywords="tables" file="math-ali.mkiv"> <cd:sequence> - <cd:variable value="mathmatrix"/> + <cd:instance value="mathmatrix"/> </cd:sequence> <cd:arguments> + <cd:assignments list="yes" optional="yes"> + <cd:inherit name="setupmathmatrix"/> + </cd:assignments> <cd:content/> </cd:arguments> + <cd:instances> + <cd:resolve name="instance-simplematrix"/> + </cd:instances> </cd:command> <cd:command name="matrices" type="environment" level="document" category="mathematics" keywords="tables" file="math-ali.mkiv"> diff --git a/tex/context/interface/mkiv/i-note.xml b/tex/context/interface/mkiv/i-note.xml index b76335765..bd1ebca24 100644 --- a/tex/context/interface/mkiv/i-note.xml +++ b/tex/context/interface/mkiv/i-note.xml @@ -672,7 +672,7 @@ </cd:arguments> </cd:command> - <cd:command name="textnote" generated="yes" level="document" category="structure" keywords="notes" file="strc-tnt.mkiv"> + <cd:command name="textnote" generated="yes" variant="example" level="document" category="structure" keywords="notes" file="strc-tnt.mkiv"> <cd:arguments> <cd:assignments list="yes" optional="yes"> <cd:inherit name="setuptextnote"/> diff --git a/tex/context/interface/mkiv/i-pagenumber.xml b/tex/context/interface/mkiv/i-pagenumber.xml index 47563984e..ae3f38cd3 100644 --- a/tex/context/interface/mkiv/i-pagenumber.xml +++ b/tex/context/interface/mkiv/i-pagenumber.xml @@ -102,6 +102,7 @@ <cd:constant type="inmargin"/> <cd:constant type="atmargin"/> <cd:constant type="marginedge"/> + <cd:constant type="none"/> </cd:parameter> <cd:parameter name="style"> <cd:resolve name="value-style"/> diff --git a/tex/context/interface/mkiv/i-parwrapper.xml b/tex/context/interface/mkiv/i-parwrapper.xml new file mode 100644 index 000000000..2cb5ee071 --- /dev/null +++ b/tex/context/interface/mkiv/i-parwrapper.xml @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?context-directive job ctxfile x-setups.ctx ?> + +<cd:interface xmlns:cd="http://www.pragma-ade.com/commands"> + + <cd:command name="freezeparagraphproperties" level="system" category="whitespace" file="spac-par.mkxl"/> + + <cd:command name="defrostparagraphproperties" level="system" category="whitespace" file="spac-par.mkxl"/> + + <cd:command name="updateparagraphproperties" level="system" category="whitespace" file="spac-par.mkxl"/> + + <cd:command name="updateparagraphpenalties" level="system" category="whitespace" file="spac-par.mkxl"/> + + <cd:command name="updateparagraphdemerits" level="system" category="whitespace" file="spac-par.mkxl"/> + + <cd:command name="updateparagraphshapes" level="system" category="whitespace" file="spac-par.mkxl"/> + + <cd:command name="setparagraphfreezing" level="system" category="whitespace" file="spac-par.mkxl"/> + + <cd:command name="forgetparagraphfreezing" level="system" category="whitespace" file="spac-par.mkxl"/> + + <cd:command name="registerparwrapper" level="system" category="whitespace" file="spac-par.mkxl"> + <cd:arguments> + <cd:resolve name="argument-name"/> + <cd:content/> + <cd:content/> + </cd:arguments> + </cd:command> + + <cd:command name="registerparwrapperreverse" level="system" category="whitespace" file="spac-par.mkxl"> + <cd:arguments> + <cd:resolve name="argument-name"/> + <cd:content/> + <cd:content/> + </cd:arguments> + </cd:command> + + <cd:command name="directparwrapper" level="system" category="whitespace" file="spac-par.mkxl"> + <cd:arguments> + <cd:content/> + <cd:content/> + </cd:arguments> + </cd:command> + + <cd:command name="forgetparwrapper" level="system" category="whitespace" file="spac-par.mkxl"/> + + <cd:command name="unregisterparwrapper" level="system" category="whitespace" file="spac-par.mkxl"> + <cd:arguments> + <cd:resolve name="argument-name"/> + </cd:arguments> + </cd:command> + + <cd:command name="doifelseparwrapper" level="system" category="whitespace" file="spac-par.mkxl"> + <cd:arguments> + <cd:resolve name="argument-name"/> + <cd:resolve name="argument-true"/> + <cd:resolve name="argument-false"/> + </cd:arguments> + </cd:command> + + <cd:command name="showparwrapperstate" level="system" category="whitespace" file="spac-par.mkxl"> + <cd:arguments> + <cd:resolve name="argument-name"/> + </cd:arguments> + </cd:command> + + <cd:command name="getparwrapper" level="system" category="whitespace" file="spac-par.lmt"> + <cd:arguments> + <cd:resolve name="argument-name"/> + </cd:arguments> + </cd:command> + + <cd:command name="lastparwrapper" level="system" category="whitespace" file="spac-par.lmt"> + <cd:arguments> + <cd:resolve name="argument-name"/> + </cd:arguments> + </cd:command> + +</cd:interface> diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 97b40da43..2e51059b1 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/context/interface/mkiv/i-replacement.xml b/tex/context/interface/mkiv/i-replacement.xml index 8e21c1f17..dec893bef 100644 --- a/tex/context/interface/mkiv/i-replacement.xml +++ b/tex/context/interface/mkiv/i-replacement.xml @@ -7,7 +7,7 @@ <cd:command name="replaceword" level="style" category="language" file="lang-rep.mkiv"> <cd:arguments> <cd:resolve name="keyword-name"/> - <cd:resolve name="keyword-text"/> + <cd:resolve name="keyword-text-optional"/> <cd:resolve name="keyword-text"/> </cd:arguments> </cd:command> @@ -18,6 +18,8 @@ <cd:constant type="reset"/> <cd:constant type="cd:name"/> </cd:keywords> + <!-- command is overloaded in typo-ovl.mkiv with second argument --> + <cd:resolve name="keyword-name-optional"/> </cd:arguments> </cd:command> diff --git a/tex/context/interface/mkiv/i-setup.xml b/tex/context/interface/mkiv/i-setup.xml index fcfed31bf..0cfb216bd 100644 --- a/tex/context/interface/mkiv/i-setup.xml +++ b/tex/context/interface/mkiv/i-setup.xml @@ -167,4 +167,10 @@ </cd:arguments> </cd:command> + <cd:command name="loadsetups" level="style" category="xml" file="x-setups-basics.mkiv"> + <cd:arguments> + <cd:resolve name="keyword-file-optional"/> + </cd:arguments> + </cd:command> + </cd:interface> diff --git a/tex/context/interface/mkiv/i-synonym.xml b/tex/context/interface/mkiv/i-synonym.xml index ca3053fe4..8bc9ed87e 100644 --- a/tex/context/interface/mkiv/i-synonym.xml +++ b/tex/context/interface/mkiv/i-synonym.xml @@ -91,6 +91,10 @@ <cd:parameter name="inbetween"> <cd:constant type="cd:command"/> </cd:parameter> + <cd:parameter name="hyphens"> + <cd:constant type="yes" default="yes"/> + <cd:constant type="no"/> + </cd:parameter> </cd:assignments> </cd:arguments> </cd:command> diff --git a/tex/context/interface/mkiv/i-system.xml b/tex/context/interface/mkiv/i-system.xml index 08a4a917d..72b51760d 100644 --- a/tex/context/interface/mkiv/i-system.xml +++ b/tex/context/interface/mkiv/i-system.xml @@ -1619,8 +1619,6 @@ </cd:arguments> </cd:command> - <cd:command name="texcode" type="environment" level="system" category="catcode" file="syst-aux.mkiv"/> - <cd:command name="newcounter" level="system" category="counter" file="syst-aux.mkiv"> <cd:arguments> <cd:csname/> @@ -1834,6 +1832,18 @@ </cd:arguments> </cd:command> + <cd:command name="validassignment" level="system" category="system" keywords="conditional" file="syst-aux.mkiv"> + <cd:arguments> + <cd:resolve name="argument-text"/> + </cd:arguments> + </cd:command> + + <cd:command name="nonvalidassignment" level="system" category="system" keywords="conditional" file="syst-aux.mkiv"> + <cd:arguments> + <cd:resolve name="argument-text"/> + </cd:arguments> + </cd:command> + <cd:command name="doifelseassignmentcs" level="system" category="system" keywords="conditional" file="syst-aux.mkiv"> <cd:arguments> <cd:resolve name="argument-text"/> diff --git a/tex/context/interface/mkiv/i-vspace.xml b/tex/context/interface/mkiv/i-vspace.xml index e79e4e736..653ae169e 100644 --- a/tex/context/interface/mkiv/i-vspace.xml +++ b/tex/context/interface/mkiv/i-vspace.xml @@ -106,6 +106,18 @@ </cd:arguments> </cd:command> + <cd:command name="doifoutervmode" level="document" category="whitespace" keywords="conditional" file="spac-ver.mkxl"> + <cd:arguments> + <cd:content/> + </cd:arguments> + </cd:command> + + <cd:command name="dosomebreak" level="document" category="whitespace" file="spac-ver.mkxl"> + <cd:arguments> + <cd:csname/> + </cd:arguments> + </cd:command> + <cd:command name="godown" level="document" category="whitespace" file="spac-ver.mkiv"> <cd:arguments> <cd:resolve name="keyword-dimension"/> diff --git a/tex/context/interface/mkiv/i-xml.xml b/tex/context/interface/mkiv/i-xml.xml index d911b58c5..5c63416d7 100644 --- a/tex/context/interface/mkiv/i-xml.xml +++ b/tex/context/interface/mkiv/i-xml.xml @@ -726,16 +726,7 @@ <cd:command name="xmlregisterns" level="style" category="xml" file="lxml-ini.mkiv"> <cd:arguments> <cd:resolve name="argument-name"/> - <cd:keywords delimiters="braces"> - <cd:constant type="cd:url"/> - </cd:keywords> - </cd:arguments> - </cd:command> - - <cd:command name="xmlregisterns" level="style" category="xml" file="lxml-ini.mkiv"> - <cd:arguments> - <cd:resolve name="argument-name"/> - <cd:resolve name="argument-name"/> + <cd:resolve name="argument-url"/> </cd:arguments> </cd:command> diff --git a/tex/context/modules/mkiv/m-chart.mkvi b/tex/context/modules/mkiv/m-chart.mkvi index e1ecd3f0c..4dee9c7ef 100644 --- a/tex/context/modules/mkiv/m-chart.mkvi +++ b/tex/context/modules/mkiv/m-chart.mkvi @@ -276,7 +276,7 @@ \let\location \FLOW_location \let\text \FLOW_text \let\label \FLOW_label - \let\comment \FLOW_comment + \overloaded\let\comment \FLOW_comment \let\exit \FLOW_exit \let\connection \FLOW_connection \let\include \FLOW_include diff --git a/tex/context/modules/mkiv/m-gnuplot.mkxl b/tex/context/modules/mkiv/m-gnuplot.mkxl index 2077b1741..e844edd1b 100644 --- a/tex/context/modules/mkiv/m-gnuplot.mkxl +++ b/tex/context/modules/mkiv/m-gnuplot.mkxl @@ -14,7 +14,7 @@ %D This is a variant on the \GNUPLOT\ terminal code. At some point (when there is a %D reason) I will make a proper environment that can be used for embedded code. -\unexpanded\def\includegnuplotsvgfile[#1]% +\permanent\protected\def\includegnuplotsvgfile[#1]% {\hbox\bgroup \ctxlua{metapost.startsvghashing()}% \includesvgfile[#1]% diff --git a/tex/context/modules/mkiv/m-timing.mkxl b/tex/context/modules/mkiv/m-timing.mkxl index 97f13a700..3edfd14e2 100644 --- a/tex/context/modules/mkiv/m-timing.mkxl +++ b/tex/context/modules/mkiv/m-timing.mkxl @@ -56,7 +56,7 @@ end \ctxlua{luatex.registerstopactions(function() moduledata.progress.save() end)} \stopnotmode -\unexpanded\def\ShowNamedUsage#1#2#3% +\permanent\protected\def\ShowNamedUsage#1#2#3% {\setbox\scratchbox\vbox\bgroup \startMPcode{doublefun} begingroup ; save p, q, b, h, w ; @@ -103,11 +103,11 @@ end \stoplinecorrection \fi} -\unexpanded\def\LoadUsage #1{\ctxlua{moduledata.progress.convert("#1")}} -\unexpanded\def\ShowUsage #1{\ctxlua{moduledata.progress.show("#1",".*", "variables: elapsed")}} -\unexpanded\def\ShowMemoryUsage #1{\ctxlua{moduledata.progress.show("#1","memory:.*","variables: elapsed")}} -\unexpanded\def\ShowNodeUsage #1{\ctxlua{moduledata.progress.show("#1","nodes:.*", "variables: elapsed")}} -\unexpanded\def\ShowFilteredUsage#1#2{\ctxlua{moduledata.progress.show("#1","#2", "variables: elapsed")}} -\unexpanded\def\ShowSimpleUsage #1#2{\ctxlua{moduledata.progress.show("#1","#2")}} +\permanent\protected\def\LoadUsage #1{\ctxlua{moduledata.progress.convert("#1")}} +\permanent\protected\def\ShowUsage #1{\ctxlua{moduledata.progress.show("#1",".*", "variables: elapsed")}} +\permanent\protected\def\ShowMemoryUsage #1{\ctxlua{moduledata.progress.show("#1","memory:.*","variables: elapsed")}} +\permanent\protected\def\ShowNodeUsage #1{\ctxlua{moduledata.progress.show("#1","nodes:.*", "variables: elapsed")}} +\permanent\protected\def\ShowFilteredUsage#1#2{\ctxlua{moduledata.progress.show("#1","#2", "variables: elapsed")}} +\permanent\protected\def\ShowSimpleUsage #1#2{\ctxlua{moduledata.progress.show("#1","#2")}} \endinput diff --git a/tex/context/modules/mkiv/s-system-macros.mkxl b/tex/context/modules/mkiv/s-system-macros.mkxl index 91aad763a..72fd3b7c2 100644 --- a/tex/context/modules/mkiv/s-system-macros.mkxl +++ b/tex/context/modules/mkiv/s-system-macros.mkxl @@ -22,7 +22,8 @@ \continueifinputfile{s-system-macros.mkxl} -\usemodule[article-basic] \setuplayout[tight] \setupbodyfont[7pt,tt] +% \usemodule[article-basic] \setuplayout[tight] \setupbodyfont[7pt,tt] +\usemodule[article-basic] \setuplayout[tight] \setupbodyfont[5pt,tt] \setuppapersize [A4,landscape] @@ -97,22 +98,27 @@ local k = list[i] if check(k) then local v = create(k) + local mutable = v.mutable and "mutable" + local immutable = v.immutable and "immutable" local frozen = v.frozen and "frozen" local permanent = v.permanent and "permanent" - local immutable = v.immutable and "immutable" local primitive = v.primitive and "primitive" - local mutable = v.mutable and "mutable" - local noaligned = v.noaligned and "noaligned" local instance = v.instance and "instance" + local dealtwith = mutable or immutable or frozen or permanent or primitive -- beware: we can have combinations + local whatever = find(k,"^[a-z][a-z][a-z]+_") + local cscommand = gsub(v.cmdname or "","_"," ") + local undefined = cscommand == "undefined cs" + local marked = (dealtwith and "+") or (whatever and "-") or (instance and "!") +--if not marked then +if not marked and not find(k,"^[pvm]_") and not find(k,"^![tT]") then local parameters = v.parameters - local dealtwith = mutable or immutable or frozen or permanent or primitive -- beware: we can have combinations - local cscommand = gsub(v.cmdname or "","_"," ") - local whatever = find(k,"^[a-z][a-z][a-z]+_") - local filename = files[k] - local csname = context.escape(k) - ctx_NC() if dealtwith then context("+") - elseif whatever then context("-") - elseif instance then context("!") end + local noaligned = v.noaligned and "noaligned" + local filename = files[k] + local csname = context.escape(k) + if undefined then + marked = "?" + end + ctx_NC() if marked then context(marked) end ctx_NC() if primitive then ctx_bold(csname) else context(csname) end ctx_NC() if parameters then context(parameters > 0 and parameters or "-") end @@ -126,6 +132,7 @@ ctx_NC() if noaligned then context(noaligned) end ctx_NC() if filename then context(hashnames[filename]) end ctx_NC() ctx_NR() +end if visible then total = total + 1 if dealtwith then diff --git a/tex/context/modules/mkiv/s-system-tokens.mkxl b/tex/context/modules/mkiv/s-system-tokens.mkxl index 3b32b0627..b83a4f47b 100644 --- a/tex/context/modules/mkiv/s-system-tokens.mkxl +++ b/tex/context/modules/mkiv/s-system-tokens.mkxl @@ -15,8 +15,7 @@ \registerctxluafile{s-system-tokens}{} -\unexpanded\def\showsystemtokens - {\ctxlua{moduledata.system.tokens.showlist()}} +\permanent\protected\def\showsystemtokens{\ctxlua{moduledata.system.tokens.showlist()}} % can be public implementor \stopmodule diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 92109f0ce..38dcce9aa 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 2020-11-19 11:23 +-- merge date : 2020-11-23 18:34 do -- begin closure to overcome local limits and interference |