diff options
-rw-r--r-- | metapost/context/base/mp-grph.mp | 2 | ||||
-rw-r--r-- | metapost/context/base/mp-mlib.mp | 29 | ||||
-rw-r--r-- | metapost/context/base/mp-text.mp | 8 | ||||
-rw-r--r-- | metapost/context/base/mp-tool.mp | 6 | ||||
-rw-r--r-- | scripts/context/lua/mtx-server.lua | 1 | ||||
-rw-r--r-- | tex/context/base/anch-bar.tex (renamed from tex/context/base/core-bar.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/anch-pgr.tex (renamed from tex/context/base/core-pgr.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/anch-pos.lua (renamed from tex/context/base/core-pos.lua) | 4 | ||||
-rw-r--r-- | tex/context/base/anch-pos.mkii (renamed from tex/context/base/core-pos.mkii) | 6 | ||||
-rw-r--r-- | tex/context/base/anch-pos.mkiv (renamed from tex/context/base/core-pos.mkiv) | 8 | ||||
-rw-r--r-- | tex/context/base/anch-snc.tex (renamed from tex/context/base/core-snc.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/attr-ini.mkiv (renamed from tex/context/base/attr-ini.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/back-ini.mkiv (renamed from tex/context/base/back-ini.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/back-pdf.mkiv (renamed from tex/context/base/back-pdf.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/buff-ini.lua (renamed from tex/context/base/core-buf.lua) | 177 | ||||
-rw-r--r-- | tex/context/base/buff-ini.mkii (renamed from tex/context/base/core-buf.mkii) | 6 | ||||
-rw-r--r-- | tex/context/base/buff-ini.mkiv (renamed from tex/context/base/core-buf.mkiv) | 8 | ||||
-rw-r--r-- | tex/context/base/buff-ver.mkii (renamed from tex/context/base/core-ver.mkii) | 6 | ||||
-rw-r--r-- | tex/context/base/buff-ver.mkiv (renamed from tex/context/base/core-ver.mkiv) | 268 | ||||
-rw-r--r-- | tex/context/base/char-act.mkiv | 125 | ||||
-rw-r--r-- | tex/context/base/char-enc.mkiv (renamed from tex/context/base/char-enc.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/char-ini.mkiv (renamed from tex/context/base/char-ini.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/char-utf.mkiv (renamed from tex/context/base/char-utf.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/colo-ini.mkiv | 316 | ||||
-rw-r--r-- | tex/context/base/cont-log.tex | 56 | ||||
-rw-r--r-- | tex/context/base/cont-new.tex | 2 | ||||
-rw-r--r-- | tex/context/base/context.mkii | 81 | ||||
-rw-r--r-- | tex/context/base/context.mkiv | 150 | ||||
-rw-r--r-- | tex/context/base/context.tex | 2 | ||||
-rw-r--r-- | tex/context/base/core-spa.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/font-otn.lua | 2 | ||||
-rw-r--r-- | tex/context/base/grph-fig.mkii (renamed from tex/context/base/core-fig.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/grph-fig.mkiv | 559 | ||||
-rw-r--r-- | tex/context/base/grph-inc.lua (renamed from tex/context/base/core-inc.lua) | 4 | ||||
-rw-r--r-- | tex/context/base/grph-inc.mkii (renamed from tex/context/base/core-inc.mkii) | 56 | ||||
-rw-r--r-- | tex/context/base/grph-inc.mkiv (renamed from tex/context/base/core-inc.mkiv) | 8 | ||||
-rw-r--r-- | tex/context/base/grph-trf.mkii (renamed from tex/context/base/core-trf.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/grph-trf.mkiv | 577 | ||||
-rw-r--r-- | tex/context/base/luat-bas.mkiv (renamed from tex/context/base/luat-bas.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/luat-cod.mkiv (renamed from tex/context/base/luat-cod.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/luat-ini.mkiv (renamed from tex/context/base/luat-ini.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/luat-lib.mkiv (renamed from tex/context/base/luat-lib.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/m-datastrc.tex (renamed from tex/context/base/core-dat.tex) | 26 | ||||
-rw-r--r-- | tex/context/base/meta-fig.mkiv | 4 | ||||
-rw-r--r-- | tex/context/base/meta-ini.mkiv | 137 | ||||
-rw-r--r-- | tex/context/base/mlib-ctx.mkiv (renamed from tex/context/base/mlib-ctx.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/mlib-pdf.lua | 3 | ||||
-rw-r--r-- | tex/context/base/mlib-pdf.mkiv (renamed from tex/context/base/mlib-pdf.tex) | 1 | ||||
-rw-r--r-- | tex/context/base/mlib-pps.lua | 216 | ||||
-rw-r--r-- | tex/context/base/mlib-pps.mkiv (renamed from tex/context/base/mlib-pps.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/mlib-run.lua | 43 | ||||
-rw-r--r-- | tex/context/base/mult-sys.tex | 2 | ||||
-rw-r--r-- | tex/context/base/node-fin.mkiv (renamed from tex/context/base/node-fin.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/node-ini.mkiv (renamed from tex/context/base/node-ini.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/node-par.mkiv (renamed from tex/context/base/node-par.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/pack-box.mkii (renamed from tex/context/base/core-box.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/pack-box.mkiv | 954 | ||||
-rw-r--r-- | tex/context/base/pack-lyr.mkii (renamed from tex/context/base/page-lyr.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/pack-lyr.mkiv | 753 | ||||
-rw-r--r-- | tex/context/base/pack-obj.lua (renamed from tex/context/base/core-obj.lua) | 4 | ||||
-rw-r--r-- | tex/context/base/pack-obj.mkii (renamed from tex/context/base/core-obj.mkii) | 8 | ||||
-rw-r--r-- | tex/context/base/pack-obj.mkiv (renamed from tex/context/base/core-obj.mkiv) | 10 | ||||
-rw-r--r-- | tex/context/base/pack-rul.lua (renamed from tex/context/base/core-rul.lua) | 4 | ||||
-rw-r--r-- | tex/context/base/pack-rul.mkii (renamed from tex/context/base/core-rul.mkii) | 8 | ||||
-rw-r--r-- | tex/context/base/pack-rul.mkiv (renamed from tex/context/base/core-rul.mkiv) | 10 | ||||
-rw-r--r-- | tex/context/base/pret-lua.lua | 259 | ||||
-rw-r--r-- | tex/context/base/pret-mp.lua (renamed from tex/context/base/verb-mp.lua) | 163 | ||||
-rw-r--r-- | tex/context/base/pret-tex.lua | 85 | ||||
-rw-r--r-- | tex/context/base/s-abr-01.tex | 7 | ||||
-rw-r--r-- | tex/context/base/scrn-fld.mkii (renamed from tex/context/base/core-fld.mkii) | 6 | ||||
-rw-r--r-- | tex/context/base/scrn-fld.mkiv (renamed from tex/context/base/core-fld.mkiv) | 6 | ||||
-rw-r--r-- | tex/context/base/scrn-hlp.mkii (renamed from tex/context/base/core-hlp.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/scrn-hlp.mkiv | 171 | ||||
-rw-r--r-- | tex/context/base/scrn-int.mkii (renamed from tex/context/base/core-int.mkii) | 4 | ||||
-rw-r--r-- | tex/context/base/scrn-int.mkiv (renamed from tex/context/base/core-int.mkiv) | 4 | ||||
-rw-r--r-- | tex/context/base/scrn-nav.mkii (renamed from tex/context/base/core-nav.mkii) | 4 | ||||
-rw-r--r-- | tex/context/base/scrn-nav.mkiv (renamed from tex/context/base/core-nav.mkiv) | 6 | ||||
-rw-r--r-- | tex/context/base/scrp-ini.mkiv (renamed from tex/context/base/scrp-ini.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-bkm.mkiv (renamed from tex/context/base/strc-bkm.tex) | 2 | ||||
-rw-r--r-- | tex/context/base/strc-blk.mkii (renamed from tex/context/base/core-blk.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/strc-blk.mkiv (renamed from tex/context/base/strc-blk.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-def.mkiv (renamed from tex/context/base/strc-def.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-des.mkii (renamed from tex/context/base/core-des.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/strc-des.mkiv (renamed from tex/context/base/strc-des.tex) | 24 | ||||
-rw-r--r-- | tex/context/base/strc-doc.lua | 4 | ||||
-rw-r--r-- | tex/context/base/strc-doc.mkiv (renamed from tex/context/base/strc-doc.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-flt.mkii (renamed from tex/context/base/page-flt.tex) | 22 | ||||
-rw-r--r-- | tex/context/base/strc-flt.mkiv (renamed from tex/context/base/strc-flt.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-ini.mkiv (renamed from tex/context/base/strc-ini.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-itm.mkii (renamed from tex/context/base/core-itm.tex) | 22 | ||||
-rw-r--r-- | tex/context/base/strc-itm.mkiv (renamed from tex/context/base/strc-itm.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-lst.mkii (renamed from tex/context/base/core-lst.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/strc-lst.mkiv (renamed from tex/context/base/strc-lst.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-mar.mkii (renamed from tex/context/base/core-mar.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/strc-mar.mkiv (renamed from tex/context/base/strc-mar.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-mat.mkii (renamed from tex/context/base/core-mat.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/strc-mat.mkiv (renamed from tex/context/base/strc-mat.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-not.lua | 5 | ||||
-rw-r--r-- | tex/context/base/strc-not.mkii (renamed from tex/context/base/core-not.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/strc-not.mkiv (renamed from tex/context/base/strc-not.tex) | 2 | ||||
-rw-r--r-- | tex/context/base/strc-num.mkii (renamed from tex/context/base/core-num.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/strc-num.mkiv (renamed from tex/context/base/strc-num.tex) | 12 | ||||
-rw-r--r-- | tex/context/base/strc-pag.mkii (renamed from tex/context/base/page-num.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/strc-pag.mkiv (renamed from tex/context/base/strc-pag.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-prc.mkiv (renamed from tex/context/base/strc-prc.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-ref.mkii (renamed from tex/context/base/core-ref.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/strc-ref.mkiv (renamed from tex/context/base/strc-ref.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-reg.mkii (renamed from tex/context/base/core-reg.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/strc-reg.mkiv (renamed from tex/context/base/strc-reg.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-ren.mkiv (renamed from tex/context/base/strc-ren.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-sbe.mkiv (renamed from tex/context/base/strc-sbe.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-sec.mkii (renamed from tex/context/base/core-sec.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/strc-sec.mkiv (renamed from tex/context/base/strc-sec.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-swd.mkii (renamed from tex/context/base/core-swd.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/strc-syn.mkii (renamed from tex/context/base/core-syn.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/strc-syn.mkiv (renamed from tex/context/base/strc-syn.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/strc-xml.mkiv (renamed from tex/context/base/strc-xml.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/syst-aux.mkiv (renamed from tex/context/base/syst-aux.tex) | 67 | ||||
-rw-r--r-- | tex/context/base/syst-lua.mkiv (renamed from tex/context/base/syst-lua.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/task-ini.mkiv (renamed from tex/context/base/task-ini.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/toks-ini.mkiv (renamed from tex/context/base/toks-ini.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/trac-deb.mkiv (renamed from tex/context/base/trac-deb.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/trac-lmx.mkiv (renamed from tex/context/base/trac-lmx.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/trac-vis.mkii (renamed from tex/context/base/core-vis.tex) | 6 | ||||
-rw-r--r-- | tex/context/base/trac-vis.mkiv | 748 | ||||
-rw-r--r-- | tex/context/base/typo-brk.mkiv (renamed from tex/context/base/typo-brk.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/typo-cap.mkiv (renamed from tex/context/base/typo-cap.tex) | 12 | ||||
-rw-r--r-- | tex/context/base/typo-ini.mkii (renamed from tex/context/base/typo-ini.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/typo-ini.mkiv | 40 | ||||
-rw-r--r-- | tex/context/base/typo-krn.mkiv (renamed from tex/context/base/typo-krn.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/typo-mir.mkiv (renamed from tex/context/base/typo-mir.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/typo-spa.mkiv (renamed from tex/context/base/typo-spa.tex) | 0 | ||||
-rw-r--r-- | tex/context/base/verb-lua.lua | 216 | ||||
-rw-r--r-- | tex/context/base/verb-tex.lua | 126 | ||||
-rw-r--r-- | tex/context/test/chem-str-test.tex (renamed from tex/context/base/chem-str-test.tex) | 0 | ||||
-rw-r--r-- | tex/generic/context/luatex-fonts-merged.lua | 4 |
136 files changed, 5272 insertions, 1533 deletions
diff --git a/metapost/context/base/mp-grph.mp b/metapost/context/base/mp-grph.mp index 1ff2a9ec2..243b45318 100644 --- a/metapost/context/base/mp-grph.mp +++ b/metapost/context/base/mp-grph.mp @@ -94,7 +94,7 @@ enddef ; def doloadfigure (expr filename) text figureattributes = begingroup ; save figurenumber, figurepicture, number, fixedplace ; - numeric figurenumber ; figurenumber := 0 ; + numeric figurenumber ; figurenumber := 0 ; boolean figureshift ; figureshift := true ; picture figurepicture ; figurepicture := currentpicture ; def number primary n = hide(figurenumber := n) enddef ; diff --git a/metapost/context/base/mp-mlib.mp b/metapost/context/base/mp-mlib.mp index 893222473..aeacb3e9c 100644 --- a/metapost/context/base/mp-mlib.mp +++ b/metapost/context/base/mp-mlib.mp @@ -36,10 +36,10 @@ vardef rawtextext(expr str) = image ( _tt_n_ := _tt_n_ + 1 ; _tt_p_ := image ( - draw _tt_p_ ; + addto currentpicture also _tt_p_ ; addto currentpicture doublepath unitsquare withprescript "tf" withpostscript decimal _tt_n_ & ":" & str ; ) ; - draw unitsquare withpen pencircle scaled 0 ; + addto currentpicture doublepath unitsquare withpen pencircle scaled 0 ; ) else : image ( @@ -68,8 +68,13 @@ labtype.urt := 6 ; labtype.llft := 7 ; labtype.lrt := 8 ; labtype.d := 10 ; labtype.dlft := 11 ; labtype.drt := 12 ; labtype.origin := 0 ; labtype.raw := 0 ; -laboff.origin = (infinity,infinity) ; labxf.origin := 0 ; labyf.origin := 0 ; -laboff.raw = (infinity,infinity) ; labxf.raw := 0 ; labyf.raw := 0 ; +% laboff.origin = (infinity,infinity) ; labxf.origin := 0 ; labyf.origin := 0 ; +% laboff.raw = (infinity,infinity) ; labxf.raw := 0 ; labyf.raw := 0 ; + +% todo: thelabel.origin("xxxx",origin) (overflows) + +laboff.origin = (0,0) ; labxf.origin := 0 ; labyf.origin := 0 ; +laboff.raw = (0,0) ; labxf.raw := 0 ; labyf.raw := 0 ; pair laboff.l ; laboff.l = laboff.lft ; pair laboff.r ; laboff.r = laboff.rt ; @@ -131,7 +136,7 @@ vardef thetextext@#(expr p,z) = % adapted copy of thelabel@ if (labtype@# >= 10) : shifted (0,ypart center p) fi shifted (z + labeloffset*laboff@# - (labxf@#*lrcorner p + labyf@#*ulcorner p + (1-labxf@#-labyf@#)*llcorner p)) fi -enddef; +enddef ; vardef textext@#(expr txt) = interim labeloffset := textextoffset ; @@ -161,7 +166,11 @@ vardef thelabel@#(expr s, z) = enddef; primarydef str infont name = % very naughty ! - textext("\definedfont[" & name & "]" & str) + if name = "" : + textext(str) + else : + textext("\definedfont[" & name & "]" & str) + fi enddef ; def circular_shade (expr p, n, ca, cb) = @@ -252,9 +261,17 @@ def doexternalfigure (expr filename) text transformation = draw unitsquare transformation withprescript "fg" withpostscript filename ; enddef ; +def register (expr label, width, height, offset) = + draw unitsquare xscaled width yscaled height shifted offset withprescript "ps" withpostscript label ; +enddef ; + extra_beginfig := extra_beginfig & "currentgraphictext := 0 ; " ; extra_endfig := extra_endfig & "finishsavingdata ; " ; extra_endfig := extra_endfig & "resettextexts ; " ; boolean cmykcolors ; cmykcolors := true ; boolean spotcolors ; spotcolors := true ; + +vardef verbatim(expr str) = + ditto & "\detokenize{" & str & "}" & ditto +enddef ; diff --git a/metapost/context/base/mp-text.mp b/metapost/context/base/mp-text.mp index 292b79b4f..a76458144 100644 --- a/metapost/context/base/mp-text.mp +++ b/metapost/context/base/mp-text.mp @@ -104,8 +104,8 @@ vardef textextstr(expr s, a) = scantokens ss enddef ; -pair laboff.origin ; laboff.origin = (infinity,infinity) ; -pair laboff.raw ; laboff.raw = (infinity,infinity) ; +pair laboff.origin ; laboff.origin = (0,0) ; % (infinity,infinity) ; +pair laboff.raw ; laboff.raw = (0,0) ; % (infinity,infinity) ; vardef thelabel@#(expr s, z) = save p ; picture p ; @@ -259,3 +259,7 @@ def build_parshape (expr p, offset_or_path, dx, dy, endgroup ; enddef ; + +vardef verbatim(expr str) = + ditto & "\detokenize{" & str & "}" & ditto +enddef ; diff --git a/metapost/context/base/mp-tool.mp b/metapost/context/base/mp-tool.mp index 817f237b0..3ba5923ea 100644 --- a/metapost/context/base/mp-tool.mp +++ b/metapost/context/base/mp-tool.mp @@ -1054,6 +1054,12 @@ enddef ; let normaldraw = draw ; let normalfill = fill ; +% bugged in mplib so ... + +def normalfill expr c = addto currentpicture contour c _op_ enddef ; +def normaldraw expr p = addto currentpicture if picture p: also p else: doublepath p withpen currentpen fi _op_ enddef ; + + def drawlineoptions (text t) = def _lin_opt_ = t enddef ; enddef ; def drawpointoptions (text t) = def _pnt_opt_ = t enddef ; enddef ; def drawcontroloptions(text t) = def _ctr_opt_ = t enddef ; enddef ; diff --git a/scripts/context/lua/mtx-server.lua b/scripts/context/lua/mtx-server.lua index 74f0ed924..615506ac0 100644 --- a/scripts/context/lua/mtx-server.lua +++ b/scripts/context/lua/mtx-server.lua @@ -279,6 +279,7 @@ function scripts.webserver.run(configuration) logs.simple("document root: %s",configuration.root or resolvers.ownpath) logs.simple("main index file: %s",configuration.index) logs.simple("scripts subpath: %s",configuration.scripts) + logs.simple("context services: http://localhost:%s/mtx-server-ctx-startup.lua",configuration.port) local server = assert(socket.bind("*", configuration.port)) while true do -- no multiple clients local start = os.clock() diff --git a/tex/context/base/core-bar.tex b/tex/context/base/anch-bar.tex index 5b28afb9d..d08573c0f 100644 --- a/tex/context/base/core-bar.tex +++ b/tex/context/base/anch-bar.tex @@ -1,7 +1,7 @@ %D \module -%D [ file=core-bar, +%D [ file=anch-bar, %D version=2003.03.16, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Anchoring Macros, %D subtitle=Margin Bars and alike, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Margin Bars} +\writestatus{loading}{ConTeXt Anchoring Macros / Margin Bars} \unprotect diff --git a/tex/context/base/core-pgr.tex b/tex/context/base/anch-pgr.tex index ab2378441..5d8ec6bf5 100644 --- a/tex/context/base/core-pgr.tex +++ b/tex/context/base/anch-pgr.tex @@ -1,7 +1,7 @@ %D \module -%D [ file=core-pgr, % split off core-pos +%D [ file=anch-pgr, % split off core-pos %D version=1999.08.01, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Anchoring Macros, %D subtitle=Positioning Graphics, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Positioning Grapics} +\writestatus{loading}{ConTeXt Anchoring Macros / Grapics} %D Before we come to graphics support, we have to make sure of %D the reference point on the page. The next macro does so and diff --git a/tex/context/base/core-pos.lua b/tex/context/base/anch-pos.lua index be2ac1915..82b0657a1 100644 --- a/tex/context/base/core-pos.lua +++ b/tex/context/base/anch-pos.lua @@ -1,6 +1,6 @@ -if not modules then modules = { } end modules ['core-pos'] = { +if not modules then modules = { } end modules ['anch-pos'] = { version = 1.001, - comment = "companion to core-pos.tex", + comment = "companion to anch-pos.tex", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" diff --git a/tex/context/base/core-pos.mkii b/tex/context/base/anch-pos.mkii index 58784ed7b..eaf9886b4 100644 --- a/tex/context/base/core-pos.mkii +++ b/tex/context/base/anch-pos.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-pos, +%D [ file=anch-pos, %D version=1999.08.01, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Anchoring Macros, %D subtitle=Positioning Support, %D author=Hans Hagen, %D date=\currentdate, @@ -26,7 +26,7 @@ % 3 -> undef, dus == prev % 4 -> opslaan -\writestatus{loading}{ConTeXt Core Macros / Positioning Support} +\writestatus{loading}{ConTeXt Anchoring Macros / Positioning} % todo: topskip als optie voor eerste regel achtergrond % todo: build pos layers on top of layers diff --git a/tex/context/base/core-pos.mkiv b/tex/context/base/anch-pos.mkiv index 16d5b229f..a3c7b06cf 100644 --- a/tex/context/base/core-pos.mkiv +++ b/tex/context/base/anch-pos.mkiv @@ -1,7 +1,7 @@ %D \module -%D [ file=core-pos, +%D [ file=anch-pos, % was core-pos %D version=1999.08.01, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Anchoring Macros, %D subtitle=Positioning Support, %D author=Hans Hagen, %D date=\currentdate, @@ -26,7 +26,7 @@ % 3 -> undef, dus == prev % 4 -> opslaan -\writestatus{loading}{ConTeXt Core Macros / Positioning Support} +\writestatus{loading}{ConTeXt Anchoring Macros / Positioning} % saveposition : tag page x y % savepositionwhd : tag page x y w h d @@ -40,7 +40,7 @@ % btw, using a function is more efficient than passing longer code % snippets to ctxlua -\registerctxluafile{core-pos}{1.001} +\registerctxluafile{anch-pos}{1.001} % todo: topskip als optie voor eerste regel achtergrond % todo: build pos layers on top of layers diff --git a/tex/context/base/core-snc.tex b/tex/context/base/anch-snc.tex index 99c7d58f6..ed090eaf9 100644 --- a/tex/context/base/core-snc.tex +++ b/tex/context/base/anch-snc.tex @@ -1,7 +1,7 @@ %D \module -%D [ file=core-snc, +%D [ file=anch-snc, %D version=2003.12.01, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Anchoring Macros, %D subtitle=Synchronization, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Synchronization} +\writestatus{loading}{ConTeXt Anchoring Macros / Synchronization} \unprotect diff --git a/tex/context/base/attr-ini.tex b/tex/context/base/attr-ini.mkiv index 3997d546b..3997d546b 100644 --- a/tex/context/base/attr-ini.tex +++ b/tex/context/base/attr-ini.mkiv diff --git a/tex/context/base/back-ini.tex b/tex/context/base/back-ini.mkiv index a60b6a329..a60b6a329 100644 --- a/tex/context/base/back-ini.tex +++ b/tex/context/base/back-ini.mkiv diff --git a/tex/context/base/back-pdf.tex b/tex/context/base/back-pdf.mkiv index b7de1051f..b7de1051f 100644 --- a/tex/context/base/back-pdf.tex +++ b/tex/context/base/back-pdf.mkiv diff --git a/tex/context/base/core-buf.lua b/tex/context/base/buff-ini.lua index 389ebde35..6f098a271 100644 --- a/tex/context/base/core-buf.lua +++ b/tex/context/base/buff-ini.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['core-buf'] = { +if not modules then modules = { } end modules ['buff-ini'] = { version = 1.001, comment = "companion to core-buf.tex", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -11,8 +11,6 @@ if not modules then modules = { } end modules ['core-buf'] = { -- redefine buffers.get -utf = unicode.utf8 - buffers = { } buffers.data = { } buffers.hooks = { } @@ -26,10 +24,9 @@ local utf = unicode.utf8 local concat, texsprint, texprint, texwrite = table.concat, tex.sprint, tex.print, tex.write local utfbyte, utffind, utfgsub = utf.byte, utf.find, utf.gsub +local type, next = type, next local byte, sub, find, char, gsub, rep, lower = string.byte, string.sub, string.find, string.char, string.gsub, string.rep, string.lower local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues - -local vrbcatcodes = tex.vrbcatcodes local ctxcatcodes = tex.ctxcatcodes local data, commands, flags, hooks, visualizers = buffers.data, buffers.commands, buffers.flags, buffers.hooks, buffers.visualizers @@ -58,7 +55,7 @@ function buffers.grab(name,begintag,endtag,bufferdata) buffers.level = 0 end buffers.level = buffers.level + bufferdata:count("\\"..begintag) - bufferdata:count("\\"..endtag) - local more = buffers.level>0 + local more = buffers.level > 0 if more then dn = dn .. bufferdata .. endtag buffers.level = buffers.level - 1 @@ -217,6 +214,8 @@ end buffers.content = content function buffers.collect(names,separator) -- no print + -- maybe we shoul always store a buffer as table so + -- that we can pass if directly local t = { } if type(names) == "table" then for i=1,#names do @@ -226,18 +225,22 @@ function buffers.collect(names,separator) -- no print end end else - for name in names:gmatch("[^,]+") do + for name in names:gmatch("[^,%s]+") do local c = content(name,separator) if c ~= "" then t[#t+1] = c end end end - return concat(t,separator or "\n") -- "\n" is safer due to comments and such + return concat(t,separator or "\r") -- "\n" is safer due to comments and such +end + +function buffers.feedback(names,separator) + texsprint(ctxcatcodes,string.splitlines(buffers.collect(names,separator))) end local function tobyte(c) - return " [" .. byte(c) .. "] " + return " [" .. utfbyte(c) .. "] " end function buffers.inspect(name) @@ -259,9 +262,9 @@ end -- maybe just line(n,str) empty(n,str) -visualizers.default = { } -visualizers.tex = { } -visualizers.mp = { } +visualizers.default = visualizers.default or { } +visualizers.tex = visualizers.tex or { } +visualizers.mp = visualizers.mp or { } visualizers.escapetoken = nil visualizers.tablength = 7 @@ -270,18 +273,23 @@ visualizers.enabletab = true -- false visualizers.enableescape = false visualizers.obeyspace = true +local default = visualizers.default + function visualizers.reset() ---~ visualizers.enabletab = false ---~ visualizers.enableescape = false ---~ buffers.currentvisualizer = 'default' +--~ visualizers.enabletab = false +--~ visualizers.enableescape = false +--~ buffers.currentvisualizer = 'default' end -buffers.currentvisualizer = 'default' +buffers.currentvisualizer = 'default' -- could become a local function buffers.setvisualizer(str) buffers.currentvisualizer = lower(str) - if not visualizers[buffers.currentvisualizer] then + local v = visualizers[buffers.currentvisualizer] + if not v then buffers.currentvisualizer = 'default' + elseif v.reset then + v.reset() end end @@ -292,78 +300,83 @@ end -- calling routines, don't change function hooks.flush_line(str,nesting) - str = str:gsub(" *[\n\r]+ *"," ") - local flush_line = visualizers[buffers.currentvisualizer].flush_line - if flush_line then - flush_line(str,nesting) - else - visualizers.default.flush_line(str,nesting) - end + str = gsub(str," *[\n\r]+ *"," ") ; -- semi colon needed + (visualizers[buffers.currentvisualizer].flush_line or default.flush_line)(str,nesting) end function hooks.begin_of_line(n) - local begin_of_line = visualizers[buffers.currentvisualizer].begin_of_line - if begin_of_line then - begin_of_line(n) - else - visualizers.default.begin_of_line(n) - end + (visualizers[buffers.currentvisualizer].begin_of_line or default.begin_of_line)(n) end function hooks.end_of_line() - local end_of_line = visualizers[buffers.currentvisualizer].end_of_line - if end_of_line then - end_of_line() - else - visualizers.default.end_of_line(str) - end + (visualizers[buffers.currentvisualizer].end_of_line or default.end_of_line)() end function hooks.empty_line() - local empty_line = visualizers[buffers.currentvisualizer].empty_line - if empty_line then - empty_line() - else - visualizers.default.empty_line() - end + (visualizers[buffers.currentvisualizer].empty_line or default.empty_line)() end function hooks.line(str) - local line = visualizers[buffers.currentvisualizer].line if visualizers.enabletab then str = string.tabtospace(str,visualizers.tablength) else str = gsub(str,"\t"," ") end - if line then - return line(str) - else - return visualizers.default.line(str) - end + return (visualizers[buffers.currentvisualizer].line or default.line)(str) end -- defaults -function visualizers.default.flush_line(str) - texsprint(ctxcatcodes,buffers.escaped(str)) -end - -function visualizers.default.begin_of_line(n) +function default.begin_of_line(n) texsprint(ctxcatcodes, commands.begin_of_line_command,"{",n,"}") end -function visualizers.default.end_of_line() +function default.end_of_line() texsprint(ctxcatcodes,commands.end_of_line_command) end -function visualizers.default.empty_line() +function default.empty_line() texsprint(ctxcatcodes,commands.empty_line_command) end -function visualizers.default.line(str) +function default.line(str) return str end +function default.flush_line(str) + str = str:gsub(" *[\n\r]+ *"," ") + if visualizers.obeyspace then + for c in utfcharacters(str) do + if c == " " then + texsprint(ctxcatcodes,"\\obs ") + else + texwrite(c) + end + end + else + texwrite(str) + end +end + +-- not needed any more + +local function escaped_token(c) + if utffind(c,"^(%a%d)$") then + return c + elseif c == " " then + return "\\obs " + else + return "\\char" .. utfbyte(c) .. " " + end +end + +buffers.escaped_token = escaped_token + +function buffers.escaped(str) + -- use the utfcharacters loop + return (utfgsub(str,"(.)", escaped_token)) +end + -- special one commands.nested = "\\switchslantedtype " @@ -415,26 +428,26 @@ end buffers.currentcolors = { } -function buffers.change_state(n, state, result) +function buffers.change_state(n, state) if n then if state ~= n then if state > 0 then - result[#result+1] = "\\sop[" .. buffers.currentcolors[n] .. "]" + texsprint(ctxcatcodes,"\\sop[",buffers.currentcolors[n],"]") else - result[#result+1] = "\\bop[" .. buffers.currentcolors[n] .. "]" + texsprint(ctxcatcodes,"\\bop[",buffers.currentcolors[n],"]") end return n end elseif state > 0 then - result[#result+1] = "\\eop " + texsprint(ctxcatcodes,"\\eop") return 0 end return state end -function buffers.finish_state(state, result) +function buffers.finish_state(state) if state > 0 then - result[#result+1] = "\\eop " + texsprint(ctxcatcodes,"\\eop") return 0 else return state @@ -457,43 +470,3 @@ function buffers.flush_result(result,nested) texsprint(ctxcatcodes,concat(result,"")) end end - -local function escaped_token(c) - if utffind(c,"^(%a%d)$") then - return c - elseif c == " " then - return "\\obs " - else - return "\\char" .. utfbyte(c) .. " " - end -end - -buffers.escaped_token = escaped_token - -function buffers.escaped(str) - -- use the utfcharacters loop - return (utfgsub(str,"(.)", escaped_token)) -end - -function buffers.escaped_chr(ch) - if ch == " " then - return "\\obs " - else - return "\\char" .. utfbyte(ch) .. " " - end -end - -function visualizers.default.flush_line(str) - str = str:gsub(" *[\n\r]+ *"," ") - if visualizers.obeyspace then - for c in utfcharacters(str) do - if c == " " then - texsprint(ctxcatcodes,"\\obs ") - else - texsprint(vrbcatcodes,c) - end - end - else - texsprint(vrbcatcodes,str) - end -end diff --git a/tex/context/base/core-buf.mkii b/tex/context/base/buff-ini.mkii index 9937fae01..0f0655ea1 100644 --- a/tex/context/base/core-buf.mkii +++ b/tex/context/base/buff-ini.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-buf, % blocks are moved to core-blk +%D [ file=buff-ini, % was core-buf % blocks are moved to core-blk %D version=2000.01.05, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Buffer Macros, %D subtitle=Buffers, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Buffers} +\writestatus{loading}{ConTeXt Buffer Macros / Buffers} \unprotect diff --git a/tex/context/base/core-buf.mkiv b/tex/context/base/buff-ini.mkiv index 8b69616b9..c9c1ae052 100644 --- a/tex/context/base/core-buf.mkiv +++ b/tex/context/base/buff-ini.mkiv @@ -1,7 +1,7 @@ %D \module -%D [ file=core-buf, % blocks are moved to core-blk +%D [ file=buff-ini, % was core-buf, % blocks are moved to core-blk %D version=2000.01.05, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Buffer Macros, %D subtitle=Buffers, %D author=Hans Hagen, %D date=\currentdate, @@ -11,9 +11,9 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Buffers} +\writestatus{loading}{ConTeXt Buffer Macros / Buffers} -\registerctxluafile{core-buf}{1.001} +\registerctxluafile{buff-ini}{1.001} \ifdefined\doinitializeverbatim \else% temp hack \ifdefined\mkinitializeverbatim diff --git a/tex/context/base/core-ver.mkii b/tex/context/base/buff-ver.mkii index dd8f5f84f..c9ad8cbc9 100644 --- a/tex/context/base/core-ver.mkii +++ b/tex/context/base/buff-ver.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-ver, +%D [ file=buff-ver, % was core-ver %D version=2000.05.09, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Buffer Macros, %D subtitle=Verbatim, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Verbatim} +\writestatus{loading}{ConTeXt Buffer Macros / Verbatim} \unprotect diff --git a/tex/context/base/core-ver.mkiv b/tex/context/base/buff-ver.mkiv index e9c092f66..5998260f2 100644 --- a/tex/context/base/core-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -1,7 +1,7 @@ %D \module -%D [ file=core-ver, +%D [ file=buff-ver, % was core-ver %D version=2000.05.09, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Buffer Macros, %D subtitle=Verbatim, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Verbatim} +\writestatus{loading}{ConTeXt Buffer Macros / Verbatim} \unprotect @@ -19,6 +19,20 @@ \ifx\stoplinenumbering \undefined \let\stoplinenumbering\relax \fi \ifx\setuplinenumbering\undefined \def\setuplinenumbering[#1]{} \fi +% D \macros +% D {iflinepar} +% D +% D A careful reader will see that \type{\linepar} is reset. +% D This boolean can be used to determine if the current line is +% D the first line in a pseudo paragraph and this boolean is set +% D after each empty line. The \type{\relax} can be used to +% D determine the end of the line when one implements a scanner +% D routine. +% +% will become obsolete + +\newif\iflinepar + % \type{ <crlf> char} geeft bagger %D We are going to embed the general verbatim support macros in @@ -39,8 +53,6 @@ \fi \fi} -\newprettytrue % movet to here from cont-sys.tex - \def\prettyidentifier {TEX} \def\prettypalet {} @@ -52,16 +64,12 @@ \uppercasestring#2\to\asciib \setevalue{\??ty\??ty\asciia}{\asciib}} -% \ctxluafileload{verb-tex}{} -% \ctxluafileload{verb-mp} {} -% \registerctxluafile{core-buf-tex}{} -% \registerctxluafile{core-buf-mp} {} - \def\setupprettiesintype#1% {\uppercasestring#1\to\ascii \edef\prettyidentifier{\executeifdefined{\??ty\??ty\ascii}{TEX}}% \begingroup - \lowercasestring verb-\prettyidentifier\to\filename + % we can move this to lua + \lowercasestring \f!prettyprefix\prettyidentifier\to\filename \doonlyonce\filename{\ctxloadluafile\filename\empty}% \endgroup} @@ -69,11 +77,18 @@ {\processingverbatimtrue % will move \ctxlua{buffers.visualizers.reset()}} +\def\setverbatimspaceskip + {\setbox\scratchbox\hbox{x}% + \spaceskip\wd\scratchbox + \xspaceskip\spaceskip} + +\let\obeycharacters\relax + \setvalue{\??tp:\c!lines:\v!yes }{\obeybreakpoints} \setvalue{\??tp:\c!lines:\v!hyphenated}{\obeyhyphens} -\setvalue{\??tp:\c!empty:\v!yes }{\obeyemptylines} -\setvalue{\??tp:\c!empty:\v!all }{\obeyallemptylines} +%setvalue{\??tp:\c!empty:\v!yes }{\obeyemptylines} +%setvalue{\??tp:\c!empty:\v!all }{\obeyallemptylines} \setvalue{\??tp:\c!option:\v!none }{\let\obeycharacters\relax} \setvalue{\??tp:\c!option:\v!color }{\setupprettiesintype{TEX}% @@ -88,15 +103,14 @@ \let\obeycharacters\setupprettytype \let\obeytabs\ignoretabs} - \def\setupcommonverbatim {\recatcodeuppercharactersfalse % obey regime / encoding % \let\prettyidentifier\s!default % - \doifelse{\typingparameter\c!text}\v!yes - \naturaltextexttrue - \naturaltextextfalse +% \doifelse{\typingparameter\c!text}\v!yes +% \naturaltextexttrue +% \naturaltextextfalse \def\prettyidentifierfont{\typingparameter\c!icommand}% \def\prettyvariablefont {\typingparameter\c!vcommand}% \def\prettynaturalfont {\typingparameter\c!ccommand}% @@ -106,11 +120,8 @@ \doif{\typingparameter\c!page }\v!no {\def\obeypages {\ignorepages}}% % - \doifelse{\typingparameter\c!tab}\v!yes - {\def\obeytabs{\settabskips}}% - {\doif{\typingparameter\c!tab}\s!ascii % not needed in mkiv - {\chardef\tabskipmode\plustwo % quit on >127 - \def\obeytabs{\settabskips}}}% +% \doifelse{\typingparameter\c!tab}\v!yes +% {}% todo % \ignorehyphens % default \getvalue{\??tp:\c!lines:\typingparameter\c!lines}% @@ -146,7 +157,6 @@ \resetcharacterspacing \to \everyinitializeverbatim - % BEWARE: the noligatures will globally change the verbatim font's behaviour % test case: @@ -334,7 +344,13 @@ \def\initializetype {\let\obeylines\ignorelines \setupcommonverbatim - \setupinlineverbatim} + \verbatimfont % needed for \tex + %\setverbatimspaceskip + %\let\obeytabs \ignoretabs % probably not needed + %\let\obeylines\ignorelines % probably not needed + %\let\obeypages\ignorepages % probably not needed + %\setupcopyverbatim % not needed + } %D \macros %D {setuptype} @@ -440,11 +456,6 @@ \let\currenttyping \empty \let\currenttypingclass\??ty % saveguard -% \def\typingparameter#1% -% {\executeifdefined -% {\currenttypingclass\currenttyping#1}% -% {\executeifdefined{\currenttypingclass#1}\empty}} - \def\typingparameter#1% {\ifcsname\currenttypingclass\currenttyping#1\endcsname \csname\currenttypingclass\currenttyping#1\endcsname @@ -458,49 +469,6 @@ \def\setxtypingparameter#1#2% {\setxvalue{\currenttypingclass\currenttyping#1}{#2}} -% \def\initializetyping -% {%\donefalse -% \switchtobodyfont[\typingparameter\c!bodyfont]% -% \donefalse -% \scratchskip\typingparameter\c!oddmargin\relax -% \ifzeropt\scratchskip\else\donetrue\fi -% \scratchskip\typingparameter\c!evenmargin\relax -% \ifzeropt\scratchskip\else\donetrue\fi -% \ifdone -% \def\doopenupverbatimline -% {\getpagestatus -% \ifrightpage -% \hskip\typingparameter\c!oddmargin\relax -% \else -% \hskip\typingparameter\c!evenmargin\relax -% \fi}% -% \else -% \doadaptleftskip{\typingparameter\c!margin}% -% \fi -% \doifdefinedelse{\??bo\typingparameter\c!blank} -% {\edef\!!stringa{\csname\??bo\typingparameter\c!blank\endcsname}} -% {\edef\!!stringa{\typingparameter\c!blank}}% -% \processaction -% [\!!stringa] -% [ \v!standard=>\scratchskip\ctxparskip, -% \v!small=>\scratchskip\blankokleinmaat, -% \v!medium=>\scratchskip\blankomiddelmaat, -% \v!big=>\scratchskip\blankogrootmaat, -% \v!halfline=>\scratchskip.5\baselineskip, -% \v!line=>\scratchskip\baselineskip, -% \v!none=>\scratchskip\zeropoint, -% \s!unknown=>\scratchskip\commalistelement]% -% \ifgridsnapping -% \ifdim\scratchskip=.5\baselineskip\relax -% \edef\verbatimbaselineskip{\the\scratchskip}% new -% \else -% \edef\verbatimbaselineskip{\the\baselineskip}% -% \fi -% \else -% \edef\verbatimbaselineskip{\the\scratchskip}% -% \fi -% \setupcommonverbatim} - \setvalue{\??tp:\c!blank:\v!standard}{\ctxparskip} \setvalue{\??tp:\c!blank:\v!small }{\blankokleinmaat} \setvalue{\??tp:\c!blank:\v!medium }{\blankomiddelmaat} @@ -545,6 +513,30 @@ %D indirect way. As we will see, they are a specific case of a %D more general mechanism. +\newif\ifoptimizeverbatim \optimizeverbatimtrue + +\let \beginofverbatimlines \relax +\let \endofverbatimlines \relax + +\def\doverbatimnobreak + {\ifoptimizeverbatim\penalty500 \fi} + +\def\doverbatimgoodbreak + {\ifoptimizeverbatim\penalty\linepenalty\fi} + +% \def\doflushverbatimline +% {\expandafter\dodoverbatimline\expandafter{\savedverbatimline}} +% \def\doverbatimbeginofline#1% linenumber (optional provided by mkiv / todo) +% {\dontleavehmode +% \strut +% \the\everyline} +% \def\doverbatimendofline +% {\par} +% \def\doverbatimemptyline +% {\strut +% \par} +% \let\handleverbatimline=\relax + % we need this hack because otherwise verbatim skips % the first line (everything after the initial command) @@ -698,26 +690,6 @@ %D Since we support a global color too, the folowing %D definition is better: -% \def\setupverbatimcolor% fast and local versus slow and global -% {\doifelsenothing{\typingparameter\c!color} -% {\def\beginofpretty[##1]{\startcolormode{\prettypalet:##1}}% -% \let\endofpretty \restorecolormode % \stopcolormode -% \let\startverbatimcolor \relax -% \let\stopverbatimcolor \relax -% \let\verbatimcolor \relax} -% {\def\beginofpretty[##1]{\startcolor[\prettypalet:##1]}% -% \let\endofpretty \stopcolor -% \def\startverbatimcolor{\startcolor[\typingparameter\c!color]}% -% \let\stopverbatimcolor \stopcolor -% \def\verbatimcolor {\getvalue{\typingparameter\c!color}}}% command ! -% \doifelsenothing{\typingparameter\c!palet} -% {\let\prettypalet\empty -% \let\endofpretty\relax -% \def\beginofpretty[##1]{}} -% {\edef\prettypalet{\prettyidentifier\typingparameter\c!palet}}} -% -% let's forget about this optimization not that we have mkiv - \def\setupverbatimcolor {\def\beginofpretty[##1]{\startcolor[\prettypalet:##1]}% \let\endofpretty \stopcolor @@ -735,96 +707,6 @@ \let\stopverbatimcolor \relax \let\verbatimcolor \relax -%D In the verbatim module, there are some examples given of -%D the more obscure features of the verbatim environments. -%D -%D \startbuffer -%D \startTEX -%D \def\mathematics#1% % usage: \type {\mathematics{x^2}} -%D {\ifmmode#1\else$#1$\fi} % becomes: \mathematics{x^2} -%D \stopTEX -%D \stopbuffer -%D -%D \typebuffer -%D -%D This gives, as can be expected: -%D -%D \getbuffer -%D -%D When we want to see some typeset \TEX\ too, we can say: -%D -%D \startbuffer -%D \startTEX -%D \def\mathematics#1% %%\ N usage: \type {\mathematics{x^2}} -%D {\ifmmode#1\else$#1$\fi} %%\ N becomes: \mathematics{x^2} -%D \stopTEX -%D \stopbuffer -%D -%D \typebuffer -%D -%D or: -%D -%D \getbuffer -%D -%D In a similar way: -%D -%D \startbuffer -%D \startSQL -%D select * -- indeed, here we {\em do} select -%D from tableA -%D where 1 = 2 -%D \stopSQL -%D \stopbuffer -%D -%D \typebuffer -%D -%D gives: -%D -%D \getbuffer -%D -%D The next examples sow how we can directly call for natural -%D \TEX\ comments: -%D -%D \startbuffer -%D \setuptyping -%D [TEX] -%D [text=yes] -%D -%D \startTEX -%D \def\mathematics#1% % usage: \type {\mathematics{x^2}} -%D {\ifmmode#1\else$#1$\fi} % becomes: \mathematics{x^2} -%D \stopTEX -%D -%D \setuptyping -%D [SQL] -%D [text=yes,palet=,icommand=\bf,vcommand=,ccommand=\it] -%D -%D \startSQL -%D select * -- indeed, here we {\em do} select -%D from tableA -%D where 1 = 2 -%D \stopSQL -%D -%D \setuptyping -%D [SQL] -%D [ccommand=\tf\underbar] -%D -%D \startSQL -%D select * -- indeed, here we {\em do} select -%D from tableA -%D where 1 = 2 -%D \stopSQL -%D \stopbuffer -%D -%D \typebuffer -%D -%D Now watch: -%D -%D \getbuffer -%D -%D The natural \TEX\ typesetting was introduced when Tobias -%D and Berend started using verbatim \JAVASCRIPT\ and \SQL. - %D \macros %D {EveryPar, EveryLine, iflinepar} %D @@ -968,11 +850,6 @@ \unexpanded\def\filename#1{{\tttf\hyphenatedfilename{#1}}} -%D This leaves some settings: - -\permitshiftedendofverbatim -\optimizeverbatimtrue - %D And a bonus macro: \def\verbatim#1{\defconvertedargument\ascii{#1}\ascii} @@ -1035,14 +912,16 @@ \c!palet=colorpretty, \c!option=\v!normal] +%D Beware: only a few are currently (re)implemented in \MKIV. + \definetyping[RAW] [\c!option=RAW] -\definetyping[MP] [\c!option=MP] +\definetyping[MP] [\c!option=MP] % done \definetyping[PL] [\c!option=PL] \definetyping[PM] [\c!option=PL] \definetyping[JS] [\c!option=JS] \definetyping[JV] [\c!option=JV] \definetyping[SQL] [\c!option=SQL] -\definetyping[TEX] [\c!option=TEX] +\definetyping[TEX] [\c!option=TEX] % done \definetyping[PAS] [\c!option=PAS] \definetyping[PASCAL][\c!option=PAS] \definetyping[MOD] [\c!option=PAS] @@ -1050,7 +929,7 @@ \definetyping[DELPHI][\c!option=PAS] \definetyping[EIFFEL][\c!option=EIF] \definetyping[XML] [\c!option=XML] -\definetyping[LUA] [\c!option=LUA] +\definetyping[LUA] [\c!option=LUA] % done \installprettytype [RAW] [RAW] @@ -1085,15 +964,6 @@ \installprettytype [LUA] [LUA] -\installnewpretty M {\setupprettiesintype {MP}\setupprettytype} -\installnewpretty P {\setupprettiesintype {PL}\setupprettytype} -\installnewpretty T {\setupprettiesintype{TEX}\setupprettytype} -\installnewpretty J {\setupprettiesintype {JV}\setupprettytype} -\installnewpretty S {\setupprettiesintype{SQL}\setupprettytype} -\installnewpretty W {\setupprettiesintype{PAS}\setupprettytype} % Wirth -\installnewpretty I {\setupprettiesintype{EIF}\setupprettytype} % E taken -\installnewpretty X {\setupprettiesintype{XML}\setupprettytype} - %D We use the \CONTEXT\ color system for switching to and from %D color mode. We can always redefine these colors afterwards. diff --git a/tex/context/base/char-act.mkiv b/tex/context/base/char-act.mkiv new file mode 100644 index 000000000..34358784a --- /dev/null +++ b/tex/context/base/char-act.mkiv @@ -0,0 +1,125 @@ +%D \module +%D [ file=char-act, +%D version=2006.12.05, +%D title=\CONTEXT\ Character Support, +%D subtitle=Active, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright=PRAGMA] +%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 Character Support / Active} + +\unprotect + +%D \macros +%D {processingverbatim} +%D +%D Typesetting a file in most cases results in more than one +%D page. Because we don't want problems with files that are +%D read in during the construction of the page, we set \type +%D {\ifprocessingverbatim}, so the output routine can adapt +%D its behavior. Originally we used \type {\scratchread}, but +%D because we want to support nesting, we decided to use a +%D separate input file. + +\newif\ifprocessingverbatim + +%D \macros +%D {obeyedspace, obeyedtab, obeyedline, obeyedpage} +%D +%D We have followed Knuth in naming macros that make \SPACE, +%D \NEWLINE\ and \NEWPAGE\ active and assigning them +%D \type{\obeysomething}, but first we set some default values. + +\def\obeyedspace {\ifprocessingverbatim\hbox{ }\else\space\fi} +\def\obeyedtab {\obeyedspace} +\def\obeyedline {\par} +\def\obeyedpage {\vfill\eject} + +%D \macros +%D {controlspace,setcontrolspaces} +%D +%D First we define \type{\obeyspaces}. When we want visible +%D spaces (control spaces) we only have to adapt the definition +%D of \type{\obeyedspace} to: + +\def\controlspace{\hbox{\char32}} % rather tex +\def\normalspace { } +\def\normalspaces{\catcode`\ =\@@space} + +\bgroup +\catcode`\ =\@@active +\gdef\obeyspaces{\catcode`\ =\@@active\def {\obeyedspace}} +\gdef\setcontrolspaces{\catcode`\ =\@@active\def {\controlspace}} +\egroup + +%D \macros +%D {obeytabs, obeylines, obeypages,ignoretabs, ignorelines, ignorepages} +%D +%D Next we take care of \NEWLINE\ and \NEWPAGE\ and because we +%D want to be able to typeset listings that contain \TAB, we +%D have to handle those too. Because we have to redefine the +%D \NEWPAGE\ character locally, we redefine the meaning of +%D this (often already) active character. + +\catcode`\^^L=\@@active \def^^L{\par} + +%D The following indirect definitions enable us to implement +%D all kind of \type{\obeyed} handlers. + +\bgroup + +\catcode`\^^I=\@@active +\catcode`\^^M=\@@active +\catcode`\^^L=\@@active + +\gdef\obeytabs {\catcode`\^^I=\@@active\def^^I{\obeyedtab}} +\gdef\obeylines {\catcode`\^^M=\@@active\def^^M{\obeyedline}} +\gdef\obeypages {\catcode`\^^L=\@@active\def^^L{\obeyedpage}} + +\gdef\ignoretabs {\catcode`\^^I=\@@active\def^^I{\obeyedspace}} +\gdef\ignorelines {\catcode`\^^M=\@@active\def^^M{\obeyedspace}} +\gdef\ignorepages {\catcode`\^^L=\@@ignore} % \@@active\def^^L{\obeyedline}} +\gdef\ignoreeofs {\catcode`\^^Z=\@@ignore} + +\egroup + +%D \macros +%D {naturaltextext} +%D +%D When one uses \ETEX, switching to normal \TEX\ is possible +%D too. We also introduce a switch that can be used in the +%D drivers and set in higher level shell macros. + +\def\naturaltextext#1\relax + {\bgroup + \def\ascii{#1}% + \setcatcodetable\ctxcatcodes + \prettynaturalfont{\scantextokens\expandafter{\ascii}\ifhmode\unskip\fi}% + \egroup} + +\endinput \protect + +% obsolete (old hack for idris) + +%D This is a hack, and only meant for special situations. We don't +%D support this in for instance verbatim. The active characters map +%D onto the \CONTEXT\ names and font handling etc. is up to the user. + +%D This feature is obsolete. + +\registerctxluafile{char-act}{1.001} + +\def\enableactiveutf {\ctxlua{characters.active.enable()}} +\def\disableactiveutf{\ctxlua{characters.active.disable()}} +\def\testactiveutf #1{\ctxlua{characters.active.test("#1")}} + +%D Usage: +%D +%D \starttyping +%D \enableactiveutf \testactiveutf{eacute} +%D \stoptyping diff --git a/tex/context/base/char-enc.tex b/tex/context/base/char-enc.mkiv index 9fe9a363b..9fe9a363b 100644 --- a/tex/context/base/char-enc.tex +++ b/tex/context/base/char-enc.mkiv diff --git a/tex/context/base/char-ini.tex b/tex/context/base/char-ini.mkiv index b79e44857..b79e44857 100644 --- a/tex/context/base/char-ini.tex +++ b/tex/context/base/char-ini.mkiv diff --git a/tex/context/base/char-utf.tex b/tex/context/base/char-utf.mkiv index d21cd842c..d21cd842c 100644 --- a/tex/context/base/char-utf.tex +++ b/tex/context/base/char-utf.mkiv diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv index cf7f2446a..b2b2b896c 100644 --- a/tex/context/base/colo-ini.mkiv +++ b/tex/context/base/colo-ini.mkiv @@ -119,125 +119,62 @@ \def\definespotcolor {\dotripleargument\dodefinespotcolor} \def\definemultitonecolor{\doquadrupleempty\dodefinemultitonecolor} -% check: registerusedspotcolors -% check: registerusedcolorchannels - %D \macros -%D {doifcolorelse, doifcolor} +%D {startcolor,stopcolor, +%D faststartcolor,faststopcolor, +%D localstartcolor,localstopcolor, +%D localstartraster,localstopraster, +%D startraster,stopraster,raster, +%D color,graycolor} %D -%D Switching to a color is done by means of the following -%D command. Later on we will explain the use of palets. We -%D define ourselves a color conditional first. - -\ifx\doifcolorelse\undefined - \let\doifcolorelse\secondoftwoarguments - \let\doifcolor \gobbleoneargument -\fi - -%D \macros -%D {localstartcolor,localstopcolor} +%D The local and global and raster commands are here just +%D for compatibility with \MKII. %D -%D Simple color support, that is without nesting, is provided -%D by: - -\ifx\localstartcolor\undefined - \let\localstartcolor\undefined - \let\localstopcolor \undefined -\fi - -%D \macros -%D {faststartcolor,faststopcolor} +%D \showsetup{startcolor} %D -%D No checking for arguments and such: - -\ifx\faststartcolor\undefined - \def\faststartcolor[#1]{} - \def\faststopcolor {} -\fi - -%D These local ones may go away in future versions. - %D \macros -%D {startcolor,stopcolor} +%D {color,graycolor} %D -%D The more save method, the one that saves the current color -%D state and returns to this state afterward, is activated by: +%D This leaves the simple color command: %D -%D \showsetup{startcolor} - -\ifx\startcolor\undefined - \let\startcolor\undefined - \let\stopcolor \undefined -\fi - -%D \macros -%D {startcurrentcolor,stopcurrentcolor} - -\def\startcurrentcolor{\startcolor[\outercolorname]} -\def\stopcurrentcolor {\stopcolor} - -%D \macros -%D {color,graycolor} +%D \showsetup{color} +%D \showsetup{graycolor} %D %D This leaves the simple color command: %D %D \showsetup{color} %D \showsetup{graycolor} -\ifx\color\undefined - \def\color [#1]{} - \def\graycolor[#1]{} - \def\gray {\graycolor} -\fi + \def\switchtocolor [#1]{\getvalue{#1}} +\unexpanded\def\color [#1]{\groupedcommand{\doactivatecolor{#1}}{}} +\unexpanded\def\startcolor [#1]{\begingroup\doactivatecolor{#1}} +\unexpanded\def\stopcolor {\endgroup} +\unexpanded\def\graycolor [#1]{\groupedcommand{\setcolormodel{gray}\getvalue{#1}}{}} +\unexpanded\def\colored [#1]{\groupedcommand{\definecolor[@colored@][#1]\doactivatecolor{@colored@}}{}} + \def\predefinecolor [#1]{\flushatshipout{\hbox{\color[#1]{}}}} + \def\predefineindexcolor[#1]{\flushatshipout{\hbox{\color[#1]{}}}} + \def\startcolorpage {\startcolor[\ifx\maintextcolor\empty\defaulttextcolor\else\maintextcolor\fi]} + \def\stopcolorpage {\stopcolor} + \def\startraster [#1]{\dosetrastercolor{#1}} + \def\stopraster {} + \def\raster [#1]{\groupedcommand{\dosetrastercolor{#1}}{}} + \def\faststartcolor [#1]{\doactivatecolor{#1}} + \def\faststopcolor {} +\unexpanded\def\dosetcolorattribute#1#2{\ifcsname#1#2\endcsname\doactivatecolor{\csname#1#2\endcsname}\fi} -%D \macros -%D {localstartraster,localstopraster, -%D startraster,stopraster,raster} -%D -%D The previous conversions are not linear and treat each color -%D component according to human perception curves. Pure gray -%D (we call them rasters) has equal color components. In -%D \CONTEXT\ rasters are only used as backgrounds and these -%D don't cross page boundaries in the way color does. Therefore -%D we don't need stacks and marks. Just to be compatible with -%D color support we offer both 'global' and 'local' commands. - -\ifx\startraster\undefined - \def\startraster [#1]{} - \def\stopraster {} - \def\raster [#1]{} - \def\localstartraster[#1]{} - \def\localstopraster {} -\fi +\let\localstartcolor \startcolor +\let\localstopcolor \stopcolor +\let\globalstartcolor\startcolor +\let\globalstopcolor \stopcolor +\let\localstartraster\startraster +\let\localstopraster \stopraster +\let\grey \graycolor %D \macros -%D {colorvalue, grayvalue} -%D -%D We can typeset the color components using \type{\colorvalue} and -%D \type{\grayvalue}. The commands: -%D -%D \startbuffer -%D color value of SomeKindOfRed: \colorvalue{SomeKindOfRed} \crlf -%D gray value of SomeKindOfRed: \grayvalue{SomeKindOfRed} -%D \stopbuffer -%D -%D \typebuffer -%D -%D show us: -%D -%D \startvoorbeeld -%D \getbuffer -%D \stopvoorbeeld - -\def\colorformatseparator{ } - -\ifx\colorvalue\undefined - \let\colorvalue\gobbleoneargument - \let\grayvalue \gobbleoneargument -\fi +%D {startcurrentcolor,stopcurrentcolor} -% check: \currentcolorname -% check: \outercolorname +\def\startcurrentcolor{\startcolor[\outercolorname]} +\def\stopcurrentcolor {\stopcolor} %D \macros %D {setupcolor} @@ -325,10 +262,6 @@ \setsystemmode{\v!color\colorsplitsuffix}% \iffilterspotcolor \let\@@clrgb\v!no \fi} -\ifx\dosetupcolormodel\undefined - \let\dosetupcolormodel\relax -\fi - \def\dosetupcolors[#1]% some no longer make sense in MkIV {\getparameters[\??cl][#1]% \doifelse\@@clspot\v!yes @@ -394,53 +327,6 @@ \dosetupcolormodel \initializemaintextcolor} -%D \macros -%D {startregistercolor,stopregistercolor,permitcolormode} -%D -%D If you only want to register a color, the switch \type -%D {\ifpermitcolormode} can be used. That way the nested -%D colors know where to go back to. - -\ifx\startregistercolor\undefined - \def\startregistercolor[#1]{} - \def\stopregistercolor {} -\fi - -%D We use these macros for implementing text colors -%D (actually, the first application was in foreground -%D colors). -%D -%D \starttyping -%D \starttextcolor[red] -%D \dorecurse{10}{\input tufte \color[green]{oeps} \par} -%D \stoptextcolor -%D \stoptyping -%D -%D This is more efficient than the alternative: -%D -%D \starttyping -%D \setupbackgrounds[text][foregroundcolor=red] -%D \startregistercolor[red] -%D \dorecurse{10}{\input tufte \color[green]{oeps} \par} -%D \stopregistercolor -%D \stoptyping - -\def\maintextcolor {} -\def\defaulttextcolor {black} -\def\@@themaintextcolor{themaintextcolor} - -\ifx\initializemaintextcolor\undefined - \def\starttextcolor [#1]{} - \def\stoptextcolor {} - \def\initializemaintextcolor {} -\fi - -\ifx\restoretextcolor\undefined % to be redone - \let\restoretextcolor \firstofoneargument - \let\localstarttextcolor\relax - \let\localstoptextcolor \relax -\fi - %D In this documentation we will not go into too much details %D on palets. Curious users can find more information on this %D topic in \from[use of color]. @@ -525,10 +411,6 @@ {\doifdefined{\??pa#2} {\expanded{\dodefinepalet[#1][\csname\??pa\??pa#2\endcsname]}}}} -\ifx\dodefinepaletcolor\undefined - \let\dodefinepaletcolor\gobblethreearguments -\fi - \let\paletsize\!!zerocount \def\getpaletsize[#1]% @@ -947,7 +829,8 @@ \letvalue{(ts:-}\empty \def\doactivatecolor#1% : in currentpalet, maybe not, ugly - {\ifcsname(cs:\currentpalet#1)\endcsname + {\def\currentcolorname{#1}% + \ifcsname(cs:\currentpalet#1)\endcsname \csname(cs:\currentpalet#1)\endcsname \csname(ts:\currentpalet#1)\endcsname \else\ifcsname(cs:#1)\endcsname @@ -970,7 +853,8 @@ \fi} \def\deactivatecolor - {\doresetattribute\s!color + {\let\currentcolorname\s!black + \doresetattribute\s!color \doresetattribute\s!transparency} \def\dodefinecolorcommand#1#2% @@ -1014,6 +898,13 @@ \fi \dosetattribute\s!color{\ctxlua{tex.sprint(ctx.definesimplegray("_raster_",\@@rastervalue))}}} +%D \macros +%D {doifcolorelse, doifcolor} +%D +%D Switching to a color is done by means of the following +%D command. Later on we will explain the use of palets. We +%D define ourselves a color conditional first. + \def\doifcolorelse#1% {\ifcsname(ca:\currentpalet#1)\endcsname \@EA\firstoftwoarguments @@ -1032,33 +923,45 @@ \@EAEAEA\gobbleoneargument \fi\fi} -% currentcolor, then we can push pop in register - - \def\switchtocolor [#1]{\getvalue{#1}} -\unexpanded\def\color [#1]{\groupedcommand{\doactivatecolor{#1}}{}} -\unexpanded\def\startcolor [#1]{\begingroup\doactivatecolor{#1}} -\unexpanded\def\stopcolor {\endgroup} -\unexpanded\def\graycolor [#1]{\groupedcommand{\setcolormodel{gray}\getvalue{#1}}{}} -\unexpanded\def\colored [#1]{\groupedcommand{\definecolor[@colored@][#1]\doactivatecolor{@colored@}}{}} - \def\predefinecolor [#1]{\flushatshipout{\hbox{\color[#1]{}}}} - \def\predefineindexcolor[#1]{\flushatshipout{\hbox{\color[#1]{}}}} - \def\startcolorpage {\startcolor[\ifx\maintextcolor\empty\defaulttextcolor\else\maintextcolor\fi]} - \def\stopcolorpage {\stopcolor} - \def\localstartraster [#1]{\dosetrastercolor{#1}} - \def\localstopraster {} - \def\startraster [#1]{\dosetrastercolor{#1}} - \def\stopraster {} - \def\raster [#1]{\groupedcommand{\dosetrastercolor{#1}}{}} - \def\faststartcolor [#1]{\doactivatecolor{#1}} - \def\faststopcolor {} -\unexpanded\def\dosetcolorattribute#1#2{\ifcsname#1#2\endcsname\doactivatecolor{\csname#1#2\endcsname}\fi} - -% more efficient: +%D \macros +%D {colored} +%D +%D A bit like \type {\definedfont}: \unexpanded\def\colored[#1]% {\ctxlua{ctx.defineprocesscolor("@colored@","#1",false,false)}% \groupedcommand{\doactivatecolor{@colored@}}{}} +%D \macros +%D {startregistercolor,stopregistercolor,permitcolormode} +%D +%D If you only want to register a color, the switch \type +%D {\ifpermitcolormode} can be used. That way the nested +%D colors know where to go back to. +%D +%D We use these macros for implementing text colors +%D (actually, the first application was in foreground +%D colors). +%D +%D \starttyping +%D \starttextcolor[red] +%D \dorecurse{10}{\input tufte \color[green]{oeps} \par} +%D \stoptextcolor +%D \stoptyping +%D +%D This is more efficient than the alternative: +%D +%D \starttyping +%D \setupbackgrounds[text][foregroundcolor=red] +%D \startregistercolor[red] +%D \dorecurse{10}{\input tufte \color[green]{oeps} \par} +%D \stopregistercolor +%D \stoptyping + +\let\maintextcolor \empty +\def\defaulttextcolor {black} +\def\@@themaintextcolor{themaintextcolor} + \def\startregistercolor[#1]% {\doifelsenothing{#1} {\let\stopregistercolor\relax} @@ -1080,25 +983,9 @@ \fi \fi} -% \def\pushpostponedpagecolor -% {\edef\savedtopofpagecolor{\topofpagecolor}% -% \doifsomething\savedtopofpagecolor\restorecolormode} -% -% \def\poppostponedpagecolor -% {\doifsomething\savedtopofpagecolor\doactivatecolor\savedtopofpagecolor} -% -% no \topofpagecolor - \let\pushpostponedpagecolor\relax \let\poppostponedpagecolor \relax -% \def\pushcolor -% {\edef\popcolor -% {\dosetattribute\s!color {\dogetattribute\s!color }% -% \dosetattribute\s!transparency{\dogetattribute\s!transparency}}% -% \let\popsplitcolor\popcolor -% \deactivatecolor} - \appendtoks\deactivatecolor\to\everybeforeoutput % maybe we don't need push pop now \def\startregistercolor[#1]% @@ -1109,12 +996,6 @@ \dosetattribute\s!transparency{\dogetattribute\s!transparency}}% \doactivatecolor{#1}}} -\let\grey \graycolor -\let\localstartcolor \startcolor -\let\localstopcolor \stopcolor -\let\globalstartcolor\startcolor -\let\globalstopcolor \stopcolor - \def\registermaintextcolor{\ctxlua{colors.main = \thecolorattribute\maintextcolor}} \def\starttextcolor[#1]% @@ -1162,10 +1043,31 @@ \def\doinheritta#1{\csname(ta:\ifcsname(ta:\currentpalet#1)\endcsname\currentpalet#1\else\ifcsname(ta:#1)\endcsname#1\fi\fi)\endcsname} \def\doinheritts#1{\csname(ts:\ifcsname(ts:\currentpalet#1)\endcsname\currentpalet#1\else\ifcsname(ts:#1)\endcsname#1\fi\fi)\endcsname} +%D \macros +%D {colorvalue, grayvalue} +%D +%D We can typeset the color components using \type{\colorvalue} and +%D \type{\grayvalue}. The commands: +%D +%D \startbuffer +%D color value of SomeKindOfRed: \colorvalue{SomeKindOfRed} \crlf +%D gray value of SomeKindOfRed: \grayvalue{SomeKindOfRed} +%D \stopbuffer +%D +%D \typebuffer +%D +%D show us: +%D +%D \startvoorbeeld +%D \getbuffer +%D \stopvoorbeeld + +\def\colorformatseparator{ } + \def\MPcolor#1{\ctxlua{tex.sprint(ctx.mpcolor(\number\currentcolormodel,\number\doinheritca{#1},\number\doinheritta{#1}))}} -\def\currentcolorname{\s!black} % todo -\def\outercolorname {\s!black} % todo +\let\currentcolorname\s!black % todo +\let\outercolorname \s!black % todo \def\thecolorattribute #1{\number\csname(ca:\ifcsname(ca:\currentpalet#1)\endcsname\currentpalet#1\else\ifcsname(ca:#1)\endcsname#1\fi\fi)\endcsname} \def\thetransparencyattribute#1{\number\csname(ta:\ifcsname(ta:\currentpalet#1)\endcsname\currentpalet#1\else\ifcsname(ta:#1)\endcsname#1\fi\fi)\endcsname} @@ -1216,7 +1118,9 @@ % % \def\forcecolorhack{\vrule\!!width\zeropoint\!!height\zeropoint\!!depth\zeropoint} -\def\forcecolorhack{\leaders\hrule\hskip\zeropoint} +% \normal added else fails in metafun manual (leaders do a hard scan) + +\unexpanded\def\forcecolorhack{\leaders\hrule\normalhskip\zeropoint} % \setupcolors[state=start] % diff --git a/tex/context/base/cont-log.tex b/tex/context/base/cont-log.tex index 8419394c4..27f3b1134 100644 --- a/tex/context/base/cont-log.tex +++ b/tex/context/base/cont-log.tex @@ -43,12 +43,12 @@ \def\Mkern#1% {{\setbox\scratchbox\hbox{M}\kern#1\wd\scratchbox}} -\def\TeX +\unexpanded\def\TeX {T% \Mkern{-.1667}\lower.5ex\hbox{E}% \Mkern{-.125}X} -\def\ConTeXt +\unexpanded\def\ConTeXt {C% \CMRkern-.0333emo% \CMRkern-.0333emn% @@ -56,10 +56,10 @@ \CMRkern-.0667em\TeX% \CMRkern-.0333emt} -\def\PPCHTeX +\unexpanded\def\PPCHTeX {ppch\TeX} -\def\PRAGMA +\unexpanded\def\PRAGMA {Pragma ADE} %\def\LaTeX @@ -67,7 +67,7 @@ % \kern-.30em\raise.3ex\hbox{\txx A}% % \kern-.18em\TeX} -\def\LaTeX % requested by erik frambach +\unexpanded\def\LaTeX % requested by erik frambach {{\setbox\scratchbox\hbox{L}% \scratchdimen\ht\scratchbox \setbox\scratchbox\hbox{\txx A}% @@ -75,14 +75,14 @@ \raise\scratchdimen\hbox{\lower\ht\scratchbox\copy\scratchbox}% \kern-.2\wd\scratchbox\TeX}} -\def\TaBlE +\unexpanded\def\TaBlE {T% \kern-.27em\lower.5ex\hbox{A}% \kern-.18emB% \kern-.1em\lower.5ex\hbox{L}% \kern-.075emE} -\def\PiCTeX +\unexpanded\def\PiCTeX {P% \kern-.12em\lower.5ex\hbox{I}% \kern-.075em C% @@ -91,20 +91,20 @@ \def\AMSswitch#1% {$\fam2\ifdim\bodyfontsize>1.1em\scriptstyle\fi#1$} -\def\AmSTeX +\unexpanded\def\AmSTeX {\AMSswitch A% \kern-.1667em\lower.5ex\hbox{\AMSswitch M}% \kern-.125em\AMSswitch S% -\TeX} -\def\LamSTeX +\unexpanded\def\LamSTeX {L% \kern-.4em\raise.3ex\hbox{\AMSswitch A}% \kern-.25em\lower.4ex\hbox{\AMSswitch M}% \kern-.1em{\AMSswitch S}% -\TeX} -\def\AmSLaTeX +\unexpanded\def\AmSLaTeX {\AMSswitch A% \kern-.1667em\lower.5ex\hbox{\AMSswitch M}% \kern-.125em\AMSswitch S% @@ -118,7 +118,7 @@ %D %D I changed this into one that adapts itself: -\def\Context +\unexpanded\def\Context {{C\kern -.0667em\getscaledglyph{.8}\empty{O\kern -.0667emN\kern -.0549emT\doifitalicelse{\kern-.1em}{\kern-.1667em}\lower.5ex\hbox {E}\doifitalicelse\empty{\kern-.11em}X\kern-.055emT}}} @@ -198,18 +198,18 @@ %D write all user defined commands, like abbreviations, in %D uppercase.) -\def\METAFONT {\MetaFont} -\def\METAPOST {\MetaPost} -\def\PPCHTEX {\PPCHTeX} -\def\CONTEXT {\ConTeXt} -\def\METAFUN {\MetaFun} +\unexpanded\def\METAFONT {\MetaFont} +\unexpanded\def\METAPOST {\MetaPost} +\unexpanded\def\PPCHTEX {\PPCHTeX} +\unexpanded\def\CONTEXT {\ConTeXt} +\unexpanded\def\METAFUN {\MetaFun} -\def\TEX {\TeX} -\def\LATEX {\LaTeX} -\def\PICTEX {\PiCTeX} -\def\TABLE {\TaBlE} -\def\AMSTEX {\AmSTeX} -\def\LAMSTEX {\LamSTeX} +\unexpanded\def\TEX {\TeX} +\unexpanded\def\LATEX {\LaTeX} +\unexpanded\def\PICTEX {\PiCTeX} +\unexpanded\def\TABLE {\TaBlE} +\unexpanded\def\AMSTEX {\AmSTeX} +\unexpanded\def\LAMSTEX {\LamSTeX} %D And this is how they show up: \TeX, \MetaFont, \MetaPost, %D \PiCTeX, \TaBlE, \ConTeXt, \PPCHTeX, \AmSTeX, \LaTeX, @@ -224,12 +224,12 @@ %D Some placeholders: -\def\eTeX {\mathematics{\varepsilon}-\TeX} -\def\pdfTeX {pdf\TeX} -\def\pdfeTeX {pdfe-\TeX} -\def\luaTeX {lua\TeX} -\def\metaTeX {meta\TeX} -\unexpanded\def\XeTeX {X\lower.5ex\hbox{\kern-.15em\mirror{E}}\kern-.1667em\TeX} +\unexpanded\def\eTeX {\mathematics{\varepsilon}-\TeX} +\unexpanded\def\pdfTeX {pdf\TeX} +\unexpanded\def\pdfeTeX{pdfe-\TeX} +\unexpanded\def\luaTeX {lua\TeX} +\unexpanded\def\metaTeX{meta\TeX} +\unexpanded\def\XeTeX {X\lower.5ex\hbox{\kern-.15em\mirror{E}}\kern-.1667em\TeX} % Better, since lm has a mirrored E (don't ask me why) diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index b8e2a6f95..5886a1f27 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2009.05.28 11:23} +\newcontextversion{2009.06.02 09:30} %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/context.mkii b/tex/context/base/context.mkii index 1a2fa4abb..9b8cb8a99 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -85,11 +85,6 @@ \loadcorefile{supp-ali.tex} \loadcorefile{supp-num.tex} -%D The next module deals with language specific typographic -%D extensions. - -\loadcorefile{typo-ini.tex} - %D Verbatim typesetting is implemented in a separate class of %D modules. The pretty typesetting modules are loaded at run %D time. @@ -173,6 +168,8 @@ \loadcorefile{lang-ara.tex} \loadcorefile{lang-cyr.tex} +\loadmarkfile{typo-ini} + %D All kind of symbols are handled in: \loadcorefile{symb-ini.tex} @@ -187,25 +184,27 @@ \loadmarkfile{core-spa} \loadcorefile{core-grd.tex} -\loadcorefile{core-mar.tex} -\loadmarkfile{core-pos} +\loadmarkfile{strc-mar} +\loadmarkfile{anch-pos} \loadcorefile{core-mak.tex} -\loadcorefile{core-dat.tex} -\loadmarkfile{core-ver} -\loadmarkfile{core-rul} -\loadcorefile{core-vis.tex} -\loadcorefile{core-num.tex} + +\loadmarkfile{buff-ver} +\loadmarkfile{buff-ini} + +\loadmarkfile{pack-rul} +\loadmarkfile{trac-vis} +\loadmarkfile{strc-num} \loadcorefile{tabl-pln.tex} \loadcorefile{tabl-tab.tex} \loadcorefile{tabl-tsp.tex} -\loadmarkfile{core-nav} -\loadcorefile{core-ref.tex} -\loadmarkfile{core-obj} -\loadcorefile{core-lst.tex} -\loadcorefile{core-itm.tex} -\loadcorefile{core-des.tex} -\loadcorefile{core-mat.tex} % should come after math-pln etc -\loadcorefile{core-syn.tex} +\loadmarkfile{scrn-nav} +\loadmarkfile{strc-ref} +\loadmarkfile{pack-obj} +\loadmarkfile{strc-lst} +\loadmarkfile{strc-itm} +\loadmarkfile{strc-des} +\loadmarkfile{strc-mat} % should come after math-pln etc +\loadmarkfile{strc-syn} \loadmarkfile{core-sys} \loadmarkfile{page-ini} @@ -216,13 +215,13 @@ \loadmkiifile{page-log.tex} \loadmarkfile{page-txt} \loadcorefile{page-sid.tex} -\loadcorefile{page-flt.tex} +\loadmarkfile{strc-flt} \loadcorefile{page-mis.tex} \loadcorefile{page-mul.tex} \loadcorefile{page-set.tex} -\loadcorefile{page-lyr.tex} +\loadmarkfile{pack-lyr} \loadcorefile{page-mak.tex} -\loadcorefile{page-num.tex} +\loadmarkfile{strc-pag} \loadmarkfile{page-lin} \loadcorefile{page-par.tex} \loadcorefile{page-mar.tex} @@ -231,13 +230,13 @@ % so far -\loadcorefile{core-sec.tex} -\loadcorefile{core-swd.tex} -\loadmarkfile{core-buf} -\loadcorefile{core-blk.tex} +\loadmarkfile{strc-sec} +\loadmarkfile{strc-swd} +\loadmarkfile{strc-blk} + \loadcorefile{page-imp.tex} \loadcorefile{tabl-tbl.tex} -\loadmarkfile{core-int} +\loadmarkfile{scrn-int} \loadmarkfile{tabl-ntb} \loadcorefile{tabl-nte.tex} \loadcorefile{tabl-ltb.tex} @@ -251,12 +250,12 @@ %D How about fill||in fields and related stuff? \loadmarkfile{java-ini} -\loadmarkfile{core-fld} -\loadcorefile{core-hlp.tex} +\loadmarkfile{scrn-fld} +\loadmarkfile{scrn-hlp} %D Registers can depend on fields, so we load that now. -\loadcorefile{core-reg.tex} +\loadmarkfile{strc-reg} %D Of course we do need fonts. There are no \TFM\ files %D loaded yet, so the format file is independant of their @@ -300,12 +299,11 @@ \loadcorefile{page-plg.tex} \loadcorefile{page-str.tex} -%D Hm. - -\loadcorefile{core-pgr.tex} -\loadcorefile{core-bar.tex} -\loadcorefile{core-snc.tex} +%D Anchoring graphics: +\loadcorefile{anch-pgr.tex} +\loadcorefile{anch-bar.tex} +\loadcorefile{anch-snc.tex} %D Math. @@ -317,17 +315,18 @@ %D Now we're ready for more core modules. \loadmarkfile{core-fnt} -\loadcorefile{core-not.tex} +\loadmarkfile{strc-not} \loadcorefile{core-lnt.tex} \loadmarkfile{core-mis} -\loadcorefile{core-trf.tex} -\loadmarkfile{core-inc} -\loadcorefile{core-fig.tex} +\loadmarkfile{grph-trf} +\loadmarkfile{grph-inc} +\loadmarkfile{grph-fig} + \loadcorefile{core-par.tex} -\loadcorefile{core-box.tex} +\loadmarkfile{pack-box} \loadcorefile{page-app.tex} \loadmarkfile{meta-fig} diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index b3542fb21..163ab803a 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -22,9 +22,9 @@ \loadcorefile{norm-ctx.tex} \loadcorefile{syst-pln.tex} -\loadmkivfile{luat-cod.tex} -\loadmkivfile{luat-bas.tex} -\loadmkivfile{luat-lib.tex} +\loadmarkfile{luat-cod} +\loadmarkfile{luat-bas} +\loadmarkfile{luat-lib} \loadmarkfile{catc-ini} \loadcorefile{catc-act.tex} @@ -34,8 +34,8 @@ \newif\ifCONTEXT \CONTEXTtrue % will disappear -\loadcorefile{syst-aux.tex} -\loadcorefile{syst-lua.tex} +\loadmarkfile{syst-aux} +\loadmarkfile{syst-lua} \loadmarkfile{syst-con} \loadmarkfile{syst-fnt} @@ -45,8 +45,9 @@ \loadmarkfile{supp-fil} \loadmarkfile{supp-dir} -\loadmkivfile{char-ini.tex} -\loadmkivfile{char-utf.tex} +\loadmarkfile{char-ini} +\loadmarkfile{char-utf} +\loadmarkfile{char-act} \loadmarkfile{mult-ini} \loadcorefile{mult-fst.tex} @@ -54,25 +55,25 @@ \loadcorefile{mult-def.tex} \loadmarkfile{mult-chk} -\loadmkivfile{luat-ini.tex} +\loadmarkfile{luat-ini} -\loadmkivfile{toks-ini.tex} +\loadmarkfile{toks-ini} -\loadmkivfile{node-ini.tex} -\loadmkivfile{node-fin.tex} -\loadmkivfile{node-par.tex} +\loadmarkfile{node-ini} +\loadmarkfile{node-fin} +\loadmarkfile{node-par} \loadcorefile{core-var.tex} -\loadcorefile{back-ini.tex} -\loadcorefile{back-pdf.tex} +\loadmarkfile{back-ini} +\loadmarkfile{back-pdf} -\loadmkivfile{attr-ini.tex} +\loadmarkfile{attr-ini} \loadmarkfile{core-env} -\loadmkivfile{trac-lmx.tex} -\loadmkivfile{trac-deb.tex} +\loadmarkfile{trac-lmx} +\loadmarkfile{trac-deb} \loadcorefile{supp-box.tex} @@ -84,9 +85,7 @@ \loadcorefile{supp-ali.tex} \loadcorefile{supp-num.tex} -\loadcorefile{typo-ini.tex} - -\loadcorefile{verb-ini.tex} +\loadmarkfile{typo-ini} \loadcorefile{core-ins.tex} \loadcorefile{core-fil.tex} @@ -110,14 +109,11 @@ \loadmarkfile{core-two} \loadcorefile{core-stg.tex} -% \loadcorefile{spec-ini.tex} -% \loadcorefile{spec-mis.tex} -% \loadcorefile{spec-def.tex} -% \loadcorefile{spec-var.tex} - \loadmarkfile{colo-ini} \loadmarkfile{colo-ext} +\loadmarkfile{trac-vis} + \loadcorefile{lang-mis.tex} \loadmarkfile{lang-url} @@ -141,41 +137,39 @@ \loadmarkfile{sort-ini} -\loadmarkfile{core-rul} +\loadmarkfile{pack-rul} \loadcorefile{lxml-ini} -\loadcorefile{strc-ini} -\loadcorefile{strc-doc} -\loadcorefile{strc-mar} -\loadcorefile{strc-prc} -\loadcorefile{strc-sbe} -\loadcorefile{strc-lst} -\loadcorefile{strc-sec} -\loadcorefile{strc-num} -\loadcorefile{strc-ren} -\loadcorefile{strc-xml} -\loadcorefile{strc-pag} % hm, depends on core-num -\loadcorefile{strc-def} % might happen later -\loadcorefile{strc-ref} -\loadcorefile{strc-reg} +\loadmarkfile{strc-ini} +\loadmarkfile{strc-doc} +\loadmarkfile{strc-mar} +\loadmarkfile{strc-prc} +\loadmarkfile{strc-sbe} +\loadmarkfile{strc-lst} +\loadmarkfile{strc-sec} +\loadmarkfile{strc-num} +\loadmarkfile{strc-ren} +\loadmarkfile{strc-xml} +\loadmarkfile{strc-pag} % hm, depends on core-num +\loadmarkfile{strc-def} % might happen later +\loadmarkfile{strc-ref} +\loadmarkfile{strc-reg} \loadcorefile{bibl-bib} \loadmarkfile{core-spa} \loadcorefile{core-grd.tex} -\loadmarkfile{core-pos} +\loadmarkfile{anch-pos} \loadcorefile{core-mak.tex} -\loadmarkfile{core-ver} -\loadcorefile{core-vis.tex} -\loadmarkfile{core-nav} -\loadmarkfile{core-obj} +\loadmarkfile{scrn-nav} +\loadmarkfile{pack-obj} -\loadcorefile{strc-itm.tex} -\loadcorefile{strc-des.tex} -\loadcorefile{strc-syn.tex} +\loadmarkfile{strc-itm} +\loadmarkfile{strc-des} +\loadmarkfile{strc-syn} \loadmarkfile{core-sys} @@ -187,12 +181,12 @@ \loadmarkfile{page-txt} \loadcorefile{page-sid.tex} -\loadcorefile{strc-flt.tex} +\loadmarkfile{strc-flt} \loadcorefile{page-mis.tex} \loadcorefile{page-mul.tex} \loadcorefile{page-set.tex} -\loadcorefile{page-lyr.tex} +\loadmarkfile{pack-lyr} \loadcorefile{page-mak.tex} \loadmarkfile{page-lin} @@ -201,14 +195,15 @@ \loadmarkfile{core-job} % why so late? -\loadmarkfile{core-buf} +\loadmarkfile{buff-ini} +\loadmarkfile{buff-ver} -\loadcorefile{strc-blk.tex} +\loadmarkfile{strc-blk} \loadcorefile{page-imp.tex} -\loadmarkfile{core-int} -\loadcorefile{strc-bkm.tex} % bookmarks +\loadmarkfile{scrn-int} +\loadmarkfile{strc-bkm} % bookmarks \loadcorefile{tabl-pln.tex} \loadcorefile{thrd-tab.tex} @@ -220,34 +215,35 @@ \loadcorefile{tabl-tsp.tex} \loadmarkfile{java-ini} -\loadmarkfile{core-fld} -\loadcorefile{core-hlp.tex} -\loadcorefile{char-enc.tex} +\loadmarkfile{scrn-fld} +\loadmarkfile{scrn-hlp} + +\loadmarkfile{char-enc} \loadmarkfile{font-ini} \loadmarkfile{font-unk} \loadmarkfile{font-tra} \loadmarkfile{font-uni} \loadmarkfile{font-col} -\loadcorefile{typo-spa.tex} -\loadcorefile{typo-krn.tex} -\loadcorefile{typo-mir.tex} -\loadcorefile{typo-brk.tex} -\loadcorefile{typo-cap.tex} +\loadmarkfile{typo-spa} +\loadmarkfile{typo-krn} +\loadmarkfile{typo-mir} +\loadmarkfile{typo-brk} +\loadmarkfile{typo-cap} \loadmarkfile{type-ini} \loadcorefile{type-def.tex} -\loadcorefile{scrp-ini.tex} +\loadmarkfile{scrp-ini} \loadmarkfile{prop-ini} \loadmarkfile{prop-lay} \loadmarkfile{prop-mis} -\loadmkivfile{mlib-ctx.tex} -\loadmkivfile{mlib-pdf.tex} -\loadmkivfile{mlib-pps.tex} +\loadmarkfile{mlib-ctx} +\loadmarkfile{mlib-pdf} +\loadmarkfile{mlib-pps} \loadmarkfile{meta-ini} \loadmarkfile{meta-tex} @@ -260,9 +256,9 @@ \loadcorefile{page-plg.tex} \loadcorefile{page-str.tex} -\loadcorefile{core-pgr.tex} -\loadcorefile{core-bar.tex} -\loadcorefile{core-snc.tex} +\loadcorefile{anch-pgr.tex} +\loadcorefile{anch-bar.tex} +\loadcorefile{anch-snc.tex} \loadmarkfile{math-pln} \loadmarkfile{math-ini} @@ -277,24 +273,24 @@ \loadmarkfile{math-inl} \loadmarkfile{math-dis} -\loadcorefile{strc-mat.tex} +\loadmarkfile{strc-mat} \loadmarkfile{chem-ini} \loadmarkfile{chem-str} \loadmarkfile{core-fnt} -\loadcorefile{strc-not.tex} +\loadmarkfile{strc-not} \loadcorefile{core-lnt.tex} \loadmarkfile{core-mis} -\loadcorefile{core-trf.tex} -\loadmarkfile{core-inc} -\loadcorefile{core-fig.tex} +\loadmarkfile{grph-trf} +\loadmarkfile{grph-inc} +\loadmarkfile{grph-fig} -\loadcorefile{core-box.tex} +\loadmarkfile{pack-box} \loadcorefile{page-app.tex} \loadmarkfile{meta-fig} @@ -311,7 +307,7 @@ \loadcorefile{cont-log.tex} -\loadcorefile{task-ini.tex} +\loadmarkfile{task-ini} \loadmarkfile{core-ctx} @@ -345,6 +341,4 @@ }% \to \everydump -\setsystemmode{experimental} % test with *experimental - \protect \errorstopmode \dump \endinput diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index 08ffc3a60..fa9866a71 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2009.05.28 11:23} +\edef\contextversion{2009.06.02 09:30} %D For those who want to use this: diff --git a/tex/context/base/core-spa.mkiv b/tex/context/base/core-spa.mkiv index dfb84da53..8dba73ac1 100644 --- a/tex/context/base/core-spa.mkiv +++ b/tex/context/base/core-spa.mkiv @@ -691,7 +691,7 @@ \dosetupblank\appliedblankskip }%\let\deblanko\v!big} -\def\dodefineblank[#1][#2]% +\def\dodefineblank[#1][#2]% why #1 commalist? {\def\docommand##1{\setvalue{\??bo##1}{#2}}% \processcommalist[#1]\docommand} diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua index 113f90470..d23a8a080 100644 --- a/tex/context/base/font-otn.lua +++ b/tex/context/base/font-otn.lua @@ -1897,7 +1897,7 @@ function fonts.methods.node.otf.features(head,font,attr) end ra[s] = r end -featurevalue = r and r[1] -- toto: pass to function instead + featurevalue = r and r[1] -- todo: pass to function instead of using a global if featurevalue then local attribute, chain, typ, subtables = r[2], r[3], sequence.type, sequence.subtables if chain < 0 then diff --git a/tex/context/base/core-fig.tex b/tex/context/base/grph-fig.mkii index 63aa1d193..c7f990af2 100644 --- a/tex/context/base/core-fig.tex +++ b/tex/context/base/grph-fig.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-fig, +%D [ file=grph-fig, %D version=2006.08.26, % overhaul of 1997.03.31 -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Graphic Macros, %D subtitle=Figure Inclusion, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Figure Handling} +\writestatus{loading}{ConTeXt Graphic Macros / Figure Handling} \unprotect diff --git a/tex/context/base/grph-fig.mkiv b/tex/context/base/grph-fig.mkiv new file mode 100644 index 000000000..c7f990af2 --- /dev/null +++ b/tex/context/base/grph-fig.mkiv @@ -0,0 +1,559 @@ +%D \module +%D [ file=grph-fig, +%D version=2006.08.26, % overhaul of 1997.03.31 +%D title=\CONTEXT\ Graphic Macros, +%D subtitle=Figure Inclusion, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%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 Graphic Macros / Figure Handling} + +\unprotect + +\def\setupexternalfigures + {\dosingleempty\dosetupexternalfigures} + +\def\dosetupexternalfigures[#1]% + {\getparameters[\??ef][#1]% local settings + \getparameters[\??ex][#1]% global settings + \setfigurepathlist} % the path may be used elsewhere too (as in x-res-04) + +\presetlocalframed[\??ef] + +\newconditional\externalfigurelevel % true=background false=normal +\newconditional\externalfigureflush % true=place false=ignore + +\setfalse\externalfigurelevel +\settrue \externalfigureflush + +\def\doplaceexternalfigure[#1][#2][#3][#4][#5]% + {\doifsomething{#2}% catches \defineexternalfigure dummies + {\doifundefinedelse{\??ef\??ef#2} + {\dodoplaceexternalfigure[#1][#2][#3][#4][#5]} + {\doifelse{#1}{#2} + {\dodoplaceexternalfigure[#1][#2][#3][#4][#5]} + {\getvalue{\??ef\??ef#2}[#5]}}}} + +\def\dodoplaceexternalfigure[#1][#2][#3][#4][#5]% + {\bgroup + \pushmacro\textunderscore + \edef\textunderscore{\string_}% brrr, temp hack, still needed? + \calculateexternalfigure [][#1][#2][#3][#4][#5]% [] is dummy dwcomp + \calculateexternalscreenfigure[][#1][#2][#3][#4][#5]% [] is dummy dwcomp + \popmacro\textunderscore + \box\foundexternalfigure + \egroup} + +\def\externalfigurereplacement#1#2#3% + {\setupcolors + [\c!state=\v!local]% + \expanded{\localframed + [\??ef] + [\c!width=\figurewidth, + \c!height=\figureheight, + \c!background=\v!screen, + \c!backgroundscreen=.8, + \c!frame=\@@efframe]}% + {\tt\tfxx \nohyphens + name: \expanded{\verbatimstring{#1}}\\% + file: \expanded{\verbatimstring{#2}}\\% + state: \expanded{\verbatimstring{#3}}}} + +\def\externalfigureplaceholder#1#2#3% + {\localframed + [\??ef] + [\c!width=#2, + \c!height=#3, + \c!frame=\v!on]% + {\tt\tfxx \nohyphens + name: \expanded{\verbatimstring{#1}}\\% + state: \expanded{\verbatimstring{placeholder}}}} + +% new: more convenient/efficient than +% +% \use..[a][a][setting] \externalfigure[b][a] +% +% is equivalent to: +% +% \def..[a][setting] \externalfigure[b][a] +% +% see x-res modules for usage: +% +% \defineexternalfigure[name][settings] + +\def\defineexternalfigure + {\dodoubleargument\dodefineexternalfigure} + +\def\dodefineexternalfigure[#1][#2]% + {\setvalue{\??ef\??ef#1}{\doplaceexternalfigure[#1][][][#2]}} + +\def\getexternalfigure#1% efef has 4 args already and take an 5th + {\wait} % OBSOLETE + +% \useexternalfigure[alpha][koe] +% \useexternalfigure[beta] [koe] [breedte=1cm] +% \useexternalfigure[gamma][koe][alpha] +% \useexternalfigure[delta][koe][alpha][breedte=2cm] +% +% volle breedte: \externalfigure[koe] \par +% 3cm breed: \externalfigure[koe] [breedte=3cm] \par +% volle breedte: \externalfigure[alpha] \par +% 1cm breed: \externalfigure[beta] \par +% volle breedte: \externalfigure[gamma] \par +% 2cm breed: \externalfigure[delta] \par +% 4cm breed: \externalfigure[beta] [breedte=4cm] \par +% 5cm breed: \externalfigure[gamma][breedte=5cm] \par + +% \defineexternalfigure[a][width=10cm] +% \defineexternalfigure[b][width=5cm] +% \externalfigure[cow][a] +% \externalfigure[cow][b][height=8cm] + +% \useexternalfigure[x][cow][width=10cm,height=1cm] +% \externalfigure[x] +% \externalfigure[x][width=3cm] + +\def\useexternalfigure + {\doquadrupleempty\douseexternalfigure} + +% [label] [filename] +% [label] [filename] [parent] +% [label] [filename] [parent] [settings] +% [label] [filename] [settings] + +\def\useexternalfigure + {\doquadrupleempty\douseexternalfigure} + +\def\douseexternalfigure[#1][#2][#3][#4]% + {\doifelsenothing{#1} + {\doifsomething{#2} + {\doifassignmentelse{#3} + {\setvalue{\??ef\??ef#2}{\doplaceexternalfigure[#2][#2][#3][#4]}} + {\setvalue{\??ef\??ef#2}{\doplaceexternalfigure[#2][#2][][#4]}}}} + {\doifelsenothing{#2} + {\doifassignmentelse{#3} + {\setvalue{\??ef\??ef#1}{\doplaceexternalfigure[#1][#1][][#3]}} + {\setvalue{\??ef\??ef#1}{\doplaceexternalfigure[#1][#1][#3][#4]}}} + {\doifassignmentelse{#3} + {\setvalue{\??ef\??ef#1}{\doplaceexternalfigure[#1][#2][][#3]}} + {\setvalue{\??ef\??ef#1}{\doplaceexternalfigure[#1][#2][#3][#4]}}}}} + +\def\dosetefparameters#1#2#3% parent_id use_settings current_settings + {\doifelsenothing{#1} % inherit from parent + {\getparameters[\??ef][#2,#3]} + {\doifdefinedelse{\??ef\??ef#1} + {\pushmacro\doplaceexternalfigure + \def\doplaceexternalfigure[##1][##2][##3][##4]{\getparameters[\??ef][##4,#2,#3]}% + \getvalue{\??ef\??ef#1}% + \popmacro\doplaceexternalfigure} + {\getparameters[\??ef][#2,#3]}}} + +\unexpanded\def\externalfigure + {\dotripleempty\doexternalfigure} + +\def\doexternalfigure[#1][#2][#3]% [label][file][settings] | [file][settings] | [file][parent][settings] + {\bgroup + \doifelsenothing{#1} + {\framed[\c!width=\defaultfigurewidth,\c!height=\defaultfigureheight]{external\\figure\\no name}} + {\doifundefinedelse{\??ef\??ef#1} + {\useexternalfigure[\s!dummy][#1][#2][#3]% + \getvalue{\??ef\??ef\s!dummy}[]} % [] is dummy arg 5 + {\doifassignmentelse{#2} + {\getvalue{\??ef\??ef#1}[#2]}% + {\getvalue{\??ef\??ef#1}[#3]}}}% + \globallet\currentresourcecomment\empty + \egroup} + +\long\def\resourcecomment#1% + {\long\gdef\currentresourcecomment{#1}} + +\long\def\startresourcecomment#1\stopresourcecomment + {\long\gdef\currentresourcecomment{#1}} + +\let\currentresourcecomment\empty + +\def\showexternalfigures % maybe run time command is better, but no core-run, unless figs-run ... + {%\writestatus\m!systems{for \string\showexternalfigures\space see \truefilename{x-res-20}.tex} + \usemodule[res-20]\showexternalfigures} % so for the moment we do it this way + +\def\overlayfigure#1% + {\externalfigure[#1][\c!width=\overlaywidth,\c!height=\overlayheight]} + +%D Still undocumented! No one uses it I think, better be done with layers. + +\newcount\efreference +\newdimen\efxsteps +\newdimen\efysteps + +\def\calculateefsteps + {\ifnum0\@@exxmax=\zerocount + \ifnum0\@@exymax=\zerocount + \def\@@exymax{24}% + \fi + \efysteps\figureheight \divide\efysteps \@@exymax + \efxsteps\efysteps + \dimen0=\figurewidth + \advance\dimen0 \efysteps + \divide \dimen0 \efysteps + \edef\@@exxmax{\number\dimen0}% + \else + \efxsteps\figurewidth \divide\efxsteps \@@exxmax + \efysteps\figureheight \divide\efysteps \@@exymax + \fi} + +\def\efcomment#1(#2,#3)#4(#5,#6)% {kader}(x,y)(h,b)[...]{tekst} + {\def\complexefdocomment[##1]##2% + {\position(#2,#3)% + {\setnostrut + \framed + [\c!width=#5\efxsteps, + \c!height=#6\exysteps, + \c!offset=\v!none, + \c!frame=#1, + ##1]% + {##2}}}% + \complexorsimpleempty\efdocomment} + +\def\efnocomment(#1,#2)#3(#4,#5)% (x,y)(h,b)[...]{tekst} + {\def\complexefdonocomment[##1]##2{}% + \complexorsimpleempty\efdonocomment} + +\def\efdomarker(#1,#2)#3#4% (h,b){kader}{tekst} + {\framed + [\c!width=#1\efxsteps, + \c!height=#2\efysteps, + \c!offset=\v!none, + \c!frame=#3]% + {#4}} + +\def\effigure#1% + {\position(0,0){\getvalue{#1}}} + +\def\efdoarea(#1,#2)#3#4% (h,b){kader}{tekst} + {\bgroup + \setnostrut + \framed + [\c!width=#1\efxsteps, + \c!height=#2\efysteps, + \c!offset=\!!zeropoint, + \c!frame=#3] + {#4}% + \egroup} + +\def\efgoto(#1,#2)#3[#4]% (h,b)kader[ref] + {\setbox0=\vbox{\efdoarea(#1,#2)#3{}}% + \gotobox{\copy0}[#4]} + +\def\efmark(#1,#2)#3(#4,#5)#6[#7]% + {\advance\efreference \plusone + \position(#1,#2) + {\hbox{\the\efreference}}% + \position(#1,#2) + {\gotosomeinternal\s!vwb{#7}\realfolio + {\efdomarker(#4,#5)\v!on{\thisissomeinternal\s!vwa{#7}}}}} + +\def\eftext#1(#2,#3)#4(#5,#6)#7[#8]% + {\advance\efreference \plusone + \hbox + {\quad + \thisissomeinternal\s!vwb{#8}% + \gotosomeinternal \s!vwa{#8}\realfolio + {\hbox to 1.5em{\the\efreference\presetgoto\hfill}}% + \quad#1 (#2,#3) (#5,#6) [#8]\hfill}% + \endgraf} + +\def\efthisis(#1,#2)#3[#4]% + {\efdoarea(#1,#2){#3}{\pagereference[#4]}} + +\newbox\colorbarbox + +\def\makecolorbar[#1]% + {\def\docommand##1% + {\color[##1] + {\blackrule + [\c!width=2em, + \c!height=1ex, + \c!depth=\!!zeropoint]}% + \endgraf}% + \global\setbox\colorbarbox\vbox + {\forgetall + \processcommalist[#1]\docommand}% + \global\setbox\colorbarbox\vbox + {\hskip2em\box\colorbarbox}% + \global\wd\colorbarbox\zeropoint} + +\def\placestartfigure[#1][#2][#3]#4\placestopfigure[#5]% + {\hbox + {\setbox0\hbox + {\useexternalfigure[\s!dummy][#2][#3,#5]% + \externalfigure[\s!dummy]}% + \calculateefsteps + \startpositioning + \def\referring(##1,##2)##3(##4,##5)##6[##7]% + {\position(##1,##2){\efgoto(##4,##5){\@@exframes}[##7]}}% + \def\marking(##1,##2)##3(##4,##5)##6[##7]% + {\position(##1,##2){\efthisis(##4,##5){\@@exframes}[##7]}}% + \def\remark{\efnocomment}% + \def\colorbar##1[##2]{}% + \position(0,0){\box0}% + \linewidth\onepoint + \setuppositioning + [\c!unit=pt, + \c!xscale=\withoutpt\the\efxsteps, + \c!yscale=\withoutpt\the\efysteps, + \c!factor=1]% + \ignorespaces#4% + \def\referring(##1,##2)##3(##4,##5)##6[##7]% + {}% + \let\marking\referring + \def\remark{\efcomment\v!no}% + \def\colorbar##1[##2]{\makecolorbar[##2]}% + \ignorespaces#4% + \stoppositioning + \box\colorbarbox}} + +\def\dodostartfigure[#1][#2][#3]#4\stopfigure + {\doifelse\v!test\@@exoption + {\teststartfigure[#1][#2][#3]#4\teststopfigure + \let\@@exframes\v!on} + {\let\@@exframes\v!off}% + \setvalue{\??ef\??ef#1}% + {\dosingleempty{\placestartfigure[#1][#2][#3]#4\placestopfigure}}% + }% no longer \doifundefined{#1}{\setvalue{#1}{\getexternalfigure{#1}}}} + +% De onderstaande macro mag niet zondermeer worden aangepast +% en is afgestemd op gebruik in de handleiding. + +\def\teststartfigure[#1][#2][#3]#4\teststopfigure% + {\begingroup + \setbox0\hbox + {\useexternalfigure[\s!dummy][#2][\c!wfactor=\v!max]% + \externalfigure[\s!dummy]}% + \def\referring{\efmark}% + \def\marking{\efmark}% + \def\remark{\efcomment\v!yes}% + \def\colorbar##1[##2]{}% + \efreference\zerocount + \setbox0\vbox + {\hsize240pt + \startpositioning + \calculateefsteps + \position(0,0) + {\box0}% + \position(0,0) + {\basegrid + [\c!nx=\@@exxmax, + \c!dx=\withoutpt\the\efxsteps, + \c!ny=\@@exymax, + \c!dy=\withoutpt\the\efysteps, + \c!xstep=1, + \c!ystep=1, + \c!scale=1, + \c!offset=\v!no, + \c!unit=pt]}% + \setuppositioning + [\c!unit=pt, + \c!xscale=\withoutpt\the\efxsteps, + \c!yscale=\withoutpt\the\efysteps, + \c!factor=1]% + \linewidth\onepoint + \ignorespaces#4\relax + \stoppositioning + \vfill}% + \efreference\zerocount + \def\referring{\eftext{$\rightarrow$}}% + \def\marking{\eftext{$\leftarrow$}}% + \def\remark{\efnocomment}% + \def\colorbar##1[##2]{}% + \setbox2\vbox + {{\tfa\doifelsenothing{#1}{#2}{#1}} + \blank + \tfxx#4 + \vfilll}% + \ifdim\ht0>\ht2 + \ht2\ht0 + \else + \ht0\ht2 + \fi + \hbox + {\hskip3em + \vtop{\vskip12pt\box0\vskip6pt}% + \vtop{\vskip12pt\box2\vskip6pt}}% + \endgroup} + +\def\dodostartfigure[#1][#2][#3]#4\stopfigure + {\doifelse\v!test\@@exoption + {\teststartfigure[#1][#2][#3]#4\teststopfigure + \let\@@exframe\v!on} + {\let\@@exframe\v!off}% + \setvalue{\??ef\??ef#1}% + {\def\next{\placestartfigure[#1][#2][#3]#4\placestopfigure}% + \dosingleempty\next}% + }% no longer: \doifundefined{#1}{\setvalue{#1}{\getexternalfigure{#1}}}} + +\long\def\dostartfigure#1% + {\dotripleargument\dodostartfigure#1\stopfigure} + +\def\startfigure + {\grabuntil{\e!stop\v!figure}\dostartfigure} + +%D defining sound tracks: +%D +%D \starttyping +%D \useexternalsoundtrack[label][file] +%D \stoptyping +%D +%D associated actions: StartSound StopSound PauseSound ResumeSound +%D +%D Todo: like external figures, also search on path, +%D although, they need to be present ar viewing time, so ... + +\def\useexternalsoundtrack + {\dodoubleargument\douseexternalsoundtrack} + +\def\douseexternalsoundtrack[#1][#2]% + {\setgvalue{\??sd:#1}{#2}} + +\def\checksoundtrack#1% + {\iflocation + \doifdefined{\??sd:#1}{\doifvaluesomething{\??sd:#1} + {\doinsertsoundtrack{\getvalue{\??sd:#1}}{#1}\@@sdoption + % brr, \..empty not really needed and maybe even wrong; + % also, not here but in driver + % well, no: sounds need to be reinitialize each time (i.e., be on page), so no + }}% \letgvalueempty{\??sd:#1}}}% + \fi} + +\setexecutecommandcheck {startsound} \checksoundtrack + +\def\setupexternalsoundtracks + {\dodoubleargument\getparameters[\??sd]} + +\setupexternalsoundtracks + [\c!option=] + +%D NEW: used in styledesign manual + +% \setbuffer[typeset-b]\endbuffer +% \setbuffer[typeset-a]\endbuffer +% +% todo: +% +% \appendtoks \setbuffer[typeset-b]\endbuffer\to \everystarttext +% \appendtoks \setbuffer[typeset-a]\endbuffer\to \everystarttext + +\def\typesetbuffer + {\dodoubleempty\dotypesetbuffer} + +\newcounter\noftypesetbuffers % all loaded at the end + +\defineexternalfigure + [typeset] + [\c!background=\v!color, + \c!backgroundcolor=\s!white] + +\def\dotypesetbuffer[#1][#2]% beware: this will mix up the mp graphics + {\bgroup + \def\TEXbufferfile##1{\bufferprefix##1.tex}% + \expanded{\setbuffer[typeset]% + \def\noexpand\bufferprefix{\ifprotectbuffers\jobname-\fi typeset-}}% + \starttext + \getbuffer[b,#1,a]% + \stoptext + \endbuffer + \doglobal\increment\noftypesetbuffers + % batch is needed + \executesystemcommand{texmfstart texexec --batch --pdf --result=\bufferprefix typeset-\noftypesetbuffers\space \bufferprefix typeset.tex}% + %\externalfigure[\bufferprefix typeset-\noftypesetbuffers.pdf][\c!object=\v!no,#2]% + \externalfigure[\bufferprefix typeset-\noftypesetbuffers.pdf][#2]% + \egroup} + +% for me only (manuals and such) + +\definesystemvariable{tz} + +\def\definetypesetting{\dotripleempty\dodefinetypesetting} +\def\typesetfile {\dotripleempty\dotypesetfile} + +\def\dodefinetypesetting[#1][#2][#3]% + {\doifsomething{#1}{\setvalue{\??tz#1}{\dodotypesetfile{#2}{#3}}}} + +\def\dotypesetfile[#1][#2][#3]% + {\executeifdefined{\??tz#1}\gobbletwoarguments{#2}{#3}} + +\def\dodotypesetfile#1#2#3#4% args settings file settings + {\doifmode{*\v!first}{\executesystemcommand{texmfstart texexec.pl --batch --pdf #1 #3}}% + \doglobal\beforesplitstring#3\at.\to\typesetfilename + \externalfigure[\typesetfilename.pdf][#2,#4]} + +\setupexternalfigures + [\c!option=, + \c!object=\v!yes, % we only check for no + \c!reset=\v!no, + \c!maxwidth=\@@efwidth, + \c!maxheight=\@@efheight, + \c!bodyfont=\bodyfontsize, + \c!directory=, + \c!file=\f!utilityfilename.\f!figureextension, + \c!radius=.5\bodyfontsize, + \c!corner=\v!rectangular, + \c!frame=\v!off, + \c!background=, % new + \c!splitcolor=\s!white, + \c!conversion=, + \c!prefix=, + \c!cache=, +% \c!grid=, + \c!equalwidth=, + \c!equalheight=, + \c!location={\v!local,\v!global}] + +\setupexternalfigures + [\c!frames=\v!off, + \c!ymax=24, + \c!xmax=] + +\useexternalfigure + [buffer] [\jobname] [\c!type=\v!buffer,\c!object=\v!no] + +\protect \endinput + +% alternative for positioning + +% \definelayer[figure][width=\overlaywidth,height=\overlayheight] +% \defineoverlay[figure][{\directsetup{figure}\tightlayer[figure]}] + +% \setupcolors[state=start] + +% \starttext + +% \startsetups figure +% \setlayerframed[figure][preset=rightbottom,x=.25\layerwidth,y=.25\layerheight]{HERE} +% \setlayerframed[figure][preset=leftbottom, x=.15\layerwidth,y=.35\layerheight]{THERE} +% \stopsetups + +% \externalfigure[cow][background={foreground,figure},width=4cm,height=8cm] + +% \startsetups figure +% \setlayerframed[figure][preset=righttop,x=.25\layerwidth,y=.25\layerheight]{MORE} +% \setlayerframed[figure][preset=middle,foregroundcolor=green]{EVEN MORE} +% \stopsetups + +% \externalfigure[cow][background={foreground,figure},width=14cm,height=2cm] + +% \defineexternalfigure[whatever][background={foreground,figure}] + +% \startsetups figure +% \setlayerframed[figure][preset=righttop,x=.25\layerwidth,y=.25\layerheight]{\red MORE} +% \setlayerframed[figure][preset=middle,foregroundcolor=green]{EVEN MORE} +% \stopsetups + +% \externalfigure[cow][whatever][width=14cm,height=4cm] + +% \stoptext + diff --git a/tex/context/base/core-inc.lua b/tex/context/base/grph-inc.lua index 35370058d..2729389eb 100644 --- a/tex/context/base/core-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -1,6 +1,6 @@ -if not modules then modules = { } end modules ['core-inc'] = { +if not modules then modules = { } end modules ['grph-inc'] = { version = 1.001, - comment = "companion to core-inc.tex", + comment = "companion to grph-inc.tex", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" diff --git a/tex/context/base/core-inc.mkii b/tex/context/base/grph-inc.mkii index ce97a0d1b..231ce902e 100644 --- a/tex/context/base/core-inc.mkii +++ b/tex/context/base/grph-inc.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-inc, % moved from core-fig +%D [ file=grph-inc, % moved from core-fig %D version=2006.08.26, % overhaul of 1997.03.31 -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Graphic Macros, %D subtitle=Figure Inclusion, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Figure Inclusion} +\writestatus{loading}{ConTeXt Graphic Macros / Figure Inclusion} % todo: directory : system -> \allinputpaths (so that we can \usesubpath) @@ -32,20 +32,6 @@ \unprotect -% messages moved - -% messages moved - -% messages moved - -% messages moved - -% messages moved - -% messages moved - -% messages moved - %D Due to the mere fact that \DVI|/|\PDF\ drivers differ in their %D needs for figure dimensions, we have to provide the width, %D height, horizontal and vertical scale. Also we want to @@ -1073,42 +1059,6 @@ \expanded{\doifinset{\v!default}{\@@exlocation}} {\appendtocommalist\defaultfigurepathsignal\figurepathlist}} -% \def\analyzefigurefilename#1#2% -% {\sanitizefilename#1\to\expandedfigurename -% \expanded{\checkfilename{\expandedfigurename}}% -% \ifcase\kindoffile -% \splitfigurefilename -% \ifcase\splitoffkind -% \let\wantedfigurepath\empty % no . either -% \setfigurepathlist -% \setfalse\figurefileisqualified -% \else -% \splitfigurefilename -% \let\figurepathlist\wantedfigurepath -% \let\wantedfigurepath\empty -% \settrue\figurefileisqualified -% \fi -% \else % fully qualified -% \splitfigurefilename -% \let\figurepathlist\wantedfigurepath -% \let\wantedfigurepath\empty -% \settrue\figurefileisqualified -% \fi -% \ifx\figurepathlist\empty -% \let\figurepathlist\defaultfigurepathsignal % will prepend no path -% \fi -% \doifelsenothing\wantedfiguretype -% {\doifparentfileelse\wantedfigurename -% {\@EA\removefromcommalist\@EA{\jobsuffix }\wantedfiguretypelist -% \@EA\removefromcommalist\@EA{\jobfilesuffix}\wantedfiguretypelist} -% {}} -% {\let\wantedfiguretypelist\empty -% \let\wantedfiguretypespec\wantedfiguretype}% -% \edef\wantedfigurelabel{#2}% -% \doshowfigurestate{type check : \ifx\wantedfiguretypelist\empty forced type \wantedfiguretypespec\else\wantedfiguretypelist\fi}% -% \doshowfigurestate{file specs : \wantedfigurefull\space [\wantedfigurepath] [\wantedfigurename] [\wantedfiguretype]}% -% \doshowfigurestate{file type : \ifconditional\figurefileisqualified qualified\else simple\fi}} - % The combined path and qualified path hack is dedicated to Onno Tomson, % our partner in fighting inconsistent and faulty image specifications in % user files. diff --git a/tex/context/base/core-inc.mkiv b/tex/context/base/grph-inc.mkiv index 06c8dc306..e55e9698a 100644 --- a/tex/context/base/core-inc.mkiv +++ b/tex/context/base/grph-inc.mkiv @@ -1,7 +1,7 @@ %D \module -%D [ file=core-inc, % moved from core-fig +%D [ file=grph-inc, % moved from core-fig %D version=2006.08.26, % overhaul of 1997.03.31 -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Graphic Macros, %D subtitle=Figure Inclusion, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Figure Inclusion} +\writestatus{loading}{ConTeXt Graphic Macros / Figure Inclusion} %D todo: %D @@ -20,7 +20,7 @@ %D - alternative images %D - a few more obscure things -\registerctxluafile{core-inc}{1.001} +\registerctxluafile{grph-inc}{1.001} \unprotect diff --git a/tex/context/base/core-trf.tex b/tex/context/base/grph-trf.mkii index c7fa8d42b..798a9b0b4 100644 --- a/tex/context/base/core-trf.tex +++ b/tex/context/base/grph-trf.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-fig, +%D [ file=grph-fig, %D version=2006.08.26, % overhaul/split of 1997.03.31 core-fig -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Graphic Macros, %D subtitle=Transformations, %D author=Hans Hagen, %D date=\currentdate, @@ -14,7 +14,7 @@ %D It may be that some functionality got lost. If it concerns %D defined features, let me know and it will be sorted out. -\writestatus{loading}{ConTeXt Core Macros / Transformations} +\writestatus{loading}{ConTeXt Graphic Macros / Transformations} \unprotect diff --git a/tex/context/base/grph-trf.mkiv b/tex/context/base/grph-trf.mkiv new file mode 100644 index 000000000..798a9b0b4 --- /dev/null +++ b/tex/context/base/grph-trf.mkiv @@ -0,0 +1,577 @@ +%D \module +%D [ file=grph-fig, +%D version=2006.08.26, % overhaul/split of 1997.03.31 core-fig +%D title=\CONTEXT\ Graphic Macros, +%D subtitle=Transformations, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D It may be that some functionality got lost. If it concerns +%D defined features, let me know and it will be sorted out. + +\writestatus{loading}{ConTeXt Graphic Macros / Transformations} + +\unprotect + +%D Scaling: + +\unexpanded\def\scale{\dodoubleempty\doscalenextbox[\??xy]} + +% probably too many dimens / the width calculations can go +% since we may assume scaling is available (was not true +% long ago which is why we also calculate the width) + +\newdimen\scaleboxwidth +\newdimen\scaleboxheight +\newdimen\scaleboxdepth + +\newdimen\scaleboxsizex +\newdimen\scaleboxsizey +\newdimen\scaleboxoffsetx +\newdimen\scaleboxoffsety + +\newdimen\scaleboxhsize +\newdimen\scaleboxvsize + +% global + +\newdimen\scaleboxdimx \let\figwid \scaleboxdimx +\newdimen\scaleboxdimy \let\fighei \scaleboxdimy +\newcount\scaleboxscax \let\figxsca\scaleboxscax +\newcount\scaleboxscay \let\figysca\scaleboxscay + +\newdimen\scaleboxoutervsize % we cannot manipulate any global vsize ! + +\let\finalscaleboxxscale \!!plusone +\let\finalscaleboxyscale \!!plusone +\let\finalscaleboxwidth \!!zeropoint +\let\finalscaleboxheight \!!zeropoint +\let\finalscaleboxxfactor\!!hundred +\let\finalscaleboxyfactor\!!hundred + +\newconditional\scaleboxdone + +\def\doscalenextbox[#1][#2]% + {\bgroup + \getparameters + [#1] + [\c!scale=,\c!xscale=,\c!yscale=,\c!width=,\c!height=,\c!lines=, + \c!factor=,\c!hfactor=,\c!wfactor=,\c!grid=,\c!sx=1,\c!sy=1, + \c!equalwidth=,\c!equalheight=, + \c!maxwidth=\scaleparameter\c!width,\c!maxheight=\scaleparameter\c!height, + #2]% + \dowithnextbox{\dodoscalenextbox{#1}\egroup}\hbox} + +\def\doscalebox#1% + {\bgroup\dowithnextbox{\dodoscalenextbox{#1}\egroup}\hbox} + +\let\currentscaletag\??xy + +\def\scaleparameter#1% + {\csname\currentscaletag#1\endcsname} + +\def\setscaleparameter#1#2% + {\setvalue{\currentscaletag#1}{#2}} + +\def\dodoscalenextbox#1% + {\edef\currentscaletag{#1}% + \doif{\scaleparameter\c!depth}\v!no{\setbox\nextbox\hbox{\raise\nextboxdp\box\nextbox}}% new + \forgetall + \dontshowcomposition + \dontcomplain + \doscaleboxcalculations + \doscaleboxindeed + \doscaleboxposition + \flushnextbox} + +\def\doscaleboxindeed + {\ifconditional\scaleboxdone + \scaleboxwidth \finalscaleboxxscale\nextboxwd + \scaleboxheight\finalscaleboxyscale\nextboxht + \scaleboxdepth \finalscaleboxyscale\nextboxdp + \setbox\nextbox\hbox + {\dostartscaling \finalscaleboxxscale \finalscaleboxyscale + \smashedbox\nextbox + \dostopscaling}% + \nextboxwd\scaleboxwidth + \nextboxht\scaleboxheight + \nextboxdp\scaleboxdepth + \fi} + +\def\doscaleboxcalculations + {\setfalse\scaleboxdone + % initial final value + \global\let\finalscaleboxxscale \!!plusone + \global\let\finalscaleboxyscale \!!plusone + \xdef \finalscaleboxwidth {\the\nextboxwd}% + \xdef \finalscaleboxheight{\the\nextboxht}% + \global\let\finalscaleboxxfactor\!!hundred + \global\let\finalscaleboxyfactor\!!hundred + \ifdim\nextboxht>\zeropoint \ifdim\nextboxwd>\zeropoint + \edef\scaleboxstampa % slow way [can be combined] + {\scaleparameter\c!scale \scaleparameter\c!xscale \scaleparameter\c!yscale + \scaleparameter\c!factor\scaleparameter\c!wfactor\scaleparameter\c!hfactor + \scaleparameter\c!lines \scaleparameter\c!width \scaleparameter\c!height}% + \edef\scaleboxstampb % fast way [just sx/sy] + {\scaleparameter\c!sx + \scaleparameter\c!sy}% + \edef\scaleboxstampc + {11}% + \ifx\scaleboxstampa\empty + \ifx\scaleboxstampb\scaleboxstampc + % no scaling, but still check; new, gone again +% wrong: scaled proportionally as side effect +% \doifsomething{\scaleparameter\c!maxwidth }{\letvalue{\currentscaletag\c!factor}\v!fit}% +% \doifsomething{\scaleparameter\c!maxheight}{\letvalue{\currentscaletag\c!factor}\v!fit}% + \insidefloattrue % trick + \dodoscaleboxcalculations + \else + \dosetscalboxsxsy + \nodoscaleboxcalculations + \fi + \else + \ifx\scaleboxstampb\empty + % no need to check further + \else + \dosetscalboxsxsy + \fi + \dodoscaleboxcalculations + \fi + \fi \fi} + +\def\dosetscalboxsxsy + {\ifdim\scaleparameter\c!sx\onepoint=\onepoint\else + \setevalue{\currentscaletag\c!width }{\the\dimexpr\scaleparameter\c!sx\wd\nextbox\relax}% + \fi + \ifdim\scaleparameter\c!sy\onepoint=\onepoint\else + \setevalue{\currentscaletag\c!height}{\the\dimexpr\scaleparameter\c!sy\ht\nextbox\relax}% + \fi} + +\def\doscaleboxrounding#1.#2\relax{#1} + +\def\scaleboxrounding#1% + {\@EA\@EA\@EA\doscaleboxrounding\@EA\WITHOUTPT\the\dimexpr#1\points*100+32768sp\relax.\relax} + +\def\nodoscaleboxcalculations + {\settrue\scaleboxdone + \xdef\finalscaleboxwidth {\the\dimexpr\scaleparameter\c!sx\wd\nextbox\relax}% + \xdef\finalscaleboxheight {\the\dimexpr\scaleparameter\c!sy\ht\nextbox\relax}% + \xdef\finalscaleboxxscale {\scaleparameter\c!sx}% + \xdef\finalscaleboxyscale {\scaleparameter\c!sy}% + \ifx\finalscaleboxxscale\empty\let\finalscaleboxxscale\!!plusone\fi + \ifx\finalscaleboxyscale\empty\let\finalscaleboxyscale\!!plusone\fi + \xdef\finalscaleboxxfactor{\scaleboxrounding\finalscaleboxxscale}% + \xdef\finalscaleboxyfactor{\scaleboxrounding\finalscaleboxyscale}} + +\def\dodoscaleboxcalculations + {\settrue\scaleboxdone + % initial values + \scaleboxoffsetx\zeropoint + \scaleboxoffsety\zeropoint + \scaleboxsizex \nextboxwd + \scaleboxsizey \nextboxht % alleen ht wordt geschaald! + % final values + \global\scaleboxdimx \zeropoint % see note * (core-fig) + \global\scaleboxdimy \zeropoint % see note * (core-fig) + \scaleboxscax \plusone % see note * (core-fig) + \scaleboxscay \plusone % see note * (core-fig) + % preparations + \setfalse\scaleboxscalingdone + \checkscaleboxsettings + % calculators + % beware, they operate in sequence, and calculate missing dimensions / messy + %setscaleboxbynature % when? needed? + \ifconditional\scaleboxscalingdone\else\setscaleboxbyfactor \fi + \ifconditional\scaleboxscalingdone\else\setscaleboxbyscale \fi + \ifconditional\scaleboxscalingdone\else\setscaleboxbydimension\fi + % finalizers / to be done (no longer needed this way, clean up) + \convertscaleboxinsertscale\scaleboxhsize\figx\scaleboxscax\scax + \convertscaleboxinsertscale\scaleboxvsize\figy\scaleboxscay\scay + % used in actual scaling + \xdef\finalscaleboxwidth {\the\scaleboxdimx}% + \xdef\finalscaleboxheight {\the\scaleboxdimy}% + \xdef\finalscaleboxxfactor{\the\scaleboxscax}% + \xdef\finalscaleboxyfactor{\the\scaleboxscay}% + \xdef\finalscaleboxxscale {\withoutpt\the\dimexpr\scax\points/\plushundred\relax}% + \xdef\finalscaleboxyscale {\withoutpt\the\dimexpr\scay\points/\plushundred\relax}} + + +\setvalue{\??xy:\c!grid:\v!yes }{\getnoflines \fighei\setevalue{\currentscaletag\c!height}{\the\noflines\lineheight}} +\setvalue{\??xy:\c!grid:\v!height }{\getrawnoflines\fighei\setevalue{\currentscaletag\c!height}{\the\dimexpr\noflines\lineheight+\strutdepth\relax}} +\setvalue{\??xy:\c!grid:\v!depth }{\getrawnoflines\fighei\setevalue{\currentscaletag\c!height}{\the\dimexpr\noflines\lineheight-\strutdepth\relax}} +\setvalue{\??xy:\c!grid:\v!halfline}{\getrawnoflines\fighei\setevalue{\currentscaletag\c!height}{\the\dimexpr\noflines\lineheight+.5\lineheight\relax}} +\setvalue{\??xy:\c!grid:\v!fit }{\getrawnoflines\fighei\setevalue{\currentscaletag\c!height}{\the\noflines\lineheight}} +\letvalue{\??xy:\c!grid:\empty }\donothing + +\def\checkscaleboxsettings + {\doifsomething{\scaleparameter\c!maxwidth }% can be defined in itself + {\setevalue{\currentscaletag\c!maxwidth }{\the\dimexpr\scaleparameter\c!maxwidth \relax}}% + \doifsomething{\scaleparameter\c!maxheight}% can be defined in itself + {\setevalue{\currentscaletag\c!maxheight}{\the\dimexpr\scaleparameter\c!maxheight\relax}}% + \doifsomething{\scaleparameter\c!lines} + {\setevalue{\currentscaletag\c!height}{\the\dimexpr\scaleparameter\c!lines\lineheight\relax}}% + \getvalue{\??xy:\c!grid:\scaleparameter\c!grid}} + +\def\setscaleboxbynature % where ! ! ! ! ! + {\doifsomething{\scaleparameter\c!width }{\global\scaleboxdimx\scaleparameter\c!width }% + \doifsomething{\scaleparameter\c!height}{\global\scaleboxdimy\scaleparameter\c!height}% + \doifsomething{\scaleparameter\c!scale } {\scaleboxscax\scaleparameter\c!scale + \scaleboxscay\scaleparameter\c!scale }% + \doifsomething{\scaleparameter\c!xscale} {\scaleboxscax\scaleparameter\c!xscale}% + \doifsomething{\scaleparameter\c!yscale} {\scaleboxscay\scaleparameter\c!yscale}} % oeps, was x + +% \defineexternalfigure[width-6][factor=auto,maxwidth=\textheight,maxheight=\textwidth] +% \defineexternalfigure[width-7][factor=auto,maxwidth=\textwidth,maxheight=\textheight] +% \placefigure{none}{\rotate[frame=on,offset=overlay]{\externalfigure[t:/sources/cow.pdf][width-6]}} \page +% \placefigure{none}{\framed[frame=on,offset=overlay]{\externalfigure[t:/sources/cow.pdf][width-7]}} + +\def\setscaleboxbyfactor + {\doifinsetelse{\scaleparameter\c!factor}{\v!max,\v!fit,\v!broad,\v!auto} + {\doapplyscaleboxsize + \ifdim\scaleboxsizex>\scaleboxsizey + \docalculatescaleboxnorm \scaleboxdimx\c!factor\c!maxwidth\hsize\scaleboxhsize + \docalculatescaleboxscales\scaleboxdimx\scaleboxsizex\scaleboxdimy\scaleboxsizey + \else + \docalculatescaleboxnorm \scaleboxdimy\c!factor\c!maxheight\scaleboxoutervsize\scaleboxvsize + \docalculatescaleboxscales\scaleboxdimy\scaleboxsizey\scaleboxdimx\scaleboxsizex + \fi + \donetrue} + {\doifinsetelse{\scaleparameter\c!hfactor}{\v!max,\v!fit,\v!broad,\v!auto} + {\doapplyscaleboxsize + \docalculatescaleboxnorm \scaleboxdimy\c!hfactor\c!maxheight\scaleboxoutervsize\scaleboxvsize + \docalculatescaleboxscales\scaleboxdimy\scaleboxsizey\scaleboxdimx\scaleboxsizex + \donetrue} + {\doifinsetelse{\scaleparameter\c!wfactor}{\v!max,\v!fit,\v!broad,\v!auto} + {\doapplyscaleboxsize + \docalculatescaleboxnorm \scaleboxdimx\c!wfactor\c!maxwidth\hsize\scaleboxhsize + \docalculatescaleboxscales\scaleboxdimx\scaleboxsizex\scaleboxdimy\scaleboxsizey + \donetrue} + {\docalculatescaleboxnorm\scaleboxdimy\c!factor \c!height \textheight\scaleboxvsize + \docalculatescaleboxnorm\scaleboxdimy\c!hfactor\c!height \textheight\scaleboxvsize + \docalculatescaleboxnorm\scaleboxdimx\c!wfactor\c!width \hsize \hsize + \donefalse}}}% + \ifdone + \settrue\scaleboxscalingdone + \ifdim\scaleboxdimx>\scaleboxhsize + \global\scaleboxdimy\zeropoint \global\scaleboxdimx\scaleboxhsize + \else\ifdim\scaleboxdimy>\scaleboxvsize + \global\scaleboxdimx\zeropoint \global\scaleboxdimy\scaleboxvsize + \fi\fi + \fi} + +\def\setscaleboxbyscale + {\doifsomething{\scaleparameter\c!scale\scaleparameter\c!xscale\scaleparameter\c!yscale} + {\doapplyscaleboxscale\scaleboxdimx\scaleboxsizex\scaleboxscax\c!xscale + \doapplyscaleboxscale\scaleboxdimy\scaleboxsizey\scaleboxscay\c!yscale + \global\scaleboxdimx\zeropoint + \global\scaleboxdimy\zeropoint + \doifelsenothing{\scaleparameter\c!maxwidth} + {\doifsomething{\scaleparameter\c!maxheight} + {\ifdim\scaleboxsizey>\scaleparameter\c!maxheight\relax + \global\scaleboxdimy\scaleparameter\c!maxheight + \fi}} + {\ifdim\scaleboxsizex>\scaleparameter\c!maxwidth\relax + \global\scaleboxdimx\scaleparameter\c!maxwidth + \fi}}} + +\def\setscaleboxbydimension + {\ifdim\scaleboxdimx>\zeropoint + \ifdim\scaleboxdimy>\zeropoint + \dosetdimensionscaleboxsize + {\docalculatescaleboxscale\scaleboxdimy\scaleboxsizey\scaleboxscay + \docalculatescaleboxscale\scaleboxdimx\scaleboxsizex\scaleboxscax}% + {\docalculatescaleboxscale\scaleboxdimy\scaleboxsizey\scaleboxscay + \docalculatescaleboxscale\scaleboxdimx\scaleboxsizex\scaleboxscax}% + {\docalculatescaleboxscale\scaleboxdimy\scaleboxsizey\scaleboxscay + \docalculatescaleboxscale\scaleboxdimx\scaleboxsizex\scaleboxscax}% + \else + \dosetdimensionscaleboxsize + {\docalculatescaleboxscales\scaleboxdimx\scaleboxsizex\scaleboxdimy\scaleboxsizey}% + {\docalculatescaleboxscales\scaleboxdimx\scaleboxsizex\scaleboxdimy\scaleboxsizey}% + {\docalculatescaleboxscales\scaleboxdimx\scaleboxsizex\scaleboxdimy\scaleboxsizey}% + \fi + \else + \ifdim\scaleboxdimy>\zeropoint + \dosetdimensionscaleboxsize + {\docalculatescaleboxscales\scaleboxdimy\scaleboxsizey\scaleboxdimx\scaleboxsizex}% + {\docalculatescaleboxscales\scaleboxdimy\scaleboxsizey\scaleboxdimx\scaleboxsizex}% + {\docalculatescaleboxscales\scaleboxdimy\scaleboxsizey\scaleboxdimx\scaleboxsizex}% + \else + \dosetdimensionscaleboxsize + {\doapplyscaleboxscale\scaleboxdimx\scaleboxsizex\scaleboxscax\c!xscale + \doapplyscaleboxscale\scaleboxdimy\scaleboxsizey\scaleboxscay\c!yscale}% + {\docalculatescaleboxscales\scaleboxdimx\scaleboxsizex\scaleboxdimy\scaleboxsizey}% + {\docalculatescaleboxscales\scaleboxdimy\scaleboxsizey\scaleboxdimx\scaleboxsizex}% + \fi + \fi} + +\def\dosetdimensionscaleboxsize#1#2#3% + {#1\relax + \doifsomething{\scaleparameter\c!maxwidth} + {\ifdim\scaleboxdimx>\scaleparameter\c!maxwidth\relax + \global\scaleboxdimx\scaleparameter\c!maxwidth + #2\relax + \fi}% + \doifsomething{\scaleparameter\c!maxheight} + {\ifdim\scaleboxdimy>\scaleparameter\c!maxheight\relax + \global\scaleboxdimy\scaleparameter\c!maxheight + #3\relax + \fi}} + +\def\docalculatescaleboxnorm#1#2#3#4#5% 2 3 parameters (dodo:speedup) + {\processaction + [\scaleparameter#2] + [ \v!max=>\global#1\dimexpr#4\relax, + \v!fit=>\global#1\dimexpr#5\relax, + \v!broad=>\global#1\dimexpr#5-4\@@exbodyfont\relax, + \v!auto=>\doifsomething{\scaleparameter#3}{\global#1\dimexpr\scaleparameter#3\relax}, + \s!default=>\doifsomething{\scaleparameter#3}{\global#1\dimexpr\scaleparameter#3\relax}, + \s!unknown=>\global#1\dimexpr\scaleparameter#2\dimexpr\@@exbodyfont/10\relax\relax]} + +\def\docalculatescaleboxscales#1#2#3#4% + {\scratchdimen\dimexpr#1/\dimexpr#2/\plusthousand\relax\relax + \scaleboxscax\scratchdimen + \scaleboxscay\scratchdimen + #3\dimexpr\scaleboxscax\dimexpr#4/\plusthousand\relax\relax} + +\def\docalculatescaleboxscale#1#2#3% + {#3\dimexpr#1/\dimexpr#2/\plusthousand\relax\relax} + +\def\doapplyscaleboxscale#1#2#3#4% $4 = parameter / scale can be empty + {\ifcase0\scaleparameter#4\relax + \ifcase0\scaleparameter\c!scale\relax + #3=\plusthousand + \else + #3=\scaleparameter\c!scale + \fi + \else + #3=\scaleparameter#4% + \fi + \relax % important ! still ? + \global#1\ifnum#3=\plusthousand#2\else\dimexpr#3\dimexpr#2/\plusthousand\relax\relax\fi + \relax} + +\def\doapplyscaleboxsize + {\doifelsenothing{\scaleparameter\c!maxheight} + {\scaleboxoutervsize\textheight + \ifinner + \scaleboxoutervsize \vsize % \textheight =\vsize + \scratchdimen\vsize % \scratchdimen=\textheight + \else\ifinsidefloat + \scaleboxoutervsize \vsize % \textheight =\vsize + \scratchdimen\vsize % \scratchdimen=\textheight + \else\ifinpagebody + \scaleboxoutervsize \vsize % \textheight =\vsize + \scratchdimen\vsize % \scratchdimen=\textheight + \else % hm, there should be an option to force this + \ifdim\pagegoal<\maxdimen + \ifdim\pagetotal<\pagegoal + \scratchdimen\pagegoal + \advance\scratchdimen -\pagetotal + \else + \scratchdimen\scaleboxoutervsize % \textheight + \fi + \else + \scratchdimen\scaleboxoutervsize % \textheight + \fi + \fi\fi\fi} + {\scaleboxoutervsize\scaleparameter\c!maxheight}% + \doifelsenothing{\scaleparameter\c!height} + {\scaleboxvsize\scratchdimen} + {\scaleboxvsize\scaleparameter\c!height}% + \doifelsenothing{\scaleparameter\c!width} + {\scaleboxhsize\hsize} + {\scaleboxhsize\scaleparameter\c!width}} + +\def\convertscaleboxinsertscale#1#2#3#4% + {\scratchdimen#1\relax + \ifnum#3=\plusthousand + % == scale 1 + \else + % better 1000 100 10 ranges, evt round 2sp + \divide\scratchdimen \plusthousand + \multiply\scratchdimen #3\relax + \fi + \scratchdimen-\scratchdimen % beter hier - dan in driver + \edef#2{\the\scratchdimen}% + \scratchcounter#3\relax + \ifnum\scratchcounter>\plustenthousand + \divide\scratchcounter\!!ten \scratchdimen\the\scratchcounter\points + \else + \scratchdimen\the\scratchcounter\points \divide\scratchdimen\!!ten + \fi + \edef#4{\withoutpt\the\scratchdimen}} + +% \startcombination +% {\externalfigure[cow.pdf] [frame=on,height=3cm,equalwidth=6cm]} {} +% {\externalfigure[mill.png][frame=on,height=3cm,equalwidth=6cm]} {} +% \stopcombination + +\def\doscaleboxposition + {\doifsomething{\scaleparameter\c!equalwidth} + {\scratchdimen\scaleparameter\c!equalwidth\relax + \ifdim\wd\nextbox<\scratchdimen + \setbox\nextbox\hbox to \scratchdimen{\hss\box\nextbox\hss}% + \fi}% + \doifsomething{\scaleparameter\c!equalheight} + {\scratchdimen\scaleparameter\c!equalheight\relax + \ifdim\ht\nextbox<\scratchdimen + \setbox\nextbox\vbox to \scratchdimen{\vss\box\nextbox\vss}% + \fi}} + +%D \macros +%D {clip, setupclipping} +%D +%D Although related to figures, clipping can be applied to +%D arbitrary content. We can use \METAPOST\ to provide a non +%D rectangular clipping path. +%D +%D \starttyping +%D \startMPclip{fun} +%D clip currentpicture to fullcircle +%D shifted (.5,.5) xscaled \width yscaled \height ; +%D \stopMPclip +%D \stoptyping +%D +%D We get a rectangular piece of the figure when we say: +%D +%D \starttyping +%D \clip[x=2,y=1]{\externalfigure[photo]} +%D \stoptyping +%D +%D When we want to clip to the oval we defined a few lines ago, +%D we say: +%D +%D \starttyping +%D \clip[nx=1,ny=1,x=1,y=1,mp=fun]{\externalfigure[photo]} +%D \stoptyping +%D +%D The general characteristics of clipping can be set up with +%D +%D \showsetup{setupclipping} + +\def\setupclipping + {\dodoubleargument\getparameters[\??cp]} + +\def\clip + {\dosingleempty\doclip} + +\def\doclip[#1]% nb top->bottom left->right + {\bgroup + \getparameters[\??cp][#1]% + \doifelse\@@cpstate\v!start\dodoclip{\egroup\hbox}} + +\def\dodoclip + {\dowithnextbox + {\ifdim\@@cpwidth>\zeropoint + \!!dimena\@@cpwidth + \!!dimenc\@@cphoffset + \else + \!!dimena\nextboxwd + \divide\!!dimena \@@cpnx + \!!dimenc\@@cpx\!!dimena + \advance\!!dimenc -\!!dimena + \!!dimena\@@cpsx\!!dimena + \fi + \relax % sure + \ifdim\@@cpheight>\zeropoint + \!!dimenb\@@cpheight + \!!dimend\nextboxht + \advance\!!dimend -\@@cpvoffset + \advance\!!dimend -\!!dimenb + \else + \!!dimenb\nextboxht + \divide\!!dimenb \@@cpny + \!!dimend-\@@cpy\!!dimenb + \advance\!!dimend -\@@cpsy\!!dimenb + \advance\!!dimend \!!dimenb + \!!dimenb\@@cpsy\!!dimenb + \advance\!!dimend \nextboxht % dimend ! + \fi + \setbox\nextbox\hbox % old + {\advance\!!dimenc -\@@cpleftoffset % new ! + \advance\!!dimend -\@@cpbottomoffset % new ! % - added + \hskip-\!!dimenc\lower\!!dimend\flushnextbox}% old + \nextboxwd\zeropoint + \nextboxht\zeropoint + \nextboxdp\zeropoint + \setbox\nextbox\hbox + {\advance\!!dimena \@@cpleftoffset % new ! + \advance\!!dimena \@@cprightoffset % new ! + \advance\!!dimenb \@@cpbottomoffset % new ! + \advance\!!dimenb \@@cptopoffset % new ! + \dostartclipping\@@cpmp\!!dimena\!!dimenb % old + \flushnextbox + \dostopclipping}% + \setbox\nextbox\hbox % new ! + {\!!dimena-\@@cpleftoffset % new ! + \!!dimenb \@@cpbottomoffset % new ! % - removed + \hskip\!!dimena\lower\!!dimenb\flushnextbox}% new ! + \nextboxwd\!!dimena + \nextboxht\!!dimenb + \nextboxdp\zeropoint + \flushnextbox + \egroup}% + \hbox} + +\setupclipping + [\c!state=\v!start, + \c!n=1, % was 2 + \c!nx=\@@cpn,\c!x=1,\c!sx=1, + \c!ny=\@@cpn,\c!y=1,\c!sy=1, + \c!width=\!!zeropoint, + \c!height=\!!zeropoint, + \c!hoffset=\!!zeropoint, + \c!voffset=\!!zeropoint, + \c!offset=\zeropoint, + \c!leftoffset=\@@cpoffset, % \zeropoint, + \c!rightoffset=\@@cpoffset, % \zeropoint, + \c!topoffset=\@@cpoffset, % \zeropoint, + \c!bottomoffset=\@@cpoffset,% \zeropoint, + \c!mp=] + +%D \startbuffer +%D \startuseMPgraphic{test} +%D path p ; p := fullcircle scaled 4cm ; +%D draw p withpen pencircle scaled 1cm ; +%D setbounds currentpicture to boundingbox p ; +%D \stopuseMPgraphic +%D +%D \hbox to \hsize \bgroup +%D \hss +%D \ruledhbox{\useMPgraphic{test}}% +%D \hss +%D \ruledhbox{\clip{\useMPgraphic{test}}}% +%D \hss +%D \egroup +%D \stopbuffer +%D +%D \typebuffer \getbuffer + +%D Mirroring. + +\def\domirrorbox % \hbox/\vbox/\vtop + {\bgroup + \dowithnextbox + {\dontshowcomposition + \scratchdimen\nextboxwd + % better use an hbox (if no \forgetall, leftskip etc may creep in) + %\setbox\nextbox\vbox{\forgetall\dostartmirroring\hskip-\nextboxwd\flushnextbox\dostopmirroring}% + \setbox\nextbox\hbox{\dostartmirroring\hskip-\nextboxwd\flushnextbox\dostopmirroring}% + \nextboxwd\scratchdimen + \flushnextbox + \egroup}} + +\unexpanded\def\mirror + {\domirrorbox\hbox} + +% \setbox0=\hbox{gans} +% \ruledhbox{\copy0 \schaal[sx=2,sy=2]{\copy0}} +% \mirror{\ruledhbox{\copy0 \schaal{\box0}}} + +\protect \endinput diff --git a/tex/context/base/luat-bas.tex b/tex/context/base/luat-bas.mkiv index a78455173..a78455173 100644 --- a/tex/context/base/luat-bas.tex +++ b/tex/context/base/luat-bas.mkiv diff --git a/tex/context/base/luat-cod.tex b/tex/context/base/luat-cod.mkiv index 07db36483..07db36483 100644 --- a/tex/context/base/luat-cod.tex +++ b/tex/context/base/luat-cod.mkiv diff --git a/tex/context/base/luat-ini.tex b/tex/context/base/luat-ini.mkiv index 265f1b643..265f1b643 100644 --- a/tex/context/base/luat-ini.tex +++ b/tex/context/base/luat-ini.mkiv diff --git a/tex/context/base/luat-lib.tex b/tex/context/base/luat-lib.mkiv index ec781f3cf..ec781f3cf 100644 --- a/tex/context/base/luat-lib.tex +++ b/tex/context/base/luat-lib.mkiv diff --git a/tex/context/base/core-dat.tex b/tex/context/base/m-datastrc.tex index 44a82e1f3..4a6faa66b 100644 --- a/tex/context/base/core-dat.tex +++ b/tex/context/base/m-datastrc.tex @@ -1,7 +1,7 @@ %D \module -%D [ file=core-dat, % was core-02a, +%D [ file=m-datastrc, % was: core-dat % was core-02a %D version=1999.08.10, % 1997.03.31, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Modules, %D subtitle=Database Support, % 2A %D author=Hans Hagen, %D date=\currentdate, @@ -11,28 +11,8 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -% THIS WILL DISAPPEAR, I.E. BE MOVED TO A MODULE - \writestatus{loading}{ConTeXt Core Macros / Database Support} -% messages moved - -% messages moved - -% messages moved - -% TOM : - -% messages moved - -% messages moved - -% messages moved - -% messages moved - -% messages moved - \unprotect %D This module is a (limited) rewrite of the original \type @@ -242,7 +222,7 @@ %D character can be non standard|>| this is not faster. %D %D Although this mechanism could have been combined with the -%D block moving mechaism, the current implementation is +%D block moving mechanism, the current implementation is %D prefered out of speed reasons. \protect \endinput diff --git a/tex/context/base/meta-fig.mkiv b/tex/context/base/meta-fig.mkiv index c2c2e127f..b3abc9d9e 100644 --- a/tex/context/base/meta-fig.mkiv +++ b/tex/context/base/meta-fig.mkiv @@ -75,8 +75,8 @@ \getfiguredimensionsonly[#1]% [\c!object=\v!no] already set \startMPcode externalfigure "#1" - xscaled \figurewidth\space - yscaled \figureheight\space + xscaled \the\dimexpr\figurewidth \relax\space % must be points + yscaled \the\dimexpr\figureheight\relax\space % must be points #2 ; \stopMPcode \egroup} diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index bcd82c4ed..02885e8cc 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -37,6 +37,9 @@ \newtoks \everyMPgraphic % mp \newtoks \everyMPTEXgraphic % tex +\newif\ifMPrun +\def\MPruntimefile{mprun} + % The next command is, of course, dedicated to Mojca, who % needs it for gnuplot. Anyway, the whole multiple engine % mechanism is to keep her gnuplot from interfering. @@ -262,8 +265,8 @@ {\executeifdefined{\@@MPG#1};} % ; if not found \def\enableincludeMPgraphics - {\let\handleuseMPgraphic \secondoftwoarguments - \let\handlereusableMPgraphic\secondoftwoarguments} + {\let\handleuseMPgraphic \thirdofthreearguments + \let\handlereusableMPgraphic\thirdofthreearguments} \let\MPdrawingdata\empty @@ -767,21 +770,14 @@ \def\processMPbuffer {\dosingleempty\doprocessMPbuffer} -% this fails (keep): -% -% \def\doprocessMPbuffer[#1]% -% {\doifelsenothing{#1} -% {\doprocessMPbuffer[\jobname]} -% {\processMPgraphic{\ctxlua{tex.sprint(tex.ctxcatcodes,buffers.collect("#1"))}}}} % "\\n" -% -% this works (keep): -% -% \def\doprocessMPbuffer[#1]% -% {\doifelsenothing{#1} -% {\doprocessMPbuffer[\jobname]} % #1 can be a list of buffers, otherwise we could use: -% {\processMPgraphic{\ctxlua{tex.sprint(tex.ctxcatcodes,unpack(buffers.data["#1"]))}}}} -% -% this we use: +\def\doprocessMPbuffer[#1]% + {\doifelsenothing{#1} + {\dodoprocessMPbuffer{\jobname}} + {\dodoprocessMPbuffer{#1}}} + +% we need to go via a toks because we have no multiline print in +% luatex (i.e. tex.sprint does not interpret lines) and therefore +% omits all after a comment token \newtoks\mpbuffertoks @@ -789,9 +785,10 @@ {\doifelsenothing{#1} {\doprocessMPbuffer[\jobname]} {\beginMPgraphicgroup{#1}% - % we need this trick because tex.sprint does not interprets newlines - \ctxlua{tex.toks.mpbuffertoks=buffers.collect("\currentMPgraphicname")}% - \processMPgraphic{\the\mpbuffertoks}% + % we need this trick because tex.sprint does not interprets newlines and the scanner + % stops at a newline; also, we do need to flush the buffer under a normal catcode + % regime in order to expand embedded tex macros; #1 can be a list + \processMPgraphic{\ctxlua{buffers.feedback("\currentMPgraphicname")}}% \endMPgraphicgroup}} \def\runMPbuffer @@ -884,6 +881,25 @@ \let\stopMPcode\relax +% for old time sake + +\def\dostartMPgraphic + {\iffirstargument + \expandafter\dodostartMPgraphic + \else + \expandafter\nodostartMPgraphic + \fi} + +\def\dodostartMPgraphic#1#2\stopMPgraphic + {\beginMPgraphicgroup{#1::\s!dummy}% name does not matter + \processMPgraphic{#2}% + \endMPgraphicgroup} + +\def\nodostartMPgraphic#1#2\stopMPcode + {\processMPgraphic{#2}} + +\let\stopMPcode\relax + %D The \type {\resetMPenvironment} is a quick way to erase %D the token list. %D @@ -999,10 +1015,20 @@ \disablecompoundcharacters \to \everyMPgraphic -\appendtoks +\appendtoks % before color \normalexpanded{\noexpand\definecolor[currentcolor][\currentcolorname]}% \to \everyMPgraphic +% \color[green]{abc \startMPcode +% fill fullcircle scaled 3cm withoutcolor; +% fill fullcircle scaled 2cm withcolor \MPcolor{currentcolor} ; +% fill fullcircle scaled 1cm withcolor \MPcolor{red} ; +% \stopMPcode def} + +% \appendtoks +% \doactivatecolor\s!black\forcecolorhack % we can also move this to the backend +% \to \everyMPgraphic + \appendtoks \baselineskip1\baselineskip \lineheight 1\lineheight @@ -1285,6 +1311,75 @@ \def\MPdivten[#1]{\withoutpt\the\dimexpr#1pt/10\relax} +%D There is no way to distinguish the black color that you get when +%D you issue a \type {draw} without color specification from a color +%D that has an explicit black specification unless you set the +%D variable \type {defaultcolormodel} to 1. Hoewever, in that case +%D you cannot distinguish that draw from one with a \type +%D {withoutcolor} specification. This means that we have to provide +%D multiple variants of inheritance. +%D +%D In any case we need to tell the converter what the inherited color +%D is to start with. Case~3 is kind of unpredictable as it closely +%D relates to the order in which paths are flushed. If you want to +%Dinherit automatically from the surrounding, you can best stick to +%D variant 1. Variant 0 (an isolated graphic) is the default. +%D +%D \startbuffer +%D \startuseMPgraphic{test} +%D drawoptions(withpen pencircle scaled 1pt) ; +%D def shift_cp = currentpicture := currentpicture shifted (-15pt,0) ; enddef ; +%D draw fullcircle scaled 10pt withoutcolor ; shift_cp ; +%D fill fullcircle scaled 10pt ; shift_cp ; +%D draw fullcircle scaled 10pt withoutcolor ; shift_cp ; +%D fill fullcircle scaled 10pt withcolor red ; shift_cp ; +%D draw fullcircle scaled 10pt withoutcolor ; shift_cp ; +%D fill fullcircle scaled 10pt ; shift_cp ; +%D \stopuseMPgraphic +%D +%D \starttabulate +%D \NC 0\quad \NC \chardef\MPcolormethod0 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR +%D \NC 1\quad \NC \chardef\MPcolormethod1 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR +%D \NC 2\quad \NC \chardef\MPcolormethod2 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR +%D \NC 3\quad \NC \chardef\MPcolormethod3 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR +%D \stoptabulate +%D \stopbuffer +%D +%D \typebuffer \getbuffer + +\chardef\MPcolormethod\zerocount + +\appendtoks + \ctxlua{metapost.set_outer_color(\number\MPcolormethod,"\PDFcolor{\currentcolorname}","")}% +\to \everyMPgraphic + +\startMPinitializations + defaultcolormodel := \ifcase\MPcolormethod1\or1\or3\else3\fi; +\stopMPinitializations + +%D \macros +%D {\setupMPgraphics} +%D +%D Here is a generic setup command: + +\newtoks \everysetupMPgraphics + +\def\setupMPgraphics[#1]% + {\getparameters[\??mp][#1]% + \the\everysetupMPgraphics} + +%D Here we hook in the outer color. When \type {color} is set to \type +%D {global} we get the outer color automatically. If you change this +%D setting, you should do it grouped in order not to make other graphics +%D behave in unexpected ways. + +\appendtoks + \doifelse\@@mpcolor\v!global{\chardef\MPcolormethod\plusone}{\chardef\MPcolormethod\zerocount}% +\to \everysetupMPgraphics + +\setupMPgraphics + [\c!color=\v!local] + %D Done. \protect \endinput diff --git a/tex/context/base/mlib-ctx.tex b/tex/context/base/mlib-ctx.mkiv index 6f56b7e68..6f56b7e68 100644 --- a/tex/context/base/mlib-ctx.tex +++ b/tex/context/base/mlib-ctx.mkiv diff --git a/tex/context/base/mlib-pdf.lua b/tex/context/base/mlib-pdf.lua index 9c5775a2d..6617e5fc0 100644 --- a/tex/context/base/mlib-pdf.lua +++ b/tex/context/base/mlib-pdf.lua @@ -247,6 +247,7 @@ function metapost.flush(result,flusher) -- pdf flusher, table en dan concat is s flusher.startfigure(fignum,llx,lly,urx,ury,"begin",figure) t[#t+1] = "q" if objects then +t[#t+1] = metapost.colorinitializer() -- once we have multiple prescripts we can do more tricky things like -- text and special colors at the same time for o=1,#objects do @@ -267,7 +268,7 @@ function metapost.flush(result,flusher) -- pdf flusher, table en dan concat is s t[#t+1] = "q" local ot = object.transform -- 3,4,5,6,1,2 t[#t+1] = format("%f %f %f %f %f %f cm",ot[3],ot[4],ot[5],ot[6],ot[1],ot[2]) -- TH: format("%f %f m %f %f %f %f 0 0 cm",unpack(ot)) - flusher.flushfigure(t) + flusher.flushfigure(t) -- flush accumulated literals t = { } flusher.textfigure(object.font,object.dsize,object.text,object.width,object.height,object.depth) t[#t+1] = "Q" diff --git a/tex/context/base/mlib-pdf.tex b/tex/context/base/mlib-pdf.mkiv index 9a04d188f..92fcb28ae 100644 --- a/tex/context/base/mlib-pdf.tex +++ b/tex/context/base/mlib-pdf.mkiv @@ -29,6 +29,7 @@ \def\startMPLIBtoPDF#1#2#3#4% watch the transparency reset {\naturalhbox\bgroup + \doactivatecolor\s!black\forcecolorhack \MPLIBboundingbox{#1}{#2}{#3}{#4}% \forgetall \setbox\scratchbox\vbox\bgroup diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua index e210e4ee1..077bf1539 100644 --- a/tex/context/base/mlib-pps.lua +++ b/tex/context/base/mlib-pps.lua @@ -39,6 +39,54 @@ local colordata = { {}, {}, {}, {}, {} } --~ => transparent spot : r=123 g= 5 b=hash --~ => rest : r=123 g=n>10 b=whatever + +local nooutercolor = "0 g 0 G" +local nooutertransparency = "/Tr0 gs" +local outercolormode = 0 +local outercolor = nooutercolor +local outertransparency = nooutertransparency +local innercolor = nooutercolor +local innertransparency = nooutertransparency + +function metapost.set_outer_color(mode,color,transparency) + -- has always to be called before conversion + -- todo: transparency (not in the mood now) + outercolormode = mode + if mode == 1 or mode == 3 then + -- inherit from outer + outercolor = color or nooutercolor + outertransparency = transparency or nooutertransparency + elseif mode == 2 then + -- stand alone + outercolor = "" + outertransparency = "" + else -- 0 + outercolor = nooutercolor + outertransparency = nooutertransparency + end + innercolor = outercolor + innertransparency = outertransparency +end + +local function checked_color_pair(color) + if not color then + return innercolor, outercolor + elseif outercolormode == 3 then + innercolor = color + return innercolor, innercolor + else + return color, outercolor + end +end + +metapost.checked_color_pair = checked_color_pair + +function metapost.colorinitializer() + innercolor = outercolor + innertransparency = outertransparency + return outercolor, outertransparency +end + function metapost.specials.register(str) -- only colors local size, content, n, class = match(str,"^%%%%MetaPostSpecial: (%d+) (.*) (%d+) (%d+)$") if class then @@ -54,10 +102,15 @@ function metapost.specials.register(str) -- only colors n = tonumber(data[1]) end if n then - colordata[class][n] = data + local cc = colordata[class] + if cc then + cc[n] = data + else + logs.report("mplib","problematic special: %s (no colordata class %s)", str or "?",class) + end else -- there is some bug to be solved, so we issue a message - logs.report("[msr bug] %s", str or "?") + logs.report("mplib","problematic special: %s", str or "?") end end --~ if str:match("^%%%%MetaPostOption: multipass") then @@ -66,7 +119,7 @@ function metapost.specials.register(str) -- only colors end function metapost.colorhandler(cs, object, result, colorconverter) - local cr = "0 g 0 G" + local cr = outercolor local what = round(cs[2]*10000) local data = colordata[what] if data then @@ -122,7 +175,7 @@ function metapost.specials.tr(specification,object,result) return object, result end local after = before and function() - result[#result+1] = "/Tr0 gs" + result[#result+1] = outertransparency -- here we could revert to teh outer color return object, result end return object, before, nil, after @@ -157,7 +210,7 @@ local colorsplitter = lpeg.Ct(lpeg.splitat(":")) -- x' = sx * x + ry * y + tx -- y' = rx * x + sy * y + ty -function metapost.specials.fg(specification,object,result,flusher) +function metapost.specials.fg(specification,object,result,flusher) -- graphics local op = object.path local first, second, fourth = op[1], op[2], op[4] local tx, ty = first.x_coord , first.y_coord @@ -173,6 +226,16 @@ function metapost.specials.fg(specification,object,result,flusher) return { } , before, nil, nil -- replace { } by object for tracing end +function metapost.specials.ps(specification,object,result) -- positions + local op = object.path + local first, third = op[1], op[3] + local x, y = first.x_coord, first.y_coord + local w, h = third.x_coord - x, third.y_coord - y + local label = specification + logs.report("mplib", "todo: position '%s' at (%s,%s) with (%s,%s)",label,x,y,w,h) + return { }, nil, nil, nil +end + local nofshades = 0 -- todo: hash resources, start at 1000 in order not to clash with older local function normalize(ca,cb) @@ -434,82 +497,9 @@ function metapost.specials.ts(specification,object,result,flusher) end end -function metapost.colorconverter() - -- it no longer pays off to distinguish between outline and fill - -- (we now have both too, e.g. in arrows) - local model = colors.model - if model == "all" then - return function(cr) - local n = #cr - if n == 1 then - local s = cr[1] - return format("%.3f g %.3f G",s,s), "0 g 0 G" - elseif n == 4 then - local c, m, y, k = cr[1], cr[2], cr[3], cr[4] - return format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k), "0 g 0 G" - else - local r, g, b = cr[1], cr[2], cr[3] - return format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b), "0 g 0 G" - end - end - elseif model == "rgb" then - return function(cr) - local n = #cr - if n == 1 then - local s = cr[1] - return format("%.3f g %.3f G",s,s), "0 g 0 G" - end - local r, g, b - if n == 4 then - r, g, b = cmyktorgb(cr[1],cr[2],cr[3],cr[4]) - else - r, g, b = cr[1],cr[2],cr[3] - end - return format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b), "0 g 0 G" - end - elseif model == "cmyk" then - return function(cr) - local n = #cr - if n == 1 then - local s = cr[1] - return format("%.3f g %.3f G",s,s), "0 g 0 G" - end - local c, m, y, k - if n == 4 then - c, m, y, k = cr[1], cr[2], cr[3], cr[4] - else - c, m, y, k = rgbtocmyk(cr[1],cr[2],cr[3]) - end - return format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k), "0 g 0 G" - end - else - return function(cr) - local s - local n = #cr - if n == 4 then - s = cmyktogray(cr[1],cr[2],cr[3],cr[4]) - elseif n == 3 then - s = rgbtogray(cr[1],cr[2],cr[3]) - else - s = cr[1] - end - return format("%.3f g %.3f G",s,s), "0 g 0 G" - end - end -end - ---~ local cmyk_fill = "%.3f %.3f %.3f %.3f k" ---~ local rgb_fill = "%.3f %.3f %.3f rg" ---~ local gray_fill = "%.3f g" ---~ local reset_fill = "0 g" - ---~ local cmyk_stroke = "%.3f %.3f %.3f %.3f K" ---~ local rgb_stroke = "%.3f %.3f %.3f RG" ---~ local gray_stroke = "%.3f G" ---~ local reset_stroke = "0 G" - metapost.reducetogray = true + function metapost.colorconverter() -- rather generic pdf, so use this elsewhere too -- it no longer pays off to distinguish between outline and fill -- (we now have both too, e.g. in arrows) @@ -518,64 +508,68 @@ function metapost.colorconverter() -- rather generic pdf, so use this elsewhere if model == "all" then return function(cr) local n = #cr - if reduce then + if n == 0 then + return checked_color_pair() + elseif reduce then if n == 1 then local s = cr[1] - return format("%.3f g %.3f G",s,s), "0 g 0 G" + return checked_color_pair(format("%.3f g %.3f G",s,s)) elseif n == 3 then local r, g, b = cr[1], cr[2], cr[3] if r == g and g == b then - return format("%.3f g %.3f G",r,r), "0 g 0 G" + return checked_color_pair(format("%.3f g %.3f G",r,r)) else - return format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b), "0 g 0 G" + return checked_color_pair(format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b)) end else local c, m, y, k = cr[1], cr[2], cr[3], cr[4] if c == m and m == y and y == 0 then k = 1 - k - return format("%.3f g %.3f G",k,k), "0 g 0 G" + return checked_color_pair(format("%.3f g %.3f G",k,k)) else - return format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k), "0 g 0 G" + return checked_color_pair(format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k)) end end elseif n == 1 then local s = cr[1] - return format("%.3f g %.3f G",s,s), "0 g 0 G" + return checked_color_pair(format("%.3f g %.3f G",s,s)) elseif n == 3 then local r, g, b = cr[1], cr[2], cr[3] - return format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b), "0 g 0 G" + return checked_color_pair(format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b)) else local c, m, y, k = cr[1], cr[2], cr[3], cr[4] - return format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k), "0 g 0 G" + return checked_color_pair(format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k)) end end elseif model == "rgb" then return function(cr) local n = #cr - if reduce then + if n == 0 then + return checked_color_pair() + elseif reduce then if n == 1 then local s = cr[1] - return format("%.3f g %.3f G",s,s), "0 g 0 G" + checked_color_pair(format("%.3f g %.3f G",s,s)) elseif n == 3 then local r, g, b = cr[1], cr[2], cr[3] if r == g and g == b then - return format("%.3f g %.3f G",r,r), "0 g 0 G" + return checked_color_pair(format("%.3f g %.3f G",r,r)) else - return format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b), "0 g 0 G" + return checked_color_pair(format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b)) end else local c, m, y, k = cr[1], cr[2], cr[3], cr[4] if c == m and m == y and y == 0 then k = 1 - k - return format("%.3f g %.3f G",k,k), "0 g 0 G" + return checked_color_pair(format("%.3f g %.3f G",k,k)) else local r, g, b = cmyktorgb(c,m,y,k) - return format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b), "0 g 0 G" + return checked_color_pair(format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b)) end end elseif n == 1 then local s = cr[1] - return format("%.3f g %.3f G",s,s), "0 g 0 G" + return checked_color_pair(format("%.3f g %.3f G",s,s)) else local r, g, b if n == 3 then @@ -583,36 +577,38 @@ function metapost.colorconverter() -- rather generic pdf, so use this elsewhere else r, g, b = cr[1], cr[2], cr[3] end - return format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b), "0 g 0 G" + return checked_color_pair(format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b)) end end elseif model == "cmyk" then return function(cr) local n = #cr - if reduce then + if n == 0 then + return checked_color_pair() + elseif reduce then if n == 1 then local s = cr[1] - return format("%.3f g %.3f G",s,s), "0 g 0 G" + return checked_color_pair(format("%.3f g %.3f G",s,s)) elseif n == 3 then local r, g, b = cr[1], cr[2], cr[3] if r == g and g == b then - return format("%.3f g %.3f G",r,r), "0 g 0 G" + return checked_color_pair(format("%.3f g %.3f G",r,r)) else local c, m, y, k = rgbtocmyk(r,g,b) - return format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k), "0 g 0 G" + return checked_color_pair(format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k)) end else local c, m, y, k = cr[1], cr[2], cr[3], cr[4] if c == m and m == y and y == 0 then k = 1 - k - return format("%.3f g %.3f G",k,k), "0 g 0 G" + return checked_color_pair(format("%.3f g %.3f G",k,k)) else - return format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k), "0 g 0 G" + return checked_color_pair(format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k)) end end elseif n == 1 then local s = cr[1] - return format("%.3f g %.3f G",s,s), "0 g 0 G" + return checked_color_pair(format("%.3f g %.3f G",s,s)) else local c, m, y, k if n == 3 then @@ -620,20 +616,22 @@ function metapost.colorconverter() -- rather generic pdf, so use this elsewhere else c, m, y, k = cr[1], cr[2], cr[3], cr[4] end - return format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k), "0 g 0 G" + return checked_color_pair(format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k)) end end else return function(cr) local n, s = #cr, 0 - if n == 4 then + if n == 0 then + return checked_color_pair() + elseif n == 4 then s = cmyktogray(cr[1],cr[2],cr[3],cr[4]) elseif n == 3 then s = rgbtogray(cr[1],cr[2],cr[3]) else s = cr[1] end - return format("%.3f g %.3f G",s,s), "0 g 0 G" + return checked_color_pair(format("%.3f g %.3f G",s,s)) end end end @@ -741,7 +739,7 @@ function metapost.graphic_base_pass(mpsformat,str,preamble) str, "endfig ;" -- }, true, nil, true ) - }, true, nil, not (forced_1 or forced_2)) + }, true, nil, not (forced_1 or forced_2), false) if metapost.intermediate.needed then for _, action in pairs(metapost.intermediate.actions) do action() @@ -759,7 +757,7 @@ function metapost.graphic_base_pass(mpsformat,str,preamble) "_trial_run_ := false ;", str, "endfig ;" - } ) + }, false, nil, false, false ) end -- here we could free the textext boxes metapost.free_boxes() @@ -773,7 +771,7 @@ function metapost.graphic_extra_pass() concat(metapost.text_texts_data()," ;\n"), current_graphic, "endfig ;" - }) + }, false, nil, false, true ) end function metapost.getclippath(data) diff --git a/tex/context/base/mlib-pps.tex b/tex/context/base/mlib-pps.mkiv index beaef044e..beaef044e 100644 --- a/tex/context/base/mlib-pps.tex +++ b/tex/context/base/mlib-pps.mkiv diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua index 9a7ed6f39..1644feb4a 100644 --- a/tex/context/base/mlib-run.lua +++ b/tex/context/base/mlib-run.lua @@ -29,6 +29,8 @@ approach is way faster than an external <l n='metapost'/> and processing time nears zero.</p> --ldx]]-- +local trace_graphics = false trackers.register("metapost.graphics", function(v) trace_graphics = v end) + local format = string.format metapost = metapost or { } @@ -143,7 +145,7 @@ function metapost.reporterror(result) metapost.report("mp error: no result object returned") elseif result.status > 0 then local t, e, l = result.term, result.error, result.log - if t then + if t and t ~= "" then metapost.report("mp terminal: %s",t) end if e then @@ -236,20 +238,41 @@ function metapost.reset(mpx) end end -function metapost.process(mpx, data, trialrun, flusher, multipass) +local mp_inp, mp_log, mp_tag = { }, { }, 0 + +function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass) local converted, result = false, {} if type(mpx) == "string" then mpx = metapost.format(mpx) -- goody end if mpx and data then statistics.starttiming(metapost) + if trace_graphics then + if not mp_inp[mpx] then + mp_tag = mp_tag + 1 + mp_inp[mpx] = io.open(format("%s-mplib-run-%03i.mp", tex.jobname,mp_tag),"w") + mp_log[mpx] = io.open(format("%s-mplib-run-%03i.log",tex.jobname,mp_tag),"w") + end + local banner = format("%% begin graphic: n=%s, trialrun=%s, multipass=%s, isextrapass=%s\n\n", metapost.n, tostring(trialrun), tostring(multipass), tostring(isextrapass)) + mp_inp[mpx]:write(banner) + mp_log[mpx]:write(banner) + end if type(data) == "table" then for i=1,#data do local d = data[i] if d then + if trace_graphics then + mp_inp[mpx]:write(d) + end statistics.starttiming(metapost.exectime) result = mpx:execute(d) statistics.stoptiming(metapost.exectime) + if trace_graphics and result then + local str = result.log or result.error + if str and str ~= "" then + mp_log[mpx]:write(str) + end + end if not metapost.reporterror(result) then if metapost.showlog then local str = (result.term ~= "" and result.term) or "no terminal output" @@ -267,9 +290,18 @@ function metapost.process(mpx, data, trialrun, flusher, multipass) end end else + if trace_graphics then + mp_inp:write(data) + end statistics.starttiming(metapost.exectime) - result = mpx:execute(data) + result = mpx[mpx]:execute(data) statistics.stoptiming(metapost.exectime) + if trace_graphics and result then + local str = result.log or result.error + if str and str ~= "" then + mp_log[mpx]:write(str) + end + end -- todo: error message if not result then metapost.report("mp error: no result object returned") @@ -285,6 +317,11 @@ function metapost.process(mpx, data, trialrun, flusher, multipass) end end end + if trace_graphics then + local banner = "\n% end graphic\n\n" + mp_inp[mpx]:write(banner) + mp_log[mpx]:write(banner) + end statistics.stoptiming(metapost) end return converted, result diff --git a/tex/context/base/mult-sys.tex b/tex/context/base/mult-sys.tex index 0fb64d98a..b24c11d58 100644 --- a/tex/context/base/mult-sys.tex +++ b/tex/context/base/mult-sys.tex @@ -504,6 +504,7 @@ \definesystemvariable {mk} % MarKering \definesystemvariable {mt} % inline MaTh \definesystemvariable {mo} % Math Options +\definesystemvariable {mp} % MetaPost \definesystemvariable {mx} % MatriX \definesystemvariable {ng} % parbuilders \definesystemvariable {nh} % new heads (structure) @@ -720,6 +721,7 @@ \definefileconstant {propprefix} {prop-} \definefileconstant {unicprefix} {unic-} \definefileconstant {sortprefix} {sort-} +\definefileconstant {prettyprefix} {pret-} \definefileconstant {moduleprefix} {m-} \definefileconstant {styleprefix} {s-} diff --git a/tex/context/base/node-fin.tex b/tex/context/base/node-fin.mkiv index 787706ff2..787706ff2 100644 --- a/tex/context/base/node-fin.tex +++ b/tex/context/base/node-fin.mkiv diff --git a/tex/context/base/node-ini.tex b/tex/context/base/node-ini.mkiv index 210f21229..210f21229 100644 --- a/tex/context/base/node-ini.tex +++ b/tex/context/base/node-ini.mkiv diff --git a/tex/context/base/node-par.tex b/tex/context/base/node-par.mkiv index 7f7ca9977..7f7ca9977 100644 --- a/tex/context/base/node-par.tex +++ b/tex/context/base/node-par.mkiv diff --git a/tex/context/base/core-box.tex b/tex/context/base/pack-box.mkii index 97811e78f..1be840552 100644 --- a/tex/context/base/core-box.tex +++ b/tex/context/base/pack-box.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-box, +%D [ file=pack-box, %D version=2002.04.12, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Packaging Macros, %D subtitle=Boxes, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Boxes} +\writestatus{loading}{ConTeXt Packaging Macros / Boxes} %D This module contains all kind of macros for moving content %D around. Many macros here come from other modules, but diff --git a/tex/context/base/pack-box.mkiv b/tex/context/base/pack-box.mkiv new file mode 100644 index 000000000..1be840552 --- /dev/null +++ b/tex/context/base/pack-box.mkiv @@ -0,0 +1,954 @@ +%D \module +%D [ file=pack-box, +%D version=2002.04.12, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Boxes, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Packaging Macros / Boxes} + +%D This module contains all kind of macros for moving content +%D around. Many macros here come from other modules, but +%D depencies made it more clear to isolate them. + +% \placeornament + +\unprotect + +% \definelayer[\v!tekst-2][\c!positie=\v!ja] +% \definelayer[\v!tekst-1][\c!positie=\v!ja] +% \definelayer[\v!tekst+1][\c!positie=\v!ja] +% \definelayer[\v!tekst+2][\c!positie=\v!ja] + +% we need to set the size, else we get dimensions depending +% on the content, which in itsel fis ok, but can lead to loops +% due to rounding errors (happened in demo-obv) + +\definelayer[\v!text-2][\c!position=\v!yes,\c!width=\overlaywidth,\c!height=\overlayheight] +\definelayer[\v!text-1][\c!position=\v!yes,\c!width=\overlaywidth,\c!height=\overlayheight] +\definelayer[\v!text+1][\c!position=\v!yes,\c!width=\overlaywidth,\c!height=\overlayheight] +\definelayer[\v!text+2][\c!position=\v!yes,\c!width=\overlaywidth,\c!height=\overlayheight] + +\def\internaltextoverlay#1% will become more generic and installable + {\startoverlay % i.e. probably an overlay by itself + {\positionoverlay{\v!text#1}} % see later + {\composedlayer {\v!text#1}} + \stopoverlay} + +%\def\internaltextoverlay#1% +% {\hbox to \zeropoint{\positionoverlay{\v!tekst#1}\hss}% +% \composedlayer{\v!tekst#1}} + +% todo: share info, so that tuo will be smaller + +\defineoverlay[\v!text-2][\internaltextoverlay{-2}] +\defineoverlay[\v!text-1][\internaltextoverlay{-1}] +\defineoverlay[\v!text+1][\internaltextoverlay{+1}] +\defineoverlay[\v!text+2][\internaltextoverlay{+2}] + +% to be documented + +\definelayer[anchor] + +\def\anchor + {\dosingleargument\doanchor} + +\def\doanchor[#1]% + {\ifundefined{\??an#1}\@EA\dodoanchor\else\@EA\nonoanchor\fi[#1]} + +\def\nonoanchor[#1]% + {\getvalue{\??an#1}} + +\def\dodoanchor[#1]% + {\dotripleempty\dododoanchor[#1]} + +\def\dododoanchor + {\ifthirdargument + \expandafter\dodoanchorT + \else + \expandafter\dodoanchorS + \fi} + +\def\dodoanchorS[#1][#2][#3]% + {\dodoanchorT[#1][#2][#2]} + +\def\dodoanchorT[#1][#2][#3]% + {\dowithnextbox + {\bgroup + \checktextbackgrounds + \setbox\scratchbox\null + \wd\scratchbox\nextboxwd + \ht\scratchbox\nextboxht + \dp\scratchbox\nextboxdp + \setlayer + [anchor] + [\c!width=\wd\scratchbox, + \c!height=\ht\scratchbox, + \c!offset=\!!zeropoint, + #2,#3] + {\setlayer[#1]{\flushnextbox}}% + \framed + [#2, + \c!background=anchor, + \c!offset=\v!overlay, + \c!frame=\v!off, + #3] + {\box\scratchbox}% + \egroup}% + \vbox} + +\def\defineanchor + {\doquadrupleempty\dodefineanchor} + +\def\dodefineanchor[#1][#2][#3][#4]% + {\setvalue{\??an#1}{\dodefinedanchor[#2][#3][#4]}} + +\def\dodefinedanchor[#1][#2][#3]% + {\def\docommand[##1][##2]% + {\ifsecondargument + \def\next{\dodoanchorT[#1][#2,##1][#3,##2]}% + \else\iffirstargument + \def\next{\dodoanchorT[#1][#2,##1][#2,##1]}% + \else + \def\next{\dodoanchorT[#1][#2][#3]}% + \fi\fi + \next}% + \dodoubleempty\docommand} + +\def\@@collectorbox{@@collectorbox} + +\def\definecollector + {\dodoubleargument\dodefinecollector} + +\def\dodefinecollector[#1][#2]% + {\ifundefined{\@@collectorbox#1}% + \expandafter\newbox\csname\@@collectorbox#1\endcsname + \fi + \resetcollector[#1]% + \setupcollector + [#1] + [\c!state=\v!start, + \c!x=\!!zeropoint,\c!y=\!!zeropoint, + \c!offset=\!!zeropoint,\c!rotation=, % geen 0 ! + \c!hoffset=\!!zeropoint,\c!voffset=\!!zeropoint, + \c!location=rb,\c!corner=,#2]} + +\def\setupcollector + {\dodoubleargument\dosetupcollector} + +\def\dosetupcollector[#1][#2]% + {\def\docommand##1{\getparameters[\??cb##1][#2]}% + \processcommalist[#1]\docommand} + +\def\setcollector + {\dodoubleargument\dosetcollector} + +\def\dosetcollector[#1][#2]% + {\bgroup + \forgetall + \dontcomplain + \dowithnextbox + {\ifundefined{\@@collectorbox#1}% + \writestatus{collector}{unknown layer #1}% + \else + \dodosetcollector[#1][#2]% + \fi + \egroup} + \hbox} + +\def\collectorparameter#1{\csname\??cb\currentcollector#1\endcsname} + +\def\dodosetcollector[#1][#2]% todo: keep reference point + {\def\currentcollector{#1}% + \mathchardef\collectorbox\csname\@@collectorbox#1\endcsname + \getparameters[\??cb#1][#2]% + \@@layerxsiz\wd\collectorbox + \@@layerysiz\ht\collectorbox + \doifvaluesomething{\??cb#1\c!rotation} + {\setbox\nextbox\hbox + {\rotate + [\c!location=\v!high, + \c!rotation=\collectorparameter\c!rotation] + {\flushnextbox}}}% + \advance\@@layerysiz\dp\collectorbox + \@@layerxpos\collectorparameter\c!x + \advance\@@layerxpos\collectorparameter\c!hoffset + \@@layerypos\collectorparameter\c!y + \advance\@@layerypos\collectorparameter\c!voffset + \doifelse\v!middle{\collectorparameter\c!corner} + {\ifdim\@@layerxsiz>\zeropoint + \advance\@@layerxpos.5\@@layerxsiz + \fi + \ifdim\@@layerysiz>\zeropoint + \advance\@@layerypos.5\@@layerysiz + \fi}% + {\ExpandBothAfter\doifinset\v!bottom{\collectorparameter\c!corner} + {\ifdim\@@layerysiz>\zeropoint + \advance\@@layerypos-\@@layerysiz + \@@layerypos-\@@layerypos + \fi}% + \ExpandBothAfter\doifinset\v!right{\collectorparameter\c!corner} + {\ifdim\@@layerxsiz>\zeropoint + \advance\@@layerxpos-\@@layerxsiz + \@@layerxpos-\@@layerxpos + \fi}}% + \setbox\nextbox\hbox + {\alignedbox[\collectorparameter\c!location]\vbox{\flushnextbox}}% + \boxmaxdepth\zeropoint % really needed, nice example + \global\advance\boxhdisplacement\@@layerxpos + \ifdim\boxhdisplacement<\zeropoint + \global\setbox\collectorbox\hbox + {\hskip-\boxhdisplacement + \box\collectorbox}% + \fi + \global\advance\boxvdisplacement\@@layerypos + \ifdim\boxvdisplacement<\zeropoint + \global\setbox\collectorbox\hbox + {\lower-\boxvdisplacement + \box\collectorbox}% + \fi + \@@layerxsiz\wd\collectorbox + \@@layerysiz\ht\collectorbox + \advance\@@layerysiz\dp\collectorbox + \global\setbox\collectorbox\hbox + {\box\collectorbox + \hskip-\@@layerxsiz + \hskip\@@layerxpos\relax + \ifdim\boxhdisplacement<\zeropoint + \hskip-\boxhdisplacement + \fi + \lower\@@layerypos\hbox + {\ifdim\boxvdisplacement<\zeropoint + \lower-\boxvdisplacement\flushnextbox + \else + \flushnextbox + \fi}}% + % combine height and depth into depth only (later flushed as height) + \global\setbox\collectorbox\hbox + {\lower\ht\collectorbox\box\collectorbox}% + % just to be sure + \ifdim\wd\collectorbox<\@@layerxsiz + \global\wd\collectorbox\@@layerxsiz + \fi} + +\def\flushcollector[#1]% + {\ifundefined{\@@collectorbox#1}% + \writestatus{collector}{unknown collector #1}% + \else + \doifnotvalue{\??cb#1\c!state}\v!stop + {\vbox + {\hbox + {\doifelsevalue{\??cb#1\c!state}\v!repeat + {\let\next\copy}{\let\next\box}% + \raise\dp\csname\@@collectorbox#1\endcsname + \next\csname\@@collectorbox#1\endcsname}}}% + \fi} + +\def\composedcollector#1{\flushcollector[#1]} + +\def\resetcollector[#1]% + {\ifundefined{\@@collectorbox#1}\else + \global\setbox\csname\@@collectorbox#1\endcsname\emptybox + \fi} + +\def\adaptcollector + {\dodoubleargument\doadaptcollector} + +\def\doadaptcollector[#1][#2]% + {\bgroup + \def\currentcollector{#1}% + \mathchardef\collectorbox\csname\@@collectorbox#1\endcsname + \getparameters + [\??cb#1][\c!voffset=\zeropoint,\c!hoffset=\zeropoint,#2]% + \scratchdimen\wd\collectorbox + \advance\scratchdimen\collectorparameter\c!hoffset + \global\wd\collectorbox\scratchdimen + \scratchdimen\ht\collectorbox + \advance\scratchdimen\collectorparameter\c!voffset + \global\ht\collectorbox\scratchdimen + \egroup} + +%\definecollector[test] +%\setcollector[test] +% [location=rb] +% {\externalfigure[koe][frame=on,width=3cm]} +%\setcollector[test] +% [corner={right,bottom},location={left,top}] +% {\framed{gans}} +%\composedcollector{test} + +\definecollector + [caption] + +\def\collectedtext + {\dodoubleempty\docollectedtext} + +\def\docollectedtext[#1][#2]#3% + {\bgroup + \dowithnextbox + {\setcollector + [caption] + {\flushnextbox}% + \setcollector + [caption][#1] + {\getparameters[\??du][#2]% + \dosetfontattribute\??du\c!style\setupinterlinespace + \framed % watch the special setting of kader/overlay + [\c!frame=\v!overlay,#2] + {\doattributes\??du\c!style\c!color{#3}}}% + \composedcollector{caption}% + \egroup}% + \hbox} + +% \collectedtext +% [corner={right,bottom},location={left,top}] +% [background=color,backgroundcolor=white,offset=0pt] +% {gans} +% {\externalfigure[koe][width=3cm]} +% +% \collectedtext +% [rotation=90,corner={right,bottom},location={right,top}] +% [frame=on,offset=0pt] +% {gans} +% {\externalfigure[koe][width=3cm]} +% +% \collectedtext +% [rotation=90,corner={left,bottom},location={left,top}] +% [frame=on,offset=0pt] +% {gans} +% {\externalfigure[koe][width=3cm]} + +\definelayer + [caption] + +\def\layeredtext + {\dodoubleempty\dolayeredtext} + +\def\dolayeredtext[#1][#2]#3% + {\bgroup + \dowithnextbox + {\!!widtha \nextboxwd + \!!heighta\nextboxht + \bgroup % preserve \nextbox + \setuplayer + [caption] + [\c!width=\!!widtha,\c!height=\!!heighta]% + \setlayer + [caption] + [#1] + {\getparameters[\??du][#2]% + \dosetfontattribute\??du\c!style\setupinterlinespace + \framed + [\c!frame=\v!overlay,,#2] + {\doattributes\??du\c!style\c!color{#3}}}% + \egroup + \framed + [\c!offset=\v!overlay, + \c!frame=\v!off, + \c!background={\v!foreground,caption}, + \c!width=\!!widtha, + \c!height=\!!heighta] + {\flushnextbox}% + \egroup}% + \hbox} + +% \layeredtext +% [corner={right,bottom},location={left,top}] +% [background=color,backgroundcolor=white,offset=0pt] +% {gans} +% {\externalfigure[koe][width=3cm]} +% +% \layeredtext +% [rotation=90,corner={right,bottom},location={right,top}] +% [frame=on,offset=0pt] +% {gans} +% {\externalfigure[koe][width=3cm]} +% +% \layeredtext +% [rotation=90,corner={left,bottom},location={left,top}] +% [frame=on,offset=0pt] +% {gans} +% {\externalfigure[koe][width=3cm]} + +\def\ornamenttext + {\dodoubleempty\doornamenttext} + +\def\doornamenttext[#1][#2]% + {\bgroup + \doifassignmentelse{#1} + {\getparameters[\s!dummy][\c!alternative=\v!a,#1]% + \doifelse\dummyalternative\v!a + {\egroup\collectedtext}% + {\egroup\layeredtext }% + [#1][#2]}% + {\egroup\getvalue{#1}}} + +\def\defineornament + {\dotripleempty\dodefineornament} + +\def\dodefineornament[#1][#2][#3]% + {\setvalue{#1}{\doornamenttext[#2][#3]}} + +% \defineornament +% [affiliation] +% [rotation=90,corner={right,bottom},location={right,top}, +% hoffset=-.25ex] +% [frame=on,background=color,backgroundcolor=red,offset=0pt] +% +% \ruledhbox{\affiliation{gans}{\externalfigure[koe][width=3cm]}} +% +% \defineornament +% [affiliation] +% [rotation=90,corner={right,bottom},location={right,top}, +% hoffset=-.25ex,alternative=b] +% [frame=on,background=color,backgroundcolor=red,offset=0pt] +% +% \ruledhbox{\affiliation{gans}{\externalfigure[koe][width=3cm]}} +% +% \defineornament +% [affiliation] +% [rotation=90,corner={right,bottom},location={left,top}, +% hoffset=.25ex,voffset=.25ex,alternative=a] +% [background=color,style=\ss\tfxx,backgroundcolor=white,offset=0pt] +% +% \affiliation{photo}{\externalfigure[molen][width=3cm]} +% +% \defineornament +% [affiliation] +% [rotation=90,corner={right,bottom},location={left,top}, +% hoffset=.25ex,voffset=.25ex,alternative=b] +% [background=color,style=\ss\tfxx,backgroundcolor=white,offset=0pt] +% +% \affiliation{drawing}{\externalfigure[hakker][width=3cm]} + +% pas op: aanpassen aan nieuwe layer hoek ankers en columnset + +\newcount\nofbleeds % per pag + +\def\setupbleeding + {\dodoubleempty\getparameters[\??bg]} + +\setupbleeding + [\c!location=l, + \c!stretch=\v!yes, + \c!width=3cm, + \c!height=3cm, + \c!offset=2mm, + \c!page=\v!no, + \c!voffset=\@@bgoffset, + \c!hoffset=\@@bgoffset] + +\def\bleed + {\dosingleempty\dobleed} + + +\def\bleedwidth {\the\hsize}% +\def\bleedheight{\the\vsize}% + +\def\dobleed[#1]#2% + {\hbox\bgroup + \xdef\bleedwidth {\the\hsize}% + \xdef\bleedheight{\the\vsize}% + \global\advance\nofbleeds\plusone + \getparameters[\??bg][#1]% + \!!doneafalse % left + \!!donebfalse % right + \!!donecfalse % top + \!!donedfalse % bottom + % replace this part ! todo: default location + \processaction + [\@@bglocation] + [ t=>\!!donectrue\let\@@bghoffset\!!zeropoint, + b=>\!!donedtrue\let\@@bghoffset\!!zeropoint, + l=>\!!doneatrue\let\@@bgvoffset\!!zeropoint, + r=>\!!donebtrue\let\@@bgvoffset\!!zeropoint, + bl=>\!!doneatrue\!!donedtrue, + lb=>\!!doneatrue\!!donedtrue, + br=>\!!donebtrue\!!donedtrue, + rb=>\!!donebtrue\!!donedtrue, + tl=>\!!doneatrue\!!donectrue, + lt=>\!!doneatrue\!!donectrue, + tr=>\!!donebtrue\!!donectrue, + rt=>\!!donebtrue\!!donectrue]% + \doifelse\@@bgstretch\v!yes\donetrue\donefalse + \scratchdimen\@@bgwidth + \ifdone + \if!!donea + \advance\scratchdimen\MPx{\??bg:\number\nofbleeds}% + \else\if!!doneb + \scratchdimen\paperwidth + \advance\scratchdimen-\MPx{\??bg:\number\nofbleeds}% + \fi\fi + \fi + \advance\scratchdimen\@@bghoffset + \xdef\bleedwidth{\the\scratchdimen}% + \scratchdimen\@@bgheight + \ifdone + \if!!donec + \scratchdimen\paperheight + \advance\scratchdimen-\MPy{\??bg:\number\nofbleeds}% + \else\if!!doned + \advance\scratchdimen\MPy{\??bg:\number\nofbleeds}% + \fi\fi + \fi + \advance\scratchdimen\@@bgvoffset + \xdef\bleedheight{\the\scratchdimen}% + \hsize\bleedwidth + \vsize\bleedheight + \setbox\scratchbox\hbox{#2}% + \doif\@@bgpage\v!yes + {\setbox\scratchbox\topskippedbox{\box\scratchbox}}% + \setbox\scratchbox\hbox to \@@bgwidth + {\if!!donea\hss\fi\box\scratchbox\if!!doneb\hss\fi}% + \if!!doned + \setbox\scratchbox\hbox + {\lower\bleedheight\hbox{\raise\@@bgheight\box\scratchbox}}% + \fi + \wd\scratchbox\@@bgwidth + \ht\scratchbox\@@bgheight + \dp\scratchbox\zeropoint + \ifdone + \hpos{\??bg:\number\nofbleeds}{\box\scratchbox}% + \else + \box\scratchbox + \fi + \egroup} + +\setupbleeding[\c!stretch=\v!yes] + +\defineexternalfigure[bleed][\c!width=\bleedwidth,\c!height=\bleedheight] + +% \placefigure[left]{none} +% {\bleed[width=5cm,height=3cm,location=lt]{\externalfigure[koe][bleed]}} +% +% \input tufte +% +% \placefigure[left]{none} +% {\bleed[width=5cm,height=3cm,location=l]{\externalfigure[koe][bleed]}} +% +% \input tufte +% +% \placefigure[right]{none} +% {\bleed[width=5cm,height=3cm,location=r]{\externalfigure[koe][bleed]}} +% +% \input tufte +% +% \placesomefloat[right]{none} +% {\bleed[width=5cm,height=3cm,location=rb]{\externalfigure[koe][bleed]}} +% +% \input tufte +% +% \placefigure +% [top,none] +% {} % no caption +% {\bleed +% [hoffset=-\backspace, +% voffset=3mm, +% width=0cm, +% height=6\lineheight, +% page=yes, % correct for topskip +% location=lt] +% {\externalfigure[koe][bleed][frame=on]}} + +% \setlayerframed[layer id][layer settings][framed setting]{data} +% \setlayerframed[layer id][combined settings]{data} + +\def\setlayerframed + {\dotripleempty\dosetlayerframed} + +\def\dosetlayerframed + {\ifthirdargument + \expandafter\dosetlayerframedT + \else + \expandafter\dosetlayerframedS + \fi} + +\def\dosetlayerframedT[#1][#2][#3]% + {\dowithnextbox{\setlayer[#1][#2]{\flushnextbox}}% + \hbox\framed[#3]} + +\def\dosetlayerframedS[#1][#2][#3]% + {\dowithnextbox + {\setlayer + [#1] + [\c!width=\nextboxwd,\c!height=\nextboxht, + \c!offset=\!!zeropoint,#2] + {\flushnextbox}}% + \hbox\framed[\c!location=\v!normal,#2]} + +\def\setlayertext + {\dotripleempty\dosetlayertext} + +\def\dosetlayertext[#1][#2][#3]% + {\bgroup + \getparameters + [\??lx] + [\c!align=, + \c!width=\hsize, + \c!color=, + \c!style=, + #3]% + \dowithnextboxcontent + {\forgetall + \hsize\@@lxwidth + \expanded{\setupalign[\@@lxalign]}% + \dosetfontattribute\??lx\c!style} + {\setlayer[#1][#2]{\strut\color[\@@lxcolor]{\flushnextbox}}% + \egroup}% + \vtop} + +% \setupbackgrounds +% [page] +% [background=pagefigures] +% +% \definelayer +% [pagefigures] +% [x=-2mm, +% y=-2mm, +% width=\paperwidth, +% height=\paperheight] +% +% \definelayerpreset [lefttop] [corner={left,top},location={right,bottom}] +% \definelayerpreset [righttop] [corner={right,top},location={left,bottom}] +% \definelayerpreset [leftbottom] [corner={left,bottom},location={right,top}] +% \definelayerpreset [rightbottom] [corner={right,bottom},location={left,top}] +% \definelayerpreset [middle] [corner=middle,location=middle] +% +% \setlayer[pagefigures][preset=lefttop] +% \setlayer[pagefigures][preset=righttop] +% \setlayer[pagefigures][preset=leftbottom] +% \setlayer[pagefigures][preset=rightbottom] + +\definelayerpreset + [\v!left\v!top] + [\c!corner={\v!left,\v!top},\c!location={\v!right,\v!bottom}] + +\definelayerpreset + [\v!right\v!top] + [\c!corner={\v!right,\v!top},\c!location={\v!left,\v!bottom}] + +\definelayerpreset + [\v!left\v!bottom] + [\c!corner={\v!left,\v!bottom},\c!location={\v!right,\v!top}] + +\definelayerpreset + [\v!right\v!bottom] + [\c!corner={\v!right,\v!bottom},\c!location={\v!left,\v!top}] + +\definelayerpreset + [\v!middle] + [\c!corner=\v!middle,\c!location=\v!middle] + +% \definelayerpreset +% [\v!middle\v!top] +% [\c!location=\v!bottom,\c!hoffset=.5\layerwidth] + +% \definelayerpreset +% [\v!middle\v!bottom] +% [\c!location=\v!top,\c!hoffset=.5\layerwidth,\c!voffset=\layerheight] + +% \definelayerpreset +% [\v!middle\v!left] +% [\c!location=\v!right,\c!voffset=.5\layerheight] + +% \definelayerpreset +% [\v!middle\v!right] +% [\c!location=\v!left,\c!hoffset=\layerwidth,\c!voffset=.5\layerheight] + +\definelayerpreset + [\v!middle\v!top] + [\c!location=\v!bottom,\c!corner=\v!top,\c!dx=.5\layerwidth] + +\definelayerpreset + [\v!middle\v!bottom] + [\c!location=\v!top,\c!corner=\v!bottom,\c!dx=.5\layerwidth] + +\definelayerpreset + [\v!middle\v!left] + [\c!location=\v!right,\c!corner=\v!left,\c!dy=.5\layerheight] + +\definelayerpreset + [\v!middle\v!right] + [\c!location=\v!left,\c!corner=\v!right,\c!dy=.5\layerheight] + +\def\alignedbox + {\dodoubleempty\doalignedbox[]} + +% \def\doalignedbox[#1][#2]% +% {\bgroup +% %\let\iftraceboxplacement\iftracelayers % ugly +% \dowithnextbox +% {\let\next\middlebox +% \processaction +% [#2] +% [ t=>\let\next\topbox , b=>\let\next\bottombox , +% l=>\let\next\leftbox , r=>\let\next\rightbox , +% bl=>\let\next\bottomleftbox,br=>\let\next\bottomrightbox, +% tl=>\let\next\topleftbox ,tr=>\let\next\toprightbox , +% lt=>\let\next\lefttopbox ,lb=>\let\next\leftbottombox , +% rt=>\let\next\righttopbox ,rb=>\let\next\rightbottombox]% +% \next{\flushnextbox}% +% \egroup}#1} + +\def\doalignedbox[#1][#2]% + {\bgroup + %\let\iftraceboxplacement\iftracelayers % ugly + \dowithnextbox + {\serializecommalist[#2]% + \executeifdefined{\??ab\??ab\serializedcommalist}\middlebox{\flushnextbox}% + \egroup}#1} + +\setvalue{\??ab\??ab }{\middlebox} +\setvalue{\??ab\??ab\v!middle }{\middlebox} +\setvalue{\??ab\??ab\v!left }{\leftbox } +\setvalue{\??ab\??ab\v!right }{\rightbox } +\setvalue{\??ab\??ab\v!bottom }{\bottombox} +\setvalue{\??ab\??ab\v!top }{\topbox } + +\setvalue{\??ab\??ab\v!middle\v!middle}{\middlebox} +\setvalue{\??ab\??ab\v!left \v!top }{\lefttopbox} +\setvalue{\??ab\??ab\v!left \v!bottom}{\leftbottombox} +\setvalue{\??ab\??ab\v!right \v!top }{\righttopbox} +\setvalue{\??ab\??ab\v!right \v!bottom}{\rightbottombox} +\setvalue{\??ab\??ab\v!top \v!left }{\topleftbox} +\setvalue{\??ab\??ab\v!bottom\v!left }{\bottomleftbox} +\setvalue{\??ab\??ab\v!top \v!right }{\toprightbox} +\setvalue{\??ab\??ab\v!bottom\v!right }{\bottomrightbox} + +\setvalue{\??ab\??ab c}{\middlebox} +\setvalue{\??ab\??ab l}{\leftbox} +\setvalue{\??ab\??ab r}{\rightbox} +\setvalue{\??ab\??ab b}{\bottombox} +\setvalue{\??ab\??ab t}{\topbox} + +\setvalue{\??ab\??ab lt}{\lefttopbox} +\setvalue{\??ab\??ab lb}{\leftbottombox} +\setvalue{\??ab\??ab rt}{\righttopbox} +\setvalue{\??ab\??ab rb}{\rightbottombox} +\setvalue{\??ab\??ab tl}{\topleftbox} +\setvalue{\??ab\??ab bl}{\bottomleftbox} +\setvalue{\??ab\??ab tr}{\toprightbox} +\setvalue{\??ab\??ab br}{\bottomrightbox} + +\setvalue{\??ab\??ab m}{\middlebox} + +% The next ones were desparately needed by Vit Zyka (see +% \type {supp-box} for definitions). + +\setvalue{\??ab\??ab g}{\baselinemiddlebox} +\setvalue{\??ab\??ab gl}{\baselineleftbox} +\setvalue{\??ab\??ab gc}{\baselinemiddlebox} +\setvalue{\??ab\??ab gr}{\baselinerightbox} + +\setvalue{\??ab\??ab \v!line }{\baselinemiddlebox} % \v!grid is taken +\setvalue{\??ab\??ab \v!line\v!left }{\baselineleftbox} +\setvalue{\??ab\??ab \v!line\v!middle}{\baselinemiddlebox} +\setvalue{\??ab\??ab \v!line\v!right }{\baselinerightbox} + +\def\offsetbox + {\dodoubleempty\dooffsetbox[]} + +% left/right/top/bottomoffset -> dimensions change +% x/y | method=fixed -> dimensions don't change + +\def\dooffsetbox[#1][#2]% + {\bgroup + \dowithnextbox + {\getparameters[\??ox] + [\c!x=\zeropoint, + \c!y=\zeropoint, + \c!width=\nextboxwd, + \c!height=\nextboxht, + \c!depth=\nextboxdp, + \c!location=, + \c!leftoffset=\zeropoint, + \c!rightoffset=\zeropoint, + \c!topoffset=\zeropoint, + \c!bottomoffset=\zeropoint, + \c!method=, + #2]% + \donefalse + \ifdim\@@oxleftoffset =\zeropoint\else\donetrue\fi + \ifdim\@@oxrightoffset=\zeropoint\else\donetrue\fi + \ifdim\@@oxtopoffset =\zeropoint\else\donetrue\fi + \ifdim\@@oxbottomoffset =\zeropoint\else\donetrue\fi + \ifdone + \doif\@@oxmethod\v!fixed % new + {\ifdim\@@oxleftoffset=\zeropoint + \ifdim\@@oxrightoffset=\zeropoint \else + \scratchdimen-\@@oxrightoffset + \edef\@@oxx{\the\scratchdimen}% + \let\@@oxrightoffset\zeropoint + \fi + \else + \let\@@oxx\@@oxleftoffset + \let\@@oxleftoffset\zeropoint + \fi + \ifdim\@@oxtopoffset=\zeropoint + \ifdim\@@oxbottomoffset=\zeropoint \else + \scratchdimen-\@@oxbottomoffset + \edef\@@oxy{\the\scratchdimen}% + \let\@@oxbottomoffset\zeropoint + \fi + \else + \let\@@oxy\@@oxtopoffset + \let\@@oxtopoffset\zeropoint + \fi + \donefalse}% + \fi + \ifdone + \setbox\nextbox\vbox + {\forgetall\offinterlineskip + \vskip\@@oxtopoffset + \hbox + {\hskip\@@oxleftoffset + \flushnextbox + \hskip\@@oxrightoffset}% + \vskip\@@oxbottomoffset}% + \scratchdimen\nextboxht + \advance\scratchdimen\nextboxdp + \nextboxht\scratchdimen + \nextboxdp\zeropoint + \fi + \freezedimenmacro\@@oxwidth + \freezedimenmacro\@@oxheight + \freezedimenmacro\@@oxdepth + \setbox\nextbox\hbox + {\hskip\@@oxx\lower\@@oxy\hbox + {\doifelsenothing\@@oxlocation + {\flushnextbox} + {\alignedbox[\@@oxlocation]\hbox{\flushnextbox}}}}% + \nextboxwd\@@oxwidth + \nextboxht\@@oxheight + \nextboxdp\@@oxdepth + \flushnextbox + \egroup}#1} + +% \useMPlibrary[pre] \setupbackgrounds[page][background=pagegrid] +% +% \placefigure[left,none]{}{\offset[leftoffset=1cm]{\externalfigure[koe][breedte=3cm]}} +% \input tufte +% \placefigure[left,none]{}{\offset[rightoffset=1cm]{\externalfigure[koe][breedte=3cm]}} +% \input tufte +% \placefigure[left,none]{}{\offset[topoffset=1cm]{\externalfigure[koe][breedte=3cm]}} +% \input tufte +% \placefigure[left,none]{}{\offset[bottomoffset=1cm]{\externalfigure[koe][breedte=3cm]}} +% \input tufte + +\def\offset {\dodoubleempty\dooffsetbox [\hbox]} % yes or no +\def\aligned{\dosingleempty\doalignedbox[\hbox]} % yes or no + +%\ruledhbox{\offsetbox[x=-1cm,y=-1cm,location=c] +% {\framed[width=4cm,height=4cm]{x}}} + +\def\dotabbed#1#2#3#4% + {\dontleavehmode + \bgroup + \setbox\scratchbox\hbox{#3}% + \hbox to \wd\scratchbox{#1#4#2}% + \egroup} + +\def\ltabbed{\dotabbed\relax\hss} +\def\rtabbed{\dotabbed\hss \relax} +\def\ctabbed{\dotabbed\hss \hss} \let\mtabbed\ctabbed + +% \ltabbed{\romeins{3}}{\romeins{1}} test \endgraf +% \ltabbed{\romeins{3}}{\romeins{2}} test \endgraf +% \ltabbed{\romeins{3}}{\romeins{3}} test \endgraf +% +% \rtabbed{\romeins{3}}{\romeins{1}} test \endgraf +% \rtabbed{\romeins{3}}{\romeins{2}} test \endgraf +% \rtabbed{\romeins{3}}{\romeins{3}} test \endgraf +% +% \ctabbed{\romeins{3}}{\romeins{1}} test \endgraf +% \ctabbed{\romeins{3}}{\romeins{2}} test \endgraf +% \ctabbed{\romeins{3}}{\romeins{3}} test \endgraf + +% alternative, if done, then other name +% +% \def\dotabbed#1#2#3#4% +% {\dontleavehmode +% \bgroup +% \scratchdimen\zeropoint +% \def\docommand##1% +% {\setbox\scratchbox\hbox{##1}% +% \ifdim\wd\scratchbox>\scratchdimen +% \scratchdimen\wd\scratchbox +% \fi}% +% \processcommalist[#3]\docommand +% \hbox to \scratchdimen{#1#4#2}% +% \egroup} +% +% \def\ltabbed{\dotabbed\relax\hss} +% \def\rtabbed{\dotabbed\hss \relax} +% \def\ctabbed{\dotabbed\hss \hss} \let\mtabbed\ctabbed +% +% \ltabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{10}} test \endgraf +% \ltabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{15}} test \endgraf +% \ltabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{2000}} test \endgraf +% +% \rtabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{10}} test \endgraf +% \rtabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{15}} test \endgraf +% \rtabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{2000}} test \endgraf +% +% \ctabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{10}} test \endgraf +% \ctabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{15}} test \endgraf +% \ctabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{2000}} test \endgraf + +% to be documented + +\def\phantombox[#1]% + {\hbox\bgroup + \getparameters + [\??ol] + [\c!width=\zeropoint,% + \c!height=\zeropoint,% + \c!depth=\zeropoint,#1]% + \setbox\scratchbox\null + \wd\scratchbox\@@olwidth + \ht\scratchbox\@@olheight + \dp\scratchbox\@@oldepth + \box\scratchbox + \egroup} + +% \backgroundimage{1}{\hsize}{\vsize}{\externalfigure[cow][\c!width=3cm]} + +\def\backgroundimage#1#2#3% repeat hsize vsize + {\bgroup + \forgetall + \dowithnextbox + {\offinterlineskip + \ifcase#1\relax + % just one + \else + \scratchdimen#2\divide\scratchdimen\nextboxwd\count0\scratchdimen\advance\count0\plusone + \scratchdimen#3\divide\scratchdimen\nextboxht\count2\scratchdimen\advance\count2\plusone + % to be considered, probably methods + \ifcase#1\or % x and y + \setbox\nextbox\hbox{\dorecurse{\count0}{\copy\nextbox}}% + \setbox\nextbox\vbox{\dorecurse{\count2}{\copy\nextbox\endgraf}}% + \or % x + \setbox\nextbox\hbox{\dorecurse{\count0}{\copy\nextbox}}% + \or % y + \setbox\nextbox\vbox{\dorecurse{\count2}{\copy\nextbox\endgraf}}% + \fi + \fi + \ifdim\nextboxwd>#2\relax + \setbox\nextbox\hbox to #2{\hss\flushnextbox\hss}% + \setbox\nextbox\hbox{\expanded{\clip[\c!width=#2,\c!height=\the\nextboxht]{\flushnextbox}}}% + \fi + \ifdim\nextboxht>#3\relax + \setbox\nextbox\vbox to #3{\vss\flushnextbox\vss}% + \setbox\nextbox\hbox{\expanded{\clip[\c!width=\the\nextboxwd,\c!height=#3]{\flushnextbox}}}% + \fi + \flushnextbox + \egroup}% + \hbox} + +\protect \endinput diff --git a/tex/context/base/page-lyr.tex b/tex/context/base/pack-lyr.mkii index fe542233f..768b1e0c9 100644 --- a/tex/context/base/page-lyr.tex +++ b/tex/context/base/pack-lyr.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=page-lyr, +%D [ file=pack-lyr, %D version=2000.10.20, -%D title=\CONTEXT\ Page Macros, +%D title=\CONTEXT\ Packaging Macros, %D subtitle=Layers, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Page Macros / Layers} +\writestatus{loading}{ConTeXt Packaging Macros / Layers} %D This module is now etex dependent. diff --git a/tex/context/base/pack-lyr.mkiv b/tex/context/base/pack-lyr.mkiv new file mode 100644 index 000000000..768b1e0c9 --- /dev/null +++ b/tex/context/base/pack-lyr.mkiv @@ -0,0 +1,753 @@ +%D \module +%D [ file=pack-lyr, +%D version=2000.10.20, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Layers, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Packaging Macros / Layers} + +%D This module is now etex dependent. + +% todo : first / last / next / +... => page key +% test on left/right box when no doublesided option given +% use \ifcsname instead of doifvalue + +\unprotect + +% When being backgrounds layers get the background offset +% displacement. Should be an option, on by default +% (compatibility). + +% positie=forceer == ja maar dan ook in status=herhaal + +%D The layering mechanism implemented here is independent of +%D the output routine, but future extensions may depend on a +%D more close cooperation. + +%D First we overload a macro from \type {core-rul}. From now on +%D we accept a (optional) argument: the specific layer it +%D will go in. This means that we can move an overlay from one +%D background to the other using the dimensions of the parent. + +%D ! ! ! ! to be documented ! ! ! ! + +\ifx\undefined\defineoverlay \message{loaded to early} \wait \fi + +\def\defineoverlay + {\dotripleempty\dodefineoverlay} + +\def\dodefineoverlay[#1][#2][#3]% overlay [layer] content + {\ifthirdargument + \writestatus{BEWARE}{This (overlay definition) has changed!}% temp + \def\docommand##1{\setvalue{\??ov##1}{\setlayer[#2]{\executedefinedoverlay{##1}{#3}}}} + \else + \def\docommand##1{\setvalue{\??ov##1}{\executedefinedoverlay{##1}{#2}}}% + \fi + \processcommalist[#1]\docommand} + +%D When tracing is turned on, a couple of boxes will +%D show up as well as the reference point. + +\newif\iftracelayers % \tracelayerstrue + +%D This handy constant saved some string memory. + +\def\@@layerbox{@@layerbox} + +%D \macros +%D {definelayer} +%D +%D Each layer gets its own (global) box. This also means that +%D the data that goes into a layer, is typeset immediately. +%D Each layer automatically gets an associated overlay, +%D which can be used in any background assignment. + +% todo : links/rechts + +\def\definelayer + {\dodoubleargument\dodefinelayer} + +\def\dodefinelayer[#1][#2]% \zeropoint ipv \!!zeropoint + {\setuplayer + [#1] + [\c!doublesided=,\c!preset=, + \c!state=\v!start,\c!direction=\v!normal,\c!option=, + \c!x=\zeropoint,\c!y=\zeropoint,\c!position=\v!no, + \c!line=0,\c!column=0, + \c!width=\nextboxwd,\c!height=\nextboxht, + \c!offset=\zeropoint,\c!rotation=, % geen 0 ! + \c!hoffset=\zeropoint,\c!voffset=\zeropoint, + \c!dx=\zeropoint,\c!dy=\zeropoint, + \c!location=rb,\c!position=\v!no,\c!page=, + \c!method=\v!overlay, + \c!sx=1,\c!sy=1,\c!corner=,#2]% + \doifvalue{\??ll#1\c!doublesided}\v!yes + {\dopresetlayerbox{\v!left #1}% + \dopresetlayerbox{\v!right#1}}% + \dopresetlayerbox{#1}% + \defineoverlay[#1][\composedlayer{#1}]} + +\def\dopresetlayerbox#1% + {\ifundefined{\@@layerbox#1}% + \expandafter\newbox\csname\@@layerbox#1\endcsname + \else + \resetlayer[#1]% + \fi} + +%D \macros +%D {setuplayer} +%D +%D After a layer is defined, you can change its +%D characteristics. + +\def\setuplayer + {\dodoubleargument\dosetuplayer} + +\def\dosetuplayer[#1][#2]% + {\def\docommand##1{\getparameters[\??ll##1][#2]}% + \processcommalist[#1]\docommand} + +%D \macros +%D {setlayer} +%D +%D Data is moved into a layer with the following macro. When +%D \type {position} is set, relative positioning is used, with +%D the current point as reference point. Otherwise the topleft +%D corner is used as reference point. +%D +%D \starttyping +%D \setlayer [identifier] [optional parameters] {data} +%D \stoptyping + +\newcount\currentlayerdata + +\let\currentlayerwidth \!!zeropoint +\let\currentlayerheight\!!zeropoint + +\def\setcurrentlayerdimensions + {\dodoubleempty\dosetcurrentlayerdimensions} + +\def\dosetcurrentlayerdimensions[#1][#2]% name left|right + {\edef\currentlayerwidth {\thelayerwidth {#2#1}}% + \edef\currentlayerheight{\thelayerheight{#2#1}}} + +\def\thelayerwidth #1{\the\wd\executeifdefined{\@@layerbox#1}\emptybox} +\def\thelayerheight#1{\the\ht\executeifdefined{\@@layerbox#1}\emptybox} + +\def\setlayer + {\dotripleempty\dosetlayer} + +\def\dosetlayer[#1][#2][#3]% #4 == box do \fi is ok + {\doifelsevalue{\??ll#1\c!state}\v!stop + {\dowithnextbox\donothing\hbox} + {\ifthirdargument + \dodosetlayer[#1][#2][#3]% + \else + \dodosetlayer[#1][][#2]% + \fi}} + +\def\dodosetlayer[#1][#2][#3]% #2 = links/rechts + {\bgroup + \recalculatebackgrounds + \recalculatelogos + \global\advance\currentlayerdata\plusone + \forgetall + \dontcomplain + \doifvalue{\??ll#1\c!option}\v!test\tracelayerstrue + \iftracelayers\traceboxplacementtrue\fi + \dowithnextbox % sneller als aparte macro + {\ifcsname\@@layerbox#1\endcsname % nb: odd/even discard, left/right not + \edef\@@layerloc{#2}% + \ifx\@@layerloc\v!even + \ifodd\realpageno + % discard nextbox + \else + \dododosetlayer[#1][\v!left][#3]% + \fi + \else\ifx\@@layerloc\v!odd + \ifodd\realpageno + \dododosetlayer[#1][\v!right][#3]% + %\else + % discard nextbox + \fi + \else + \dododosetlayer[#1][#2][#3]% + \fi\fi + \else + \writestatus{layer}{unknown layer #1}% + \fi + \egroup}% + \hbox} + +\newbox\layerbox + +\newdimen\@@layerxsiz +\newdimen\@@layerysiz +\newdimen\@@layerxoff +\newdimen\@@layeryoff +\newdimen\@@layerxpos +\newdimen\@@layerypos + +\let\lastlayerxpos\!!zeropoint +\let\lastlayerypos\!!zeropoint +\let\lastlayerwd \!!zeropoint +\let\lastlayerht \!!zeropoint +\let\lastlayerdp \!!zeropoint + +% todo left/right + +\def\setlastlayerpos#1% + {\edef\layerpage{\MPp{lyr:\the\currentlayerdata}}% + \xdef\lastlayerxpos{\the\dimexpr-\MPx{lyr:#1:\layerpage}+\MPx{lyr:\the\currentlayerdata}\relax}% + \xdef\lastlayerypos{\the\dimexpr \MPy{lyr:#1:\layerpage}-\MPy{lyr:\the\currentlayerdata}\relax}} + +\def\definelayerpreset + {\dodoubleargument\dodefinelayerpreset} + +% \def\dodefinelayerpreset[#1][#2]% +% {\setvalue{\??ll\??ll#1}{\dopresetlayer{#2}}} +% +% more fun: \definelayerpreset[whatever][lefttop] + +\def\dodefinelayerpreset[#1][#2]% + {\doifassignmentelse{#2} + {\setvalue{\??ll\??ll#1}{\dopresetlayer{#2}}} + {\setvalue{\??ll\??ll#1}{\getvalue{\??ll\??ll#2}}}} + +\def\dopresetlayer#1#2#3% #1=list #2=tag #3=list + {\getparameters[\??ll#2][#1,#3]} + +\letempty\currentlayer + +\def\layerparameter#1{\csname\??ll\currentlayer#1\endcsname} + +\newdimen\layerwidth +\newdimen\layerheight + +\chardef\@@lacome=1 % LAyerCOnstructionMEthod / temp, will be default + +\def\dododosetlayer[#1][#2][#3]% will be sped up + {% we use the global width, never change this + \def\currentlayer{#1}% + \@@layerxsiz\layerparameter\c!width + \@@layerysiz\layerparameter\c!height + \layerwidth \@@layerxsiz + \layerheight\@@layerysiz + % preroll + \getparameters[\??ll\currentlayer][#3]% + % presets and real roll +% maybe todo: +% \doif{\layerparameter\c!method}\v!fit +% {\@@layerxsiz\thelayerwidth \currentlayer +% \@@layerysiz\thelayerheight\currentlayer +% \layerwidth \@@layerxsiz +% \layerheight\@@layerysiz +% }% + % etc + \executeifdefined{\??ll\??ll\layerparameter\c!preset}\gobbletwoarguments\currentlayer{#3}% + % that was real slow + \doif{\layerparameter\c!position}\v!overlay % slow, use \dosetvalue instead + {\getparameters[\??ll\currentlayer][\c!width=\zeropoint,\c!height=\zeropoint,\c!position=\v!yes]}% + \doifsomething{\layerparameter\c!rotation} + {\setbox\nextbox\hbox + {\rotate % to be checked with new rotation + [\c!location=\v!high,\c!rotation=\layerparameter\c!rotation] + {\flushnextbox}}}% + % no, not local + % \@@layerxsiz\layerparameter\c!width + % \@@layerysiz\layerparameter\c!height + % never change that + \@@layerxpos\layerparameter\c!x + \@@layerypos\layerparameter\c!y + \doifelse{\layerparameter\c!hoffset}\v!max + {\@@layerxoff\@@layerxsiz}{\@@layerxoff\layerparameter\c!hoffset}% + \doifelse{\layerparameter\c!voffset}\v!max + {\@@layeryoff\@@layerysiz}{\@@layeryoff\layerparameter\c!voffset}% + % dx/dy are internal context ones and can be used in preset + \advance\@@layerxoff\dimexpr\layerparameter\c!offset+\layerparameter\c!dx\relax + \advance\@@layeryoff\dimexpr\layerparameter\c!offset+\layerparameter\c!dy\relax + \@@layerxpos\layerparameter\c!sx\@@layerxpos + \@@layerypos\layerparameter\c!sy\@@layerypos + \@@layerxoff\layerparameter\c!sx\@@layerxoff + \@@layeryoff\layerparameter\c!sy\@@layeryoff + \doifelse{\layerparameter\c!position}\v!yes % combine ^ + {\setlastlayerpos{#2\currentlayer}% todo l/r %%%%%%%%%%%% + \@@layerxpos\lastlayerxpos + \@@layerypos\lastlayerypos + \letgvalue{\??ll\currentlayer\layerpage\c!position}\v!yes + \letgvalue{\??ll\currentlayer\c!state}\v!start % needed ? + \setbox\layerbox\vbox to \@@layerysiz + {\hbox to \@@layerxsiz{\xypos{lyr:\the\currentlayerdata}\hss}\vss}} + {\setbox\layerbox\emptybox + \globallet\lastlayerxpos\!!zeropoint + \globallet\lastlayerypos\!!zeropoint + \ExpandBothAfter\doifinset\v!bottom{\layerparameter\c!corner} + {\ifnum\layerparameter\c!line=\zerocount\else % can be < 0 + \setevalue{\??ll\currentlayer\c!line}% + {\the\numexpr-\layerparameter\c!line+\layoutlines+\plusone\relax}% + \fi + \ifdim\@@layerysiz>\zeropoint + \advance\@@layerypos-\@@layerysiz + \@@layerypos-\@@layerypos + \@@layeryoff-\@@layeryoff + \fi}% + \ExpandBothAfter\doifinset\v!right{\layerparameter\c!corner} + {\ifnum\layerparameter\c!column=\zerocount\else % can be < 0 + \setevalue{\??ll\currentlayer\c!column}% + {\the\numexpr-\layerparameter\c!column+\layoutcolumns+\plusone\relax}% + \fi + \ifdim\@@layerxsiz>\zeropoint + \advance\@@layerxpos-\@@layerxsiz + \@@layerxpos-\@@layerxpos + \@@layerxoff-\@@layerxoff + \fi}% + \ExpandBothAfter\doif\v!middle{\layerparameter\c!corner} + {\ifdim\@@layerxsiz>\zeropoint \advance\@@layerxpos.5\@@layerxsiz \fi + \ifdim\@@layerysiz>\zeropoint \advance\@@layerypos.5\@@layerysiz \fi}% + \edef\layerpage{\layerparameter\c!page}}% + \doifsomething\layerpage + {\edef\layerpage{:\layerpage}% + \doifundefined{\@@layerbox#2\currentlayer\layerpage} + {\global\expandafter\newbox\csname\@@layerbox#2\currentlayer\layerpage\endcsname}}% + \dontcomplain % more comfortable + \mathchardef\layerpagebox\csname\@@layerbox#2\currentlayer\layerpage\endcsname + \ifvoid\layerpagebox + \gsetboxllx\layerpagebox\zeropoint + \gsetboxlly\layerpagebox\zeropoint + \fi + \global\setbox\layerpagebox\vbox %to \layerparameter\c!height % new, otherwise no negative y possible + {\offinterlineskip + %postpone, to after nextboxwd correction % \hsize\layerparameter\c!width % new, keep box small + %\ifvoid\csname\@@layerbox\currentlayer\layerpage\endcsname\else % why not #2#1 + \ifvoid\layerpagebox + \let\lastlayerwidth \zeropoint + \let\lastlayerheight\zeropoint + \else + \edef\lastlayerwidth {\the\wd\layerpagebox}% + \edef\lastlayerheight{\the\ht\layerpagebox}% + \ht\layerpagebox\zeropoint + \dp\layerpagebox\zeropoint + \wd\layerpagebox\zeropoint + \doifnot{\layerparameter\c!direction}\v!reverse{\box\layerpagebox}% + \fi + % don't move + \xdef\lastlayerwd{\the\nextboxwd}% + \xdef\lastlayerht{\the\nextboxht}% % not entirely ok when grid ! + \xdef\lastlayerdp{\the\nextboxdp}% % not entirely ok when grid ! + % this code + \doifelse{\layerparameter\c!location}\v!grid\donetrue\donefalse + \ifdone + \nextboxht\strutheight + \nextboxdp\strutdepth + \else + \setbox\nextbox\hbox{\alignedbox[\layerparameter\c!location]\vbox{\flushnextbox}}% + \fi + \ifnum\layerparameter\c!line=\zerocount\else % no \ifcase, can be negative + \advance\@@layerypos\dimexpr\layerparameter\c!line\lineheight+\topskip-\lineheight-\nextboxht\relax + \fi + \ifnum\layerparameter\c!column=\zerocount\else % no \ifcase, can be negative + \advance\@@layerxpos\layoutcolumnoffset{\layerparameter\c!column}% + \fi + \ifdone + \setbox\nextbox\hbox{\alignedbox[rb]\vbox{\flushnextbox}}% + \fi + % ll registration + \scratchdimen\@@layerxpos + \advance\scratchdimen\@@layerxoff + \ifdim\scratchdimen<\getboxllx\layerpagebox + \gsetboxllx\layerpagebox\scratchdimen + \fi + \ifcase\@@lacome\or % this test will become obsolete + \advance\scratchdimen\nextboxwd + \nextboxwd\ifdim\scratchdimen>\lastlayerwidth \scratchdimen \else \lastlayerwidth \fi + \fi + \scratchdimen\@@layerypos + \advance\scratchdimen\@@layeryoff + \ifdim\scratchdimen<\getboxlly\layerpagebox + \gsetboxlly\layerpagebox\scratchdimen + \fi + % ll compensation + \ifcase\@@lacome\or % this test will become obsolete + \advance\scratchdimen\dimexpr\nextboxht+\nextboxdp\relax + \nextboxht\ifdim\scratchdimen>\lastlayerheight \scratchdimen \else \lastlayerheight \fi + \nextboxdp\zeropoint + \fi + % placement + \hsize\layerparameter\c!width % new, keep box small + \vbox to \layerparameter\c!height \bgroup + \smashbox\nextbox + \vskip\dimexpr\@@layerypos+\@@layeryoff\relax + \hskip\dimexpr\@@layerxpos+\@@layerxoff\relax + \flushnextbox + \ifvoid\layerpagebox + % already flushed + \else + % the reverse case % check ! + \vskip-\dimexpr\@@layerypos+\@@layeryoff\relax + \box\layerpagebox + \fi + \egroup}% + % when position is true, the layerbox holds the compensation and needs + % to be placed; never change this ! + \ifvoid\layerbox\else\box\layerbox\fi} + +%D Given the task to be accomplished, the previous macro is +%D not even that complicated. It mainly comes down to skipping +%D to the right place and placing a box on top of or below the +%D existing content. In the case of position tracking, another +%D reference point is chosen. + +%D \macros +%D {doifelselayerdata} +%D + +\def\doifelselayerdata#1% + {\ifundefined{\@@layerbox#1}% + \@EA\secondoftwoarguments + \else\ifvoid\csname\@@layerbox#1\endcsname + \@EAEAEA\secondoftwoarguments + \else + \@EAEAEA\firstoftwoarguments + \fi\fi} + +%D \macros +%D {flushlayer} +%D +%D When we flush a layer, we flush both the main one and the +%D page dependent one (when defined). This feature is more +%D efficient in \ETEX\ since there testing for an undefined +%D macro does not takes hash space. + +% todo: setups before flush, handy hook + +\unexpanded\def\flushlayer[#1]% + {\doifelsevalue{\??ll#1\c!state}\v!next + {\global\letvalue{\??ll#1\c!state}\v!start} % dangerous, stack-built-up + {\doifelsevalue{\??ll#1\c!state}\v!continue + {\global\letvalue{\??ll#1\c!state}\v!repeat} % dangerous, stack-built-up + {\doifelsevalue{\??ll#1\c!doublesided}\v!yes + {\doifundefinedelse{\@@layerbox#1}% + {\dodoflushlayerA[#1]} + {\doifbothsidesoverruled + {\dodoflushlayerB\v!left [#1]}% left + {\dodoflushlayerB\v!right[#1]}% right + {\dodoflushlayerB\v!left [#1]}}}% left + {\dodoflushlayerA[#1]}}}} + +\def\dodoflushlayerA[#1]% + {\doifnotvalue{\??ll#1\c!state}\v!stop + {\startoverlay + {\dodoflushlayer1{#1}{#1}} + {\dodoflushlayer0{#1}{#1:\realfolio}} + \stopoverlay}} + +\def\dodoflushlayerB#1[#2]% + {\doifnotvalue{\??ll#2\c!state}\v!stop + {\startoverlay + {\dodoflushlayer1{#2}{#2}} + {\dodoflushlayer0{#2}{#2:\realfolio}} + {\dodoflushlayer1{#2}{#1#2}} + {\dodoflushlayer0{#2}{#1#2:\realfolio}} + \stopoverlay}} + +\def\dodoflushlayer#1#2#3% + {\ifundefined{\@@layerbox#3}% + \ifcase#1\else\writestatus{layer}{unknown layer #3}\fi + \else + \bgroup + \forgetall + \offinterlineskip + % needed because we need to handle method + \executeifdefined{\??ll\??ll\getvalue{\??ll#2\c!preset}}\gobbletwoarguments{#2}{}% + % + \doifvalue{\??ll#2\c!option}\v!test\tracelayerstrue + \iftracelayers\traceboxplacementtrue\fi + \!!doneafalse + \!!donebfalse + \doifvalue{\??ll#2\c!method}\v!overlay\!!doneatrue + \doifvalue{\??ll#2\c!method}\v!fit\!!donebtrue + \!!donectrue + \ifcase#1\else + \doifnotvalue{\??ll#2\c!position}\v!yes + {\doifvalue{\??ll#2\c!repeat}\v!yes\!!donecfalse + \doifvalue{\??ll#2\c!state}\v!repeat\!!donecfalse}% + \fi + \mathchardef\layerbox\csname\@@layerbox#3\endcsname + % we need to copy in order to retain the negative offsets for a next + % stage of additions, i.e. llx/lly accumulate in repeat mode and the + % compensation may differ each flush depending on added content + \setbox\nextbox \if!!doneb +% \vbox +% {\scratchdimen\getboxlly\layerbox +% \vskip-\scratchdimen +% \scratchdimen\getboxllx\layerbox +% \hskip-\scratchdimen +% \advance\scratchdimen-\wd\layerbox +% \hsize-\scratchdimen +% \if!!donec\box\else\copy\fi\layerbox}% + \vbox + {\vskip-\getboxlly\layerbox + \hskip-\getboxllx\layerbox + \hsize-\dimexpr\getboxllx\layerbox-\wd\layerbox\relax + \if!!donec\box\else\copy\fi\layerbox}% + \else + \if!!donec\box\else\copy\fi\layerbox % sorry for the delay due to copying + \fi + % todo: method=offset => overlayoffset right/down (handy for backgrounds with offset) + \iftracelayers \ruledvbox \else \vbox \fi \if!!donea to \overlayheight \fi + {\hbox \if!!donea to \overlaywidth \fi + {% klopt dit? #3 en niet #2 ? + \doifvalue{\??ll#3\realfolio\c!position}\v!yes{\xypos{lyr:#3:\realfolio}}% + \doifoverlayelse{#3} + {\box\nextbox} + {\startlayoutcomponent{l:#3}{layer #3}\box\nextbox\stoplayoutcomponent}% + \hss}% + \vss}% + \if!!donec + \gsetboxllx\layerbox\zeropoint + \gsetboxlly\layerbox\zeropoint + \fi + \egroup + \fi} + +% \definelayer[test][method=fit] \setupcolors[state=start] \tracelayerstrue +% +% \framed[framecolor=red,offset=overlay]{\setlayer[test]{aa}\setlayer[test][x=10pt]{g}\flushlayer[test]} +% \framed[framecolor=red,offset=overlay]{\setlayer[test]{aa}\setlayer[test][x=-10pt]{bb}\flushlayer[test]} +% \framed[framecolor=red,offset=overlay]{\setlayer[test][x=-20pt]{cccccc}\flushlayer[test]} +% \framed[framecolor=red,offset=overlay]{\setlayer[test]{dd}\setlayer[test][x=-20pt,y=-3pt]{eeeeee}\flushlayer[test]} + +%D \macros +%D {composedlayer,placelayer,tightlayer} +%D +%D This is a handy shortcut, which saves a couple of braces +%D when we use it as parameter. This name also suits better +%D to other layering commands. + +\def\composedlayer#1{\flushlayer[#1]} + +\let\placelayer\flushlayer + +\def\tightlayer[#1]% + {\hbox + {\def\currentlayer{#1}% todo: left/right + \setbox\nextbox\emptybox % hoogte/breedte are \wd\nextbox/\ht\nextbox + \hsize\layerparameter\c!width % \overlaywidth = \hsize + \vsize\layerparameter\c!height % \overlaywheight = \vsize + \composedlayer{#1}}} + +%D \macros +%D {resetlayer} +%D +%D This macro hardly needs an explanation (and is seldom +%D needed as well). + +\def\doresetlayer#1% + {\ifundefined{\@@layerbox#1}\else + \global\setbox\csname\@@layerbox#1\endcsname\emptybox + \fi} + +\def\resetlayer[#1]% + {\doresetlayer{#1}% + \doifvalue{\??ll#1\c!doublesided}\v!yes % kind of redundant test + {\doresetlayer{\v!left #1}% + \doresetlayer{\v!right#1}}% + \doresetlayer{#1:\realfolio}} + +%D \macros +%D {setMPlayer} +%D +%D The following layer macro uses the positions that are +%D registered by \METAPOST. +%D +%D \starttyping +%D \definelayer[test] +%D +%D \setMPlayer [test] [somepos-1] {Whatever we want here!} +%D \setMPlayer [test] [somepos-2] {Whatever we need there!} +%D \setMPlayer [test] [somepos-3] {\externalfigure[cow.mps][width=2cm]} +%D +%D \startuseMPgraphic{oeps} +%D draw fullcircle scaled 10cm withcolor red ; +%D register ("somepos-1",2cm,3cm,center currentpicture) ; +%D register ("somepos-2",8cm,5cm,(-1cm,-2cm)) ; +%D register ("somepos-3",0cm,0cm,(-2cm,2cm)) ; +%D \stopuseMPgraphic +%D +%D \getMPlayer[test]{\useMPgraphic{oeps}} +%D \stoptyping +%D +%D The last line is equivalent to +%D +%D \starttyping +%D \framed +%D [background={foreground,test},offset=overlay] +%D {\useMPgraphic{oeps}} +%D \stoptyping + +\def\setMPlayer + {\dotripleempty\dosetMPlayer} + +\def\MPlayerwidth {\hsize} +\def\MPlayerheight{\vsize} + +\def\dosetMPlayer[#1][#2][#3]% + {\checkpositions % new, else only support after \starttext + \edef\MPlayerwidth {\MPw{#2}}% + \edef\MPlayerheight{\MPh{#2}}% + \setlayer[#1][\c!x=\MPx{#2},\c!y=\MPy{#2},\c!position=\v!no,#3]} + +\def\getMPlayer + {\dodoubleempty\dogetMPlayer} + +\def\dogetMPlayer[#1][#2]% + {\framed + [\c!background={\v!foreground,#1}, + \c!frame=\v!off, + \c!offset=\v!overlay,#2]} + +% Some day this (old) mechanism will be combined/integrated +% in overlays + +\newskip\xposition \newskip\yposition +\newskip\xdimension \newskip\ydimension +\newskip\xoffset \newskip\yoffset + +% already defined \newbox\positionbox + +\def\startpositioning + {\bgroup + \xposition \zeropoint \yposition \zeropoint + \xdimension\zeropoint \ydimension\zeropoint + \xoffset \zeropoint \yoffset \zeropoint + \hfuzz \paperwidth \vfuzz \paperheight + \setbox\positionbox\hbox\bgroup} + +\def\stoppositioning + {\doifnot\@@psoffset\v!yes + {\global\xoffset\zeropoint + \global\yoffset\zeropoint}% + \global\advance\xdimension \xoffset + \global\advance\ydimension \yoffset + \egroup + \vbox to \ydimension + {\vskip\yoffset + \hbox to \xdimension + {\hskip\xoffset + \box\positionbox + \hfill} + \vfill}% + \egroup} + +\def\resetpositioning + {\getparameters[\??ps] + [\c!state=\v!start,% + \c!unit=\s!cm,% + \c!factor=1,% + \c!scale=1,% + \c!xfactor=\@@psfactor,% + \c!yfactor=\@@psfactor,% + \c!xscale=\@@psscale,% + \c!yscale=\@@psscale,% + \c!xstep=\v!absolute,% + \c!ystep=\v!absolute,% + \c!xoffset=\!!zeropoint,% + \c!yoffset=\!!zeropoint]} + +\def\setuppositioning + {\resetpositioning + \dodoubleargument\getparameters[\??ps]} + +\def\calculateposition#1#2#3#4#5#6#7#8#9% + {\setdimensionwithunit\scratchskip{#1}\@@psunit + \scratchskip#8\scratchskip + \scratchskip#9\scratchskip + \advance\scratchskip #4\relax + \doif{#2}\v!relative + {\advance\scratchskip #3% + \let#4\!!zeropoint}% + #3\scratchskip\relax + \doifnot\@@psstate\v!overlay + {\scratchskip#5\relax + \advance\scratchskip #3\relax + \ifdim#3<-#7\relax \global#7-#3\relax \fi + \ifdim\scratchskip>#6\relax \global#6\scratchskip\relax \fi}} + +\def\position + {\dosingleempty\doposition} + +\def\doposition[#1]#2(#3,#4)% + {\dowithnextbox + {\bgroup + \getparameters[\??ps][#1]% + \dontcomplain + \calculateposition{#3}\@@psxstep\xposition + \@@psxoffset{\nextboxwd}\xdimension\xoffset + \@@psxscale\@@psxfactor + \scratchdimen\nextboxht \advance\scratchdimen \nextboxdp + \calculateposition{#4}\@@psystep\yposition + \@@psyoffset\scratchdimen\ydimension\yoffset + \@@psyscale\@@psyfactor + \vbox to \zeropoint % kan beter. + {\vskip\yposition + \hbox to \zeropoint + {\hskip\xposition + \flushnextbox + \hss} + \vss}% + \xdef\dopoppositioning + {\xposition\the\xposition + \yposition\the\yposition + \noexpand\def\noexpand\@@psxoffset{\@@psxoffset}% + \noexpand\def\noexpand\@@psyoffset{\@@psyoffset}}% + \egroup + \dopoppositioning + \ignorespaces} + \hbox} + +\resetpositioning + +\setuppositioning + [\c!unit=\s!cm, + \c!factor=1, + \c!scale=1, + \c!xstep=\v!absolute, + \c!ystep=\v!absolute, + \c!offset=\v!yes, + \c!xoffset=\!!zeropoint, + \c!yoffset=\!!zeropoint] + +%D Watch out, a redefinition: + +\ifx\settextpagecontent\undefined \writestatus\m!systems{error in page-lyr.tex} \wait \fi + +\let\normalsettextpagecontent\settextpagecontent + +\definelayer + [OTRTEXT] + +\setuplayer + [OTRTEXT] + [\c!width=\innermakeupwidth, + \c!height=\textheight] + +% will be overloaded in page-spr + +\def\settextpagecontent#1#2#3% #2 and #3 will disappear + {\doifelselayerdata{OTRTEXT} + {\setbox#1\hbox to \makeupwidth + {\startoverlay + {\tightlayer[OTRTEXT]} % first, otherwise problems with toc + {\normalsettextpagecontent{#1}{#2}{#3}\box#1} + \stopoverlay}% + \dp#1\zeropoint}% + {\normalsettextpagecontent{#1}{#2}{#3}}} + +\protect \endinput diff --git a/tex/context/base/core-obj.lua b/tex/context/base/pack-obj.lua index f879ddc8c..3256b3702 100644 --- a/tex/context/base/core-obj.lua +++ b/tex/context/base/pack-obj.lua @@ -1,6 +1,6 @@ -if not modules then modules = { } end modules ['core-obj'] = { +if not modules then modules = { } end modules ['pack-obj'] = { version = 1.001, - comment = "companion to core-obj.tex", + comment = "companion to pack-obj.tex", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" diff --git a/tex/context/base/core-obj.mkii b/tex/context/base/pack-obj.mkii index 6e210a0ab..6971ad04f 100644 --- a/tex/context/base/core-obj.mkii +++ b/tex/context/base/pack-obj.mkii @@ -1,8 +1,8 @@ %D \module -%D [ file=core-obj, +%D [ file=pack-obj, %D version=1998.01.15, -%D title=\CONTEXT\ Core Macros, -%D subtitle=Object Handling, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Objects, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA / Hans Hagen \& Ton Otten}] @@ -13,7 +13,7 @@ % todo, move more to mkiv, get rid of blabelgroup -\writestatus{loading}{ConTeXt Core Macros / Object Handling} +\writestatus{loading}{ConTeXt Packaging Macros / Objects} \unprotect diff --git a/tex/context/base/core-obj.mkiv b/tex/context/base/pack-obj.mkiv index 560a7012d..6c1e54758 100644 --- a/tex/context/base/core-obj.mkiv +++ b/tex/context/base/pack-obj.mkiv @@ -1,8 +1,8 @@ %D \module -%D [ file=core-obj, +%D [ file=pack-obj, %D version=1998.01.15, -%D title=\CONTEXT\ Core Macros, -%D subtitle=Object Handling, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Objects, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA / Hans Hagen \& Ton Otten}] @@ -11,13 +11,13 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Object Handling} +\writestatus{loading}{ConTeXt Packaging Macros / Objects} \unprotect \let\objectreference\gobblefourarguments % catch mkii tuo stuff -\registerctxluafile{core-obj}{1.001} +\registerctxluafile{pack-obj}{1.001} %D \macros %D {setobject,getobject,ifinobject} diff --git a/tex/context/base/core-rul.lua b/tex/context/base/pack-rul.lua index 6947c7f7b..11995bfed 100644 --- a/tex/context/base/core-rul.lua +++ b/tex/context/base/pack-rul.lua @@ -1,6 +1,6 @@ -if not modules then modules = { } end modules ['core-rul'] = { +if not modules then modules = { } end modules ['pack-rul'] = { version = 1.001, - comment = "companion to core-rul.tex", + comment = "companion to pack-rul.tex", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" diff --git a/tex/context/base/core-rul.mkii b/tex/context/base/pack-rul.mkii index 59bfd2f3c..042e8805d 100644 --- a/tex/context/base/core-rul.mkii +++ b/tex/context/base/pack-rul.mkii @@ -1,8 +1,8 @@ %D \module -%D [ file=core-rul, +%D [ file=pack-rul, % was core-rul, %D version=1998.10.16, -%D title=\CONTEXT\ Core Macros, -%D subtitle=Ruled Stuff Handling, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Ruled Content, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA / Hans Hagen \& Ton Otten}] @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Ruled Content Handling} +\writestatus{loading}{ConTeXt Packaging Macros / Ruled Content} \unprotect diff --git a/tex/context/base/core-rul.mkiv b/tex/context/base/pack-rul.mkiv index 78c7156b8..574175dde 100644 --- a/tex/context/base/core-rul.mkiv +++ b/tex/context/base/pack-rul.mkiv @@ -1,8 +1,8 @@ %D \module -%D [ file=core-rul, +%D [ file=pack-rul, % was core-rul, %D version=1998.10.16, -%D title=\CONTEXT\ Core Macros, -%D subtitle=Ruled Stuff Handling, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Ruled Content, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA / Hans Hagen \& Ton Otten}] @@ -11,13 +11,13 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Ruled Content Handling} +\writestatus{loading}{ConTeXt Packaging Macros / Ruled Content} %D After a few months testing this solution is now added %D to the core. This introduces a possible incompatibility %D between \MKII\ and \MKIV\ but for the better. -\registerctxluafile{core-rul}{1.001} +\registerctxluafile{pack-rul}{1.001} % old off new % 4 lines oeps : 3.6 2.8 3.0 diff --git a/tex/context/base/pret-lua.lua b/tex/context/base/pret-lua.lua new file mode 100644 index 000000000..81e02c360 --- /dev/null +++ b/tex/context/base/pret-lua.lua @@ -0,0 +1,259 @@ +if not modules then modules = { } end modules ['pret-lua'] = { + version = 1.001, + comment = "companion to buff-ver.tex", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local utf = unicode.utf8 + +local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues +local utfbyte, utffind = utf.byte, utf.find +local byte, sub, find, match = string.byte, string.sub, string.find, string.match +local texsprint, texwrite = tex.sprint, tex.write +local ctxcatcodes = tex.ctxcatcodes + +buffers.visualizers.lua = buffers.visualizers.lua or { } +buffers.visualizers.lua.identifiers = buffers.visualizers.lua.identifiers or { } + +-- borrowed from scite + +buffers.visualizers.lua.identifiers.core = { + "and", "break", "do", "else", "elseif", "end", "false", "for", "function", + "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", + "true", "until", "while" +} + +buffers.visualizers.lua.identifiers.base = { + "assert", "collectgarbage", "dofile", "error", "gcinfo", "loadfile", + "loadstring", "print", "rawget", "rawset", "require", "tonumber", + "tostring", "type", "unpack", +} + +buffers.visualizers.lua.identifiers.five = { + "_G", "getfenv", "getmetatable", "ipairs", "loadlib", "next", "pairs", + "pcall", "rawequal", "setfenv", "setmetatable", "xpcall", "string", "table", + "math", "coroutine", "io", "os", "debug", "load", "module", "select" +} + +buffers.visualizers.lua.identifiers.libs = { + -- coroutine + "coroutine.create", "coroutine.resume", "coroutine.status", "coroutine.wrap", + "coroutine.yield", "coroutine.running", + -- package + "package.cpath", "package.loaded", "package.loadlib", "package.path", + -- io + "io.close", "io.flush", "io.input", "io.lines", "io.open", "io.output", + "io.read", "io.tmpfile", "io.type", "io.write", "io.stdin", "io.stdout", + "io.stderr", "io.popen", + -- math + "math.abs", "math.acos", "math.asin", "math.atan", "math.atan2", "math.ceil", + "math.cos", "math.deg", "math.exp", "math.floor math.", "math.ldexp", + "math.log", "math.log10", "math.max", "math.min math.mod math.pi", "math.pow", + "math.rad", "math.random", "math.randomseed", "math.sin", "math.sqrt", + "math.tan", "math.cosh", "math.fmod", "math.modf", "math.sinh", "math.tanh", + "math.huge", + -- string + "string.byte", "string.char", "string.dump", "string.find", "string.len", + "string.lower", "string.rep", "string.sub", "string.upper", "string.format", + "string.gfind", "string.gsub", "string.gmatch", "string.match", "string.reverse", + -- table + "table.maxn", "table.concat", "table.foreach", "table.foreachi", "table.getn", + "table.sort", "table.insert", "table.remove", "table.setn", + -- os + "os.clock", "os.date", "os.difftime", "os.execute", "os.exit", "os.getenv", + "os.remove", "os.rename", "os.setlocale", "os.time", "os.tmpname", + -- package + "package.preload", "package.seeall" +} + +local known_words = { } + +for k,v in pairs(buffers.visualizers.lua.identifiers) do + for _,w in pairs(v) do + known_words[w] = k + end +end + +buffers.visualizers.lua.styles = { + core = "", + base = "\\sl ", + five = "\\sl ", + libs = "\\sl ", +} + +local styles = buffers.visualizers.lua.styles + +local colors = { + "prettyone", + "prettytwo", + "prettythree", + "prettyfour", +} + +local states = { + ['"']=1, ["'"]=1, ["[["] = 1, ["]]"] = 1, + ['+']=1, ['-']=1, ['*']=1, ['/']=1, ['%']=1, ['^']=1, + ["("] = 3, [")"] = 3, ["["] = 3, ["]"] = 3, + ['--']=4, +} + +local change_state, finish_state = buffers.change_state, buffers.finish_state + +local function flush_lua_word(state, word) + if word then + local id = known_words[word] + if id then + state = change_state(2,state) + if styles[id] then + texsprint(ctxcatcodes,styles[id]) + end + texwrite(word) + state = finish_state(state) + else + state = finish_state(state) -- ? + texwrite(word) + end + else + state = finish_state(state) + end + return state +end + +local incomment, inlongstring = false, false + +function buffers.visualizers.lua.reset() + incomment, inlongstring = false, false -- needs to be hooked into flusher +end + +-- we will also provide a proper parser based pretty printer although normaly +-- a pretty printer should handle faulty code too (educational purposes) + +function buffers.visualizers.lua.flush_line(str, nested) + local state, instr, inesc, word = 0, false, false, nil + buffers.currentcolors = colors + local code, comment = match(str,"^(.-)%-%-%[%[(.*)$") + if comment then + -- process the code and then flush the comment + elseif incomment then + comment, code = match(str,"^(.-)%]%](.*)$") + if comment then + -- flush the comment and then process the code + for c in utfcharacters(comment) do + if c == " " then texsprint(ctxcatcodes,"\\obs") else texwrite(c) end + end + state = change_state(states['--'], state) + texwrite("]]") + state = finish_state(state) + incomment = false + else + for c in utfcharacters(str) do + if c == " " then texsprint(ctxcatcodes,"\\obs") else texwrite(c) end + end + end + comment = nil + else + code = str + end + if code and code ~= "" then + local pre, post = match(code,"^(.-)%-%-(.*)$") + if pre then + code = pre + end + local p, s = nil, nil + for c in utfcharacters(code) do + if c == "[" then + if p == "[" then + inlongstring = true + state = change_state(states["[["],state) + texwrite(p,c) + state = finish_state(state) + p = nil + else + p = c + end + elseif c == "]" then + if p == "]" then + inlongstring = false + state = change_state(states["]]"],state) + texwrite(p,c) + state = finish_state(state) + p = nil + else + p = c + end + else + if p then + state = change_state(states[c],state) + texwrite(p,c) + state = finish_state(state) + p = nil + end + if c == " " then + if word then + state = flush_lua_word(state,word) + word = nil + end + texsprint(ctxcatcodes,"\\obs") + elseif inlongstring then + texwrite(c) + elseif instr then + if c == s then + if inesc then + texwrite(c) + inesc = false + else + state = change_state(states[c],state) + instr = false + texwrite(c) + state = finish_state(state) + end + s = nil + else + if c == "\\" then + inesc = not inesc + else + inesc = false + end + texwrite(c) + end + elseif c == '"' or c == "'" then + instr = true + state = change_state(states[c],state) + texwrite(c) + state = finish_state(state) + s = c + elseif find(c,"^[%a]$") then + state = finish_state(state) + if word then word = word .. c else word = c end + elseif word and (#word > 1) and find(c,"^[%d%.%_]$") then + if word then word = word .. c else word = c end + else + state = flush_lua_word(state,word) + word = nil + state = change_state(states[c],state) + texwrite(c) + instr = (c == '"') + end + end + end + state = flush_lua_word(state,word) + if post then + state = change_state(states['--'], state) + texwrite("--") + state = finish_state(state) + for c in utfcharacters(post) do + if c == " " then texsprint(ctxcatcodes,"\\obs") else texwrite(c) end + end + end + end + if comment then + incomment = true + state = change_state(states['--'], state) + texwrite("[[") + state = finish_state(state) + texwrite(comment) + end + state = finish_state(state) +end diff --git a/tex/context/base/verb-mp.lua b/tex/context/base/pret-mp.lua index 4ff957b41..c4904e2d4 100644 --- a/tex/context/base/verb-mp.lua +++ b/tex/context/base/pret-mp.lua @@ -1,18 +1,20 @@ --- filename : type-mp.lua --- comment : companion to core-buf.tex --- author : Hans Hagen, PRAGMA-ADE, Hasselt NL --- copyright: PRAGMA ADE / ConTeXt Development Team --- license : see context related readme files +if not modules then modules = { } end modules ['pret-mp'] = { + version = 1.001, + comment = "companion to buff-ver.tex", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} local utf = unicode.utf8 local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues +local utfbyte, utffind = utf.byte, utf.find +local texsprint, texwrite = tex.sprint, tex.write +local ctxcatcodes = tex.ctxcatcodes -if not buffers then buffers = { } end -if not buffers.visualizers then buffers.visualizers = { } end -if not buffers.visualizers.mp then buffers.visualizers.mp = { } end - -buffers.visualizers.mp.identifiers = { } +buffers.visualizers.mp = buffers.visualizers.mp or { } +buffers.visualizers.mp.identifiers = buffers.visualizers.mp.identifiers or { } buffers.visualizers.mp.identifiers.primitives = { 'charcode', 'day', 'linecap', 'linejoin', 'miterlimit', 'month', 'pausing', @@ -91,6 +93,7 @@ buffers.visualizers.mp.identifiers.metafun = { 'lltriangle', 'lrtriangle', 'urtriangle', 'ultriangle', 'smoothed', 'cornered', 'superellipsed', 'randomized', 'squeezed', 'punked', 'curved', 'unspiked', 'simplified', 'blownup', 'stretched', + 'paralled', 'enlonged', 'shortened', 'enlarged', 'leftenlarged', 'topenlarged', 'rightenlarged', 'bottomenlarged', 'llenlarged', 'lrenlarged', 'urenlarged', 'ulenlarged', 'llmoved', 'lrmoved', 'urmoved', 'ulmoved', @@ -104,68 +107,71 @@ buffers.visualizers.mp.identifiers.metafun = { 'loadfigure', 'externalfigure' } -buffers.visualizers.mp.words = { } - -for k,v in pairs(buffers.visualizers.mp.identifiers) do - for _,w in pairs(v) do - buffers.visualizers.mp.words[w] = k - end -end - -buffers.visualizers.mp.styles = { } +buffers.visualizers.mp.styles = buffers.visualizers.mp.styles or { + primitives = "", + plain = "\\sl", + metafun = "\\sl", +} -buffers.visualizers.mp.styles.primitives = "" -buffers.visualizers.mp.styles.plain = "\\sl " -buffers.visualizers.mp.styles.metafun = "\\sl " +local styles = buffers.visualizers.mp.styles -- btex .. etex -buffers.visualizers.mp.colors = { +local colors = { "prettyone", "prettytwo", "prettythree", "prettyfour", } -buffers.visualizers.mp.states = { +local states = { [';']=1, ['$']=1, ['@']=1, ['#']=1, ['\\']=2, - ['(']=3, [')']=3, ['[']=3, [']']=3, [':']=3, ['=']=3, ['<']=3, ['>']=3, + ['(']=3, [')']=3, ['[']=3, [']']=3, [':']=3, ['=']=3, ['<']=3, ['>']=3, ['"']=3, ['-']=4, ['+']=4, ['/']=4, ['*']=4, ['|']=4, ['`']=4, ['!']=4, ['?']=4, ['^']=4, ['&']=4, ['%']=4, ['%']=4, ['.']=4, [',']=4 } -function buffers.flush_mp_word(state, word, intex, result) - if #word>0 then +local known_words = { } + +for k,v in pairs(buffers.visualizers.mp.identifiers) do + for _,w in pairs(v) do + known_words[w] = k + end +end + +local change_state, finish_state = buffers.change_state, buffers.finish_state + +local function flush_mp_word(state, word, intex) + if word then if intex then if word == 'etex' then - state = buffers.change_state(2, state, result) - result[#result+1] = word - state = buffers.finish_state(state,result) + state = change_state(2,state) + texwrite(word) + state = finish_state(state) return state, false else - result[#result+1] = word + texwrite(word) return state, true end else - local id = buffers.visualizers.mp.words[word] + local id = known_words[word] if id then - state = buffers.change_state(2, state, result) - if buffers.visualizers.mp.styles[id] then - result[#result+1] = buffers.visualizers.mp.styles[id] .. word - else - result[#result+1] = word + state = change_state(2,state) + if styles[id] then + texsprint(ctxcatcodes,styles[id]) end - state = buffers.finish_state(state,result) + texwrite(word) + state = finish_state(state) return state, (word == 'btex') or (word == 'verbatimtex') else - state = buffers.finish_state(state,result) - result[#result+1] = word + state = finish_state(state) + texwrite(word) return state, intex end end else - state = buffers.finish_state(state,result) + state = finish_state(state) return state, intex end end @@ -175,64 +181,55 @@ end -- to be considered: visualizer => table [result, instr, incomment, word] -function buffers.visualizers.mp.flush_line_(str,nested) - local result, state, word = { }, 0, "" - local instr, intex, incomment = false, false, false - local byte, find = utf.byte, utf.find - local finish, change = buffers.finish_state, buffers.change_state - buffers.currentcolors = buffers.visualizers.mp.colors +function buffers.visualizers.mp.flush_line(str,nested) + local state, word, instr, intex, incomment = 0, nil, false, false, false + buffers.currentcolors = colors for c in utfcharacters(str) do - if incomment then - result[#result+1] = buffers.escaped_chr(c) + if c == " " then + state, intex = flush_mp_word(state, word, intex) + word = nil + texsprint(ctxcatcodes,"\\obs") + elseif incomment then + texwrite(c) elseif c == '%' then - state = change(buffers.visualizers.mp.states[c], state, result) + state = change_state(states[c], state) incomment = true - result[#result+1] = "\\char" .. byte(c) .. " " - state = finish(state,result) + texwrite(c) + state = finish_state(state) elseif instr then if c == '"' then - state = change(buffers.visualizers.mp.states[c], state, result) + state = change_state(states[c],state) instr = false - result[#result+1] = "\\char" .. byte(c) .. " " - state = finish(state,result) - elseif find(c,"^[%a%d]$") then - result[#result+1] = c + texwrite(c) + state = finish_state(state) else - result[#result+1] = "\\char" .. byte(c) .. " " + texwrite(c) end - elseif c == " " then - state, intex = buffers.flush_mp_word_(state, word, intex, result) - word = "" - result[#result+1] = "\\obs " elseif intex then - if find(c,"^[%a]$") then - word = word .. c + if utffind(c,"^[%a]$") then + if word then word = word .. c else word = c end else - state, intex = buffers.flush_mp_word_(state, word, intex, result) - word = "" + state, intex = flush_mp_word(state, word, intex) + word = nil if intex then - if find(c,"^[%d]$") then - result[#result+1] = c - else - result[#result+1] = "\\char" .. byte(c) .. " " - end + texwrite(c) else - state = change(buffers.visualizers.mp.states[c], state, result) - result[#result+1] = "\\char" .. byte(c) .. " " + state = change_state(states[c], state) + texwrite(c) end end - elseif find(c,"^[%a]$") then - state = finish(state,result) - word = word .. c + elseif utffind(c,"^[%a]$") then + state = finish_state(state) + if word then word = word .. c else word = c end else - state, intex = buffers.flush_mp_word_(state, word, intex, result) - word = "" - state = change(buffers.visualizers.mp.states[c], state, result) - result[#result+1] = "\\char" .. byte(c) .. " " + state, intex = flush_mp_word(state, word, intex) + word = nil + state = change_state(states[c], state) + texwrite(c) + state = finish_state(state) instr = (c == '"') end end - state, intex = buffers.flush_mp_word_(state, word, intex, result) - state = finish(state,result) - buffers.flush_result(result,false) + state, intex = flush_mp_word(state, word, intex) + state = finish_state(state) end diff --git a/tex/context/base/pret-tex.lua b/tex/context/base/pret-tex.lua new file mode 100644 index 000000000..7b3c116a5 --- /dev/null +++ b/tex/context/base/pret-tex.lua @@ -0,0 +1,85 @@ +if not modules then modules = { } end modules ['pret-tex'] = { + version = 1.001, + comment = "companion to buff-ver.tex", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local utf = unicode.utf8 + +local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues +local utfbyte, utffind = utf.byte, utf.find +local rep = string.rep +local texsprint, texwrite = tex.sprint, tex.write +local ctxcatcodes, vrbcatcodes = tex.ctxcatcodes, tex.vrbcatcodes + +buffers.visualizers.tex = { } + +local colors = { + "prettytwo", + "prettyone", + "prettythree", + "prettyfour" +} + +local states = { + ['$']=2, ['{']=2, ['}']=2, + ['[']=3, [']']=3, ['(']=3, [')']=3, ['<']=3, ['>']=3, ['#']=3, ['=']=3, ['"']=3, + ['/']=4, ['^']=4, ['_']=4, ['-']=4, ['&']=4, ['+']=4, ["'"]=4, ['`']=4, ['|']=4, ['%']=4 +} + +-- some day I'll make an lpeg + +local change_state, finish_state = buffers.change_state, buffers.finish_state + +local chardata = characters.data +local is_letter = characters.is_letter + +function buffers.visualizers.tex.flush_line(str,nested) + local state, first = 0, false + buffers.currentcolors = colors + for c in utfcharacters(str) do + if c == " " then + state = finish_state(state) + texsprint(ctxcatcodes,"\\obs") + first = false + elseif c == "\t" then + state = finish_state(state) + texsprint(ctxcatcodes,"\\obs") + if buffers.visualizers.enabletab then + texsprint(ctxcatcodes,rep("\\obs ",i%buffers.visualizers.tablength)) + end + first = false + elseif first then + state = 1 + texwrite(c) + if not utffind(c,"^[%a%!%?%@]$") then + state = finish_state(state) + end + first = false + elseif state == 1 then + if utffind(c,"^[%a%!%?%@]$") then + texwrite(c) + first = false + elseif c == "\\" then + state = change_state(1, state) + texwrite(c) + first = true + else + state = change_state(states[c], state) + texwrite(c) + first = false + end + elseif c == "\\" then + first = true + state = change_state(1, state) + texwrite(c) + else + state = change_state(states[c], state) + texwrite(c) + first = false + end + end + state = finish_state(state) +end diff --git a/tex/context/base/s-abr-01.tex b/tex/context/base/s-abr-01.tex index f7665177d..8c2f6ebab 100644 --- a/tex/context/base/s-abr-01.tex +++ b/tex/context/base/s-abr-01.tex @@ -314,7 +314,12 @@ \def\NEWPAGE {\SystemSpecialB{newpage}} \def\NEWLINE {\SystemSpecialB{newline}} -\def\THANH {H\`an Th\^e\llap{\raise 0.5ex\hbox{\'{}}} Th\`anh} + +\doifmodeelse {mkiv} { + \def\THANH{Han The Thanh} % todo +} { + \def\THANH{H\`an Th\^e\llap{\raise 0.5ex\hbox{\'{}}} Th\`anh} +} %def\THANH {H\`an Th\ecircumflexacute\ Th\`anh} diff --git a/tex/context/base/core-fld.mkii b/tex/context/base/scrn-fld.mkii index 2b177c916..60511ac2b 100644 --- a/tex/context/base/core-fld.mkii +++ b/tex/context/base/scrn-fld.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-fld, +%D [ file=scrn-fld, %D version=1997.05.18, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Screen Macros, %D subtitle=Fields, %D author=Hans Hagen, %D date=\currentdate, @@ -20,7 +20,7 @@ % internal string truncated, (3) second time truncated % string is sent. -\writestatus{loading}{ConTeXt Core Macros / Fields} +\writestatus{loading}{ConTeXt Screen Macros / Fields} % messages diff --git a/tex/context/base/core-fld.mkiv b/tex/context/base/scrn-fld.mkiv index 96ecf6b54..604b675c0 100644 --- a/tex/context/base/core-fld.mkiv +++ b/tex/context/base/scrn-fld.mkiv @@ -1,7 +1,7 @@ %D \module -%D [ file=core-fld, +%D [ file=scrn-fld, %D version=1997.05.18, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Screen Macros, %D subtitle=Fields, %D author=Hans Hagen, %D date=\currentdate, @@ -20,7 +20,7 @@ % internal string truncated, (3) second time truncated % string is sent. -\writestatus{loading}{ConTeXt Core Macros / Fields} +\writestatus{loading}{ConTeXt Screen Macros / Fields} % messages diff --git a/tex/context/base/core-hlp.tex b/tex/context/base/scrn-hlp.mkii index 46b469b68..c9fcbd29a 100644 --- a/tex/context/base/core-hlp.tex +++ b/tex/context/base/scrn-hlp.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-hlp, +%D [ file=scrn-hlp, %D version=1998.10.10, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Screen Macros, %D subtitle=Help (Experimental), %D author={Hans Hagen \& Ton Otten}, %D date=\currentdate, @@ -13,6 +13,8 @@ % todo : dedicated vide/hide voor helps +\writestatus{loading}{ConTeXt Screen Macros / Help popups} + %D This is an experimental and private module, so the interface %D and functionality can change. Pieces of code will be moved %D to other modules. More features are possible but will be diff --git a/tex/context/base/scrn-hlp.mkiv b/tex/context/base/scrn-hlp.mkiv new file mode 100644 index 000000000..c9fcbd29a --- /dev/null +++ b/tex/context/base/scrn-hlp.mkiv @@ -0,0 +1,171 @@ +%D \module +%D [ file=scrn-hlp, +%D version=1998.10.10, +%D title=\CONTEXT\ Screen Macros, +%D subtitle=Help (Experimental), +%D author={Hans Hagen \& Ton Otten}, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +% todo : dedicated vide/hide voor helps + +\writestatus{loading}{ConTeXt Screen Macros / Help popups} + +%D This is an experimental and private module, so the interface +%D and functionality can change. Pieces of code will be moved +%D to other modules. More features are possible but will be +%D interfaces later. See m-chart for an application as well +%D as the second tno-tpd manual (graphic in margin, click +%D on it, pop up big one, use menu with hides, as well as +%D background, etc. etc. + +\unprotect + +\defineframedtext + [\v!helptext] + +\setupframedtexts + [\v!helptext] + [\c!width=.75\textwidth, + \c!align=\v!normal, + \c!frame=\v!off, + \c!background=\v!screen] + +\newcounter \nofhelpdataentries +\newconditional \somehelpdatadefined + +\appendtoks \getpagehelpdata \to \beforeeverypage +\appendtoks \synchronizepagehelpdata \to \aftereverypage + +% will be proper state variable + +\let\pagehelpdata\empty + +\def\dontresetpagedata + {\let\synchronizepagehelpdata\relax} + +\def\resetpagehelpdata + {\iflocation + \let\synchronizepagehelpdata\resetpagehelpdata + \global\let\pagehelpdata\empty + \resetreference[HideHelp]% + \fi} + +\let\synchronizepagehelpdata\resetpagehelpdata + +\resetreference[HideHelp] + +\def\getpagehelpdata + {\iflocation\ifcase\nofhelpdataentries\else + \let\pagehelpdata\empty + \ifconditional\somehelpdatadefined + \definetwopasslist{hlp:\realfolio}% + \doloop + {\gettwopassdata{hlp:\realfolio}% + \iftwopassdatafound + \addtocommalist\twopassdata\pagehelpdata + \else + \exitloop + \fi}% + \fi + \ifx\pagehelpdata\empty \else + \useJSscripts[fld]% + \definereference[HideHelp][JS(Hide_Fields)]% for the moment + \fi + \fi\fi} + +\def\setpagehelpdata[#1]% + {\iflocation\expanded{\dosetpagehelpdata{#1}}\fi} + +\def\dosetpagehelpdata#1% + {\doglobal\increment\nofhelpdataentries + \savetwopassdata{hlp:\realfolio}{\nofhelpdataentries}{#1}} + +\setvalue{\e!start\v!helptext}[#1]% + {\iflocation + \global\settrue\somehelpdatadefined + \setvalue{\e!stop\v!helptext}% + %{\definesymbol[helpinfo:#1][{\doframedtext[\v!helptext]{\getbuffer[\v!helptext]}}]% + % \dopresetfieldsymbol{helpinfo:#1}}% + {\definesymbol[\v!helptext:#1][{\doframedtext[\v!helptext]{\getbuffer[\v!helptext]}}]% + \dopresetfieldsymbol{\v!helptext:#1}}% + \else + \letvalue{\e!stop\v!helptext}\relax + \fi + \dostartbuffer[\v!helptext][\e!start\v!helptext][\e!stop\v!helptext]} + +\long\def\helptext[#1]#2% + {\iflocation + \global\settrue\somehelpdatadefined + %\definesymbol[helpinfo:#1][{\doframedtext[\v!helptext]{#2}}]% + %\dopresetfieldsymbol{helpinfo:#1}% + \definesymbol[\v!helptext:#1][{\doframedtext[\v!helptext]{#2}}]% + \dopresetfieldsymbol{\v!helptext:#1}% + \fi} + +\let\definehelptext\helptext % for backward compabilities sake + +\def\dohelpdata#1% + {\setbox\scratchbox\hbox + {\startoverlay + {\box\scratchbox} + %{\definemainfield[help:#1][check][helpsetup][helpinfo:#1][helpinfo:#1]% + {\definemainfield[help:#1][check][helpsetup][\v!helptext:#1][\v!helptext:#1]% + \fitfield[help:#1]} + \stopoverlay}} + +\def\helpdata + {\iflocation + \bgroup + %\getpagehelpdata + \ifx\pagehelpdata\empty \else + \setupfields[\v!reset]% + \setupfield + [helpsetup] + [\c!width=\v!fit, + \c!height=\v!fit, + \c!frame=\v!off, + \c!clickin=JS(Hide_Fields), + \c!option={\v!readonly,\v!hidden}]% + \setbox\scratchbox\emptybox + \processcommacommand[\pagehelpdata]\dohelpdata + \box\scratchbox + \fi + \egroup + \fi} + +\def\helpbutton % also gobble spaces between [][] + {\dodoubleempty\dohelpbutton} + +\def\dohelpbutton + {\ifsecondargument + \expandafter\donohelpbutton + \else + \expandafter\dodohelpbutton + \fi} + +\def\dodohelpbutton[#1][#2]#3[#4]% #2 is space gobbling dummy + {\iflocation + \setpagehelpdata[#4]% + \useJSscripts[fld]% + \button[#1]{#3}[JS(Vide_Hide_Fields{help:#4})]% + \fi} + +\def\donohelpbutton[#1][#2]% + {\dodohelpbutton[#1][]{}[#2]} + +\def\doifhelpinfo#1#2% + {\iflocation + \doifsymboldefinedelse{helpinfo:#1}{#2}\donothing + \fi} + +\def\doifelsehelpinfo#1#2#3% + {\iflocation + \doifsymboldefinedelse{helpinfo:#1}{#2}{#3}% + \fi} + +\protect \endinput diff --git a/tex/context/base/core-int.mkii b/tex/context/base/scrn-int.mkii index 1ca9d23d1..38d50a350 100644 --- a/tex/context/base/core-int.mkii +++ b/tex/context/base/scrn-int.mkii @@ -1,5 +1,5 @@ %D \module -%D [ file=core-int, +%D [ file=scrn-int, %D version=1995.01.01, %D title=\CONTEXT\ Core Macros, %D subtitle=Interaction, @@ -15,7 +15,7 @@ %D Still to be done properly. -\writestatus{loading}{ConTeXt Core Macros / Interaction} +\writestatus{loading}{ConTeXt Screen Macros / Interaction} \unprotect diff --git a/tex/context/base/core-int.mkiv b/tex/context/base/scrn-int.mkiv index d02881801..e47f5745e 100644 --- a/tex/context/base/core-int.mkiv +++ b/tex/context/base/scrn-int.mkiv @@ -1,5 +1,5 @@ %D \module -%D [ file=core-int, +%D [ file=scrn-int, %D version=1995.01.01, %D title=\CONTEXT\ Core Macros, %D subtitle=Interaction, @@ -15,7 +15,7 @@ %D Still to be done properly. -\writestatus{loading}{ConTeXt Core Macros / Interaction} +\writestatus{loading}{ConTeXt Screen Macros / Interaction} \unprotect diff --git a/tex/context/base/core-nav.mkii b/tex/context/base/scrn-nav.mkii index f4594ab3b..591d4134c 100644 --- a/tex/context/base/core-nav.mkii +++ b/tex/context/base/scrn-nav.mkii @@ -1,5 +1,5 @@ %D \module -%D [ file=core-nav, +%D [ file=scrn-nav, %D version=1998.01.15, %D title=\CONTEXT\ Core Macros, %D subtitle=Navigation, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Navigation} +\writestatus{loading}{ConTeXt Screen Macros / Navigation} \unprotect diff --git a/tex/context/base/core-nav.mkiv b/tex/context/base/scrn-nav.mkiv index e079f5f08..441951eff 100644 --- a/tex/context/base/core-nav.mkiv +++ b/tex/context/base/scrn-nav.mkiv @@ -1,7 +1,7 @@ %D \module -%D [ file=core-nav, +%D [ file=scrn-nav, %D version=1998.01.15, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Screen Macros, %D subtitle=Navigation, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Navigation} +\writestatus{loading}{ConTeXt Screen Macros / Navigation} \unprotect diff --git a/tex/context/base/scrp-ini.tex b/tex/context/base/scrp-ini.mkiv index 3382ef4b6..3382ef4b6 100644 --- a/tex/context/base/scrp-ini.tex +++ b/tex/context/base/scrp-ini.mkiv diff --git a/tex/context/base/strc-bkm.tex b/tex/context/base/strc-bkm.mkiv index dd6352356..9298a9d8e 100644 --- a/tex/context/base/strc-bkm.tex +++ b/tex/context/base/strc-bkm.mkiv @@ -11,6 +11,8 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +%D This might become scrn-bkm.mkiv. + \writestatus{loading}{ConTeXt Structure Macros / Bookmarks} \registerctxluafile{strc-bkm}{1.001} diff --git a/tex/context/base/core-blk.tex b/tex/context/base/strc-blk.mkii index b224bf18e..c4e38a607 100644 --- a/tex/context/base/core-blk.tex +++ b/tex/context/base/strc-blk.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-blk, % split off core-buf.tex +%D [ file=strc-blk, % split off core-buf.tex %D version=2000.01.05, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Blockmoves, %D author=Hans Hagen, %D date=\currentdate, @@ -13,7 +13,7 @@ % investigate etex's \readline and \scantokens -\writestatus{loading}{ConTeXt Core Macros / Blockmoves} +\writestatus{loading}{ConTeXt Structure Macros / Blockmoves} \unprotect diff --git a/tex/context/base/strc-blk.tex b/tex/context/base/strc-blk.mkiv index 90d2ff9ab..90d2ff9ab 100644 --- a/tex/context/base/strc-blk.tex +++ b/tex/context/base/strc-blk.mkiv diff --git a/tex/context/base/strc-def.tex b/tex/context/base/strc-def.mkiv index f24ee2023..f24ee2023 100644 --- a/tex/context/base/strc-def.tex +++ b/tex/context/base/strc-def.mkiv diff --git a/tex/context/base/core-des.tex b/tex/context/base/strc-des.mkii index dc7136c40..0c34e9ef9 100644 --- a/tex/context/base/core-des.tex +++ b/tex/context/base/strc-des.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-des, +%D [ file=strc-des, %D version=1997.03.31, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Descriptions, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Descriptions} +\writestatus{loading}{ConTeXt Structure Macros / Descriptions} %D In order to be more flexible with theorems Aditya Mahajan added %D support for titles and endsymbols. At the same time we some more diff --git a/tex/context/base/strc-des.tex b/tex/context/base/strc-des.mkiv index 1b196974a..eb7d7a6bc 100644 --- a/tex/context/base/strc-des.tex +++ b/tex/context/base/strc-des.mkiv @@ -967,30 +967,6 @@ \setupenumerations [\c!location=\v!top, -% \c!headstyle=\v!bold, -% \c!titlestyle=\v!bold, -% \c!style=\v!normal, -% \c!headcolor=, -% \c!titlecolor=, -% \c!color=, -% \c!width=8em, -% \c!distance=0pt, -% \c!titledistance=0.5em, -% \c!hang=, -% \c!sample=, -% \c!align=, -% \c!margin=\v!no, -% \c!before=\blank, -% \c!inbetween=\blank, -% \c!after=\blank, -% \c!indentnext=\v!yes, -% \c!indenting=\v!never, -% \c!titleleft=(, -% \c!titleright=), -% \c!closesymbol=, -% \c!closecommand=\wordright, -% \c!command=, -% \c!titlecommand=, \c!text=, \c!way=\v!by\v!text, \c!prefixconnector=., diff --git a/tex/context/base/strc-doc.lua b/tex/context/base/strc-doc.lua index e0df8294a..cc8f46f6c 100644 --- a/tex/context/base/strc-doc.lua +++ b/tex/context/base/strc-doc.lua @@ -465,10 +465,10 @@ function sections.typesetnumber(entry,kind,...) -- kind='section','number','pref if ownnumber ~= "" then processors.sprint(ctxcatcodes,ownnumber) -- elseif conversion and conversion ~= "" then - -- tex.sprint(ctxcatcodes,format("\\convertnumber{%s}{%s}",conversion,number)) + -- texsprint(ctxcatcodes,format("\\convertnumber{%s}{%s}",conversion,number)) elseif conversion and conversion ~= "" then -- traditional (e.g. used in itemgroups) - tex.sprint(ctxcatcodes,format("\\convertnumber{%s}{%s}",conversion,number)) + texsprint(ctxcatcodes,format("\\convertnumber{%s}{%s}",conversion,number)) else local theconversion = sets.get("structure:conversions",block,conversion,index,"numbers") processors.sprint(ctxcatcodes,theconversion,function(str) diff --git a/tex/context/base/strc-doc.tex b/tex/context/base/strc-doc.mkiv index e76e015a9..e76e015a9 100644 --- a/tex/context/base/strc-doc.tex +++ b/tex/context/base/strc-doc.mkiv diff --git a/tex/context/base/page-flt.tex b/tex/context/base/strc-flt.mkii index 91cb25e6b..e64a439ec 100644 --- a/tex/context/base/page-flt.tex +++ b/tex/context/base/strc-flt.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=page-flt, +%D [ file=strc-flt, %D version=2000.10.20, -%D title=\CONTEXT\ Page Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Floating Bodies, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Page Macros / Floating Bodies} +\writestatus{loading}{ConTeXt Structure Macros / Float Numbering} %D Some of the sidefloat settings should move to page-sid; now it's quite %D fuzzy the way the variables are set/reset. @@ -22,22 +22,6 @@ \def\placefloats{\doflushfloats} % keep this one -% messages moved - -% messages moved - -% messages moved - -% messages moved - -% messages moved - -% messages moved - -% messages moved - -% messages moved - \def\floatparameter #1{\csname\??fl\currentfloat#1\endcsname} \def\floatcaptionparameter#1{\csname\??kj\currentfloat#1\endcsname} diff --git a/tex/context/base/strc-flt.tex b/tex/context/base/strc-flt.mkiv index b0ff9893b..b0ff9893b 100644 --- a/tex/context/base/strc-flt.tex +++ b/tex/context/base/strc-flt.mkiv diff --git a/tex/context/base/strc-ini.tex b/tex/context/base/strc-ini.mkiv index 619442998..619442998 100644 --- a/tex/context/base/strc-ini.tex +++ b/tex/context/base/strc-ini.mkiv diff --git a/tex/context/base/core-itm.tex b/tex/context/base/strc-itm.mkii index 406f9d1e4..0148f83ca 100644 --- a/tex/context/base/core-itm.tex +++ b/tex/context/base/strc-itm.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-itm, % updated +%D [ file=strc-itm, % updated %D version=1997.03.31, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=itemgroups, %D author=Hans Hagen, %D date=\currentdate, @@ -14,23 +14,7 @@ % new: text + lefttext=(,righttext=) % start= -\writestatus{loading}{ConTeXt Core Macros / Itemgroups} - -% messages moved - -% messages moved - -% messages moved - -% messages moved - -% messages moved - -% messages moved - -% messages moved - -% messages moved +\writestatus{loading}{ConTeXt Structure Macros / Itemgroups} \unprotect diff --git a/tex/context/base/strc-itm.tex b/tex/context/base/strc-itm.mkiv index dd639d72b..dd639d72b 100644 --- a/tex/context/base/strc-itm.tex +++ b/tex/context/base/strc-itm.mkiv diff --git a/tex/context/base/core-lst.tex b/tex/context/base/strc-lst.mkii index 84648f6c9..527966354 100644 --- a/tex/context/base/core-lst.tex +++ b/tex/context/base/strc-lst.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-lst, +%D [ file=strc-lst, %D version=1997.03.31, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Lists, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Lists} +\writestatus{loading}{ConTeXt Structure Macros / Lists} \unprotect diff --git a/tex/context/base/strc-lst.tex b/tex/context/base/strc-lst.mkiv index 22c189c77..22c189c77 100644 --- a/tex/context/base/strc-lst.tex +++ b/tex/context/base/strc-lst.mkiv diff --git a/tex/context/base/core-mar.tex b/tex/context/base/strc-mar.mkii index 8096793ad..62e6f4ded 100644 --- a/tex/context/base/core-mar.tex +++ b/tex/context/base/strc-mar.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-mar, +%D [ file=strc-mar, %D version=1997.03.31, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Markings, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Markings} +\writestatus{loading}{ConTeXt Structure Macros / Markings} \unprotect diff --git a/tex/context/base/strc-mar.tex b/tex/context/base/strc-mar.mkiv index 8dbbb232c..8dbbb232c 100644 --- a/tex/context/base/strc-mar.tex +++ b/tex/context/base/strc-mar.mkiv diff --git a/tex/context/base/core-mat.tex b/tex/context/base/strc-mat.mkii index 21f4e60b8..342f3f3fb 100644 --- a/tex/context/base/core-mat.tex +++ b/tex/context/base/strc-mat.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-mat, +%D [ file=strc-mat, %D version=2006.03.27, % 1998.12.07 -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Math Fundamentals, %D author={Hans Hagen, Taco Hoekwater \& Aditya Mahajan}, %D date=\currentdate, @@ -13,7 +13,7 @@ % engels maken -\writestatus{loading}{ConTeXt Core Macros / Math Fundamentals} +\writestatus{loading}{ConTeXt Structure Macros / Math Fundamentals} \unprotect diff --git a/tex/context/base/strc-mat.tex b/tex/context/base/strc-mat.mkiv index 482426b48..482426b48 100644 --- a/tex/context/base/strc-mat.tex +++ b/tex/context/base/strc-mat.mkiv diff --git a/tex/context/base/strc-not.lua b/tex/context/base/strc-not.lua index 78e7b6acd..115de7b9d 100644 --- a/tex/context/base/strc-not.lua +++ b/tex/context/base/strc-not.lua @@ -44,7 +44,8 @@ function notes.store(tag,n) nd[#nd+1] = n local state = notestates[tag] if state.kind ~= "insert" then - state.start = #nd +--~ state.start = #nd + state.start = state.start or #nd end tex.write(#nd) end @@ -102,7 +103,7 @@ end function notes.getstate(tag) local state = notestates[tag] - texsprint((state and state.kind ) or "unknown") + texsprint(ctxcatcodes,(state and state.kind ) or "unknown") end function notes.doifcontent(tag) diff --git a/tex/context/base/core-not.tex b/tex/context/base/strc-not.mkii index 70d3f8627..40e06c9a4 100644 --- a/tex/context/base/core-not.tex +++ b/tex/context/base/strc-not.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-not, +%D [ file=strc-not, %D version=2002.05.10, % 1997.09.15 -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Note Handling, % Footnote Handling %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Note Handling} +\writestatus{loading}{ConTeXt Structure Macros / Note Handling} %D Unfortunately we cannot force an even number of lines in %D a two column footnote placement. diff --git a/tex/context/base/strc-not.tex b/tex/context/base/strc-not.mkiv index ca0d3c0a4..7dc998451 100644 --- a/tex/context/base/strc-not.tex +++ b/tex/context/base/strc-not.mkiv @@ -929,7 +929,7 @@ \def\dodoplacenotes#1#2% settings note {\edef\currentnote{#2}% - \doifelse{\ctxlua{structure.notes.getstate("#1")}}{store} + \doifelse{\ctxlua{structure.notes.getstate("#2")}}{store} \dodoplacelocalnotes \dodoplaceglobalnotes {#1}{#2}} diff --git a/tex/context/base/core-num.tex b/tex/context/base/strc-num.mkii index a86ce8a1d..28f69b441 100644 --- a/tex/context/base/core-num.tex +++ b/tex/context/base/strc-num.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-num, +%D [ file=strc-num, %D version=1997.03.31, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Numbering, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Numbering} +\writestatus{loading}{ConTeXt Structure Macros / Numbering} \unprotect diff --git a/tex/context/base/strc-num.tex b/tex/context/base/strc-num.mkiv index 8b723575b..82558cd61 100644 --- a/tex/context/base/strc-num.tex +++ b/tex/context/base/strc-num.mkiv @@ -291,9 +291,19 @@ \setupnumbering [\c!way=\v!by\v!chapter, \c!blockway=, - \c!sectionnumber=\v!yes, \c!state=\v!start] +\def\numberingparameter#1{\csname\??nr#1\endcsname} + +% \c!prefixconnector=., +% \c!stopper=, + +% \c!prefix=\v!no, +% \c!prefixconnector=., +% \c!way=bychapter, +% \c!prefixsegments=2:2, + + %D Helpers: % call: diff --git a/tex/context/base/page-num.tex b/tex/context/base/strc-pag.mkii index 95eeea806..5a86a99e8 100644 --- a/tex/context/base/page-num.tex +++ b/tex/context/base/strc-pag.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=page-num, % moved here from main-001 +%D [ file=strc-num, % moved here from main-001 %D version=1997.03.31, -%D title=\CONTEXT\ Page Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Numbering, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Page Macros / Numbering} +\writestatus{loading}{ConTeXt Structure Macros / Numbering} % todo: {}{}{} ipv ...--...-...-...--... in pag ref diff --git a/tex/context/base/strc-pag.tex b/tex/context/base/strc-pag.mkiv index 2b7c3fc21..2b7c3fc21 100644 --- a/tex/context/base/strc-pag.tex +++ b/tex/context/base/strc-pag.mkiv diff --git a/tex/context/base/strc-prc.tex b/tex/context/base/strc-prc.mkiv index a81cfddd1..a81cfddd1 100644 --- a/tex/context/base/strc-prc.tex +++ b/tex/context/base/strc-prc.mkiv diff --git a/tex/context/base/core-ref.tex b/tex/context/base/strc-ref.mkii index 8ca0a92bf..d06319d07 100644 --- a/tex/context/base/core-ref.tex +++ b/tex/context/base/strc-ref.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-ref, +%D [ file=strc-ref, %D version=1998.01.15, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Cross Referencing, %D author=Hans Hagen, %D date=\currentdate, @@ -13,7 +13,7 @@ % we will merge mkii code back in here -\writestatus{loading}{ConTeXt Core Macros / Cross Referencing} +\writestatus{loading}{ConTeXt Structure Macros / Cross Referencing} % todo : unknown/illegal reference no arg % todo : +n pages check on 'samepage' (contrastcolor) diff --git a/tex/context/base/strc-ref.tex b/tex/context/base/strc-ref.mkiv index 23fc3e01e..23fc3e01e 100644 --- a/tex/context/base/strc-ref.tex +++ b/tex/context/base/strc-ref.mkiv diff --git a/tex/context/base/core-reg.tex b/tex/context/base/strc-reg.mkii index 1d139a2dc..8d824bd9d 100644 --- a/tex/context/base/core-reg.tex +++ b/tex/context/base/strc-reg.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-reg, +%D [ file=strc-reg, %D version=1999.12.27, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Register Management, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Register Management} +\writestatus{loading}{ConTeXt Structure Macros / Register Management} \newif \ifautoregisterhack % for the moment a private hack diff --git a/tex/context/base/strc-reg.tex b/tex/context/base/strc-reg.mkiv index b764525e1..b764525e1 100644 --- a/tex/context/base/strc-reg.tex +++ b/tex/context/base/strc-reg.mkiv diff --git a/tex/context/base/strc-ren.tex b/tex/context/base/strc-ren.mkiv index c2b8ffd83..c2b8ffd83 100644 --- a/tex/context/base/strc-ren.tex +++ b/tex/context/base/strc-ren.mkiv diff --git a/tex/context/base/strc-sbe.tex b/tex/context/base/strc-sbe.mkiv index de7c2af63..de7c2af63 100644 --- a/tex/context/base/strc-sbe.tex +++ b/tex/context/base/strc-sbe.mkiv diff --git a/tex/context/base/core-sec.tex b/tex/context/base/strc-sec.mkii index 6cc0fbbf9..ef85d1e7a 100644 --- a/tex/context/base/core-sec.tex +++ b/tex/context/base/strc-sec.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-sec, +%D [ file=strc-sec, %D version=1997.03.31, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Sectioning, %D author=Hans Hagen, %D date=\currentdate, @@ -23,7 +23,7 @@ % in manual (zie prikkels) : tussen=\blanko is enige hook om % met kop-in-hoofd een spatiering af te dwingen -\writestatus{loading}{ConTeXt Core Macros / Sectioning} +\writestatus{loading}{ConTeXt Structure Macros / Sectioning} \unprotect diff --git a/tex/context/base/strc-sec.tex b/tex/context/base/strc-sec.mkiv index a45564c43..a45564c43 100644 --- a/tex/context/base/strc-sec.tex +++ b/tex/context/base/strc-sec.mkiv diff --git a/tex/context/base/core-swd.tex b/tex/context/base/strc-swd.mkii index ade3e6caa..4a71b8781 100644 --- a/tex/context/base/core-swd.tex +++ b/tex/context/base/strc-swd.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-swd, +%D [ file=strc-swd, %D version=2007.08.14, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Section Worlds, %D author=Hans Hagen, %D date=\currentdate, @@ -19,6 +19,8 @@ % \startsectionworld[chapter][text={Test}] % \stopsectionworld +\writestatus{loading}{ConTeXt Structure Macros / Sectionworlds} + \unprotect \ifx\pushvalue\undefined diff --git a/tex/context/base/core-syn.tex b/tex/context/base/strc-syn.mkii index b5c87c487..39acb7d91 100644 --- a/tex/context/base/core-syn.tex +++ b/tex/context/base/strc-syn.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-syn, +%D [ file=strc-syn, %D version=1997.03.31, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Structure Macros, %D subtitle=Synonyms and Sorts, %D author=Hans Hagen, %D date=\currentdate, @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{ConTeXt Core Macros / Synonyms and Sorts} +\writestatus{loading}{ConTeXt Structure Macros / Synonyms and Sorts} \unprotect diff --git a/tex/context/base/strc-syn.tex b/tex/context/base/strc-syn.mkiv index a739be902..a739be902 100644 --- a/tex/context/base/strc-syn.tex +++ b/tex/context/base/strc-syn.mkiv diff --git a/tex/context/base/strc-xml.tex b/tex/context/base/strc-xml.mkiv index 04c5e71b8..04c5e71b8 100644 --- a/tex/context/base/strc-xml.tex +++ b/tex/context/base/strc-xml.mkiv diff --git a/tex/context/base/syst-aux.tex b/tex/context/base/syst-aux.mkiv index 3b9d6803f..c6a7c2499 100644 --- a/tex/context/base/syst-aux.tex +++ b/tex/context/base/syst-aux.mkiv @@ -2307,22 +2307,22 @@ %D replace the more general version by alternatives tuned for %D speed. -\def\dosingleempty#1% +\def\dosingleempty#1% we can make dedicated doifnextoptional's {\noshowargumenterror % \relax % prevents lookahead, brr \doifnextoptionalelse - {\firstargumenttrue#1} + {\firstargumenttrue#1}% {\dosinglefakeempty#1}} \def\dodoubleempty#1% {\noshowargumenterror % \relax % prevents lookahead, brr \doifnextoptionalelse - {\dodoubletestempty#1} + {\dodoubletestempty#1}% {\dodoublefakeempty#1}} \def\dotripleempty#1% {\noshowargumenterror % \relax % prevents lookahead, brr \doifnextoptionalelse - {\dotripletestempty#1} + {\dotripletestempty#1}% {\dotriplefakeempty#1}} \def\dosinglefakeempty#1% @@ -2337,20 +2337,20 @@ \long\def\dodoubletestempty#1[#2]% {\firstargumenttrue \doifnextoptionalelse - {\secondargumenttrue #1[{#2}]} + {\secondargumenttrue #1[{#2}]}% {\secondargumentfalse#1[{#2}][]}} \long\def\dotripletestempty#1[#2]% {\firstargumenttrue \doifnextoptionalelse - {\dotripletestemptyx #1[{#2}]} + {\dotripletestemptyx #1[{#2}]}% {\secondargumentfalse \thirdargumentfalse #1[{#2}][][]}} \long\def\dotripletestemptyx#1[#2][#3]% {\secondargumenttrue \doifnextoptionalelse - {\thirdargumenttrue #1[{#2}][{#3}]} + {\thirdargumenttrue #1[{#2}][{#3}]}% {\thirdargumentfalse#1[{#2}][{#3}][]}} %D \macros @@ -2489,10 +2489,10 @@ %D potentially being an \type {conditional} token. Okay, these macros %D are not called that often but it saves crap when tracing. -\def\dogetgroupargument#1#2% - {\let\dogroupargumentyes#1% - \let\dogroupargumentnop#2% - \futurelet\nextargument\dodogetgroupargument} +% \def\dogetgroupargument#1#2% +% {\let\dogroupargumentyes#1% +% \let\dogroupargumentnop#2% +% \futurelet\nextargument\dodogetgroupargument} \def\dodogetgroupargument {\ifx\nextargument\bgroup @@ -2505,26 +2505,38 @@ {\noshowargumenterror \dogroupargumentyes\dodogetargument} +% \def\dodogetgroupargumentB +% {\ifcase\@@permitspacesbetweengroups +% \expandafter\dodogetgroupargumentC +% \else +% \expandafter\dodogetgroupargumentD +% \fi} + +% \def\dodogetgroupargumentC +% {\ifx\nextargument\lineending +% \expandafter\dodogetgroupargumentE +% \else +% \expandafter\dodogetgroupargumentF +% \fi} + \def\dodogetgroupargumentB {\ifcase\@@permitspacesbetweengroups - \expandafter\dodogetgroupargumentC + \expandafter\dodogetgroupargumentF \else \expandafter\dodogetgroupargumentD \fi} -\def\dodogetgroupargumentC - {\ifx\nextargument\lineending - \expandafter\dodogetgroupargumentE - \else - \expandafter\dodogetgroupargumentF - \fi} - \def\dodogetgroupargumentD {\doshowargumenterror \dogroupargumentnop\dodogetargument{}} -\def\dodogetgroupargumentE - {\begingroup\def\\ {\endgroup\dogetgroupargument\dogroupargumentyes\dogroupargumentnop}\\} +% \def\dodogetgroupargumentE +% {\begingroup\def\\ {\endgroup\dogetgroupargument\dogroupargumentyes\dogroupargumentnop}\\} + +\begingroup + \def\\ {\dogetgroupargument\dogroupargumentyes\dogroupargumentnop} + \global\let\dodogetgroupargumentE\\ +\endgroup \def\dodogetgroupargumentF {\ifx\nextargument\blankspace @@ -6787,6 +6799,19 @@ \def\ignoreimplicitspaces {\doifnextcharelse\relax\relax\relax} + +%D \macros +%D {processwords} +%D +%D Not that sophisticated but sometimes users (like in metafun). + +\def\doprocesswords#1 #2\od + {\doifsomething{#1}{\processword{#1} \doprocesswords#2 \od}} + +\def\processwords#1% + {\doprocesswords#1 \od}% no \unskip + +\let\processword\relax % new % diff --git a/tex/context/base/syst-lua.tex b/tex/context/base/syst-lua.mkiv index 40cd9f756..40cd9f756 100644 --- a/tex/context/base/syst-lua.tex +++ b/tex/context/base/syst-lua.mkiv diff --git a/tex/context/base/task-ini.tex b/tex/context/base/task-ini.mkiv index ef32ee87d..ef32ee87d 100644 --- a/tex/context/base/task-ini.tex +++ b/tex/context/base/task-ini.mkiv diff --git a/tex/context/base/toks-ini.tex b/tex/context/base/toks-ini.mkiv index 932c05f32..932c05f32 100644 --- a/tex/context/base/toks-ini.tex +++ b/tex/context/base/toks-ini.mkiv diff --git a/tex/context/base/trac-deb.tex b/tex/context/base/trac-deb.mkiv index 870c452ad..870c452ad 100644 --- a/tex/context/base/trac-deb.tex +++ b/tex/context/base/trac-deb.mkiv diff --git a/tex/context/base/trac-lmx.tex b/tex/context/base/trac-lmx.mkiv index a47d2b8bb..a47d2b8bb 100644 --- a/tex/context/base/trac-lmx.tex +++ b/tex/context/base/trac-lmx.mkiv diff --git a/tex/context/base/core-vis.tex b/tex/context/base/trac-vis.mkii index 949cd176f..23ded2af9 100644 --- a/tex/context/base/core-vis.tex +++ b/tex/context/base/trac-vis.mkii @@ -1,7 +1,7 @@ %D \module -%D [ file=core-vis, +%D [ file=trac-vis, % was core-vis, %D version=1996.06.01, -%D title=\CONTEXT\ Core Macros, +%D title=\CONTEXT\ Tracking Macros, %D subtitle=Visualization, %D author=Hans Hagen, %D date=\currentdate, @@ -25,7 +25,7 @@ %D %\leftskip only if explicit one %D %\rightskip only if explicit one -\writestatus{loading}{ConTeXt Support Macros / Visualization} +\writestatus{loading}{ConTeXt Tracking Macros / Visualization} \unprotect diff --git a/tex/context/base/trac-vis.mkiv b/tex/context/base/trac-vis.mkiv new file mode 100644 index 000000000..23ded2af9 --- /dev/null +++ b/tex/context/base/trac-vis.mkiv @@ -0,0 +1,748 @@ +%D \module +%D [ file=trac-vis, % was core-vis, +%D version=1996.06.01, +%D title=\CONTEXT\ Tracking Macros, +%D subtitle=Visualization, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D This module adds some more visualization cues to the ones +%D supplied in the support module. +%D +%D %\everypar dual character, \the\everypar and \everypar= +%D %\hrule cannot be grabbed in advance, switches mode +%D %\vrule cannot be grabbed in advance, switches mode +%D % +%D %\indent only explicit ones +%D %\noindent only explicit ones +%D %\par only explicit ones +%D +%D %\leftskip only if explicit one +%D %\rightskip only if explicit one + +\writestatus{loading}{ConTeXt Tracking Macros / Visualization} + +\unprotect + +%D \macros +%D {indent, noindent, par} +%D +%D \TeX\ acts upon paragraphs. In mosts documents paragraphs +%D are separated by empty lines, which internally are handled as +%D \type{\par}. Paragraphs can be indented or not, depending on +%D the setting of \type{\parindent}, the first token of a +%D paragraph and/or user suppressed or forced indentation. +%D +%D Because the actual typesetting is based on both explicit +%D user and implicit system actions, visualization is only +%D possible for the user supplied \type{\indent}, +%D \type{\noindent}, and \type{\par}. Other +%D 'clever' tricks will quite certainly lead to more failures +%D than successes, so we only support these three explicit +%D primitives and one macro: + +\def\showparagraphcue#1#2#3#4#5% + {\bgroup + \scratchdimen#1\relax + \dontinterfere + \dontcomplain + \boxrulewidth5\testrulewidth + #3#4\relax + \setbox\scratchbox\normalhbox to \scratchdimen + {#2{\ruledhbox to \scratchdimen + {\vrule #5 20\testrulewidth \!!width \zeropoint + \normalhss}}}% + \smashbox\scratchbox + \normalpenalty\!!tenthousand + \box\scratchbox + \egroup} + +\def\ruledhanging + {\ifdim\hangindent>\zeropoint + \ifnum\hangafter<\zerocount + \normalhbox + {\boxrulewidth5\testrulewidth + \setbox\scratchbox\ruledhbox to \hangindent + {\scratchdimen\strutht + \advance\scratchdimen \strutdp + \vrule + \!!width \zeropoint + \!!height \zeropoint + \!!depth -\hangafter\scratchdimen}% + \normalhskip-\hangindent + \smashbox\scratchbox + \raise\strutht\box\scratchbox}% + \fi + \fi} + +\def\ruledparagraphcues + {\bgroup + \dontcomplain + \normalhbox to \zeropoint + {\ifdim\leftskip>\zeropoint\relax + \showparagraphcue\leftskip\llap\relax\relax\!!depth + \normalhskip-\leftskip + \fi + \ruledhanging + \normalhskip\hsize + \ifdim\rightskip>\zeropoint\relax + \normalhskip-\rightskip + \showparagraphcue\rightskip\relax\relax\relax\!!depth + \fi}% + \egroup} + +\def\ruledpar + {\relax + \ifhmode + \showparagraphcue{40\testrulewidth}\relax\rightrulefalse\relax\!!height + \fi + \normalpar} + +\def\rulednoindent + {\relax + \normalnoindent + \ruledparagraphcues + \showparagraphcue{40\testrulewidth}\llap\leftrulefalse\relax\!!height} + +\def\ruledindent + {\relax + \normalnoindent + \ruledparagraphcues + \ifdim\parindent>\zeropoint + \showparagraphcue\parindent\relax\relax\relax\!!height + \else + \showparagraphcue{40\testrulewidth}\llap\relax\relax\!!height + \fi + \normalhskip\parindent} + +\def\dontshowimplicits + {\let\noindent \normalnoindent + \let\indent \normalindent + \let\par \normalpar} + +\def\showimplicits + {\testrulewidth \defaulttestrulewidth + \let\noindent \rulednoindent + \let\indent \ruledindent + \let\par \ruledpar} + +%D The next few||line examples show the four cues. Keep in +%D mind that we only see them when we explicitly open or close +%D a paragraph. +%D +%D \bgroup +%D \def\voorbeeld#1% +%D {#1Visualizing some \TeX\ primitives and Plain \TeX\ +%D macros can be very instructive, at least it is to me. +%D Here we see {\tt\string#1} and {\tt\string\ruledpar} in +%D action, while {\tt\string\parindent} equals +%D {\tt\the\parindent}.\ruledpar} +%D +%D \showimplicits +%D +%D \voorbeeld \indent +%D \voorbeeld \noindent +%D +%D \parindent=60pt +%D +%D \voorbeeld \indent +%D \voorbeeld \noindent +%D +%D \startnarrower +%D \voorbeeld \indent +%D \voorbeeld \noindent +%D \stopnarrower +%D \egroup +%D +%D These examples also demonstrate the visualization of +%D \type {\leftskip} and \type {\rightskip}. The macro +%D \type {\nofruledbaselines} determines the number of lines +%D shown. + +\newcounter\ruledbaselines + +\def\nofruledbaselines{3} + +\def\debuggertext#1% + {\ifx\ttxx\undefined + $\scriptscriptstyle#1$% + \else + {\ttxx#1}% + \fi} + +\def\ruledbaseline + {\vrule \!!width \zeropoint + \bgroup + \dontinterfere + \doglobal\increment\ruledbaselines + \scratchdimen\nofruledbaselines\baselineskip + \setbox\scratchbox\normalvbox to 2\scratchdimen + {\leaders + \normalhbox + {\strut + \vrule + \!!height \testrulewidth + \!!depth \testrulewidth + \!!width 120\points} + \normalvfill}% + \smashbox\scratchbox + \advance\scratchdimen \strutheightfactor\baselineskip + \setbox\scratchbox\normalhbox + {\normalhskip -48\points + \normalhbox to 24\points + {\normalhss\debuggertext\ruledbaselines\normalhskip6\points}% + \raise\scratchdimen\box\scratchbox}% + \smashbox\scratchbox + \box\scratchbox + \egroup} + +\def\showbaselines + {\testrulewidth\defaulttestrulewidth + \EveryPar{\ruledbaseline}} + +%D \macros +%D {showpagebuilder} +%D +%D The next tracing option probaly is only of use to me and a +%D few \CONTEXT\ hackers. + +\def\showpagebuilder + {\EveryPar{\doshowpagebuilder}} + +\def\doshowpagebuilder + {\strut\llap + {\startcolor[blue]\vl + \high{\infofont v:\the\vsize }\vl + \high{\infofont g:\the\pagegoal }\vl + \high{\infofont t:\the\pagetotal}\vl + \stopcolor}} + +%D \macros +%D {makecutbox, cuthbox, cutvbox, cutvtop} +%D +%D Although mainly used for marking the page, these macros can +%D also serve local use. +%D +%D \startbuffer +%D \setbox0=\vbox{a real \crlf vertical box} \makecutbox0 +%D \stopbuffer +%D +%D \typebuffer +%D +%D This marked \type{\vbox} shows up as: +%D +%D \startlinecorrection +%D \getbuffer +%D \stoplinecorrection +%D +%D The alternative macros are used as: +%D +%D \startbuffer +%D \cuthbox{a made cut box} +%D \stopbuffer +%D +%D \typebuffer +%D +%D This is typeset as: +%D +%D \startlinecorrection +%D \getbuffer +%D \stoplinecorrection +%D +%D By setting the next macros one can influence the length of +%D the marks as well as the horizontal and vertical divisions. + +\def\cutmarklength {2\bodyfontsize} +\chardef\horizontalcutmarks = 2 +\chardef\verticalcutmarks = 2 +\chardef\cutmarkoffset = 1 +\let\cutmarksymbol = \relax +\let\cutmarktoptext = \empty +\let\cutmarkbottomtext = \empty + +\def\horizontalcuts + {\normalhbox to \ruledwidth + {\dorecurse\horizontalcutmarks + {\vrule\!!width\boxrulewidth\!!height\cutmarklength\normalhfill}% + \unskip}} + +\def\verticalcuts + {\scratchdimen\ruledheight + \advance\scratchdimen \ruleddepth + \normalvbox to \scratchdimen + {\hsize\cutmarklength + \dorecurse\verticalcutmarks + {\vrule\!!height\boxrulewidth\!!width\hsize\normalvfill}% + \unskip}} + +\def\baselinecuts + {\ifdim\ruleddepth>\zeropoint + \scratchdimen\ruledheight + \advance\scratchdimen \ruleddepth + \normalvbox to \scratchdimen + {\scratchdimen\cutmarklength + \divide\scratchdimen 2 + \hsize\scratchdimen + \normalvskip\zeropoint\!!plus\ruledheight + \vrule\!!height\boxrulewidth\!!width\hsize + \normalvskip\zeropoint\!!plus\ruleddepth}% + \fi} + +\def\cutmarksymbols#1% + {\normalhbox to \ruledwidth + {\setbox\scratchbox\normalhbox to \cutmarklength + {\normalhss\infofont\cutmarksymbol\normalhss}% + \normalhss + \normalvbox to \cutmarklength + {\scratchdimen\cutmarklength + \divide\scratchdimen \plustwo + \normalvss + \hbox to \ruledwidth + {\llap{\copy\scratchbox\normalhskip\cutmarkoffset\scratchdimen}% + \normalhskip\scratchdimen\hss\infofont#1\hss\normalhskip\scratchdimen + \rlap{\normalhskip\cutmarkoffset\scratchdimen\copy\scratchbox}}% + \normalvss}% + \normalhss}} + +\def\makecutbox#1% simplier with layers, todo + {\edef\ruledheight{\the\ht#1}% + \edef\ruleddepth {\the\dp#1}% + \edef\ruledwidth {\the\wd#1}% + \setbox#1\normalhbox + {\dontcomplain + \forgetall + \boxmaxdepth\maxdimen + \offinterlineskip + \scratchdimen\cutmarklength + \divide\scratchdimen \plustwo + \hsize\ruledwidth + \setbox\scratchbox\normalvbox + {\setbox\scratchbox\normalhbox{\horizontalcuts}% + \normalvskip-\cutmarkoffset\scratchdimen + \normalvskip-2\scratchdimen + \copy\scratchbox + \normalvskip\cutmarkoffset\scratchdimen + \hbox to \ruledwidth + {\setbox\scratchbox\normalhbox{\verticalcuts}% + \llap{\copy\scratchbox\normalhskip\cutmarkoffset\scratchdimen}% + \bgroup + \setbox\scratchbox\normalhbox{\baselinecuts}% + \llap{\copy\scratchbox\normalhskip\cutmarkoffset\scratchdimen}% + \normalhfill + \rlap{\normalhskip\cutmarkoffset\scratchdimen\copy\scratchbox}% + \egroup + \rlap{\normalhskip\cutmarkoffset\scratchdimen\copy\scratchbox}}% + \normalvskip\cutmarkoffset\scratchdimen + \copy\scratchbox}% + \ht\scratchbox\ruledheight + \dp\scratchbox\ruleddepth + \wd\scratchbox\zeropoint + \resetcolorseparation + \localstartcolor[\defaulttextcolor]% + \box\scratchbox + \ifx\cutmarksymbol\relax \else + \setbox\scratchbox\normalvbox + {\vskip-\cutmarkoffset\scratchdimen + \vskip-\cutmarklength + \normalhbox{\cutmarksymbols\cutmarktoptext}% + \vskip\cutmarkoffset\scratchdimen + \vskip\ruledheight + \vskip\ruleddepth + \vskip\cutmarkoffset\scratchdimen + \normalhbox{\cutmarksymbols\cutmarkbottomtext}}% + \ht\scratchbox\ruledheight + \dp\scratchbox\ruleddepth + \wd\scratchbox\zeropoint + \box\scratchbox + \fi + \localstopcolor + \box#1}% + \wd#1=\ruledwidth + \ht#1=\ruledheight + \dp#1=\ruleddepth} + +\def\cuthbox + {\normalhbox\bgroup + \dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalhbox} + +\def\cutvbox + {\normalvbox\bgroup + \dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalvbox} + +\def\cutvtop + {\normalvtop\bgroup + \dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalvtop} + +%D \macros +%D {colormarkbox,rastermarkbox} +%D +%D This macro is used in the pagebody routine. No other use +%D is advocated here. +%D +%D \starttyping +%D \colormarkbox0 +%D \stoptyping + +\def\colormarkoffset{\cutmarkoffset} +\def\colormarklength{\cutmarklength} + +\def\colorrangeA#1#2#3#4% + {\vbox + {\scratchdimen-\colormarklength + \multiply\scratchdimen 4 + \advance\scratchdimen \ruledheight + \advance\scratchdimen \ruleddepth + \divide\scratchdimen 21 + \def\docommand##1% + {\vbox + {\hsize3em % \scratchdimen + \definecolor + [\s!dummy] + [\c!c=#2##1\else0\fi, + \c!m=#3##1\else0\fi, + \c!y=#4##1\else0\fi, + \c!k=0]% + \localstartcolor[\s!dummy]% + \hrule + \!!width 3em + \!!height \scratchdimen + \!!depth \zeropoint + \localstopcolor + \ifdim\scratchdimen>1ex + \vskip-\scratchdimen + \vbox to \scratchdimen + {\vss + \hbox to 3em + {\hss + \localstartcolor[\s!white]% + \ifdim##1\points=\zeropoint#1\else##1\fi + \localstopcolor + \hss}% + \vss}% + \fi}}% + \offinterlineskip + \processcommalist[1.00,0.95,0.75,0.50,0.25,0.05,0.00]\docommand}} + +\def\colorrangeB + {\hbox + {\scratchdimen-\colormarklength + \multiply\scratchdimen \plustwo + \advance\scratchdimen \ruledwidth + \divide\scratchdimen 11 + \def\docommand ##1 ##2 ##3##4##5##6% + {\definecolor + [\s!dummy] + [\c!c=##3##2\else0\fi, + \c!m=##4##2\else0\fi, + \c!y=##5##2\else0\fi, + \c!k=##6##2\else0\fi]% + \localstartcolor[\s!dummy]% + \vrule + \!!width \scratchdimen + \!!height \colormarklength + \!!depth \zeropoint + \localstopcolor + \ifdim\scratchdimen>2em + \hskip-\scratchdimen + \vbox to \colormarklength + {\vss + \hbox to \scratchdimen + {\hss + \localstartcolor[\s!white]% + \ifdim##2\points=.5\points##2~\fi##1% + \localstopcolor + \hss} + \vss}% + \fi}% + \docommand C .5 \iftrue \iffalse\iffalse\iffalse + \docommand M .5 \iffalse\iftrue \iffalse\iffalse + \docommand Y .5 \iffalse\iffalse\iftrue \iffalse + \docommand K .5 \iffalse\iffalse\iffalse\iftrue + \docommand C 1 \iftrue \iffalse\iffalse\iffalse + \docommand G 1 \iftrue \iffalse\iftrue \iffalse + \docommand Y 1 \iffalse\iffalse\iftrue \iffalse + \docommand R 1 \iffalse\iftrue \iftrue \iffalse + \docommand M 1 \iffalse\iftrue \iffalse\iffalse + \docommand B 1 \iftrue \iftrue \iffalse\iffalse + \docommand K 1 \iffalse\iffalse\iffalse\iftrue}} + +\def\colorrangeC + {\hbox + {\resetcolorseparation + \scratchdimen-\colormarklength + \multiply\scratchdimen 2 + \advance\scratchdimen \ruledwidth + \divide\scratchdimen 14 + \def\docommand##1% + {\definecolor[\s!dummy][\c!s=##1]% + \localstartcolor[\s!dummy]% + \vrule + \!!width \scratchdimen + \!!height \colormarklength + \!!depth \zeropoint + \localstopcolor + \ifdim\scratchdimen>2em + \hskip-\scratchdimen + \vbox to \colormarklength + {\vss + \localstartcolor[\s!white]% + \hbox to \scratchdimen{\hss##1\hss} + \localstopcolor + \vss}% + \fi}% + \processcommalist[1,.95,.9,.85,.8,.75,.7,.6,.5,.4,.3,.2,.1,0]\docommand}} + +\def\docolormarkbox#1#2% + {\edef\ruledheight{\the\ht#2}% + \edef\ruleddepth {\the\dp#2}% + \edef\ruledwidth {\the\wd#2}% + \setbox#2\hbox + {\scratchdimen\colormarklength + \divide\scratchdimen \plustwo + \forgetall + \ssxx + \setbox\scratchbox\vbox + {\offinterlineskip + \vskip-\colormarkoffset\scratchdimen + \vskip-2\scratchdimen\relax % relax needed + % beware: no \ifcase, due to nested \iftrue/\iffalse + % and lacking \fi's + \doifelse{#1}{0}% + {\vskip\colormarklength + \vskip\colormarkoffset\scratchdimen + \vskip\ruledheight} + {\hbox to \ruledwidth{\hss\hbox{\colorrangeB}\hss}% + \vskip\colormarkoffset\scratchdimen + \vbox to \ruledheight + {\vss + \hbox to \ruledwidth + {\llap{\colorrangeA C\iftrue\iffalse\iffalse\hskip\colormarkoffset\scratchdimen}% + \hfill + \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA R\iffalse\iftrue\iftrue}}% + \vss + \hbox to \ruledwidth + {\llap{\colorrangeA M\iffalse\iftrue\iffalse\hskip\colormarkoffset\scratchdimen}% + \hfill + \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA G\iftrue\iffalse\iftrue}}% + \vss + \hbox to \ruledwidth + {\llap{\colorrangeA Y\iffalse\iffalse\iftrue\hskip\colormarkoffset\scratchdimen}% + \hfill + \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA B\iftrue\iftrue\iffalse}}% + \vss}}% + \vskip\colormarkoffset\scratchdimen + \hbox to \ruledwidth + {\hss\lower\ruleddepth\hbox{\colorrangeC}\hss}}% + \ht\scratchbox\ruledheight + \dp\scratchbox\ruleddepth + \wd\scratchbox\zeropoint + \box\scratchbox + \box#2}% + \wd#2=\ruledwidth + \ht#2=\ruledheight + \dp#2=\ruleddepth} + +\def\colormarkbox % #1 + {\ifincolor\@EA\docolormarkbox\else\@EA\gobbletwoarguments\fi1} + +\def\rastermarkbox % #1 + {\ifincolor\@EA\docolormarkbox\else\@EA\gobbletwoarguments\fi0} + +%D \macros +%D {showwhatsits, dontshowwhatsits} +%D +%D \TEX\ has three so called whatsits: \type {\mark}, \type +%D {\write} and \type {\special}. The first one keeps track of +%D the current state at page boundaries, the last two are used +%D to communicate to the outside world. Due to fact that +%D especially \type {\write} is often used in conjunction with +%D \type {\edef}, we can only savely support that one in \ETEX. +%D +%D \bgroup \showwhatsits \setupcolors[state=start] +%D +%D Whatsits show up \color[blue]{in color} and are +%D characterized bij their first character.\footnote [some note] +%D {So we may encounter \type {w}, \type {m} and \type{s}.} +%D They are \writestatus{dummy}{demo}\color[yellow]{stacked}. +%D +%D \egroup + +\newif\ifimmediatewrite + +\ifx\eTeXversion\undefined + + \let\showwhatsits \relax + \let\dontshowwhatsits\relax + +\else + + \let\supernormalmark \normalmark % mark may already been superseded + \let\supernormalmarks \normalmarks % mark may already been superseded + + \def\showwhatsits + {\protected\def\normalmark {\visualwhatsit100+m\supernormalmark }% + \protected\def\normalmarks{\visualwhatsit100+m\supernormalmarks}% + \protected\def\special {\visualwhatsit0100s\normalspecial }% + \protected\def\write {\visualwhatsit001-w\normalwrite }% + \let\immediate\immediatewhatsit + \appendtoks\dontshowwhatsits\to\everystoptext} + + \def\immediatewhatsit + {\bgroup\futurelet\next\doimmediatewhatsit} + + \def\doimmediatewhatsit + {\ifx\next\write + \egroup\immediatewritetrue + \else + \egroup\expandafter\normalimmediate + \fi} + + \def\dontshowwhatsits + {\let\immediate \normalimmediate + \let\normalmark\supernormalmark + \let\special \normalspecial + \let\write \normalwrite} + + \def\visualwhatsit#1#2#3#4#5% + {\bgroup + \pushwhatsit + \dontinterfere + \dontcomplain + \dontshowcomposition + \dontshowwhatsits + \ttx + \ifvmode\donetrue\else\donefalse\fi + \setbox\scratchbox\hbox + {\ifdone\dostartgraycolormode0\else\dostartrgbcolormode#1#2#3\fi + #5\dostopcolormode}% + \setbox\scratchbox\hbox + {\ifdone\dostartrgbcolormode#1#2#3\else\dostartgraycolormode0\fi + \vrule\!!width\wd\scratchbox\dostopcolormode + \hskip-\wd\scratchbox\box\scratchbox}% + \scratchdimen1ex + \setbox\scratchbox\hbox + {\ifdone\hskip\else\raise#4\fi\scratchdimen\box\scratchbox}% + \smashbox\scratchbox + \ifdone\nointerlineskip\fi + \box\scratchbox + \ifvmode\nointerlineskip\fi + \popwhatsit + \egroup + \ifimmediatewrite + \immediatewritefalse + \expandafter\normalimmediate + \fi} + + \def\pushwhatsit + {\ifzeropt\lastskip + \ifcase\lastpenalty + \ifzeropt\lastkern + \ifhmode + \let\popwhatsit\relax + \else + \edef\popwhatsit{\prevdepth\the\prevdepth}% + \fi + \else + \ifhmode + \edef\popwhatsit{\kern\the\lastkern}\unkern + \else + \edef\popwhatsit{\kern\the\lastkern\prevdepth\the\prevdepth}% + \kern-\lastkern + \fi + \fi + \else + \ifhmode + \edef\popwhatsit{\the\lastpenalty}% + \unpenalty + \else + \edef\popwhatsit{\penalty\the\lastpenalty\prevdepth\the\prevdepth}% + %\nobreak + \fi + \fi + \else + \ifhmode + \edef\popwhatsit{\hskip\the\lastskip}\unskip + \else + \edef\popwhatsit{\vskip\the\lastskip\prevdepth\the\prevdepth}% + \vskip-\lastskip + \fi + \fi} + +\fi + +%D The next macro can be used to keep track of classes of +%D boxes (handy for development cq.\ tracing). + +\def\dodotagbox#1#2#3% can be reimplemented + {\def\next##1##2##3##4% + {\vbox to \ht#2{##3\hbox to \wd#2{##1#3##2}##4}}% + \processaction + [#1] + [ l=>\next\relax\hfill\vfill\vfill, + r=>\next\hfill\relax\vfill\vfill, + t=>\next\hfill\hfill\relax\vfill, + b=>\next\hfill\hfill\vfill\relax, + lt=>\next\relax\hfill\relax\vfill, + lb=>\next\relax\hfill\vfill\relax, + rt=>\next\hfill\relax\relax\vfill, + rb=>\next\hfill\relax\vfill\relax, + tl=>\next\relax\hfill\relax\vfill, + bl=>\next\relax\hfill\vfill\relax, + tr=>\next\hfill\relax\relax\vfill, + br=>\next\hfill\relax\vfill\relax, + \s!default=>\next\hfill\hfill\vfill\vfill, + \s!unknown=>\next\hfill\hfill\vfill\vfill]} + +\def\dotagbox[#1]#2% + {\bgroup + \dowithnextbox + {\setbox\scratchbox\flushnextbox + \setbox\nextbox\ifhbox\nextbox\hbox\else\vbox\fi + \bgroup + \startoverlay + {\copy\scratchbox} + {\dodotagbox{#1}\scratchbox{\framed + [\c!background=\v!screen,\c!backgroundscreen=1]{#2}}} + \stopoverlay + \egroup + \nextboxwd\the\wd\scratchbox + \nextboxht\the\ht\scratchbox + \nextboxdp\the\dp\scratchbox + \flushnextbox + \egroup}} + +\def\tagbox + {\dosingleempty\dotagbox} + +%D \macros +%D {coloredhbox,coloredvbox,coloredvtop, +%D coloredstrut} +%D +%D The following visualizations are used in some of the manuals: + +\definecolor[boxcolor:ht][r=.5,g=.75,b=.5] +\definecolor[boxcolor:dp][r=.5,g=.5,b=.75] +\definecolor[boxcolor:wd][r=.75,g=.5,b=.5] +\definecolor[strutcolor] [r=.5,g=.25,b=.25] + +\def\coloredbox#1% + {\dowithnextbox{#1{\hbox + {\blackrule[\c!width=\nextboxwd,\c!height=\nextboxht,\c!depth=\zeropoint,\c!color=boxcolor:ht]% + \hskip-\nextboxwd + \blackrule[\c!width=\nextboxwd,\c!height=\zeropoint,\c!depth=\nextboxdp,\c!color=boxcolor:dp]% + \hskip-\nextboxwd + \box\nextbox}}}#1} + +\def\coloredhbox{\coloredbox\hbox} +\def\coloredvbox{\coloredbox\vbox} +\def\coloredvtop{\coloredbox\vtop} + +\def\coloredstrut + {\color[strutcolor]{\def\strutwidth{2\points}\setstrut\strut}} + +\protect \endinput diff --git a/tex/context/base/typo-brk.tex b/tex/context/base/typo-brk.mkiv index 90561fc9e..90561fc9e 100644 --- a/tex/context/base/typo-brk.tex +++ b/tex/context/base/typo-brk.mkiv diff --git a/tex/context/base/typo-cap.tex b/tex/context/base/typo-cap.mkiv index 49ca64957..45a932200 100644 --- a/tex/context/base/typo-cap.tex +++ b/tex/context/base/typo-cap.mkiv @@ -20,7 +20,7 @@ \definesystemattribute[case] %D \macros -%D {Word, Words, WORD, WORDS, doprocesswords} +%D {Word, Words, WORD, WORDS} %D %D This is probably not the right place to present the next set %D of macros. @@ -47,16 +47,6 @@ %D \showsetup{WORD} %D \showsetup{WORDS} -% \def\doprocesswords#1 #2\od -% {\ConvertToConstant\doifnot{#1}{} -% {\processword{#1} % -% \doprocesswords#2 \od}} -% -% \def\processwords#1% -% {\doprocesswords#1 \od\unskip} -% -% \let\processword\relax - % test \WORD{test TEST \TeX} test % test \word{test TEST \TeX} test % test \Word{test TEST \TeX} test diff --git a/tex/context/base/typo-ini.tex b/tex/context/base/typo-ini.mkii index 1317021ef..1317021ef 100644 --- a/tex/context/base/typo-ini.tex +++ b/tex/context/base/typo-ini.mkii diff --git a/tex/context/base/typo-ini.mkiv b/tex/context/base/typo-ini.mkiv new file mode 100644 index 000000000..1317021ef --- /dev/null +++ b/tex/context/base/typo-ini.mkiv @@ -0,0 +1,40 @@ +%D \module +%D [ file=typo-ini, +%D version=2000.16.09, +%D title=\CONTEXT\ Typographic Macros, +%D subtitle=Initialization, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Since \CONTEXT\ is dealing with typographics, isn't +%D September 2000 a bit late to start writing this module? It +%D may seem so, but since more and more languages are +%D supported, we think it is time to isolate language specific +%D typographic extensions in modules. The first language that +%D demands this is Chinese, and more will follow. + +\writestatus{loading}{ConTeXt Typographic Macros / Initialization} + +\unprotect + +%D \macros +%D {ifvertical} +%D +%D The following switch can be used to signal macros that they +%D should adapt their behaviour. + +\newif\ifvertical % maybe also ifreverse + +%D \macros +%D {vhbox} +%D +%D A stupid but useful macro. + +\def\vhbox{\ifvertical\vbox\else\hbox\fi} + +\protect \endinput diff --git a/tex/context/base/typo-krn.tex b/tex/context/base/typo-krn.mkiv index e2f10d806..e2f10d806 100644 --- a/tex/context/base/typo-krn.tex +++ b/tex/context/base/typo-krn.mkiv diff --git a/tex/context/base/typo-mir.tex b/tex/context/base/typo-mir.mkiv index fe9d793e0..fe9d793e0 100644 --- a/tex/context/base/typo-mir.tex +++ b/tex/context/base/typo-mir.mkiv diff --git a/tex/context/base/typo-spa.tex b/tex/context/base/typo-spa.mkiv index d1b855edd..d1b855edd 100644 --- a/tex/context/base/typo-spa.tex +++ b/tex/context/base/typo-spa.mkiv diff --git a/tex/context/base/verb-lua.lua b/tex/context/base/verb-lua.lua deleted file mode 100644 index 9ba22c1f2..000000000 --- a/tex/context/base/verb-lua.lua +++ /dev/null @@ -1,216 +0,0 @@ --- filename : type-lua.lua --- comment : companion to core-buf.tex --- author : Hans Hagen, PRAGMA-ADE, Hasselt NL --- copyright: PRAGMA ADE / ConTeXt Development Team --- license : see context related readme files - --- BROKEN : result is now table - -local utf = unicode.utf8 - -local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues - -local ctxcatcodes = tex.ctxcatcodes - -if not buffers then buffers = { } end -if not buffers.visualizers then buffers.visualizers = { } end -if not buffers.visualizers.lua then buffers.visualizers.lua = { } end - -buffers.visualizers.lua.identifiers = { } - --- borrowed from scite - -buffers.visualizers.lua.identifiers.core = { - "and", "break", "do", "else", "elseif", "end", "false", "for", "function", - "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", - "true", "until", "while" -} - -buffers.visualizers.lua.identifiers.base = { - "assert", "collectgarbage", "dofile", "error", "gcinfo", "loadfile", - "loadstring", "print", "rawget", "rawset", "require", "tonumber", - "tostring", "type", "unpack", -} - -buffers.visualizers.lua.identifiers.five = { - "_G", "getfenv", "getmetatable", "ipairs", "loadlib", "next", "pairs", - "pcall", "rawequal", "setfenv", "setmetatable", "xpcall", "string", "table", - "math", "coroutine", "io", "os", "debug", "load", "module", "select" -} - -buffers.visualizers.lua.identifiers.libs = { - -- coroutine - "coroutine.create", "coroutine.resume", "coroutine.status", "coroutine.wrap", - "coroutine.yield", "coroutine.running", - -- package - "package.cpath", "package.loaded", "package.loadlib", "package.path", - -- io - "io.close", "io.flush", "io.input", "io.lines", "io.open", "io.output", - "io.read", "io.tmpfile", "io.type", "io.write", "io.stdin", "io.stdout", - "io.stderr", "io.popen", - -- math - "math.abs", "math.acos", "math.asin", "math.atan", "math.atan2", "math.ceil", - "math.cos", "math.deg", "math.exp", "math.floor math.", "math.ldexp", - "math.log", "math.log10", "math.max", "math.min math.mod math.pi", "math.pow", - "math.rad", "math.random", "math.randomseed", "math.sin", "math.sqrt", - "math.tan", "math.cosh", "math.fmod", "math.modf", "math.sinh", "math.tanh", - "math.huge", - -- string - "string.byte", "string.char", "string.dump", "string.find", "string.len", - "string.lower", "string.rep", "string.sub", "string.upper", "string.format", - "string.gfind", "string.gsub", "string.gmatch", "string.match", "string.reverse", - -- table - "table.maxn", "table.concat", "table.foreach", "table.foreachi", "table.getn", - "table.sort", "table.insert", "table.remove", "table.setn", - -- os - "os.clock", "os.date", "os.difftime", "os.execute", "os.exit", "os.getenv", - "os.remove", "os.rename", "os.setlocale", "os.time", "os.tmpname", - -- package - "package.preload", "package.seeall" -} - -buffers.visualizers.lua.words = { } - -for k,v in pairs(buffers.visualizers.lua.identifiers) do - for _,w in pairs(v) do - buffers.visualizers.lua.words[w] = k - end -end - -buffers.visualizers.lua.styles = { } - -buffers.visualizers.lua.styles.core = "" -buffers.visualizers.lua.styles.base = "\\sl " -buffers.visualizers.lua.styles.five = "\\sl " -buffers.visualizers.lua.styles.libs = "\\sl " - --- btex .. etex - -buffers.visualizers.lua.colors = { - "prettyone", - "prettytwo", - "prettythree", - "prettyfour", -} - -buffers.visualizers.lua.states = { - ['1']=1, ['2']=1, ['3']=1, ['4']=1, ['5']=1, ['6']=1, ['7']=1, ['8']=1, ['9']=1, ['0']=1, - ['--']=4, - ['"']=3, ["'"]=3, - ['+']=1, ['-']=1, ['*']=1, ['/']=1, ['%']=1, ['^']=1, -} - -buffers.visualizers.lua.options = { } - -buffers.visualizers.lua.options.colorize_strings = false -buffers.visualizers.lua.options.colorize_comments = false - -function buffers.flush_lua_word(state, word, result) - if #word>0 then - local id = buffers.visualizers.lua.words[word] - if id then - state, result = buffers.change_state(2, state, result) - if buffers.visualizers.lua.styles[id] then - state, result = buffers.finish_state(state,result .. buffers.visualizers.lua.styles[id] .. word) - else - state, result = buffers.finish_state(state,result .. word) - end - return state, result - else - state, result = buffers.finish_state(state,result) - return state, result .. buffers.escaped(word) -- cmp mp - end - else - state, result = buffers.finish_state(state,result) - return state, result - end -end - -buffers.visualizers.lua.states.incomment = false - --- to be sped up - -function buffers.visualizers.lua.flush_line(str, nested) - local result, state = { }, 0 - local instr, inesc, incom = false, false, false - local c, p - local sb, ss, sf = string.byte, string.sub, string.find - local code, comment ---~ buffers.currentcolors = buffers.visualizers.lua.colors ---~ if sf(str,"^%-%-%[") then ---~ buffers.visualizers.lua.states.incomment = true ---~ code, comment, incom = "", str, true ---~ elseif sf(str,"^%]%-%-") then ---~ buffers.visualizers.lua.states.incomment = false ---~ code, comment, incom = "", str, true ---~ elseif buffers.visualizers.lua.states.incomment then ---~ code, comment, incom = "", str, true ---~ else ---~ code, comment = string.match(str,"^(.-)%-%-(.*)$") ---~ if not code then ---~ code, comment = str, "" ---~ end ---~ end ---~ -- bla bla1 bla.bla ---~ for c in utfcharacters(code) do ---~ if instr then ---~ if c == s then ---~ if inesc then ---~ result = result .. "\\char" .. sb(c) .. " " ---~ inesc = false ---~ else ---~ state, result = buffers.change_state(buffers.visualizers.lua.states[c], state, result) ---~ instr = false ---~ result = result .. "\\char" .. sb(c) .. " " ---~ state, result = buffers.finish_state(state,result) ---~ end ---~ elseif c == "\\" then ---~ inesc = not inesc ---~ result = result .. buffers.escaped_chr(c) ---~ else ---~ inesc = false ---~ result = result .. buffers.escaped_chr(c) ---~ end ---~ elseif sf(c,"^([\'\"])$") then ---~ s, instr = c, true ---~ state, result = buffers.change_state(buffers.visualizers.lua.states[c], state, result) ---~ result = result .. "\\char" .. sb(c) .. " " ---~ if not buffers.visualizers.lua.options.colorize_strings then ---~ state, result = buffers.finish_state(state,result) ---~ end ---~ elseif c == " " then ---~ state, result = buffers.flush_lua_word(state, word, result) ---~ word = "" ---~ result = result .. "\\obs " ---~ elseif sf(c,"^[%a]$") then ---~ state, result = buffers.finish_state(state,result) ---~ word = word .. c ---~ elseif (#word > 1) and sf(c,"^[%d%.%_]$") then ---~ word = word .. c ---~ else ---~ state, result = buffers.flush_lua_word(state, word, result) ---~ word = "" ---~ state, result = buffers.change_state(buffers.visualizers.lua.states[c], state, result) ---~ result = result .. "\\char" .. sb(c) .. " " ---~ instr = (c == '"') ---~ end ---~ end ---~ state, result = buffers.flush_lua_word(state, word, result) ---~ if comment ~= "" then ---~ state, result = buffers.change_state(buffers.visualizers.lua.states['--'], state, result) ---~ if not incom then ---~ result = result .. buffers.escaped("--") ---~ end ---~ if buffers.visualizers.lua.options.colorize_comments then ---~ state, result = buffers.finish_state(state,result) ---~ result = result .. buffers.escaped(comment) ---~ else ---~ result = result .. buffers.escaped(comment) ---~ state, result = buffers.finish_state(state,result) ---~ end ---~ else ---~ state, result = buffers.finish_state(state,result) ---~ end ---~ tex.sprint(ctxcatcodes,result) - return "not yet finished" -end diff --git a/tex/context/base/verb-tex.lua b/tex/context/base/verb-tex.lua deleted file mode 100644 index 98e6eccb4..000000000 --- a/tex/context/base/verb-tex.lua +++ /dev/null @@ -1,126 +0,0 @@ --- filename : type-tex.lua --- comment : companion to core-buf.tex --- author : Hans Hagen, PRAGMA-ADE, Hasselt NL --- copyright: PRAGMA ADE / ConTeXt Development Team --- license : see context related readme files - -local utf = unicode.utf8 - -local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues - -if not buffers then buffers = { } end -if not buffers.visualizers then buffers.visualizers = { } end -if not buffers.visualizers.tex then buffers.visualizers.tex = { } end - -buffers.visualizers.tex.colors = { - "prettytwo", - "prettyone", - "prettythree", - "prettyfour" -} - -buffers.visualizers.tex.states = { - ['$']=2, ['{']=2, ['}']=2, - ['[']=3, [']']=3, ['(']=3, [')']=3, ['<']=3, ['>']=3, ['#']=3, ['=']=3, ['"']=3, - ['/']=4, ['^']=4, ['_']=4, ['-']=4, ['&']=4, ['+']=4, ["'"]=4, ['`']=4, ['|']=4, ['%']=4 -} - --- using a table to store the result does not make sense here (actually, --- it's substantial slower since we're flushing lines on the fly) --- --- we could use a special catcode regime: only \ { } - -function buffers.visualizers.tex.flush_line(str,nested) - local result, state = { }, 0 - local first, escaping = false, false - local byte, find = utf.byte, utf.find - local finish, change = buffers.finish_state, buffers.change_state - buffers.currentcolors = buffers.visualizers.tex.colors - for c in utfcharacters(str) do - if c == " " then - if escaping then - result[#result+1] = " " - else - state = finish(state, result) - result[#result+1] = "\\obs " - end - escaping, first = false, false - elseif c == "\t" then - if escaping then - result[#result+1] = " " - else - state = finish(state, result) - result[#result+1] = "\\obs " - end - if buffers.visualizers.enabletab then - result[#result+1] = string.rep("\\obs ",i%buffers.visualizers.tablength) - end - escaping, first = false, false - elseif buffers.visualizers.enableescape and (c == buffers.visualizers.escapetoken) then - if escaping then - if first then - if find(c,"^[%a%!%?%@]$") then - result[#result+1] =c - else - result[#result+1] ="\\char" .. byte(c) .. " " - end - first = false - else - result[#result+1] = "\\" - first = true - end - else - state = finish(state, result) - result[#result+1] = "\\" - escaping, first = true, true - end - elseif escaping then - if find(c,"^[%a%!%?%@]$") then - result[#result+1] = c - else - result[#result+1] = "\\char" .. byte(c) .. " " - end - first = false - elseif first then - state = 1 - if find(c,"^[%a%!%?%@]$") then - result[#result+1] = c - else - result[#result+1] = "\\char" .. byte(c) .. " " - state = finish(state, result) - end - first = false - elseif state == 1 then - if find(c,"^[%a%!%?%@]$") then - result[#result+1] = c - first = false - elseif c == "\\" then - state = change(1, state, result) - result[#result+1] = "\\char" .. byte(c) .. " " - first = true - else - state = change(buffers.visualizers.tex.states[c], state, result) - if state == 0 then - result[#result+1] = c - else - result[#result+1] = "\\char" .. byte(c) .. " " - end - first = false - end - elseif c == "\\" then - first = true - state = change(1, state, result) - result[#result+1] = "\\char" .. byte(c) .. " " - else - state = change(buffers.visualizers.tex.states[c], state, result) - if state == 0 then - result[#result+1] = c - else - result[#result+1] = "\\char" .. byte(c) .. " " - end - first = false - end - end - state = finish(state, result) - buffers.flush_result(result,nested) -end diff --git a/tex/context/base/chem-str-test.tex b/tex/context/test/chem-str-test.tex index fd6a8227a..fd6a8227a 100644 --- a/tex/context/base/chem-str-test.tex +++ b/tex/context/test/chem-str-test.tex diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 15d12a584..4772646b9 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua --- merge date : 05/28/09 11:25:26 +-- merge date : 06/02/09 09:32:43 do -- begin closure to overcome local limits and interference @@ -9084,7 +9084,7 @@ function fonts.methods.node.otf.features(head,font,attr) end ra[s] = r end -featurevalue = r and r[1] -- toto: pass to function instead + featurevalue = r and r[1] -- todo: pass to function instead of using a global if featurevalue then local attribute, chain, typ, subtables = r[2], r[3], sequence.type, sequence.subtables if chain < 0 then |