From c36e19abdfd15bf6cae6fa379c6ce51f3ef5332d Mon Sep 17 00:00:00 2001 From: Marius Date: Fri, 19 Oct 2012 01:21:22 +0300 Subject: beta 2012.10.19 00:06 --- 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 4128 -> 4140 bytes tex/context/base/context-version.png | Bin 105721 -> 105499 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 24413 -> 24585 bytes tex/context/base/status-lua.pdf | Bin 180149 -> 195620 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 | 73 +- tex/context/base/strc-flt.mkvi | 1061 +-- 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 | 241 +- 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 | 488 +- tex/context/base/strc-not.lua | 180 +- tex/context/base/strc-not.mkvi | 631 +- 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 | 44 +- 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 | 391 ++ 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 | 7308 ++++++++++--------- tex/generic/context/luatex/luatex-fonts.lua | 2 +- tex/generic/context/luatex/luatex-mplib.tex | 11 +- 545 files changed, 49842 insertions(+), 32322 deletions(-) delete mode 100644 tex/context/base/buff-par.mkiv create mode 100644 tex/context/base/buff-par.mkvi create mode 100644 tex/context/base/cont-nop.mkiv create mode 100644 tex/context/base/cont-yes.mkiv delete mode 100644 tex/context/base/context.todo create mode 100644 tex/context/base/core-ctx.ctx delete mode 100644 tex/context/base/core-fnt.mkiv delete mode 100644 tex/context/base/core-mis.mkiv delete mode 100644 tex/context/base/core-var.mkiv create mode 100644 tex/context/base/font-afk.lua create mode 100644 tex/context/base/font-aux.mkvi create mode 100644 tex/context/base/font-chk.mkiv delete mode 100644 tex/context/base/font-gds.mkiv create mode 100644 tex/context/base/font-gds.mkvi create mode 100644 tex/context/base/font-sol.lua create mode 100644 tex/context/base/font-sol.mkvi create mode 100644 tex/context/base/lang-frd.mkiv create mode 100644 tex/context/base/lang-frq.mkiv create mode 100644 tex/context/base/m-ipsum.mkiv create mode 100644 tex/context/base/m-json.mkiv create mode 100644 tex/context/base/m-oldfun.mkiv create mode 100644 tex/context/base/m-oldnum.mkiv create mode 100644 tex/context/base/m-spreadsheet.lua create mode 100644 tex/context/base/math-fbk.lua create mode 100644 tex/context/base/math-ttv.lua create mode 100644 tex/context/base/meta-grd.mkiv create mode 100644 tex/context/base/mult-fun.lua delete mode 100644 tex/context/base/node-par.lua delete mode 100644 tex/context/base/node-par.mkiv delete mode 100644 tex/context/base/node-spl.lua delete mode 100644 tex/context/base/node-spl.mkiv create mode 100644 tex/context/base/pack-cut.mkiv create mode 100644 tex/context/base/page-ins.lua delete mode 100644 tex/context/base/page-mis.lua delete mode 100644 tex/context/base/page-mis.mkiv create mode 100644 tex/context/base/page-mix.lua create mode 100644 tex/context/base/page-mix.mkiv create mode 100644 tex/context/base/page-pst.lua create mode 100644 tex/context/base/page-pst.mkiv delete mode 100644 tex/context/base/page-sel.mkiv create mode 100644 tex/context/base/page-sel.mkvi create mode 100644 tex/context/base/spac-cha.mkiv delete mode 100644 tex/context/base/supp-ali.mkiv delete mode 100644 tex/context/base/supp-fun.mkiv delete mode 100644 tex/context/base/supp-num.mkiv create mode 100644 tex/context/base/tabl-mis.mkiv create mode 100644 tex/context/base/trac-ctx.lua create mode 100644 tex/context/base/trac-ctx.mkiv create mode 100644 tex/context/base/trac-vis.lua create mode 100644 tex/context/base/typo-bld.lua create mode 100644 tex/context/base/typo-bld.mkiv create mode 100644 tex/context/base/typo-itm.mkiv create mode 100644 tex/context/base/util-jsn.lua create mode 100644 tex/context/base/util-sql-imp-client.lua create mode 100644 tex/context/base/util-sql-imp-library.lua create mode 100644 tex/context/base/util-sql-imp-swiglib.lua create mode 100644 tex/context/base/util-sql-loggers.lua create mode 100644 tex/context/base/util-sql-sessions.lua create mode 100644 tex/context/base/util-sql-tickets.lua create mode 100644 tex/context/base/util-sql-users.lua create mode 100644 tex/context/base/util-sql.lua create mode 100644 tex/context/base/util-sta.lua create mode 100644 tex/context/base/util-tpl.lua delete mode 100644 tex/context/base/x-mathml.mkiv create mode 100644 tex/context/base/x-xfdf.mkiv create 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 9f9770fb6..c7c6190be 100644 --- a/tex/context/base/anch-bar.mkiv +++ b/tex/context/base/anch-bar.mkiv @@ -58,7 +58,9 @@ \installcommandhandler \??sidebar {sidebar} \??sidebar \newcount\c_anch_sidebars_n -\newdimen\c_anch_sidebars_distance +\newcount\c_anch_sidebars_current % local +\newdimen\d_anch_sidebars_distance +\newcount\c_anch_sidebars_level % \setupMPvariables % [mpos:sidebar] @@ -67,24 +69,60 @@ % distance=5pt] \setupsidebar - [\c!rulethickness=2pt, + [\c!rulethickness=\dimexpr\bodyfontsize/6\relax, % 2pt default \c!rulecolor=\s!black, \c!alternative=0, - \c!topoffset=0pt, - \c!bottomoffset=0pt, - \c!distance=.5\bodyfontsize] + \c!topoffset=\zeropoint, + \c!bottomoffset=\zeropoint, + \c!distance=.5\bodyfontsize, + \c!level=, + \c!leftmargindistance=\zeropoint] \let\setupsidebars\setupsidebar \unexpanded\def\startsidebar {\dosingleempty\anch_sidebars_start} -\def\anch_sidebars_start[#1]% +\unexpanded\def\startsidebar + {\dodoubleempty\anch_sidebars_start} + +\def\anch_sidebars_start[#1][#2]% {\bgroup - \def\currentsidebar{#1}% \dontleavehmode + \advance\c_anch_sidebars_level\plusone \global\advance\c_anch_sidebars_n\plusone - \advance\c_anch_sidebars_distance\sidebarparameter\c!distance + \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 \startpositionoverlay{text-1}% \normalexpanded{\setMPpositiongraphicrange % maybe expand in definition {b:sidebar:\the\c_anch_sidebars_n}% @@ -94,15 +132,17 @@ linewidth=\sidebarparameter\c!rulethickness, linecolor=\sidebarparameter\c!rulecolor, alternative=\sidebarparameter\c!alternative, - topoffset=\sidebarparameter\c!topoffset, - bottomoffset=\sidebarparameter\c!bottomoffset, - distance=\the\c_anch_sidebars_distance}}% + topoffset=\the\dimexpr\sidebarparameter\c!topoffset, + bottomoffset=\the\dimexpr\sidebarparameter\c!bottomoffset, + distance=\the\d_anch_sidebars_distance}% + }% \stoppositionoverlay - \bpos{sidebar:\the\c_anch_sidebars_n}} + \bpos{sidebar:\the\c_anch_sidebars_current}% + \ignorespaces} \unexpanded\def\stopsidebar {\removelastspace - \epos{sidebar:\the\c_anch_sidebars_n} + \epos{sidebar:\the\c_anch_sidebars_current} \carryoverpar\egroup} %D Let's keep this nice and simple (okay, we could pass the 6 variables in @@ -121,49 +161,73 @@ \MPpositiongraphic{mpos:sidebar}{}% \stopMPpositionmethod -%D We now reimplement the margin rules handler defined in -%D \type {core-rul}: +%D We now reimplement the \MKII\ margin rules handler in a more +%D modern way. %D -%D \setupmarginrules[level=5] +%D \setupmarginrules +%D [rulecolor=darkred, +%D rulethickness=2pt] %D -%D \startmarginrule[1] -%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 \setupmarginrules % sidebar +%D [2] +%D [rulecolor=darkblue] %D -%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 \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 \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 +%D Compared to the old mechanism we now can pass settings too. \definesidebar [\v!margin] - [\c!rulethickness=\@@karulethickness, - \c!distance=\dimexpr\leftmargindistance-\@@karulethickness/2\relax] + [\c!leftmargindistance=\dimexpr\leftmargindistance+\sidebarparameter\c!rulethickness/2\relax] -\definecomplexorsimple\startmarginrule +\dorecurse{5}{\definesidebar[\v!margin:#1][\v!margin]} % let's be nice and predefine 5 levels -\def\simplestartmarginrule - {\complexstartmarginrule[1]} +\unexpanded\def\setupmarginrule + {\dodoubleargument\anch_marginrules_setup} -\def\complexstartmarginrule[#1]% - {\bgroup - \ifnum#1<\@@kalevel\relax - \let\stopmarginrule\egroup +\def\anch_marginrules_setup[#1][#2]% + {\ifsecondargument + \setupsidebar[\v!margin:#1][#2]% \else - \def\@@kadefaultwidth{#1}% - \let\stopmarginrule\dostopmarginrule - \normalexpanded{\startsidebar[\v!margin]}% why expanded + \setupsidebar[\v!margin][#1]% \fi} -\def\dostopmarginrule - {\stopsidebar - \egroup} +\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][]% + \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]}% + \fi} + +\def\anch_marginrules_check#1% + {\doifnotcommandhandler\??sidebar{\v!margin:#1}{\definesidebar[\v!margin:#1][\v!margin]}} + +\let\stopmarginrule\stopsidebar \protect \endinput diff --git a/tex/context/base/anch-bck.mkvi b/tex/context/base/anch-bck.mkvi index 8ec056468..79e42dc0a 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 + \vskip-\dimexpr\lineheight+\parskip\relax % problem: we loose the hangindent \nobreak \endgroup \begingroup @@ -298,7 +298,7 @@ \endgraf % new \textbackgroundparameter\c!after} -\unexpanded\def\checkpositionoverlays +\unexpanded\def\checkpositionoverlays % overloads \relax in anch-pgr {\ifproductionrun \enabletextarearegistration \enablehiddenbackground @@ -307,7 +307,7 @@ \setuptextbackground [\c!mp=mpos:region:draw, - \c!method=mpos:region, + \c!method=mpos:region, % mpos:regionshape \c!state=\v!start, \c!location=\v!text, \c!leftoffset=\!!zeropoint, % 1em, @@ -397,6 +397,14 @@ \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 bf4dcbe02..aba61794b 100644 --- a/tex/context/base/anch-pgr.lua +++ b/tex/context/base/anch-pgr.lua @@ -8,6 +8,8 @@ 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 @@ -47,34 +49,48 @@ end local eps = 2 -local function add(t,x,y,last) +local function add(t,x,y,last,direction) 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 abs(lx-tm[1]) <= eps and abs(lx-x) <= eps then - if abs(ly-y) > eps then - tn[2] = y + 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 } end - elseif abs(ly-tm[2]) <= eps and abs(ly-y) <= eps then - if abs(lx-x) > eps then - tn[1] = x + 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 } end - elseif not last then - t[n+1] = { x, y } +end 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 @@ -109,105 +125,103 @@ end -- todo: mark regions and free paragraphs in collected -local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot) +local function shapes(r,rx,ry,rw,rh,rd,lytop,lybot,rytop,rybot,obeyhang) -- 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 = 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 + 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 local py = p.y local ph = p.h local pd = p.d - local hi = p.hi - local hang = ha * (ph + pd) + local step = ph + pd + local size = #ps * step 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) - 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 + 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") 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 - -- 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 + 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 return clip(leftshape,lytop,lybot), clip(rightshape,rytop,rybot) end -local function singlepart(b,e,r,left,right) +-- 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 bx, by = b.x, b.y local ex, ey = e.x, e.y local rx, ry = r.x, r.y @@ -238,7 +252,7 @@ local function singlepart(b,e,r,left,right) } else area = { } - local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,ed,bh,eh) + local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,ed,bh,eh,obeyhang) add(area,bx,bh-ry) for i=1,#rightshapes do local ri = rightshapes[i] @@ -265,7 +279,7 @@ local function singlepart(b,e,r,left,right) } end -local function firstpart(b,r,left,right) +local function firstpart(b,r,left,right,obeyhang) local bx, by = b.x, b.y local rx, ry = r.x, r.y local rw = rx + r.w @@ -278,7 +292,7 @@ local function firstpart(b,r,left,right) 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) + local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,bd,rd,bh,rd,obeyhang) add(area,bx,bh-ry) for i=1,#rightshapes do local ri = rightshapes[i] @@ -302,7 +316,7 @@ local function firstpart(b,r,left,right) } end -local function middlepart(r,left,right) +local function middlepart(r,left,right,obeyhang) local rx, ry = r.x, r.y local rw = rx + r.w local rh = ry + r.h @@ -312,7 +326,7 @@ local function middlepart(r,left,right) rw = rw - right end local area = { } - local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,rh,rd,rh,rd) + local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,rh,rd,rh,rd,obeyhang) for i=#leftshapes,1,-1 do local li = leftshapes[i] add(area,li[1],li[2]-ry) @@ -333,7 +347,7 @@ local function middlepart(r,left,right) } end -local function lastpart(e,r,left,right) +local function lastpart(e,r,left,right,obeyhang) local ex, ey = e.x, e.y local rx, ry = r.x, r.y local rw = rx + r.w @@ -347,7 +361,7 @@ local function lastpart(e,r,left,right) 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) + local leftshapes, rightshapes = shapes(r,rx,ry,rw,rh,rd,rh,ed,rh,eh,obeyhang) for i=1,#rightshapes do local ri = rightshapes[i] add(area,ri[1],ri[2]-ry) @@ -375,7 +389,7 @@ local backgrounds = { } graphics.backgrounds = backgrounds -local function calculatemultipar(tag) +local function calculatemultipar(tag,obeyhang) local collected = jobpositions.collected local b = collected[format("b:%s",tag)] local e = collected[format("e:%s",tag)] @@ -429,13 +443,13 @@ local function calculatemultipar(tag) -- if bindex == eindex then return { - list = { [b.p] = { singlepart(b,e,collected[br],left,right) } }, + list = { [b.p] = { singlepart(b,e,collected[br],left,right,obeyhang) } }, bpos = b, epos = e, } else local list = { - [b.p] = { firstpart(b,collected[br],left,right) }, + [b.p] = { firstpart(b,collected[br],left,right,obeyhang) }, } for i=bindex+1,eindex-1 do br = format("%s:%s",btag,i) @@ -446,18 +460,18 @@ local function calculatemultipar(tag) local p = r.p local pp = list[p] if pp then - pp[#pp+1] = middlepart(r,left,right) + pp[#pp+1] = middlepart(r,left,right,obeyhang) else - list[p] = { middlepart(r,left,right) } + list[p] = { middlepart(r,left,right,obeyhang) } end end end local p = e.p local pp = list[p] if pp then - pp[#pp+1] = lastpart(e,collected[er],left,right) + pp[#pp+1] = lastpart(e,collected[er],left,right,obeyhang) else - list[p] = { lastpart(e,collected[er],left,right) } + list[p] = { lastpart(e,collected[er],left,right,obeyhang) } end return { list = list, @@ -537,10 +551,10 @@ local template_d = [[ setbounds currentpicture to multibox ; ]] -function backgrounds.fetchmultipar(n,anchor,page) +function backgrounds.fetchmultipar(n,anchor,page,obeyhang) local data = pbg[n] if not data then - data = calculatemultipar(n) + data = calculatemultipar(n,obeyhang) pbg[n] = data -- can be replaced by register -- register(data.list,n,anchor) end @@ -590,6 +604,10 @@ 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[] ; @@ -642,10 +660,10 @@ end local doifelse = commands.doifelse -function commands.doifelsemultipar(n,page) +function commands.doifelsemultipar(n,page,obeyhang) local data = pbg[n] if not data then - data = calculatemultipar(n) + data = calculatemultipar(n,obeyhang) pbg[n] = data end if page then diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index a417d26e3..01ef25dc4 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\dosetpositionaction#1% +\unexpanded\def\anch_positions_set_action#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{\dosetpositionaction{\currentpositionanchor}{\noexpand\getvalue{\??positioncleanup\currentpositionanchor}}}% + \normalexpanded{\anch_positions_set_action{\currentpositionanchor}{\noexpand\getvalue{\??positioncleanup\currentpositionanchor}}}% \let#1\relax \ifcsname\??positioncleanup\currentpositionanchor\endcsname \setxvalue{\??positioncleanup\currentpositionanchor}% @@ -140,9 +140,6 @@ \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}} @@ -218,7 +215,6 @@ %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, @@ -237,8 +233,8 @@ \def\textbackgroundoverlay#1{\v!text#1} \def\MPanchornumber {\the\realpageno} -\def\positionoverlay % the test prevents too many redundant positions - {\ifpositioning % in (not used) text* position layers +\unexpanded\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 @@ -269,7 +265,7 @@ \box\scratchbox \vfill}} -\def\positionregionoverlay % shares regions +\unexpanded\def\positionregionoverlay % shares regions {\ifpositioning \expandafter\anch_positions_region_overlay_indeed \else % also \iftrialtypesetting test here? @@ -308,9 +304,15 @@ \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}} @@ -318,9 +320,11 @@ \unexpanded\def\stoppositionoverlay {\let\currentpositionoverlay\empty} +% needs checking if still needed +% % \def\resetpositionoverlay#1% -% {\dosetpositionaction{#1::\MPanchoridentifier::}{}} - +% {\anch_positions_set_action{#1::\MPanchoridentifier::}{}} +% % \def\handlepositionboxes#1#2#3% % {\handlepositionaction\dohandlepositionboxes\with{#1}{#2}{#3}\on{#2}} % @@ -332,15 +336,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 @@ -350,7 +354,7 @@ \installcorenamespace{positionmethod} %installcorenamespace{graphicvariable} -\newbox\positiongraphicbox +\newbox\b_anch_positions_graphic \def\startMPpositiongraphic % id setups {\dodoublegroupempty\anch_positions_meta_graphic_start} @@ -361,11 +365,11 @@ \let\stopMPpositiongraphic\relax \def\anch_positions_meta_graphic_prepare - {\ifcsname\??gv\currentmpvariableclass:self\endcsname \else - \letvalue{\??gv\currentmpvariableclass:self}\currentposition + {\ifcsname\??graphicvariable\currentmpvariableclass:self\endcsname \else + \letvalue{\??graphicvariable\currentmpvariableclass:self}\currentposition \fi - \ifcsname\??gv\currentmpvariableclass:from\endcsname \else - \letvalue{\??gv\currentmpvariableclass:from}\currentposition + \ifcsname\??graphicvariable\currentmpvariableclass:from\endcsname \else + \letvalue{\??graphicvariable\currentmpvariableclass:from}\currentposition \fi} \def\anch_positions_meta_graphic_use#1#2#3% @@ -375,7 +379,7 @@ \startMPcode#3\stopMPcode \endgroup} -\def\MPpositiongraphic +\unexpanded\def\MPpositiongraphic {\dodoublegroupempty\anch_positions_meta_graphic_direct} \def\anch_positions_meta_graphic_direct#1% tag setups @@ -402,9 +406,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\positiongraphicbox\hbox{\ignorespaces\csname#1#2\endcsname\removelastspace}% - \smashbox\positiongraphicbox - \box\positiongraphicbox + \setbox\b_anch_positions_graphic\hbox{\ignorespaces\csname#1#2\endcsname\removelastspace}% + \smashbox\b_anch_positions_graphic + \box\b_anch_positions_graphic \endgroup} \def\anch_positions_meta_graphic_nested#1#2#3% nesting used in prikkels / pascal (might go away) @@ -422,77 +426,77 @@ %D Simple one position graphics. -\def\setMPpositiongraphic - {\dotriplegroupempty\dosetMPpositiongraphic} +\unexpanded\def\setMPpositiongraphic + {\dotriplegroupempty\anch_positions_meta_graphic_set} -\def\dosetMPpositiongraphic#1#2#3% pos tag vars +\def\anch_positions_meta_graphic_set#1#2#3% pos tag vars {\ifx\currentpositionoverlay\empty - \dosetpositionaction{#1}{\MPpositiongraphic{#2}{#3}}% + \anch_positions_set_action{#1}{\MPpositiongraphic{#2}{#3}}% \else % silly can be one - \handlepositiongraphics{#1}{#2}{#3}% + \anch_positions_meta_graphic_handle{#1}{#2}{#3}% \fi} -\def\handlepositiongraphics#1#2#3% combine with boxes - {\handlepositionaction\dohandleMPpositiongraphic\with{#1}{#2}{#3}\on{#2}} +\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\doinsertMPpositiongraphic#1#2#3% pos tag setups +\def\anch_positions_meta_graphic_insert#1#2#3% pos tag setups {\ifnum\MPp{#1}=\realpageno\relax % extra saveguard \def\currentposition{#1}\MPpositiongraphic{#2}{#3}% \fi} \appendtoks - \let\dohandleMPpositiongraphic\doinsertMPpositiongraphic + \let\anch_positions_meta_graphic_handle_indeed\anch_positions_meta_graphic_insert \to \everyinsertpositionaction -\def\docleanMPpositiongraphic#1#2#3% pos tag setups +\def\anch_positions_meta_graphic_cleanup#1#2#3% pos tag setups {\ifnum\MPp{#1}<\realpageno \else - \noexpand\dohandleMPpositiongraphic{#1}{#2}{#3}% + \noexpand\anch_positions_meta_graphic_handle_indeed{#1}{#2}{#3}% \fi} \appendtoks - \let\dohandleMPpositiongraphic\docleanMPpositiongraphic + \let\anch_positions_meta_graphic_handle_indeed\anch_positions_meta_graphic_cleanup \to \everycleanpositionaction %D Graphics that span two positions (beware, does not cross pages). \unexpanded\def\setMPpositiongraphicrange - {\doquadruplegroupempty\dosetMPpositiongraphicrange} + {\doquadruplegroupempty\anch_positions_meta_graphic_set_range} -\def\dosetMPpositiongraphicrange#1#2#3#4% bpos epos tag vars +\def\anch_positions_meta_graphic_set_range#1#2#3#4% bpos epos tag vars {\ifx\currentpositionoverlay\empty - \dosetpositionaction{#1}{\MPpositiongraphic{#3}{#4}}% + \anch_positions_set_action{#1}{\MPpositiongraphic{#3}{#4}}% \else - \handlepositiongraphicsrange{#1}{#2}{#3}{#4}% + \anch_positions_meta_graphic_handle_range{#1}{#2}{#3}{#4}% \fi} -\def\handlepositiongraphicsrange#1#2#3#4% - {\handlepositionaction\dohandleMPpositiongraphicrange\with{#1}{#2}{#3}{#4}\on{#2}} +\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\doinsertMPpositiongraphicrange#1#2#3#4% pos pos tag setups +\def\anch_positions_meta_graphic_insert_range#1#2#3#4% pos pos tag setups {\ctxcommand{doifelserangeonpage("#1","#2",\number\realpageno)}% - {%\writestatus{YES}{#1/#2 => #3}% - \def\currentposition{#1}% + {\def\currentposition{#1}% \MPpositiongraphic{#3}{#4}}% - {}}%\writestatus{NOP}{#1/#2 = #3}}} + {}} \appendtoks - \let\dohandleMPpositiongraphicrange\doinsertMPpositiongraphicrange + \let\anch_positions_meta_graphic_handle_range_indeed\anch_positions_meta_graphic_insert_range \to \everyinsertpositionaction -\def\docleanMPpositiongraphicrange#1#2#3#4% pos tag setups +\def\anch_positions_meta_graphic_cleanup_range#1#2#3#4% pos tag setups {\ifnum\MPp{#2}<\realpageno \else - \noexpand \dohandleMPpositiongraphicrange{#1}{#2}{#3}{#4}% + \noexpand \anch_positions_meta_graphic_handle_range_indeed{#1}{#2}{#3}{#4}% \fi} \appendtoks - \let\dohandleMPpositiongraphicrange\docleanMPpositiongraphicrange + \let\anch_positions_meta_graphic_handle_range_indeed\anch_positions_meta_graphic_cleanup_range \to \everycleanpositionaction -\let\dohandleMPpositiongraphicrange\gobblefourarguments +\let\anch_positions_meta_graphic_handle_range_indeed\gobblefourarguments % Helpers: -\def\MPgetposboxes #1#2{\ctxcommand{fetchposboxes("#1","#2",\the\realpageno)}} -\def\MPgetmultipars#1#2{\ctxcommand{fetchmultipar("#1","#2",\the\realpageno)}} +\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)}} \protect \endinput diff --git a/tex/context/base/anch-pos.lua b/tex/context/base/anch-pos.lua index 5d01a6e46..6fa916291 100644 --- a/tex/context/base/anch-pos.lua +++ b/tex/context/base/anch-pos.lua @@ -17,6 +17,8 @@ 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 @@ -969,35 +971,35 @@ function commands.MPxywhd(id) end end --- is testcase already defined? if so, then local +local doif, doifelse = commands.doif, commands.doifelse function commands.doifpositionelse(name) - commands.doifelse(collected[name]) + doifelse(collected[name]) end function commands.doifposition(name) - commands.doif(collected[name]) + doif(collected[name]) end function commands.doifpositiononpage(name,page) -- probably always realpageno local c = collected[name] - commands.testcase(c and c.p == page) + doifelse(c and c.p == page) end function commands.doifoverlappingelse(one,two,overlappingmargin) - commands.testcase(overlapping(one,two,overlappingmargin)) + doifelse(overlapping(one,two,overlappingmargin)) end function commands.doifpositionsonsamepageelse(list,page) - commands.testcase(onsamepage(list)) + doifelse(onsamepage(list)) end function commands.doifpositionsonthispageelse(list) - commands.testcase(onsamepage(list,tostring(tex.count.realpageno))) + doifelse(onsamepage(list,tostring(tex.count.realpageno))) end function commands.doifelsepositionsused() - commands.testcase(next(collected)) + doifelse(next(collected)) end commands.markcolumnbox = jobpositions.markcolumnbox diff --git a/tex/context/base/anch-pos.mkiv b/tex/context/base/anch-pos.mkiv index 2e13eeba2..7ecaa296e 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 - \!!width 4\onepoint - \!!height2\onepoint - \!!depth 2\onepoint + \s!width 4\onepoint + \s!height2\onepoint + \s!depth 2\onepoint \stopcolor \hss}} @@ -377,7 +377,7 @@ {\smashedhbox {#1{\infofont#2#3}% \kern-\onepoint - \vrule\!!width2\onepoint\!!height\halfapoint\!!depth\halfapoint}} + \vrule\s!width2\onepoint\s!height\halfapoint\s!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 4bdaa2ef9..2fb6938a2 100644 --- a/tex/context/base/anch-tab.mkiv +++ b/tex/context/base/anch-tab.mkiv @@ -13,6 +13,9 @@ \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 @@ -57,23 +60,22 @@ \global\advance\c_anch_tabs\plusone \to \everytabulate -%D Beware, the following code is somewhat weird and experimental -%D and might be dropped or become a loadable module. +%D Beware, the following code is somewhat weird and experimental and might be +%D dropped or become a loadable module. %D \macros %D {GFC, GTC, GSC} %D -%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. +%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. \newconditional\tablehaspositions -\newcount\noftabpositions -\newtoks \posXCtoks +\newcount \noftabpositions +\newtoks \posXCtoks -\def\dotablebpos{\bpos} -\def\dotableepos{\epos} +\def\anch_tabulate_bpos{\bpos} +\def\anch_tabulate_epos{\epos} \installcorenamespace{positiontables} @@ -85,74 +87,80 @@ \let\tabulatepos\tablepos -\def\dodododoGSC[#1:#2]% - {\remappositionframed{#2}{\tbPOSprefix#1}% - \dotablebpos{\tbPOSprefix#1}% - \doglobal\appendtoks\@EA\dotableepos\@EA{\tbPOSprefix#1}\to\posXCtoks} +\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\dododoGSC[#1:#2:#3]% - {\doglobal\appendtoks\dodododoGSC[#1:#2]\to\posXCtoks\NC} +\def\anch_table_check_state + {\iftrialtypesetting + \global\settrue\tablehaspositions + \firstargumentfalse + \fi} -\def\dodoGSC[#1]% - {\def\docommand##1{\dododoGSC[##1:##1]}% - \processcommalist[#1]\docommand} +\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\dodododoGFC[#1:#2:#3]% - {\remappositionframed{#2}{\tbPOSprefix#1}% - \dotablebpos{\tbPOSprefix#1}} +\def\anch_tables_indeed_XC[#1]% + {{\let\NC\relax\processcommalist[#1]\anch_tables_step_XC}} -\def\dododoGFC[#1]% - {\def\docommand##1{\dodododoGFC[##1:##1]}% - \processcommalist[#1]\docommand} +\def\anch_tables_step_XC#1% + {\anch_tables_step_indeed_XC[#1]} -\def\dodoGFC[#1]% - {\doglobal\appendtoks\dododoGFC[#1]\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\dododododoGTC[#1:#2]% - {\dotableepos{\tbPOSprefix#1}} +\def\anch_tables_indeed_GSC[#1]% + {\processcommalist[#1]\anch_tables_step_GSC} -\def\dodododoGTC[#1]% - {\def\docommand##1{\dododododoGTC[##1:##1]}% - \processcommalist[#1]\docommand} +\def\anch_tables_step_GSC#1% + {\anch_tables_append_GSC[#1:#1]} -\def\dododoGTC[#1]% - {\doglobal\appendtoks\dodododoGTC[#1]\to\posXCtoks} +\def\anch_tables_append_GSC[#1:#2:#3]% + {\doglobal\appendtoks\anch_tables_process_GSC[#1:#2]\to\posXCtoks\NC} -\def\dodoGTC[#1]% - {\doglobal\appendtoks\dododoGTC[#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\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_GFC[#1]% + {\doglobal\appendtoks\anch_tables_delayed_GFC[#1]\to\posXCtoks\NC} -\def\dododoXC#1% - {\dodododoXC[#1]} +\def\anch_tables_delayed_GFC[#1]% + {\processcommalist[#1]\anch_tables_step_GFC} -\def\dodoXC[#1]% - {{\let\NC\relax\processcommalist[#1]\dododoXC}} +\def\anch_tables_step_GFC#1% + {\anch_tables_process_GFC[#1:#1]} -\def\@@checktablepositionstate - {\iftrialtypesetting - \global\settrue\tablehaspositions - \firstargumentfalse - \fi} +\def\anch_tables_process_GFC[#1:#2:#3]% + {\remappositionframed{#2}{\tbPOSprefix#1}% + \anch_tabulate_bpos{\tbPOSprefix#1}} + +\def\anch_tables_indeed_GTC[#1]% + {\doglobal\appendtoks\anch_tables_delayed_GTC[#1]\to\posXCtoks\NC} -\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_delayed_GTC[#1]% + {\doglobal\appendtoks\anch_tables_process_GTC[#1]\to\posXCtoks} -\def\tbGSC{\dosingleempty\doGSC} -\def\tbGFC{\dosingleempty\doGFC} -\def\tbGTC{\dosingleempty\doGTC} -\def\tbXC {\dosingleempty\doXC } +\def\anch_tables_process_GTC[#1]% + {\processcommalist[#1]\anch_tables_step_GTC} -%D The amount of code to support tables and tabulation is -%D rather minimalistic. +\def\anch_tables_step_GTC#1% + {\anch_tables_step_indeed_GTC[#1:#1]} + +\def\anch_tables_step_indeed_GTC[#1:#2]% + {\anch_tabulate_epos{\tbPOSprefix#1}} + +%D The amount of code to support tables and tabulation is rather +%D minimalistic. \let\tabulatepos\tablepos @@ -187,31 +195,30 @@ % We need to handle paragraphs as well. -\let\doflushtabulateepos\relax +\let\anch_tabulate_flush_epos\relax -\def\dotabulatebpos +\def\anch_tabulate_bpos_indeed {\bpos} -\def\dotabulateepos#1% +\def\anch_tabulate_epos_indeed#1% {\ifvoid\b_tabl_tabulate_current\c_tabl_tabulate_column \epos{#1}% - \glet\doflushtabulateepos\relax + \glet\anch_tabulate_flush_epos\relax \else - \gdef\doflushtabulateepos{\epos{#1}}% + \gdef\anch_tabulate_flush_epos{\epos{#1}}% \fi} \def\flushtabulatesplitbox {\box\b_tabl_tabulate - \iftrialtypesetting\else\ifconditional\tablehaspositions\doflushtabulateepos\fi\fi} + \iftrialtypesetting\else\ifconditional\tablehaspositions\anch_tabulate_flush_epos\fi\fi} \appendtoks - \let\dotablebpos\dotabulatebpos % ? - \let\dotableepos\dotabulateepos % ? - \glet\doflushtabulateepos\relax + \let\anch_tabulate_bpos\anch_tabulate_bpos_indeed % ? + \let\anch_tabulate_epos\anch_tabulate_epos_indeed % ? + \glet\anch_tabulate_flush_epos\relax \to \everytabulate -%D In order to prevent potential clashes with abbreviations, -%D postpone the mapping. +%D In order to prevent potential clashes with abbreviations, postpone the mapping. \appendtoks \let\GSC\tbGSC @@ -223,8 +230,8 @@ %D \macros %D {definepositionframed} %D -%D The next example show how to provide backgrounds to table -%D cells. First we define some framed backgrounds. +%D The next example show how to provide backgrounds to table cells. First we define +%D some framed backgrounds. %D %D \startbuffer %D \definepositionframed[x][background=color,backgroundcolor=red] @@ -244,8 +251,7 @@ %D \stoptabulate %D \stopbuffer %D -%D The table itself defines three areas (a, b and~c) using -%D these frames. +%D The table itself defines three areas (a, b and~c) using these frames. %D %D \typebuffer %D % \getbuffer @@ -270,9 +276,8 @@ \let\XC \tbXC \to \everytable -%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 In the previous example, we could have provided an overlay to the framed definition. +%D A more direct approach is demonstrated below: %D %D \startbuffer %D \def\cw#1{\color[white]{#1}} @@ -291,8 +296,7 @@ %D %D \typebuffer \getbuffer %D -%D The definition of the table looks about the same as the -%D previous one: +%D The definition of the table looks about the same as the previous one: %D %D \startbuffer %D \starttable[|c|c|c|] @@ -347,22 +351,26 @@ % \definepositionframed[y][background=color,fillcolor=green] % \definepositionframed[z][background=color,fillcolor=blue] -\def\remappositionframed#1#2% from to +\unexpanded\def\remappositionframed#1#2% from to {\copyposition{b:#1}{b:#2}% \copyposition{e:#1}{e:#2}% - \dosetpositionaction{b:#2}{\dopositionaction{b:#1}}} + \anch_positions_set_action{b:#2}{\dopositionaction{b:#1}}} \unexpanded\def\definepositionframed - {\dodoubleargument\dodefinepositionframed} + {\dodoubleargument\anch_framed_define} -\def\dodefinepositionframed[#1][#2]% - {\dosetpositionaction{b:#1}{\dopositionframed[#1][#2]}} +\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} \unexpanded\def\positionframed {\bgroup - \dodoubleempty\dopositionframed} + \dodoubleempty\anch_framed_indeed} -\def\dopositionframed[#1][#2]% +\def\anch_framed_indeed[#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 c592d1dc1..18182ba85 100644 --- a/tex/context/base/attr-col.lua +++ b/tex/context/base/attr-col.lua @@ -15,8 +15,11 @@ 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 = attributes, nodes +local attributes, nodes, utilities, logs, backends, storage = attributes, nodes, utilities, logs, backends, storage +local commands, context, interfaces = commands, context, interfaces +local tex = tex local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex @@ -31,11 +34,13 @@ 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 states = attributes.states +local tasks = nodes.tasks +local nodeinjections = backends.nodeinjections +local registrations = backends.registrations +local unsetvalue = attributes.unsetvalue + +local registerstorage = storage.register -- 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 @@ -63,7 +68,7 @@ local unsetvalue = attributes.unsetvalue -- colors.strings[color] = "return colors." .. colorspace .. "(" .. concat({...},",") .. ")" -- end -- --- storage.register("attributes/colors/data", colors.strings, "attributes.colors.data") -- evaluated +-- registerstorage("attributes/colors/data", colors.strings, "attributes.colors.data") -- evaluated -- -- We assume that only processcolors are defined in the format. @@ -83,9 +88,17 @@ 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 -storage.register("attributes/colors/values", colors.values, "attributes.colors.values") -storage.register("attributes/colors/registered", colors.registered, "attributes.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") local templates = { rgb = "r:%s:%s:%s", @@ -104,17 +117,6 @@ 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 @@ -125,9 +127,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 @@ -135,6 +137,17 @@ 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) @@ -363,15 +376,15 @@ transparencies.triggering = true transparencies.attribute = a_transparency transparencies.supported = true -storage.register("attributes/transparencies/registered", transparencies.registered, "attributes.transparencies.registered") -storage.register("attributes/transparencies/values", transparencies.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 registered = transparencies.registered -- we could use a 2 dimensional table instead -local data = transparencies.data -local values = transparencies.values -local template = "%s:%s" +registerstorage("attributes/transparencies/registered", registered, "attributes.transparencies.registered") +registerstorage("attributes/transparencies/values", values, "attributes.transparencies.values") -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 023d1c51b..60e0c08ac 100644 --- a/tex/context/base/attr-eff.lua +++ b/tex/context/base/attr-eff.lua @@ -8,7 +8,9 @@ if not modules then modules = { } end modules ['attr-eff'] = { local format = string.format -local attributes, nodes = attributes, nodes +local commands, interfaces = commands, interfaces +local attributes, nodes, backends, utilities = attributes, nodes, backends, utilities +local tex = tex local states = attributes.states local tasks = nodes.tasks @@ -17,6 +19,9 @@ 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 @@ -27,14 +32,14 @@ effects.values = effects.values or { } effects.registered = effects.registered or { } effects.attribute = a_effect -storage.register("attributes/effects/registered", effects.registered, "attributes.effects.registered") -storage.register("attributes/effects/values", effects.values, "attributes.effects.values") +local data = effects.data +local registered = effects.registered +local values = effects.values -local template = "%s:%s:%s" +local template = "%s:%s:%s" -local data = effects.data -local registered = effects.registered -local values = effects.values +storage.register("attributes/effects/registered", registered, "attributes.effects.registered") +storage.register("attributes/effects/values", values, "attributes.effects.values") -- valid effects: normal inner outer both hidden (stretch,rulethickness,effect) @@ -66,12 +71,22 @@ effects.handler = nodes.installattributehandler { processor = states.process, } -local function register(effect,stretch,rulethickness) - local stamp = format(template,effect,stretch,rulethickness) +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 n = registered[stamp] if not n then n = #values + 1 - values[n] = { effect, stretch, rulethickness } + values[n] = { alternative, stretch, rulethickness } registered[stamp] = n end return n @@ -88,10 +103,10 @@ effects.enable = enable local enabled = false -function commands.triggereffect(effect,stretch,rulethickness) +function commands.triggereffect(specification) if not enabled then enable() enabled = true end - settexattribute(a_effect,register(effect,stretch,rulethickness)) + settexattribute(a_effect,register(specification)) end diff --git a/tex/context/base/attr-eff.mkiv b/tex/context/base/attr-eff.mkiv index c5c94537c..43f575a7a 100644 --- a/tex/context/base/attr-eff.mkiv +++ b/tex/context/base/attr-eff.mkiv @@ -17,38 +17,39 @@ \unprotect -\gdef\dotriggereffect#1#2#3% - {\ctxcommand{triggereffect('#1',#2,\number\dimexpr#3\relax)}} +\installcorenamespace{effect} -\unexpanded\def\setupeffect - {\dodoubleargument\dosetupeffect} +\installcommandhandler \??effect {effect} \??effect -\def\dosetupeffect[#1][#2]% - {\getparameters[\??et#1][#2]} +\setupeffect + [\c!method=\v!none, + \c!stretch=\zerocount, + \c!rulethickness=\zeropoint, + \c!alternative=\v!normal] -\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 +\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\starteffect[#1]% - {\dotriggereffect - {\csname\??et#1\c!alternative \endcsname}% - {\csname\??et#1\c!stretch \endcsname}% - {\csname\??et#1\c!rulethickness\endcsname}} + {\ctxcommand{triggereffect{ + alternative = "\namedeffectparameter{#1}\c!alternative", + stretch = \number\namedeffectparameter{#1}\c!stretch, + rulethickness = \number\dimexpr\namedeffectparameter{#1}\c!rulethickness\relax + }}} \unexpanded\def\stopeffect % can be special - {\dotriggereffect\v!normal0\zeropoint} + {\ctxcommand{triggereffect()}} % v!normal 0 0 \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 f3714fcb4..5a3bafce3 100644 --- a/tex/context/base/attr-ini.lua +++ b/tex/context/base/attr-ini.lua @@ -6,6 +6,8 @@ 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-- @@ -13,11 +15,10 @@ local next, type = next, type symbolic names later on.

--ldx]]-- -attributes = attributes or { } - -local attributes, nodes = attributes, nodes +attributes = attributes or { } +local attributes = attributes --- todo: local and then gobals ... first loaded anyway +local sharedstorage = storage.shared attributes.names = attributes.names or { } attributes.numbers = attributes.numbers or { } @@ -26,15 +27,14 @@ attributes.states = attributes.states or { } attributes.handlers = attributes.handlers or { } attributes.unsetvalue = -0x7FFFFFFF -local names, numbers, list = attributes.names, attributes.numbers, attributes.list +local names = attributes.names +local numbers = attributes.numbers +local list = 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,13 +43,19 @@ 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]]-- -storage.shared.attributes_last_private = storage.shared.attributes_last_private or 127 +sharedstorage.attributes_last_private = sharedstorage.attributes_last_private or 127 -- to be considered (so that we can use an array access): -- @@ -57,10 +63,10 @@ storage.shared.attributes_last_private = storage.shared.attributes_last_private -- -- setmetatable(private, { -- __index = function(t,name) --- local number = storage.shared.attributes_last_private or 127 +-- local number = sharedstorage.attributes_last_private -- if number < 1023 then -- tex.count.minallocatedattribute - 1 -- number = number + 1 --- storage.shared.attributes_last_private = number +-- sharedstorage.attributes_last_private = number -- end -- numbers[name], names[number], list[number] = number, name, { } -- private[name] = number @@ -74,12 +80,12 @@ storage.shared.attributes_last_private = storage.shared.attributes_last_private function attributes.private(name) -- at the lua end (hidden from user) local number = numbers[name] if not number then - local last = storage.shared.attributes_last_private or 127 + local last = sharedstorage.attributes_last_private if last < 1023 then -- tex.count.minallocatedattribute - 1 last = last + 1 - storage.shared.attributes_last_private = last + sharedstorage.attributes_last_private = last else - report_attribute("no more room for private attributes") -- fatal + report_attribute("no more room for private attributes") os.exit() end number = last @@ -88,7 +94,7 @@ function attributes.private(name) -- at the lua end (hidden from user) return number end --- new (actually a tracer) +-- tracers local report_attribute = logs.reporter("attributes") diff --git a/tex/context/base/attr-ini.mkiv b/tex/context/base/attr-ini.mkiv index a1550b4be..8a41dd427 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 \newattribute will go away. +%D related to attributes. Housekeeping will move completely to \LUA\ +%D and \type {\newattribute} will go away. \unprotect @@ -27,14 +27,16 @@ \unexpanded\def\pushattribute#1% {\global\advance\csname\??attributestack\string#1\endcsname\plusone - \global\expandafter\mathchardef\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname\attribute#1} + \expandafter\xdef\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname{\number\attribute#1}} \unexpanded\def\popattribute#1% - {\attribute#1\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname + {\attribute#1\csname\??attributestack\string#1:\number\csname\??attributestack\string#1\endcsname\endcsname\relax \global\advance\csname\??attributestack\string#1\endcsname\minusone} \unexpanded\def\installattributestack#1% - {\expandafter\newcount\csname\??attributestack\string#1\endcsname} + {\ifcsname\??attributestack\string#1\endcsname \else + \expandafter\newcount\csname\??attributestack\string#1\endcsname + \fi} \newtoks \attributesresetlist diff --git a/tex/context/base/attr-lay.lua b/tex/context/base/attr-lay.lua index bcdc541f7..5e5e81ff1 100644 --- a/tex/context/base/attr-lay.lua +++ b/tex/context/base/attr-lay.lua @@ -10,9 +10,15 @@ 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 = table.insert, table.remove +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 allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex @@ -26,8 +32,6 @@ 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 @@ -57,22 +61,42 @@ local texgetattribute = tex.getattribute local texsettokenlist = tex.settoks local unsetvalue = attributes.unsetvalue -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") +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" -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", 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 -- 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 = nodeinjections.stoplayer() + local d = stoplayer() viewerlayers.none = d return d end @@ -82,7 +106,7 @@ local function reviver(data,n) if viewerlayers.supported then local v = values[n] if v then - local d = nodeinjections.startlayer(v) + local d = startlayer(v) data[n] = d return d else @@ -91,8 +115,14 @@ local function reviver(data,n) end end -setmetatableindex(viewerlayers, extender) -setmetatableindex(viewerlayers.data, reviver) +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 local function initializer(...) return states.initialize(...) @@ -103,7 +133,8 @@ attributes.viewerlayers.handler = nodes.installattributehandler { namespace = viewerlayers, initializer = initializer, finalizer = states.finalize, - processor = states.stacked, + -- processor = states.stacked, + processor = states.stacker, } local stack, enabled, global = { }, false, false @@ -149,12 +180,16 @@ function viewerlayers.setfeatures(hasorder) viewerlayers.hasorder = hasorder end +local usestacker = true -- new, experimental + function viewerlayers.start(name) --- if not enabled then --- viewerlayers.enable(true) --- end - insert(stack,texgetattribute(a_viewerlayer)) - local a = register(name) or unsetvalue + 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 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) @@ -165,14 +200,21 @@ function viewerlayers.start(name) end function viewerlayers.stop() - local a = remove(stack) - if a >= 0 then + local a + if usestacker then + a = layerstacker.pop() + else + a = remove(stack) + end + if not a then + -- error + elseif 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]) + texsettokenlist("currentviewerlayertoks",values[a] or "") else if global or scopes[a] == v_global then texsetattribute("global",a_viewerlayer,unsetvalue) @@ -197,9 +239,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 67cd204e2..9c9c3318e 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 -% \def\registerviewerlayer#1#2% global ! -% {\setxvalue{\??ql:#1}{\global\attribute\viewerlayerattribute\ctxlua{tex.write(attributes.viewerlayers.register('#2'))} }} -% -% \setevalue{\??ql:}{\global\attribute\viewerlayerattribute\attributeunsetvalue} +\installcorenamespace{viewerlayer} + +\installcommandhandler \??viewerlayer {viewerlayer} \??viewerlayer -\getparameters - [\??lr] +\setupviewerlayer [\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] -\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 +\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 \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 -\let\currentviewerlayer\empty \newtoks\currentviewerlayertoks % soon we can set macros at the lua end +\newtoks\currentviewerlayertoks % soon we can set macros at the lua end \def\currentviewerlayer{\the\currentviewerlayertoks} @@ -67,7 +67,9 @@ % layout components are implemented rather directly (speed) -\def\doinitializelayoutcomponent#1% +\installcorenamespace{layoutcomponentattribute} + +\def\attr_layoutcomponent_initialize#1% {\edef\layoutcomponentboxattribute{\ctxcommand{definedviewerlayer{% tag = "#1", title = utilities.strings.nice("#1"), % only here as in steps we have step: @@ -76,24 +78,28 @@ printable = "\v!yes" }}}% \edef\layoutcomponentboxattribute{attr \viewerlayerattribute \layoutcomponentboxattribute\relax}% - \expandafter\glet\csname\??lr:a:#1\endcsname\layoutcomponentboxattribute} + \expandafter\glet\csname\??layoutcomponentattribute#1\endcsname\layoutcomponentboxattribute} -\def\dosetlayoutcomponentattribute#1% make this faster - {\expandafter\let\expandafter\layoutcomponentboxattribute\csname\??lr:a:#1\endcsname +\def\attr_layoutcomponent_set#1% make this faster + {\expandafter\let\expandafter\layoutcomponentboxattribute\csname\??layoutcomponentattribute#1\endcsname \ifx\layoutcomponentboxattribute\relax - \doinitializelayoutcomponent{#1}% get rid of { } + \attr_layoutcomponent_initialize{#1}% get rid of { } \fi} -\def\doresetlayoutcomponentattribute +\def\attr_layoutcomponent_reset {\let\layoutcomponentboxattribute\empty} \let\setlayoutcomponentattribute \gobbleoneargument \let\resetlayoutcomponentattribute\relax \let\layoutcomponentboxattribute \empty -\def\showlayoutcomponents - {\ctxlua{attributes.viewerlayers.enable()}% will go - \let\setlayoutcomponentattribute \dosetlayoutcomponentattribute - \let\resetlayoutcomponentattribute\doresetlayoutcomponentattribute} +\unexpanded\def\showlayoutcomponents + {%\ctxlua{attributes.viewerlayers.enable()}% automatic + \let\setlayoutcomponentattribute \attr_layoutcomponent_set + \let\resetlayoutcomponentattribute\attr_layoutcomponent_reset} + +\appendtoks + \ctxcommand{cleanuplayers()}% +\to \everyshipout \protect \endinput diff --git a/tex/context/base/attr-neg.lua b/tex/context/base/attr-neg.lua index 4d89cb49b..c32cec956 100644 --- a/tex/context/base/attr-neg.lua +++ b/tex/context/base/attr-neg.lua @@ -11,8 +11,9 @@ if not modules then modules = { } end modules ['attr-neg'] = { local format = string.format - -local attributes, nodes = attributes, nodes +local attributes, nodes, utilities, logs, backends = attributes, nodes, utilities, logs, backends +local commands, context, interfaces = commands, context, interfaces +local tex = tex 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 0fc5070f1..102b220ba 100644 --- a/tex/context/base/attr-neg.mkiv +++ b/tex/context/base/attr-neg.mkiv @@ -19,12 +19,12 @@ % positive and negative are preregistered -\def\dotriggernegative#1{\ctxcommand{triggernegative('#1')}} +\unexpanded\def\startnegative{\attr_trigger_negative\v!negative} +\unexpanded\def\stopnegative {\attr_trigger_negative\v!positive} -\unexpanded\def\startnegative{\dotriggernegative\v!negative} -\unexpanded\def\stopnegative {\dotriggernegative\v!positive} +\unexpanded\def\startpositive{\attr_trigger_negative\v!positive} +\unexpanded\def\stoppositive {\attr_trigger_negative\v!negative} -\unexpanded\def\startpositive{\dotriggernegative\v!positive} -\unexpanded\def\stoppositive {\dotriggernegative\v!negative} +\def\attr_trigger_negative#1{\ctxcommand{triggernegative('#1')}} \protect \endinput diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index 3ce40a6c5..46ce4f96c 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -20,8 +20,9 @@ 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, utfsub, utfgsub = utf.char, utf.byte, utf.sub, utf.gsub +local utfchar, utfbyte = utf.char, utf.byte local insert, remove = table.insert, table.remove local topoints = number.topoints local utfvalues = string.utfvalues @@ -154,6 +155,8 @@ local somespace = { [0x20] = true, [" "] = true } -- for testing local entities = { ["&"] = "&", [">"] = ">", ["<"] = "<" } local attribentities = { ["&"] = "&", [">"] = ">", ["<"] = "<", ['"'] = "quot;" } +local entityremapper = utf.remapper(entities) + local alignmapping = { flushright = "right", middle = "center", @@ -300,7 +303,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 ; @@ -382,7 +385,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.extname(name) == "pdf" then + if file.suffix(name) == "pdf" then -- temp hack .. we will have a remapper name = file.replacesuffix(name,"svg") end @@ -397,7 +400,7 @@ local function uniqueusedimages() for element, details in next, usedimages do for detail, data in next, details do local name = data.name - if file.extname(name) == "pdf" then + if file.suffix(name) == "pdf" then unique[file.replacesuffix(name,"svg")] = name else unique[name] = name @@ -1351,7 +1354,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 = utfgsub(v,".",entities) + v = entityremapper(v) result[#result+1] = format("%s%s\n",spaces[depth+1],k,v) end result[#result+1] = format("%s\n",spaces[depth]) @@ -1409,7 +1412,7 @@ local function flushtree(result,data,nature,depth) -- whatever elseif di.content then -- already has breaks - local content = utfgsub(di.content,".",entities) + local content = entityremapper(di.content) 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 @@ -2362,12 +2365,21 @@ 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 871d08b19..9e65633d4 100644 --- a/tex/context/base/back-exp.mkiv +++ b/tex/context/base/back-exp.mkiv @@ -132,6 +132,11 @@ [\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 @@ -141,12 +146,21 @@ 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]}% @@ -155,11 +169,11 @@ \to \everysetupbackend \appendtoks - \doifsomething{\backendparameter\c!export} - {\setuptagging - [\c!state=\v!start]% - \enabledirectives - [backend.export=\backendparameter\c!export]}% + \doifelsenothing{\backendparameter\c!export} + {\resetsystemmode\v!export} + {\setuptagging[\c!state=\v!start]% + \enabledirectives[backend.export=\backendparameter\c!export]% + \setsystemmode\v!export}% \to \everysetupbackend \protect \endinput diff --git a/tex/context/base/back-ini.lua b/tex/context/base/back-ini.lua index 0c02e201a..f76b85438 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) +function commands.pdfrotation(a) -- somewhat weird here 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 8ece8f6e1..fc8759c14 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 {doovalbox} +%D {back_ovalbox} %D %D When we look at the implementation, this is a complicated %D one. There are seven arguments. %D %D \starttyping -%D \doovalbox {w} {h} {d} {linewidth} {radius} {stroke} {fill} {variant} +%D \back_ovalbox {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 \doovalbox \gobbleeightarguments +\let\back_ovalbox \gobbleeightarguments %D \macros %D {dostartclipping,dostopclipping} diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv index 9e441e224..7e910f07f 100644 --- a/tex/context/base/back-pdf.mkiv +++ b/tex/context/base/back-pdf.mkiv @@ -68,16 +68,17 @@ {\ctxcommand{setxmpfile("\backendparameter{xmpfile}")}}% \to \everysetupbackend +% \doifsomething{\backendparameter\c!format} .. at the lua end + \appendtoks - \doifsomething{\backendparameter\c!format} - {\ctxcommand{setformat { + \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. @@ -220,12 +221,12 @@ \newbox\objectbox -\def\dostartobject#1#2#3#4#5% +\unexpanded\def\dostartobject#1#2#3#4#5% needs to be \unexpanded {\bgroup \setbox\objectbox\vbox\bgroup \def\back_object_stop{\egroup\back_object_register{#1}{#2}}} -\def\dostopobject +\unexpanded\def\dostopobject % needs to be \unexpanded {\back_object_stop \egroup} @@ -237,9 +238,6 @@ \immediate\pdfxform resources {\pdfbackendcurrentresources}\objectbox \dosetobjectreference{#1}{#2}{\the\pdflastxform}} -\def\doresetobjects - {} - \let\m_back_object_reference\empty \def\doinsertobject#1#2% @@ -263,7 +261,7 @@ % for the moment here %D \macros -%D {doovalbox} +%D {back_ovalbox} %D %D Drawing frames with round corners is inherited from the %D main module. @@ -276,7 +274,7 @@ % \def\back_oval_calculate#1#2#3% % {\PointsToBigPoints{\dimexpr#2+#3\relax}#1} -\unexpanded\def\doovalbox#1#2#3#4#5#6#7#8% +\unexpanded\def\back_ovalbox#1#2#3#4#5#6#7#8% {\forcecolorhack \bgroup % \scratchdimen#4% @@ -306,16 +304,16 @@ \PointsToBigPoints{\dimexpr #2-\scratchdimen}\yymax \PointsToBigPoints{\dimexpr-#3+\scratchdimen}\yymin % - \edef\dostroke{#6}% - \edef\dofill{#7}% - \edef\mode{\number#8 \space}% + \edef\dostroke{\number#6}% + \edef\dofill{\number#7}% + \edef\mode{\number#8}% % no \ifcase, else \relax in pdfcode \setbox\scratchbox\hbox {\ifnum\dostroke\dofill>\zerocount \pdfliteral {q \stroke\space w - \ifcase\mode + \ifcase\mode\space \xxmin\space \ymin \space m \xxmax\space \ymin \space l \xmax \space \ymin \space \xmax \space \yymin\space y @@ -495,7 +493,7 @@ \xmin \space \ymin \space \xmin \space \yymin\space y \or % 28 \fi - \ifnum\mode>8 + \ifnum\mode>8\space S \else \ifnum\dostroke=\plusone S \fi diff --git a/tex/context/base/back-swf.mkiv b/tex/context/base/back-swf.mkiv index 1d225b550..09745e0f9 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. -% This is only a placeholder that demonstrates the usage of swf -% resources. - -%D \starttyping -%D \starttext +%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 +%D \starttyping %D \enabletrackers[graphics.locating] %D \enabletrackers[backend.swf] %D @@ -41,8 +41,6 @@ %D \stopTEXpage %D \stoptyping -\stoptext - \endinput \starttext @@ -72,8 +70,6 @@ }, \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 dfe8a90c2..89d26ee41 100644 --- a/tex/context/base/back-u3d.mkiv +++ b/tex/context/base/back-u3d.mkiv @@ -11,10 +11,9 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -% 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. +%D This is only a placeholder that demonstrates the usage of u3d resources. The +%D user interface is rather messy an might be improved. The files and setup is +%D derived from an example by Michael Vidiassov. \endinput diff --git a/tex/context/base/bibl-bib.mkiv b/tex/context/base/bibl-bib.mkiv index 56007d21c..7ca6799cf 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)}}% - \doplacestructurelist + \strc_lists_place_current {\currentbibtexsession} {\currentbibtexcriterium} {\namedlistparameter\currentbibtexsession\c!number}% diff --git a/tex/context/base/bibl-tra.lua b/tex/context/base/bibl-tra.lua index 6341898ee..ca6403c44 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-bib'] = { +if not modules then modules = { } end modules ['bibl-tra'] = { 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.testcase(used[str]) + commands.doifelse(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 3531703ad..08d8eb6fe 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]}% - \doplacestructurelist + \strc_lists_place_current {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\ifbibinteractionelse +\def\doifbibinteractionelse {\iflocation \edef\test{\bibalternative\c!interaction}% \ifx\test\v!stop @@ -1256,20 +1256,11 @@ \@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 - \ifbibinteractionelse{\gotobiblink{#2}[#1]}{#2}% + \doifbibinteractionelse{\gotobiblink{#2}[#1]}{#2}% \fi} \def\bibauthoryearref[#1]% @@ -1360,7 +1351,7 @@ \gotobiblink{#1}[#1]} \def\bibgotoDOI#1#2% - {\ifbibinteractionelse + {\doifbibinteractionelse {\useURL[bibfooDoi#1][#2]% \useURL[bibfoo#1][http://dx.doi.org/#2]% \goto{\url[bibfooDoi#1]}[url(bibfoo#1)]} @@ -1383,7 +1374,7 @@ \bibalternative\v!right} \def\bibgotoURL#1#2% - {\ifbibinteractionelse + {\doifbibinteractionelse {\useURL[bibfoo#1][#2]\goto{\url[bibfoo#1]}[url(bibfoo#1)]} {\hyphenatedurl{#2}}} @@ -1411,7 +1402,7 @@ \def\dobibpageref#1% {\bibinsertrefsep - \ifbibinteractionelse + \doifbibinteractionelse {\atbiblink[#1]} {{\referencingfalse\at[#1]}}} @@ -1484,8 +1475,6 @@ %D And some defaults are loaded from bibl-apa: -\def\c!monthconversion{monthconversion} % todo - \setuppublications [\c!monthconversion=, \c!alternative=apa, @@ -1502,4 +1491,6 @@ % \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 b97485b1b..4debaf94c 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) -- will be link nodes.link +function blobs.append(t,str) -- compare concat and 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 7098679ca..11d7cc9f6 100644 --- a/tex/context/base/buff-ini.lua +++ b/tex/context/base/buff-ini.lua @@ -13,21 +13,23 @@ 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 = string.count, string.splitlines +local count, splitlines, validstring = string.count, string.splitlines, string.valid -local variables = interfaces.variables +local variables = interfaces.variables local settings_to_array = utilities.parsers.settings_to_array -local ctxcatcodes = tex.ctxcatcodes -local txtcatcodes = tex.txtcatcodes +local catcodenumbers = catcodes.numbers -buffers = { } +local ctxcatcodes = catcodenumbers.ctxcatcodes +local txtcatcodes = catcodenumbers.txtcatcodes +buffers = buffers or { } local buffers = buffers -local context = context local cache = { } @@ -100,14 +102,17 @@ 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 - + patterns.anything - local p = patterns.alwaysmatched / function() n = 0 end + + anything + local p = alwaysmatched / function() n = 0 end * g^0 - * patterns.alwaysmatched / function() return n end + * alwaysmatched / function() return n end return p end @@ -150,12 +155,10 @@ 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 - if dn == "" then - dn = sub(bufferdata,2,-2) - else - dn = dn .. "\n" .. sub(bufferdata,2,-2) -- no \r, \n is more generic - end + dn = dn .. "\n" .. sub(bufferdata,2,-2) -- no \r, \n is more generic end local last = sub(dn,-1) if last == "\n" or last == "\r" then -- \n is unlikely as \r is the endlinechar @@ -184,7 +187,7 @@ function commands.grabbuffer(name,begintag,endtag,bufferdata,catcodes) -- maybe end end assign(name,dn,catcodes) - commands.testcase(more) + commands.doifelse(more) end -- The optional prefix hack is there for the typesetbuffer feature and @@ -232,12 +235,12 @@ end function commands.getbuffer(name) local str = getcontent(name) if str ~= "" then - context.viafile(str) + context.viafile(str,format("buffer.%s",validstring(name,"noname"))) end end function commands.getbuffermkvi(name) -- rather direct ! - context.viafile(resolvers.macros.preprocessed(getcontent(name))) + context.viafile(resolvers.macros.preprocessed(getcontent(name)),format("buffer.%s.mkiv",validstring(name,"noname"))) end function commands.gettexbuffer(name) @@ -265,7 +268,7 @@ function commands.getbufferctxlua(name) end function commands.doifelsebuffer(name) - commands.testcase(exists(name)) + commands.doifelse(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 239a274c0..5f9d1d1e6 100644 --- a/tex/context/base/buff-ini.mkiv +++ b/tex/context/base/buff-ini.mkiv @@ -199,4 +199,28 @@ \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 2015b0bc0..29742f497 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-ini'] = { +if not modules then modules = { } end modules ['buff-par'] = { version = 1.001, comment = "companion to buff-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -6,21 +6,26 @@ if not modules then modules = { } end modules ['buff-ini'] = { license = "see context related readme files" } -local trace_parallel = false trackers.register("buffers.parallel", function(v) trace_parallel = v end) - -local report_parallel = logs.reporter("buffers","parallel") +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 variables = interfaces.variables +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 parallel = buffers.parallel or { } +buffers.parallel = parallel -buffers.parallel = { } local parallel = buffers.parallel +local settings_to_array = utilities.parsers.settings_to_array -local data = { } +local data = { } function parallel.define(category,tags) - local tags = utilities.parsers.settings_to_array(tags) + local tags = settings_to_array(tags) local entries = { } data[category] = { tags = tags, @@ -38,7 +43,7 @@ function parallel.reset(category,tags) if not tags or tags == "" or tags == variables.all then tags = table.keys(entries) else - tags = utilities.parsers.settings_to_array(tags) + tags = settings_to_array(tags) end for i=1,#tags do entries[tags[i]] = { @@ -76,7 +81,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 @@ -175,5 +180,5 @@ commands.placeparallel = parallel.place commands.resetparallel = parallel.reset function commands.doifelseparallel(category,tags) - commands.testcase(parallel.hassomecontent(category,tags)) + commands.doifelse(parallel.hassomecontent(category,tags)) end diff --git a/tex/context/base/buff-par.mkiv b/tex/context/base/buff-par.mkiv deleted file mode 100644 index 7d35676bd..000000000 --- a/tex/context/base/buff-par.mkiv +++ /dev/null @@ -1,151 +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 -%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 new file mode 100644 index 000000000..404fa8ef3 --- /dev/null +++ b/tex/context/base/buff-par.mkvi @@ -0,0 +1,131 @@ +%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 004d89858..5748d9298 100644 --- a/tex/context/base/buff-ver.lua +++ b/tex/context/base/buff-ver.lua @@ -18,6 +18,8 @@ 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") @@ -30,7 +32,6 @@ 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 @@ -52,6 +53,7 @@ local dodisplayverbatimemptyline = context.dodisplayverbatimemptyline local dodisplayverbatimstart = context.dodisplayverbatimstart local dodisplayverbatimstop = context.dodisplayverbatimstop +local verbatim = context.verbatim local doverbatimspace = context.doverbatimspace local CargOne = Carg(1) @@ -688,7 +690,7 @@ local getlines = buffers.getlines -- interface function commands.doifelsevisualizer(name) - commands.testcase(specifications[lower(name)]) + commands.doifelse(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 5336c4458..d18883faf 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -70,21 +70,22 @@ \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 - {\getpagestatus - \hskip\ifrightpage\typingparameter\c!oddmargin\else\typingparameter\c!evenmargin\fi\relax} + {\hskip\doifoddpageelse{\typingparameter\c!oddmargin}{\typingparameter\c!evenmargin}\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 @@ -331,7 +332,7 @@ \unexpanded\def\specialfixedspace {\kern\interwordspace\relax} \unexpanded\def\specialobeyedspace {\hskip\interwordspace\relax} % better than spaceskip -\unexpanded\def\specialstretchedspace{\hskip.5\interwordspace\!!plus.125\interwordstretch\relax} % more but not less +\unexpanded\def\specialstretchedspace{\hskip.5\interwordspace\s!plus.125\interwordstretch\relax} % more but not less \unexpanded\def\specialcontrolspace {\hskip\zeropoint\hbox{\normalcontrolspace}\hskip\zeropoint\relax} \unexpanded\def\obeyhyphens @@ -369,7 +370,7 @@ \let\inlinemathmarker \textdollar \def\displaymathmarker{\textdollar\textdollar} -\def\buff_verbatim_special_type#1#2% +\def\buff_verbatim_special_type#1#2#% # gobbles spaces {\dontleavehmode\bgroup \buff_verbatim_initialize_type_one \catcode\leftbraceasciicode \begingroupcatcode @@ -390,6 +391,8 @@ \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. @@ -641,9 +644,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, @@ -836,4 +839,9 @@ % \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 bd5c16d69..ddade7f52 100644 --- a/tex/context/base/catc-ctx.mkiv +++ b/tex/context/base/catc-ctx.mkiv @@ -128,11 +128,18 @@ % for the moment here: -\def\starttexcode +\normalprotected\def\starttexcode {\pushcatcodetable \catcodetable\prtcatcodes} -\def\stoptexcode +\normalprotected\def\stoptexcode + {\popcatcodetable} + +\normalprotected\def\startcontextcode + {\pushcatcodetable + \catcodetable\ctxcatcodes} + +\normalprotected\def\stopcontextcode {\popcatcodetable} \endinput diff --git a/tex/context/base/catc-def.mkiv b/tex/context/base/catc-def.mkiv index 26e8cb11e..cfbaed171 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 % but way too wide in lm, so ... until that's fixed: +\chardef \_ = \underscoreasciicode \chardef \& = \ampersandasciicode \chardef \% = \commentasciicode \chardef \# = \hashasciicode @@ -133,8 +133,9 @@ \chardef \\ = \backslashasciicode \chardef \| = \barasciicode -%def\_{\leavevmode \kern.06em \vbox{\hrule width.3em}} -\def\_{\dontleavehmode \kern.06em \vbox{\hrule width.3em}} % this will become a \chardef +% way too wide in lm, so one can also use: +% +% \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 b2c793a6a..d4f9b65af 100644 --- a/tex/context/base/catc-ini.lua +++ b/tex/context/base/catc-ini.lua @@ -6,8 +6,6 @@ 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 { } @@ -15,26 +13,29 @@ 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) - catcodes.numbers[name] = number - local cnn = catcodes.names[number] + numbers[name] = number + local cnn = names[number] if cnn then cnn[#cnn+1] = name else - catcodes.names[number] = { name } + names[number] = { name } end - tex[name] = number + tex[name] = number -- downward compatible end -- this only happens at runtime -for k, v in next, catcodes.numbers do - tex[k] = v +for k, v in next, numbers do + tex[k] = v -- downward compatible end -- nasty -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) +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) diff --git a/tex/context/base/catc-ini.mkiv b/tex/context/base/catc-ini.mkiv index 26c3ceee9..791ce31c4 100644 --- a/tex/context/base/catc-ini.mkiv +++ b/tex/context/base/catc-ini.mkiv @@ -87,6 +87,17 @@ \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 @@ -94,7 +105,7 @@ \normalprotected\def\newcatcodetable#1% we could move the cctdefcounter to lua {\global\advance\c_syst_catcodes_n\plusone - \expandafter\xdef\csname\??qm:n:\number\c_syst_catcodes_n\endcsname{\string#1}% logging + \expandafter\xdef\csname\??catcodetablen\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)}} @@ -151,12 +162,7 @@ \setnewconstant\c_syst_catcodes_hack\tildeasciicode %D Once a catcode is assigned, the next assignments will happen -%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 +%D faster. \def\letcatcodecommand{\afterassignment\syst_catcodes_let_a\c_syst_catcodes_a} \def\defcatcodecommand{\afterassignment\syst_catcodes_def_a\c_syst_catcodes_a} @@ -167,46 +173,46 @@ \def\syst_catcodes_ued_a{\afterassignment\syst_catcodes_ued_b\c_syst_catcodes_b} \def\syst_catcodes_let_b % each time - {\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 + {\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 \else \expandafter\syst_catcodes_let_c \fi} \def\syst_catcodes_def_b % each time - {\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 + {\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 \else \expandafter\syst_catcodes_def_c \fi} \def\syst_catcodes_ued_b % each time - {\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 + {\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 \else \expandafter\syst_catcodes_ued_c \fi} \def\syst_catcodes_let_c % only first time - {\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}% + {\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}% \syst_catcodes_reinstate_unexpanded - \csname\??ql:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname} + \csname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname} \def\syst_catcodes_def_c % only first time (we could use \normalexpanded here) - {\expandafter\gdef\csname\??qd:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname + {\expandafter\gdef\csname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname \expandafter##\expandafter1\expandafter - {\expandafter\def\csname\??qm:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}% + {\expandafter\def\csname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}% \syst_catcodes_reinstate_normal - \csname\??qd:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname} + \csname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname} \def\syst_catcodes_ued_c % only first time - {\expandafter\gdef\csname\??qu:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname + {\expandafter\gdef\csname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname \expandafter##\expandafter1\expandafter - {\expandafter\normalprotected\expandafter\def\csname\??qm:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}% + {\expandafter\normalprotected\expandafter\def\csname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}% \syst_catcodes_reinstate_unexpanded - \csname\??qu:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname} + \csname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname} \def\reinstatecatcodecommand{\afterassignment\syst_catcodes_reinstate_normal\c_syst_catcodes_b} @@ -227,8 +233,8 @@ \newconstant\defaultcatcodetable \def\catcodecommand#1% - {\csname\??qm:\number - \ifcsname\??qm:\number\currentcatcodetable:\number#1\endcsname + {\csname\??catcodeget\number + \ifcsname\??catcodeget\number\currentcatcodetable:\number#1\endcsname \currentcatcodetable \else \defaultcatcodetable \fi :\number#1\endcsname} @@ -251,13 +257,13 @@ \normalprotected\def\pushcatcodetable {\advance\c_syst_catcodes_level\plusone \syst_catcodes_trace_push - \expandafter\chardef\csname\??qm:t:\number\c_syst_catcodes_level\endcsname\currentcatcodetable} + \expandafter\chardef\csname\??catcodetablet\number\c_syst_catcodes_level\endcsname\currentcatcodetable} \normalprotected\def\popcatcodetable {\ifcase\c_syst_catcodes_level \syst_catcodes_trace_nesting_error \else - \expandafter\catcodetable\csname\??qm:t:\number\c_syst_catcodes_level\endcsname + \expandafter\catcodetable\csname\??catcodetablet\number\c_syst_catcodes_level\endcsname \syst_catcodes_trace_pop \advance\c_syst_catcodes_level\minusone \fi} @@ -269,7 +275,7 @@ \normalprotected\def\restorecatcodes % takes previous level {\ifnum\c_syst_catcodes_level>\plusone - \expandafter\catcodetable\csname\??qm:t:\number\numexpr\c_syst_catcodes_level-1\relax\endcsname + \expandafter\catcodetable\csname\??catcodetablet\number\numexpr\c_syst_catcodes_level-1\relax\endcsname \fi} % \newtoks\everycatcodetable @@ -294,14 +300,14 @@ \def\syst_catcodes_prev {\ifnum\numexpr\c_syst_catcodes_level-1\relax>\zerocount - \csname\??qm:n:\number\csname\??qm:t:\number\numexpr\c_syst_catcodes_level-1\relax\endcsname\endcsname + \csname\??catcodetablen\number\csname\??catcodetablet\number\numexpr\c_syst_catcodes_level-1\relax\endcsname\endcsname \else -% \fi} \def\catcodetablename {\ifnum\currentcatcodetable>\zerocount - \csname\??qm:n:\number\currentcatcodetable\endcsname + \csname\??catcodetablen\number\currentcatcodetable\endcsname \else -% \fi} diff --git a/tex/context/base/char-cjk.lua b/tex/context/base/char-cjk.lua index b077f4a3e..3d7de1423 100644 --- a/tex/context/base/char-cjk.lua +++ b/tex/context/base/char-cjk.lua @@ -12,7 +12,8 @@ local floor = math.floor local format = string.format local utfchar = utf.char -local ranges = characters.ranges +local ranges = characters.ranges +local allocate = utilities.storage.allocate -- Hangul Syllable @@ -209,7 +210,7 @@ local remapped = { -- this might be merged into char-def.lua [0x11C2] = 0x314E, -- H } -characters.hangul = { +characters.hangul = allocate { decomposed = decomposed, description = description, leadconsonant = leadconsonant, @@ -226,24 +227,6 @@ 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 804468c2d..6c73cf008 100644 --- a/tex/context/base/char-def.lua +++ b/tex/context/base/char-def.lua @@ -3,7 +3,8 @@ 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" + license = "see context related readme files", + dataonly = true, } --[[ @@ -56832,6 +56833,16 @@ characters.data={ description="OVERLINE", direction="on", linebreak="al", + mathspec={ + { + class="topaccent", + name="overbar", + }, + { + class="botaccent", + name="underbar", + }, + }, specials={ "compat", 0x0020, 0x0305 }, unicodeslot=0x203E, }, @@ -57244,6 +57255,8 @@ characters.data={ description="SUPERSCRIPT PLUS SIGN", direction="es", linebreak="al", + mathclass="binary", + mathname ="positivesign", specials={ "super", 0x002B }, unicodeslot=0x207A, }, @@ -57252,6 +57265,8 @@ characters.data={ description="SUPERSCRIPT MINUS", direction="es", linebreak="al", + mathclass="binary", + mathname ="negativesign", specials={ "super", 0x2212 }, unicodeslot=0x207B, }, @@ -58669,7 +58684,7 @@ characters.data={ description="TURNED AMPERSAND", direction="on", linebreak="al", - mathclass="bin", + mathclass="binary", mathname="upand", unicodeslot=0x214B, }, @@ -60887,11 +60902,11 @@ characters.data={ linebreak="ai", mathspec={ { - class="bin", + class="binary", name="vee", }, { - class="bin", + class="binary", name="lor", }, }, @@ -60932,15 +60947,16 @@ characters.data={ description="INTEGRAL", direction="on", linebreak="ai", + mathclass="limop", mathspec={ - { - class="nothing", - name="intop", - }, { class="limop", name="int", }, + { + class="nothing", + name="intop", + }, }, unicodeslot=0x222B, }, @@ -60951,15 +60967,16 @@ characters.data={ description="DOUBLE INTEGRAL", direction="on", linebreak="ai", + mathclass="limop", mathspec={ - { - class="nothing", - name="iintop", - }, { class="limop", name="iint", }, + { + class="nothing", + name="iintop", + }, }, specials={ "compat", 0x222B, 0x222B }, unicodeslot=0x222C, @@ -60969,15 +60986,16 @@ characters.data={ description="TRIPLE INTEGRAL", direction="on", linebreak="al", + mathclass="limop", mathspec={ - { - class="nothing", - name="iiintop", - }, { class="limop", name="iiint", }, + { + class="nothing", + name="iiintop", + }, }, specials={ "compat", 0x222B, 0x222B, 0x222B }, unicodeslot=0x222D, @@ -62402,7 +62420,7 @@ characters.data={ description="NORMAL SUBGROUP OF", direction="on", linebreak="al", - mathclass="bin", + mathclass="binary", mirror=0x22B3, unicodeslot=0x22B2, }, @@ -62412,7 +62430,7 @@ characters.data={ description="CONTAINS AS NORMAL SUBGROUP", direction="on", linebreak="al", - mathclass="bin", + mathclass="binary", mirror=0x22B2, unicodeslot=0x22B3, }, @@ -68388,6 +68406,8 @@ characters.data={ description="BLACK UP-POINTING TRIANGLE", direction="on", linebreak="ai", + mathclass="binary", + mathname="blacktriangle", unicodeslot=0x25B2, }, [0x25B3]={ @@ -68432,7 +68452,7 @@ characters.data={ description="BLACK RIGHT-POINTING TRIANGLE", direction="on", linebreak="ai", - mathclass="bin", + mathclass="binary", mathname="blacktriangleright", unicodeslot=0x25B6, }, @@ -68443,7 +68463,7 @@ characters.data={ description="WHITE RIGHT-POINTING TRIANGLE", direction="on", linebreak="ai", - mathclass="bin", + mathclass="binary", mathname="triangleright", unicodeslot=0x25B7, }, @@ -68452,8 +68472,6 @@ characters.data={ description="BLACK RIGHT-POINTING SMALL TRIANGLE", direction="on", linebreak="al", - mathclass="bin", - mathname="blacktriangleleft", unicodeslot=0x25B8, }, [0x25B9]={ @@ -68486,6 +68504,8 @@ characters.data={ description="BLACK DOWN-POINTING TRIANGLE", direction="on", linebreak="ai", + mathclass="binary", + mathname="blacktriangledown", unicodeslot=0x25BC, }, [0x25BD]={ @@ -68495,8 +68515,16 @@ characters.data={ description="WHITE DOWN-POINTING TRIANGLE", direction="on", linebreak="ai", - mathclass="binary", - mathname="bigtriangledown", + mathspec={ + { + class="binary", + name="triangledown", + }, + { + class="binary", + name="bigtriangledown", + }, + }, unicodeslot=0x25BD, }, [0x25BE]={ @@ -68521,6 +68549,8 @@ characters.data={ description="BLACK LEFT-POINTING TRIANGLE", direction="on", linebreak="ai", + mathclass="binary", + mathname="blacktriangleleft", unicodeslot=0x25C0, }, [0x25C1]={ @@ -68530,7 +68560,7 @@ characters.data={ description="WHITE LEFT-POINTING TRIANGLE", direction="on", linebreak="ai", - mathclass="bin", + mathclass="binary", mathname="triangleleft", unicodeslot=0x25C1, }, diff --git a/tex/context/base/char-enc.lua b/tex/context/base/char-enc.lua index ef6805e54..048837eec 100644 --- a/tex/context/base/char-enc.lua +++ b/tex/context/base/char-enc.lua @@ -1,9 +1,10 @@ -if not modules then modules = { } end modules ['char-syn'] = { +if not modules then modules = { } end modules ['char-enc'] = { 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. @@ -144,25 +145,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 d2ac22bbf..ef55be7e4 100644 --- a/tex/context/base/char-ent.lua +++ b/tex/context/base/char-ent.lua @@ -1,15 +1,14 @@ -if not modules then modules = { } end modules ['math-ent'] = { +if not modules then modules = { } end modules ['char-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 244b8d2a7..778035ff4 100644 --- a/tex/context/base/char-ini.lua +++ b/tex/context/base/char-ini.lua @@ -11,10 +11,9 @@ 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 = unicode.ustring +local ustring, utf = unicode.ustring, unicode.utf8 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 @@ -28,8 +27,8 @@ local texsetsfcode = tex.setsfcode local texsetcatcode = tex.setcatcode local contextsprint = context.sprint -local ctxcatcodes = tex.ctxcatcodes -local texcatcodes = tex.texcatcodes +local ctxcatcodes = catcodes.numbers.ctxcatcodes +local texcatcodes = catcodes.numbers.texcatcodes local setmetatableindex = table.setmetatableindex @@ -48,7 +47,6 @@ loaded!

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

if not characters.fallbacks then - -- we could the definition by using a metatable - - characters.fallbacks = { } - characters.directions = { } + characters.fallbacks = { } -- not than many - local fallbacks = characters.fallbacks - local directions = characters.directions + local fallbacks = characters.fallbacks - 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 + for k, d in next, data do + local specials = d.specials + if specials and specials[1] == "compat" and specials[2] == 0x0020 then local s = specials[3] - fallbacks[k] = s - fallbacks[s] = k + if s then + fallbacks[k] = s + fallbacks[s] = k + end end - directions[k] = v.direction end end -storage.register("characters/fallbacks", characters.fallbacks, "characters.fallbacks") -- accents and such -storage.register("characters/directions", characters.directions, "characters.directions") +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) --[[ldx--

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

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

--ldx]]-- -function characters.makeactive(n,name) -- let ? +function characters.makeactive(n,name) -- 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 @@ -503,7 +512,7 @@ function tex.uprint(c,n) end end -local temphack = tohash { +local forbidden = tohash { -- at least now 0x00A0, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x200B, 0x200C, 0x200D, 0x202F, @@ -539,12 +548,10 @@ function characters.define(tobelettered, tobeactivated) -- catcodetables else contextsprint(ctxcatcodes,format("\\def\\%s{%s}",contextname,utfchar(u))) -- has no s end - elseif is_command[category] then -if not temphack[u] then + elseif is_command[category] and not forbidden[u] then contextsprint("{\\catcode",u,"=13\\unexpanded\\gdef ",utfchar(u),"{\\"..contextname,"}}") a = a + 1 activated[a] = u -end end end end @@ -632,15 +639,17 @@ function characters.setcodes() end else local lc, uc = chr.lccode, chr.uccode - 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 + if not lc then + chr.lccode, lc = code, code + elseif type(lc) == "table" then lc = code end - if type(uc) == "table" then + if not uc then + chr.uccode, uc = code, code + elseif type(uc) == "table" then uc = code end + texsetcatcode(code,11) -- letter texsetlccode(code,lc,uc) if cc == "lu" then texsetsfcode(code,999) @@ -815,8 +824,7 @@ function characters.unicodechar(asked) if n then return n elseif type(asked) == "string" then - asked = gsub(asked," ","") - return descriptions[asked] + return descriptions[asked] or descriptions[gsub(asked," ","")] end end @@ -882,17 +890,21 @@ end function characters.uccode(n) return uccodes[n] end -- obsolete function characters.lccode(n) return lccodes[n] end -- obsolete -function characters.flush(n,direct) +function characters.safechar(n) local c = data[n] if c and c.contextname then - c = "\\" .. c.contextname + return "\\" .. c.contextname else - c = utfchar(n) + return utfchar(n) end - if direct then - return c +end + +function commands.safechar(n) + local c = data[n] + if c and c.contextname then + contextsprint("\\" .. c.contextname) -- context[c.contextname]() else - contextsprint(c) + contextsprint(utfchar(n)) end end diff --git a/tex/context/base/char-map.lua b/tex/context/base/char-map.lua index 376ebf343..749da5289 100644 --- a/tex/context/base/char-map.lua +++ b/tex/context/base/char-map.lua @@ -3,7 +3,8 @@ 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" + license = "see context related readme files", + dataonly = true, } -- not yet used diff --git a/tex/context/base/char-utf.lua b/tex/context/base/char-utf.lua index a411c2d82..52fdfc0d0 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, utfgsub = utf.char, utf.byte, utf.gsub +local utfchar, utfbyte = utf.char, utf.byte 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,6 +76,7 @@ local decomposed = allocate { ["ﬖ"] = "վն", ["ﬗ"] = "մխ", } + characters.decomposed = decomposed local function initialize() -- maybe only 'mn' @@ -209,9 +210,13 @@ 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 +-- 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) for ch in gmatch(special,".") do set(ch) end @@ -481,6 +486,14 @@ 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 4d47982a2..192953ec9 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 -chemicals = chemicals or { } -local chemicals = chemicals +chemistry = chemistry or { } +local chemistry = chemistry --[[

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) -chemicals.moleculeparser = parser -- can be used to avoid functioncall +chemistry.moleculeparser = parser -- can be used to avoid functioncall -function chemicals.molecule(str) +function chemistry.molecule(str) return lpegmatch(parser,str) end diff --git a/tex/context/base/chem-str.lua b/tex/context/base/chem-str.lua index fb325ccea..db1849c5a 100644 --- a/tex/context/base/chem-str.lua +++ b/tex/context/base/chem-str.lua @@ -1,12 +1,15 @@ if not modules then modules = { } end modules ['chem-str'] = { version = 1.001, comment = "companion to chem-str.mkiv", - author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + author = "Hans Hagen and Alan Braslau", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" } --- This module in incomplete and experimental. +-- 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, -- We can push snippets into an mp instance. @@ -26,12 +29,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 -chemicals = chemicals or { } -local chemicals = chemicals +chemistry = chemistry or { } +local chemistry = chemistry -chemicals.instance = "metafun" -- "ppchtex" -chemicals.format = "metafun" -chemicals.structures = 0 +chemistry.instance = "metafun" -- "ppchtex" +chemistry.format = "metafun" +chemistry.structures = 0 local remapper = { ["+"] = "p", @@ -52,7 +55,9 @@ 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", - mov = "transform", rot = "transform", adj = "transform", dir = "transform", sub = "transform", + zbt = "text", zbn = "number", ztt = "text", ztn = "number", + mov = "transform", rot = "transform", adj = "transform", sub = "transform", + off = "transform", } local front_keys = { @@ -60,9 +65,11 @@ 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", @@ -81,15 +88,16 @@ 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 = { { "r","l_b","l_t" }, { "b","l_t","r_t" }, { "l","r_t","r_b" }, { "t","r_b","l_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" } }, prz = { { "r","l","t" }, { "b","t","r" }, { "l","r","b" }, { "t","b","l" } }, } }, @@ -97,7 +105,8 @@ 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 = { { "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 = { { "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" } }, prz = { { "r","b","l","t" }, { "b","l","t","r" }, { "l","t","r","b" }, { "t","r","b","l" } }, } }, @@ -105,7 +114,8 @@ 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 = { { "r","r","b","l","t" }, { "b","b","l","t","r" }, { "l","l","t","r","b" }, { "t","t","r","b","l" } }, + 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" } }, prz = { { "r","b","l","t","t" }, { "b","l","t","r","r" }, { "l","t","r","b","b" }, { "t","r","b","l","l" } }, } }, @@ -113,7 +123,8 @@ 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 = { { "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 = { { "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" } }, 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" } }, } }, @@ -121,7 +132,8 @@ 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 = { { "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 = { { "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" } }, 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" } }, } }, @@ -147,11 +159,11 @@ local syntax = { local definitions = { } -function chemicals.undefine(name) +function chemistry.undefine(name) definitions[lower(name)] = nil end -function chemicals.define(name,spec,text) +function chemistry.define(name,spec,text) name = lower(name) local dn = definitions[name] if not dn then dn = { } definitions[name] = dn end @@ -162,7 +174,7 @@ function chemicals.define(name,spec,text) end local metacode, variant, keys, bonds, max, txt, textsize, rot, pstack -local molecule = chemicals.molecule -- or use lpegmatch(chemicals.moleculeparser,...) +local molecule = chemistry.molecule -- or use lpegmatch(chemistry.moleculeparser,...) local function fetch(txt) local st = stack[txt] @@ -196,35 +208,46 @@ local text = (equal * C(P(1)^0)) + Cc(false) local pattern = (amount + Cc(1)) * - operation * - special * ( + Cs(operation/lower) * + Cs(special/lower) * ( +-- 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 s = spec[i] + local step = spec[i] + local s = lower(step) 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,s) + 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 if operation == "pb" then insert(pstack,variant) m = m + 1 ; metacode[m] = syntax.pb.direct @@ -339,7 +362,8 @@ 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_zero("\\chemicaltext{%s}");',operation,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) end elseif index then local t = text @@ -388,8 +412,8 @@ end -- -- rulethickness in points -function chemicals.start(settings) - chemicals.structures = chemicals.structures + 1 +function chemistry.start(settings) + chemistry.structures = chemistry.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 @@ -445,63 +469,73 @@ function chemicals.start(settings) scale = 0.75 * scale/625 -- metacode[#metacode+1] = format("chem_start_structure(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) ;", - chemicals.structures, + chemistry.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 = "six", { }, 6, { }, 1, { } + variant, keys, bonds, stack, rot, pstack = "one", { }, 1, { }, 1, { } end -function chemicals.stop() +function chemistry.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(chemicals.instance,chemicals.format,mpcode) + metapost.graphic(chemistry.instance,chemistry.format,mpcode) metacode = nil end -function chemicals.component(spec,text,settings) +function chemistry.component(spec,text,settings) rulethickness, rulecolor, offset = settings.rulethickness, settings.rulecolor - local spec = settings_to_array(lower(spec)) +-- local spec = settings_to_array(lower(spec)) + local spec = settings_to_array(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", + ["double"] = "\\chemicaldoublebond", ["--"] = "\\chemicaldoublebond", -- also =? and unicode triple? ["triple"] = "\\chemicaltriplebond", ["---"] = "\\chemicaltriplebond", ["gives"] = "\\chemicalgives", ["->"] = "\\chemicalgives", ["equilibrium"] = "\\chemicalequilibrium", ["<->"] = "\\chemicalequilibrium", ["mesomeric"] = "\\chemicalmesomeric", ["<>"] = "\\chemicalmesomeric", - ["plus"] = "\\chemicalsplus", ["+"] = "\\chemicalsplus", - ["minus"] = "\\chemicalsminus", - ["space"] = "\\chemicalsspace", + ["plus"] = "\\chemicalplus", ["+"] = "\\chemicalplus", + ["minus"] = "\\chemicalminus", + ["space"] = "\\chemicalspace", } --- todo: top / bottom - -function chemicals.inline(spec) +function commands.inlinechemical(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) + context(inl) -- could be a fast context.sprint 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 1d60a293e..c4b03dd1e 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, +%D author=Hans Hagen \& Alan Braslau, %D date=\currentdate, %D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C @@ -10,8 +10,10 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D This module in incomplete and experimental. Eventually this code -%D will replace \PPCHTEX. +%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, \writestatus{loading}{ConTeXt Chemistry Macros / Structure} @@ -26,24 +28,24 @@ % Here we use chemicalformula instead, so no longer a mix: % % \startchemicalformula -% \chemical{H_2}{top}{bottom} +% \chemical{2H_2}{top}{bottom} % \chemical{PLUS}{top}{bottom} -% \chemical{O}{top}{bottom} +% \chemical{O_2}{top}{bottom} % \chemical{GIVES}{top}{bottom} -% \chemical{H_2O}{top}{bottom} +% \chemical{2H_2O}{top}{bottom} % \stopchemicalformula % % \startchemicalformula -% \chemical{H_2} +% \chemical{2H_2} % \chemical{PLUS} -% \chemical{O} +% \chemical{O_2} % \chemical{GIVES} -% \chemical{H_2O} +% \chemical{2H_2O} % \stopchemicalformula % % The inline variant has only one argument: % -% \chemical{H_2,PLUS,O,GIVES,H_2O} +% \chemical{2H_2,PLUS,O_2,GIVES,2H_2O} % todo: seven | eight | frontsix | fontfive | carbon | newmans | chair @@ -58,11 +60,17 @@ \let\setupchemicals\setupchemical -\unexpanded\def\setupchemicalframed - {\dosingleempty\dosetupchemicalframed} +%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] -\def\dosetupchemicalframed - {\getparameters[\??chemicalframed]} +\unexpanded\def\setupchemicalframed + {\setupframed[\??chemicalframed]} \unexpanded\def\definechemical % is global (so we don't use the commandhandler) {\dosingleargument\chem_define} @@ -71,7 +79,7 @@ {\startnointerference \edef\currentdefinedchemical{#1}% \let\chemical\chem_chemical_nested - \ctxlua{chemicals.undefine("#1")}% + \ctxcommand{undefinechemical("#1")}% #2% flush \stopnointerference} @@ -79,7 +87,7 @@ {\dodoubleempty\chem_chemical_nested_indeed} \def\chem_chemical_nested_indeed[#1][#2]% - {\ctxlua{chemicals.define("\currentdefinedchemical",\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es)}} + {\ctxcommand{definechemical("\currentdefinedchemical",\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es)}} % chemical symbols @@ -90,20 +98,15 @@ {\setvalue{\??chemicalsymbol#1}{#2}} \unexpanded\def\chemicalsymbol[#1]% - {\csname\??chemicalsymbol\ifcsname\??chemicalsymbol#1\endcsname\s!unknown\else#1\fi\endcsname} + {\csname\??chemicalsymbol\ifcsname\??chemicalsymbol#1\endcsname#1\else\s!unknown\fi\endcsname} -\definechemicalsymbol[\s!unknown][] % empty +\definechemicalsymbol[\s!unknown][] % \char"FFFD 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 @@ -147,7 +150,7 @@ \fi\fi \the\everystructurechemical \setbox\b_chem_result\hbox\bgroup - \ctxlua{chemicals.start { + \ctxcommand{startchemical { width = "\chemicalparameter\c!width", height = "\chemicalparameter\c!height", left = \chemicalparameter\c!left, @@ -162,7 +165,7 @@ \unexpanded\def\stopchemical {\stopnointerference - \ctxlua{chemicals.stop()}% + \ctxcommand{stopchemical()}% \egroup \d_chem_width \wd\b_chem_result \d_chem_height\ht\b_chem_result @@ -171,15 +174,16 @@ \doifelsenothing{\chemicalparameter\c!frame}\chem_framed_nop\chem_framed_yes \egroup} -\def\chem_framed_yes - {\localframed% +\unexpanded\def\chem_framed_yes + {\localframedwithsettings [\??chemicalframed]% - [\c!frame=\chemicalparameter\c!frame,\c!align=\v!normal,\c!strut=\v!no]{\vbox{\box\b_chem_result\vss}}} % remove depth + [\c!frame=\chemicalparameter\c!frame]% + {\vbox{\box\b_chem_result\vss}}} % remove depth -\def\chem_framed_nop - {\localframed% +\unexpanded\def\chem_framed_nop + {\directlocalframed [\??chemicalframed]% - [\c!align=\v!normal,\c!strut=\v!no]{\vbox{\box\b_chem_result\vss}}} % remove depth + {\vbox{\box\b_chem_result\vss}}} % remove depth \let\startstructurechemical\startchemical \let\stopstructurechemical \stopchemical @@ -200,14 +204,14 @@ \def\strc_chem_indeed_three[#1][#2][#3]% {\writestatus\m!chemicals{hyperlinked chemicals not yet supported}% todo reference, for the moment ignored - \ctxlua{chemicals.component(\!!bs#2\!!es, \!!bs\detokenize{#3}\!!es, { % maybe also pass first two args this way + \ctxcommand{chemicalcomponent(\!!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]% - {\ctxlua{chemicals.component(\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es, { % maybe also pass first two args this way + {\ctxcommand{chemicalcomponent(\!!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 } ) }% @@ -289,8 +293,8 @@ \def\chem_arrow_construct#1#2#3% {\enspace \mathematics{#1% - {\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}}}% + {\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}}% \enspace} % special macros (probably needs some more work) @@ -428,9 +432,9 @@ \usechemicalstyleandcolor\c!style\c!color \ifthirdargument \ifsecondargument - \halign{&\hss##\hss\cr#2\cr\molecule{#1}\cr#3\cr}% + \halign{\aligntab\hss\alignmark\alignmark\hss\cr#2\cr\molecule{#1}\cr#3\cr}% \else - \halign{&\hss##\hss\cr\molecule{#1}\cr#2\cr}% + \halign{\aligntab\hss\alignmark\alignmark\hss \cr\molecule{#1}\cr#2\cr}% \fi \else \hbox{\molecule{#1}}% @@ -440,30 +444,30 @@ \unexpanded\def\inlinechemical#1% {\dontleavehmode - \hbox{\usechemicalstyleandcolor\c!style\c!color\ctxlua{chemicals.inline(\!!bs#1\!!es)}}} + \hbox{\usechemicalstyleandcolor\c!style\c!color\ctxcommand{inlinechemical(\!!bs#1\!!es)}}} \unexpanded\def\chemicalbondrule - {\hbox{\vrule\!!height.75ex\!!depth-\dimexpr.75ex-\linewidth\relax\!!width1em\relax}} + {\hbox{\vrule\s!height.75\exheight\s!depth-\dimexpr.75\exheight-\linewidth\relax\s!width\emwidth\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{\xrightpverleftarrow{}{}}\enspace] +\definechemicalsymbol[i:equilibrium] [\enspace\mathematics{\xrightoverleftarrow{}{}}\enspace] \definechemicalsymbol[i:mesomeric] [\enspace\mathematics{\xleftrightarrow{}{}}\enspace] \definechemicalsymbol[i:single] [\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}] +\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}] \unexpanded\def\chemicalsinglebond {\chemicalsymbol[i:single]} -\unexpanded\def\chemicaldoublebond {\chemicalsymbol[i:tripple]} -\unexpanded\def\chemicaltriplebond {\chemicalsymbol[i:double]} +\unexpanded\def\chemicaldoublebond {\chemicalsymbol[i:double]} +\unexpanded\def\chemicaltriplebond {\chemicalsymbol[i:triple]} \unexpanded\def\chemicalgives {\chemicalsymbol[i:gives]} \unexpanded\def\chemicalmesomeric {\chemicalsymbol[i:mesomeric]} \unexpanded\def\chemicalequilibrium{\chemicalsymbol[i:equilibrium]} -\unexpanded\def\chemicalsplus {\chemicalsymbol[i:plus]} -\unexpanded\def\chemicalsminus {\chemicalsymbol[i:minus]} -\unexpanded\def\chemicalsspace {\chemicalsymbol[i:space]} +\unexpanded\def\chemicalplus {\chemicalsymbol[i:plus]} +\unexpanded\def\chemicalminus {\chemicalsymbol[i:minus]} +\unexpanded\def\chemicalspace {\chemicalsymbol[i:space]} \unexpanded\def\chemicalinline #1{#1} % display @@ -491,61 +495,133 @@ \setfalse\c_chem_has_bot} \unexpanded\def\stopchemicalformula - {\tabskip1em\relax + {\tabskip\emwidth\relax \nointerlineskip \ifconditional\c_chem_has_top \ifconditional\c_chem_has_bot - \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}% + \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}% \else - \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr}% + \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr}% \fi \else \ifconditional\c_chem_has_bot - \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}% + \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}% \else - \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_mid\cr}% + \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\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 - {\ifcsname\??chemicalsymbol\detokenize{#1}\endcsname - \t_chem_mid\expandafter{\the\t_chem_mid\chem_formula_mid{#1}{#2}{#3}}% + {\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 - \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}&}% + \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}% \fi} \def\chem_formula_mid#1% {\csname\??chemicalsymbol\detokenize{#1}\endcsname} -\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_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_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=off] + \c!frame=\v!off] \setupchemical [\c!frame=, diff --git a/tex/context/base/cldf-bas.lua b/tex/context/base/cldf-bas.lua index 30a9265bc..9cf8dcd4a 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-ini'] = { +if not modules then modules = { } end modules ['cldf-bas'] = { version = 1.001, comment = "companion to cldf-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -22,6 +22,8 @@ if not modules then modules = { } end modules ['cldf-ini'] = { -- flush(ctxcatcodes,"}") -- end +-- maybe use context.generics + local type = type local format = string.format local utfchar = utf.char @@ -32,13 +34,16 @@ 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 - -- for i=1,#k do - -- context(format([[\char%s\relax]],k[i])) - -- end - context([[\char%s\relax]],concat(k,[[\relax\char]])) + 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 elseif k then context([[\char%s\relax]],k) end @@ -98,22 +103,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\\bgroup",n) + context([[\setbox%s\hbox{]],n) else - context("\\setbox\\%s\\hbox\\bgroup",n) + context([[\setbox\%s\hbox{]],n) end end function context.startvboxregister(n) if type(n) == "number" then - context("\\setbox%s\\vbox\\bgroup",n) + context([[\setbox%s\vbox{]],n) else - context("\\setbox\\%s\\vbox\\bgroup",n) + context([[\setbox\%s\vbox{]],n) end end @@ -122,19 +127,36 @@ 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\\bgroup") -- we can do \bvbox ... \evbox (less tokens) + context([[\vbox{]]) -- we can do \bvbox ... \evbox (less tokens) end function context.beginhbox() - context("\\hbox\\bgroup") -- todo: use fast one + context([[\hbox{]]) -- 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 bacbbeafd..d9062594e 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 = "start" .. variables.tabulate -- todo: e!start -generics.stoptabulate = "stop" .. variables.tabulate -- todo: e!stop +generics.starttabulate = "starttabulate" -- "start" .. variables.tabulate -- todo: e!start +generics.stoptabulate = "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 ed86c2923..ad5f14855 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 = string.format, string.find, string.gmatch, string.gsub +local format, find, gmatch, gsub, validstring = string.format, string.find, string.gmatch, string.gsub, string.valid 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,12 +40,14 @@ local isnode = node.is_node -- after 0.65 just node.type local writenode = node.write local copynodelist = node.copy_list -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 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 flush = texsprint local flushdirect = texprint @@ -344,9 +346,9 @@ end local methodhandler = resolvers.methodhandler -function context.viafile(data) +function context.viafile(data,tag) if data and data ~= "" then - local filename = resolvers.savers.byscheme("virtual","viafile",data) + local filename = resolvers.savers.byscheme("virtual",validstring(tag,"viafile"),data) -- context.startregime { "utf" } context.input(filename) -- context.stopregime() @@ -410,7 +412,11 @@ local function writer(parent,command,first,...) -- already optimized before call done = true end end - flush(currentcatcodes,"]") + if done then + flush(currentcatcodes,"]") + else + flush(currentcatcodes,"[]") + end 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 55db9fa0b..6cbfd666f 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 ['mult-clm'] = { +if not modules then modules = { } end modules ['cldf-int'] = { version = 1.001, comment = "companion to mult-clm.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -14,9 +14,12 @@ if not modules then modules = { } end modules ['mult-clm'] = { local format, insert, remove, concat = string.format, table.insert, table.remove, table.concat local unpack = unpack or table.unpack -local contextsprint = context.sprint -local ctxcatcodes = tex.ctxcatcodes -local vrbcatcodes = tex.vrbcatcodes +local catcodenumbers = catcodes.numbers + +local ctxcatcodes = catcodenumbers.ctxcatcodes +local vrbcatcodes = catcodenumbers.vrbcatcodes + +local contextsprint = context.sprint 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 237078157..b48fd253a 100644 --- a/tex/context/base/cldf-ver.lua +++ b/tex/context/base/cldf-ver.lua @@ -6,6 +6,10 @@ 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 @@ -41,7 +45,7 @@ table .tocontext = t_tocontext string .tocontext = s_tocontext boolean.tocontext = b_tocontext -function tocontext(first,...) +function context.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 af6c3830e..8878da485 100644 --- a/tex/context/base/colo-ext.mkiv +++ b/tex/context/base/colo-ext.mkiv @@ -29,18 +29,10 @@ %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\!!height\ht#1\!!depth\dp#1\!!width\wd#1\stopcolor + % \startcolor[\s!white]\vrule\s!height\ht#1\s!depth\dp#1\s!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 904d42143..4ab28eb68 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-ini'] = { +if not modules then modules = { } end modules ['colo-icc'] = { 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 747e2116f..e08f3d387 100644 --- a/tex/context/base/colo-ini.lua +++ b/tex/context/base/colo-ini.lua @@ -16,7 +16,8 @@ local trace_define = false trackers.register("colors.define",function(v) trace_ local report_colors = logs.reporter("colors","defining") -local attributes, context, commands = attributes, context, commands +local attributes, backends, storage = attributes, backends, storage +local context, commands = context, commands local settings_to_hash_strict = utilities.parsers.settings_to_hash_strict @@ -666,83 +667,51 @@ function colors.defineintermediatecolor(name,fraction,c_one,c_two,a_one,a_two,sp end end ---~ 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 +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 - 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 - 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)) +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 - definecolor(name,ca,global,freeze) + 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)) + 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) @@ -877,3 +846,22 @@ 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 5721bb513..629f2b96a 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!colors9\v!rgb \fi - \ifconditional\c_colo_cmyk_supported\colo_helpers_show_message\m!colors9\v!cmyk\fi + \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 \colo_helpers_set_current_model \ifproductionrun \edef\p_pagecolormodel{\directcolorsparameter\c!pagecolormodel}% @@ -357,16 +357,26 @@ \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 { } 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_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 -\def\getpaletsize[#1]% +\unexpanded\def\getpaletsize[#1]% only works for valid k=v definitions {\getcommacommandsize[\csname\??colorpaletspecification#1\endcsname]% \edef\paletsize{\number\commalistsize}} @@ -802,9 +812,19 @@ \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? - \ifx\maintextcolor\empty\else\colo_helpers_activate\maintextcolor\fi + \inheritmaintextcolor \to \everybeforeoutput \def\colo_helpers_switch_to_maintextcolor#1% @@ -961,7 +981,7 @@ % ignores in attribute handler % -% \def\forcecolorhack{\vrule\!!width\zeropoint\!!height\zeropoint\!!depth\zeropoint} +% \def\forcecolorhack{\vrule\s!width\zeropoint\s!height\zeropoint\s!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 4f1916d5a..27f7c6b12 100644 --- a/tex/context/base/colo-run.lua +++ b/tex/context/base/colo-run.lua @@ -6,8 +6,10 @@ 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. +-- 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 local colors= attributes.colors diff --git a/tex/context/base/colo-run.mkiv b/tex/context/base/colo-run.mkiv index c330accf3..5084fdd35 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\doshowpalet} + {\dodoubleargument\colo_show_palet} -\gdef\doshowpalet[#1][#2]% +\gdef\colo_show_palet[#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\!!width3em\!!height\strutht\!!depth\strutdp}% - \graycolor[##1]{\vrule\!!width3em\!!height\strutht\!!depth\strutdp}& + \color[##1]{\vrule\s!width3em\s!height\strutht\s!depth\strutdp}% + \graycolor[##1]{\vrule\s!width3em\s!height\strutht\s!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\!!width\!!widtha\!!height\strutht\!!depth\zeropoint}}% + {&\strut\color[##1]{\vrule\s!width\!!widtha\s!height\strutht\s!depth\zeropoint}}% \colo_palets_process[#1]\colo_palets_show_palet\crcr \noalign{\vskip-\strutdepth}% \def\colo_palets_show_palet##1% - {&\graycolor[##1]{\vrule\!!width\!!widtha\!!height\zeropoint\!!depth\strutdp}}% + {&\graycolor[##1]{\vrule\s!width\!!widtha\s!height\zeropoint\s!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\!!width\hsize\!!height3ex}}% + {#1[##1]{\vrule\s!width\hsize\s!height3ex}}% \wd0\zeropoint \box0 \hbox to \hsize {\def\colo_palets_compare####1% {\hbox to \!!widtha - {\hss#1[####1]{\vrule\!!width.5\!!widtha\!!height2.25ex\!!depth-.75ex}\hss}}% + {\hss#1[####1]{\vrule\s!width.5\!!widtha\s!height2.25ex\s!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\!!width4em\!!height\strutht\!!depth\zeropoint}\cr - \graycolor[#1:##1]{\vrule\!!width4em\!!height\zeropoint\!!depth\strutdp}\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 \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\!!width2.5em\!!height\strutht\!!depth\strutdp}% - \graycolor[#1:##1]{\vrule\!!width2.5em\!!height\strutht\!!depth\strutdp}& + \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}& \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\!!width\hsize\!!height3ex}}% + {#1[#2:#3]{\vrule\s!width\hsize\s!height3ex}}% \wd0\zeropoint \box0 \hbox to \hsize - {\hss\dorecurse\!!counta{#1[#2:\recurselevel]{\vrule\!!width.5\!!widtha\!!height2.25ex\!!depth-.75ex}\hss}}} + {\hss\dorecurse\!!counta{#1[#2:\recurselevel]{\vrule\s!width.5\!!widtha\s!height2.25ex\s!depth-.75ex}\hss}}} \endgraf} \protect \endinput diff --git a/tex/context/base/cont-log.mkiv b/tex/context/base/cont-log.mkiv index 67647920d..5d4133143 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\!!height.33em\!!depth-.27em\!!width.33em}{}{}} + {\discretionary{\vrule\s!height.33em\s!depth-.27em\s!width.33em}{}{}} \unexpanded\def\MetaFont {\dontleavehmode @@ -270,4 +270,12 @@ \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 b4958762f..2c07401d8 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.05.30 11:26} +\newcontextversion{2012.10.19 00:06} %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 5a28f8e29..e791d3ba8 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,515 +11,60 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.05.30 11:26} +\newcontextversion{2012.10.19 00:06} -%D This file is loaded at runtime, thereby providing an -%D excellent place for hacks, patches, extensions and new -%D features. +%D This file is loaded at runtime, thereby providing an excellent place for +%D hacks, patches, extensions and new features. \unprotect \writestatus\m!system{beware: some patches loaded from cont-new.mkiv} -\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}} +%D Maybe: -\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 +\unexpanded\def\tightvbox{\dowithnextbox{\dp\nextbox\zeropoint\box\nextbox}\vbox} +\unexpanded\def\tightvtop{\dowithnextbox{\ht\nextbox\zeropoint\box\nextbox}\vtop} -\def\startdescriptions - {\dosingleempty\dostartdescriptions} +%D Needs some work: -\def\dostartdescriptions[#1]% - {\begingroup - \def\item{\getvalue{#1}}% - \let\dostoppairdescription \donothing - \let\@@description \dostartpairdescription - \let\@@startsomedescription\dostartsomedescription} +\unexpanded\def\startgridcorrection + {\dosingleempty\spac_grid_correction_start} -\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]% +\def\spac_grid_correction_start[#1]% {\ifgridsnapping \snaptogrid[#1]\vbox\bgroup \else \startbaselinecorrection \fi} -\def\stopgridcorrection +\unexpanded\def\stopgridcorrection {\ifgridsnapping \egroup \else \stopbaselinecorrection \fi} - -\def\checkgridsnapping + +\unexpanded\def\checkgridsnapping {\lineskip\ifgridsnapping\zeropoint\else\normallineskip\fi} - -\def\startplaatsen - {\dosingleempty\dostartplaatsen} -\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} +%D Probably obsolete: -% \startplaatsen[links] bla \stopplaatsen - -\def\startcolumnmakeup % don't change +\unexpanded\def\startcolumnmakeup % don't change {\bgroup - \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 + \getrawnoflines\textheight % raw as we cna have topskip + \setbox\scratchbox\vbox to \dimexpr\noflines\lineheight-\lineheight+\topskip\relax + \bgroup + \forgetall} -\def\stopcolumnmakeup +\unexpanded\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] -% till we fixed all styles: +%D Till we fixed all styles: \let\\=\crlf diff --git a/tex/context/base/cont-nop.mkiv b/tex/context/base/cont-nop.mkiv new file mode 100644 index 000000000..c8188503e --- /dev/null +++ b/tex/context/base/cont-nop.mkiv @@ -0,0 +1,22 @@ +%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 new file mode 100644 index 000000000..2a032fc0b --- /dev/null +++ b/tex/context/base/cont-yes.mkiv @@ -0,0 +1,80 @@ +%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 09817463b..2b093c3e1 100644 --- a/tex/context/base/context-base.lmx +++ b/tex/context/base/context-base.lmx @@ -19,7 +19,9 @@ + + + diff --git a/tex/context/base/context-help.lmx b/tex/context/base/context-help.lmx index 5401fb65d..939b70cb6 100644 --- a/tex/context/base/context-help.lmx +++ b/tex/context/base/context-help.lmx @@ -19,6 +19,7 @@ <?lua pv('title') ?> +