From 69d2352af4b60929b37fc49f3bdb263977016244 Mon Sep 17 00:00:00 2001 From: Marius Date: Fri, 19 Oct 2012 01:20:13 +0300 Subject: stable 2012.05.30 11:26 --- tex/context/base/anch-bar.mkiv | 150 +- tex/context/base/anch-bck.mkvi | 14 +- tex/context/base/anch-pgr.lua | 248 +- tex/context/base/anch-pgr.mkiv | 120 +- tex/context/base/anch-pos.lua | 18 +- tex/context/base/anch-pos.mkiv | 8 +- tex/context/base/anch-tab.mkiv | 186 +- tex/context/base/attr-col.lua | 71 +- tex/context/base/attr-eff.lua | 39 +- tex/context/base/attr-eff.mkiv | 43 +- tex/context/base/attr-ini.lua | 36 +- tex/context/base/attr-ini.mkiv | 12 +- tex/context/base/attr-lay.lua | 98 +- tex/context/base/attr-lay.mkiv | 82 +- tex/context/base/attr-neg.lua | 5 +- tex/context/base/attr-neg.mkiv | 10 +- tex/context/base/back-exp.lua | 24 +- tex/context/base/back-exp.mkiv | 26 +- tex/context/base/back-ini.lua | 4 +- tex/context/base/back-ini.mkiv | 6 +- tex/context/base/back-pdf.mkiv | 28 +- tex/context/base/back-swf.mkiv | 14 +- tex/context/base/back-u3d.mkiv | 7 +- tex/context/base/bibl-bib.mkiv | 2 +- tex/context/base/bibl-tra.lua | 4 +- tex/context/base/bibl-tra.mkiv | 25 +- tex/context/base/blob-ini.lua | 2 +- tex/context/base/buff-ini.lua | 39 +- tex/context/base/buff-ini.mkiv | 24 - tex/context/base/buff-par.lua | 27 +- tex/context/base/buff-par.mkiv | 151 + tex/context/base/buff-par.mkvi | 131 - tex/context/base/buff-ver.lua | 6 +- tex/context/base/buff-ver.mkiv | 30 +- tex/context/base/catc-ctx.mkiv | 11 +- tex/context/base/catc-def.mkiv | 7 +- tex/context/base/catc-ini.lua | 21 +- tex/context/base/catc-ini.mkiv | 64 +- tex/context/base/char-cjk.lua | 23 +- tex/context/base/char-def.lua | 80 +- tex/context/base/char-enc.lua | 41 +- tex/context/base/char-ent.lua | 5 +- tex/context/base/char-ini.lua | 86 +- tex/context/base/char-map.lua | 3 +- tex/context/base/char-utf.lua | 21 +- tex/context/base/chem-ini.lua | 8 +- tex/context/base/chem-str.lua | 134 +- tex/context/base/chem-str.mkiv | 216 +- tex/context/base/cldf-bas.lua | 52 +- tex/context/base/cldf-com.lua | 4 +- tex/context/base/cldf-ini.lua | 26 +- tex/context/base/cldf-int.lua | 11 +- tex/context/base/cldf-ver.lua | 6 +- tex/context/base/colo-ext.mkiv | 10 +- tex/context/base/colo-icc.lua | 2 +- tex/context/base/colo-ini.lua | 124 +- tex/context/base/colo-ini.mkiv | 34 +- tex/context/base/colo-run.lua | 6 +- tex/context/base/colo-run.mkiv | 28 +- tex/context/base/cont-log.mkiv | 10 +- tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 497 +- tex/context/base/cont-nop.mkiv | 22 - tex/context/base/cont-yes.mkiv | 80 - tex/context/base/context-base.lmx | 4 +- tex/context/base/context-help.lmx | 1 - tex/context/base/context-version.pdf | Bin 4141 -> 4128 bytes tex/context/base/context-version.png | Bin 106781 -> 105721 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 57 +- tex/context/base/context.rme | 7 +- tex/context/base/context.todo | 6 + tex/context/base/core-con.lua | 153 +- tex/context/base/core-con.mkiv | 177 +- tex/context/base/core-ctx.ctx | 23 - tex/context/base/core-ctx.lua | 331 +- tex/context/base/core-ctx.mkiv | 18 +- tex/context/base/core-dat.lua | 60 +- tex/context/base/core-def.mkiv | 126 +- tex/context/base/core-env.lua | 7 +- tex/context/base/core-env.mkiv | 115 +- tex/context/base/core-fnt.mkiv | 158 + tex/context/base/core-ini.mkiv | 228 +- tex/context/base/core-mis.mkiv | 738 ++ tex/context/base/core-sys.lua | 90 +- tex/context/base/core-sys.mkiv | 80 +- tex/context/base/core-two.lua | 2 +- tex/context/base/core-uti.lua | 22 +- tex/context/base/core-var.mkiv | 239 + tex/context/base/data-env.lua | 6 +- tex/context/base/data-exp.lua | 8 +- tex/context/base/data-ini.lua | 2 +- tex/context/base/data-lua.lua | 263 +- tex/context/base/data-pre.lua | 44 +- tex/context/base/data-res.lua | 59 +- tex/context/base/data-sch.lua | 68 +- tex/context/base/data-tex.lua | 7 - tex/context/base/data-vir.lua | 8 +- tex/context/base/data-zip.lua | 16 +- tex/context/base/enco-ini.mkiv | 111 +- tex/context/base/file-ini.lua | 5 +- tex/context/base/file-ini.mkvi | 20 +- tex/context/base/file-job.lua | 348 +- tex/context/base/file-job.mkvi | 25 +- tex/context/base/file-lib.lua | 7 +- tex/context/base/file-mod.lua | 16 +- tex/context/base/file-res.lua | 6 +- tex/context/base/file-syn.lua | 7 +- tex/context/base/font-afk.lua | 200 - tex/context/base/font-afm.lua | 372 +- tex/context/base/font-age.lua | 1 - tex/context/base/font-agl.lua | 2 +- tex/context/base/font-aux.lua | 2 +- tex/context/base/font-aux.mkvi | 26 - tex/context/base/font-chk.lua | 2 +- tex/context/base/font-chk.mkiv | 22 - tex/context/base/font-cid.lua | 17 +- tex/context/base/font-col.lua | 96 +- tex/context/base/font-con.lua | 30 +- tex/context/base/font-ctx.lua | 272 +- tex/context/base/font-def.lua | 23 +- tex/context/base/font-ext.lua | 38 +- tex/context/base/font-fbk.lua | 23 +- tex/context/base/font-gds.lua | 59 +- tex/context/base/font-gds.mkiv | 83 + tex/context/base/font-gds.mkvi | 83 - tex/context/base/font-ini.lua | 24 +- tex/context/base/font-ldr.lua | 4 +- tex/context/base/font-lib.mkvi | 4 +- tex/context/base/font-map.lua | 12 +- tex/context/base/font-mat.mkvi | 1 - tex/context/base/font-mis.lua | 2 +- tex/context/base/font-ota.lua | 83 +- tex/context/base/font-otb.lua | 37 +- tex/context/base/font-otc.lua | 3 +- tex/context/base/font-otd.lua | 31 +- tex/context/base/font-otf.lua | 96 +- tex/context/base/font-oti.lua | 13 +- tex/context/base/font-otn.lua | 338 +- tex/context/base/font-otp.lua | 53 +- tex/context/base/font-ott.lua | 171 +- tex/context/base/font-pat.lua | 14 +- tex/context/base/font-pre.mkiv | 30 +- tex/context/base/font-run.mkiv | 47 +- tex/context/base/font-set.mkvi | 2 +- tex/context/base/font-sol.lua | 898 --- tex/context/base/font-sol.mkvi | 123 - tex/context/base/font-sty.mkvi | 42 +- tex/context/base/font-syn.lua | 11 +- tex/context/base/font-tfm.lua | 15 +- tex/context/base/font-tra.mkiv | 46 +- tex/context/base/font-vf.lua | 3 +- tex/context/base/grph-epd.lua | 1 + tex/context/base/grph-epd.mkiv | 12 +- tex/context/base/grph-fig.mkiv | 729 +- tex/context/base/grph-fil.lua | 11 +- tex/context/base/grph-inc.lua | 100 +- tex/context/base/grph-inc.mkiv | 895 +-- tex/context/base/grph-raw.lua | 5 +- tex/context/base/grph-raw.mkiv | 14 +- tex/context/base/grph-swf.lua | 15 +- tex/context/base/grph-trf.mkiv | 492 +- tex/context/base/grph-u3d.lua | 8 +- tex/context/base/java-ini.lua | 37 +- tex/context/base/l-boolean.lua | 45 +- tex/context/base/l-dir.lua | 18 - tex/context/base/l-file.lua | 36 +- tex/context/base/l-io.lua | 47 +- tex/context/base/l-lpeg.lua | 228 +- tex/context/base/l-md5.lua | 33 +- tex/context/base/l-number.lua | 10 +- tex/context/base/l-os.lua | 67 +- tex/context/base/l-string.lua | 17 - tex/context/base/l-table.lua | 131 +- tex/context/base/l-unicode.lua | 356 +- tex/context/base/l-url.lua | 124 +- tex/context/base/lang-def.lua | 47 +- tex/context/base/lang-def.mkiv | 34 +- tex/context/base/lang-frd.mkiv | 141 - tex/context/base/lang-frq.mkiv | 233 - tex/context/base/lang-ini.lua | 91 +- tex/context/base/lang-ini.mkiv | 31 +- tex/context/base/lang-lab.lua | 67 +- tex/context/base/lang-lab.mkiv | 70 +- tex/context/base/lang-mis.mkiv | 31 - tex/context/base/lang-txt.lua | 183 +- tex/context/base/lang-url.lua | 7 +- tex/context/base/lang-wrd.lua | 97 +- tex/context/base/lpdf-ano.lua | 6 +- tex/context/base/lpdf-col.lua | 8 +- tex/context/base/lpdf-epa.lua | 6 +- tex/context/base/lpdf-epd.lua | 24 +- tex/context/base/lpdf-fmt.lua | 40 +- tex/context/base/lpdf-nod.lua | 71 +- tex/context/base/lpdf-ren.lua | 120 +- tex/context/base/lpdf-u3d.lua | 2 +- tex/context/base/luat-bwc.lua | 2 +- tex/context/base/luat-cbk.lua | 29 +- tex/context/base/luat-cnf.lua | 7 +- tex/context/base/luat-cod.lua | 28 +- tex/context/base/luat-cod.mkiv | 6 + tex/context/base/luat-env.lua | 44 +- tex/context/base/luat-fmt.lua | 1 + tex/context/base/luat-ini.lua | 44 +- tex/context/base/luat-ini.mkiv | 8 +- tex/context/base/luat-lib.mkiv | 5 - tex/context/base/luat-mac.lua | 92 +- tex/context/base/luat-run.lua | 12 +- tex/context/base/luat-soc.lua | 16 +- tex/context/base/luat-sto.lua | 32 +- tex/context/base/lxml-css.lua | 48 +- tex/context/base/lxml-ctx.mkiv | 3 + tex/context/base/lxml-ini.mkiv | 4 +- tex/context/base/lxml-lpt.lua | 51 +- tex/context/base/lxml-tab.lua | 42 +- tex/context/base/lxml-tex.lua | 25 +- tex/context/base/m-barcodes.mkiv | 8 +- tex/context/base/m-chart.lua | 159 +- tex/context/base/m-chart.mkii | 2 +- tex/context/base/m-chart.mkvi | 154 +- tex/context/base/m-database.mkiv | 7 +- tex/context/base/m-graph.mkiv | 124 +- tex/context/base/m-ipsum.mkiv | 198 - tex/context/base/m-json.mkiv | 30 - tex/context/base/m-morse.mkvi | 12 +- tex/context/base/m-oldfun.mkiv | 714 -- tex/context/base/m-oldnum.mkiv | 416 -- tex/context/base/m-pstricks.lua | 8 +- tex/context/base/m-spreadsheet.lua | 331 - tex/context/base/m-spreadsheet.mkiv | 295 +- tex/context/base/m-timing.mkiv | 10 +- tex/context/base/m-translate.mkiv | 27 +- tex/context/base/m-visual.mkiv | 581 +- tex/context/base/math-act.lua | 2 - tex/context/base/math-ali.mkiv | 101 +- tex/context/base/math-arr.mkiv | 405 +- tex/context/base/math-def.mkiv | 10 +- tex/context/base/math-dim.lua | 6 +- tex/context/base/math-ext.lua | 5 +- tex/context/base/math-fbk.lua | 281 - tex/context/base/math-for.mkiv | 15 + tex/context/base/math-ini.lua | 141 +- tex/context/base/math-ini.mkiv | 41 +- tex/context/base/math-int.mkiv | 15 +- tex/context/base/math-noa.lua | 219 +- tex/context/base/math-ttv.lua | 799 --- tex/context/base/math-vfu.lua | 785 ++- tex/context/base/meta-grd.mkiv | 116 - tex/context/base/meta-imp-dum.mkiv | 123 +- tex/context/base/meta-ini.lua | 2 - tex/context/base/meta-ini.mkiv | 67 +- tex/context/base/meta-pag.mkiv | 10 +- tex/context/base/meta-pdf.lua | 7 +- tex/context/base/meta-pdh.mkiv | 2 +- tex/context/base/meta-tex.lua | 2 +- tex/context/base/mlib-ctx.lua | 2 - tex/context/base/mlib-pdf.lua | 93 +- tex/context/base/mlib-pdf.mkiv | 6 +- tex/context/base/mlib-pps.mkiv | 16 +- tex/context/base/mlib-run.lua | 261 +- tex/context/base/mult-aux.lua | 2 +- tex/context/base/mult-aux.mkiv | 180 +- tex/context/base/mult-chk.lua | 5 +- tex/context/base/mult-chk.mkiv | 14 +- tex/context/base/mult-de.mkii | 8 - tex/context/base/mult-def.lua | 45 +- tex/context/base/mult-def.mkiv | 76 +- tex/context/base/mult-dim.mkvi | 1 - tex/context/base/mult-en.mkii | 8 - tex/context/base/mult-fr.mkii | 8 - tex/context/base/mult-fun.lua | 95 - tex/context/base/mult-ini.lua | 122 +- tex/context/base/mult-ini.mkiv | 72 +- tex/context/base/mult-it.mkii | 8 - tex/context/base/mult-low.lua | 50 +- tex/context/base/mult-mes.lua | 3 +- tex/context/base/mult-nl.mkii | 8 - tex/context/base/mult-pe.mkii | 8 - tex/context/base/mult-prm.mkiv | 15 - tex/context/base/mult-ro.mkii | 8 - tex/context/base/mult-sys.mkiv | 566 +- tex/context/base/node-aux.lua | 44 +- tex/context/base/node-dir.lua | 2 +- tex/context/base/node-fin.lua | 591 +- tex/context/base/node-ini.lua | 42 +- tex/context/base/node-inj.lua | 31 +- tex/context/base/node-par.lua | 118 + tex/context/base/node-par.mkiv | 82 + tex/context/base/node-ref.lua | 11 +- tex/context/base/node-res.lua | 19 +- tex/context/base/node-rul.lua | 32 +- tex/context/base/node-rul.mkiv | 40 +- tex/context/base/node-ser.lua | 27 +- tex/context/base/node-spl.lua | 619 ++ tex/context/base/node-spl.mkiv | 114 + tex/context/base/node-tra.lua | 90 +- tex/context/base/node-tsk.lua | 4 +- tex/context/base/node-typ.lua | 9 +- tex/context/base/norm-ctx.mkiv | 8 +- tex/context/base/pack-bar.mkiv | 97 +- tex/context/base/pack-bck.mkvi | 2 +- tex/context/base/pack-box.mkiv | 881 +-- tex/context/base/pack-com.mkiv | 14 +- tex/context/base/pack-cut.mkiv | 163 - tex/context/base/pack-mrl.mkiv | 920 +-- tex/context/base/pack-obj.lua | 25 +- tex/context/base/pack-obj.mkiv | 143 +- tex/context/base/pack-pos.mkiv | 189 +- tex/context/base/pack-rul.mkiv | 1021 +-- tex/context/base/page-app.mkiv | 9 +- tex/context/base/page-bck.mkiv | 394 +- tex/context/base/page-brk.mkiv | 14 +- tex/context/base/page-col.mkiv | 245 +- tex/context/base/page-com.mkiv | 176 +- tex/context/base/page-fac.mkiv | 48 +- tex/context/base/page-flt.lua | 14 +- tex/context/base/page-flt.mkiv | 214 +- tex/context/base/page-flw.mkiv | 186 +- tex/context/base/page-grd.mkiv | 6 +- tex/context/base/page-imp.mkiv | 3 +- tex/context/base/page-inf.mkiv | 6 +- tex/context/base/page-ini.mkiv | 46 +- tex/context/base/page-ins.lua | 97 - tex/context/base/page-ins.mkiv | 197 +- tex/context/base/page-lay.mkiv | 77 +- tex/context/base/page-lin.lua | 9 - tex/context/base/page-lin.mkiv | 597 +- tex/context/base/page-mak.mkvi | 33 +- tex/context/base/page-mbk.mkvi | 4 +- tex/context/base/page-mis.lua | 77 + tex/context/base/page-mis.mkiv | 95 + tex/context/base/page-mix.lua | 642 -- tex/context/base/page-mix.mkiv | 771 -- tex/context/base/page-mul.mkiv | 2253 +++--- tex/context/base/page-not.mkiv | 20 +- tex/context/base/page-one.mkiv | 259 +- tex/context/base/page-otr.mkvi | 4 +- tex/context/base/page-par.mkiv | 88 +- tex/context/base/page-plg.mkiv | 110 +- tex/context/base/page-pst.lua | 78 - tex/context/base/page-pst.mkiv | 102 - tex/context/base/page-run.mkiv | 8 +- tex/context/base/page-sel.mkiv | 347 + tex/context/base/page-sel.mkvi | 368 - tex/context/base/page-set.mkiv | 598 +- tex/context/base/page-sid.mkiv | 60 +- tex/context/base/page-spr.mkiv | 90 +- tex/context/base/page-str.mkiv | 39 +- tex/context/base/page-txt.mkvi | 112 +- tex/context/base/phys-dim.lua | 66 +- tex/context/base/phys-dim.mkiv | 19 +- tex/context/base/ppchtex.mkiv | 18 +- tex/context/base/prop-ini.mkiv | 2 +- tex/context/base/regi-ini.lua | 72 +- tex/context/base/s-abr-01.tex | 554 +- tex/context/base/s-art-01.mkiv | 4 - tex/context/base/s-def-01.mkiv | 2 +- tex/context/base/s-fnt-10.mkiv | 2 +- tex/context/base/s-fnt-20.mkiv | 10 +- tex/context/base/s-fnt-28.mkiv | 2 +- tex/context/base/s-fnt-29.mkiv | 2 +- tex/context/base/s-fnt-32.mkiv | 2 +- tex/context/base/s-inf-01.mkvi | 2 +- tex/context/base/s-inf-03.mkiv | 117 +- tex/context/base/s-lan-04.mkiv | 2 +- tex/context/base/s-mod.ctx | 1 + tex/context/base/s-pre-60.mkiv | 134 +- tex/context/base/s-pre-61.tex | 2 +- tex/context/base/s-pre-62.tex | 2 +- tex/context/base/s-pre-63.tex | 1 - tex/context/base/s-pre-67.tex | 2 +- tex/context/base/s-pre-69.mkiv | 2 +- tex/context/base/scrn-fld.lua | 6 +- tex/context/base/scrn-fld.mkvi | 10 +- tex/context/base/scrn-ini.lua | 2 +- tex/context/base/scrn-ini.mkvi | 14 +- tex/context/base/scrn-pag.mkvi | 6 + tex/context/base/scrn-ref.lua | 2 +- tex/context/base/scrn-wid.lua | 12 +- tex/context/base/scrn-wid.mkvi | 125 +- tex/context/base/scrp-cjk.lua | 3 - tex/context/base/scrp-ini.lua | 276 +- tex/context/base/sort-ini.lua | 2 +- tex/context/base/sort-lan.lua | 20 +- tex/context/base/spac-ali.lua | 6 +- tex/context/base/spac-ali.mkiv | 52 +- tex/context/base/spac-cha.mkiv | 191 - tex/context/base/spac-def.mkiv | 116 +- tex/context/base/spac-grd.mkiv | 61 +- tex/context/base/spac-hor.mkiv | 137 +- tex/context/base/spac-par.mkiv | 7 - tex/context/base/spac-ver.lua | 62 +- tex/context/base/spac-ver.mkiv | 299 +- tex/context/base/status-files.pdf | Bin 24604 -> 24413 bytes tex/context/base/status-lua.pdf | Bin 195628 -> 180149 bytes tex/context/base/status-mkiv.lua | 7384 ++++---------------- tex/context/base/status-mkiv.tex | 308 +- tex/context/base/strc-bkm.mkiv | 150 +- tex/context/base/strc-blk.lua | 7 +- tex/context/base/strc-blk.mkiv | 96 +- tex/context/base/strc-con.mkvi | 197 +- tex/context/base/strc-def.mkiv | 59 +- tex/context/base/strc-des.mkii | 2 +- tex/context/base/strc-des.mkvi | 52 +- tex/context/base/strc-doc.lua | 48 +- tex/context/base/strc-doc.mkiv | 234 +- tex/context/base/strc-enu.mkvi | 69 +- tex/context/base/strc-flt.mkvi | 1060 ++- tex/context/base/strc-ind.mkiv | 12 +- tex/context/base/strc-ini.lua | 25 +- tex/context/base/strc-itm.mkvi | 89 +- tex/context/base/strc-lab.mkiv | 239 +- tex/context/base/strc-lnt.mkvi | 127 +- tex/context/base/strc-lst.lua | 3 +- tex/context/base/strc-lst.mkvi | 31 +- tex/context/base/strc-mar.lua | 11 +- tex/context/base/strc-mat.mkiv | 487 +- tex/context/base/strc-not.lua | 180 +- tex/context/base/strc-not.mkvi | 627 +- tex/context/base/strc-num.lua | 207 +- tex/context/base/strc-num.mkiv | 62 +- tex/context/base/strc-pag.lua | 12 - tex/context/base/strc-pag.mkiv | 193 +- tex/context/base/strc-ref.lua | 127 +- tex/context/base/strc-ref.mkvi | 346 +- tex/context/base/strc-reg.lua | 11 +- tex/context/base/strc-reg.mkiv | 454 +- tex/context/base/strc-ren.mkiv | 866 +-- tex/context/base/strc-sbe.mkiv | 102 +- tex/context/base/strc-sec.mkiv | 828 +-- tex/context/base/strc-syn.lua | 2 +- tex/context/base/strc-syn.mkiv | 4 +- tex/context/base/strc-tag.lua | 1 - tex/context/base/strc-tag.mkiv | 9 - tex/context/base/supp-ali.mkiv | 173 + tex/context/base/supp-box.lua | 12 +- tex/context/base/supp-box.mkiv | 68 +- tex/context/base/supp-fun.mkiv | 716 ++ tex/context/base/supp-mat.mkiv | 143 +- tex/context/base/supp-num.mkiv | 416 ++ tex/context/base/supp-ran.lua | 28 +- tex/context/base/supp-ran.mkiv | 4 +- tex/context/base/supp-vis.mkiv | 185 +- tex/context/base/symb-run.mkiv | 8 +- tex/context/base/syst-aux.lua | 33 +- tex/context/base/syst-aux.mkiv | 3650 +++++----- tex/context/base/syst-fnt.mkiv | 2 +- tex/context/base/syst-gen.mkii | 5 - tex/context/base/syst-ini.mkiv | 338 +- tex/context/base/syst-lua.lua | 52 +- tex/context/base/syst-lua.mkiv | 7 - tex/context/base/tabl-ltb.mkiv | 8 +- tex/context/base/tabl-mis.mkiv | 288 - tex/context/base/tabl-ntb.mkiv | 1912 +++-- tex/context/base/tabl-nte.mkiv | 67 +- tex/context/base/tabl-pln.mkiv | 155 +- tex/context/base/tabl-tab.mkiv | 174 +- tex/context/base/tabl-tbl.lua | 6 +- tex/context/base/tabl-tbl.mkiv | 129 +- tex/context/base/tabl-tsp.mkiv | 470 +- tex/context/base/tabl-xnt.mkvi | 2 +- tex/context/base/tabl-xtb.lua | 5 +- tex/context/base/tabl-xtb.mkvi | 108 +- tex/context/base/task-ini.lua | 9 +- tex/context/base/trac-ctx.lua | 36 - tex/context/base/trac-ctx.mkiv | 28 - tex/context/base/trac-deb.lua | 13 +- tex/context/base/trac-deb.mkiv | 6 +- tex/context/base/trac-fil.lua | 214 +- tex/context/base/trac-inf.lua | 4 +- tex/context/base/trac-lmx.lua | 606 +- tex/context/base/trac-set.lua | 36 +- tex/context/base/trac-tex.lua | 2 +- tex/context/base/trac-tim.lua | 2 +- tex/context/base/trac-vis.lua | 859 --- tex/context/base/trac-vis.mkiv | 810 ++- tex/context/base/type-imp-husayni.mkiv | 290 +- tex/context/base/type-ini.lua | 17 +- tex/context/base/type-ini.mkvi | 14 +- tex/context/base/typo-bld.lua | 186 - tex/context/base/typo-bld.mkiv | 64 - tex/context/base/typo-brk.lua | 17 +- tex/context/base/typo-brk.mkiv | 18 +- tex/context/base/typo-cap.mkiv | 25 +- tex/context/base/typo-del.mkiv | 31 +- tex/context/base/typo-dir.lua | 10 +- tex/context/base/typo-itm.mkiv | 273 - tex/context/base/typo-krn.lua | 51 +- tex/context/base/typo-krn.mkiv | 57 +- tex/context/base/typo-mar.lua | 89 +- tex/context/base/typo-mar.mkiv | 7 +- tex/context/base/typo-scr.mkiv | 250 +- tex/context/base/typo-spa.mkiv | 17 +- tex/context/base/typo-txt.mkvi | 174 +- tex/context/base/unic-ini.mkiv | 2 +- tex/context/base/util-deb.lua | 3 +- tex/context/base/util-dim.lua | 18 +- tex/context/base/util-jsn.lua | 145 - tex/context/base/util-lua.lua | 213 +- tex/context/base/util-mrg.lua | 9 +- tex/context/base/util-prs.lua | 73 +- tex/context/base/util-sql-imp-client.lua | 253 - tex/context/base/util-sql-imp-library.lua | 283 - tex/context/base/util-sql-imp-swiglib.lua | 426 -- tex/context/base/util-sql-loggers.lua | 277 - tex/context/base/util-sql-sessions.lua | 349 - tex/context/base/util-sql-tickets.lua | 698 -- tex/context/base/util-sql-users.lua | 417 -- tex/context/base/util-sql.lua | 425 -- tex/context/base/util-sta.lua | 342 - tex/context/base/util-str.lua | 7 +- tex/context/base/util-tab.lua | 120 +- tex/context/base/util-tpl.lua | 117 - tex/context/base/x-asciimath.mkiv | 2 +- tex/context/base/x-chemml.lua | 2 +- tex/context/base/x-chemml.mkiv | 22 +- tex/context/base/x-dir-05.mkiv | 4 +- tex/context/base/x-mathml.lua | 24 +- tex/context/base/x-mathml.mkiv | 2366 +++++++ tex/context/base/x-udhr.mkiv | 2 +- tex/context/base/x-xfdf.mkiv | 72 - tex/context/base/xtag-ini.mkii | 50 +- tex/context/base/xtag-pre.mkii | 13 - tex/context/fonts/demo.lfg | 29 +- tex/context/fonts/husayni.lfg | 6 +- tex/context/interface/keys-cs.xml | 8 - tex/context/interface/keys-de.xml | 8 - tex/context/interface/keys-en.xml | 8 - tex/context/interface/keys-fr.xml | 8 - tex/context/interface/keys-it.xml | 8 - tex/context/interface/keys-nl.xml | 8 - tex/context/interface/keys-pe.xml | 8 - tex/context/interface/keys-ro.xml | 8 - tex/context/sample/lorem.tex | 11 - tex/context/test/pdf-x1a-2001.mkiv | 2 +- tex/context/test/pdf-x1a-2003.mkiv | 2 +- tex/context/test/pdf-x3-2002.mkiv | 2 +- tex/context/test/pdf-x3-2003.mkiv | 2 +- tex/context/test/pdf-x4.mkiv | 2 +- tex/context/test/pdf-x4p.mkiv | 4 +- tex/generic/context/luatex/luatex-basics-gen.lua | 4 +- tex/generic/context/luatex/luatex-fonts-ext.lua | 16 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 1936 +++-- tex/generic/context/luatex/luatex-fonts.lua | 2 +- tex/generic/context/luatex/luatex-mplib.tex | 11 +- 545 files changed, 29632 insertions(+), 47155 deletions(-) create mode 100644 tex/context/base/buff-par.mkiv delete mode 100644 tex/context/base/buff-par.mkvi delete mode 100644 tex/context/base/cont-nop.mkiv delete mode 100644 tex/context/base/cont-yes.mkiv create mode 100644 tex/context/base/context.todo delete mode 100644 tex/context/base/core-ctx.ctx create mode 100644 tex/context/base/core-fnt.mkiv create mode 100644 tex/context/base/core-mis.mkiv create mode 100644 tex/context/base/core-var.mkiv delete mode 100644 tex/context/base/font-afk.lua delete mode 100644 tex/context/base/font-aux.mkvi delete mode 100644 tex/context/base/font-chk.mkiv create mode 100644 tex/context/base/font-gds.mkiv delete mode 100644 tex/context/base/font-gds.mkvi delete mode 100644 tex/context/base/font-sol.lua delete mode 100644 tex/context/base/font-sol.mkvi delete mode 100644 tex/context/base/lang-frd.mkiv delete mode 100644 tex/context/base/lang-frq.mkiv delete mode 100644 tex/context/base/m-ipsum.mkiv delete mode 100644 tex/context/base/m-json.mkiv delete mode 100644 tex/context/base/m-oldfun.mkiv delete mode 100644 tex/context/base/m-oldnum.mkiv delete mode 100644 tex/context/base/m-spreadsheet.lua delete mode 100644 tex/context/base/math-fbk.lua delete mode 100644 tex/context/base/math-ttv.lua delete mode 100644 tex/context/base/meta-grd.mkiv delete mode 100644 tex/context/base/mult-fun.lua create mode 100644 tex/context/base/node-par.lua create mode 100644 tex/context/base/node-par.mkiv create mode 100644 tex/context/base/node-spl.lua create mode 100644 tex/context/base/node-spl.mkiv delete mode 100644 tex/context/base/pack-cut.mkiv delete mode 100644 tex/context/base/page-ins.lua create mode 100644 tex/context/base/page-mis.lua create mode 100644 tex/context/base/page-mis.mkiv delete mode 100644 tex/context/base/page-mix.lua delete mode 100644 tex/context/base/page-mix.mkiv delete mode 100644 tex/context/base/page-pst.lua delete mode 100644 tex/context/base/page-pst.mkiv create mode 100644 tex/context/base/page-sel.mkiv delete mode 100644 tex/context/base/page-sel.mkvi delete mode 100644 tex/context/base/spac-cha.mkiv create mode 100644 tex/context/base/supp-ali.mkiv create mode 100644 tex/context/base/supp-fun.mkiv create mode 100644 tex/context/base/supp-num.mkiv delete mode 100644 tex/context/base/tabl-mis.mkiv delete mode 100644 tex/context/base/trac-ctx.lua delete mode 100644 tex/context/base/trac-ctx.mkiv delete mode 100644 tex/context/base/trac-vis.lua delete mode 100644 tex/context/base/typo-bld.lua delete mode 100644 tex/context/base/typo-bld.mkiv delete mode 100644 tex/context/base/typo-itm.mkiv delete mode 100644 tex/context/base/util-jsn.lua delete mode 100644 tex/context/base/util-sql-imp-client.lua delete mode 100644 tex/context/base/util-sql-imp-library.lua delete mode 100644 tex/context/base/util-sql-imp-swiglib.lua delete mode 100644 tex/context/base/util-sql-loggers.lua delete mode 100644 tex/context/base/util-sql-sessions.lua delete mode 100644 tex/context/base/util-sql-tickets.lua delete mode 100644 tex/context/base/util-sql-users.lua delete mode 100644 tex/context/base/util-sql.lua delete mode 100644 tex/context/base/util-sta.lua delete mode 100644 tex/context/base/util-tpl.lua create mode 100644 tex/context/base/x-mathml.mkiv delete mode 100644 tex/context/base/x-xfdf.mkiv delete mode 100644 tex/context/sample/lorem.tex (limited to 'tex') diff --git a/tex/context/base/anch-bar.mkiv b/tex/context/base/anch-bar.mkiv index c7c6190be..9f9770fb6 100644 --- a/tex/context/base/anch-bar.mkiv +++ b/tex/context/base/anch-bar.mkiv @@ -58,9 +58,7 @@ \installcommandhandler \??sidebar {sidebar} \??sidebar \newcount\c_anch_sidebars_n -\newcount\c_anch_sidebars_current % local -\newdimen\d_anch_sidebars_distance -\newcount\c_anch_sidebars_level +\newdimen\c_anch_sidebars_distance % \setupMPvariables % [mpos:sidebar] @@ -69,60 +67,24 @@ % distance=5pt] \setupsidebar - [\c!rulethickness=\dimexpr\bodyfontsize/6\relax, % 2pt default + [\c!rulethickness=2pt, \c!rulecolor=\s!black, \c!alternative=0, - \c!topoffset=\zeropoint, - \c!bottomoffset=\zeropoint, - \c!distance=.5\bodyfontsize, - \c!level=, - \c!leftmargindistance=\zeropoint] + \c!topoffset=0pt, + \c!bottomoffset=0pt, + \c!distance=.5\bodyfontsize] \let\setupsidebars\setupsidebar \unexpanded\def\startsidebar {\dosingleempty\anch_sidebars_start} -\unexpanded\def\startsidebar - {\dodoubleempty\anch_sidebars_start} - -\def\anch_sidebars_start[#1][#2]% +\def\anch_sidebars_start[#1]% {\bgroup + \def\currentsidebar{#1}% \dontleavehmode - \advance\c_anch_sidebars_level\plusone \global\advance\c_anch_sidebars_n\plusone - \c_anch_sidebars_current\c_anch_sidebars_n\relax % relax needed - \doifassignmentelse{#1} - {\edef\currentsidebar{\the\c_anch_sidebars_level}% - \checksidebarparent - \setupcurrentsidebar[#1]} - {\def\currentsidebar{#1}% - \setupcurrentsidebar[#2]}% - \scratchdistance\sidebarparameter\c!distance\relax - \edef\m_level{\sidebarparameter\c!level}% - \ifx\m_level\empty - \ifnum\c_anch_sidebars_level=\plusone - \scratchdimen\sidebarparameter\c!leftmargindistance\relax - \ifdim\scratchdimen=\zeropoint - \advance\d_anch_sidebars_distance\scratchdistance\relax - \else - \d_anch_sidebars_distance\scratchdimen - \fi - \else - \advance\d_anch_sidebars_distance\scratchdistance\relax - \fi - \else - \ifnum\m_level=\plusone - \scratchdimen\sidebarparameter\c!leftmargindistance\relax - \ifdim\scratchdimen=\zeropoint - \advance\d_anch_sidebars_distance\scratchdistance\relax - \else - \d_anch_sidebars_distance\scratchdimen - \fi - \else - \d_anch_sidebars_distance\dimexpr\scratchdimen+\numexpr\m_level-\plusone\relax\dimexpr\scratchdistance\relax\relax - \fi - \fi + \advance\c_anch_sidebars_distance\sidebarparameter\c!distance \startpositionoverlay{text-1}% \normalexpanded{\setMPpositiongraphicrange % maybe expand in definition {b:sidebar:\the\c_anch_sidebars_n}% @@ -132,17 +94,15 @@ linewidth=\sidebarparameter\c!rulethickness, linecolor=\sidebarparameter\c!rulecolor, alternative=\sidebarparameter\c!alternative, - topoffset=\the\dimexpr\sidebarparameter\c!topoffset, - bottomoffset=\the\dimexpr\sidebarparameter\c!bottomoffset, - distance=\the\d_anch_sidebars_distance}% - }% + topoffset=\sidebarparameter\c!topoffset, + bottomoffset=\sidebarparameter\c!bottomoffset, + distance=\the\c_anch_sidebars_distance}}% \stoppositionoverlay - \bpos{sidebar:\the\c_anch_sidebars_current}% - \ignorespaces} + \bpos{sidebar:\the\c_anch_sidebars_n}} \unexpanded\def\stopsidebar {\removelastspace - \epos{sidebar:\the\c_anch_sidebars_current} + \epos{sidebar:\the\c_anch_sidebars_n} \carryoverpar\egroup} %D Let's keep this nice and simple (okay, we could pass the 6 variables in @@ -161,73 +121,49 @@ \MPpositiongraphic{mpos:sidebar}{}% \stopMPpositionmethod -%D We now reimplement the \MKII\ margin rules handler in a more -%D modern way. -%D -%D \setupmarginrules -%D [rulecolor=darkred, -%D rulethickness=2pt] +%D We now reimplement the margin rules handler defined in +%D \type {core-rul}: %D -%D \setupmarginrules % sidebar -%D [2] -%D [rulecolor=darkblue] +%D \setupmarginrules[level=5] %D %D \startmarginrule[1] -%D \input ward -%D \startmarginrule[2] -%D \input ward -%D \startmarginrule[3] -%D \input ward -%D \startmarginrule[level=6,rulecolor=darkgreen] -%D \input ward -%D \stopmarginrule -%D \input ward -%D \stopmarginrule -%D \input ward -%D \stopmarginrule -%D \input ward +%D First we set the level at~5. Next we typeset this first +%D paragraph as a level~1 one. As expected no rule show up. %D \stopmarginrule %D -%D Compared to the old mechanism we now can pass settings too. +%D \startmarginrule[5] +%D The second paragraph is a level~5 one. As we can see here, +%D the marginal rule gets a width according to its level. +%D \stopmarginrule +%D +%D \startmarginrule[8] +%D It will of course be no surprise that this third paragraph +%D has a even thicker margin rule. This behavior can be +%D overruled by specifying the width explictly. +%D \stopmarginrule \definesidebar [\v!margin] - [\c!leftmargindistance=\dimexpr\leftmargindistance+\sidebarparameter\c!rulethickness/2\relax] + [\c!rulethickness=\@@karulethickness, + \c!distance=\dimexpr\leftmargindistance-\@@karulethickness/2\relax] -\dorecurse{5}{\definesidebar[\v!margin:#1][\v!margin]} % let's be nice and predefine 5 levels +\definecomplexorsimple\startmarginrule -\unexpanded\def\setupmarginrule - {\dodoubleargument\anch_marginrules_setup} +\def\simplestartmarginrule + {\complexstartmarginrule[1]} -\def\anch_marginrules_setup[#1][#2]% - {\ifsecondargument - \setupsidebar[\v!margin:#1][#2]% - \else - \setupsidebar[\v!margin][#1]% - \fi} - -\let\setupmarginrules\setupmarginrule - -\unexpanded\def\startmarginrule - {\dosingleempty\anch_marginrules_start} - -\unexpanded\def\startmarginrule - {\dosingleempty\anch_marginrules_start} - -\def\anch_marginrules_start[#1]% pretty inefficient checking - {\edef\m_anch_marginrules_kind{#1}% - \ifx\m_anch_marginrules_kind\empty - \anch_sidebars_start[\v!margin][]% +\def\complexstartmarginrule[#1]% + {\bgroup + \ifnum#1<\@@kalevel\relax + \let\stopmarginrule\egroup \else - \doifassignmentelse\m_anch_marginrules_kind - {\anch_sidebars_start[\v!margin][#1]}% - {\anch_marginrules_check{#1}% - \anch_sidebars_start[\v!margin:#1][\c!level=#1]}% + \def\@@kadefaultwidth{#1}% + \let\stopmarginrule\dostopmarginrule + \normalexpanded{\startsidebar[\v!margin]}% why expanded \fi} -\def\anch_marginrules_check#1% - {\doifnotcommandhandler\??sidebar{\v!margin:#1}{\definesidebar[\v!margin:#1][\v!margin]}} - -\let\stopmarginrule\stopsidebar +\def\dostopmarginrule + {\stopsidebar + \egroup} \protect \endinput diff --git a/tex/context/base/anch-bck.mkvi b/tex/context/base/anch-bck.mkvi index 79e42dc0a..8ec056468 100644 --- a/tex/context/base/anch-bck.mkvi +++ b/tex/context/base/anch-bck.mkvi @@ -276,7 +276,7 @@ \kern\textbackgroundskip\nobreak \fi \fi \nobreak - \vskip-\dimexpr\lineheight+\parskip\relax % problem: we loose the hangindent + \vskip-\dimexpr\lineheight+\parskip\relax \nobreak \endgroup \begingroup @@ -298,7 +298,7 @@ \endgraf % new \textbackgroundparameter\c!after} -\unexpanded\def\checkpositionoverlays % overloads \relax in anch-pgr +\unexpanded\def\checkpositionoverlays {\ifproductionrun \enabletextarearegistration \enablehiddenbackground @@ -307,7 +307,7 @@ \setuptextbackground [\c!mp=mpos:region:draw, - \c!method=mpos:region, % mpos:regionshape + \c!method=mpos:region, \c!state=\v!start, \c!location=\v!text, \c!leftoffset=\!!zeropoint, % 1em, @@ -397,14 +397,6 @@ \includeMPgraphic{mpos:region:anchor} ; \stopMPpositiongraphic -\startMPpositiongraphic{mpos:regionshape}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius,lineoffset} - \includeMPgraphic{mpos:region:setup} ; - \includeMPgraphic{mpos:region:extra} ; - \MPgetmultishapes{\MPvar{self}}{\MPanchorid} ; - \includeMPgraphic{\MPvar{mp}} ; - \includeMPgraphic{mpos:region:anchor} ; -\stopMPpositiongraphic - \startMPpositionmethod{mpos:region} \MPpositiongraphic{mpos:region}{}% \stopMPpositionmethod diff --git a/tex/context/base/anch-pgr.lua b/tex/context/base/anch-pgr.lua index aba61794b..bf4dcbe02 100644 --- a/tex/context/base/anch-pgr.lua +++ b/tex/context/base/anch-pgr.lua @@ -8,8 +8,6 @@ if not modules then modules = { } end modules ['anch-pgr'] = { -- todo: we need to clean up lists (of previous pages) -local commands, context = commands, context - local format = string.format local abs = math.abs local concat, sort = table.concat, table.sort @@ -49,48 +47,34 @@ end local eps = 2 -local function add(t,x,y,last,direction) +local function add(t,x,y,last) local n = #t if n == 0 then t[n+1] = { x, y } + elseif n == 1 then + local tn = t[1] + if abs(tn[1]-x) <= eps or abs(tn[2]-y) <= eps then + t[n+1] = { x, y } + end else + local tm = t[n-1] local tn = t[n] local lx = tn[1] local ly = tn[2] - if x == lx and y == ly then - -- quick skip - elseif n == 1 then --- if abs(lx-x) <= eps or abs(ly-y) <= eps then - if abs(lx-x) > eps or abs(ly-y) > eps then - t[n+1] = { x, y } + if abs(lx-tm[1]) <= eps and abs(lx-x) <= eps then + if abs(ly-y) > eps then + tn[2] = y end - else - local tm = t[n-1] - local px = tm[1] - local py = tm[2] -if (direction == "down" and y > ly) or (direction == "up" and y < ly) then - -- move back from too much hang -else - if abs(lx-px) <= eps and abs(lx-x) <= eps then - if abs(ly-y) > eps then - tn[2] = y - end - elseif abs(ly-py) <= eps and abs(ly-y) <= eps then - if abs(lx-x) > eps then - tn[1] = x - end - elseif not last then - t[n+1] = { x, y } + elseif abs(ly-tm[2]) <= eps and abs(ly-y) <= eps then + if abs(lx-x) > eps then + tn[1] = x end -end + elseif not last then + t[n+1] = { x, y } end end end --- local function add(t,x,y,last) --- t[#t+1] = { x, y } --- end - local function finish(t) local n = #t if n > 1 then @@ -125,103 +109,105 @@ end -- todo: mark regions and free paragraphs in collected -local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot,obeyhang) +local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot) -- we assume that we only hang per page and not cross pages -- which makes sense as hanging is only uses in special cases -- -- we can remove data as soon as a page is done so we could -- remember per page and discard areas after each shipout local leftshape, rightshape - leftshape = { { rx, rh } } -- spikes get removed so we can start at the edge - rightshape = { { rw, rh } } -- even if we hang next - local paragraphs = r.paragraphs - local extending = false - if paragraphs then - for i=1,#paragraphs do - local p = paragraphs[i] - local ha = p.ha - if obeyhang and ha and ha ~= 0 then - local py = p.y - local ph = p.h - local pd = p.d - local hi = p.hi - local hang = ha * (ph + pd) - local py_ph = py + ph - -- ha < 0 hi < 0 : right top - -- ha < 0 hi > 0 : left top - if ha < 0 then - if hi < 0 then -- right - add(rightshape,rw, py_ph,"up") - add(rightshape,rw + hi,py_ph,"up") - add(rightshape,rw + hi,py_ph + hang,"up") - add(rightshape,rw, py_ph + hang,"up") - else - -- left - add(leftshape,rx,py_ph,"down") - add(leftshape,rx + hi,py_ph,"down") - add(leftshape,rx + hi,py_ph + hang,"down") - add(leftshape,rx,py_ph + hang,"down") - end - else - -- maybe some day - end - extending = true -- false - else -- we need to clip to the next par - local ps = p.ps - if ps then +-- leftshape = r.leftshape +-- rightshape = r.rightshape +-- if not leftshape then + leftshape = { { rx, rh } } + rightshape = { { rw, rh } } + local paragraphs = r.paragraphs + local extending = false + if paragraphs then + for i=1,#paragraphs do + local p = paragraphs[i] + local ha = p.ha + if ha and ha ~= 0 then local py = p.y local ph = p.h local pd = p.d - local step = ph + pd - local size = #ps * step + local hi = p.hi + local hang = ha * (ph + pd) local py_ph = py + ph - add(leftshape,rx,py_ph,"up") - add(rightshape,rw,py_ph,"down") - for i=1,#ps do - local p = ps[i] - local l = p[1] - local w = p[2] - add(leftshape,rx + l, py_ph,"up") - add(rightshape,rx + l + w, py_ph,"down") - py_ph = py_ph - step - add(leftshape,rx + l, py_ph,"up") - add(rightshape,rx + l + w, py_ph,"down") + -- ha < 0 hi < 0 : right top + -- ha < 0 hi > 0 : left top + if ha < 0 then + if hi < 0 then -- right + add(rightshape,rw , py_ph) + add(rightshape,rw + hi, py_ph) + add(rightshape,rw + hi, py_ph + hang) + add(rightshape,rw , py_ph + hang) + else + -- left + add(leftshape,rx, py_ph) + add(leftshape,rx + hi, py_ph) + add(leftshape,rx + hi, py_ph + hang) + add(leftshape,rx, py_ph + hang) + end + end +extending = false + else -- we need to clip to the next par + local ps = p.ps + if ps then + local py = p.y + local ph = p.h + local pd = p.d + local step = ph + pd + local size = #ps * step + local py_ph = py + ph + add(leftshape,rx,py_ph) + add(rightshape,rw,py_ph) + for i=1,#ps do + local p = ps[i] + local l = p[1] + local w = p[2] + add(leftshape,rx + l, py_ph) + add(rightshape,rx + l + w, py_ph) + py_ph = py_ph - step + add(leftshape,rx + l, py_ph) + add(rightshape,rx + l + w, py_ph) + end + extending = true +-- add(left,rx,py_ph) +-- add(right,rw,py_ph) + else + if extending then + local py = p.y + local ph = p.h + local pd = p.d + local py_ph = py + ph + local py_pd = py - pd + add(leftshape,leftshape[#leftshape][1],py_ph) + add(rightshape,rightshape[#rightshape][1],py_ph) + add(leftshape,rx,py_ph) + add(rightshape,rw,py_ph) +extending = false + end end - extending = true - elseif extending then - local py = p.y - local ph = p.h - local pd = p.d - local py_ph = py + ph - local py_pd = py - pd - add(leftshape,leftshape[#leftshape][1],py_ph,"up") - add(rightshape,rightshape[#rightshape][1],py_ph,"down") - add(leftshape,rx,py_ph,"up") -- shouldn't this be py_pd - add(rightshape,rw,py_ph,"down") -- shouldn't this be py_pd - extending = false end end end - end - -- we can have a simple variant when no paragraphs - if extending then - -- not ok - leftshape[#leftshape][2] = rd - rightshape[#rightshape][2] = rw - else - add(leftshape,rx,rd,"up") - add(rightshape,rw,rd,"down") - end + -- we can have a simple variant when no paragraphs + if extending then + -- not ok + leftshape[#leftshape][2] = rd + rightshape[#rightshape][2] = rw + else + add(leftshape,rx,rd) + add(rightshape,rw,rd) + end +-- r.leftshape = leftshape +-- r.rightshape = rightshape +-- end return clip(leftshape,lytop,lybot), clip(rightshape,rytop,rybot) end --- local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot,obeyhang) --- local leftshape = { { rx, rh }, { rx, rd } } --- local rightshape = { { rw, rh }, { rw, rd } } --- return clip(leftshape,lytop,lybot), clip(rightshape,rytop,rybot) --- end - -local function singlepart(b,e,r,left,right,obeyhang) +local function singlepart(b,e,r,left,right) local bx, by = b.x, b.y local ex, ey = e.x, e.y local rx, ry = r.x, r.y @@ -252,7 +238,7 @@ local function singlepart(b,e,r,left,right,obeyhang) } else area = { } - local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,ed,bh,eh,obeyhang) + local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,ed,bh,eh) add(area,bx,bh-ry) for i=1,#rightshapes do local ri = rightshapes[i] @@ -279,7 +265,7 @@ local function singlepart(b,e,r,left,right,obeyhang) } end -local function firstpart(b,r,left,right,obeyhang) +local function firstpart(b,r,left,right) local bx, by = b.x, b.y local rx, ry = r.x, r.y local rw = rx + r.w @@ -292,7 +278,7 @@ local function firstpart(b,r,left,right,obeyhang) local bh = by + b.h local bd = by - b.d local area = { } - local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,rd,bh,rd,obeyhang) + local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,rd,bh,rd) add(area,bx,bh-ry) for i=1,#rightshapes do local ri = rightshapes[i] @@ -316,7 +302,7 @@ local function firstpart(b,r,left,right,obeyhang) } end -local function middlepart(r,left,right,obeyhang) +local function middlepart(r,left,right) local rx, ry = r.x, r.y local rw = rx + r.w local rh = ry + r.h @@ -326,7 +312,7 @@ local function middlepart(r,left,right,obeyhang) rw = rw - right end local area = { } - local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,rh,rd,rh,rd,obeyhang) + local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,rh,rd,rh,rd) for i=#leftshapes,1,-1 do local li = leftshapes[i] add(area,li[1],li[2]-ry) @@ -347,7 +333,7 @@ local function middlepart(r,left,right,obeyhang) } end -local function lastpart(e,r,left,right,obeyhang) +local function lastpart(e,r,left,right) local ex, ey = e.x, e.y local rx, ry = r.x, r.y local rw = rx + r.w @@ -361,7 +347,7 @@ local function lastpart(e,r,left,right,obeyhang) local ed = ey - e.d local area = { } -- two cases: till end and halfway e line - local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,rh,ed,rh,eh,obeyhang) + local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,rh,ed,rh,eh) for i=1,#rightshapes do local ri = rightshapes[i] add(area,ri[1],ri[2]-ry) @@ -389,7 +375,7 @@ local backgrounds = { } graphics.backgrounds = backgrounds -local function calculatemultipar(tag,obeyhang) +local function calculatemultipar(tag) local collected = jobpositions.collected local b = collected[format("b:%s",tag)] local e = collected[format("e:%s",tag)] @@ -443,13 +429,13 @@ local function calculatemultipar(tag,obeyhang) -- if bindex == eindex then return { - list = { [b.p] = { singlepart(b,e,collected[br],left,right,obeyhang) } }, + list = { [b.p] = { singlepart(b,e,collected[br],left,right) } }, bpos = b, epos = e, } else local list = { - [b.p] = { firstpart(b,collected[br],left,right,obeyhang) }, + [b.p] = { firstpart(b,collected[br],left,right) }, } for i=bindex+1,eindex-1 do br = format("%s:%s",btag,i) @@ -460,18 +446,18 @@ local function calculatemultipar(tag,obeyhang) local p = r.p local pp = list[p] if pp then - pp[#pp+1] = middlepart(r,left,right,obeyhang) + pp[#pp+1] = middlepart(r,left,right) else - list[p] = { middlepart(r,left,right,obeyhang) } + list[p] = { middlepart(r,left,right) } end end end local p = e.p local pp = list[p] if pp then - pp[#pp+1] = lastpart(e,collected[er],left,right,obeyhang) + pp[#pp+1] = lastpart(e,collected[er],left,right) else - list[p] = { lastpart(e,collected[er],left,right,obeyhang) } + list[p] = { lastpart(e,collected[er],left,right) } end return { list = list, @@ -551,10 +537,10 @@ local template_d = [[ setbounds currentpicture to multibox ; ]] -function backgrounds.fetchmultipar(n,anchor,page,obeyhang) +function backgrounds.fetchmultipar(n,anchor,page) local data = pbg[n] if not data then - data = calculatemultipar(n,obeyhang) + data = calculatemultipar(n) pbg[n] = data -- can be replaced by register -- register(data.list,n,anchor) end @@ -604,10 +590,6 @@ function commands.fetchmultipar(n,anchor,page) context(backgrounds.fetchmultipar(n,anchor,page)) end -function commands.fetchmultishape(n,anchor,page) - context(backgrounds.fetchmultipar(n,anchor,page,true)) -end - local template_a = [[ path posboxes[], posregions[] ; numeric pospages[] ; @@ -660,10 +642,10 @@ end local doifelse = commands.doifelse -function commands.doifelsemultipar(n,page,obeyhang) +function commands.doifelsemultipar(n,page) local data = pbg[n] if not data then - data = calculatemultipar(n,obeyhang) + data = calculatemultipar(n) pbg[n] = data end if page then diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index 01ef25dc4..a417d26e3 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -33,7 +33,7 @@ \installcorenamespace{positionaction} \installcorenamespace{positioncleanup} -\unexpanded\def\anch_positions_set_action#1% +\unexpanded\def\dosetpositionaction#1% {\expandafter\gdef\csname\??positionaction#1\endcsname} % nicely gobbles spaces \unexpanded\def\doifpositionaction#1% @@ -111,7 +111,7 @@ {\begingroup \edef\currentpositionanchor {\ifx\currentpositionoverlay\empty#3\else\currentpositionoverlay::\MPanchoridentifier\fi}% - \normalexpanded{\anch_positions_set_action{\currentpositionanchor}{\noexpand\getvalue{\??positioncleanup\currentpositionanchor}}}% + \normalexpanded{\dosetpositionaction{\currentpositionanchor}{\noexpand\getvalue{\??positioncleanup\currentpositionanchor}}}% \let#1\relax \ifcsname\??positioncleanup\currentpositionanchor\endcsname \setxvalue{\??positioncleanup\currentpositionanchor}% @@ -140,6 +140,9 @@ \fi \fi\fi} +% \def\anch_positions_register_page_indeed#1% +% {\setbox#1\hbox{\hpos\pageanchor{\box#1}}} + \def\anch_positions_register_page_indeed#1% maybe like text {\ifvbox#1\setbox#1\hbox{\box#1}\fi \anch_make_page_box{#1}} @@ -215,6 +218,7 @@ %D \typebuffer[graphic] \def\MPanchoridentifier{mpa} % {mp-anchor} +%def\MPoverlayposprefix{MO::} % not used %D The rest of the definitions concerning such overlays may %D look complicated, @@ -233,8 +237,8 @@ \def\textbackgroundoverlay#1{\v!text#1} \def\MPanchornumber {\the\realpageno} -\unexpanded\def\positionoverlay % the test prevents too many redundant positions - {\ifpositioning % in (not used) text* position layers +\def\positionoverlay % the test prevents too many redundant positions + {\ifpositioning % in (not used) text* position layers \expandafter\anch_positions_overlay_indeed \else % also \iftrialtypesetting test here? \expandafter\gobbleoneargument @@ -265,7 +269,7 @@ \box\scratchbox \vfill}} -\unexpanded\def\positionregionoverlay % shares regions +\def\positionregionoverlay % shares regions {\ifpositioning \expandafter\anch_positions_region_overlay_indeed \else % also \iftrialtypesetting test here? @@ -304,15 +308,9 @@ \expandafter\anch_positions_overlay_start_yes \fi} -\let\stoppositionoverlay\relax - \def\anch_positions_overlay_start_nop#1\stoppositionoverlay {} -\ifdefined\checkpositionoverlays \else \let\checkpositionoverlays\relax \fi - -\let\currentpositionoverlay\empty - \def\anch_positions_overlay_start_yes#1% {\checkpositionoverlays \edef\currentpositionoverlay{#1}} @@ -320,11 +318,9 @@ \unexpanded\def\stoppositionoverlay {\let\currentpositionoverlay\empty} -% needs checking if still needed -% % \def\resetpositionoverlay#1% -% {\anch_positions_set_action{#1::\MPanchoridentifier::}{}} -% +% {\dosetpositionaction{#1::\MPanchoridentifier::}{}} + % \def\handlepositionboxes#1#2#3% % {\handlepositionaction\dohandlepositionboxes\with{#1}{#2}{#3}\on{#2}} % @@ -336,15 +332,15 @@ % \appendtoks % \let\dohandlepositionboxes\doinsertpositionboxes % was handle ? % \to \everyinsertpositionaction -% -% \def\docleanpositionboxes#1#2#3% pos tag setups -% {\ifnum\MPp{#1}<\realpageno \else -% \noexpand \dohandlepositionboxes{#1}{#2}{#3}% reinsert -% \fi} -% -% \appendtoks -% \let\dohandlepositionboxes\docleanpositionboxes -% \to \everycleanpositionaction + +\def\docleanpositionboxes#1#2#3% pos tag setups + {\ifnum\MPp{#1}<\realpageno \else + \noexpand \dohandlepositionboxes{#1}{#2}{#3}% reinsert + \fi} + +\appendtoks + \let\dohandlepositionboxes\docleanpositionboxes +\to \everycleanpositionaction %D A position graphic is a normal (non||reused) \METAPOST\ %D graphic, used immediately, with zero dimensions, so that a @@ -354,7 +350,7 @@ \installcorenamespace{positionmethod} %installcorenamespace{graphicvariable} -\newbox\b_anch_positions_graphic +\newbox\positiongraphicbox \def\startMPpositiongraphic % id setups {\dodoublegroupempty\anch_positions_meta_graphic_start} @@ -365,11 +361,11 @@ \let\stopMPpositiongraphic\relax \def\anch_positions_meta_graphic_prepare - {\ifcsname\??graphicvariable\currentmpvariableclass:self\endcsname \else - \letvalue{\??graphicvariable\currentmpvariableclass:self}\currentposition + {\ifcsname\??gv\currentmpvariableclass:self\endcsname \else + \letvalue{\??gv\currentmpvariableclass:self}\currentposition \fi - \ifcsname\??graphicvariable\currentmpvariableclass:from\endcsname \else - \letvalue{\??graphicvariable\currentmpvariableclass:from}\currentposition + \ifcsname\??gv\currentmpvariableclass:from\endcsname \else + \letvalue{\??gv\currentmpvariableclass:from}\currentposition \fi} \def\anch_positions_meta_graphic_use#1#2#3% @@ -379,7 +375,7 @@ \startMPcode#3\stopMPcode \endgroup} -\unexpanded\def\MPpositiongraphic +\def\MPpositiongraphic {\dodoublegroupempty\anch_positions_meta_graphic_direct} \def\anch_positions_meta_graphic_direct#1% tag setups @@ -406,9 +402,9 @@ \anch_positions_meta_graphic_prepare \obeyMPboxorigin % do we also set the size ? when needed this must be done in mp ... might change \def\anch_positions_meta_graphic_direct{\anch_positions_meta_graphic_nested{#3}}% takes two extra arguments - \setbox\b_anch_positions_graphic\hbox{\ignorespaces\csname#1#2\endcsname\removelastspace}% - \smashbox\b_anch_positions_graphic - \box\b_anch_positions_graphic + \setbox\positiongraphicbox\hbox{\ignorespaces\csname#1#2\endcsname\removelastspace}% + \smashbox\positiongraphicbox + \box\positiongraphicbox \endgroup} \def\anch_positions_meta_graphic_nested#1#2#3% nesting used in prikkels / pascal (might go away) @@ -426,77 +422,77 @@ %D Simple one position graphics. -\unexpanded\def\setMPpositiongraphic - {\dotriplegroupempty\anch_positions_meta_graphic_set} +\def\setMPpositiongraphic + {\dotriplegroupempty\dosetMPpositiongraphic} -\def\anch_positions_meta_graphic_set#1#2#3% pos tag vars +\def\dosetMPpositiongraphic#1#2#3% pos tag vars {\ifx\currentpositionoverlay\empty - \anch_positions_set_action{#1}{\MPpositiongraphic{#2}{#3}}% + \dosetpositionaction{#1}{\MPpositiongraphic{#2}{#3}}% \else % silly can be one - \anch_positions_meta_graphic_handle{#1}{#2}{#3}% + \handlepositiongraphics{#1}{#2}{#3}% \fi} -\def\anch_positions_meta_graphic_handle#1#2#3% combine with boxes - {\handlepositionaction\anch_positions_meta_graphic_handle_indeed\with{#1}{#2}{#3}\on{#2}} +\def\handlepositiongraphics#1#2#3% combine with boxes + {\handlepositionaction\dohandleMPpositiongraphic\with{#1}{#2}{#3}\on{#2}} -\def\anch_positions_meta_graphic_insert#1#2#3% pos tag setups +\def\doinsertMPpositiongraphic#1#2#3% pos tag setups {\ifnum\MPp{#1}=\realpageno\relax % extra saveguard \def\currentposition{#1}\MPpositiongraphic{#2}{#3}% \fi} \appendtoks - \let\anch_positions_meta_graphic_handle_indeed\anch_positions_meta_graphic_insert + \let\dohandleMPpositiongraphic\doinsertMPpositiongraphic \to \everyinsertpositionaction -\def\anch_positions_meta_graphic_cleanup#1#2#3% pos tag setups +\def\docleanMPpositiongraphic#1#2#3% pos tag setups {\ifnum\MPp{#1}<\realpageno \else - \noexpand\anch_positions_meta_graphic_handle_indeed{#1}{#2}{#3}% + \noexpand\dohandleMPpositiongraphic{#1}{#2}{#3}% \fi} \appendtoks - \let\anch_positions_meta_graphic_handle_indeed\anch_positions_meta_graphic_cleanup + \let\dohandleMPpositiongraphic\docleanMPpositiongraphic \to \everycleanpositionaction %D Graphics that span two positions (beware, does not cross pages). \unexpanded\def\setMPpositiongraphicrange - {\doquadruplegroupempty\anch_positions_meta_graphic_set_range} + {\doquadruplegroupempty\dosetMPpositiongraphicrange} -\def\anch_positions_meta_graphic_set_range#1#2#3#4% bpos epos tag vars +\def\dosetMPpositiongraphicrange#1#2#3#4% bpos epos tag vars {\ifx\currentpositionoverlay\empty - \anch_positions_set_action{#1}{\MPpositiongraphic{#3}{#4}}% + \dosetpositionaction{#1}{\MPpositiongraphic{#3}{#4}}% \else - \anch_positions_meta_graphic_handle_range{#1}{#2}{#3}{#4}% + \handlepositiongraphicsrange{#1}{#2}{#3}{#4}% \fi} -\def\anch_positions_meta_graphic_handle_range#1#2#3#4% - {\handlepositionaction\anch_positions_meta_graphic_handle_range_indeed\with{#1}{#2}{#3}{#4}\on{#2}} +\def\handlepositiongraphicsrange#1#2#3#4% + {\handlepositionaction\dohandleMPpositiongraphicrange\with{#1}{#2}{#3}{#4}\on{#2}} -\def\anch_positions_meta_graphic_insert_range#1#2#3#4% pos pos tag setups +\def\doinsertMPpositiongraphicrange#1#2#3#4% pos pos tag setups {\ctxcommand{doifelserangeonpage("#1","#2",\number\realpageno)}% - {\def\currentposition{#1}% + {%\writestatus{YES}{#1/#2 => #3}% + \def\currentposition{#1}% \MPpositiongraphic{#3}{#4}}% - {}} + {}}%\writestatus{NOP}{#1/#2 = #3}}} \appendtoks - \let\anch_positions_meta_graphic_handle_range_indeed\anch_positions_meta_graphic_insert_range + \let\dohandleMPpositiongraphicrange\doinsertMPpositiongraphicrange \to \everyinsertpositionaction -\def\anch_positions_meta_graphic_cleanup_range#1#2#3#4% pos tag setups +\def\docleanMPpositiongraphicrange#1#2#3#4% pos tag setups {\ifnum\MPp{#2}<\realpageno \else - \noexpand \anch_positions_meta_graphic_handle_range_indeed{#1}{#2}{#3}{#4}% + \noexpand \dohandleMPpositiongraphicrange{#1}{#2}{#3}{#4}% \fi} \appendtoks - \let\anch_positions_meta_graphic_handle_range_indeed\anch_positions_meta_graphic_cleanup_range + \let\dohandleMPpositiongraphicrange\docleanMPpositiongraphicrange \to \everycleanpositionaction -\let\anch_positions_meta_graphic_handle_range_indeed\gobblefourarguments +\let\dohandleMPpositiongraphicrange\gobblefourarguments % Helpers: -\def\MPgetposboxes #1#2{\ctxcommand{fetchposboxes("#1","#2",\the\realpageno)}} -\def\MPgetmultipars #1#2{\ctxcommand{fetchmultipar("#1","#2",\the\realpageno)}} -\def\MPgetmultishapes#1#2{\ctxcommand{fetchmultishape("#1","#2",\the\realpageno)}} +\def\MPgetposboxes #1#2{\ctxcommand{fetchposboxes("#1","#2",\the\realpageno)}} +\def\MPgetmultipars#1#2{\ctxcommand{fetchmultipar("#1","#2",\the\realpageno)}} \protect \endinput diff --git a/tex/context/base/anch-pos.lua b/tex/context/base/anch-pos.lua index 6fa916291..5d01a6e46 100644 --- a/tex/context/base/anch-pos.lua +++ b/tex/context/base/anch-pos.lua @@ -17,8 +17,6 @@ more efficient.

-- maybe replace texsp by our own converter (stay at the lua end) -- eventually mp will have large numbers so we can use sp there too -local commands, context = commands, context - local tostring, next, rawget, setmetatable = tostring, next, rawget, setmetatable local concat, sort = table.concat, table.sort local format, gmatch, match = string.format, string.gmatch, string.match @@ -971,35 +969,35 @@ function commands.MPxywhd(id) end end -local doif, doifelse = commands.doif, commands.doifelse +-- is testcase already defined? if so, then local function commands.doifpositionelse(name) - doifelse(collected[name]) + commands.doifelse(collected[name]) end function commands.doifposition(name) - doif(collected[name]) + commands.doif(collected[name]) end function commands.doifpositiononpage(name,page) -- probably always realpageno local c = collected[name] - doifelse(c and c.p == page) + commands.testcase(c and c.p == page) end function commands.doifoverlappingelse(one,two,overlappingmargin) - doifelse(overlapping(one,two,overlappingmargin)) + commands.testcase(overlapping(one,two,overlappingmargin)) end function commands.doifpositionsonsamepageelse(list,page) - doifelse(onsamepage(list)) + commands.testcase(onsamepage(list)) end function commands.doifpositionsonthispageelse(list) - doifelse(onsamepage(list,tostring(tex.count.realpageno))) + commands.testcase(onsamepage(list,tostring(tex.count.realpageno))) end function commands.doifelsepositionsused() - doifelse(next(collected)) + commands.testcase(next(collected)) end commands.markcolumnbox = jobpositions.markcolumnbox diff --git a/tex/context/base/anch-pos.mkiv b/tex/context/base/anch-pos.mkiv index 7ecaa296e..2e13eeba2 100644 --- a/tex/context/base/anch-pos.mkiv +++ b/tex/context/base/anch-pos.mkiv @@ -361,9 +361,9 @@ \startcolor[blue]% \llap{\infofont\number\c_anch_positions_paragraph}% \vrule - \s!width 4\onepoint - \s!height2\onepoint - \s!depth 2\onepoint + \!!width 4\onepoint + \!!height2\onepoint + \!!depth 2\onepoint \stopcolor \hss}} @@ -377,7 +377,7 @@ {\smashedhbox {#1{\infofont#2#3}% \kern-\onepoint - \vrule\s!width2\onepoint\s!height\halfapoint\s!depth\halfapoint}} + \vrule\!!width2\onepoint\!!height\halfapoint\!!depth\halfapoint}} \unexpanded\def\anch_positions_trace_left_indeed {\anch_positions_trace\llap\darkmagenta{\currentposition>}} diff --git a/tex/context/base/anch-tab.mkiv b/tex/context/base/anch-tab.mkiv index 2fb6938a2..4bdaa2ef9 100644 --- a/tex/context/base/anch-tab.mkiv +++ b/tex/context/base/anch-tab.mkiv @@ -13,9 +13,6 @@ \writestatus{loading}{ConTeXt Anchoring Macros / Table Extensions} -%D This is just a playground and functionality might change or even -%D dissappear in favour of better solutions. - \unprotect \newcount\c_anch_tabs @@ -60,22 +57,23 @@ \global\advance\c_anch_tabs\plusone \to \everytabulate -%D Beware, the following code is somewhat weird and experimental and might be -%D dropped or become a loadable module. +%D Beware, the following code is somewhat weird and experimental +%D and might be dropped or become a loadable module. %D \macros %D {GFC, GTC, GSC} %D -%D The next macros extend tables and tabulation with backgrounds and position -%D related features. Areas are specified with symbolic names, and symbolic -%D references to the graphics involved. Each table has its own namespace. +%D The next macros extend tables and tabulation with +%D backgrounds and position related features. Areas are +%D specified with symbolic names, and symbolic references to +%D the graphics involved. Each table has its own namespace. \newconditional\tablehaspositions -\newcount \noftabpositions -\newtoks \posXCtoks +\newcount\noftabpositions +\newtoks \posXCtoks -\def\anch_tabulate_bpos{\bpos} -\def\anch_tabulate_epos{\epos} +\def\dotablebpos{\bpos} +\def\dotableepos{\epos} \installcorenamespace{positiontables} @@ -87,80 +85,74 @@ \let\tabulatepos\tablepos -\unexpanded\def\tbXC {\dosingleempty\anch_tables_XC } -\unexpanded\def\tbGSC{\dosingleempty\anch_tables_GSC} -\unexpanded\def\tbGFC{\dosingleempty\anch_tables_GFC} -\unexpanded\def\tbGTC{\dosingleempty\anch_tables_GTC} - -\def\anch_table_check_state - {\iftrialtypesetting - \global\settrue\tablehaspositions - \firstargumentfalse - \fi} - -\def\anch_tables_XC [#1]{\anch_table_check_state\iffirstargument\anch_tables_indeed_XC [#1]\else\expandafter\fi\NC} -\def\anch_tables_GSC[#1]{\anch_table_check_state\iffirstargument\anch_tables_indeed_GSC[#1]\else\expandafter\NC\fi} -\def\anch_tables_GFC[#1]{\anch_table_check_state\iffirstargument\anch_tables_indeed_GFC[#1]\else\expandafter\NC\fi} -\def\anch_tables_GTC[#1]{\anch_table_check_state\iffirstargument\anch_tables_indeed_GTC[#1]\else\expandafter\NC\fi} - -\def\anch_tables_indeed_XC[#1]% - {{\let\NC\relax\processcommalist[#1]\anch_tables_step_XC}} +\def\dodododoGSC[#1:#2]% + {\remappositionframed{#2}{\tbPOSprefix#1}% + \dotablebpos{\tbPOSprefix#1}% + \doglobal\appendtoks\@EA\dotableepos\@EA{\tbPOSprefix#1}\to\posXCtoks} -\def\anch_tables_step_XC#1% - {\anch_tables_step_indeed_XC[#1]} +\def\dododoGSC[#1:#2:#3]% + {\doglobal\appendtoks\dodododoGSC[#1:#2]\to\posXCtoks\NC} -\def\anch_tables_step_indeed_XC[#1#2]% - {\if#1>\anch_tables_indeed_GFC [#2:#2]\else - \if#1+\anch_tables_indeed_GFC [#2:#2]\else - \if#1<\anch_tables_indeed_GTC [#2:#2]\else - \if#1-\anch_tables_indeed_GTC [#2:#2]\else - \if#1=\anch_tables_indeed_GSC [#2:#2]\else - \anch_tables_indeed_GSC[#1#2:#1#2]\fi\fi\fi\fi\fi} +\def\dodoGSC[#1]% + {\def\docommand##1{\dododoGSC[##1:##1]}% + \processcommalist[#1]\docommand} -\def\anch_tables_indeed_GSC[#1]% - {\processcommalist[#1]\anch_tables_step_GSC} +\def\dodododoGFC[#1:#2:#3]% + {\remappositionframed{#2}{\tbPOSprefix#1}% + \dotablebpos{\tbPOSprefix#1}} -\def\anch_tables_step_GSC#1% - {\anch_tables_append_GSC[#1:#1]} +\def\dododoGFC[#1]% + {\def\docommand##1{\dodododoGFC[##1:##1]}% + \processcommalist[#1]\docommand} -\def\anch_tables_append_GSC[#1:#2:#3]% - {\doglobal\appendtoks\anch_tables_process_GSC[#1:#2]\to\posXCtoks\NC} +\def\dodoGFC[#1]% + {\doglobal\appendtoks\dododoGFC[#1]\to\posXCtoks\NC} -\def\anch_tables_process_GSC[#1:#2]% - {\remappositionframed{#2}{\tbPOSprefix#1}% - \anch_tabulate_bpos{\tbPOSprefix#1}% - \doglobal\appendtoks\@EA\anch_tabulate_epos\@EA{\tbPOSprefix#1}\to\posXCtoks} +\def\dododododoGTC[#1:#2]% + {\dotableepos{\tbPOSprefix#1}} -\def\anch_tables_indeed_GFC[#1]% - {\doglobal\appendtoks\anch_tables_delayed_GFC[#1]\to\posXCtoks\NC} +\def\dodododoGTC[#1]% + {\def\docommand##1{\dododododoGTC[##1:##1]}% + \processcommalist[#1]\docommand} -\def\anch_tables_delayed_GFC[#1]% - {\processcommalist[#1]\anch_tables_step_GFC} +\def\dododoGTC[#1]% + {\doglobal\appendtoks\dodododoGTC[#1]\to\posXCtoks} -\def\anch_tables_step_GFC#1% - {\anch_tables_process_GFC[#1:#1]} +\def\dodoGTC[#1]% + {\doglobal\appendtoks\dododoGTC[#1]\to\posXCtoks\NC} -\def\anch_tables_process_GFC[#1:#2:#3]% - {\remappositionframed{#2}{\tbPOSprefix#1}% - \anch_tabulate_bpos{\tbPOSprefix#1}} +\def\dodododoXC[#1#2]% + {\if#1>\dodoGFC [#2:#2]\else + \if#1+\dodoGFC [#2:#2]\else + \if#1<\dodoGTC [#2:#2]\else + \if#1-\dodoGTC [#2:#2]\else + \if#1=\dodoGSC [#2:#2]\else + \dodoGSC[#1#2:#1#2]\fi\fi\fi\fi\fi} -\def\anch_tables_indeed_GTC[#1]% - {\doglobal\appendtoks\anch_tables_delayed_GTC[#1]\to\posXCtoks\NC} +\def\dododoXC#1% + {\dodododoXC[#1]} -\def\anch_tables_delayed_GTC[#1]% - {\doglobal\appendtoks\anch_tables_process_GTC[#1]\to\posXCtoks} +\def\dodoXC[#1]% + {{\let\NC\relax\processcommalist[#1]\dododoXC}} -\def\anch_tables_process_GTC[#1]% - {\processcommalist[#1]\anch_tables_step_GTC} +\def\@@checktablepositionstate + {\iftrialtypesetting + \global\settrue\tablehaspositions + \firstargumentfalse + \fi} -\def\anch_tables_step_GTC#1% - {\anch_tables_step_indeed_GTC[#1:#1]} +\def\doGSC[#1]{\@@checktablepositionstate\iffirstargument\dodoGSC[#1]\else\expandafter\NC\fi} +\def\doGFC[#1]{\@@checktablepositionstate\iffirstargument\dodoGFC[#1]\else\expandafter\NC\fi} +\def\doGTC[#1]{\@@checktablepositionstate\iffirstargument\dodoGTC[#1]\else\expandafter\NC\fi} +\def\doXC [#1]{\@@checktablepositionstate\iffirstargument\dodoXC [#1]\else\expandafter\fi\NC} -\def\anch_tables_step_indeed_GTC[#1:#2]% - {\anch_tabulate_epos{\tbPOSprefix#1}} +\def\tbGSC{\dosingleempty\doGSC} +\def\tbGFC{\dosingleempty\doGFC} +\def\tbGTC{\dosingleempty\doGTC} +\def\tbXC {\dosingleempty\doXC } -%D The amount of code to support tables and tabulation is rather -%D minimalistic. +%D The amount of code to support tables and tabulation is +%D rather minimalistic. \let\tabulatepos\tablepos @@ -195,30 +187,31 @@ % We need to handle paragraphs as well. -\let\anch_tabulate_flush_epos\relax +\let\doflushtabulateepos\relax -\def\anch_tabulate_bpos_indeed +\def\dotabulatebpos {\bpos} -\def\anch_tabulate_epos_indeed#1% +\def\dotabulateepos#1% {\ifvoid\b_tabl_tabulate_current\c_tabl_tabulate_column \epos{#1}% - \glet\anch_tabulate_flush_epos\relax + \glet\doflushtabulateepos\relax \else - \gdef\anch_tabulate_flush_epos{\epos{#1}}% + \gdef\doflushtabulateepos{\epos{#1}}% \fi} \def\flushtabulatesplitbox {\box\b_tabl_tabulate - \iftrialtypesetting\else\ifconditional\tablehaspositions\anch_tabulate_flush_epos\fi\fi} + \iftrialtypesetting\else\ifconditional\tablehaspositions\doflushtabulateepos\fi\fi} \appendtoks - \let\anch_tabulate_bpos\anch_tabulate_bpos_indeed % ? - \let\anch_tabulate_epos\anch_tabulate_epos_indeed % ? - \glet\anch_tabulate_flush_epos\relax + \let\dotablebpos\dotabulatebpos % ? + \let\dotableepos\dotabulateepos % ? + \glet\doflushtabulateepos\relax \to \everytabulate -%D In order to prevent potential clashes with abbreviations, postpone the mapping. +%D In order to prevent potential clashes with abbreviations, +%D postpone the mapping. \appendtoks \let\GSC\tbGSC @@ -230,8 +223,8 @@ %D \macros %D {definepositionframed} %D -%D The next example show how to provide backgrounds to table cells. First we define -%D some framed backgrounds. +%D The next example show how to provide backgrounds to table +%D cells. First we define some framed backgrounds. %D %D \startbuffer %D \definepositionframed[x][background=color,backgroundcolor=red] @@ -251,7 +244,8 @@ %D \stoptabulate %D \stopbuffer %D -%D The table itself defines three areas (a, b and~c) using these frames. +%D The table itself defines three areas (a, b and~c) using +%D these frames. %D %D \typebuffer %D % \getbuffer @@ -276,8 +270,9 @@ \let\XC \tbXC \to \everytable -%D In the previous example, we could have provided an overlay to the framed definition. -%D A more direct approach is demonstrated below: +%D In the previous example, we could have provided an overlay to +%D the framed definition. A more direct approach is demonstrated +%D below: %D %D \startbuffer %D \def\cw#1{\color[white]{#1}} @@ -296,7 +291,8 @@ %D %D \typebuffer \getbuffer %D -%D The definition of the table looks about the same as the previous one: +%D The definition of the table looks about the same as the +%D previous one: %D %D \startbuffer %D \starttable[|c|c|c|] @@ -351,26 +347,22 @@ % \definepositionframed[y][background=color,fillcolor=green] % \definepositionframed[z][background=color,fillcolor=blue] -\unexpanded\def\remappositionframed#1#2% from to +\def\remappositionframed#1#2% from to {\copyposition{b:#1}{b:#2}% \copyposition{e:#1}{e:#2}% - \anch_positions_set_action{b:#2}{\dopositionaction{b:#1}}} + \dosetpositionaction{b:#2}{\dopositionaction{b:#1}}} \unexpanded\def\definepositionframed - {\dodoubleargument\anch_framed_define} + {\dodoubleargument\dodefinepositionframed} -\def\anch_framed_define[#1][#2]% - {\anch_positions_set_action{b:#1}{\anch_framed_handle[#1][#2]}} - -\unexpanded\def\anch_framed_handle - {\bgroup - \anch_framed_indeed} +\def\dodefinepositionframed[#1][#2]% + {\dosetpositionaction{b:#1}{\dopositionframed[#1][#2]}} \unexpanded\def\positionframed {\bgroup - \dodoubleempty\anch_framed_indeed} + \dodoubleempty\dopositionframed} -\def\anch_framed_indeed[#1][#2]% +\def\dopositionframed[#1][#2]% {\setbox\scratchbox\hbox {\scratchwidth \dimexpr\MPx{e:#1}-\MPx{b:#1}\relax \scratchdepth \dimexpr\MPy{b:#1}-\MPy{e:#1}+\MPd{e:#1}\relax diff --git a/tex/context/base/attr-col.lua b/tex/context/base/attr-col.lua index 18182ba85..c592d1dc1 100644 --- a/tex/context/base/attr-col.lua +++ b/tex/context/base/attr-col.lua @@ -15,11 +15,8 @@ if not modules then modules = { } end modules ['attr-col'] = { local type = type local format = string.format local concat = table.concat -local min, max, floor = math.min, math.max, math.floor -local attributes, nodes, utilities, logs, backends, storage = attributes, nodes, utilities, logs, backends, storage -local commands, context, interfaces = commands, context, interfaces -local tex = tex +local attributes, nodes = attributes, nodes local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex @@ -34,13 +31,11 @@ local report_transparencies = logs.reporter("transparencies","support") -- nb: attributes: color etc is much slower than normal (marks + literals) but ... -- nb. too many "0 g"s -local states = attributes.states -local tasks = nodes.tasks -local nodeinjections = backends.nodeinjections -local registrations = backends.registrations -local unsetvalue = attributes.unsetvalue - -local registerstorage = storage.register +local states = attributes.states +local tasks = nodes.tasks +local nodeinjections = backends.nodeinjections +local registrations = backends.registrations +local unsetvalue = attributes.unsetvalue -- We can distinguish between rules and glyphs but it's not worth the trouble. A -- first implementation did that and while it saves a bit for glyphs and rules, it @@ -68,7 +63,7 @@ local registerstorage = storage.register -- colors.strings[color] = "return colors." .. colorspace .. "(" .. concat({...},",") .. ")" -- end -- --- registerstorage("attributes/colors/data", colors.strings, "attributes.colors.data") -- evaluated +-- storage.register("attributes/colors/data", colors.strings, "attributes.colors.data") -- evaluated -- -- We assume that only processcolors are defined in the format. @@ -88,17 +83,9 @@ colors.default = 1 colors.main = nil colors.triggering = true colors.supported = true -colors.model = "all" - -local data = colors.data -local values = colors.values -local registered = colors.registered -local numbers = attributes.numbers -local list = attributes.list - -registerstorage("attributes/colors/values", values, "attributes.colors.values") -registerstorage("attributes/colors/registered", registered, "attributes.colors.registered") +storage.register("attributes/colors/values", colors.values, "attributes.colors.values") +storage.register("attributes/colors/registered", colors.registered, "attributes.colors.registered") local templates = { rgb = "r:%s:%s:%s", @@ -117,6 +104,17 @@ local models = { cmyk = 4, } +colors.model = "all" + +local data = colors.data +local values = colors.values +local registered = colors.registered + +local numbers = attributes.numbers +local list = attributes.list + +local min, max, floor = math.min, math.max, math.floor + local function rgbtocmyk(r,g,b) -- we could reduce return 1-r, 1-g, 1-b, 0 end @@ -127,9 +125,9 @@ end local function rgbtogray(r,g,b) if colors.weightgray then - return .30*r + .59*g + .11*b + return .30*r+.59*g+.11*b else - return r/3 + g/3 + b/3 + return r/3+g/3+b/3 end end @@ -137,17 +135,6 @@ local function cmyktogray(c,m,y,k) return rgbtogray(cmyktorgb(c,m,y,k)) end --- not critical so not needed: --- --- local function cmyktogray(c,m,y,k) --- local r, g, b = 1.0 - min(1.0,c+k), 1.0 - min(1.0,m+k), 1.0 - min(1.0,y+k) --- if colors.weightgray then --- return .30*r + .59*g + .11*b --- else --- return r/3 + g/3 + b/3 --- end --- end - -- http://en.wikipedia.org/wiki/HSI_color_space -- http://nl.wikipedia.org/wiki/HSV_(kleurruimte) @@ -376,15 +363,15 @@ transparencies.triggering = true transparencies.attribute = a_transparency transparencies.supported = true -local registered = transparencies.registered -- we could use a 2 dimensional table instead -local data = transparencies.data -local values = transparencies.values -local template = "%s:%s" +storage.register("attributes/transparencies/registered", transparencies.registered, "attributes.transparencies.registered") +storage.register("attributes/transparencies/values", transparencies.values, "attributes.transparencies.values") -registerstorage("attributes/transparencies/registered", registered, "attributes.transparencies.registered") -registerstorage("attributes/transparencies/values", values, "attributes.transparencies.values") +local registered = transparencies.registered -- we could use a 2 dimensional table instead +local data = transparencies.data +local values = transparencies.values +local template = "%s:%s" -local function inject_transparency(...) +local function inject_transparency (...) inject_transparency = nodeinjections.transparency return inject_transparency(...) end diff --git a/tex/context/base/attr-eff.lua b/tex/context/base/attr-eff.lua index 60e0c08ac..023d1c51b 100644 --- a/tex/context/base/attr-eff.lua +++ b/tex/context/base/attr-eff.lua @@ -8,9 +8,7 @@ if not modules then modules = { } end modules ['attr-eff'] = { local format = string.format -local commands, interfaces = commands, interfaces -local attributes, nodes, backends, utilities = attributes, nodes, backends, utilities -local tex = tex +local attributes, nodes = attributes, nodes local states = attributes.states local tasks = nodes.tasks @@ -19,9 +17,6 @@ local settexattribute = tex.setattribute local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex -local variables = interfaces.variables -local v_normal = variables.normal - attributes.effects = attributes.effects or { } local effects = attributes.effects @@ -32,14 +27,14 @@ effects.values = effects.values or { } effects.registered = effects.registered or { } effects.attribute = a_effect -local data = effects.data -local registered = effects.registered -local values = effects.values +storage.register("attributes/effects/registered", effects.registered, "attributes.effects.registered") +storage.register("attributes/effects/values", effects.values, "attributes.effects.values") -local template = "%s:%s:%s" +local template = "%s:%s:%s" -storage.register("attributes/effects/registered", registered, "attributes.effects.registered") -storage.register("attributes/effects/values", values, "attributes.effects.values") +local data = effects.data +local registered = effects.registered +local values = effects.values -- valid effects: normal inner outer both hidden (stretch,rulethickness,effect) @@ -71,22 +66,12 @@ effects.handler = nodes.installattributehandler { processor = states.process, } -local function register(specification) - local alternative, stretch, rulethickness - if specification then - alternative = specification.alternative or v_normal - stretch = specification.stretch or 0 - rulethickness = specification.rulethickness or 0 - else - alternative = v_normal - stretch = 0 - rulethickness = 0 - end - local stamp = format(template,alternative,stretch,rulethickness) +local function register(effect,stretch,rulethickness) + local stamp = format(template,effect,stretch,rulethickness) local n = registered[stamp] if not n then n = #values + 1 - values[n] = { alternative, stretch, rulethickness } + values[n] = { effect, stretch, rulethickness } registered[stamp] = n end return n @@ -103,10 +88,10 @@ effects.enable = enable local enabled = false -function commands.triggereffect(specification) +function commands.triggereffect(effect,stretch,rulethickness) if not enabled then enable() enabled = true end - settexattribute(a_effect,register(specification)) + settexattribute(a_effect,register(effect,stretch,rulethickness)) end diff --git a/tex/context/base/attr-eff.mkiv b/tex/context/base/attr-eff.mkiv index 43f575a7a..c5c94537c 100644 --- a/tex/context/base/attr-eff.mkiv +++ b/tex/context/base/attr-eff.mkiv @@ -17,39 +17,38 @@ \unprotect -\installcorenamespace{effect} +\gdef\dotriggereffect#1#2#3% + {\ctxcommand{triggereffect('#1',#2,\number\dimexpr#3\relax)}} -\installcommandhandler \??effect {effect} \??effect +\unexpanded\def\setupeffect + {\dodoubleargument\dosetupeffect} -\setupeffect - [\c!method=\v!none, - \c!stretch=\zerocount, - \c!rulethickness=\zeropoint, - \c!alternative=\v!normal] +\def\dosetupeffect[#1][#2]% + {\getparameters[\??et#1][#2]} -\appendtoks - \edef\p_method{\effectparameter\c!method}% - \ifx\p_method\v!method - \setuxvalue{\e!start\currenteffect}{\starteffect[#1]}% - \setuxvalue{\e!stop \currenteffect}{\stopeffect}% - \fi -\to \everydefineeffect +\unexpanded\def\defineeffect + {\dodoubleargument\dodefineeffect} + +\def\dodefineeffect[#1][#2]% + {\getparameters[\??et#1][\c!method=\v!none,\c!stretch=0,\c!rulethickness=\zeropoint,\c!alternative=\v!normal,#2]% + \doif{\getvalue{\??et#1\c!method}}\v!command + {\setugvalue{\e!start#1}{\starteffect[#1]}% + \setugvalue{\e!stop #1}{\stopeffect}}} + +% yes or no grouped \unexpanded\def\starteffect[#1]% - {\ctxcommand{triggereffect{ - alternative = "\namedeffectparameter{#1}\c!alternative", - stretch = \number\namedeffectparameter{#1}\c!stretch, - rulethickness = \number\dimexpr\namedeffectparameter{#1}\c!rulethickness\relax - }}} + {\dotriggereffect + {\csname\??et#1\c!alternative \endcsname}% + {\csname\??et#1\c!stretch \endcsname}% + {\csname\??et#1\c!rulethickness\endcsname}} \unexpanded\def\stopeffect % can be special - {\ctxcommand{triggereffect()}} % v!normal 0 0 + {\dotriggereffect\v!normal0\zeropoint} \unexpanded\def\effect[#1]% {\groupedcommand{\starteffect[#1]}{\stopeffect}} -% yes or no grouped - \defineeffect [\v!inner] [\c!alternative=\v!inner,\c!rulethickness=.25pt] \defineeffect [\v!outer] [\c!alternative=\v!outer,\c!rulethickness=.25pt] \defineeffect [\v!both] [\c!alternative=\v!both, \c!rulethickness=.25pt] diff --git a/tex/context/base/attr-ini.lua b/tex/context/base/attr-ini.lua index 5a3bafce3..f3714fcb4 100644 --- a/tex/context/base/attr-ini.lua +++ b/tex/context/base/attr-ini.lua @@ -6,8 +6,6 @@ if not modules then modules = { } end modules ['attr-ini'] = { license = "see context related readme files" } -local commands, context, nodes, storage = commands, context, nodes, storage - local next, type = next, type --[[ldx-- @@ -15,10 +13,11 @@ local next, type = next, type symbolic names later on.

--ldx]]-- -attributes = attributes or { } -local attributes = attributes +attributes = attributes or { } + +local attributes, nodes = attributes, nodes -local sharedstorage = storage.shared +-- todo: local and then gobals ... first loaded anyway attributes.names = attributes.names or { } attributes.numbers = attributes.numbers or { } @@ -27,14 +26,15 @@ attributes.states = attributes.states or { } attributes.handlers = attributes.handlers or { } attributes.unsetvalue = -0x7FFFFFFF -local names = attributes.names -local numbers = attributes.numbers -local list = attributes.list +local names, numbers, list = attributes.names, attributes.numbers, attributes.list storage.register("attributes/names", names, "attributes.names") storage.register("attributes/numbers", numbers, "attributes.numbers") storage.register("attributes/list", list, "attributes.list") +names [0] = "fontdynamic" +numbers["fontdynamic"] = 0 + function attributes.define(name,number) -- at the tex end if not numbers[name] then numbers[name] = number @@ -43,19 +43,13 @@ function attributes.define(name,number) -- at the tex end end end ---[[ldx-- -

We reserve this one as we really want it to be always set (faster).

---ldx]]-- - -names[0], numbers["fontdynamic"] = "fontdynamic", 0 - --[[ldx--

We can use the attributes in the range 127-255 (outside user space). These are only used when no attribute is set at the \TEX\ end which normally happens in .

--ldx]]-- -sharedstorage.attributes_last_private = sharedstorage.attributes_last_private or 127 +storage.shared.attributes_last_private = storage.shared.attributes_last_private or 127 -- to be considered (so that we can use an array access): -- @@ -63,10 +57,10 @@ sharedstorage.attributes_last_private = sharedstorage.attributes_last_private or -- -- setmetatable(private, { -- __index = function(t,name) --- local number = sharedstorage.attributes_last_private +-- local number = storage.shared.attributes_last_private or 127 -- if number < 1023 then -- tex.count.minallocatedattribute - 1 -- number = number + 1 --- sharedstorage.attributes_last_private = number +-- storage.shared.attributes_last_private = number -- end -- numbers[name], names[number], list[number] = number, name, { } -- private[name] = number @@ -80,12 +74,12 @@ sharedstorage.attributes_last_private = sharedstorage.attributes_last_private or function attributes.private(name) -- at the lua end (hidden from user) local number = numbers[name] if not number then - local last = sharedstorage.attributes_last_private + local last = storage.shared.attributes_last_private or 127 if last < 1023 then -- tex.count.minallocatedattribute - 1 last = last + 1 - sharedstorage.attributes_last_private = last + storage.shared.attributes_last_private = last else - report_attribute("no more room for private attributes") + report_attribute("no more room for private attributes") -- fatal os.exit() end number = last @@ -94,7 +88,7 @@ function attributes.private(name) -- at the lua end (hidden from user) return number end --- tracers +-- new (actually a tracer) local report_attribute = logs.reporter("attributes") diff --git a/tex/context/base/attr-ini.mkiv b/tex/context/base/attr-ini.mkiv index 8a41dd427..a1550b4be 100644 --- a/tex/context/base/attr-ini.mkiv +++ b/tex/context/base/attr-ini.mkiv @@ -14,8 +14,8 @@ \writestatus{loading}{ConTeXt Attribute Macros / Initialization} %D Although it's still somewhat experimental, here we introduce code -%D related to attributes. Housekeeping will move completely to \LUA\ -%D and \type {\newattribute} will go away. +%D related to attributes. Housekeeping will move completely to Lua +%D and \newattribute will go away. \unprotect @@ -27,16 +27,14 @@ \unexpanded\def\pushattribute#1% {\global\advance\csname\??attributestack\string#1\endcsname\plusone - \expandafter\xdef\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname{\number\attribute#1}} + \global\expandafter\mathchardef\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname\attribute#1} \unexpanded\def\popattribute#1% - {\attribute#1\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname\relax + {\attribute#1\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname \global\advance\csname\??attributestack\string#1\endcsname\minusone} \unexpanded\def\installattributestack#1% - {\ifcsname\??attributestack\string#1\endcsname \else - \expandafter\newcount\csname\??attributestack\string#1\endcsname - \fi} + {\expandafter\newcount\csname\??attributestack\string#1\endcsname} \newtoks \attributesresetlist diff --git a/tex/context/base/attr-lay.lua b/tex/context/base/attr-lay.lua index 5e5e81ff1..bcdc541f7 100644 --- a/tex/context/base/attr-lay.lua +++ b/tex/context/base/attr-lay.lua @@ -10,15 +10,9 @@ if not modules then modules = { } end modules ['attr-lay'] = { -- but when we need it stacked layers might show up too; the next function based -- approach can be replaced by static (metatable driven) resolvers --- maybe use backends.registrations here too - local type = type local format = string.format -local insert, remove, concat = table.insert, table.remove, table.concat - -local attributes, nodes, utilities, logs, backends = attributes, nodes, utilities, logs, backends -local commands, context, interfaces = commands, context, interfaces -local tex = tex +local insert, remove = table.insert, table.remove local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex @@ -32,6 +26,8 @@ local report_viewerlayers = logs.reporter("viewerlayers") -- nb. too many "0 g"s -- nb: more local tables +local attributes, nodes = attributes, nodes + attributes.viewerlayers = attributes.viewerlayers or { } local viewerlayers = attributes.viewerlayers @@ -61,42 +57,22 @@ local texgetattribute = tex.getattribute local texsettokenlist = tex.settoks local unsetvalue = attributes.unsetvalue -local nodepool = nodes.pool - -local data = viewerlayers.data -local values = viewerlayers.values -local listwise = viewerlayers.listwise -local registered = viewerlayers.registered -local scopes = viewerlayers.scopes - -local template = "%s" +storage.register("attributes/viewerlayers/registered", viewerlayers.registered, "attributes.viewerlayers.registered") +storage.register("attributes/viewerlayers/values", viewerlayers.values, "attributes.viewerlayers.values") +storage.register("attributes/viewerlayers/scopes", viewerlayers.scopes, "attributes.viewerlayers.scopes") -storage.register("attributes/viewerlayers/registered", registered, "attributes.viewerlayers.registered") -storage.register("attributes/viewerlayers/values", values, "attributes.viewerlayers.values") -storage.register("attributes/viewerlayers/scopes", scopes, "attributes.viewerlayers.scopes") - -local layerstacker = utilities.stacker.new("layers") -- experiment - -layerstacker.mode = "stack" -layerstacker.unset = attributes.unsetvalue - -viewerlayers.resolve_begin = layerstacker.resolve_begin -viewerlayers.resolve_step = layerstacker.resolve_step -viewerlayers.resolve_end = layerstacker.resolve_end - -function commands.cleanuplayers() - layerstacker.clean() - -- todo -end +local data = viewerlayers.data +local values = viewerlayers.values +local listwise = viewerlayers.listwise +local registered = viewerlayers.registered +local scopes = viewerlayers.scopes +local template = "%s" -- stacked -local function startlayer(...) startlayer = nodeinjections.startlayer return startlayer(...) end -local function stoplayer (...) stoplayer = nodeinjections.stoplayer return stoplayer (...) end - local function extender(viewerlayers,key) if viewerlayers.supported and key == "none" then - local d = stoplayer() + local d = nodeinjections.stoplayer() viewerlayers.none = d return d end @@ -106,7 +82,7 @@ local function reviver(data,n) if viewerlayers.supported then local v = values[n] if v then - local d = startlayer(v) + local d = nodeinjections.startlayer(v) data[n] = d return d else @@ -115,14 +91,8 @@ local function reviver(data,n) end end -setmetatableindex(viewerlayers,extender) -setmetatableindex(viewerlayers.data,reviver) - --- !!!! TEST CODE !!!! - -layerstacker.start = function(...) local f = nodeinjections.startstackedlayer layerstacker.start = f return f(...) end -layerstacker.stop = function(...) local f = nodeinjections.stopstackedlayer layerstacker.stop = f return f(...) end -layerstacker.change = function(...) local f = nodeinjections.changestackedlayer layerstacker.change = f return f(...) end +setmetatableindex(viewerlayers, extender) +setmetatableindex(viewerlayers.data, reviver) local function initializer(...) return states.initialize(...) @@ -133,8 +103,7 @@ attributes.viewerlayers.handler = nodes.installattributehandler { namespace = viewerlayers, initializer = initializer, finalizer = states.finalize, - -- processor = states.stacked, - processor = states.stacker, + processor = states.stacked, } local stack, enabled, global = { }, false, false @@ -180,16 +149,12 @@ function viewerlayers.setfeatures(hasorder) viewerlayers.hasorder = hasorder end -local usestacker = true -- new, experimental - function viewerlayers.start(name) - local a - if usestacker then - a = layerstacker.push(register(name) or unsetvalue) - else - insert(stack,texgetattribute(a_viewerlayer)) - a = register(name) or unsetvalue - end +-- if not enabled then +-- viewerlayers.enable(true) +-- end + insert(stack,texgetattribute(a_viewerlayer)) + local a = register(name) or unsetvalue if global or scopes[name] == v_global then scopes[a] = v_global -- messy but we don't know the attributes yet texsetattribute("global",a_viewerlayer,a) @@ -200,21 +165,14 @@ function viewerlayers.start(name) end function viewerlayers.stop() - local a - if usestacker then - a = layerstacker.pop() - else - a = remove(stack) - end - if not a then - -- error - elseif a >= 0 then + local a = remove(stack) + if a >= 0 then if global or scopes[a] == v_global then texsetattribute("global",a_viewerlayer,a) else texsetattribute(a_viewerlayer,a) end - texsettokenlist("currentviewerlayertoks",values[a] or "") + texsettokenlist("currentviewerlayertoks",values[a]) else if global or scopes[a] == v_global then texsetattribute("global",a_viewerlayer,unsetvalue) @@ -239,9 +197,9 @@ function viewerlayers.define(settings) end end -commands.defineviewerlayer = viewerlayers.define -commands.startviewerlayer = viewerlayers.start -commands.stopviewerlayer = viewerlayers.stop +commands.defineviewerlayer = viewerlayers.define +commands.startviewerlayer = viewerlayers.start +commands.stopviewerlayer = viewerlayers.stop function commands.definedviewerlayer(settings) viewerlayers.define(settings) diff --git a/tex/context/base/attr-lay.mkiv b/tex/context/base/attr-lay.mkiv index 9c9c3318e..67cd204e2 100644 --- a/tex/context/base/attr-lay.mkiv +++ b/tex/context/base/attr-lay.mkiv @@ -13,51 +13,51 @@ \writestatus{loading}{ConTeXt Attribute Macros / Viewerlayers} -%D Currently there is a limitation in mixed inline usage. This has to do with the fact -%D that we have a stacked model but cannot determine where to revert to (as we can -%D have AABBCCAA ranges). Maybe I'll solve that one day. It only affects nested inline -%D layers and these make not much sense anyway. We'd have to store the complete nesting -%D stack in the attribute in order to be able to cross pages and that demands a new -%D mechanism. - \unprotect \registerctxluafile{attr-lay}{1.001} % needs to work over stopitemize grouping etc -\installcorenamespace{viewerlayer} - -\installcommandhandler \??viewerlayer {viewerlayer} \??viewerlayer +% \def\registerviewerlayer#1#2% global ! +% {\setxvalue{\??ql:#1}{\global\attribute\viewerlayerattribute\ctxlua{tex.write(attributes.viewerlayers.register('#2'))} }} +% +% \setevalue{\??ql:}{\global\attribute\viewerlayerattribute\attributeunsetvalue} -\setupviewerlayer +\getparameters + [\??lr] [\c!state=\v!start, \c!title=, \c!printable=\v!yes, \c!scope=\v!local, % maybe global but needs checking with layout \c!method=\v!none] -\appendtoks - \ctxcommand{defineviewerlayer{ - tag = "\currentviewerlayer", - title = "\viewerlayerparameter\c!title", - visible = "\viewerlayerparameter\c!state", - editable = "\v!yes", - printable = "\viewerlayerparameter\c!printable", - scope = "\viewerlayerparameter\c!scope" - }}% - \doif{\viewerlayerparameter\c!method}\v!command - {\setuxvalue{\e!start#1}{\startviewerlayer[\currentviewerlayer]}% - \setuxvalue{\e!stop #1}{\stopviewerlayer}}% -\to \everydefineviewerlayer - -\unexpanded\def\startviewerlayer[#1]{\ctxcommand{startviewerlayer("#1")}} % not grouped -\unexpanded\def\stopviewerlayer {\ctxcommand{stopviewerlayer()}} % not grouped +\def\defineviewerlayer + {\dodoubleargument\dodefineviewerlayer} + +\def\dodefineviewerlayer[#1][#2]% document wide properties + {\begingroup + \getparameters[\??lr][#2]% + \ctxcommand{defineviewerlayer{ + tag = "#1", + title = "\@@lrtitle", + visible = "\@@lrstate", + editable = "\v!yes", + printable = "\@@lrprintable", + scope = "\@@lrscope" + }}% + \doif\@@lrmethod\v!command + {\setugvalue{\e!start#1}{\startviewerlayer[#1]}% + \setugvalue{\e!stop #1}{\stopviewerlayer }}% + \endgroup} + +\unexpanded\def\startviewerlayer[#1]{\ctxcommand{startviewerlayer("#1")}} % not grouped +\unexpanded\def\stopviewerlayer {\ctxcommand{stopviewerlayer()}} % not grouped \unexpanded\def\viewerlayer [#1]{\groupedcommand{\startviewerlayer[#1]}{\stopviewerlayer}} % grouped % some day we will keep this at the lua end as the info is only needed there -\newtoks\currentviewerlayertoks % soon we can set macros at the lua end +\let\currentviewerlayer\empty \newtoks\currentviewerlayertoks % soon we can set macros at the lua end \def\currentviewerlayer{\the\currentviewerlayertoks} @@ -67,9 +67,7 @@ % layout components are implemented rather directly (speed) -\installcorenamespace{layoutcomponentattribute} - -\def\attr_layoutcomponent_initialize#1% +\def\doinitializelayoutcomponent#1% {\edef\layoutcomponentboxattribute{\ctxcommand{definedviewerlayer{% tag = "#1", title = utilities.strings.nice("#1"), % only here as in steps we have step: @@ -78,28 +76,24 @@ printable = "\v!yes" }}}% \edef\layoutcomponentboxattribute{attr \viewerlayerattribute \layoutcomponentboxattribute\relax}% - \expandafter\glet\csname\??layoutcomponentattribute#1\endcsname\layoutcomponentboxattribute} + \expandafter\glet\csname\??lr:a:#1\endcsname\layoutcomponentboxattribute} -\def\attr_layoutcomponent_set#1% make this faster - {\expandafter\let\expandafter\layoutcomponentboxattribute\csname\??layoutcomponentattribute#1\endcsname +\def\dosetlayoutcomponentattribute#1% make this faster + {\expandafter\let\expandafter\layoutcomponentboxattribute\csname\??lr:a:#1\endcsname \ifx\layoutcomponentboxattribute\relax - \attr_layoutcomponent_initialize{#1}% get rid of { } + \doinitializelayoutcomponent{#1}% get rid of { } \fi} -\def\attr_layoutcomponent_reset +\def\doresetlayoutcomponentattribute {\let\layoutcomponentboxattribute\empty} \let\setlayoutcomponentattribute \gobbleoneargument \let\resetlayoutcomponentattribute\relax \let\layoutcomponentboxattribute \empty -\unexpanded\def\showlayoutcomponents - {%\ctxlua{attributes.viewerlayers.enable()}% automatic - \let\setlayoutcomponentattribute \attr_layoutcomponent_set - \let\resetlayoutcomponentattribute\attr_layoutcomponent_reset} - -\appendtoks - \ctxcommand{cleanuplayers()}% -\to \everyshipout +\def\showlayoutcomponents + {\ctxlua{attributes.viewerlayers.enable()}% will go + \let\setlayoutcomponentattribute \dosetlayoutcomponentattribute + \let\resetlayoutcomponentattribute\doresetlayoutcomponentattribute} \protect \endinput diff --git a/tex/context/base/attr-neg.lua b/tex/context/base/attr-neg.lua index c32cec956..4d89cb49b 100644 --- a/tex/context/base/attr-neg.lua +++ b/tex/context/base/attr-neg.lua @@ -11,9 +11,8 @@ if not modules then modules = { } end modules ['attr-neg'] = { local format = string.format -local attributes, nodes, utilities, logs, backends = attributes, nodes, utilities, logs, backends -local commands, context, interfaces = commands, context, interfaces -local tex = tex + +local attributes, nodes = attributes, nodes local states = attributes.states local tasks = nodes.tasks diff --git a/tex/context/base/attr-neg.mkiv b/tex/context/base/attr-neg.mkiv index 102b220ba..0fc5070f1 100644 --- a/tex/context/base/attr-neg.mkiv +++ b/tex/context/base/attr-neg.mkiv @@ -19,12 +19,12 @@ % positive and negative are preregistered -\unexpanded\def\startnegative{\attr_trigger_negative\v!negative} -\unexpanded\def\stopnegative {\attr_trigger_negative\v!positive} +\def\dotriggernegative#1{\ctxcommand{triggernegative('#1')}} -\unexpanded\def\startpositive{\attr_trigger_negative\v!positive} -\unexpanded\def\stoppositive {\attr_trigger_negative\v!negative} +\unexpanded\def\startnegative{\dotriggernegative\v!negative} +\unexpanded\def\stopnegative {\dotriggernegative\v!positive} -\def\attr_trigger_negative#1{\ctxcommand{triggernegative('#1')}} +\unexpanded\def\startpositive{\dotriggernegative\v!positive} +\unexpanded\def\stoppositive {\dotriggernegative\v!negative} \protect \endinput diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index 46ce4f96c..3ce40a6c5 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -20,9 +20,8 @@ if not modules then modules = { } end modules ['back-exp'] = { local next, type = next, type local format, match, concat, rep, sub, gsub, gmatch, find = string.format, string.match, table.concat, string.rep, string.sub, string.gsub, string.gmatch, string.find -local validstring = string.valid local lpegmatch = lpeg.match -local utfchar, utfbyte = utf.char, utf.byte +local utfchar, utfbyte, utfsub, utfgsub = utf.char, utf.byte, utf.sub, utf.gsub local insert, remove = table.insert, table.remove local topoints = number.topoints local utfvalues = string.utfvalues @@ -155,8 +154,6 @@ local somespace = { [0x20] = true, [" "] = true } -- for testing local entities = { ["&"] = "&", [">"] = ">", ["<"] = "<" } local attribentities = { ["&"] = "&", [">"] = ">", ["<"] = "<", ['"'] = "quot;" } -local entityremapper = utf.remapper(entities) - local alignmapping = { flushright = "right", middle = "center", @@ -303,7 +300,7 @@ local usedstyles = { } local documenttemplate = [[ document { - font-size : %s !important ; + font-size : %s !important ; max-width : %s !important ; text-align : %s !important ; hyphens : %s !important ; @@ -385,7 +382,7 @@ local function allusedimages(xmlfile) for element, details in sortedhash(usedimages) do for detail, data in sortedhash(details) do local name = data.name - if file.suffix(name) == "pdf" then + if file.extname(name) == "pdf" then -- temp hack .. we will have a remapper name = file.replacesuffix(name,"svg") end @@ -400,7 +397,7 @@ local function uniqueusedimages() for element, details in next, usedimages do for detail, data in next, details do local name = data.name - if file.suffix(name) == "pdf" then + if file.extname(name) == "pdf" then unique[file.replacesuffix(name,"svg")] = name else unique[name] = name @@ -1354,7 +1351,7 @@ local function begintag(result,element,nature,depth,di,skip) end result[#result+1] = format("%s\n",spaces[depth]) for k, v in table.sortedpairs(metadata) do - v = entityremapper(v) + v = utfgsub(v,".",entities) result[#result+1] = format("%s%s\n",spaces[depth+1],k,v) end result[#result+1] = format("%s\n",spaces[depth]) @@ -1412,7 +1409,7 @@ local function flushtree(result,data,nature,depth) -- whatever elseif di.content then -- already has breaks - local content = entityremapper(di.content) + local content = utfgsub(di.content,".",entities) if i == nofdata and sub(content,-1) == "\n" then -- move check -- can be an end of line in par but can also be the last line if trace_spacing then @@ -2365,21 +2362,12 @@ local function stopexport(v) report_export("saving xhtml variant in '%s",xhtmlfile) local xmltree = cleanxhtmltree(xml.convert(results)) xml.save(xmltree,xhtmlfile) - -- looking at identity is somewhat redundant as we also inherit from interaction - -- at the tex end - local identity = interactions.general.getidentity() local specification = { name = file.removesuffix(v), identifier = os.uuid(), images = uniqueusedimages(), root = xhtmlfile, files = files, - language = languagenames[tex.count.mainlanguagenumber], - title = validstring(finetuning.title) or validstring(identity.title), - subtitle = validstring(finetuning.subtitle) or validstring(identity.subtitle), - author = validstring(finetuning.author) or validstring(identity.author), - firstpage = validstring(finetuning.firstpage), - lastpage = validstring(finetuning.lastpage), } report_export("saving specification in '%s' (mtxrun --script epub --make %s)",specificationfilename,specificationfilename) io.savedata(specificationfilename,table.serialize(specification,true)) diff --git a/tex/context/base/back-exp.mkiv b/tex/context/base/back-exp.mkiv index 9e65633d4..871d08b19 100644 --- a/tex/context/base/back-exp.mkiv +++ b/tex/context/base/back-exp.mkiv @@ -132,11 +132,6 @@ [\c!align=\number\raggedstatus, \c!bodyfont=\bodyfontsize, \c!width=\textwidth, - \c!title={\directinteractionparameter\c!title}, - \c!subtitle={\directinteractionparameter\c!subtitle}, - \c!author={\directinteractionparameter\c!author}, - % \c!firstpage=, % imagename - % \c!lastpage=, % imagename \c!hyphen=\v!no] \def\dosynchronizeexport @@ -146,21 +141,12 @@ bodyfont = \number\dimexpr\exportparameter\c!bodyfont, width = \number\dimexpr\exportparameter\c!width, hyphen = "\exportparameter\c!hyphen", - title = \!!bs\exportparameter\c!title\!!es, - subtitle = \!!bs\exportparameter\c!subtitle\!!es, - author = \!!bs\exportparameter\c!author\!!es, - firstpage = "\exportparameter\c!firstpage", - lastpage = "\exportparameter\c!lastpage", }}} \appendtoks - \doifsomething{\backendparameter\c!export}\dosynchronizeexport + \doifsomething{\backendparameter\c!export}{\dosynchronizeexport}% \to \everystarttext -\appendtoks - \doifsomething{\backendparameter\c!export}\dosynchronizeexport % in case it is done inside \starttext -\to \everysetupdocument - \appendtoks \doifsomething{\backendparameter\c!xhtml} {\enabledirectives[backend.export.xhtml=\backendparameter\c!xhtml]}% @@ -169,11 +155,11 @@ \to \everysetupbackend \appendtoks - \doifelsenothing{\backendparameter\c!export} - {\resetsystemmode\v!export} - {\setuptagging[\c!state=\v!start]% - \enabledirectives[backend.export=\backendparameter\c!export]% - \setsystemmode\v!export}% + \doifsomething{\backendparameter\c!export} + {\setuptagging + [\c!state=\v!start]% + \enabledirectives + [backend.export=\backendparameter\c!export]}% \to \everysetupbackend \protect \endinput diff --git a/tex/context/base/back-ini.lua b/tex/context/base/back-ini.lua index f76b85438..0c02e201a 100644 --- a/tex/context/base/back-ini.lua +++ b/tex/context/base/back-ini.lua @@ -93,9 +93,9 @@ tables.vfspecials = allocate { stopslant = comment, } --- experimental code -- +-- -- experimental code -- -function commands.pdfrotation(a) -- somewhat weird here +function commands.pdfrotation(a) local s, c = sind(a), cosd(a) context("%s %s %s %s",c,s,-s,c) end diff --git a/tex/context/base/back-ini.mkiv b/tex/context/base/back-ini.mkiv index fc8759c14..8ece8f6e1 100644 --- a/tex/context/base/back-ini.mkiv +++ b/tex/context/base/back-ini.mkiv @@ -61,13 +61,13 @@ \let \dotransformnextbox\gobblesixarguments % and pass last box %D \macros -%D {back_ovalbox} +%D {doovalbox} %D %D When we look at the implementation, this is a complicated %D one. There are seven arguments. %D %D \starttyping -%D \back_ovalbox {w} {h} {d} {linewidth} {radius} {stroke} {fill} {variant} +%D \doovalbox {w} {h} {d} {linewidth} {radius} {stroke} {fill} {variant} %D \stoptyping %D %D This command has to return a \type{\vbox} which can be used @@ -75,7 +75,7 @@ %D degrees, the stroke and fill are~\type{1} (true) of~\type{0} %D (false). -\let\back_ovalbox \gobbleeightarguments +\let \doovalbox \gobbleeightarguments %D \macros %D {dostartclipping,dostopclipping} diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv index 7e910f07f..9e441e224 100644 --- a/tex/context/base/back-pdf.mkiv +++ b/tex/context/base/back-pdf.mkiv @@ -68,17 +68,16 @@ {\ctxcommand{setxmpfile("\backendparameter{xmpfile}")}}% \to \everysetupbackend -% \doifsomething{\backendparameter\c!format} .. at the lua end - \appendtoks - \ctxcommand{setformat { + \doifsomething{\backendparameter\c!format} + {\ctxcommand{setformat { format = "\backendparameter\c!format", level = "\backendparameter\c!level", option = "\backendparameter\c!option", profile = "\backendparameter\c!profile", intent = "\backendparameter\c!intent", file = "\backendparameter\c!file", - }}% + }}}% \to \everysetupbackend %D For the moment we keep these. @@ -221,12 +220,12 @@ \newbox\objectbox -\unexpanded\def\dostartobject#1#2#3#4#5% needs to be \unexpanded +\def\dostartobject#1#2#3#4#5% {\bgroup \setbox\objectbox\vbox\bgroup \def\back_object_stop{\egroup\back_object_register{#1}{#2}}} -\unexpanded\def\dostopobject % needs to be \unexpanded +\def\dostopobject {\back_object_stop \egroup} @@ -238,6 +237,9 @@ \immediate\pdfxform resources {\pdfbackendcurrentresources}\objectbox \dosetobjectreference{#1}{#2}{\the\pdflastxform}} +\def\doresetobjects + {} + \let\m_back_object_reference\empty \def\doinsertobject#1#2% @@ -261,7 +263,7 @@ % for the moment here %D \macros -%D {back_ovalbox} +%D {doovalbox} %D %D Drawing frames with round corners is inherited from the %D main module. @@ -274,7 +276,7 @@ % \def\back_oval_calculate#1#2#3% % {\PointsToBigPoints{\dimexpr#2+#3\relax}#1} -\unexpanded\def\back_ovalbox#1#2#3#4#5#6#7#8% +\unexpanded\def\doovalbox#1#2#3#4#5#6#7#8% {\forcecolorhack \bgroup % \scratchdimen#4% @@ -304,16 +306,16 @@ \PointsToBigPoints{\dimexpr #2-\scratchdimen}\yymax \PointsToBigPoints{\dimexpr-#3+\scratchdimen}\yymin % - \edef\dostroke{\number#6}% - \edef\dofill{\number#7}% - \edef\mode{\number#8}% + \edef\dostroke{#6}% + \edef\dofill{#7}% + \edef\mode{\number#8 \space}% % no \ifcase, else \relax in pdfcode \setbox\scratchbox\hbox {\ifnum\dostroke\dofill>\zerocount \pdfliteral {q \stroke\space w - \ifcase\mode\space + \ifcase\mode \xxmin\space \ymin \space m \xxmax\space \ymin \space l \xmax \space \ymin \space \xmax \space \yymin\space y @@ -493,7 +495,7 @@ \xmin \space \ymin \space \xmin \space \yymin\space y \or % 28 \fi - \ifnum\mode>8\space + \ifnum\mode>8 S \else \ifnum\dostroke=\plusone S \fi diff --git a/tex/context/base/back-swf.mkiv b/tex/context/base/back-swf.mkiv index 09745e0f9..1d225b550 100644 --- a/tex/context/base/back-swf.mkiv +++ b/tex/context/base/back-swf.mkiv @@ -11,12 +11,12 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D This is only a placeholder that demonstrates the usage of swf resources. -%D There is no need to include this file into the format. The module was -%D tested by Luigi and Willi and based on their suggestions the functionality -%D was improved. -%D +% This is only a placeholder that demonstrates the usage of swf +% resources. + %D \starttyping +%D \starttext +%D %D \enabletrackers[graphics.locating] %D \enabletrackers[backend.swf] %D @@ -41,6 +41,8 @@ %D \stopTEXpage %D \stoptyping +\stoptext + \endinput \starttext @@ -70,6 +72,8 @@ }, \stopluaparameterset +\starttext + % preview=swf:myset:display:1 % controls=swf:myset:controls:1 % resources=swf:myset:resources:1 diff --git a/tex/context/base/back-u3d.mkiv b/tex/context/base/back-u3d.mkiv index 89d26ee41..dfe8a90c2 100644 --- a/tex/context/base/back-u3d.mkiv +++ b/tex/context/base/back-u3d.mkiv @@ -11,9 +11,10 @@ %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. +% This is only a placeholder that demonstrates the usage of u3d +% resources. The user interface is rather messy an might be +% improved. The files and setup is derived from an example by +% Michael Vidiassov. \endinput diff --git a/tex/context/base/bibl-bib.mkiv b/tex/context/base/bibl-bib.mkiv index 7ca6799cf..56007d21c 100644 --- a/tex/context/base/bibl-bib.mkiv +++ b/tex/context/base/bibl-bib.mkiv @@ -626,7 +626,7 @@ \doifelse{\bibtexpublicationsparameter\c!method}\v!local {\ctxlua{bibtex.hacks.reset(1)}}% function can take method {\ctxlua{bibtex.hacks.reset(2)}}% - \strc_lists_place_current + \doplacestructurelist {\currentbibtexsession} {\currentbibtexcriterium} {\namedlistparameter\currentbibtexsession\c!number}% diff --git a/tex/context/base/bibl-tra.lua b/tex/context/base/bibl-tra.lua index ca6403c44..6341898ee 100644 --- a/tex/context/base/bibl-tra.lua +++ b/tex/context/base/bibl-tra.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['bibl-tra'] = { +if not modules then modules = { } end modules ['bibl-bib'] = { version = 1.001, comment = "this module is the basis for the lxml-* ones", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -115,7 +115,7 @@ function hacks.registerplaced(str) end function hacks.doifalreadyplaced(str) - commands.doifelse(used[str]) + commands.testcase(used[str]) end -- we ask for :tag but when we can't find it we go back diff --git a/tex/context/base/bibl-tra.mkiv b/tex/context/base/bibl-tra.mkiv index 08d8eb6fe..3531703ad 100644 --- a/tex/context/base/bibl-tra.mkiv +++ b/tex/context/base/bibl-tra.mkiv @@ -755,7 +755,7 @@ \ctxlua{bibtex.hacks.filterall()}} {\doif{\listparameter\c!criterium}\v!cite {\setuplist[pubs][\c!criterium=\v!here]}% - \strc_lists_place_current + \doplacestructurelist {pubs}% {\listparameter\c!criterium}% {\listparameter\c!number}% @@ -1244,7 +1244,7 @@ %D \type{\ixbibauthoryearref} stores the data in the macros %D \type{\currentbibauthor} and \type{\currentbibyear}. -\def\doifbibinteractionelse +\def\ifbibinteractionelse {\iflocation \edef\test{\bibalternative\c!interaction}% \ifx\test\v!stop @@ -1256,11 +1256,20 @@ \@EA\secondoftwoarguments \fi} +\def\ifbibinteractionelse + {\iflocation + \doifelse{\bibalternative\c!interaction}\v!stop + {\@EA\secondoftwoarguments} + {\@EA\firstoftwoarguments}% + \else + \@EA\secondoftwoarguments + \fi} + \def\bibmaybeinteractive#1#2% {\ifbibcitecompress #2% \else - \doifbibinteractionelse{\gotobiblink{#2}[#1]}{#2}% + \ifbibinteractionelse{\gotobiblink{#2}[#1]}{#2}% \fi} \def\bibauthoryearref[#1]% @@ -1351,7 +1360,7 @@ \gotobiblink{#1}[#1]} \def\bibgotoDOI#1#2% - {\doifbibinteractionelse + {\ifbibinteractionelse {\useURL[bibfooDoi#1][#2]% \useURL[bibfoo#1][http://dx.doi.org/#2]% \goto{\url[bibfooDoi#1]}[url(bibfoo#1)]} @@ -1374,7 +1383,7 @@ \bibalternative\v!right} \def\bibgotoURL#1#2% - {\doifbibinteractionelse + {\ifbibinteractionelse {\useURL[bibfoo#1][#2]\goto{\url[bibfoo#1]}[url(bibfoo#1)]} {\hyphenatedurl{#2}}} @@ -1402,7 +1411,7 @@ \def\dobibpageref#1% {\bibinsertrefsep - \doifbibinteractionelse + \ifbibinteractionelse {\atbiblink[#1]} {{\referencingfalse\at[#1]}}} @@ -1475,6 +1484,8 @@ %D And some defaults are loaded from bibl-apa: +\def\c!monthconversion{monthconversion} % todo + \setuppublications [\c!monthconversion=, \c!alternative=apa, @@ -1491,6 +1502,4 @@ % \appendtoks \preloadbiblist \to \everysetuppublications % \appendtoks \preloadbiblist \to \everystarttext -\let\ifbibinteractionelse\doifbibinteractionelse - \protect \endinput diff --git a/tex/context/base/blob-ini.lua b/tex/context/base/blob-ini.lua index 4debaf94c..b97485b1b 100644 --- a/tex/context/base/blob-ini.lua +++ b/tex/context/base/blob-ini.lua @@ -74,7 +74,7 @@ function blobs.dispose(t) end end -function blobs.append(t,str) -- compare concat and link +function blobs.append(t,str) -- will be link nodes.link local typ = type(str) local dummy = nil if typ == "number" then diff --git a/tex/context/base/buff-ini.lua b/tex/context/base/buff-ini.lua index 11d7cc9f6..7098679ca 100644 --- a/tex/context/base/buff-ini.lua +++ b/tex/context/base/buff-ini.lua @@ -13,23 +13,21 @@ local trace_visualize = false trackers.register("buffers.visualize", function(v local report_buffers = logs.reporter("buffers","usage") local report_grabbing = logs.reporter("buffers","grabbing") -local context, commands = context, commands - local concat = table.concat local type, next = type, next local sub, format, match, find = string.sub, string.format, string.match, string.find -local count, splitlines, validstring = string.count, string.splitlines, string.valid +local count, splitlines = string.count, string.splitlines -local variables = interfaces.variables +local variables = interfaces.variables local settings_to_array = utilities.parsers.settings_to_array -local catcodenumbers = catcodes.numbers +local ctxcatcodes = tex.ctxcatcodes +local txtcatcodes = tex.txtcatcodes -local ctxcatcodes = catcodenumbers.ctxcatcodes -local txtcatcodes = catcodenumbers.txtcatcodes +buffers = { } -buffers = buffers or { } local buffers = buffers +local context = context local cache = { } @@ -102,17 +100,14 @@ commands.assignbuffer = assign local P, patterns, lpegmatch = lpeg.P, lpeg.patterns, lpeg.match -local anything = patterns.anything -local alwaysmatched = patterns.alwaysmatched - local function countnesting(b,e) local n local g = P(b) / function() n = n + 1 end + P(e) / function() n = n - 1 end - + anything - local p = alwaysmatched / function() n = 0 end + + patterns.anything + local p = patterns.alwaysmatched / function() n = 0 end * g^0 - * alwaysmatched / function() return n end + * patterns.alwaysmatched / function() return n end return p end @@ -155,10 +150,12 @@ function commands.grabbuffer(name,begintag,endtag,bufferdata,catcodes) -- maybe else if continue then dn = dn .. sub(bufferdata,2,-2) -- no \r, \n is more generic - elseif dn == "" then - dn = sub(bufferdata,2,-2) else - dn = dn .. "\n" .. sub(bufferdata,2,-2) -- no \r, \n is more generic + if dn == "" then + dn = sub(bufferdata,2,-2) + else + dn = dn .. "\n" .. sub(bufferdata,2,-2) -- no \r, \n is more generic + end end local last = sub(dn,-1) if last == "\n" or last == "\r" then -- \n is unlikely as \r is the endlinechar @@ -187,7 +184,7 @@ function commands.grabbuffer(name,begintag,endtag,bufferdata,catcodes) -- maybe end end assign(name,dn,catcodes) - commands.doifelse(more) + commands.testcase(more) end -- The optional prefix hack is there for the typesetbuffer feature and @@ -235,12 +232,12 @@ end function commands.getbuffer(name) local str = getcontent(name) if str ~= "" then - context.viafile(str,format("buffer.%s",validstring(name,"noname"))) + context.viafile(str) end end function commands.getbuffermkvi(name) -- rather direct ! - context.viafile(resolvers.macros.preprocessed(getcontent(name)),format("buffer.%s.mkiv",validstring(name,"noname"))) + context.viafile(resolvers.macros.preprocessed(getcontent(name))) end function commands.gettexbuffer(name) @@ -268,7 +265,7 @@ function commands.getbufferctxlua(name) end function commands.doifelsebuffer(name) - commands.doifelse(exists(name)) + commands.testcase(exists(name)) end -- This only used for mp buffers and is a kludge. Don't change the diff --git a/tex/context/base/buff-ini.mkiv b/tex/context/base/buff-ini.mkiv index 5f9d1d1e6..239a274c0 100644 --- a/tex/context/base/buff-ini.mkiv +++ b/tex/context/base/buff-ini.mkiv @@ -199,28 +199,4 @@ \def\getbufferdata[#1]{\buff_get_stored_indeed{#1}} -%D This is a weird one, moved from cont-new. Do we really need it? If not -%D it will go away. - -\bgroup \permitcircumflexescape - -\obeylines % don't remove %'s ! - -\gdef\collapsedspace#1% - {\ifx#1^^M% - \expandafter\collapsedspace - \else - \space - \expandafter#1% - \fi} - -\unexpanded\gdef\collapsespaces - {\prependtoksonce\relax\to\everyeof% - \ignorelines% - \ignoretabs% - \let\obeyedspace\collapsedspace% - \obeyspaces} - -\egroup - \protect \endinput diff --git a/tex/context/base/buff-par.lua b/tex/context/base/buff-par.lua index 29742f497..2015b0bc0 100644 --- a/tex/context/base/buff-par.lua +++ b/tex/context/base/buff-par.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['buff-par'] = { +if not modules then modules = { } end modules ['buff-ini'] = { version = 1.001, comment = "companion to buff-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -6,26 +6,21 @@ if not modules then modules = { } end modules ['buff-par'] = { license = "see context related readme files" } -local context, commands = context, commands - -local insert, remove, find, gmatch = table.insert, table.remove, string.find, string.gmatch -local strip, format = string.strip, string.format - -local trace_parallel = false trackers.register("buffers.parallel", function(v) trace_parallel = v end) +local trace_parallel = false trackers.register("buffers.parallel", function(v) trace_parallel = v end) local report_parallel = logs.reporter("buffers","parallel") -local variables = interfaces.variables +local insert, remove, find, gmatch = table.insert, table.remove, string.find, string.gmatch +local strip, format = string.strip, string.format -local parallel = buffers.parallel or { } -buffers.parallel = parallel +local variables = interfaces.variables -local settings_to_array = utilities.parsers.settings_to_array +buffers.parallel = { } local parallel = buffers.parallel -local data = { } +local data = { } function parallel.define(category,tags) - local tags = settings_to_array(tags) + local tags = utilities.parsers.settings_to_array(tags) local entries = { } data[category] = { tags = tags, @@ -43,7 +38,7 @@ function parallel.reset(category,tags) if not tags or tags == "" or tags == variables.all then tags = table.keys(entries) else - tags = settings_to_array(tags) + tags = utilities.parsers.settings_to_array(tags) end for i=1,#tags do entries[tags[i]] = { @@ -81,7 +76,7 @@ function parallel.save(category,tag,content) end -- maybe no strip -- use lpeg - if find(content,"%s*%[") then + if find(content,"^%s*%[") then local done = false for label, content in gmatch(content,"%s*%[(.-)%]%s*([^%[]+)") do if done then @@ -180,5 +175,5 @@ commands.placeparallel = parallel.place commands.resetparallel = parallel.reset function commands.doifelseparallel(category,tags) - commands.doifelse(parallel.hassomecontent(category,tags)) + commands.testcase(parallel.hassomecontent(category,tags)) end diff --git a/tex/context/base/buff-par.mkiv b/tex/context/base/buff-par.mkiv new file mode 100644 index 000000000..7d35676bd --- /dev/null +++ b/tex/context/base/buff-par.mkiv @@ -0,0 +1,151 @@ +%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}{1.001} + +%D This module is developped for Thomas Schmitz as part of +%D a project. + +\unprotect + +\letvalue{\??px:}\empty + +\def\parallelparameter#1% + {\csname\??px:% + \ifcsname\??px:\currentparallel:\currentparallelinstance:#1\endcsname + \currentparallel:\currentparallelinstance:#1% + \else\ifcsname\??px:\currentparallel:#1\endcsname + \currentparallel:#1% + \else\ifcsname\??px:#1\endcsname + #1% + \fi\fi\fi + \endcsname} + +\unexpanded\def\defineparallel + {\dodoubleargument\dodefineparallel} + +\def\dodefineparallel[#1][#2]% + {\ctxcommand{defineparallel("#1","#2")}% + \processcommalist[#2]\dododefineparallel + \setuvalue{\e!start#1}{\dostartparallelset{#1}}% + \setuvalue{\e!stop #1}{\dostopparallelset}} + +\def\dododefineparallel#1% + {\definebuffer[#1]%% + \setuvalue{\e!stop#1}{\dowithparallel{#1}}} + +\def\dostartparallelset#1% + {\def\currentparallel{#1}% + \ctxcommand{nextparallel("\currentparallel")}} + +\def\dostopparallelset#1% + {} + +\def\dowithparallel#1% defined moet ook aan de lua kant kunnen + {\ctxcommand{saveparallel("\currentparallel","#1",buffers.raw("\thedefinedbuffer{#1}"))}} + +\unexpanded\def\placeparallel + {\dotripleempty\doplaceparallel} + +\def\doplaceparallel[#1][#2][#3]% + {\begingroup + \def\currentparallel{#1}% + \ctxcommand{placeparallel("\currentparallel","#2","#3")}% + \endgroup} + +% was: \parallelparameter\c!command} + +\def\doflushparallel#1#2#3#4#5% {instance}{status}{line}{label}{content} + {\begingroup + \def\currentparallelinstance{#1}% + \def\currentparallelnumber {#2}% + \def\currentparallelline {#3}% + \def\currentparallellabel {#4}% + \def\currentparallelcontent {#5}% + \ifcase#2\relax + \expandafter\noflushparalleldefault + \or + \expandafter\doflushparalleldefault + \fi + \endgroup} + +\def\noflushparalleldefault{} +\def\doflushparalleldefault{\directsetup{\parallelparameter\c!setups}} + +\startsetups parallel:place:default + \hangafter\plusone + \hangindent4em + \dontleavehmode + \hbox to 3em \bgroup + \hss + \bf + \doifsomething \currentparallellabel { + \textreference[\currentparallellabel]{\currentparallelline} + } + \currentparallelline + \quad + \egroup + \currentparallelcontent + \par +\stopsetups + +\unexpanded\def\setupparallel + {\dotripleempty\dosetupparallel} + +\def\dosetupparallel[#1][#2][#3]% + {\ifthirdargument + \getparameters[\??px:#1:#2:][#3]% + \else\ifsecondargument + \getparameters[\??px:#1:][#2]% + \else + \getparameters[\??px:][#1]% maybe no : here + \fi\fi} + +\setupparallel +% [\c!command=\doflushparalleldefault] + [\c!setups=parallel:place:default] + +\def\doifelseparallel#1#2% + {\cldcontext{commands.doifelseparallel("#1","#2")}} + +\def\resetparallel + {\dodoubleempty\doresetparallel} + +\def\resetparallel[#1][#2]% + {\ctxcommand{resetparallel("#1","#2"))}} + +% default + +% \def\doflushparalleldefault#1#2#3#4% todo: setups instead +% {\ifcase#1\or +% \begingroup +% \hangafter1 +% \hangindent4em +% \dontleavehmode +% \hbox to 3em{\hss\bf\doifsomething{#3}{\textreference[#3]{#2}}#2\quad}#4\par +% \endgroup +% \fi} + +\protect \endinput + +% \def\dododefineparallel#1% +% {\setuvalue{\e!stop #1}{}% +% \setuvalue{\e!start#1}{\dostartparallel{#1}}} +% +% \def\dostartparallel#1% +% {\grabuntil{\e!stop#1}{\dododostartparallel{#1}}} +% +% \def\dododostartparallel#1#2% +% {\ctxcommand{saveparallel("\currentparallel","#1",\!!bs\detokenize{#2}\!!es)}} diff --git a/tex/context/base/buff-par.mkvi b/tex/context/base/buff-par.mkvi deleted file mode 100644 index 404fa8ef3..000000000 --- a/tex/context/base/buff-par.mkvi +++ /dev/null @@ -1,131 +0,0 @@ -%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}{1.001} - -%D This module is developped for Thomas Schmitz as part of a project. There is -%D no documentation yet. -%D -%D \starttyping -%D \defineparallel[main][one,two] -%D -%D \startmain -%D \startone -%D first 1 -%D [reference] first 2 -%D first 3 -%D \stopone -%D \starttwo -%D second 1 -%D \stoptwo -%D \stopmain -%D -%D \placeparallel[main][one,two][criterium=all] - -%D criterium=all start= n= - -\unprotect - -\installcorenamespace{parallel} - -\installcommandhandler \??parallel {parallel} \??parallel - -\setupparallel - [\c!setups=parallel:place:default] - -\let\buff_parallel_define_saved\defineparallel - -\unexpanded\def\defineparallel - {\dodoubleargument\buff_parallel_define} - -\def\buff_parallel_define[#name][#instances]% - {\buff_parallel_define_saved[#name] - \ctxcommand{defineparallel("#name","#instances")}% - \processcommalist[#instances]\buff_parallel_define_instance - \setuevalue{\e!start#name}{\buff_parallel_start{#name}}% - \setuevalue{\e!stop #name}{\buff_parallel_stop}} - -\def\buff_parallel_define_instance#instance% - {\normalexpanded{\buff_parallel_define_saved[#instance][\currentparallel]}% - \definebuffer[#instance]% - \setuevalue{\e!stop#instance}{\buff_parallel_save{#instance}}} - -\unexpanded\def\buff_parallel_start#name% - {\pushmacro\currentparallel - \edef\currentparallel{#name}% - \ctxcommand{nextparallel("\currentparallel")}} - -\unexpanded\def\buff_parallel_stop - {\popmacro\currentparallel} - -\unexpanded\def\buff_parallel_save#instance% defined moet ook aan de lua kant kunnen - {\ctxcommand{saveparallel("\currentparallel","#instance",buffers.raw("\thedefinedbuffer{#instance}"))}} - -\unexpanded\def\placeparallel - {\dotripleempty\buff_parallel_place} - -\def\buff_parallel_place[#name][#instance][#settings]% - {\begingroup - \edef\currentparallel{#name}% - \ctxcommand{placeparallel("\currentparallel","#instance","#settings")}% -- todo: pass options as k/v - \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}% - \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\currentparallelinstance\c!setups}} - -\unexpanded\def\doifelseparallel#name#instance% - {\ctxcommand{doifelseparallel("#name","#instance")}} - -\unexpanded\def\resetparallel - {\dodoubleempty\buff_parallel_reset} - -\def\buff_parallel_reset[#name][#instance]% - {\ctxcommand{resetparallel("#name","#instance"))}} - -\startsetups parallel:place:default - \hangafter\plusone - \hangindent4em - \dontleavehmode - \hbox to 3em \bgroup - \hss - \bf - \doifsomething \currentparallellabel { - \textreference[\currentparallellabel]{\currentparallelline} - } - \currentparallelline - \quad - \egroup - \currentparallelcontent - \par -\stopsetups - -\protect \endinput diff --git a/tex/context/base/buff-ver.lua b/tex/context/base/buff-ver.lua index 5748d9298..004d89858 100644 --- a/tex/context/base/buff-ver.lua +++ b/tex/context/base/buff-ver.lua @@ -18,8 +18,6 @@ local concat = table.concat local C, P, R, S, V, Carg, Cc, Cs = lpeg.C, lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.Carg, lpeg.Cc, lpeg.Cs local patterns, lpegmatch, is_lpeg = lpeg.patterns, lpeg.match, lpeg.is_lpeg -local context, commands = context, commands - local trace_visualize = false trackers.register("buffers.visualize", function(v) trace_visualize = v end) local report_visualizers = logs.reporter("buffers","visualizers") @@ -32,6 +30,7 @@ visualizers.specifications = specifications local tabtospace = utilities.strings.tabtospace local variables = interfaces.variables local settings_to_array = utilities.parsers.settings_to_array +local verbatim = context.verbatim local variables = interfaces.variables local findfile = resolvers.findfile local addsuffix = file.addsuffix @@ -53,7 +52,6 @@ local dodisplayverbatimemptyline = context.dodisplayverbatimemptyline local dodisplayverbatimstart = context.dodisplayverbatimstart local dodisplayverbatimstop = context.dodisplayverbatimstop -local verbatim = context.verbatim local doverbatimspace = context.doverbatimspace local CargOne = Carg(1) @@ -690,7 +688,7 @@ local getlines = buffers.getlines -- interface function commands.doifelsevisualizer(name) - commands.doifelse(specifications[lower(name)]) + commands.testcase(specifications[lower(name)]) end commands.loadvisualizer = visualizers.load diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv index d18883faf..5336c4458 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -70,22 +70,21 @@ \csname\??typingspace\typeparameter\c!space\endcsname \relax\the\everyinitializeverbatim\relax} -\unexpanded\def\doinitializeverbatim % for use elsewhere .. temp hack (see lxml-ini) - {\buff_verbatim_initialize_type_one - \buff_verbatim_initialize_type_two} - \let\buff_verbatim_set_line_margin\relax \def\buff_verbatim_set_line_margin_indeed - {\hskip\doifoddpageelse{\typingparameter\c!oddmargin}{\typingparameter\c!evenmargin}\relax} + {\getpagestatus + \hskip\ifrightpage\typingparameter\c!oddmargin\else\typingparameter\c!evenmargin\fi\relax} \def\buff_verbatim_check_margins {\scratchskip\typingparameter\c!oddmargin\relax - \ifzeropt\scratchskip \else + \ifzeropt\scratchskip + \else \let\buff_verbatim_set_line_margin\buff_verbatim_set_line_margin_indeed \fi \scratchskip\typingparameter\c!evenmargin\relax - \ifzeropt\scratchskip \else + \ifzeropt\scratchskip + \else \let\buff_verbatim_set_line_margin\buff_verbatim_set_line_margin_indeed \fi \ifx\buff_verbatim_set_line_margin\relax @@ -332,7 +331,7 @@ \unexpanded\def\specialfixedspace {\kern\interwordspace\relax} \unexpanded\def\specialobeyedspace {\hskip\interwordspace\relax} % better than spaceskip -\unexpanded\def\specialstretchedspace{\hskip.5\interwordspace\s!plus.125\interwordstretch\relax} % more but not less +\unexpanded\def\specialstretchedspace{\hskip.5\interwordspace\!!plus.125\interwordstretch\relax} % more but not less \unexpanded\def\specialcontrolspace {\hskip\zeropoint\hbox{\normalcontrolspace}\hskip\zeropoint\relax} \unexpanded\def\obeyhyphens @@ -370,7 +369,7 @@ \let\inlinemathmarker \textdollar \def\displaymathmarker{\textdollar\textdollar} -\def\buff_verbatim_special_type#1#2#% # gobbles spaces +\def\buff_verbatim_special_type#1#2% {\dontleavehmode\bgroup \buff_verbatim_initialize_type_one \catcode\leftbraceasciicode \begingroupcatcode @@ -391,8 +390,6 @@ \unexpanded\def\astype{\bgroup\usetypestyleandcolor\c!style\c!color\let\nexttoken} -\unexpanded\def\asciistr#1{\dontleavehmode{\verbatimfont\detokenize{#1}}} % use in some old styles - %D The basic display verbatim commands are defined in an indirect way. As we %D will see, they are a specific case of a more general mechanism. @@ -644,9 +641,9 @@ \c!text=\v!no, \c!style=\tt, \c!indentnext=\v!yes, - \c!margin=\zeropoint, - \c!evenmargin=\zeropoint, - \c!oddmargin=\zeropoint, + \c!margin=\!!zeropoint, + \c!evenmargin=\!!zeropoint, + \c!oddmargin=\!!zeropoint, \c!blank=\v!line, %\c!escape=, % yes | no | {START,STOP} | default when yes: {BTEX,ETEX} \c!numbering=\v!no, @@ -839,9 +836,4 @@ % \usevisualizerstyleandcolor\c!style\c!color % \let\next} -\appendtoks - \def\type#1{\letterbackslash\checkedstrippedcsname#1}% or maybe detokenize - \def\tex #1{\letterbackslash#1}% -\to \everysimplifycommands - \protect \endinput diff --git a/tex/context/base/catc-ctx.mkiv b/tex/context/base/catc-ctx.mkiv index ddade7f52..bd5c16d69 100644 --- a/tex/context/base/catc-ctx.mkiv +++ b/tex/context/base/catc-ctx.mkiv @@ -128,18 +128,11 @@ % for the moment here: -\normalprotected\def\starttexcode +\def\starttexcode {\pushcatcodetable \catcodetable\prtcatcodes} -\normalprotected\def\stoptexcode - {\popcatcodetable} - -\normalprotected\def\startcontextcode - {\pushcatcodetable - \catcodetable\ctxcatcodes} - -\normalprotected\def\stopcontextcode +\def\stoptexcode {\popcatcodetable} \endinput diff --git a/tex/context/base/catc-def.mkiv b/tex/context/base/catc-def.mkiv index cfbaed171..26e8cb11e 100644 --- a/tex/context/base/catc-def.mkiv +++ b/tex/context/base/catc-def.mkiv @@ -123,7 +123,7 @@ %D shortcuts to their character representation. \chardef \^ = \circumflexasciicode -\chardef \_ = \underscoreasciicode +\chardef \_ = \underscoreasciicode % but way too wide in lm, so ... until that's fixed: \chardef \& = \ampersandasciicode \chardef \% = \commentasciicode \chardef \# = \hashasciicode @@ -133,9 +133,8 @@ \chardef \\ = \backslashasciicode \chardef \| = \barasciicode -% way too wide in lm, so one can also use: -% -% \def\_{\dontleavehmode \kern.06em \vbox{\hrule width.3em}} % this will become a \chardef +%def\_{\leavevmode \kern.06em \vbox{\hrule width.3em}} +\def\_{\dontleavehmode \kern.06em \vbox{\hrule width.3em}} % this will become a \chardef %D From now on we can use the protection mechanisms. diff --git a/tex/context/base/catc-ini.lua b/tex/context/base/catc-ini.lua index d4f9b65af..b2c793a6a 100644 --- a/tex/context/base/catc-ini.lua +++ b/tex/context/base/catc-ini.lua @@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['catc-ini'] = { license = "see context related readme files" } +-- todo: everywhere replace tex.ctxcatcodes -> catcodes.numbers.ctxcatcodes + catcodes = catcodes or { } catcodes.numbers = catcodes.numbers or { } catcodes.names = catcodes.names or { } @@ -13,29 +15,26 @@ catcodes.names = catcodes.names or { } storage.register("catcodes/numbers", catcodes.numbers, "catcodes.numbers") storage.register("catcodes/names", catcodes.names, "catcodes.names") -local numbers = catcodes.numbers -local names = catcodes.names - -- this only happens at initime function catcodes.register(name,number) - numbers[name] = number - local cnn = names[number] + catcodes.numbers[name] = number + local cnn = catcodes.names[number] if cnn then cnn[#cnn+1] = name else - names[number] = { name } + catcodes.names[number] = { name } end - tex[name] = number -- downward compatible + tex[name] = number end -- this only happens at runtime -for k, v in next, numbers do - tex[k] = v -- downward compatible +for k, v in next, catcodes.numbers do + tex[k] = v end -- nasty -table.setmetatableindex(numbers,function(t,k) if type(k) == "number" then t[k] = k return k end end) -table.setmetatableindex(names, function(t,k) if type(k) == "string" then t[k] = k return k end end) +table.setmetatableindex(catcodes.numbers,function(t,k) if type(k) == "number" then t[k] = k return k end end) +table.setmetatableindex(catcodes.names, function(t,k) if type(k) == "string" then t[k] = k return k end end) diff --git a/tex/context/base/catc-ini.mkiv b/tex/context/base/catc-ini.mkiv index 791ce31c4..26c3ceee9 100644 --- a/tex/context/base/catc-ini.mkiv +++ b/tex/context/base/catc-ini.mkiv @@ -87,17 +87,6 @@ \xdef\outputnewlinechar{^^J}% \endgroup} -%D We predefine some prefixes ahead of syst-aux and mult-sys. We reserve 8 slots -%D for catcodes. - -\def\??catcodelet {1>>} % let : \let -\def\??catcodedef {2>>} % def : \def -\def\??catcodeued {3>>} % ued : \unexpanded\def -\def\??catcodeget {4>>} % \meaning - -\def\??catcodetablet{5>>} -\def\??catcodetablen{6>>} - \newcount\c_syst_catcodes_n \c_syst_catcodes_n\zerocount % 0 = signal, so advance before allocate \newcount\c_syst_catcodes_a \newcount\c_syst_catcodes_b @@ -105,7 +94,7 @@ \normalprotected\def\newcatcodetable#1% we could move the cctdefcounter to lua {\global\advance\c_syst_catcodes_n\plusone - \expandafter\xdef\csname\??catcodetablen\number\c_syst_catcodes_n\endcsname{\string#1}% logging + \expandafter\xdef\csname\??qm:n:\number\c_syst_catcodes_n\endcsname{\string#1}% logging \newconstant#1% #1\c_syst_catcodes_n \ctxlua{catcodes.register("\expandafter\gobbleoneargument\string#1",\number#1)}} @@ -162,7 +151,12 @@ \setnewconstant\c_syst_catcodes_hack\tildeasciicode %D Once a catcode is assigned, the next assignments will happen -%D faster. +%D faster. We predefine some prefixes ahead of mult-sys. + +\def\??ql{@@ql} % let : \let +\def\??qd{@@qd} % def : \def +\def\??qu{@@qu} % ued : \unexpanded\def +\def\??qm{@@qm} % \meaning \def\letcatcodecommand{\afterassignment\syst_catcodes_let_a\c_syst_catcodes_a} \def\defcatcodecommand{\afterassignment\syst_catcodes_def_a\c_syst_catcodes_a} @@ -173,46 +167,46 @@ \def\syst_catcodes_ued_a{\afterassignment\syst_catcodes_ued_b\c_syst_catcodes_b} \def\syst_catcodes_let_b % each time - {\ifcsname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname - \csname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname + {\ifcsname\??ql:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname + \csname\??ql:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname \else \expandafter\syst_catcodes_let_c \fi} \def\syst_catcodes_def_b % each time - {\ifcsname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname - \csname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname + {\ifcsname\??qd:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname + \csname\??qd:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname \else \expandafter\syst_catcodes_def_c \fi} \def\syst_catcodes_ued_b % each time - {\ifcsname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname - \csname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname + {\ifcsname\??qu:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname + \csname\??qu:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname \else \expandafter\syst_catcodes_ued_c \fi} \def\syst_catcodes_let_c % only first time - {\expandafter\gdef\csname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname\expandafter - {\expandafter\let\csname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}% + {\expandafter\gdef\csname\??ql:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname\expandafter + {\expandafter\let\csname\??qm:\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} + \csname\??ql:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname} \def\syst_catcodes_def_c % only first time (we could use \normalexpanded here) - {\expandafter\gdef\csname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname + {\expandafter\gdef\csname\??qd:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname \expandafter##\expandafter1\expandafter - {\expandafter\def\csname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}% + {\expandafter\def\csname\??qm:\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} + \csname\??qd:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname} \def\syst_catcodes_ued_c % only first time - {\expandafter\gdef\csname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname + {\expandafter\gdef\csname\??qu:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname \expandafter##\expandafter1\expandafter - {\expandafter\normalprotected\expandafter\def\csname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}% + {\expandafter\normalprotected\expandafter\def\csname\??qm:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}% \syst_catcodes_reinstate_unexpanded - \csname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname} + \csname\??qu:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname} \def\reinstatecatcodecommand{\afterassignment\syst_catcodes_reinstate_normal\c_syst_catcodes_b} @@ -233,8 +227,8 @@ \newconstant\defaultcatcodetable \def\catcodecommand#1% - {\csname\??catcodeget\number - \ifcsname\??catcodeget\number\currentcatcodetable:\number#1\endcsname + {\csname\??qm:\number + \ifcsname\??qm:\number\currentcatcodetable:\number#1\endcsname \currentcatcodetable \else \defaultcatcodetable \fi :\number#1\endcsname} @@ -257,13 +251,13 @@ \normalprotected\def\pushcatcodetable {\advance\c_syst_catcodes_level\plusone \syst_catcodes_trace_push - \expandafter\chardef\csname\??catcodetablet\number\c_syst_catcodes_level\endcsname\currentcatcodetable} + \expandafter\chardef\csname\??qm:t:\number\c_syst_catcodes_level\endcsname\currentcatcodetable} \normalprotected\def\popcatcodetable {\ifcase\c_syst_catcodes_level \syst_catcodes_trace_nesting_error \else - \expandafter\catcodetable\csname\??catcodetablet\number\c_syst_catcodes_level\endcsname + \expandafter\catcodetable\csname\??qm:t:\number\c_syst_catcodes_level\endcsname \syst_catcodes_trace_pop \advance\c_syst_catcodes_level\minusone \fi} @@ -275,7 +269,7 @@ \normalprotected\def\restorecatcodes % takes previous level {\ifnum\c_syst_catcodes_level>\plusone - \expandafter\catcodetable\csname\??catcodetablet\number\numexpr\c_syst_catcodes_level-1\relax\endcsname + \expandafter\catcodetable\csname\??qm:t:\number\numexpr\c_syst_catcodes_level-1\relax\endcsname \fi} % \newtoks\everycatcodetable @@ -300,14 +294,14 @@ \def\syst_catcodes_prev {\ifnum\numexpr\c_syst_catcodes_level-1\relax>\zerocount - \csname\??catcodetablen\number\csname\??catcodetablet\number\numexpr\c_syst_catcodes_level-1\relax\endcsname\endcsname + \csname\??qm:n:\number\csname\??qm:t:\number\numexpr\c_syst_catcodes_level-1\relax\endcsname\endcsname \else -% \fi} \def\catcodetablename {\ifnum\currentcatcodetable>\zerocount - \csname\??catcodetablen\number\currentcatcodetable\endcsname + \csname\??qm:n:\number\currentcatcodetable\endcsname \else -% \fi} diff --git a/tex/context/base/char-cjk.lua b/tex/context/base/char-cjk.lua index 3d7de1423..b077f4a3e 100644 --- a/tex/context/base/char-cjk.lua +++ b/tex/context/base/char-cjk.lua @@ -12,8 +12,7 @@ local floor = math.floor local format = string.format local utfchar = utf.char -local ranges = characters.ranges -local allocate = utilities.storage.allocate +local ranges = characters.ranges -- Hangul Syllable @@ -210,7 +209,7 @@ local remapped = { -- this might be merged into char-def.lua [0x11C2] = 0x314E, -- H } -characters.hangul = allocate { +characters.hangul = { decomposed = decomposed, description = description, leadconsonant = leadconsonant, @@ -227,6 +226,24 @@ local hangul_syllable_basetable = { linebreak = "h2", } +--~ local hangul_syllable_metatable = { +--~ __index = function(t,k) +--~ local u = t.unicodeslot +--~ if k == "fscode" then +--~ -- no need to cache this as we normally use fscodes +--~ return leadconsonant(u) +--~ elseif k == "shcode" then +--~ return { decomposed(u) } +--~ elseif k == "specials" then +--~ return { "char", decomposed(u) } +--~ elseif k == "description" then +--~ return description(u) +--~ else +--~ return hangul_syllable_basetable[k] +--~ end +--~ end +--~ } + local hangul_syllable_metatable = { __index = function(t,k) local u = t.unicodeslot diff --git a/tex/context/base/char-def.lua b/tex/context/base/char-def.lua index 6c73cf008..804468c2d 100644 --- a/tex/context/base/char-def.lua +++ b/tex/context/base/char-def.lua @@ -3,8 +3,7 @@ if not modules then modules = { } end modules ['char-def'] = { comment = "companion to char-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", - license = "see context related readme files", - dataonly = true, + license = "see context related readme files" } --[[ @@ -56833,16 +56832,6 @@ characters.data={ description="OVERLINE", direction="on", linebreak="al", - mathspec={ - { - class="topaccent", - name="overbar", - }, - { - class="botaccent", - name="underbar", - }, - }, specials={ "compat", 0x0020, 0x0305 }, unicodeslot=0x203E, }, @@ -57255,8 +57244,6 @@ characters.data={ description="SUPERSCRIPT PLUS SIGN", direction="es", linebreak="al", - mathclass="binary", - mathname ="positivesign", specials={ "super", 0x002B }, unicodeslot=0x207A, }, @@ -57265,8 +57252,6 @@ characters.data={ description="SUPERSCRIPT MINUS", direction="es", linebreak="al", - mathclass="binary", - mathname ="negativesign", specials={ "super", 0x2212 }, unicodeslot=0x207B, }, @@ -58684,7 +58669,7 @@ characters.data={ description="TURNED AMPERSAND", direction="on", linebreak="al", - mathclass="binary", + mathclass="bin", mathname="upand", unicodeslot=0x214B, }, @@ -60902,11 +60887,11 @@ characters.data={ linebreak="ai", mathspec={ { - class="binary", + class="bin", name="vee", }, { - class="binary", + class="bin", name="lor", }, }, @@ -60947,16 +60932,15 @@ characters.data={ description="INTEGRAL", direction="on", linebreak="ai", - mathclass="limop", mathspec={ - { - class="limop", - name="int", - }, { class="nothing", name="intop", }, + { + class="limop", + name="int", + }, }, unicodeslot=0x222B, }, @@ -60967,16 +60951,15 @@ characters.data={ description="DOUBLE INTEGRAL", direction="on", linebreak="ai", - mathclass="limop", mathspec={ - { - class="limop", - name="iint", - }, { class="nothing", name="iintop", }, + { + class="limop", + name="iint", + }, }, specials={ "compat", 0x222B, 0x222B }, unicodeslot=0x222C, @@ -60986,16 +60969,15 @@ characters.data={ description="TRIPLE INTEGRAL", direction="on", linebreak="al", - mathclass="limop", mathspec={ - { - class="limop", - name="iiint", - }, { class="nothing", name="iiintop", }, + { + class="limop", + name="iiint", + }, }, specials={ "compat", 0x222B, 0x222B, 0x222B }, unicodeslot=0x222D, @@ -62420,7 +62402,7 @@ characters.data={ description="NORMAL SUBGROUP OF", direction="on", linebreak="al", - mathclass="binary", + mathclass="bin", mirror=0x22B3, unicodeslot=0x22B2, }, @@ -62430,7 +62412,7 @@ characters.data={ description="CONTAINS AS NORMAL SUBGROUP", direction="on", linebreak="al", - mathclass="binary", + mathclass="bin", mirror=0x22B2, unicodeslot=0x22B3, }, @@ -68406,8 +68388,6 @@ characters.data={ description="BLACK UP-POINTING TRIANGLE", direction="on", linebreak="ai", - mathclass="binary", - mathname="blacktriangle", unicodeslot=0x25B2, }, [0x25B3]={ @@ -68452,7 +68432,7 @@ characters.data={ description="BLACK RIGHT-POINTING TRIANGLE", direction="on", linebreak="ai", - mathclass="binary", + mathclass="bin", mathname="blacktriangleright", unicodeslot=0x25B6, }, @@ -68463,7 +68443,7 @@ characters.data={ description="WHITE RIGHT-POINTING TRIANGLE", direction="on", linebreak="ai", - mathclass="binary", + mathclass="bin", mathname="triangleright", unicodeslot=0x25B7, }, @@ -68472,6 +68452,8 @@ characters.data={ description="BLACK RIGHT-POINTING SMALL TRIANGLE", direction="on", linebreak="al", + mathclass="bin", + mathname="blacktriangleleft", unicodeslot=0x25B8, }, [0x25B9]={ @@ -68504,8 +68486,6 @@ characters.data={ description="BLACK DOWN-POINTING TRIANGLE", direction="on", linebreak="ai", - mathclass="binary", - mathname="blacktriangledown", unicodeslot=0x25BC, }, [0x25BD]={ @@ -68515,16 +68495,8 @@ characters.data={ description="WHITE DOWN-POINTING TRIANGLE", direction="on", linebreak="ai", - mathspec={ - { - class="binary", - name="triangledown", - }, - { - class="binary", - name="bigtriangledown", - }, - }, + mathclass="binary", + mathname="bigtriangledown", unicodeslot=0x25BD, }, [0x25BE]={ @@ -68549,8 +68521,6 @@ characters.data={ description="BLACK LEFT-POINTING TRIANGLE", direction="on", linebreak="ai", - mathclass="binary", - mathname="blacktriangleleft", unicodeslot=0x25C0, }, [0x25C1]={ @@ -68560,7 +68530,7 @@ characters.data={ description="WHITE LEFT-POINTING TRIANGLE", direction="on", linebreak="ai", - mathclass="binary", + mathclass="bin", mathname="triangleleft", unicodeslot=0x25C1, }, diff --git a/tex/context/base/char-enc.lua b/tex/context/base/char-enc.lua index 048837eec..ef6805e54 100644 --- a/tex/context/base/char-enc.lua +++ b/tex/context/base/char-enc.lua @@ -1,10 +1,9 @@ -if not modules then modules = { } end modules ['char-enc'] = { +if not modules then modules = { } end modules ['char-syn'] = { version = 1.001, comment = "companion to char-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" - -- dataonly = true, } -- Thanks to tex4ht for these mappings. @@ -145,25 +144,25 @@ characters.synonyms = allocate { -- afm mess Yen = 0x00A5, } --- if not characters.enccodes then --- --- local enccodes = { } characters.enccodes = enccodes --- --- for unicode, data in next, characters.data do --- local encname = data.adobename or data.contextname --- if encname then --- enccodes[encname] = unicode --- end --- end --- --- for name, unicode in next, characters.synonyms do --- if not enccodes[name] then enccodes[name] = unicode end --- end --- --- --- end --- --- storage.register("characters.enccodes", characters.enccodes, "characters.enccodes") +--~ if not characters.enccodes then +--~ +--~ local enccodes = { } characters.enccodes = enccodes +--~ +--~ for unicode, data in next, characters.data do +--~ local encname = data.adobename or data.contextname +--~ if encname then +--~ enccodes[encname] = unicode +--~ end +--~ end +--~ +--~ for name, unicode in next, characters.synonyms do +--~ if not enccodes[name] then enccodes[name] = unicode end +--~ end +--~ +--~ +--~ end +--~ +--~ storage.register("characters.enccodes", characters.enccodes, "characters.enccodes") -- As this table is seldom used, we can delay its definition. Beware, this means -- that table.print would not work on this file unless it is accessed once. This diff --git a/tex/context/base/char-ent.lua b/tex/context/base/char-ent.lua index ef55be7e4..d2ac22bbf 100644 --- a/tex/context/base/char-ent.lua +++ b/tex/context/base/char-ent.lua @@ -1,14 +1,15 @@ -if not modules then modules = { } end modules ['char-ent'] = { +if not modules then modules = { } end modules ['math-ent'] = { version = 1.001, comment = "companion to math-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "derived from the mathml 2.0 specification", - dataonly = true, } -- http://www.w3.org/2003/entities/2007/w3centities-f.ent -- http://www.w3.org/2003/entities/2007/htmlmathml-f.ent +-- this might go into char-def + local entities = utilities.storage.allocate { ["AElig"] = "Æ", -- U+000C6 ["AMP"] = "&", -- U+00026 diff --git a/tex/context/base/char-ini.lua b/tex/context/base/char-ini.lua index 778035ff4..244b8d2a7 100644 --- a/tex/context/base/char-ini.lua +++ b/tex/context/base/char-ini.lua @@ -11,9 +11,10 @@ if not modules then modules = { } end modules ['char-ini'] = { -- we can remove the tag range starting at 0xE0000 (special applications) local tex = tex +local utf = unicode.utf8 local utfchar, utfbyte, utfvalues = utf.char, utf.byte, string.utfvalues -local ustring, utf = unicode.ustring, unicode.utf8 +local ustring = unicode.ustring local concat, unpack, tohash = table.concat, table.unpack, table.tohash local next, tonumber, type, rawget, rawset = next, tonumber, type, rawget, rawset local format, lower, gsub, match, gmatch = string.format, string.lower, string.gsub, string.match, string.match, string.gmatch @@ -27,8 +28,8 @@ local texsetsfcode = tex.setsfcode local texsetcatcode = tex.setcatcode local contextsprint = context.sprint -local ctxcatcodes = catcodes.numbers.ctxcatcodes -local texcatcodes = catcodes.numbers.texcatcodes +local ctxcatcodes = tex.ctxcatcodes +local texcatcodes = tex.texcatcodes local setmetatableindex = table.setmetatableindex @@ -47,6 +48,7 @@ loaded!

characters = characters or { } local characters = characters + local data = characters.data if data then @@ -453,39 +455,28 @@ table we derive a few more.

if not characters.fallbacks then - characters.fallbacks = { } -- not than many + -- we could the definition by using a metatable + + characters.fallbacks = { } + characters.directions = { } - local fallbacks = characters.fallbacks + local fallbacks = characters.fallbacks + local directions = characters.directions - for k, d in next, data do - local specials = d.specials - if specials and specials[1] == "compat" and specials[2] == 0x0020 then + for k,v in next, data do + local specials = v.specials + if specials and specials[1] == "compat" and specials[2] == 0x0020 and specials[3] then local s = specials[3] - if s then - fallbacks[k] = s - fallbacks[s] = k - end + fallbacks[k] = s + fallbacks[s] = k end + directions[k] = v.direction end end -storage.register("characters/fallbacks", characters.fallbacks, "characters.fallbacks") -- accents and such - -characters.directions = { } - -setmetatableindex(characters.directions,function(t,k) - local d = data[k] - if d then - local v = d.direction - if v then - t[k] = v - return v - end - end - t[k] = false -- maybe 'l' - return v -end) +storage.register("characters/fallbacks", characters.fallbacks, "characters.fallbacks") -- accents and such +storage.register("characters/directions", characters.directions, "characters.directions") --[[ldx--

The context namespace is used to store methods and data @@ -497,7 +488,7 @@ which is rather specific to .

use the table. After all, we have this information available anyway.

--ldx]]-- -function characters.makeactive(n,name) -- +function characters.makeactive(n,name) -- let ? contextsprint(ctxcatcodes,format("\\catcode%s=13\\unexpanded\\def %s{\\%s}",n,utfchar(n),name)) -- context("\\catcode%s=13\\unexpanded\\def %s{\\%s}",n,utfchar(n),name) end @@ -512,7 +503,7 @@ function tex.uprint(c,n) end end -local forbidden = tohash { -- at least now +local temphack = tohash { 0x00A0, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x200B, 0x200C, 0x200D, 0x202F, @@ -548,10 +539,12 @@ function characters.define(tobelettered, tobeactivated) -- catcodetables else contextsprint(ctxcatcodes,format("\\def\\%s{%s}",contextname,utfchar(u))) -- has no s end - elseif is_command[category] and not forbidden[u] then + elseif is_command[category] then +if not temphack[u] then contextsprint("{\\catcode",u,"=13\\unexpanded\\gdef ",utfchar(u),"{\\"..contextname,"}}") a = a + 1 activated[a] = u +end end end end @@ -639,17 +632,15 @@ function characters.setcodes() end else local lc, uc = chr.lccode, chr.uccode - if not lc then - chr.lccode, lc = code, code - elseif type(lc) == "table" then + if not lc then chr.lccode, lc = code, code end + if not uc then chr.uccode, uc = code, code end + texsetcatcode(code,11) -- letter + if type(lc) == "table" then lc = code end - if not uc then - chr.uccode, uc = code, code - elseif type(uc) == "table" then + if type(uc) == "table" then uc = code end - texsetcatcode(code,11) -- letter texsetlccode(code,lc,uc) if cc == "lu" then texsetsfcode(code,999) @@ -824,7 +815,8 @@ function characters.unicodechar(asked) if n then return n elseif type(asked) == "string" then - return descriptions[asked] or descriptions[gsub(asked," ","")] + asked = gsub(asked," ","") + return descriptions[asked] end end @@ -890,21 +882,17 @@ end function characters.uccode(n) return uccodes[n] end -- obsolete function characters.lccode(n) return lccodes[n] end -- obsolete -function characters.safechar(n) +function characters.flush(n,direct) local c = data[n] if c and c.contextname then - return "\\" .. c.contextname + c = "\\" .. c.contextname else - return utfchar(n) + c = utfchar(n) end -end - -function commands.safechar(n) - local c = data[n] - if c and c.contextname then - contextsprint("\\" .. c.contextname) -- context[c.contextname]() + if direct then + return c else - contextsprint(utfchar(n)) + contextsprint(c) end end diff --git a/tex/context/base/char-map.lua b/tex/context/base/char-map.lua index 749da5289..376ebf343 100644 --- a/tex/context/base/char-map.lua +++ b/tex/context/base/char-map.lua @@ -3,8 +3,7 @@ if not modules then modules = { } end modules ['char-map'] = { comment = "companion to char-ini.mkiv", author = "Hans Hagen & Arthur Reutenauer", copyright = "PRAGMA ADE / ConTeXt Development Team", - license = "see context related readme files", - dataonly = true, + license = "see context related readme files" } -- not yet used diff --git a/tex/context/base/char-utf.lua b/tex/context/base/char-utf.lua index 52fdfc0d0..a411c2d82 100644 --- a/tex/context/base/char-utf.lua +++ b/tex/context/base/char-utf.lua @@ -19,7 +19,7 @@ in special kinds of output (for instance ).

over a string.

--ldx]]-- -local utfchar, utfbyte = utf.char, utf.byte +local utfchar, utfbyte, utfgsub = utf.char, utf.byte, utf.gsub local concat, gmatch, gsub, find = table.concat, string.gmatch, string.gsub, string.find local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues local allocate = utilities.storage.allocate @@ -76,7 +76,6 @@ local decomposed = allocate { ["ﬖ"] = "վն", ["ﬗ"] = "մխ", } - characters.decomposed = decomposed local function initialize() -- maybe only 'mn' @@ -210,13 +209,9 @@ end private.set = set --- function private.escape (str) return gsub(str,"(.)", escapes) end --- function private.replace(str) return utfgsub(str,"(.)", low ) end --- function private.revert (str) return utfgsub(str,"(.)", high ) end - -private.escape = utf.remapper(escapes) -private.replace = utf.remapper(low) -private.revert = utf.remapper(high) +function private.escape (str) return gsub(str,"(.)", escapes) end +function private.replace(str) return utfgsub(str,"(.)", low ) end +function private.revert (str) return utfgsub(str,"(.)", high ) end for ch in gmatch(special,".") do set(ch) end @@ -486,14 +481,6 @@ if sequencers then sequencers.enableaction(textfileactions,"characters.filters.utf.decompose") end - directives.register("filters.utf.collapse", function(v) - sequencers[v and "enableaction" or "disableaction"](textfileactions,"characters.filters.utf.collapse") - end) - - directives.register("filters.utf.decompose", function(v) - sequencers[v and "enableaction" or "disableaction"](textfileactions,"characters.filters.utf.decompose") - end) - end --[[ldx-- diff --git a/tex/context/base/chem-ini.lua b/tex/context/base/chem-ini.lua index 192953ec9..4d47982a2 100644 --- a/tex/context/base/chem-ini.lua +++ b/tex/context/base/chem-ini.lua @@ -17,8 +17,8 @@ local report_chemistry = logs.reporter("chemistry") local context = context -chemistry = chemistry or { } -local chemistry = chemistry +chemicals = chemicals or { } +local chemicals = chemicals --[[

The next code is an adaptation of code from Wolfgang Schuster @@ -62,9 +62,9 @@ local high = Cc("\\high{%s}") * superscript * content local justtext = (1 - somescript)^1 local parser = Cs((csname + lowhigh + highlow + low + high + sign + any)^0) -chemistry.moleculeparser = parser -- can be used to avoid functioncall +chemicals.moleculeparser = parser -- can be used to avoid functioncall -function chemistry.molecule(str) +function chemicals.molecule(str) return lpegmatch(parser,str) end diff --git a/tex/context/base/chem-str.lua b/tex/context/base/chem-str.lua index db1849c5a..fb325ccea 100644 --- a/tex/context/base/chem-str.lua +++ b/tex/context/base/chem-str.lua @@ -1,15 +1,12 @@ if not modules then modules = { } end modules ['chem-str'] = { version = 1.001, comment = "companion to chem-str.mkiv", - author = "Hans Hagen and Alan Braslau", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" } --- The original \PPCHTEX\ code was written in pure \TEX\, although later we made --- the move from \PICTEX\ to \METAPOST\. The current implementation is a mix between --- \TEX\, \LUA\ and \METAPOST. Although the first objective is to get a compatible --- but better implementation, later versions might provide more, +-- This module in incomplete and experimental. -- We can push snippets into an mp instance. @@ -29,12 +26,12 @@ local P, R, S, C, Cs, Ct, Cc = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cs, lpeg.Ct, local variables = interfaces.variables local context = context -chemistry = chemistry or { } -local chemistry = chemistry +chemicals = chemicals or { } +local chemicals = chemicals -chemistry.instance = "metafun" -- "ppchtex" -chemistry.format = "metafun" -chemistry.structures = 0 +chemicals.instance = "metafun" -- "ppchtex" +chemicals.format = "metafun" +chemicals.structures = 0 local remapper = { ["+"] = "p", @@ -55,9 +52,7 @@ local common_keys = { mid = "fixed", mids = "fixed", midz = "text", z = "text", rz = "text", mrz = "text", prz = "text", crz = "text", rt = "text", rtt = "text", rbt = "text", zt = "text", zn = "number", - zbt = "text", zbn = "number", ztt = "text", ztn = "number", - mov = "transform", rot = "transform", adj = "transform", sub = "transform", - off = "transform", + mov = "transform", rot = "transform", adj = "transform", dir = "transform", sub = "transform", } local front_keys = { @@ -65,11 +60,9 @@ local front_keys = { sb = "line", msb = "line", psb = "line", r = "line", pr = "line", mr = "line", z = "text", mrz = "text", prz = "text", - zt = "text", zn = "number", } local one_keys = { - b = "line", msb = "line", psb = "line", sb = "line", db = "line", tb = "line", ep = "line", es = "line", ed = "line", et = "line", sd = "line", ldd = "line", rdd = "line", @@ -88,16 +81,15 @@ local syntax = { one = { n = 1, max = 8, keys = one_keys, align = { - -- z = { { "r", "r_b", "b", "l_b", "l", "l_t", "t", "r_t" } }, - -- z = { { "r", "r", "b", "l", "l", "l", "t", "r" } }, + z = { { "r", "r_b", "b", "l_b", "l", "l_t", "t", "r_t" } }, +--~ z = { { "r", "r", "b", "l", "l", "l", "t", "r" } }, } }, three = { n = 3, max = 3, keys = common_keys, align = { mrz = { { "r","b","l" }, { "b","l","t" }, { "l","t","r" }, { "t","r","b" } }, - rz = { { "auto","auto","auto" }, { "auto","auto","auto" }, { "auto","auto","auto" }, { "auto","auto","auto" } }, - -- rz = { { "r_t","r_b","l" }, { "r_b","l_b","t" }, { "l_b","l_t","r" }, { "l_t","r_t","b" } }, + rz = { { "r","l_b","l_t" }, { "b","l_t","r_t" }, { "l","r_t","r_b" }, { "t","r_b","l_b" } }, prz = { { "r","l","t" }, { "b","t","r" }, { "l","r","b" }, { "t","b","l" } }, } }, @@ -105,8 +97,7 @@ local syntax = { n = 4, max = 4, keys = common_keys, align = { mrz = { { "t","r","b","l" }, { "r","b","l","t" }, { "b","l","t","r" }, { "l","t","r","b" } }, - rz = { { "auto","auto","auto","auto" }, { "auto","auto","auto","auto" }, { "auto","auto","auto","auto" }, { "auto","auto","auto","auto" } }, - -- rz = { { "r_t","r_b","l_b","l_t" }, { "r_b","l_b","l_t","r_t" }, { "l_b","l_t","r_t","r_b" }, { "l_t","r_t","r_b","l_b" } }, + rz = { { "r_t","r_b","l_b","l_t" }, { "r_b","l_b","l_t","r_t" }, { "l_b","l_t","r_t","r_b" }, { "l_t","r_t","r_b","l_b" } }, prz = { { "r","b","l","t" }, { "b","l","t","r" }, { "l","t","r","b" }, { "t","r","b","l" } }, } }, @@ -114,8 +105,7 @@ local syntax = { n = 5, max = 5, keys = common_keys, align = { mrz = { { "t","r","b","b","l" }, { "r","b","l","l","t" }, { "b","l","t","r","r" }, { "l","t","r","r","b" } }, - rz = { { "auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto" } }, - -- rz = { { "r","r","b","l","t" }, { "b","b","l","t","r" }, { "l","l","t","r","b" }, { "t","t","r","b","l" } }, + rz = { { "r","r","b","l","t" }, { "b","b","l","t","r" }, { "l","l","t","r","b" }, { "t","t","r","b","l" } }, prz = { { "r","b","l","t","t" }, { "b","l","t","r","r" }, { "l","t","r","b","b" }, { "t","r","b","l","l" } }, } }, @@ -123,8 +113,7 @@ local syntax = { n = 6, max = 6, keys = common_keys, align = { mrz = { { "t","t","r","b","b","l" }, { "r","b","b","l","t","t" }, { "b","b","l","t","t","r" }, { "l","t","t","r","b","b" } }, - rz = { { "auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto" } }, - -- rz = { { "r","r","b","l","l","t" }, { "b","b","l","t","t","r" }, { "l","l","t","r","r","b" }, { "t","t","r","b","b","l" } }, + rz = { { "r","r","b","l","l","t" }, { "b","b","l","t","t","r" }, { "l","l","t","r","r","b" }, { "t","t","r","b","b","l" } }, prz = { { "r","b","l","l","t","r" }, { "b","l","t","t","r","b" }, { "l","t","r","r","b","l" }, { "t","r","b","b","l","t" } }, } }, @@ -132,8 +121,7 @@ local syntax = { n = 8, max = 8, keys = common_keys, align = { -- todo mrz = { { "t","r","r","b","b","l","l","t" }, { "r","b","b","l","l","t","t","r" }, { "b","l","l","t","t","r","r","b" }, { "l","t","t","r","r","b","b","l" } }, - rz = { { "auto","auto","auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto","auto","auto" } }, - -- rz = { { "r","r","b","b","l","l","t","t" }, { "b","b","l","l","t","t","r","r" }, { "l","l","t","t","r","r","b","b" }, { "t","t","r","r","b","b","l","l" } }, + rz = { { "r","r","b","b","l","l","t","t" }, { "b","b","l","l","t","t","r","r" }, { "l","l","t","t","r","r","b","b" }, { "t","t","r","r","b","b","l","l" } }, prz = { { "r","b","b","l","l","t","t","r" }, { "b","l","l","t","t","r","r","b" }, { "l","t","t","r","r","b","b","l" }, { "t","r","r","b","b","l","l","t" } }, } }, @@ -159,11 +147,11 @@ local syntax = { local definitions = { } -function chemistry.undefine(name) +function chemicals.undefine(name) definitions[lower(name)] = nil end -function chemistry.define(name,spec,text) +function chemicals.define(name,spec,text) name = lower(name) local dn = definitions[name] if not dn then dn = { } definitions[name] = dn end @@ -174,7 +162,7 @@ function chemistry.define(name,spec,text) end local metacode, variant, keys, bonds, max, txt, textsize, rot, pstack -local molecule = chemistry.molecule -- or use lpegmatch(chemistry.moleculeparser,...) +local molecule = chemicals.molecule -- or use lpegmatch(chemicals.moleculeparser,...) local function fetch(txt) local st = stack[txt] @@ -208,46 +196,35 @@ local text = (equal * C(P(1)^0)) + Cc(false) local pattern = (amount + Cc(1)) * - Cs(operation/lower) * - Cs(special/lower) * ( --- operation * --- special * ( + operation * + special * ( range * Cc(false) * text + Cc(false) * Cc(false) * set * text + single * Cc(false) * Cc(false) * text + Cc(false) * Cc(false) * Cc(false) * text ) --- local n, operation, index, upto, set, text = lpegmatch(pattern,"RZ1357") +--~ local n, operation, index, upto, set, text = lpegmatch(pattern,"RZ1357") --- print(lpegmatch(pattern,"RZ=x")) -- 1 RZ false false false x --- print(lpegmatch(pattern,"RZ1=x")) -- 1 RZ 1 false false x --- print(lpegmatch(pattern,"RZ1..3=x")) -- 1 RZ 1 3 false x --- print(lpegmatch(pattern,"RZ13=x")) -- 1 RZ false false table x +--~ print(lpegmatch(pattern,"RZ=x")) 1 RZ false false false x +--~ print(lpegmatch(pattern,"RZ1=x")) 1 RZ 1 false false x +--~ print(lpegmatch(pattern,"RZ1..3=x")) 1 RZ 1 3 false x +--~ print(lpegmatch(pattern,"RZ13=x")) 1 RZ false false table x local function process(spec,text,n,rulethickness,rulecolor,offset) insert(stack,{ spec=spec, text=text, n=n }) local txt = #stack local m = #metacode for i=1,#spec do - local step = spec[i] - local s = lower(step) + local s = spec[i] local d = definitions[s] if d then - if trace_structure then - report_chemistry("%s => definition: %s",step,s) - end for i=1,#d do local di = d[i] process(di.spec,di.text,1,rulethickness,rulecolor) end else - local rep, operation, special, index, upto, set, text = lpegmatch(pattern,step) - if trace_structure then - local set = set and concat(set," ") or "-" - report_chemistry("%s => rep: %s, operation: %s, special: %s, index: %s, upto: %s, set: %s, text: %s", - step,rep or "-",operation or "-",special and special ~= "" or "-",index or "-",upto or "-",set or "-",text or "-") - end + local rep, operation, special, index, upto, set, text = lpegmatch(pattern,s) if operation == "pb" then insert(pstack,variant) m = m + 1 ; metacode[m] = syntax.pb.direct @@ -362,8 +339,7 @@ local function process(spec,text,n,rulethickness,rulecolor,offset) if not t then txt, t = fetch(txt) end if t then t = molecule(processor_tostring(t)) - m = m + 1 ; metacode[m] = format('chem_%s(%s,%s,"\\chemicaltext{%s}");',operation,bonds,index,t) - -- m = m + 1 ; metacode[m] = format('chem_%s_zero("\\chemicaltext{%s}");',operation,t) + m = m + 1 ; metacode[m] = format('chem_%s_zero("\\chemicaltext{%s}");',operation,t) end elseif index then local t = text @@ -412,8 +388,8 @@ end -- -- rulethickness in points -function chemistry.start(settings) - chemistry.structures = chemistry.structures + 1 +function chemicals.start(settings) + chemicals.structures = chemicals.structures + 1 local textsize, rulethickness, rulecolor = settings.size, settings.rulethickness, settings.rulecolor local width, height, scale, offset = settings.width or 0, settings.height or 0, settings.scale or "medium", settings.offset or 0 local l, r, t, b = settings.left or 0, settings.right or 0, settings.top or 0, settings.bottom or 0 @@ -469,73 +445,63 @@ function chemistry.start(settings) scale = 0.75 * scale/625 -- metacode[#metacode+1] = format("chem_start_structure(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) ;", - chemistry.structures, + chemicals.structures, l/25, r/25, t/25, b/25, scale, tostring(settings.axis == variables.on), tostring(width), tostring(height), tostring(offset) ) -- - -- variant, keys, bonds, stack, rot, pstack = "six", { }, 6, { }, 1, { } - variant, keys, bonds, stack, rot, pstack = "one", { }, 1, { }, 1, { } + variant, keys, bonds, stack, rot, pstack = "six", { }, 6, { }, 1, { } end -function chemistry.stop() +function chemicals.stop() metacode[#metacode+1] = "chem_stop_structure ;" -- local mpcode = concat(metacode,"\n") if trace_structure then report_chemistry("metapost code:\n%s", mpcode) end - metapost.graphic(chemistry.instance,chemistry.format,mpcode) + metapost.graphic(chemicals.instance,chemicals.format,mpcode) metacode = nil end -function chemistry.component(spec,text,settings) +function chemicals.component(spec,text,settings) rulethickness, rulecolor, offset = settings.rulethickness, settings.rulecolor --- local spec = settings_to_array(lower(spec)) - local spec = settings_to_array(spec) + local spec = settings_to_array(lower(spec)) local text = settings_to_array(text) metacode[#metacode+1] = "chem_start_component ;" process(spec,text,1,rulethickness,rulecolor) metacode[#metacode+1] = "chem_stop_component ;" end -statistics.register("chemical formulas", function() - if chemistry.structures > 0 then - return format("%s chemical structure formulas",chemistry.structures) -- no timing needed, part of metapost - end -end) - --- interfaces - -commands.undefinechemical = chemistry.undefine -commands.definechemical = chemistry.define -commands.startchemical = chemistry.start -commands.stopchemical = chemistry.stop -commands.chemicalcomponent = chemistry.component - --- todo: top / bottom - local inline = { ["single"] = "\\chemicalsinglebond", ["-"] = "\\chemicalsinglebond", - ["double"] = "\\chemicaldoublebond", ["--"] = "\\chemicaldoublebond", -- also =? and unicode triple? + ["double"] = "\\chemicaldoublebond", ["--"] = "\\chemicaldoublebond", ["triple"] = "\\chemicaltriplebond", ["---"] = "\\chemicaltriplebond", ["gives"] = "\\chemicalgives", ["->"] = "\\chemicalgives", ["equilibrium"] = "\\chemicalequilibrium", ["<->"] = "\\chemicalequilibrium", ["mesomeric"] = "\\chemicalmesomeric", ["<>"] = "\\chemicalmesomeric", - ["plus"] = "\\chemicalplus", ["+"] = "\\chemicalplus", - ["minus"] = "\\chemicalminus", - ["space"] = "\\chemicalspace", + ["plus"] = "\\chemicalsplus", ["+"] = "\\chemicalsplus", + ["minus"] = "\\chemicalsminus", + ["space"] = "\\chemicalsspace", } -function commands.inlinechemical(spec) +-- todo: top / bottom + +function chemicals.inline(spec) local spec = settings_to_array(spec) for i=1,#spec do local s = spec[i] local inl = inline[lower(s)] if inl then - context(inl) -- could be a fast context.sprint + context(inl) else context.chemicalinline(molecule(s)) end end end + +statistics.register("chemical formulas", function() + if chemicals.structures > 0 then + return format("%s chemical structure formulas",chemicals.structures) -- no timing needed, part of metapost + end +end) diff --git a/tex/context/base/chem-str.mkiv b/tex/context/base/chem-str.mkiv index c4b03dd1e..1d60a293e 100644 --- a/tex/context/base/chem-str.mkiv +++ b/tex/context/base/chem-str.mkiv @@ -2,7 +2,7 @@ %D [ file=chem-ini, %D version=2009.05.13, %D subtitle=Chemistry, -%D author=Hans Hagen \& Alan Braslau, +%D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C @@ -10,10 +10,8 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D The original \PPCHTEX\ code was written in pure \TEX\, although later we made -%D the move from \PICTEX\ to \METAPOST\. The current implementation is a mix between -%D \TEX\, \LUA\ and \METAPOST. Although the first objective is to get a compatible -%D but better implementation, later versions might provide more, +%D This module in incomplete and experimental. Eventually this code +%D will replace \PPCHTEX. \writestatus{loading}{ConTeXt Chemistry Macros / Structure} @@ -28,24 +26,24 @@ % Here we use chemicalformula instead, so no longer a mix: % % \startchemicalformula -% \chemical{2H_2}{top}{bottom} +% \chemical{H_2}{top}{bottom} % \chemical{PLUS}{top}{bottom} -% \chemical{O_2}{top}{bottom} +% \chemical{O}{top}{bottom} % \chemical{GIVES}{top}{bottom} -% \chemical{2H_2O}{top}{bottom} +% \chemical{H_2O}{top}{bottom} % \stopchemicalformula % % \startchemicalformula -% \chemical{2H_2} +% \chemical{H_2} % \chemical{PLUS} -% \chemical{O_2} +% \chemical{O} % \chemical{GIVES} -% \chemical{2H_2O} +% \chemical{H_2O} % \stopchemicalformula % % The inline variant has only one argument: % -% \chemical{2H_2,PLUS,O_2,GIVES,2H_2O} +% \chemical{H_2,PLUS,O,GIVES,H_2O} % todo: seven | eight | frontsix | fontfive | carbon | newmans | chair @@ -60,17 +58,11 @@ \let\setupchemicals\setupchemical -%D We use a dedicated framed macro instead of inheriting one. This is both -%D a historical and practical reason (like shared keys with different meaning -%D that could clash, e.g.\ align). - -\defineframed - [\??chemicalframed] - [\c!align=\v!normal, - \c!strut=\v!no] - \unexpanded\def\setupchemicalframed - {\setupframed[\??chemicalframed]} + {\dosingleempty\dosetupchemicalframed} + +\def\dosetupchemicalframed + {\getparameters[\??chemicalframed]} \unexpanded\def\definechemical % is global (so we don't use the commandhandler) {\dosingleargument\chem_define} @@ -79,7 +71,7 @@ {\startnointerference \edef\currentdefinedchemical{#1}% \let\chemical\chem_chemical_nested - \ctxcommand{undefinechemical("#1")}% + \ctxlua{chemicals.undefine("#1")}% #2% flush \stopnointerference} @@ -87,7 +79,7 @@ {\dodoubleempty\chem_chemical_nested_indeed} \def\chem_chemical_nested_indeed[#1][#2]% - {\ctxcommand{definechemical("\currentdefinedchemical",\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es)}} + {\ctxlua{chemicals.define("\currentdefinedchemical",\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es)}} % chemical symbols @@ -98,15 +90,20 @@ {\setvalue{\??chemicalsymbol#1}{#2}} \unexpanded\def\chemicalsymbol[#1]% - {\csname\??chemicalsymbol\ifcsname\??chemicalsymbol#1\endcsname#1\else\s!unknown\fi\endcsname} + {\csname\??chemicalsymbol\ifcsname\??chemicalsymbol#1\endcsname\s!unknown\else#1\fi\endcsname} -\definechemicalsymbol[\s!unknown][] % \char"FFFD empty +\definechemicalsymbol[\s!unknown][] % empty % size (small medium big) \edef\chemicaltoplocation{t} \edef\chemicalbotlocation{b} +% \unexpanded\def\chemicaltext#1% in ppchtex we had a more clever alignment +% {\usechemicalstyleandcolor\c!style\c!color +% \strut +% #1} % maybe also \setstrut + \unexpanded\def\chemicaltext#1% {\mathematics {\usechemicalstyleandcolor\c!style\c!color @@ -150,7 +147,7 @@ \fi\fi \the\everystructurechemical \setbox\b_chem_result\hbox\bgroup - \ctxcommand{startchemical { + \ctxlua{chemicals.start { width = "\chemicalparameter\c!width", height = "\chemicalparameter\c!height", left = \chemicalparameter\c!left, @@ -165,7 +162,7 @@ \unexpanded\def\stopchemical {\stopnointerference - \ctxcommand{stopchemical()}% + \ctxlua{chemicals.stop()}% \egroup \d_chem_width \wd\b_chem_result \d_chem_height\ht\b_chem_result @@ -174,16 +171,15 @@ \doifelsenothing{\chemicalparameter\c!frame}\chem_framed_nop\chem_framed_yes \egroup} -\unexpanded\def\chem_framed_yes - {\localframedwithsettings +\def\chem_framed_yes + {\localframed% [\??chemicalframed]% - [\c!frame=\chemicalparameter\c!frame]% - {\vbox{\box\b_chem_result\vss}}} % remove depth + [\c!frame=\chemicalparameter\c!frame,\c!align=\v!normal,\c!strut=\v!no]{\vbox{\box\b_chem_result\vss}}} % remove depth -\unexpanded\def\chem_framed_nop - {\directlocalframed +\def\chem_framed_nop + {\localframed% [\??chemicalframed]% - {\vbox{\box\b_chem_result\vss}}} % remove depth + [\c!align=\v!normal,\c!strut=\v!no]{\vbox{\box\b_chem_result\vss}}} % remove depth \let\startstructurechemical\startchemical \let\stopstructurechemical \stopchemical @@ -204,14 +200,14 @@ \def\strc_chem_indeed_three[#1][#2][#3]% {\writestatus\m!chemicals{hyperlinked chemicals not yet supported}% todo reference, for the moment ignored - \ctxcommand{chemicalcomponent(\!!bs#2\!!es, \!!bs\detokenize{#3}\!!es, { % maybe also pass first two args this way + \ctxlua{chemicals.component(\!!bs#2\!!es, \!!bs\detokenize{#3}\!!es, { % maybe also pass first two args this way rulethickness = "\the\dimexpr\chemicalparameter\c!rulethickness\relax", % todo: scaled points rulecolor = "\MPcolor{\chemicalparameter\c!rulecolor}" % we can precalculate this for speedup } ) }% \ignorespaces} \def\strc_chem_indeed_two[#1][#2]% - {\ctxcommand{chemicalcomponent(\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es, { % maybe also pass first two args this way + {\ctxlua{chemicals.component(\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es, { % maybe also pass first two args this way rulethickness = "\the\dimexpr\chemicalparameter\c!rulethickness\relax", % todo: scaled points rulecolor = "\MPcolor{\chemicalparameter\c!rulecolor}" % we can precalculate this for speedup } ) }% @@ -293,8 +289,8 @@ \def\chem_arrow_construct#1#2#3% {\enspace \mathematics{#1% - {\strut\hbox \s!spread 2\emwidth{\hss\ctxcommand{inlinechemical(\!!bs#3\!!es)}\hss}}% {\strut\hbox \s!spread 2em{\hss#3\hss}}}% - {\strut\hbox \s!spread 2\emwidth{\hss\ctxcommand{inlinechemical(\!!bs#2\!!es)}\hss}}}% {\strut\hbox \s!spread 2em{\hss#2\hss}}% + {\strut\hbox \!!spread 2\emwidth{\hss\ctxlua{chemicals.inline(\!!bs#2\!!es)}\hss}}% {\strut\hbox \!!spread 2em{\hss#2\hss}}% + {\strut\hbox \!!spread 2\emwidth{\hss\ctxlua{chemicals.inline(\!!bs#3\!!es)}\hss}}}% {\strut\hbox \!!spread 2em{\hss#3\hss}}}% \enspace} % special macros (probably needs some more work) @@ -432,9 +428,9 @@ \usechemicalstyleandcolor\c!style\c!color \ifthirdargument \ifsecondargument - \halign{\aligntab\hss\alignmark\alignmark\hss\cr#2\cr\molecule{#1}\cr#3\cr}% + \halign{&\hss##\hss\cr#2\cr\molecule{#1}\cr#3\cr}% \else - \halign{\aligntab\hss\alignmark\alignmark\hss \cr\molecule{#1}\cr#2\cr}% + \halign{&\hss##\hss\cr\molecule{#1}\cr#2\cr}% \fi \else \hbox{\molecule{#1}}% @@ -444,30 +440,30 @@ \unexpanded\def\inlinechemical#1% {\dontleavehmode - \hbox{\usechemicalstyleandcolor\c!style\c!color\ctxcommand{inlinechemical(\!!bs#1\!!es)}}} + \hbox{\usechemicalstyleandcolor\c!style\c!color\ctxlua{chemicals.inline(\!!bs#1\!!es)}}} \unexpanded\def\chemicalbondrule - {\hbox{\vrule\s!height.75\exheight\s!depth-\dimexpr.75\exheight-\linewidth\relax\s!width\emwidth\relax}} + {\hbox{\vrule\!!height.75ex\!!depth-\dimexpr.75ex-\linewidth\relax\!!width1em\relax}} \definechemicalsymbol[i:space] [\enspace\quad\enspace] \definechemicalsymbol[i:plus] [\enspace\mathematics{+}\enspace] \definechemicalsymbol[i:minus] [\enspace\mathematics{-}\enspace] \definechemicalsymbol[i:gives] [\enspace\mathematics{\xrightarrow{}{}}\enspace] -\definechemicalsymbol[i:equilibrium] [\enspace\mathematics{\xrightoverleftarrow{}{}}\enspace] +\definechemicalsymbol[i:equilibrium] [\enspace\mathematics{\xrightpverleftarrow{}{}}\enspace] \definechemicalsymbol[i:mesomeric] [\enspace\mathematics{\xleftrightarrow{}{}}\enspace] \definechemicalsymbol[i:single] [\chemicalbondrule] -\definechemicalsymbol[i:double] [\hbox{\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}] -\definechemicalsymbol[i:triple] [\hbox{\chemicalbondrule\hskip-1em\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}] +\definechemicalsymbol[i:tripple] [\hbox{\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}] +\definechemicalsymbol[i:double] [\hbox{\chemicalbondrule\hskip-1em\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}] \unexpanded\def\chemicalsinglebond {\chemicalsymbol[i:single]} -\unexpanded\def\chemicaldoublebond {\chemicalsymbol[i:double]} -\unexpanded\def\chemicaltriplebond {\chemicalsymbol[i:triple]} +\unexpanded\def\chemicaldoublebond {\chemicalsymbol[i:tripple]} +\unexpanded\def\chemicaltriplebond {\chemicalsymbol[i:double]} \unexpanded\def\chemicalgives {\chemicalsymbol[i:gives]} \unexpanded\def\chemicalmesomeric {\chemicalsymbol[i:mesomeric]} \unexpanded\def\chemicalequilibrium{\chemicalsymbol[i:equilibrium]} -\unexpanded\def\chemicalplus {\chemicalsymbol[i:plus]} -\unexpanded\def\chemicalminus {\chemicalsymbol[i:minus]} -\unexpanded\def\chemicalspace {\chemicalsymbol[i:space]} +\unexpanded\def\chemicalsplus {\chemicalsymbol[i:plus]} +\unexpanded\def\chemicalsminus {\chemicalsymbol[i:minus]} +\unexpanded\def\chemicalsspace {\chemicalsymbol[i:space]} \unexpanded\def\chemicalinline #1{#1} % display @@ -495,133 +491,61 @@ \setfalse\c_chem_has_bot} \unexpanded\def\stopchemicalformula - {\tabskip\emwidth\relax + {\tabskip1em\relax \nointerlineskip \ifconditional\c_chem_has_top \ifconditional\c_chem_has_bot - \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}% + \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}% \else - \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr}% + \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr}% \fi \else \ifconditional\c_chem_has_bot - \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}% + \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}% \else - \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_mid\cr}% + \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_mid\cr}% \fi \fi \egroup} -% for the moment we have a special set - -\definechemicalsymbol[d:space] [\enspace\quad\enspace] -\definechemicalsymbol[d:plus] [\enspace+\enspace] -\definechemicalsymbol[d:minus] [\enspace-\enspace] -\definechemicalsymbol[d:gives] [\rightarrowfill] % \chem_arrow_construct\xrightarrow -\definechemicalsymbol[d:equilibrium] [\rightoverleftarrowfill] % \chem_arrow_construct\xrightoverleftarrow -\definechemicalsymbol[d:mesomeric] [\leftarrowfill] % \chem_arrow_construct\xleftrightarrow -\definechemicalsymbol[d:opencomplex] [\mathematics{\Bigg[}] % not yet ok -\definechemicalsymbol[d:closecomplex][\mathematics{\Bigg]}] % not yet ok - -\definechemicalsymbol[d:SPACE] [{\chemicalsymbol[d:space]}] -\definechemicalsymbol[d:PLUS] [{\chemicalsymbol[d:plus]}] -\definechemicalsymbol[d:MINUS] [{\chemicalsymbol[d:minus]}] -\definechemicalsymbol[d:GIVES] [{\chemicalsymbol[d:gives]}] -\definechemicalsymbol[d:EQUILIBRIUM] [{\chemicalsymbol[d:equilibrium]}] -\definechemicalsymbol[d:MESOMERIC] [{\chemicalsymbol[d:mesomeric]}] -\definechemicalsymbol[d:OPENCOMPLEX] [{\chemicalsymbol[d:opencomplex]}] -\definechemicalsymbol[d:CLOSECOMPLEX][{\chemicalsymbol[d:closecomplex]}] - \unexpanded\def\formulachemical {\relax\dotriplegroupempty\chem_formula} -% \def\chem_formula#1#2#3% we could do hboxes and measure -% {\ifcsname\??chemicalsymbol\detokenize{#1}\endcsname -% \t_chem_mid\expandafter{\the\t_chem_mid\chem_formula_mid{#1}{#2}{#3}}% -% \else -% \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 -% \chem_formula_top_nop -% \chem_formula_bot_nop -% \fi\fi -% \t_chem_mid\expandafter{\the\t_chem_mid\molecule{#1}\aligntab}% -% \fi} - \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}}% + {\ifcsname\??chemicalsymbol\detokenize{#1}\endcsname + \t_chem_mid\expandafter{\the\t_chem_mid\chem_formula_mid{#1}{#2}{#3}}% \else - \chem_formula_top_nop - \chem_formula_bot_nop - \fi\fi - \ifcsname\??chemicalsymbol d:\detokenize{#1}\endcsname - \t_chem_mid\expandafter{\the\t_chem_mid\chemicalsymbol[d:#1]\aligntab}% - \else - \t_chem_mid\expandafter{\the\t_chem_mid\molecule{#1}\aligntab}% + \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 + \chem_formula_top_nop + \chem_formula_bot_nop + \fi\fi + \t_chem_mid\expandafter{\the\t_chem_mid\molecule{#1}&}% \fi} \def\chem_formula_mid#1% {\csname\??chemicalsymbol\detokenize{#1}\endcsname} -\def\chem_formula_top_nop {\t_chem_top\expandafter{\the\t_chem_top\aligntab}} -\def\chem_formula_bot_nop {\t_chem_bot\expandafter{\the\t_chem_bot\aligntab}} -\def\chem_formula_top_yes#1{\t_chem_top\expandafter{\the\t_chem_top\chem_formula_top_indeed{#1}\aligntab}\settrue\c_chem_has_top} -\def\chem_formula_bot_yes#1{\t_chem_bot\expandafter{\the\t_chem_bot\chem_formula_bot_indeed{#1}\aligntab}\settrue\c_chem_has_bot} +\def\chem_formula_top_nop {\t_chem_top\expandafter{\the\t_chem_top&}} +\def\chem_formula_bot_nop {\t_chem_bot\expandafter{\the\t_chem_bot&}} +\def\chem_formula_top_yes#1{\t_chem_top\expandafter{\the\t_chem_top\chem_formula_top_indeed{#1}&}\settrue\c_chem_has_top} +\def\chem_formula_bot_yes#1{\t_chem_bot\expandafter{\the\t_chem_bot\chem_formula_bot_indeed{#1}&}\settrue\c_chem_has_bot} \def\chem_formula_top_indeed#1{\strut#1} \def\chem_formula_bot_indeed#1{\strut#1} -% Experimental: defaults might change. - -\definefloat - [\v!chemical] - [\v!chemicals] - -\setuplabeltext - [\v!chemical=] - -\setupfloat - [\v!chemical] - [\c!location=\v!here, - \c!inner=\hsize.8\textwidth\dontleavehmode, % brr - \c!align={\v!flushleft,\v!lohi}] - -\setupcaption - [\v!chemical] - [\c!location=\v!right, - \c!distance=\zeropoint, - \c!width=.2\textwidth, - \c!align=\v!flushright] - -% Can be used as for displayed math: \startplaceformula... to display a chemical formula -% or a chemical structure: -% -% \startplacechemical -% \startchemicalformula -% \chemical{2H_2} -% \chemical{PLUS} -% \chemical{O_2} -% \chemical{GIVES} -% \chemical{2H_2O} -% \stopchemicalformula -% \stopplacechemical - % gone: state option resolution offset (now frame offset) alternative \setupchemicalframed [\c!align=\v!normal, \c!strut=\v!no, \c!offset=\v!overlay, - \c!frame=\v!off] + \c!frame=off] \setupchemical [\c!frame=, diff --git a/tex/context/base/cldf-bas.lua b/tex/context/base/cldf-bas.lua index 9cf8dcd4a..30a9265bc 100644 --- a/tex/context/base/cldf-bas.lua +++ b/tex/context/base/cldf-bas.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['cldf-bas'] = { +if not modules then modules = { } end modules ['cldf-ini'] = { version = 1.001, comment = "companion to cldf-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -22,8 +22,6 @@ if not modules then modules = { } end modules ['cldf-bas'] = { -- flush(ctxcatcodes,"}") -- end --- maybe use context.generics - local type = type local format = string.format local utfchar = utf.char @@ -34,16 +32,13 @@ local generics = context.generics local variables = interfaces.variables local new_rule = nodes.pool.rule -local texcount = tex.count function context.char(k) -- used as escape too, so don't change to utf if type(k) == "table" then - local n = #k - if n == 1 then - context([[\char%s\relax]],k[1]) - elseif n > 0 then - context([[\char%s\relax]],concat(k,[[\relax\char]])) - end + -- for i=1,#k do + -- context(format([[\char%s\relax]],k[i])) + -- end + context([[\char%s\relax]],concat(k,[[\relax\char]])) elseif k then context([[\char%s\relax]],k) end @@ -103,22 +98,22 @@ context.vrule = context.hrule -- not yet used ... but will get variant at the tex end as well -function context.sethboxregister(n) context([[\setbox %s\hbox]],n) end -function context.setvboxregister(n) context([[\setbox %s\vbox]],n) end +function context.sethboxregister (n) context("\\setbox %s\\hbox",n) end +function context.setvboxregister (n) context("\\setbox %s\\vbox",n) end function context.starthboxregister(n) if type(n) == "number" then - context([[\setbox%s\hbox{]],n) + context("\\setbox%s\\hbox\\bgroup",n) else - context([[\setbox\%s\hbox{]],n) + context("\\setbox\\%s\\hbox\\bgroup",n) end end function context.startvboxregister(n) if type(n) == "number" then - context([[\setbox%s\vbox{]],n) + context("\\setbox%s\\vbox\\bgroup",n) else - context([[\setbox\%s\vbox{]],n) + context("\\setbox\\%s\\vbox\\bgroup",n) end end @@ -127,36 +122,19 @@ context.stopvboxregister = context.egroup function context.flushboxregister(n) if type(n) == "number" then - context([[\box%s ]],n) + context("\\box%s ",n) else - context([[\box\%s]],n) + context("\\box\\%s",n) end end function context.beginvbox() - context([[\vbox{]]) -- we can do \bvbox ... \evbox (less tokens) + context("\\vbox\\bgroup") -- we can do \bvbox ... \evbox (less tokens) end function context.beginhbox() - context([[\hbox{]]) -- todo: use fast one + context("\\hbox\\bgroup") -- todo: use fast one end context.endvbox = context.egroup context.endhbox = context.egroup - -local function allocate(name,what,cmd) - local a = format("c_syst_last_allocated_%s",what) - local n = texcount[a] + 1 - if n <= texcount.c_syst_max_allocated_register then - texcount[a] = n - end - context("\\global\\expandafter\\%sdef\\csname %s\\endcsname %s\\relax",cmd or what,name,n) - return n -end - -function context.newdimen (name) return allocate(name,"dimen") end -function context.newskip (name) return allocate(name,"skip") end -function context.newcount (name) return allocate(name,"count") end -function context.newmuskip(name) return allocate(name,"muskip") end -function context.newtoks (name) return allocate(name,"toks") end -function context.newbox (name) return allocate(name,"box","mathchar") end diff --git a/tex/context/base/cldf-com.lua b/tex/context/base/cldf-com.lua index d9062594e..bacbbeafd 100644 --- a/tex/context/base/cldf-com.lua +++ b/tex/context/base/cldf-com.lua @@ -11,8 +11,8 @@ local context = context local generics = context.generics -- needs documentation local variables = interfaces.variables -generics.starttabulate = "starttabulate" -- "start" .. variables.tabulate -- todo: e!start -generics.stoptabulate = "stoptabulate" -- "stop" .. variables.tabulate -- todo: e!stop +generics.starttabulate = "start" .. variables.tabulate -- todo: e!start +generics.stoptabulate = "stop" .. variables.tabulate -- todo: e!stop local NC, NR = context.NC, context.NR diff --git a/tex/context/base/cldf-ini.lua b/tex/context/base/cldf-ini.lua index ad5f14855..ed86c2923 100644 --- a/tex/context/base/cldf-ini.lua +++ b/tex/context/base/cldf-ini.lua @@ -25,7 +25,7 @@ local tex = tex context = context or { } local context = context -local format, find, gmatch, gsub, validstring = string.format, string.find, string.gmatch, string.gsub, string.valid +local format, find, gmatch, gsub = string.format, string.find, string.gmatch, string.gsub local next, type, tostring, tonumber, setmetatable = next, type, tostring, tonumber, setmetatable local insert, remove, concat = table.insert, table.remove, table.concat local lpegmatch, lpegC, lpegS, lpegP, lpegCc = lpeg.match, lpeg.C, lpeg.S, lpeg.P, lpeg.Cc @@ -40,14 +40,12 @@ local isnode = node.is_node -- after 0.65 just node.type local writenode = node.write local copynodelist = node.copy_list -local catcodenumbers = catcodes.numbers - -local ctxcatcodes = catcodenumbers.ctxcatcodes -local prtcatcodes = catcodenumbers.prtcatcodes -local texcatcodes = catcodenumbers.texcatcodes -local txtcatcodes = catcodenumbers.txtcatcodes -local vrbcatcodes = catcodenumbers.vrbcatcodes -local xmlcatcodes = catcodenumbers.xmlcatcodes +local ctxcatcodes = tex.ctxcatcodes +local prtcatcodes = tex.prtcatcodes +local texcatcodes = tex.texcatcodes +local txtcatcodes = tex.txtcatcodes +local vrbcatcodes = tex.vrbcatcodes +local xmlcatcodes = tex.xmlcatcodes local flush = texsprint local flushdirect = texprint @@ -346,9 +344,9 @@ end local methodhandler = resolvers.methodhandler -function context.viafile(data,tag) +function context.viafile(data) if data and data ~= "" then - local filename = resolvers.savers.byscheme("virtual",validstring(tag,"viafile"),data) + local filename = resolvers.savers.byscheme("virtual","viafile",data) -- context.startregime { "utf" } context.input(filename) -- context.stopregime() @@ -412,11 +410,7 @@ local function writer(parent,command,first,...) -- already optimized before call done = true end end - if done then - flush(currentcatcodes,"]") - else - flush(currentcatcodes,"[]") - end + flush(currentcatcodes,"]") elseif tn == 1 then -- some 20% faster than the next loop local tj = ti[1] if type(tj) == "function" then diff --git a/tex/context/base/cldf-int.lua b/tex/context/base/cldf-int.lua index 6cbfd666f..55db9fa0b 100644 --- a/tex/context/base/cldf-int.lua +++ b/tex/context/base/cldf-int.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['cldf-int'] = { +if not modules then modules = { } end modules ['mult-clm'] = { version = 1.001, comment = "companion to mult-clm.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -14,12 +14,9 @@ if not modules then modules = { } end modules ['cldf-int'] = { local format, insert, remove, concat = string.format, table.insert, table.remove, table.concat local unpack = unpack or table.unpack -local catcodenumbers = catcodes.numbers - -local ctxcatcodes = catcodenumbers.ctxcatcodes -local vrbcatcodes = catcodenumbers.vrbcatcodes - -local contextsprint = context.sprint +local contextsprint = context.sprint +local ctxcatcodes = tex.ctxcatcodes +local vrbcatcodes = tex.vrbcatcodes local trace_define = false trackers.register("context.define", function(v) trace_define = v end) diff --git a/tex/context/base/cldf-ver.lua b/tex/context/base/cldf-ver.lua index b48fd253a..237078157 100644 --- a/tex/context/base/cldf-ver.lua +++ b/tex/context/base/cldf-ver.lua @@ -6,10 +6,6 @@ if not modules then modules = { } end modules ['cldf-ver'] = { license = "see context related readme files" } --- We have better verbatim: context.verbatim so that needs to be looked --- into. We can also directly store in buffers although this variant works --- better when used mixed with other code (synchronization issue). - local concat, tohandle = table.concat, table.tohandle local find, splitlines = string.find, string.splitlines local tostring, type = tostring, type @@ -45,7 +41,7 @@ table .tocontext = t_tocontext string .tocontext = s_tocontext boolean.tocontext = b_tocontext -function context.tocontext(first,...) +function tocontext(first,...) local t = type(first) if t == "string" then s_tocontext(first,...) diff --git a/tex/context/base/colo-ext.mkiv b/tex/context/base/colo-ext.mkiv index 8878da485..af6c3830e 100644 --- a/tex/context/base/colo-ext.mkiv +++ b/tex/context/base/colo-ext.mkiv @@ -29,10 +29,18 @@ %D %D will negate the colors in box zero. +% \unexpanded\def\negatecolorbox#1% +% {\setbox#1\hbox +% {\startnegative % might change +% \startcolor[\s!white]\vrule\!!height\ht#1\!!depth\dp#1\!!width\wd#1\stopcolor +% \hskip-\wd#1% +% \box#1% +% \stopnegative}} + \unexpanded\def\negatecolorbox#1% {\setbox#1\hbox {\startnegative % might change - % \startcolor[\s!white]\vrule\s!height\ht#1\s!depth\dp#1\s!width\wd#1\stopcolor +% \startcolor[\s!white]\vrule\!!height\ht#1\!!depth\dp#1\!!width\wd#1\stopcolor \blackrule[\c!color=\s!white,\c!height=\ht#1,\c!depth=\dp#1,\c!width=\wd#1]% \hskip-\wd#1% \box#1% diff --git a/tex/context/base/colo-icc.lua b/tex/context/base/colo-icc.lua index 4ab28eb68..904d42143 100644 --- a/tex/context/base/colo-icc.lua +++ b/tex/context/base/colo-icc.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['colo-icc'] = { +if not modules then modules = { } end modules ['colo-ini'] = { version = 1.000, comment = "companion to colo-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", diff --git a/tex/context/base/colo-ini.lua b/tex/context/base/colo-ini.lua index e08f3d387..747e2116f 100644 --- a/tex/context/base/colo-ini.lua +++ b/tex/context/base/colo-ini.lua @@ -16,8 +16,7 @@ local trace_define = false trackers.register("colors.define",function(v) trace_ local report_colors = logs.reporter("colors","defining") -local attributes, backends, storage = attributes, backends, storage -local context, commands = context, commands +local attributes, context, commands = attributes, context, commands local settings_to_hash_strict = utilities.parsers.settings_to_hash_strict @@ -667,51 +666,83 @@ function colors.defineintermediatecolor(name,fraction,c_one,c_two,a_one,a_two,sp end end -local function f(i,colors,fraction) - local otf = 0 - for c=1,#colors do - otf = otf + (tonumber(fraction[c]) or 1) * colors[c][i] - end - if otf > 1 then - otf = 1 +--~ local function f(one,two,i,fraction_one,fraction_two) +--~ local otf = fraction_one * one[i] + fraction_two * two[i] +--~ if otf > 1 then +--~ otf = 1 +--~ end +--~ return otf +--~ end + +--~ function colors.defineduocolor(name,fraction_one,c_one,fraction_two,c_two,global,freeze) +--~ local one, two = colorvalues[c_one], colorvalues[c_two] +--~ if one and two then +--~ fraction_one = tonumber(fraction_one) or 1 +--~ fraction_two = tonumber(fraction_two) or 1 +--~ local csone, cstwo = one[1], two[1] +--~ local ca +--~ if csone == 2 then +--~ ca = register_color(name,'gray',f(one,two,2,fraction_one,fraction_two)) +--~ elseif csone == 3 then +--~ ca = register_color(name,'rgb', f(one,two,3,fraction_one,fraction_two), +--~ f(one,two,4,fraction_one,fraction_two), +--~ f(one,two,5,fraction_one,fraction_two)) +--~ elseif csone == 4 then +--~ ca = register_color(name,'cmyk',f(one,two,6,fraction_one,fraction_two), +--~ f(one,two,7,fraction_one,fraction_two), +--~ f(one,two,8,fraction_one,fraction_two), +--~ f(one,two,9,fraction_one,fraction_two)) +--~ else +--~ ca = register_color(name,'gray',f(one,two,2,fraction_one,fraction_two)) +--~ end +--~ definecolor(name,ca,global,freeze) +--~ end +--~ end + + local function f(i,colors,fraction) + local otf = 0 + for c=1,#colors do + otf = otf + (tonumber(fraction[c]) or 1) * colors[c][i] + end + if otf > 1 then + otf = 1 + end + return otf end - return otf -end -function colors.definemixcolor(name,fractions,cs,global,freeze) - local values = { } - for i=1,#cs do -- do fraction in here - local v = colorvalues[cs[i]] - if not v then - return + function colors.definemixcolor(name,fractions,cs,global,freeze) + local values = { } + for i=1,#cs do -- do fraction in here + local v = colorvalues[cs[i]] + if not v then + return + end + values[i] = v end - values[i] = v - end - local csone = values[1][1] - local ca - if csone == 2 then - ca = register_color(name,'gray',f(2,values,fractions)) - elseif csone == 3 then - ca = register_color(name,'rgb', f(3,values,fractions), - f(4,values,fractions), - f(5,values,fractions)) - elseif csone == 4 then - ca = register_color(name,'cmyk',f(6,values,fractions), - f(7,values,fractions), - f(8,values,fractions), - f(9,values,fractions)) - else - ca = register_color(name,'gray',f(2,values,fractions)) + local csone = values[1][1] + local ca + if csone == 2 then + ca = register_color(name,'gray',f(2,values,fractions)) + elseif csone == 3 then + ca = register_color(name,'rgb', f(3,values,fractions), + f(4,values,fractions), + f(5,values,fractions)) + elseif csone == 4 then + ca = register_color(name,'cmyk',f(6,values,fractions), + f(7,values,fractions), + f(8,values,fractions), + f(9,values,fractions)) + else + ca = register_color(name,'gray',f(2,values,fractions)) + end + definecolor(name,ca,global,freeze) end - definecolor(name,ca,global,freeze) -end -- for the moment downward compatible local patterns = { "colo-imp-%s.mkiv", "colo-imp-%s.tex", "colo-%s.mkiv", "colo-%s.tex" } local function action(name,foundname) - -- could be one command context.startreadingfile() context.startcolorset { name } context.input(foundname) @@ -846,22 +877,3 @@ end -- context.popcatcodes() -- end --- handy - -local models = storage.allocate { "all", "gray", "rgb", "cmyk", "spot" } - -colors.models = models -- check for usage elsewhere - -function colors.spec(name) - local l = attributes_list[a_color] - local t = colorvalues[l[name]] or colorvalues[l.black] - return { - model = models[t[1]] or models[1], - s = t[2], - r = t[3], g = t[4], b = t[5], - c = t[6], m = t[7], y = t[8], k = t[9], - } -end - --- inspect(attributes.colors.spec("red")) --- inspect(attributes.colors.spec("red socks")) diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv index 629f2b96a..5721bb513 100644 --- a/tex/context/base/colo-ini.mkiv +++ b/tex/context/base/colo-ini.mkiv @@ -242,8 +242,8 @@ \setfalse\c_colo_convert_gray \getvalue{\??colorconversions\directcolorsparameter\c!conversion}% could be a nice \ifcsname % too often: - \ifconditional\c_colo_rgb_supported \colo_helpers_show_message\m!colors{10}\v!rgb \fi - \ifconditional\c_colo_cmyk_supported\colo_helpers_show_message\m!colors{10}\v!cmyk\fi + \ifconditional\c_colo_rgb_supported \colo_helpers_show_message\m!colors9\v!rgb \fi + \ifconditional\c_colo_cmyk_supported\colo_helpers_show_message\m!colors9\v!cmyk\fi \colo_helpers_set_current_model \ifproductionrun \edef\p_pagecolormodel{\directcolorsparameter\c!pagecolormodel}% @@ -357,26 +357,16 @@ \normalexpanded{\colo_palets_define[#1][\csname\??colorpaletspecification#2\endcsname]}% \fi}} -% \def\colo_palets_define_one#1#2% get rid of { } in #2 -% {\colo_palets_define_two{#1}[#2]}% - -\def\colo_palets_define_one#1#2% get rid of { } - {\doifassignmentelse{#2} % catch empty entries - {\colo_palets_define_two{#1}[#2]} - {\colo_palets_define_three{#1}{#2}}} +\def\colo_palets_define_one#1#2% get rid of { } in #2 + {\colo_palets_define_two{#1}[#2]}% \def\colo_palets_define_two#1[#2=#3]% {\edef\m_colo_palets_tmp{\ifx\m_colo_palets_tmp\empty\else\m_colo_palets_tmp,\fi#2}% \colo_palets_define_set{#1}{#2}{#3}}% -\def\colo_palets_define_three#1#2% - {\ifcsname\??colorpaletspecification#2\endcsname - \processcommacommand[\csname\??colorpaletspecification#2\endcsname]{\colo_palets_define_one{#1}}% - \fi} - \let\paletsize\!!zerocount -\unexpanded\def\getpaletsize[#1]% only works for valid k=v definitions +\def\getpaletsize[#1]% {\getcommacommandsize[\csname\??colorpaletspecification#1\endcsname]% \edef\paletsize{\number\commalistsize}} @@ -812,19 +802,9 @@ \def\defaulttextcolor {black} \def\s!themaintextcolor{themaintextcolor} -\unexpanded\def\inheritmaintextcolor - {\ifx\maintextcolor\empty\else\colo_helpers_activate\maintextcolor\fi} - -\unexpanded\def\onlyinheritmaintextcolor - {\ifx\maintextcolor\empty - \deactivatecolor - \else - \colo_helpers_activate\maintextcolor - \fi} - \appendtoks \deactivatecolor % public? - \inheritmaintextcolor + \ifx\maintextcolor\empty\else\colo_helpers_activate\maintextcolor\fi \to \everybeforeoutput \def\colo_helpers_switch_to_maintextcolor#1% @@ -981,7 +961,7 @@ % ignores in attribute handler % -% \def\forcecolorhack{\vrule\s!width\zeropoint\s!height\zeropoint\s!depth\zeropoint} +% \def\forcecolorhack{\vrule\!!width\zeropoint\!!height\zeropoint\!!depth\zeropoint} % \normal added else fails in metafun manual (leaders do a hard scan) diff --git a/tex/context/base/colo-run.lua b/tex/context/base/colo-run.lua index 27f7c6b12..4f1916d5a 100644 --- a/tex/context/base/colo-run.lua +++ b/tex/context/base/colo-run.lua @@ -6,10 +6,8 @@ if not modules then modules = { } end modules ['colo-run'] = { license = "see context related readme files" } --- For historic reasons the core has a couple of tracing features. Nowadays --- these would end up in modules. - -local colors, commands, context, utilities = colors, commands, context, utilities +-- For historic reasons the core has a couple of tracing +-- features. Nowadays these would end up in modules. local colors= attributes.colors diff --git a/tex/context/base/colo-run.mkiv b/tex/context/base/colo-run.mkiv index 5084fdd35..c330accf3 100644 --- a/tex/context/base/colo-run.mkiv +++ b/tex/context/base/colo-run.mkiv @@ -42,9 +42,9 @@ %D Palets \unexpanded\gdef\showpalet - {\dodoubleargument\colo_show_palet} + {\dodoubleargument\doshowpalet} -\gdef\colo_show_palet[#1][#2]% +\gdef\doshowpalet[#1][#2]% {\ifcsname\??colorpalet#1\endcsname \doifinsetelse\v!vertical{#2} \colo_palets_show_vertical \colo_palets_show_horizontal [#1][#2]% \fi} @@ -59,8 +59,8 @@ \tabskip\zeropoint \def\colo_palets_show_palet##1% {\doifinsetelse\v!number{#2}{##1\hskip.5em}{}& - \color[##1]{\vrule\s!width3em\s!height\strutht\s!depth\strutdp}% - \graycolor[##1]{\vrule\s!width3em\s!height\strutht\s!depth\strutdp}& + \color[##1]{\vrule\!!width3em\!!height\strutht\!!depth\strutdp}% + \graycolor[##1]{\vrule\!!width3em\!!height\strutht\!!depth\strutdp}& \doifinset\v!value{#2}{\hskip.5em\colorvalue{##1}}\crcr} \halign {\hss##&\hss##\hss&##\cr @@ -92,11 +92,11 @@ \colo_palets_process[#1]\colo_palets_show_palet}\cr \doifinset\v!name{#2}{#1\hskip.5em}% \def\colo_palets_show_palet##1% - {&\strut\color[##1]{\vrule\s!width\!!widtha\s!height\strutht\s!depth\zeropoint}}% + {&\strut\color[##1]{\vrule\!!width\!!widtha\!!height\strutht\!!depth\zeropoint}}% \colo_palets_process[#1]\colo_palets_show_palet\crcr \noalign{\vskip-\strutdepth}% \def\colo_palets_show_palet##1% - {&\graycolor[##1]{\vrule\s!width\!!widtha\s!height\zeropoint\s!depth\strutdp}}% + {&\graycolor[##1]{\vrule\!!width\!!widtha\!!height\zeropoint\!!depth\strutdp}}% \colo_palets_process[#1]\colo_palets_show_palet\crcr \doifinset\v!value{#2} {\def\colo_palets_show_palet##1% @@ -137,13 +137,13 @@ \def\colo_palets_compare##1% {\hbox {\setbox0\hbox - {#1[##1]{\vrule\s!width\hsize\s!height3ex}}% + {#1[##1]{\vrule\!!width\hsize\!!height3ex}}% \wd0\zeropoint \box0 \hbox to \hsize {\def\colo_palets_compare####1% {\hbox to \!!widtha - {\hss#1[####1]{\vrule\s!width.5\!!widtha\s!height2.25ex\s!depth-.75ex}\hss}}% + {\hss#1[####1]{\vrule\!!width.5\!!widtha\!!height2.25ex\!!depth-.75ex}\hss}}% \processcommacommand[\getvalue{\??colorpalet#2}]\colo_palets_compare}} \endgraf} \processcommacommand[\getvalue{\??colorpalet#2}]\colo_palets_compare}} @@ -171,8 +171,8 @@ {\halign {\hss####\hss\cr \doifinset\v!number{#2}{\strut##1}\cr - \color[#1:##1]{\vrule\s!width4em\s!height\strutht\s!depth\zeropoint}\cr - \graycolor[#1:##1]{\vrule\s!width4em\s!height\zeropoint\s!depth\strutdp}\cr + \color[#1:##1]{\vrule\!!width4em\!!height\strutht\!!depth\zeropoint}\cr + \graycolor[#1:##1]{\vrule\!!width4em\!!height\zeropoint\!!depth\strutdp}\cr \doifinset\v!value{#2}{\colorvalue{#1:##1}\strut}\crcr}}}}% \hbox {\doifinset\v!name{#2} @@ -195,8 +195,8 @@ \def\colo_groups_show_group##1% {\doifcolor{#1:##1} {\doifinset\v!number{#2}{##1\hskip.5em}& - \color[#1:##1]{\vrule\s!width2.5em\s!height\strutht\s!depth\strutdp}% - \graycolor[#1:##1]{\vrule\s!width2.5em\s!height\strutht\s!depth\strutdp}& + \color[#1:##1]{\vrule\!!width2.5em\!!height\strutht\!!depth\strutdp}% + \graycolor[#1:##1]{\vrule\!!width2.5em\!!height\strutht\!!depth\strutdp}& \doifinset\v!value{#2}{\hskip.5em\colorvalue{#1:##1}}\crcr}}% \halign {\hss##&\hss##\hss&##\hss\cr @@ -228,11 +228,11 @@ \def\colo_groups_compare_step#1#2#3% {\hbox to \hsize {\setbox0\hbox - {#1[#2:#3]{\vrule\s!width\hsize\s!height3ex}}% + {#1[#2:#3]{\vrule\!!width\hsize\!!height3ex}}% \wd0\zeropoint \box0 \hbox to \hsize - {\hss\dorecurse\!!counta{#1[#2:\recurselevel]{\vrule\s!width.5\!!widtha\s!height2.25ex\s!depth-.75ex}\hss}}} + {\hss\dorecurse\!!counta{#1[#2:\recurselevel]{\vrule\!!width.5\!!widtha\!!height2.25ex\!!depth-.75ex}\hss}}} \endgraf} \protect \endinput diff --git a/tex/context/base/cont-log.mkiv b/tex/context/base/cont-log.mkiv index 5d4133143..67647920d 100644 --- a/tex/context/base/cont-log.mkiv +++ b/tex/context/base/cont-log.mkiv @@ -118,7 +118,7 @@ \logofont} \def\syst_logos_meta_hyphen % there is no hyphenchar in this font - {\discretionary{\vrule\s!height.33em\s!depth-.27em\s!width.33em}{}{}} + {\discretionary{\vrule\!!height.33em\!!depth-.27em\!!width.33em}{}{}} \unexpanded\def\MetaFont {\dontleavehmode @@ -270,12 +270,4 @@ \unexpanded\def\MPII{MpII} \unexpanded\def\MPIV{MpIV} -\appendtoks - \def\ConTeXt {ConTeXt}% - \def\MetaPost{MetaPost}% - \def\MetaFont{MetaFont}% - \def\MetaFun {MetaFun}% - \def\TeX {TeX}% -\to \everysimplifycommands - \protect \endinput diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 2a2e12ba8..b4958762f 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.10.17 22:49} +\newcontextversion{2012.05.30 11:26} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 9f3d8cbc2..5a28f8e29 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,60 +11,515 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.10.17 22:49} +\newcontextversion{2012.05.30 11:26} -%D This file is loaded at runtime, thereby providing an excellent place for -%D hacks, patches, extensions and new features. +%D This file is loaded at runtime, thereby providing an +%D excellent place for hacks, patches, extensions and new +%D features. \unprotect \writestatus\m!system{beware: some patches loaded from cont-new.mkiv} -%D Maybe: +\def\dividedsize#1#2#3% size gap n + {\dimexpr + \ifnum\dimexpr#1\relax>\plusone + (\dimexpr#1\relax-\numexpr#3-1\relax\dimexpr#2\relax)/#3\else#1% + \fi + \relax} + +\def\singlewidened #1{\hbox spread 1em{\hss#1\hss}} +\def\complexwidened[#1]#2{\hbox spread #1{\hss#2\hss}} -\unexpanded\def\tightvbox{\dowithnextbox{\dp\nextbox\zeropoint\box\nextbox}\vbox} -\unexpanded\def\tightvtop{\dowithnextbox{\ht\nextbox\zeropoint\box\nextbox}\vtop} +\definecomplexorsimple\widened + +\let\active\activecatcode % for a while (tikz) + +% todo +% +% \def\definelocation{\dodoubleargument\dodefinelocation} +% \def\dodefinelocation[#1][#2]{\setvalue{loc:#1}{#2}} +% +% \definelocation[lt] [\v!left\v!top] +% \definelocation[tl] [\v!left\v!top] +% \definelocation[\v!top\v!left][\v!left\v!top] +% +% \def\getlocation#1{\executeifdefined{loc:#1}{#1}} + +% \let\cs\getvalue % no, we want \cs to be czech + +% experimental so this may change -%D Needs some work: +\def\startdescriptions + {\dosingleempty\dostartdescriptions} -\unexpanded\def\startgridcorrection - {\dosingleempty\spac_grid_correction_start} +\def\dostartdescriptions[#1]% + {\begingroup + \def\item{\getvalue{#1}}% + \let\dostoppairdescription \donothing + \let\@@description \dostartpairdescription + \let\@@startsomedescription\dostartsomedescription} -\def\spac_grid_correction_start[#1]% +\def\stopdescriptions + {\dostoppairdescription + \endgroup} + +\def\dostartpairdescription[#1][#2]% + {\dostoppairdescription + \def\dostoppairdescription{\@@stopdescription{#1}}% + \bgroup + \def\currentdescription{#1}% + \doifelse{\descriptionparameter{\s!do\c!state}}\v!start + {\@@makedescription{#1}[#2]{}} + {\@@makedescription{#1}[#2]}} + +\def\dostartsomedescription% #1[#2]#3% + {\bgroup + \@@makedescription} % {#1}[#2]{#3}} + +% \starttext +% +% \definedescription[test] +% +% \startdescriptions +% \test{Foo} Bar bar bar +% \test{Foo} Bar bar bar +% \test{Foo} Bar bar bar +% \stopdescriptions +% +% \startdescriptions[test] +% \item{Foo} Bar bar bar +% \item{Foo} Bar bar bar +% \item{Foo} Bar bar bar +% \stopdescriptions +% +% \startdescriptions +% \starttest{Foo} Bar bar bar \stoptest +% \starttest{Foo} Bar bar bar \stoptest +% \starttest{Foo} Bar bar bar \stoptest +% \stopdescriptions +% +% \startdescriptions[test] +% \item{Foo} Bar bar bar +% \item{Foo} Bar bar bar +% \item{Foo} Bar bar bar +% \stopdescriptions +% +% \stoptext + +% this will be activated when +% +% \newinsert\thispageinsert % <- installinsertion +% +% \def\flushatthispage +% {\bgroup +% \dowithnextbox{\insert\thispageinsert{\box\nextbox}\egroup}% +% \hbox} +% +% \appendtoks +% \ifvoid\thispageinsert\else\hbox{\smashedbox\thispageinsert}\fi +% \to \everyshipout + +% \definemarkedpage[nobackgrounds] +% \markpage[nobackgrounds] +% \doifmarkedpageelse{nobackgrounds} + +% Just a simple and fast hanger, for usage in macros. + +\def\setuphanging + {\dodoubleempty\getparameters[\??ha]} + +\setuphanging + [\c!distance=.5em] + +\def\starthanging + {\noindent\bgroup + \dowithnextbox + {\setbox\nextbox\hbox{\flushnextbox\hskip\@@hadistance}% + \hangindent\nextboxwd + \hangafter\plusone + \flushnextbox\ignorespaces} + \hbox} + +\def\stophanging + {\endgraf + \egroup} + +% experimental + +\def\stophangaround + {\endgraf + \egroup} + +\def\starthangaround + {\noindent\bgroup + \dowithnextbox + {\ifdim\nextboxht>\strutht\setbox\nextbox\tbox{\flushnextbox}\fi + \setbox\nextbox\hbox{\flushnextbox\hskip\@@hadistance}% + \getboxheight\scratchdimen\of\box\nextbox + \getnoflines\scratchdimen + \nextboxht\strutht + \nextboxdp\strutdp + \hangindent\nextboxwd + \hangafter-\noflines + \llap{\flushnextbox}\ignorespaces} + \hbox} + +\def\modevalue#1#2#3% + {\@EA\ifx\csname\@mode@\systemmodeprefix#1\endcsname\endcsname\enabledmode#2\else#2\fi} + +\def\systemmodevalue#1% + {\modevalue{\systemmodeprefix#1}} + +% new, still to be improved +% +% \dorecurse{10} +% {\input thuan +% \placefigure{}{\framed[height=1.5cm]{test}} +% \placefloatplaceholder} + +\def\placefloatplaceholder + {\ifroomforfloat \else + \scratchdimen\pagegoal + \advance\scratchdimen-\pagetotal + \advance\scratchdimen-3\lineheight + \ifdim\scratchdimen>\zeropoint + \startlinecorrection[blank] + \mhbox{\inframed{\labeltexts{placeholder}{\lastcaptiontag}}}% + \stoplinecorrection + \else + \allowbreak + \fi + \fi} + +\setuplabeltext + [placeholder={, moved}] + +% move to support module, and then use context(...) + +\startluacode + function commands.percentageof(str,dim) + local n = str:match("^(.*)%%$") + context.sprint(tex.ctxcatcodes,(n and (tonumber(n)/100)*dim .. "sp") or str) + end +\stopluacode + +\gdef\setpercentdimen#1#2% + {#1=\ctxcommand{percentageof("#2",\number#1)}\relax} + +% \scratchdimen=100pt \setpercentdimen\scratchdimen{10\letterpercent} \the\scratchdimen +% \scratchdimen=100pt \setpercentdimen\scratchdimen{5pt} \the\scratchdimen + +\bgroup \permitcircumflexescape + +\obeylines % don't remove %'s ! + +\gdef\collapsedspace#1% + {\ifx#1^^M% + \expandafter\collapsedspace + \else + \space + \expandafter#1% + \fi} + +\gdef\collapsespaces + {\prependtoksonce\relax\to\everyeof% + \ignorelines% + \ignoretabs% + \let\obeyedspace\collapsedspace% + \obeyspaces} + +\egroup + +\def\inlinedbox + {\bgroup + \dowithnextbox + {\scratchdimen\nextboxht + \advance\scratchdimen\nextboxdp + \advance\scratchdimen-\lineheight + \divide\scratchdimen\plustwo + \advance\scratchdimen\strutdepth + \setbox\nextbox\hbox{\lower\scratchdimen\flushnextbox}% + \nextboxht\strutht + \nextboxdp\strutdp + \flushnextbox + \egroup}% + \hbox} + +\def\dimenratio#1#2% etex only + {\withoutpt\the\dimexpr2\dimexpr(#1)/\dimexpr(#2)/32768\relax\relax} + +\def\doxprecurse#1#2% + {\ifnum#1=\zerocount % no \ifcase + \expandafter\gobblethreearguments + \else + #2\expandafter\expandafter\expandafter\doxprecurse\expandafter + \fi\expandafter{\the\numexpr#1-1\relax}{#2}} + +\def\buttonframed{\dodoubleempty\localframed[\??bt]} % goodie + +\unexpanded\def\asciistr#1{\dontleavehmode{\defconvertedargument\ascii{#1}\verbatimfont\ascii}} + +\def\shapefill{\vskip\zeropoint\!!plus\lineheight\!!minus\lineheight\relax} + +% \ruledhbox +% {\startignorespaces +% \def\oeps{a} +% \startignorespaces +% \def\oeps{a} +% \stopignorespaces +% \def\oeps{a} +% \stopignorespaces +% \oeps} + +\newsignal\boissignal +\newcount \boislevel + +\long\def\startignorespaces + {\advance\boislevel\plusone + \ifcase\boislevel\or \ifhmode + \hskip\boissignal + \fi \fi + \ignorespaces} + +\long\def\stopignorespaces + {\ifcase\boislevel\or \ifhmode + \doloop + {\ifdim\lastskip=\zeropoint + \exitloop + \else\ifdim\lastskip=\boissignal + \unskip + \exitloop + \else + \unskip + \fi\fi}% + \fi \fi + \advance\boislevel\minusone} + +\def\minimalhbox#1#% + {\dowithnextbox + {\bgroup + \setbox\scratchbox\hbox#1{\hss}% + \ifdim\nextboxwd<\wd\scratchbox\nextboxwd\wd\scratchbox\fi + \flushnextbox + \egroup} + \hbox} + +\def\gobbleuntilempty#1\empty{} + +\def\dodimchoice#1#2#3% + {\ifdim#1#2% + #3\@EA\gobbleuntilempty + \else + \@EA\dodimchoice + \fi{#1}} + +\def\donumchoice#1#2#3% + {\ifnum#1#2% + #3\@EA\gobbleuntilempty + \else + \@EA\dodimchoice + \fi{#1}} + +\def\dimchoice#1#2{\dodimchoice{#1}#2{=#1}{#1}\empty} +\def\numchoice#1#2{\donumchoice{#1}#2{=#1}{#1}\empty} + +% \the\dimexpr(\dimchoice {7pt}{{<10pt}{8pt}{<12pt}{9pt}{<15pt}{10pt}{=11pt}{12pt}}) +% \the\dimexpr(\dimchoice{11pt}{{<10pt}{8pt}{<12pt}{9pt}{<15pt}{10pt}{=11pt}{12pt}}) +% \the\dimexpr(\dimchoice{14pt}{{<10pt}{8pt}{<12pt}{9pt}{<15pt}{10pt}{=11pt}{12pt}}) + +\def\tabulaterule % to be redone, not correct + {\dotabulaterule + {\hrule\!!height.5\scratchdimen\!!depth.5\scratchdimen\relax + \doifvalue{\??tt\currenttabulate\c!distance}\v!grid + {\kern-\scratchdimen}}} % experimental tm-prikkels +% so far + +% between alignment lines certain rules apply, and even a +% simple test can mess up a table, which is why we have a +% special test facility +% +% \ruledvbox +% {\starttabulate[|l|p|] +% \NC 1test \NC test \NC \NR +% \tableifelse{\doifelse{a}{a}}{\NC Xtest \NC test \NC \NR}{}% +% \stoptabulate} + +\long\def\tableifelse#1% + {\tablenoalign + {#1% + {\aftergroup \firstoftwoarguments}% + {\aftergroup\secondoftwoarguments}}} + +\long \def\tableiftextelse#1{\tableifelse{\doiftextelse{#1}}} + +\def\tightvbox{\dowithnextbox{\nextboxdp\zeropoint\flushnextbox}\vbox} +\def\tightvtop{\dowithnextbox{\nextboxht\zeropoint\flushnextbox}\vtop} + +% what is this stupid macro meant for: + +\def\hyphenationpoint + {\hskip\zeropoint} + +\def\hyphenated#1% + {\bgroup + \!!counta\zerocount + \def\hyphenated##1{\advance\!!counta\plusone}% + \handletokens#1\with\hyphenated + \!!countb\plusone + \def\hyphenated##1% + {##1% + \advance\!!countb\plusone\relax + \ifnum\!!countb>2 \ifnum\!!countb<\!!counta + \hyphenationpoint + \fi\fi}% + \handletokens#1\with\hyphenated + \egroup} + +\def\obeysupersubletters + {\let\super\normalsuper + \let\suber\normalsuber + \let\normalsuper\letterhat + \let\normalsuber\letterunderscore + \enablesupersub} + +\def\obeysupersubmath + {\let\normalsuper\letterhat + \let\normalsuber\letterunderscore + \enablesupersub} + +\def\startgridcorrection + {\dosingleempty\dostartgridcorrection} + +\def\dostartgridcorrection[#1]% {\ifgridsnapping \snaptogrid[#1]\vbox\bgroup \else \startbaselinecorrection \fi} -\unexpanded\def\stopgridcorrection +\def\stopgridcorrection {\ifgridsnapping \egroup \else \stopbaselinecorrection \fi} - -\unexpanded\def\checkgridsnapping + +\def\checkgridsnapping {\lineskip\ifgridsnapping\zeropoint\else\normallineskip\fi} + +\def\startplaatsen + {\dosingleempty\dostartplaatsen} -%D Probably obsolete: +\def\dostartplaatsen[#1]% tzt n*links etc + {\endgraf + \noindent\bgroup + \setlocalhsize + \hbox to \localhsize\bgroup + \doifnot{#1}\v!left\hss + \def\stopplaatsen + {\unskip\unskip\unskip + \doifnot{#1}\v!right\hss + \egroup + \egroup + \endgraf}% + \gobblespacetokens} -\unexpanded\def\startcolumnmakeup % don't change +% \startplaatsen[links] bla \stopplaatsen + +\def\startcolumnmakeup % don't change {\bgroup - \getrawnoflines\textheight % raw as we cna have topskip - \setbox\scratchbox\vbox to \dimexpr\noflines\lineheight-\lineheight+\topskip\relax - \bgroup - \forgetall} + \getrawnoflines\textheight % teksthoogte kan topskip hebben, dus raw + \scratchdimen\noflines\lineheight + \advance\scratchdimen-\lineheight + \advance\scratchdimen\topskip + \setbox\scratchbox + \ifcase\showgridstate\vbox\else\ruledvbox\fi to \scratchdimen\bgroup + \forgetall} % ! don't change -\unexpanded\def\stopcolumnmakeup +\def\stopcolumnmakeup {\egroup \dp\scratchbox\zeropoint \wd\scratchbox\textwidth \box\scratchbox \egroup \page_otr_command_synchronize_hsize} + +\long\def\startexternalfigure + {\dotripleempty\dostartexternalfigure} + +\long\def\dostartexternalfigure[#1][#2][#3]#4\stopexternalfigure + {\gdef\figuredescription{#4}% + \externalfigure[#1][#2][#3]% + \globallet\figuredescription\empty} + +\let\figuredescription\empty + +% incomplete, will be a special case of float placement + +\def\startfixed{\dosingleempty\dostartfixed} + +\def\dostartfixed[#1]% + {\expanded{\dowithnextbox{\noexpand\dodofixed{\ifhmode0\else1\fi}{#1}}}% + \vbox\bgroup + \setlocalhsize} + +\def\stopfixed + {\egroup} + +\def\dodofixed#1#2% + {\ifcase#1\relax + \processaction + [#2] + [ \v!high=>\bbox {\flushnextbox}, + \v!low=>\tbox {\flushnextbox}, + \v!middle=>\vcenter{\flushnextbox}, + \v!lohi=>\vcenter{\flushnextbox}, + \s!unknown=>\tbox {\flushnextbox}, + \s!default=>\tbox {\flushnextbox}]% + \else + \startbaselinecorrection + \noindent\flushnextbox + \stopbaselinecorrection + \fi} + +% \startitemize +% +% \item \externalfigure[koe][height=2cm] +% \item \externalfigure[koe][height=2cm] +% \item \externalfigure[koe][height=2cm] +% \item \externalfigure[koe][height=2cm] +% +% \page +% +% \item \startfixed \externalfigure[koe][height=2cm]\stopfixed +% \item \startfixed[high]\externalfigure[koe][height=2cm]\stopfixed +% \item \startfixed[low] \externalfigure[koe][height=2cm]\stopfixed +% \item \startfixed[lohi]\externalfigure[koe][height=2cm]\stopfixed +% +% \page +% +% \item test \startfixed \externalfigure[koe][height=2cm]\stopfixed +% \item test \startfixed[high]\externalfigure[koe][height=2cm]\stopfixed +% \item test \startfixed[low] \externalfigure[koe][height=2cm]\stopfixed +% \item test \startfixed[lohi]\externalfigure[koe][height=2cm]\stopfixed +% +% \page +% +% \item test \par \startfixed \externalfigure[koe][height=2cm]\stopfixed +% \item test \par \startfixed[high]\externalfigure[koe][height=2cm]\stopfixed +% \item test \par \startfixed[low] \externalfigure[koe][height=2cm]\stopfixed +% \item test \par \startfixed[lohi]\externalfigure[koe][height=2cm]\stopfixed +% +% \stopitemize + +\def\obeyfollowingtoken{{}} % end \cs scanning + +% potential new defaults: +% +% \setbreakpoints[compound] -%D Till we fixed all styles: +% till we fixed all styles: \let\\=\crlf diff --git a/tex/context/base/cont-nop.mkiv b/tex/context/base/cont-nop.mkiv deleted file mode 100644 index c8188503e..000000000 --- a/tex/context/base/cont-nop.mkiv +++ /dev/null @@ -1,22 +0,0 @@ -%D \module -%D [ file=cont-nop, -%D version=2012.06.01, -%D title=\CONTEXT\ Miscellaneous Macros, -%D subtitle=Startup Dummy, -%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 - -\writestatus\m!system{loading dummy replacement for jobname} - -\protect - -\finishjob - -\endinput diff --git a/tex/context/base/cont-yes.mkiv b/tex/context/base/cont-yes.mkiv deleted file mode 100644 index 2a032fc0b..000000000 --- a/tex/context/base/cont-yes.mkiv +++ /dev/null @@ -1,80 +0,0 @@ -%D \module -%D [ file=cont-yes, -%D version=2012.06.01, -%D title=\CONTEXT\ Miscellaneous Macros, -%D subtitle=Startup Stub, -%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. - -% 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. - -\startluacode - - -- When a style is loaded there is a good change that we never enter - -- this code. - - environment.initializefilenames() - - local arguments = environment.arguments - local suffix = environment.suffix - local filename = environment.filename - - 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. - - context.starttext() - context.xmlprocess("main",filename,"") - context.stoptext() - - elseif suffix == "cld" or arguments.forcecld then - - context.runfile(filename) - - elseif suffix == "lua" or arguments.forcelua then - - -- The wrapping might go away. Why is is it there in the - -- first place. - - context.starttext() - context.ctxlua(string.format('dofile("%s")',filename)) - context.stoptext() - - elseif suffix == "mp" or arguments.forcemp then - - 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 - - -- We have a regular tex file so no \starttext yet as we can - -- load fonts. - - context.input(filename) - - end - - context.finishjob() - -\stopluacode - -\endinput diff --git a/tex/context/base/context-base.lmx b/tex/context/base/context-base.lmx index 2b093c3e1..09817463b 100644 --- a/tex/context/base/context-base.lmx +++ b/tex/context/base/context-base.lmx @@ -19,9 +19,7 @@ + diff --git a/tex/context/base/context-help.lmx b/tex/context/base/context-help.lmx index 939b70cb6..5401fb65d 100644 --- a/tex/context/base/context-help.lmx +++ b/tex/context/base/context-help.lmx @@ -19,7 +19,6 @@ <?lua pv('title') ?> -