From ce5e3838a9f6f947562e79bca07d1fb758caab29 Mon Sep 17 00:00:00 2001 From: Marius Date: Wed, 13 Jun 2012 11:20:14 +0300 Subject: beta 2012.06.13 09:57 --- .../lexers/data/scite-context-data-context.lua | 2 +- .../scite/scite-context-data-context.properties | 43 +- metapost/context/base/mp-crop.mpiv | 12 +- scripts/context/lua/mtxrun.lua | 59 +- scripts/context/stubs/mswin/mtxrun.lua | 59 +- scripts/context/stubs/unix/mtxrun | 59 +- tex/context/base/back-pdf.mkiv | 7 +- tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4145 -> 4150 bytes tex/context/base/context-version.png | Bin 106428 -> 106440 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 8 +- tex/context/base/data-exp.lua | 8 +- tex/context/base/data-res.lua | 51 +- tex/context/base/font-sol.lua | 731 +++++++++++++++++++++ tex/context/base/font-sol.mkiv | 121 ++++ tex/context/base/m-visual.mkiv | 562 +++++++++++++++- tex/context/base/mult-aux.mkiv | 22 +- tex/context/base/mult-de.mkii | 3 + tex/context/base/mult-def.lua | 12 + tex/context/base/mult-en.mkii | 3 + tex/context/base/mult-fr.mkii | 3 + tex/context/base/mult-it.mkii | 3 + tex/context/base/mult-low.lua | 1 + tex/context/base/mult-nl.mkii | 3 + tex/context/base/mult-pe.mkii | 3 + tex/context/base/mult-ro.mkii | 3 + tex/context/base/mult-sys.mkiv | 2 - tex/context/base/node-par.lua | 124 ---- tex/context/base/node-par.mkiv | 82 --- tex/context/base/node-spl.lua | 619 ----------------- tex/context/base/node-spl.mkiv | 114 ---- tex/context/base/pack-bar.mkiv | 97 ++- tex/context/base/pack-box.mkiv | 214 ++---- tex/context/base/pack-cut.mkiv | 162 +++++ tex/context/base/pack-obj.lua | 21 +- tex/context/base/pack-obj.mkiv | 143 ++-- tex/context/base/pack-pos.mkiv | 176 ++--- tex/context/base/page-col.mkiv | 2 +- tex/context/base/page-inf.mkiv | 6 +- tex/context/base/page-par.mkiv | 88 +-- tex/context/base/page-sel.mkiv | 2 +- tex/context/base/page-str.mkiv | 29 +- tex/context/base/status-files.pdf | Bin 24384 -> 24439 bytes tex/context/base/status-lua.pdf | Bin 181170 -> 181593 bytes tex/context/base/status-mkiv.lua | 28 +- tex/context/base/status-mkiv.tex | 4 +- tex/context/base/trac-vis.mkiv | 721 -------------------- tex/context/base/typo-bld.lua | 186 ++++++ tex/context/base/typo-bld.mkiv | 64 ++ tex/context/interface/keys-cs.xml | 3 + tex/context/interface/keys-de.xml | 3 + tex/context/interface/keys-en.xml | 3 + tex/context/interface/keys-fr.xml | 3 + tex/context/interface/keys-it.xml | 3 + tex/context/interface/keys-nl.xml | 3 + tex/context/interface/keys-pe.xml | 3 + tex/context/interface/keys-ro.xml | 3 + tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 60 files changed, 2470 insertions(+), 2224 deletions(-) create mode 100644 tex/context/base/font-sol.lua create mode 100644 tex/context/base/font-sol.mkiv delete mode 100644 tex/context/base/node-par.lua delete mode 100644 tex/context/base/node-par.mkiv delete mode 100644 tex/context/base/node-spl.lua delete mode 100644 tex/context/base/node-spl.mkiv create mode 100644 tex/context/base/pack-cut.mkiv delete mode 100644 tex/context/base/trac-vis.mkiv create mode 100644 tex/context/base/typo-bld.lua create mode 100644 tex/context/base/typo-bld.mkiv diff --git a/context/data/scite/lexers/data/scite-context-data-context.lua b/context/data/scite/lexers/data/scite-context-data-context.lua index 0893a4350..de8a000bf 100644 --- a/context/data/scite/lexers/data/scite-context-data-context.lua +++ b/context/data/scite/lexers/data/scite-context-data-context.lua @@ -1,4 +1,4 @@ return { ["constants"]={ "zerocount", "minusone", "minustwo", "plusone", "plustwo", "plusthree", "plusfour", "plusfive", "plussix", "plusseven", "pluseight", "plusnine", "plusten", "plussixteen", "plushundred", "plusthousand", "plustenthousand", "plustwentythousand", "medcard", "maxcard", "zeropoint", "onepoint", "halfapoint", "onebasepoint", "maxdimen", "scaledpoint", "thousandpoint", "points", "halfpoint", "zeroskip", "pluscxxvii", "pluscxxviii", "pluscclv", "pluscclvi", "normalpagebox", "endoflinetoken", "outputnewlinechar", "emptytoks", "empty", "undefined", "voidbox", "emptybox", "emptyvbox", "emptyhbox", "bigskipamount", "medskipamount", "smallskipamount", "fmtname", "fmtversion", "texengine", "texenginename", "texengineversion", "luatexengine", "pdftexengine", "xetexengine", "unknownengine", "etexversion", "pdftexversion", "xetexversion", "xetexrevision", "activecatcode", "bgroup", "egroup", "endline", "conditionaltrue", "conditionalfalse", "attributeunsetvalue", "uprotationangle", "rightrotationangle", "downrotationangle", "leftrotationangle", "inicatcodes", "ctxcatcodes", "texcatcodes", "notcatcodes", "txtcatcodes", "vrbcatcodes", "prtcatcodes", "nilcatcodes", "luacatcodes", "tpacatcodes", "tpbcatcodes", "xmlcatcodes", "escapecatcode", "begingroupcatcode", "endgroupcatcode", "mathshiftcatcode", "alignmentcatcode", "endoflinecatcode", "parametercatcode", "superscriptcatcode", "subscriptcatcode", "ignorecatcode", "spacecatcode", "lettercatcode", "othercatcode", "activecatcode", "commentcatcode", "invalidcatcode", "tabasciicode", "newlineasciicode", "formfeedasciicode", "endoflineasciicode", "endoffileasciicode", "spaceasciicode", "hashasciicode", "dollarasciicode", "commentasciicode", "ampersandasciicode", "colonasciicode", "backslashasciicode", "circumflexasciicode", "underscoreasciicode", "leftbraceasciicode", "barasciicode", "rightbraceasciicode", "tildeasciicode", "delasciicode", "lessthanasciicode", "morethanasciicode", "doublecommentsignal", "atsignasciicode", "exclamationmarkasciicode", "questionmarkasciicode", "doublequoteasciicode", "singlequoteasciicode", "forwardslashasciicode", "primeasciicode", "activemathcharcode", "activetabtoken", "activeformfeedtoken", "activeendoflinetoken", "batchmodecode", "nonstopmodecode", "scrollmodecode", "errorstopmodecode", "bottomlevelgroupcode", "simplegroupcode", "hboxgroupcode", "adjustedhboxgroupcode", "vboxgroupcode", "vtopgroupcode", "aligngroupcode", "noaligngroupcode", "outputgroupcode", "mathgroupcode", "discretionarygroupcode", "insertgroupcode", "vcentergroupcode", "mathchoicegroupcode", "semisimplegroupcode", "mathshiftgroupcode", "mathleftgroupcode", "vadjustgroupcode", "charnodecode", "hlistnodecode", "vlistnodecode", "rulenodecode", "insertnodecode", "marknodecode", "adjustnodecode", "ligaturenodecode", "discretionarynodecode", "whatsitnodecode", "mathnodecode", "gluenodecode", "kernnodecode", "penaltynodecode", "unsetnodecode", "mathsnodecode", "charifcode", "catifcode", "numifcode", "dimifcode", "oddifcode", "vmodeifcode", "hmodeifcode", "mmodeifcode", "innerifcode", "voidifcode", "hboxifcode", "vboxifcode", "xifcode", "eofifcode", "trueifcode", "falseifcode", "caseifcode", "definedifcode", "csnameifcode", "fontcharifcode", "fontslantperpoint", "fontinterwordspace", "fontinterwordstretch", "fontinterwordshrink", "fontexheight", "fontemwidth", "fontextraspace", "slantperpoint", "interwordspace", "interwordstretch", "interwordshrink", "exheight", "emwidth", "extraspace", "mathsupdisplay", "mathsupnormal", "mathsupcramped", "mathsubnormal", "mathsubcombined", "mathaxisheight", "startmode", "stopmode", "startnotmode", "stopnotmode", "startmodeset", "stopmodeset", "doifmode", "doifmodeelse", "doifnotmode", "startallmodes", "stopallmodes", "startnotallmodes", "stopnotallmodes", "doifallmodes", "doifallmodeselse", "doifnotallmodes", "startenvironment", "stopenvironment", "environment", "startcomponent", "stopcomponent", "component", "startproduct", "stopproduct", "product", "startproject", "stopproject", "project", "starttext", "stoptext", "startnotext", "stopnotext", "startdocument", "stopdocument", "documentvariable", "startmodule", "stopmodule", "usemodule", "startTEXpage", "stopTEXpage", "enablemode", "disablemode", "preventmode", "pushmode", "popmode", "typescriptone", "typescripttwo", "typescriptthree", "mathsizesuffix", "mathordcode", "mathopcode", "mathbincode", "mathrelcode", "mathopencode", "mathclosecode", "mathpunctcode", "mathalphacode", "mathinnercode", "mathnothingcode", "mathlimopcode", "mathnolopcode", "mathboxcode", "mathchoicecode", "mathaccentcode", "mathradicalcode", "constantnumber", "constantnumberargument", "constantdimen", "constantdimenargument", "constantemptyargument", "continueifinputfile" }, - ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "startluasetups", "stopluasetups", "starttexsetups", "stoptexsetups", "startrawsetups", "stoprawsetups", "startlocalsetups", "stoplocalsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "startcontextcode", "stopcontextcode", "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "doifelsecommandhandler", "doifnotcommandhandler", "doifcommandhandler", "newmode", "setmode", "resetmode", "newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode", "booleanmodevalue", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "then", "donothing", "dontcomplain", "donetrue", "donefalse", "htdp", "unvoidbox", "vfilll", "mathbox", "mathlimop", "mathnolop", "mathnothing", "mathalpha", "currentcatcodetable", "defaultcatcodetable", "catcodetablename", "newcatcodetable", "startcatcodetable", "stopcatcodetable", "startextendcatcodetable", "stopextendcatcodetable", "pushcatcodetable", "popcatcodetable", "restorecatcodes", "setcatcodetable", "letcatcodecommand", "defcatcodecommand", "uedcatcodecommand", "hglue", "vglue", "hfillneg", "vfillneg", "hfilllneg", "vfilllneg", "ruledhss", "ruledhfil", "ruledhfill", "ruledhfilneg", "ruledhfillneg", "normalhfillneg", "ruledvss", "ruledvfil", "ruledvfill", "ruledvfilneg", "ruledvfillneg", "normalvfillneg", "ruledhbox", "ruledvbox", "ruledvtop", "ruledvcenter", "ruledhskip", "ruledvskip", "ruledkern", "ruledmskip", "ruledmkern", "ruledhglue", "ruledvglue", "normalhglue", "normalvglue", "ruledpenalty", "scratchcounter", "globalscratchcounter", "scratchdimen", "globalscratchdimen", "scratchskip", "globalscratchskip", "scratchmuskip", "globalscratchmuskip", "scratchtoks", "globalscratchtoks", "scratchbox", "globalscratchbox", "nextbox", "dowithnextbox", "dowithnextboxcs", "dowithnextboxcontent", "dowithnextboxcontentcs", "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset", "scratchdistance", "scratchhsize", "scratchvsize", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchboxone", "scratchboxtwo", "scratchboxthree", "doif", "doifnot", "doifelse", "doifinset", "doifnotinset", "doifinsetelse", "doifnextcharelse", "doifnextoptionalelse", "doifnextbgroupelse", "doifnextparenthesiselse", "doiffastoptionalcheckelse", "doifundefinedelse", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifdimensionelse", "doifnumberelse", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifinstringelse", "doifassignmentelse", "tracingall", "tracingnone", "loggingall", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", "endgraf", "empty", "null", "space", "quad", "enspace", "obeyspaces", "obeylines", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "removelastspace", "removeunwantedspaces", "wait", "writestatus", "define", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "measure", "getvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "copyparameters", "processcommalist", "processcommacommand", "quitcommalist", "quitprevcommalist", "processaction", "processallactions", "processfirstactioninset", "processallactionsinset", "unexpanded", "expanded", "startexpanded", "stopexpanded", "protected", "protect", "unprotect", "firstofoneargument", "firstoftwoarguments", "secondoftwoarguments", "firstofthreearguments", "secondofthreearguments", "thirdofthreearguments", "firstoffourarguments", "secondoffourarguments", "thirdoffourarguments", "fourthoffourarguments", "firstoffivearguments", "secondoffivearguments", "thirdoffivearguments", "fourthoffivearguments", "fifthoffivearguments", "firstofsixarguments", "secondofsixarguments", "thirdofsixarguments", "fourthofsixarguments", "fifthofsixarguments", "sixthofsixarguments", "firstofoneunexpanded", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "dofastloopcs", "newconstant", "setnewconstant", "newconditional", "settrue", "setfalse", "setconstant", "newmacro", "setnewmacro", "newfraction", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosingleargument", "dodoubleargument", "dotripleargument", "doquadrupleargument", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doiffirstcharelse", "startnointerference", "stopnointerference", "strut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "begstrut", "endstrut" }, + ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "startluasetups", "stopluasetups", "starttexsetups", "stoptexsetups", "startrawsetups", "stoprawsetups", "startlocalsetups", "stoplocalsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "startcontextcode", "stopcontextcode", "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "doifelsecommandhandler", "doifnotcommandhandler", "doifcommandhandler", "newmode", "setmode", "resetmode", "newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode", "booleanmodevalue", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "then", "donothing", "dontcomplain", "donetrue", "donefalse", "htdp", "unvoidbox", "vfilll", "mathbox", "mathlimop", "mathnolop", "mathnothing", "mathalpha", "currentcatcodetable", "defaultcatcodetable", "catcodetablename", "newcatcodetable", "startcatcodetable", "stopcatcodetable", "startextendcatcodetable", "stopextendcatcodetable", "pushcatcodetable", "popcatcodetable", "restorecatcodes", "setcatcodetable", "letcatcodecommand", "defcatcodecommand", "uedcatcodecommand", "hglue", "vglue", "hfillneg", "vfillneg", "hfilllneg", "vfilllneg", "ruledhss", "ruledhfil", "ruledhfill", "ruledhfilneg", "ruledhfillneg", "normalhfillneg", "ruledvss", "ruledvfil", "ruledvfill", "ruledvfilneg", "ruledvfillneg", "normalvfillneg", "ruledhbox", "ruledvbox", "ruledvtop", "ruledvcenter", "ruledhskip", "ruledvskip", "ruledkern", "ruledmskip", "ruledmkern", "ruledhglue", "ruledvglue", "normalhglue", "normalvglue", "ruledpenalty", "scratchcounter", "globalscratchcounter", "scratchdimen", "globalscratchdimen", "scratchskip", "globalscratchskip", "scratchmuskip", "globalscratchmuskip", "scratchtoks", "globalscratchtoks", "scratchbox", "globalscratchbox", "nextbox", "dowithnextbox", "dowithnextboxcs", "dowithnextboxcontent", "dowithnextboxcontentcs", "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset", "scratchdistance", "scratchhsize", "scratchvsize", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchboxone", "scratchboxtwo", "scratchboxthree", "doif", "doifnot", "doifelse", "doifinset", "doifnotinset", "doifinsetelse", "doifnextcharelse", "doifnextoptionalelse", "doifnextbgroupelse", "doifnextparenthesiselse", "doiffastoptionalcheckelse", "doifundefinedelse", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifdimensionelse", "doifnumberelse", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifinstringelse", "doifassignmentelse", "tracingall", "tracingnone", "loggingall", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", "endgraf", "empty", "null", "space", "quad", "enspace", "obeyspaces", "obeylines", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "removelastspace", "removeunwantedspaces", "wait", "writestatus", "define", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "measure", "getvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "copyparameters", "getdummyparameters", "dummyparameter", "directdummyparameter", "processcommalist", "processcommacommand", "quitcommalist", "quitprevcommalist", "processaction", "processallactions", "processfirstactioninset", "processallactionsinset", "unexpanded", "expanded", "startexpanded", "stopexpanded", "protected", "protect", "unprotect", "firstofoneargument", "firstoftwoarguments", "secondoftwoarguments", "firstofthreearguments", "secondofthreearguments", "thirdofthreearguments", "firstoffourarguments", "secondoffourarguments", "thirdoffourarguments", "fourthoffourarguments", "firstoffivearguments", "secondoffivearguments", "thirdoffivearguments", "fourthoffivearguments", "fifthoffivearguments", "firstofsixarguments", "secondofsixarguments", "thirdofsixarguments", "fourthofsixarguments", "fifthofsixarguments", "sixthofsixarguments", "firstofoneunexpanded", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "dofastloopcs", "newconstant", "setnewconstant", "newconditional", "settrue", "setfalse", "setconstant", "newmacro", "setnewmacro", "newfraction", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosingleargument", "dodoubleargument", "dotripleargument", "doquadrupleargument", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doiffirstcharelse", "startnointerference", "stopnointerference", "strut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "begstrut", "endstrut" }, } \ No newline at end of file diff --git a/context/data/scite/scite-context-data-context.properties b/context/data/scite/scite-context-data-context.properties index 34ee443dd..4d0aca488 100644 --- a/context/data/scite/scite-context-data-context.properties +++ b/context/data/scite/scite-context-data-context.properties @@ -48,27 +48,28 @@ measure getvalue setvalue setevalue setgvalue \ setxvalue letvalue letgvalue resetvalue undefinevalue \ ignorevalue setuvalue setuevalue setugvalue setuxvalue \ globallet glet getparameters geteparameters getgparameters \ -getxparameters forgetparameters copyparameters processcommalist processcommacommand \ -quitcommalist quitprevcommalist processaction processallactions processfirstactioninset \ -processallactionsinset unexpanded expanded startexpanded stopexpanded \ -protected protect unprotect firstofoneargument firstoftwoarguments \ -secondoftwoarguments firstofthreearguments secondofthreearguments thirdofthreearguments firstoffourarguments \ -secondoffourarguments thirdoffourarguments fourthoffourarguments firstoffivearguments secondoffivearguments \ -thirdoffivearguments fourthoffivearguments fifthoffivearguments firstofsixarguments secondofsixarguments \ -thirdofsixarguments fourthofsixarguments fifthofsixarguments sixthofsixarguments firstofoneunexpanded \ -gobbleoneargument gobbletwoarguments gobblethreearguments gobblefourarguments gobblefivearguments \ -gobblesixarguments gobblesevenarguments gobbleeightarguments gobbleninearguments gobbletenarguments \ -gobbleoneoptional gobbletwooptionals gobblethreeoptionals gobblefouroptionals gobblefiveoptionals \ -dorecurse doloop exitloop dostepwiserecurse recurselevel \ -recursedepth dofastloopcs newconstant setnewconstant newconditional \ -settrue setfalse setconstant newmacro setnewmacro \ -newfraction dosingleempty dodoubleempty dotripleempty doquadrupleempty \ -doquintupleempty dosixtupleempty doseventupleempty dosingleargument dodoubleargument \ -dotripleargument doquadrupleargument dosinglegroupempty dodoublegroupempty dotriplegroupempty \ -doquadruplegroupempty doquintuplegroupempty nopdfcompression maximumpdfcompression normalpdfcompression \ -modulonumber dividenumber getfirstcharacter doiffirstcharelse startnointerference \ -stopnointerference strut setstrut strutbox strutht \ -strutdp strutwd begstrut endstrut +getxparameters forgetparameters copyparameters getdummyparameters dummyparameter \ +directdummyparameter processcommalist processcommacommand quitcommalist quitprevcommalist \ +processaction processallactions processfirstactioninset processallactionsinset unexpanded \ +expanded startexpanded stopexpanded protected protect \ +unprotect firstofoneargument firstoftwoarguments secondoftwoarguments firstofthreearguments \ +secondofthreearguments thirdofthreearguments firstoffourarguments secondoffourarguments thirdoffourarguments \ +fourthoffourarguments firstoffivearguments secondoffivearguments thirdoffivearguments fourthoffivearguments \ +fifthoffivearguments firstofsixarguments secondofsixarguments thirdofsixarguments fourthofsixarguments \ +fifthofsixarguments sixthofsixarguments firstofoneunexpanded gobbleoneargument gobbletwoarguments \ +gobblethreearguments gobblefourarguments gobblefivearguments gobblesixarguments gobblesevenarguments \ +gobbleeightarguments gobbleninearguments gobbletenarguments gobbleoneoptional gobbletwooptionals \ +gobblethreeoptionals gobblefouroptionals gobblefiveoptionals dorecurse doloop \ +exitloop dostepwiserecurse recurselevel recursedepth dofastloopcs \ +newconstant setnewconstant newconditional settrue setfalse \ +setconstant newmacro setnewmacro newfraction dosingleempty \ +dodoubleempty dotripleempty doquadrupleempty doquintupleempty dosixtupleempty \ +doseventupleempty dosingleargument dodoubleargument dotripleargument doquadrupleargument \ +dosinglegroupempty dodoublegroupempty dotriplegroupempty doquadruplegroupempty doquintuplegroupempty \ +nopdfcompression maximumpdfcompression normalpdfcompression modulonumber dividenumber \ +getfirstcharacter doiffirstcharelse startnointerference stopnointerference strut \ +setstrut strutbox strutht strutdp strutwd \ +begstrut endstrut keywordclass.context.constants=\ zerocount minusone minustwo plusone \ diff --git a/metapost/context/base/mp-crop.mpiv b/metapost/context/base/mp-crop.mpiv index 6360757e5..3ba384a1f 100644 --- a/metapost/context/base/mp-crop.mpiv +++ b/metapost/context/base/mp-crop.mpiv @@ -15,20 +15,20 @@ if known context_crop : endinput ; fi ; boolean context_crop ; context_crop := true ; -vardef crop_marks_lines (expr box, length, offset, nx, ny) = - save p ; picture p ; save w, h, x, y ; numeric w, h, x, y ; +vardef crop_marks_lines (expr box, len, offset, nx, ny) = + save p ; picture p ; save w, h, x, y ; numeric w, h, x, y ; p := image ( x := if nx = 0 : 1 else : nx - 1 fi ; y := if ny = 0 : 1 else : ny - 1 fi ; w := bbwidth (box) / x ; h := bbheight(box) / y ; for i=0 upto y : - draw ((llcorner box) -- (llcorner box) shifted (-length,0)) shifted (-offset,i*h) ; - draw ((lrcorner box) -- (lrcorner box) shifted ( length,0)) shifted ( offset,i*h) ; + draw ((llcorner box) -- (llcorner box) shifted (-len,0)) shifted (-offset,i*h) ; + draw ((lrcorner box) -- (lrcorner box) shifted ( len,0)) shifted ( offset,i*h) ; endfor ; for i=0 upto x : - draw ((llcorner box) -- (llcorner box) shifted (0,-length)) shifted (i*w,-offset) ; - draw ((ulcorner box) -- (ulcorner box) shifted (0, length)) shifted (i*w, offset) ; + draw ((llcorner box) -- (llcorner box) shifted (0,-len)) shifted (i*w,-offset) ; + draw ((ulcorner box) -- (ulcorner box) shifted (0, len)) shifted (i*w, offset) ; endfor ; ) ; setbounds p to box ; diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index cc3d9c1ad..12ee56f74 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -11107,12 +11107,14 @@ local function splitpathexpr(str, newlist, validate) -- I couldn't resist lpeggi for s in gmatch(str,"[^,]+") do s = validate(s) if s then - n = n + 1 ; t[n] = s + n = n + 1 + t[n] = s end end else for s in gmatch(str,"[^,]+") do - n = n + 1 ; t[n] = s + n = n + 1 + t[n] = s end end if trace_expansions then @@ -11126,7 +11128,7 @@ end -- We could make the previous one public. local function validate(s) - s = collapsepath(s) -- already keeps the // + s = collapsepath(s) -- already keeps the trailing / and // return s ~= "" and not find(s,"^!*unset/*$") and s end @@ -12292,6 +12294,7 @@ local filejoin = file.join local collapsepath = file.collapsepath local joinpath = file.joinpath local allocate = utilities.storage.allocate +local settings_to_array = utilities.parsers.settings_to_array local setmetatableindex = table.setmetatableindex local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end) @@ -12315,7 +12318,7 @@ resolvers.cacheversion = '1.0.1' resolvers.configbanner = '' resolvers.homedir = environment.homedir resolvers.criticalvars = allocate { "SELFAUTOLOC", "SELFAUTODIR", "SELFAUTOPARENT", "TEXMFCNF", "TEXMF", "TEXOS" } -resolvers.luacnfname = 'texmfcnf.lua' +resolvers.luacnfname = "texmfcnf.lua" resolvers.luacnfstate = "unknown" -- The web2c tex binaries as well as kpse have built in paths for the configuration @@ -12587,7 +12590,7 @@ end local function identify_configuration_files() local specification = instance.specification if #specification == 0 then - local cnfspec = getenv('TEXMFCNF') + local cnfspec = getenv("TEXMFCNF") if cnfspec == "" then cnfspec = resolvers.luacnfspec resolvers.luacnfstate = "default" @@ -12675,7 +12678,7 @@ local function load_configuration_files() -- we push the value into the main environment (osenv) so -- that it takes precedence over the default one and therefore -- also over following definitions - resolvers.setenv('TEXMFCNF',cnfspec) -- resolves prefixes + resolvers.setenv("TEXMFCNF",cnfspec) -- resolves prefixes -- we now identify and load the specified configuration files instance.specification = { } identify_configuration_files() @@ -12723,10 +12726,11 @@ end local function locate_file_databases() -- todo: cache:// and tree:// (runtime) - local texmfpaths = resolvers.expandedpathlist('TEXMF') + local texmfpaths = resolvers.expandedpathlist("TEXMF") if #texmfpaths > 0 then for i=1,#texmfpaths do local path = collapsepath(texmfpaths[i]) + path = gsub(path,"/+$","") -- in case $HOME expands to something with a trailing / local stripped = lpegmatch(inhibitstripper,path) -- the !! thing if stripped ~= "" then local runtime = stripped == path @@ -12855,9 +12859,9 @@ function resolvers.prependhash(type,name,cache) end function resolvers.extendtexmfvariable(specification) -- crap, we could better prepend the hash - local t = resolvers.splitpath(getenv('TEXMF')) + local t = resolvers.splitpath(getenv("TEXMF")) -- okay? insert(t,1,specification) - local newspec = concat(t,";") + local newspec = concat(t,",") -- not ; if instance.environment["TEXMF"] then instance.environment["TEXMF"] = newspec elseif instance.variables["TEXMF"] then @@ -12932,14 +12936,19 @@ function resolvers.resetextrapath() end function resolvers.registerextrapath(paths,subpaths) + paths = paths and settings_to_array(paths) + subpaths = subpaths and settings_to_array(subpaths) local ep = instance.extra_paths or { } local oldn = #ep local newn = oldn - if paths and paths ~= "" then - if subpaths and subpaths ~= "" then - for p in gmatch(paths,"[^,]+") do - -- we gmatch each step again, not that fast, but used seldom - for s in gmatch(subpaths,"[^,]+") do + local nofpaths = #paths + local nofsubpaths = #subpaths + if nofpaths > 0 then + if nofsubpaths > 0 then + for i=1,nofpaths do + local p = paths[i] + for j=1,nofsubpaths do + local s = subpaths[j] local ps = p .. "/" .. s if not done[ps] then newn = newn + 1 @@ -12949,7 +12958,8 @@ function resolvers.registerextrapath(paths,subpaths) end end else - for p in gmatch(paths,"[^,]+") do + for i=1,nofpaths do + local p = paths[i] if not done[p] then newn = newn + 1 ep[newn] = resolvers.cleanpath(p) @@ -12957,10 +12967,10 @@ function resolvers.registerextrapath(paths,subpaths) end end end - elseif subpaths and subpaths ~= "" then + elseif nofsubpaths > 0 then for i=1,oldn do - -- we gmatch each step again, not that fast, but used seldom - for s in gmatch(subpaths,"[^,]+") do + for j=1,nofsubpaths do + local s = subpaths[j] local ps = ep[i] .. "/" .. s if not done[ps] then newn = newn + 1 @@ -13038,11 +13048,14 @@ function resolvers.expandedpathlist(str) return { } elseif instance.savelists then str = lpegmatch(dollarstripper,str) - if not instance.lists[str] then -- cached - local lst = made_list(instance,resolvers.splitpath(resolvers.expansion(str))) - instance.lists[str] = expandedpathfromlist(lst) - end - return instance.lists[str] + local lists = instance.lists + local lst = lists[str] + if not lst then + local l = made_list(instance,resolvers.splitpath(resolvers.expansion(str))) + lst = expandedpathfromlist(l) + lists[str] = lst + end + return lst else local lst = resolvers.splitpath(resolvers.expansion(str)) return made_list(instance,expandedpathfromlist(lst)) diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index cc3d9c1ad..12ee56f74 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -11107,12 +11107,14 @@ local function splitpathexpr(str, newlist, validate) -- I couldn't resist lpeggi for s in gmatch(str,"[^,]+") do s = validate(s) if s then - n = n + 1 ; t[n] = s + n = n + 1 + t[n] = s end end else for s in gmatch(str,"[^,]+") do - n = n + 1 ; t[n] = s + n = n + 1 + t[n] = s end end if trace_expansions then @@ -11126,7 +11128,7 @@ end -- We could make the previous one public. local function validate(s) - s = collapsepath(s) -- already keeps the // + s = collapsepath(s) -- already keeps the trailing / and // return s ~= "" and not find(s,"^!*unset/*$") and s end @@ -12292,6 +12294,7 @@ local filejoin = file.join local collapsepath = file.collapsepath local joinpath = file.joinpath local allocate = utilities.storage.allocate +local settings_to_array = utilities.parsers.settings_to_array local setmetatableindex = table.setmetatableindex local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end) @@ -12315,7 +12318,7 @@ resolvers.cacheversion = '1.0.1' resolvers.configbanner = '' resolvers.homedir = environment.homedir resolvers.criticalvars = allocate { "SELFAUTOLOC", "SELFAUTODIR", "SELFAUTOPARENT", "TEXMFCNF", "TEXMF", "TEXOS" } -resolvers.luacnfname = 'texmfcnf.lua' +resolvers.luacnfname = "texmfcnf.lua" resolvers.luacnfstate = "unknown" -- The web2c tex binaries as well as kpse have built in paths for the configuration @@ -12587,7 +12590,7 @@ end local function identify_configuration_files() local specification = instance.specification if #specification == 0 then - local cnfspec = getenv('TEXMFCNF') + local cnfspec = getenv("TEXMFCNF") if cnfspec == "" then cnfspec = resolvers.luacnfspec resolvers.luacnfstate = "default" @@ -12675,7 +12678,7 @@ local function load_configuration_files() -- we push the value into the main environment (osenv) so -- that it takes precedence over the default one and therefore -- also over following definitions - resolvers.setenv('TEXMFCNF',cnfspec) -- resolves prefixes + resolvers.setenv("TEXMFCNF",cnfspec) -- resolves prefixes -- we now identify and load the specified configuration files instance.specification = { } identify_configuration_files() @@ -12723,10 +12726,11 @@ end local function locate_file_databases() -- todo: cache:// and tree:// (runtime) - local texmfpaths = resolvers.expandedpathlist('TEXMF') + local texmfpaths = resolvers.expandedpathlist("TEXMF") if #texmfpaths > 0 then for i=1,#texmfpaths do local path = collapsepath(texmfpaths[i]) + path = gsub(path,"/+$","") -- in case $HOME expands to something with a trailing / local stripped = lpegmatch(inhibitstripper,path) -- the !! thing if stripped ~= "" then local runtime = stripped == path @@ -12855,9 +12859,9 @@ function resolvers.prependhash(type,name,cache) end function resolvers.extendtexmfvariable(specification) -- crap, we could better prepend the hash - local t = resolvers.splitpath(getenv('TEXMF')) + local t = resolvers.splitpath(getenv("TEXMF")) -- okay? insert(t,1,specification) - local newspec = concat(t,";") + local newspec = concat(t,",") -- not ; if instance.environment["TEXMF"] then instance.environment["TEXMF"] = newspec elseif instance.variables["TEXMF"] then @@ -12932,14 +12936,19 @@ function resolvers.resetextrapath() end function resolvers.registerextrapath(paths,subpaths) + paths = paths and settings_to_array(paths) + subpaths = subpaths and settings_to_array(subpaths) local ep = instance.extra_paths or { } local oldn = #ep local newn = oldn - if paths and paths ~= "" then - if subpaths and subpaths ~= "" then - for p in gmatch(paths,"[^,]+") do - -- we gmatch each step again, not that fast, but used seldom - for s in gmatch(subpaths,"[^,]+") do + local nofpaths = #paths + local nofsubpaths = #subpaths + if nofpaths > 0 then + if nofsubpaths > 0 then + for i=1,nofpaths do + local p = paths[i] + for j=1,nofsubpaths do + local s = subpaths[j] local ps = p .. "/" .. s if not done[ps] then newn = newn + 1 @@ -12949,7 +12958,8 @@ function resolvers.registerextrapath(paths,subpaths) end end else - for p in gmatch(paths,"[^,]+") do + for i=1,nofpaths do + local p = paths[i] if not done[p] then newn = newn + 1 ep[newn] = resolvers.cleanpath(p) @@ -12957,10 +12967,10 @@ function resolvers.registerextrapath(paths,subpaths) end end end - elseif subpaths and subpaths ~= "" then + elseif nofsubpaths > 0 then for i=1,oldn do - -- we gmatch each step again, not that fast, but used seldom - for s in gmatch(subpaths,"[^,]+") do + for j=1,nofsubpaths do + local s = subpaths[j] local ps = ep[i] .. "/" .. s if not done[ps] then newn = newn + 1 @@ -13038,11 +13048,14 @@ function resolvers.expandedpathlist(str) return { } elseif instance.savelists then str = lpegmatch(dollarstripper,str) - if not instance.lists[str] then -- cached - local lst = made_list(instance,resolvers.splitpath(resolvers.expansion(str))) - instance.lists[str] = expandedpathfromlist(lst) - end - return instance.lists[str] + local lists = instance.lists + local lst = lists[str] + if not lst then + local l = made_list(instance,resolvers.splitpath(resolvers.expansion(str))) + lst = expandedpathfromlist(l) + lists[str] = lst + end + return lst else local lst = resolvers.splitpath(resolvers.expansion(str)) return made_list(instance,expandedpathfromlist(lst)) diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index cc3d9c1ad..12ee56f74 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -11107,12 +11107,14 @@ local function splitpathexpr(str, newlist, validate) -- I couldn't resist lpeggi for s in gmatch(str,"[^,]+") do s = validate(s) if s then - n = n + 1 ; t[n] = s + n = n + 1 + t[n] = s end end else for s in gmatch(str,"[^,]+") do - n = n + 1 ; t[n] = s + n = n + 1 + t[n] = s end end if trace_expansions then @@ -11126,7 +11128,7 @@ end -- We could make the previous one public. local function validate(s) - s = collapsepath(s) -- already keeps the // + s = collapsepath(s) -- already keeps the trailing / and // return s ~= "" and not find(s,"^!*unset/*$") and s end @@ -12292,6 +12294,7 @@ local filejoin = file.join local collapsepath = file.collapsepath local joinpath = file.joinpath local allocate = utilities.storage.allocate +local settings_to_array = utilities.parsers.settings_to_array local setmetatableindex = table.setmetatableindex local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end) @@ -12315,7 +12318,7 @@ resolvers.cacheversion = '1.0.1' resolvers.configbanner = '' resolvers.homedir = environment.homedir resolvers.criticalvars = allocate { "SELFAUTOLOC", "SELFAUTODIR", "SELFAUTOPARENT", "TEXMFCNF", "TEXMF", "TEXOS" } -resolvers.luacnfname = 'texmfcnf.lua' +resolvers.luacnfname = "texmfcnf.lua" resolvers.luacnfstate = "unknown" -- The web2c tex binaries as well as kpse have built in paths for the configuration @@ -12587,7 +12590,7 @@ end local function identify_configuration_files() local specification = instance.specification if #specification == 0 then - local cnfspec = getenv('TEXMFCNF') + local cnfspec = getenv("TEXMFCNF") if cnfspec == "" then cnfspec = resolvers.luacnfspec resolvers.luacnfstate = "default" @@ -12675,7 +12678,7 @@ local function load_configuration_files() -- we push the value into the main environment (osenv) so -- that it takes precedence over the default one and therefore -- also over following definitions - resolvers.setenv('TEXMFCNF',cnfspec) -- resolves prefixes + resolvers.setenv("TEXMFCNF",cnfspec) -- resolves prefixes -- we now identify and load the specified configuration files instance.specification = { } identify_configuration_files() @@ -12723,10 +12726,11 @@ end local function locate_file_databases() -- todo: cache:// and tree:// (runtime) - local texmfpaths = resolvers.expandedpathlist('TEXMF') + local texmfpaths = resolvers.expandedpathlist("TEXMF") if #texmfpaths > 0 then for i=1,#texmfpaths do local path = collapsepath(texmfpaths[i]) + path = gsub(path,"/+$","") -- in case $HOME expands to something with a trailing / local stripped = lpegmatch(inhibitstripper,path) -- the !! thing if stripped ~= "" then local runtime = stripped == path @@ -12855,9 +12859,9 @@ function resolvers.prependhash(type,name,cache) end function resolvers.extendtexmfvariable(specification) -- crap, we could better prepend the hash - local t = resolvers.splitpath(getenv('TEXMF')) + local t = resolvers.splitpath(getenv("TEXMF")) -- okay? insert(t,1,specification) - local newspec = concat(t,";") + local newspec = concat(t,",") -- not ; if instance.environment["TEXMF"] then instance.environment["TEXMF"] = newspec elseif instance.variables["TEXMF"] then @@ -12932,14 +12936,19 @@ function resolvers.resetextrapath() end function resolvers.registerextrapath(paths,subpaths) + paths = paths and settings_to_array(paths) + subpaths = subpaths and settings_to_array(subpaths) local ep = instance.extra_paths or { } local oldn = #ep local newn = oldn - if paths and paths ~= "" then - if subpaths and subpaths ~= "" then - for p in gmatch(paths,"[^,]+") do - -- we gmatch each step again, not that fast, but used seldom - for s in gmatch(subpaths,"[^,]+") do + local nofpaths = #paths + local nofsubpaths = #subpaths + if nofpaths > 0 then + if nofsubpaths > 0 then + for i=1,nofpaths do + local p = paths[i] + for j=1,nofsubpaths do + local s = subpaths[j] local ps = p .. "/" .. s if not done[ps] then newn = newn + 1 @@ -12949,7 +12958,8 @@ function resolvers.registerextrapath(paths,subpaths) end end else - for p in gmatch(paths,"[^,]+") do + for i=1,nofpaths do + local p = paths[i] if not done[p] then newn = newn + 1 ep[newn] = resolvers.cleanpath(p) @@ -12957,10 +12967,10 @@ function resolvers.registerextrapath(paths,subpaths) end end end - elseif subpaths and subpaths ~= "" then + elseif nofsubpaths > 0 then for i=1,oldn do - -- we gmatch each step again, not that fast, but used seldom - for s in gmatch(subpaths,"[^,]+") do + for j=1,nofsubpaths do + local s = subpaths[j] local ps = ep[i] .. "/" .. s if not done[ps] then newn = newn + 1 @@ -13038,11 +13048,14 @@ function resolvers.expandedpathlist(str) return { } elseif instance.savelists then str = lpegmatch(dollarstripper,str) - if not instance.lists[str] then -- cached - local lst = made_list(instance,resolvers.splitpath(resolvers.expansion(str))) - instance.lists[str] = expandedpathfromlist(lst) - end - return instance.lists[str] + local lists = instance.lists + local lst = lists[str] + if not lst then + local l = made_list(instance,resolvers.splitpath(resolvers.expansion(str))) + lst = expandedpathfromlist(l) + lists[str] = lst + end + return lst else local lst = resolvers.splitpath(resolvers.expansion(str)) return made_list(instance,expandedpathfromlist(lst)) diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv index 9e441e224..332d7ea89 100644 --- a/tex/context/base/back-pdf.mkiv +++ b/tex/context/base/back-pdf.mkiv @@ -220,12 +220,12 @@ \newbox\objectbox -\def\dostartobject#1#2#3#4#5% +\unexpanded\def\dostartobject#1#2#3#4#5% needs to be \unexpanded {\bgroup \setbox\objectbox\vbox\bgroup \def\back_object_stop{\egroup\back_object_register{#1}{#2}}} -\def\dostopobject +\unexpanded\def\dostopobject % needs to be \unexpanded {\back_object_stop \egroup} @@ -237,9 +237,6 @@ \immediate\pdfxform resources {\pdfbackendcurrentresources}\objectbox \dosetobjectreference{#1}{#2}{\the\pdflastxform}} -\def\doresetobjects - {} - \let\m_back_object_reference\empty \def\doinsertobject#1#2% diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 484feffbc..f67ff38ef 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.06.12 09:56} +\newcontextversion{2012.06.13 09:57} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index fcd31610c..59ebd9ad6 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.06.12 09:56} +\newcontextversion{2012.06.13 09:57} %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-version.pdf b/tex/context/base/context-version.pdf index 0f949075a..c28388200 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index adf4b170f..f8110d973 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index a58242a24..f0f272d16 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2012.06.12 09:56} +\edef\contextversion{2012.06.13 09:57} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index dd1f6d058..1551bf94d 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -23,7 +23,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.06.12 09:56} +\edef\contextversion{2012.06.13 09:57} %D For those who want to use this: @@ -131,7 +131,7 @@ \loadmarkfile{node-fin} \loadmarkfile{node-mig} -\loadmarkfile{node-par} +\loadmarkfile{typo-bld} % par builders %loadmarkfile{node-pag} \loadmarkfile{back-ini} @@ -186,7 +186,7 @@ \loadmarkfile{node-bck} % overloads anch-pgr (experimental and undocumented) -\loadmarkfile{trac-vis} +\loadmarkfile{pack-cut} % leftovers from trac-vis \loadmarkfile{lang-mis} \loadmarkfile{lang-url} @@ -419,7 +419,7 @@ \loadmarkfile{core-fnt} \loadmarkfile{node-rul} -\loadmarkfile{node-spl} +\loadmarkfile{font-sol} % font solutions \loadmkvifile{strc-not} \loadmkvifile{strc-lnt} diff --git a/tex/context/base/data-exp.lua b/tex/context/base/data-exp.lua index 66bbb56cb..550b61689 100644 --- a/tex/context/base/data-exp.lua +++ b/tex/context/base/data-exp.lua @@ -114,12 +114,14 @@ local function splitpathexpr(str, newlist, validate) -- I couldn't resist lpeggi for s in gmatch(str,"[^,]+") do s = validate(s) if s then - n = n + 1 ; t[n] = s + n = n + 1 + t[n] = s end end else for s in gmatch(str,"[^,]+") do - n = n + 1 ; t[n] = s + n = n + 1 + t[n] = s end end if trace_expansions then @@ -133,7 +135,7 @@ end -- We could make the previous one public. local function validate(s) - s = collapsepath(s) -- already keeps the // + s = collapsepath(s) -- already keeps the trailing / and // return s ~= "" and not find(s,"^!*unset/*$") and s end diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua index 7206c0d78..362cacf58 100644 --- a/tex/context/base/data-res.lua +++ b/tex/context/base/data-res.lua @@ -29,6 +29,7 @@ local filejoin = file.join local collapsepath = file.collapsepath local joinpath = file.joinpath local allocate = utilities.storage.allocate +local settings_to_array = utilities.parsers.settings_to_array local setmetatableindex = table.setmetatableindex local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end) @@ -52,7 +53,7 @@ resolvers.cacheversion = '1.0.1' resolvers.configbanner = '' resolvers.homedir = environment.homedir resolvers.criticalvars = allocate { "SELFAUTOLOC", "SELFAUTODIR", "SELFAUTOPARENT", "TEXMFCNF", "TEXMF", "TEXOS" } -resolvers.luacnfname = 'texmfcnf.lua' +resolvers.luacnfname = "texmfcnf.lua" resolvers.luacnfstate = "unknown" -- The web2c tex binaries as well as kpse have built in paths for the configuration @@ -332,7 +333,7 @@ end local function identify_configuration_files() local specification = instance.specification if #specification == 0 then - local cnfspec = getenv('TEXMFCNF') + local cnfspec = getenv("TEXMFCNF") if cnfspec == "" then cnfspec = resolvers.luacnfspec resolvers.luacnfstate = "default" @@ -420,7 +421,7 @@ local function load_configuration_files() -- we push the value into the main environment (osenv) so -- that it takes precedence over the default one and therefore -- also over following definitions - resolvers.setenv('TEXMFCNF',cnfspec) -- resolves prefixes + resolvers.setenv("TEXMFCNF",cnfspec) -- resolves prefixes -- we now identify and load the specified configuration files instance.specification = { } identify_configuration_files() @@ -468,10 +469,11 @@ end local function locate_file_databases() -- todo: cache:// and tree:// (runtime) - local texmfpaths = resolvers.expandedpathlist('TEXMF') + local texmfpaths = resolvers.expandedpathlist("TEXMF") if #texmfpaths > 0 then for i=1,#texmfpaths do local path = collapsepath(texmfpaths[i]) + path = gsub(path,"/+$","") -- in case $HOME expands to something with a trailing / local stripped = lpegmatch(inhibitstripper,path) -- the !! thing if stripped ~= "" then local runtime = stripped == path @@ -600,9 +602,9 @@ function resolvers.prependhash(type,name,cache) end function resolvers.extendtexmfvariable(specification) -- crap, we could better prepend the hash - local t = resolvers.splitpath(getenv('TEXMF')) + local t = resolvers.splitpath(getenv("TEXMF")) -- okay? insert(t,1,specification) - local newspec = concat(t,";") + local newspec = concat(t,",") -- not ; if instance.environment["TEXMF"] then instance.environment["TEXMF"] = newspec elseif instance.variables["TEXMF"] then @@ -677,14 +679,19 @@ function resolvers.resetextrapath() end function resolvers.registerextrapath(paths,subpaths) + paths = paths and settings_to_array(paths) + subpaths = subpaths and settings_to_array(subpaths) local ep = instance.extra_paths or { } local oldn = #ep local newn = oldn - if paths and paths ~= "" then - if subpaths and subpaths ~= "" then - for p in gmatch(paths,"[^,]+") do - -- we gmatch each step again, not that fast, but used seldom - for s in gmatch(subpaths,"[^,]+") do + local nofpaths = #paths + local nofsubpaths = #subpaths + if nofpaths > 0 then + if nofsubpaths > 0 then + for i=1,nofpaths do + local p = paths[i] + for j=1,nofsubpaths do + local s = subpaths[j] local ps = p .. "/" .. s if not done[ps] then newn = newn + 1 @@ -694,7 +701,8 @@ function resolvers.registerextrapath(paths,subpaths) end end else - for p in gmatch(paths,"[^,]+") do + for i=1,nofpaths do + local p = paths[i] if not done[p] then newn = newn + 1 ep[newn] = resolvers.cleanpath(p) @@ -702,10 +710,10 @@ function resolvers.registerextrapath(paths,subpaths) end end end - elseif subpaths and subpaths ~= "" then + elseif nofsubpaths > 0 then for i=1,oldn do - -- we gmatch each step again, not that fast, but used seldom - for s in gmatch(subpaths,"[^,]+") do + for j=1,nofsubpaths do + local s = subpaths[j] local ps = ep[i] .. "/" .. s if not done[ps] then newn = newn + 1 @@ -783,11 +791,14 @@ function resolvers.expandedpathlist(str) return { } elseif instance.savelists then str = lpegmatch(dollarstripper,str) - if not instance.lists[str] then -- cached - local lst = made_list(instance,resolvers.splitpath(resolvers.expansion(str))) - instance.lists[str] = expandedpathfromlist(lst) - end - return instance.lists[str] + local lists = instance.lists + local lst = lists[str] + if not lst then + local l = made_list(instance,resolvers.splitpath(resolvers.expansion(str))) + lst = expandedpathfromlist(l) + lists[str] = lst + end + return lst else local lst = resolvers.splitpath(resolvers.expansion(str)) return made_list(instance,expandedpathfromlist(lst)) diff --git a/tex/context/base/font-sol.lua b/tex/context/base/font-sol.lua new file mode 100644 index 000000000..08ab533dd --- /dev/null +++ b/tex/context/base/font-sol.lua @@ -0,0 +1,731 @@ +if not modules then modules = { } end modules ['font-sol'] = { -- this was: node-spl + version = 1.001, + comment = "companion to font-sol.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- This module is dedicated to the oriental tex project and for +-- the moment is too experimental to be publicly supported. +-- +-- We could cache solutions: say that we store the featureset and +-- all 'words' -> replacement ... so we create a large solution +-- database (per font) +-- +-- This module can be optimized by using a dedicated dynamics handler +-- but I'll only do that when the rest of the code is stable. +-- +-- Todo: bind setups to paragraph. + +local gmatch, concat, format, remove = string.gmatch, table.concat, string.format, table.remove +local next, tostring, tonumber = next, tostring, tonumber +local insert, remove = table.insert, table.remove +local utfchar = utf.char +local random = math.random + +local trace_split = false trackers.register("builders.paragraphs.solutions.splitters.splitter", function(v) trace_split = v end) +local trace_optimize = false trackers.register("builders.paragraphs.solutions.splitters.optimizer", function(v) trace_optimize = v end) +local trace_colors = false trackers.register("builders.paragraphs.solutions.splitters.colors", function(v) trace_colors = v end) +local trace_goodies = false trackers.register("fonts.goodies", function(v) trace_goodies = v end) + +local report_solutions = logs.reporter("fonts","solutions") +local report_splitters = logs.reporter("nodes","splitters") +local report_optimizers = logs.reporter("nodes","optimizers") + +local nodes, node = nodes, node + +local variables = interfaces.variables + +local v_normal = variables.normal +local v_reverse = variables.reverse +local v_preroll = variables.preroll +local v_random = variables.random +local v_less = variables.less +local v_more = variables.more + +local settings_to_array = utilities.parsers.settings_to_array +local settings_to_hash = utilities.parsers.settings_to_hash + +local find_node_tail = node.tail or node.slide +local free_node = node.free +local free_nodelist = node.flush_list +local has_attribute = node.has_attribute +local set_attribute = node.set_attribute +local new_node = node.new +local copy_node = node.copy +local copy_nodelist = node.copy_list +local traverse_nodes = node.traverse +local traverse_ids = node.traverse_id +local protect_glyphs = nodes.handlers.protectglyphs or node.protect_glyphs +local hpack_nodes = node.hpack +local insert_node_before = node.insert_before +local insert_node_after = node.insert_after +local repack_hlist = nodes.repackhlist + +local setnodecolor = nodes.tracers.colors.set + +local nodecodes = nodes.nodecodes +local whatsitcodes = nodes.whatsitcodes + +local glyph_code = nodecodes.glyph +local disc_code = nodecodes.disc +local hlist_code = nodecodes.hlist +local whatsit_code = nodecodes.whatsit + +local localpar_code = whatsitcodes.localpar +local dir_code = whatsitcodes.dir +local userdefined_code = whatsitcodes.userdefined + +local nodepool = nodes.pool +local tasks = nodes.tasks +local usernodeids = nodepool.userids + +local new_textdir = nodepool.textdir +local new_usernumber = nodepool.usernumber + +local starttiming = statistics.starttiming +local stoptiming = statistics.stoptiming +local process_characters = nodes.handlers.characters +local inject_kerns = nodes.injections.handler +local fontdata = fonts.hashes.identifiers +local setfontdynamics = fonts.hashes.setdynamics +local fontprocesses = fonts.hashes.processes + +local texsetattribute = tex.setattribute +local unsetvalue = attributes.unsetvalue + +local parbuilders = builders.paragraphs +parbuilders.solutions = parbuilders.solutions or { } +parbuilders.solutions.splitters = parbuilders.solutions.splitters or { } + +local splitters = parbuilders.solutions.splitters + +local solutions = { } -- attribute sets +local registered = { } -- backmapping + +local a_split = attributes.private('splitter') + +local preroll = true +local criterium = 0 +local randomseed = nil +local optimize = nil -- set later + +local variant = "normal" + +local cache = { } +local variants = { } +local max_less = 0 +local max_more = 0 + +splitters.registered = registered + +local stack = { } + +local dummy = { + attribute = unsetvalue, + randomseed = 0, + criterium = 0, + preroll = false, + optimize = nil, +} + +local function checksettings(r,settings) + local s = r.settings + local method = settings_to_hash(settings.method or "") + local optimize + for k, v in next, method do + if variants[k] then + optimize = variants[k] -- last? + end + end + r.randomseed = tonumber(settings.randomseed) or s.randomseed or r.randomseed or 0 + r.criterium = tonumber(settings.criterium ) or s.criterium or r.criterium or 0 + r.preroll = method[v_preroll] and true or false + r.optimize = optimize or s.optimize or r.optimize +end + +local function pushsplitter(name,settings) + local r = name and registered[name] + if r then + if settings then + checksettings(r,settings) + end + else + r = dummy + end + insert(stack,r) + -- brr + randomseed = r.randomseed or 0 + criterium = r.criterium or 0 + preroll = r.preroll or false + optimize = r.optimize or nil + -- + texsetattribute(a_split,r.attribute) + return #stack +end + +local function popsplitter() + remove(stack) + local n = #stack + local r = stack[n] or dummy + -- + randomseed = r.randomseed or 0 + criterium = r.criterium or 0 + preroll = r.preroll or false + optimize = r.optimize or nil + -- + texsetattribute(a_split,r.attribute) + return n +end + +local contextsetups = fonts.specifiers.contextsetups + +local function convert(featuresets,name,set,what) + local list = set[what] + if list then + local numbers = { } + local nofnumbers = 0 + for i=1,#list do + local feature = list[i] + local fs = featuresets[feature] + local fn = fs and fs.number + if not fn then + -- fall back on global features + fs = contextsetups[feature] + fn = fs and fs.number + end + if fn then + nofnumbers = nofnumbers + 1 + numbers[nofnumbers] = fn + if trace_goodies or trace_optimize then + report_solutions("solution %s of '%s' uses feature '%s' with number %s",i,name,feature,fn) + end + else + report_solutions("solution %s has an invalid feature reference '%s'",i,name,tostring(feature)) + end + end + return nofnumbers > 0 and numbers + end +end + +local function initialize(goodies) + local solutions = goodies.solutions + if solutions then + local featuresets = goodies.featuresets + local goodiesname = goodies.name + if trace_goodies or trace_optimize then + report_solutions("checking solutions in '%s'",goodiesname) + end + for name, set in next, solutions do + set.less = convert(featuresets,name,set.less) + set.more = convert(featuresets,name,set.more) + end + end +end + +fonts.goodies.register("solutions",initialize) + +function splitters.define(name,settings) + local goodies = settings.goodies + local solution = settings.solution + local less = settings.less + local more = settings.more + local less_set, more_set + local l = less and settings_to_array(less) + local m = more and settings_to_array(more) + if goodies then + goodies = fonts.goodies.load(goodies) -- also in tfmdata + if goodies then + local featuresets = goodies.featuresets + local solution = solution and goodies.solutions[solution] + if l and #l > 0 then + less_set = convert(featuresets,name,less) -- take from settings + else + less_set = solution and solution.less -- take from goodies + end + if m and #m > 0 then + more_set = convert(featuresets,name,more) -- take from settings + else + more_set = solution and solution.more -- take from goodies + end + end + else + if l then + local n = #less_set + for i=1,#l do + local ss = contextsetups[l[i]] + if ss then + n = n + 1 + less_set[n] = ss.number + end + end + end + if m then + local n = #more_set + for i=1,#m do + local ss = contextsetups[m[i]] + if ss then + n = n + 1 + more_set[n] = ss.number + end + end + end + end + if trace_optimize then + report_solutions("defining solutions '%s', less: '%s', more: '%s'",name,concat(less_set or {}," "),concat(more_set or {}," ")) + end + local nofsolutions = #solutions + 1 + local t = { + solution = solution, + less = less_set or { }, + more = more_set or { }, + settings = settings, -- for tracing + attribute = nofsolutions, + } + solutions[nofsolutions] = t + registered[name] = t + return nofsolutions +end + +local nofwords, noftries, nofadapted, nofkept, nofparagraphs = 0, 0, 0, 0, 0 + +local splitter_one = usernodeids["splitters.one"] +local splitter_two = usernodeids["splitters.two"] + +function splitters.split(head) + -- quite fast + local current, done, rlmode, start, stop, attribute = head, false, false, nil, nil, 0 + cache, max_less, max_more = { }, 0, 0 + local function flush() -- we can move this + local font = start.font + local last = stop.next + local list = last and copy_nodelist(start,last) or copy_nodelist(start) + local n = #cache + 1 + local user_one = new_usernumber(splitter_one,n) + local user_two = new_usernumber(splitter_two,n) + head, start = insert_node_before(head,start,user_one) + insert_node_after(head,stop,user_two) + if rlmode == "TRT" or rlmode == "+TRT" then + local dirnode = new_textdir("+TRT") + list.prev = dirnode + dirnode.next = list + list = dirnode + end + local c = { + original = list, + attribute = attribute, + direction = rlmode, + font = font + } + if trace_split then + report_splitters("cached %4i: font: %s, attribute: %s, word: %s, direction: %s", + n, font, attribute, nodes.listtoutf(list,true), rlmode and "r2l" or "l2r") + end + cache[n] = c + local solution = solutions[attribute] + local l, m = #solution.less, #solution.more + if l > max_less then max_less = l end + if m > max_more then max_more = m end + start, stop, done = nil, nil, true + end + while current do + local id = current.id + if id == glyph_code and current.subtype < 256 then + local a = has_attribute(current,a_split) + if not a then + start, stop = nil, nil + elseif not start then + start, stop, attribute = current, current, a + elseif a ~= attribute then + start, stop = nil, nil + else + stop = current + end + current = current.next + elseif id == disc_code then + start, stop, current = nil, nil, current.next + elseif id == whatsit_code then + if start then + flush() + end + local subtype = current.subtype + if subtype == dir_code or subtype == localpar_code then + rlmode = current.dir + end + current = current.next + else + if start then + flush() + end + current = current.next + end + end + if start then + flush() + end + nofparagraphs = nofparagraphs + 1 + nofwords = nofwords + #cache + return head, done +end + +local function collect_words(list) + local words, w, word = { }, 0, nil + for current in traverse_ids(whatsit_code,list) do + if current.subtype == userdefined_code then + local user_id = current.user_id + if user_id == splitter_one then + word = { current.value, current, current } + w = w + 1 + words[w] = word + elseif user_id == splitter_two then + word[3] = current + end + end + end + return words -- check for empty (elsewhere) +end + +-- we could avoid a hpack but hpack is not that slow + +local function doit(word,list,best,width,badness,line,set,listdir) + local changed = 0 + local n = word[1] + local found = cache[n] + if found then + local original, attribute, direction = found.original, found.attribute, found.direction + local solution = solutions[attribute] + local features = solution and solution[set] + if features then + local featurenumber = features[best] -- not ok probably + if featurenumber then + noftries = noftries + 1 + local first = copy_nodelist(original) + if not trace_colors then + for n in traverse_nodes(first) do -- maybe fast force so no attr needed + set_attribute(n,0,featurenumber) -- this forces dynamics + end + elseif set == "less" then + for n in traverse_nodes(first) do + setnodecolor(n,"font:isol") + set_attribute(n,0,featurenumber) + end + else + for n in traverse_nodes(first) do + setnodecolor(n,"font:medi") + set_attribute(n,0,featurenumber) + end + end + local font = found.font + -- local dynamics = found.dynamics + -- local shared = fontdata[font].shared + -- if not dynamics then -- we cache this + -- dynamics = shared.dynamics + -- found.dynamics = dynamics + -- end + -- local processors = found[featurenumber] + -- if not processors then -- we cache this too + -- processors = fonts.handlers.otf.setdynamics(font,featurenumber) + -- found[featurenumber] = processors + -- end + local setdynamics = setfontdynamics[font] + if setdynamics then + local processes = setdynamics(font,featurenumber) + for i=1,#processes do -- often more than 1 + first = processes[i](first,font,featurenumber) + end + else + report_solutions("fatal error, no dynamics for font %s",font) + end + first = inject_kerns(first) + local h = word[2].next -- head of current word + local t = word[3].prev -- tail of current word + if first.id == whatsit_code then + local temp = first + first = first.next + free_node(temp) + end + local last = find_node_tail(first) + -- replace [u]h->t by [u]first->last + local next, prev = t.next, h.prev + prev.next, first.prev = first, prev + if next then + last.next, next.prev = next, last + end + -- check new pack + local temp, b = repack_hlist(list,width,'exactly',listdir) + if b > badness then + if trace_optimize then + report_optimizers("line %s, badness before: %s, after: %s, criterium: %s -> quit",line,badness,b,criterium) + end + -- remove last insert + prev.next, h.prev = h, prev + if next then + t.next, next.prev = next, t + else + t.next = nil + end + last.next = nil + free_nodelist(first) + else + if trace_optimize then + report_optimizers("line %s, badness before: %s, after: %s, criterium: %s -> continue",line,badness,b,criterium) + end + -- free old h->t + t.next = nil + free_nodelist(h) + changed, badness = changed + 1, b + end + if b <= criterium then + return true, changed + end + end + end + end + return false, changed +end + +-- We repeat some code but adding yet another layer of indirectness is not +-- making things better. + +variants[v_normal] = function(words,list,best,width,badness,line,set,listdir) + local changed = 0 + for i=1,#words do + local done, c = doit(words[i],list,best,width,badness,line,set,listdir) + changed = changed + c + if done then + break + end + end + if changed > 0 then + nofadapted = nofadapted + 1 + -- todo: get rid of pack when ok because we already have packed and we only need the last b + local list, b = repack_hlist(list,width,'exactly',listdir) + return list, true, changed, b -- badness + else + nofkept = nofkept + 1 + return list, false, 0, badness + end +end + +variants[v_reverse] = function(words,list,best,width,badness,line,set,listdir) + local changed = 0 + for i=#words,1,-1 do + local done, c = doit(words[i],list,best,width,badness,line,set,listdir) + changed = changed + c + if done then + break + end + end + if changed > 0 then + nofadapted = nofadapted + 1 + -- todo: get rid of pack when ok because we already have packed and we only need the last b + local list, b = repack_hlist(list,width,'exactly',listdir) + return list, true, changed, b -- badness + else + nofkept = nofkept + 1 + return list, false, 0, badness + end +end + +variants[v_random] = function(words,list,best,width,badness,line,set,listdir) + local changed = 0 + while #words > 0 do + local done, c = doit(remove(words,random(1,#words)),list,best,width,badness,line,set,listdir) + changed = changed + c + if done then + break + end + end + if changed > 0 then + nofadapted = nofadapted + 1 + -- todo: get rid of pack when ok because we already have packed and we only need the last b + local list, b = repack_hlist(list,width,'exactly',listdir) + return list, true, changed, b -- badness + else + nofkept = nofkept + 1 + return list, false, 0, badness + end +end + +optimize = variants.normal -- the default + +local function show_quality(current,what,line) + local set = current.glue_set + local sign = current.glue_sign + local order = current.glue_order + local amount = set * ((sign == 2 and -1) or 1) + report_optimizers("line %s, %s, amount %s, set %s, sign %s (%s), order %s",line,what,amount,set,sign,how,order) +end + +function splitters.optimize(head) + local nc = #cache + if nc > 0 then + starttiming(splitters) + local listdir = nil -- todo ! ! ! + if randomseed then + math.setrandomseedi(randomseed) + randomseed = nil + end + local line = 0 + local tex_hbadness, tex_hfuzz = tex.hbadness, tex.hfuzz + tex.hbadness, tex.hfuzz = 10000, number.maxdimen + if trace_optimize then + report_optimizers("preroll: %s, variant: %s, preroll criterium: %s, cache size: %s", + tostring(preroll),variant,criterium,nc) + end + for current in traverse_ids(hlist_code,head) do + -- report_splitters("before: [%s] => %s",current.dir,nodes.tosequence(current.list,nil)) + line = line + 1 + local sign, dir, list, width = current.glue_sign, current.dir, current.list, current.width + local temp, badness = repack_hlist(list,width,'exactly',dir) -- it would be nice if the badness was stored in the node + if badness > 0 then + if sign == 0 then + if trace_optimize then + report_optimizers("line %s, badness %s, okay",line,badness) + end + else + local set, max + if sign == 1 then + if trace_optimize then + report_optimizers("line %s, badness %s, underfull, trying more",line,badness) + end + set, max = "more", max_more + else + if trace_optimize then + report_optimizers("line %s, badness %s, overfull, trying less",line,badness) + end + set, max = "less", max_less + end + -- we can keep the best variants + local lastbest, lastbadness = nil, badness + if preroll then + local bb, base + for i=1,max do + if base then + free_nodelist(base) + end + base = copy_nodelist(list) + local words = collect_words(base) -- beware: words is adapted + for j=i,max do + local temp, done, changes, b = optimize(words,base,j,width,badness,line,set,dir) + base = temp + if trace_optimize then + report_optimizers("line %s, alternative: %s.%s, changes: %s, badness %s",line,i,j,changes,b) + end + bb = b + if b <= criterium then + break + end + -- if done then + -- break + -- end + end + if bb and bb > criterium then -- needs checking + if not lastbest then + lastbest, lastbadness = i, bb + elseif bb > lastbadness then + lastbest, lastbadness = i, bb + end + else + break + end + end + free_nodelist(base) + end + local words = collect_words(list) + for best=lastbest or 1,max do + local temp, done, changes, b = optimize(words,list,best,width,badness,line,set,dir) + current.list = temp + if trace_optimize then + report_optimizers("line %s, alternative: %s, changes: %s, badness %s",line,best,changes,b) + end + if done then + if b <= criterium then -- was == 0 + protect_glyphs(list) + break + end + end + end + end + else + if trace_optimize then + report_optimizers("line %s, not bad enough",line) + end + end + -- we pack inside the outer hpack and that way keep the original wd/ht/dp as bonus + current.list = hpack_nodes(current.list,width,'exactly',listdir) + -- report_splitters("after: [%s] => %s",temp.dir,nodes.tosequence(temp.list,nil)) + end + for i=1,nc do + local ci = cache[i] + free_nodelist(ci.original) + end + cache = { } + tex.hbadness, tex.hfuzz = tex_hbadness, tex_hfuzz + stoptiming(splitters) + end +end + +statistics.register("optimizer statistics", function() + if nofwords > 0 then + local elapsed = statistics.elapsedtime(splitters) + local average = noftries/elapsed + return format("%s words identified in %s paragraphs, %s words retried, %s lines tried, %0.3f seconds used, %s adapted, %0.1f lines per second", + nofwords,nofparagraphs,noftries,nofadapted+nofkept,elapsed,nofadapted,average) + end +end) + +-- we could use a stack + +local enableaction = tasks.enableaction +local disableaction = tasks.disableaction + +local function enable() + enableaction("processors", "builders.paragraphs.solutions.splitters.split") + enableaction("finalizers", "builders.paragraphs.solutions.splitters.optimize") +end + +local function disable() + disableaction("processors", "builders.paragraphs.solutions.splitters.split") + disableaction("finalizers", "builders.paragraphs.solutions.splitters.optimize") +end + +function splitters.start(name,settings) + if pushsplitter(name,settings) == 1 then + enable() + end +end + +function splitters.stop() + if popsplitter() == 0 then + disable() + end +end + +function splitters.set(name,settings) + if #stack > 0 then + stack = { } + else + enable() + end + pushsplitter(name,settings) -- sets attribute etc +end + +function splitters.reset() + if #stack > 0 then + stack = { } + popsplitter() -- resets attribute etc + disable() + end +end + + +-- interface + +commands.definefontsolution = splitters.define +commands.startfontsolution = splitters.start +commands.stopfontsolution = splitters.stop +commands.setfontsolution = splitters.start +commands.resetfontsolution = splitters.stop + diff --git a/tex/context/base/font-sol.mkiv b/tex/context/base/font-sol.mkiv new file mode 100644 index 000000000..2c6bf8860 --- /dev/null +++ b/tex/context/base/font-sol.mkiv @@ -0,0 +1,121 @@ +%D \module +%D [ file=font-sol, +%D version=2009.05.19, +%D title=\CONTEXT\ Font Macros, +%D subtitle=Solutions, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Node Support / Splitters} + +%D This module is specially made for the oriental \TEX\ project. The working is as +%D follows (and tuned for fonts like Idris' Husayni. The following method came to +%D my mind after a couple of Skype sessions with Idris while working on the rough +%D edges of the Husayni font and playing with font dynamics. +%D +%D \startitemize[packed] +%D +%D \item We define a couple of features sets, some can have stylistics variants +%D that result in the same words getting a different width. Normally this +%D happens in a goodies file. +%D +%D \item We group such features in a solution set. A solutionset can be enabled +%D by setting an attribute. +%D +%D \item For each paragraph we identify words that get this set applied. We replace +%D these words by a user node that refers to the original. +%D +%D \item For each word we apply the features to a copy that we associate with this +%D original word. +%D +%D \item At the end we have a paragraph (node list) with user nodes that point to a +%D cache that has originals and processed variants. +%D +%D \item When the paragraph is broken into lines we optimize the spacing by +%D substituting variants. +%D +%D \stopitemize +%D +%D This approach permits us to use a dedicated paragraph builder, one that treats +%D the user nodes special and takes the alternatives into account. +%D +%D Currently we assume only one solution being active. Maybe some day I'll support +%D a mixture. This is only one way of optimizing and after several experiments this +%D one was chosen as testcase. It took quite some experiments (and time) to get thus +%D far. +%D +%D The is experimental code for the Oriental \TEX\ project and aspects of it might +%D change. +%D +%D \starttyping +%D \setupfontsolutions[method={random,preroll},criterium=1,randomseed=101] +%D +%D \definefontsolution % actually only the last run needs to be done this way +%D [FancyHusayni] +%D [goodies=husayni, +%D solution=experimental] +%D +%D \definedfont[husayni*husayni-default at 24pt] +%D \setupinterlinespace[line=36pt] +%D \righttoleft +%D \enabletrackers[parbuilders.solutions.splitters.colors] +%D \setfontsolution[FancyHusayni] +%D alb alb alb \par +%D \resetfontsolution +%D \disabletrackers[parbuilders.solutions.splitters.colors] +%D \stoptyping + +\registerctxluafile{font-sol}{1.001} + +\unprotect + +\definesystemattribute[splitter][public] + +\installcorenamespace{fontsolution} + +\installcommandhandler \??fontsolution {fontsolution} \??fontsolution + +\let\setupfontsolutions\setupfontsolution + +\appendtoks + \ctxcommand{definefontsolution("\currentfontsolution",{ % these are frozen + goodies = "\fontsolutionparameter\s!goodies", + solution = "\fontsolutionparameter\c!solution", + less = "\fontsolutionparameter\c!less", + more = "\fontsolutionparameter\c!more", + })} +\to \everydefinefontsolution + +\unexpanded\def\setfontsolution[#1]% just one + {\edef\currentfontsolution{#1}% + \ctxcommand{setfontsolution("\currentfontsolution", { + method = "\fontsolutionparameter\c!method", + criterium = "\fontsolutionparameter\c!criterium", + % randomseed = "\fontsolutionparameter\c!random", + })}} + +\unexpanded\def\resetfontsolution % resets all + {\ctxcommand{resetfontsolution()}% + \let\currentfontsolution\empty} + +\unexpanded\def\startfontsolution % [#1] + {\pushmacro\currentfontsolution + \setfontsolution} + +\unexpanded\def\stopfontsolution + {\ifhmode\par\fi + \ctxcommand{stopfontsolution()}% + \popmacro\currentfontsolution} + +% We initialize this module at the \LUA\ end. +% +% \setupfontsolutions +% [\c!method={\v!normal,preroll}, +% \c!criterium=0] + +\protect diff --git a/tex/context/base/m-visual.mkiv b/tex/context/base/m-visual.mkiv index 5d259f6ab..988276a53 100644 --- a/tex/context/base/m-visual.mkiv +++ b/tex/context/base/m-visual.mkiv @@ -13,6 +13,9 @@ \unprotect +%D Much will probably be replaced by \LUA\ based solutions which is +%D rather trivial and fun doing. + %D This module collect a few more visual debugger features. I %D needed them for manuals and styles. The macros are documented %D in a my way document. @@ -243,10 +246,565 @@ \placefigure{\fakewords{8}{15}}{\fakeimage{5cm}{3cm}{10cm}{5cm}} \dorecurse{2}{\fakewords{100}{200}\endgraf}}}}} +%D Moved code: + +%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 ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D This module 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: + +\unexpanded\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\plustenthousand + \box\scratchbox + \egroup} + +\unexpanded\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} + +\unexpanded\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} + +\unexpanded\def\ruledpar + {\relax + \ifhmode + \showparagraphcue{40\testrulewidth}\relax\rightrulefalse\relax\!!height + \fi + \normalpar} + +\unexpanded\def\rulednoindent + {\relax + \normalnoindent + \ruledparagraphcues + \showparagraphcue{40\testrulewidth}\llap\leftrulefalse\relax\!!height} + +\unexpanded\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} + +\unexpanded\def\dontshowimplicits + {\let\noindent \normalnoindent + \let\indent \normalindent + \let\par \normalpar} + +\unexpanded\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} + +\unexpanded\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 + {\ttxx#1}% + \ruledbaselines + \normalhskip6\points}% + \raise\scratchdimen\box\scratchbox}% + \smashbox\scratchbox + \box\scratchbox + \egroup} + +\unexpanded\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. + +\unexpanded\def\showpagebuilder + {\EveryPar{\doshowpagebuilder}} + +\unexpanded\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 {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\dodocolorrangeA#1% + {\fastcolored[#1]{\hrule\!!width3em\!!height\scratchdimen\!!depth\zeropoint}} + +\def\docolorrangeA#1 #2 % + {\vbox + {\hsize3em % \scratchdimen + \ifcase#1\or + \dodocolorrangeA{c=#2}\or + \dodocolorrangeA{m=#2}\or + \dodocolorrangeA{y=#2}\or + \dodocolorrangeA{m=#2,y=#2}\or + \dodocolorrangeA{c=#2,y=#2}\or + \dodocolorrangeA{c=#2,m=#2}\fi + \ifdim\scratchdimen>1ex + \vskip-\scratchdimen + \vbox to \scratchdimen + {\vss\hbox to 3em{\hss#2\hss}\vss}% + \fi}} + +\def\colorrangeA#1% + {\vbox + {\startcolor[\s!white]% + \scratchdimen\dimexpr(-\colormarklength*4+\tractempheight+\tractempdepth)/21\relax + \offinterlineskip + \docolorrangeA #1 1.00 \docolorrangeA #1 0.95 + \docolorrangeA #1 0.75 + \docolorrangeA #1 0.50 + \docolorrangeA #1 0.25 \docolorrangeA #1 0.05 + \docolorrangeA #1 0.00 + \stopcolor}} + +\def\docolorrangeB #1 #2 #3 #4 #5 % + {\fastcolored + [\c!c=#2,\c!m=#3,\c!y=#4,\c!k=#5] + {\vrule\!!width\scratchdimen\!!height\colormarklength\!!depth\zeropoint}% + \ifdim\scratchdimen>2em + \hskip-\scratchdimen + \vbox to \colormarklength + {\vss\hbox to \scratchdimen{\hss#1\hss}\vss}% + \fi} + +\def\colorrangeB + {\hbox + {\startcolor[\s!white]% + \scratchdimen\dimexpr(-\colormarklength*\plustwo+\tractempwidth)/11\relax + \docolorrangeB .5~C .5 0 0 0 + \docolorrangeB .5~M 0 .5 0 0 + \docolorrangeB .5~Y 0 0 .5 0 + \docolorrangeB .5~K 0 0 0 .5 + \docolorrangeB C 1 0 0 0 + \docolorrangeB G 1 0 1 0 + \docolorrangeB Y 0 0 1 0 + \docolorrangeB R 0 1 1 0 + \docolorrangeB M 0 1 0 0 + \docolorrangeB B 1 1 0 0 + \docolorrangeB K 0 0 0 1 + \stopcolor}} + +\def\docolorrangeC#1 % + {\fastcolored + [\c!s=#1]% + {\vrule\!!width\scratchdimen\!!height\colormarklength\!!depth\zeropoint}% + \ifdim\scratchdimen>2em + \hskip-\scratchdimen + \vbox to \colormarklength + {\vss\hbox to \scratchdimen{\hss#1\hss}\vss}% + \fi} + +\def\colorrangeC + {\hbox + {\startcolor[\s!white]% + \scratchdimen\dimexpr(-\colormarklength*2+\tractempwidth)/14\relax + \docolorrangeC 1 \docolorrangeC .95 + \docolorrangeC .9 \docolorrangeC .85 + \docolorrangeC .8 \docolorrangeC .75 + \docolorrangeC .7 + \docolorrangeC .6 + \docolorrangeC .5 + \docolorrangeC .4 + \docolorrangeC .3 + \docolorrangeC .2 + \docolorrangeC .1 + \docolorrangeC 0 + \stopcolor}} + +\def\docolormarkbox#1#2% + {\tractempheight\ht#2% + \tractempdepth \dp#2% + \tractempwidth \wd#2% + \setbox#2\hbox + {\scratchdimen\dimexpr\colormarklength/2\relax + \forgetall + \ssxx + \setbox\scratchbox\vbox + {\offinterlineskip + \vskip\dimexpr-\colormarkoffset\scratchdimen-2\scratchdimen\relax + \ifcase#1\relax + \vskip\dimexpr\colormarklength+\scratchdimen+\tractempheight\relax + \else + \hbox to \tractempwidth{\hss\hbox{\colorrangeB}\hss}% + \vskip\colormarkoffset\scratchdimen + \vbox to \tractempheight + {\vss + \hbox to \tractempwidth + {\llap{\colorrangeA1\hskip\colormarkoffset\scratchdimen}\hfill + \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA4}}% + \vss + \hbox to \tractempwidth + {\llap{\colorrangeA2\hskip\colormarkoffset\scratchdimen}\hfill + \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA5}}% + \vss + \hbox to \tractempwidth + {\llap{\colorrangeA3\hskip\colormarkoffset\scratchdimen}\hfill + \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA6}}% + \vss}% + \fi + \vskip\colormarkoffset\scratchdimen + \hbox to \tractempwidth + {\hss\lower\tractempdepth\hbox{\colorrangeC}\hss}}% + \ht\scratchbox\tractempheight + \dp\scratchbox\tractempdepth + \wd\scratchbox\zeropoint + \box\scratchbox + \box#2}% + \wd#2\tractempwidth + \ht#2\tractempheight + \dp#2\tractempdepth} + +\unexpanded\def\colormarkbox {\docolormarkbox\plusone } % #1 +\unexpanded\def\rastermarkbox{\docolormarkbox\zerocount} % #1 + +%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 + +\let\supernormalmark \normalmark % mark may already been superseded +\let\supernormalmarks \normalmarks % mark may already been superseded + +\unexpanded\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} + +\unexpanded\def\immediatewhatsit + {\bgroup\futurelet\next\doimmediatewhatsit} + +\unexpanded\def\doimmediatewhatsit + {\ifx\next\write + \egroup\immediatewritetrue + \else + \egroup\expandafter\normalimmediate + \fi} + +\unexpanded\def\dontshowwhatsits + {\let\immediate \normalimmediate + \let\normalmark\supernormalmark + \let\special \normalspecial + \let\write \normalwrite} + +\unexpanded\def\visualwhatsit#1#2#3#4#5% + {\bgroup + \pushwhatsit + \dontinterfere + \dontcomplain + \dontshowcomposition + \dontshowwhatsits + \ttx + \ifvmode\donetrue\else\donefalse\fi + \setbox\scratchbox\hbox + {\ifdone + \colored[r=#1,g=#2,b=#3]{#5}% temp hack + \else + \colored[s=0]{#5}% temp hack + \fi}% + \setbox\scratchbox\hbox + {\ifdone + \colored[r=#1,g=#2,b=#3]{\vrule\!!width\wd\scratchbox}% temp hack + \else + \colored[s=0]{\vrule\!!width\wd\scratchbox}% temp hack + \fi + \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} + +\unexpanded\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} + +%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}} + +\unexpanded\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] + +\unexpanded\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} + +\unexpanded\def\coloredhbox{\coloredbox\hbox} +\unexpanded\def\coloredvbox{\coloredbox\vbox} +\unexpanded\def\coloredvtop{\coloredbox\vtop} + +\unexpanded\def\coloredstrut + {\color[strutcolor]{\def\strutwidth{2\points}\setstrut\strut}} + +\protect + \continueifinputfile{m-visual.mkiv} \starttext \simplethesis \stoptext - -\protect \endinput diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv index 788e8cd42..6fa7022c4 100644 --- a/tex/context/base/mult-aux.mkiv +++ b/tex/context/base/mult-aux.mkiv @@ -41,7 +41,7 @@ %D % \whateverparameter \c!test %D % \whateverparameterhash \c!test %D % \namedwhateverparameter \mycurrentwhatever \c!test -%D % \dosetwhateverstyleandcolor \c!style \c!color +%D % \usewhateverstyleandcolor \c!style \c!color %D % \everydefinewhatever (sets \currentwhatever) %D % \everypresetwhatever (can be used to reset parameters as we can redefine) %D % \everysetupwhatever (sets \currentwhatever) @@ -642,6 +642,26 @@ \installcorenamespace{fontinstancebasic} \installcorenamespace{fontinstanceclass} +%D The next one is handy for local assignments. + +\installcorenamespace{dummy} + +\letvalue\??dummy\empty + +\def\dummyparameter #1{\csname\??dummy\ifcsname\??dummy#1\endcsname#1\fi\endcsname} +\def\directdummyparameter#1{\csname\??dummy#1\endcsname} + +% \unexpanded\def\getdummyparameters +% {\mult_interfaces_get_parameters\??dummy} + +\unexpanded\def\getdummyparameters[#1% + {\if\noexpand#1]% + \expandafter\gobbleoneargument + \else + \let\m_mult_interfaces_namespace\??dummy + \expandafter\mult_interfaces_get_parameters_indeed + \fi#1} + % Maybe a \definecorenamespace[name][directparameter,directsetup][parent] % but we don't gain much. Actually we might just inline all definitions. diff --git a/tex/context/base/mult-de.mkii b/tex/context/base/mult-de.mkii index 2f19a78a1..6d4e3734a 100644 --- a/tex/context/base/mult-de.mkii +++ b/tex/context/base/mult-de.mkii @@ -773,6 +773,7 @@ \setinterfaceconstant{leftsubsentence}{linkersubsatz} \setinterfaceconstant{lefttext}{linkertext} \setinterfaceconstant{leftwidth}{linkerbreite} +\setinterfaceconstant{less}{less} \setinterfaceconstant{level}{niveau} \setinterfaceconstant{levels}{niveaus} \setinterfaceconstant{limittext}{limittext} @@ -811,6 +812,7 @@ \setinterfaceconstant{minheight}{minhoehe} \setinterfaceconstant{minwidth}{minbreite} \setinterfaceconstant{monthconversion}{monthconversion} +\setinterfaceconstant{more}{more} \setinterfaceconstant{n}{n} \setinterfaceconstant{name}{name} \setinterfaceconstant{namesep}{namesep} @@ -973,6 +975,7 @@ \setinterfaceconstant{sign}{zeichen} \setinterfaceconstant{size}{groesse} \setinterfaceconstant{small}{klein} +\setinterfaceconstant{solution}{solution} \setinterfaceconstant{sort}{sort} \setinterfaceconstant{sorttype}{sorttype} \setinterfaceconstant{source}{quelle} diff --git a/tex/context/base/mult-def.lua b/tex/context/base/mult-def.lua index b700d2802..89ef990c7 100644 --- a/tex/context/base/mult-def.lua +++ b/tex/context/base/mult-def.lua @@ -6449,6 +6449,18 @@ return { }, }, ["constants"]={ + ["less"]={ + ["en"]="less", + ["nl"]="minder", + }, + ["more"]={ + ["en"]="more", + ["nl"]="meer", + }, + ["solution"]={ + ["en"]="solution", + ["nl"]="oplossing", + }, ["anchor"]={ ["en"]="anchor", ["nl"]="anker", diff --git a/tex/context/base/mult-en.mkii b/tex/context/base/mult-en.mkii index c156a0fa3..6325765e0 100644 --- a/tex/context/base/mult-en.mkii +++ b/tex/context/base/mult-en.mkii @@ -773,6 +773,7 @@ \setinterfaceconstant{leftsubsentence}{leftsubsentence} \setinterfaceconstant{lefttext}{lefttext} \setinterfaceconstant{leftwidth}{leftwidth} +\setinterfaceconstant{less}{less} \setinterfaceconstant{level}{level} \setinterfaceconstant{levels}{levels} \setinterfaceconstant{limittext}{limittext} @@ -811,6 +812,7 @@ \setinterfaceconstant{minheight}{minheight} \setinterfaceconstant{minwidth}{minwidth} \setinterfaceconstant{monthconversion}{monthconversion} +\setinterfaceconstant{more}{more} \setinterfaceconstant{n}{n} \setinterfaceconstant{name}{name} \setinterfaceconstant{namesep}{namesep} @@ -973,6 +975,7 @@ \setinterfaceconstant{sign}{sign} \setinterfaceconstant{size}{size} \setinterfaceconstant{small}{small} +\setinterfaceconstant{solution}{solution} \setinterfaceconstant{sort}{sort} \setinterfaceconstant{sorttype}{sorttype} \setinterfaceconstant{source}{source} diff --git a/tex/context/base/mult-fr.mkii b/tex/context/base/mult-fr.mkii index e48e583ea..6b3acd811 100644 --- a/tex/context/base/mult-fr.mkii +++ b/tex/context/base/mult-fr.mkii @@ -773,6 +773,7 @@ \setinterfaceconstant{leftsubsentence}{sousphrasegauche} \setinterfaceconstant{lefttext}{textegauche} \setinterfaceconstant{leftwidth}{largeurgauche} +\setinterfaceconstant{less}{less} \setinterfaceconstant{level}{niveau} \setinterfaceconstant{levels}{niveaux} \setinterfaceconstant{limittext}{limittext} @@ -811,6 +812,7 @@ \setinterfaceconstant{minheight}{hauteurmin} \setinterfaceconstant{minwidth}{largeurmin} \setinterfaceconstant{monthconversion}{monthconversion} +\setinterfaceconstant{more}{more} \setinterfaceconstant{n}{n} \setinterfaceconstant{name}{nom} \setinterfaceconstant{namesep}{namesep} @@ -973,6 +975,7 @@ \setinterfaceconstant{sign}{signe} \setinterfaceconstant{size}{dimension} \setinterfaceconstant{small}{petit} +\setinterfaceconstant{solution}{solution} \setinterfaceconstant{sort}{sort} \setinterfaceconstant{sorttype}{sorttype} \setinterfaceconstant{source}{origine} diff --git a/tex/context/base/mult-it.mkii b/tex/context/base/mult-it.mkii index 0af7edde5..c901f1816 100644 --- a/tex/context/base/mult-it.mkii +++ b/tex/context/base/mult-it.mkii @@ -773,6 +773,7 @@ \setinterfaceconstant{leftsubsentence}{sottofrasesinistra} \setinterfaceconstant{lefttext}{testosinistro} \setinterfaceconstant{leftwidth}{ampiezzasinistra} +\setinterfaceconstant{less}{less} \setinterfaceconstant{level}{livello} \setinterfaceconstant{levels}{livelli} \setinterfaceconstant{limittext}{limittext} @@ -811,6 +812,7 @@ \setinterfaceconstant{minheight}{altezzamin} \setinterfaceconstant{minwidth}{ampiezzamin} \setinterfaceconstant{monthconversion}{monthconversion} +\setinterfaceconstant{more}{more} \setinterfaceconstant{n}{n} \setinterfaceconstant{name}{nome} \setinterfaceconstant{namesep}{namesep} @@ -973,6 +975,7 @@ \setinterfaceconstant{sign}{segno} \setinterfaceconstant{size}{dimensione} \setinterfaceconstant{small}{piccolo} +\setinterfaceconstant{solution}{solution} \setinterfaceconstant{sort}{sort} \setinterfaceconstant{sorttype}{sorttype} \setinterfaceconstant{source}{origine} diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua index 404af4f05..7b92fd200 100644 --- a/tex/context/base/mult-low.lua +++ b/tex/context/base/mult-low.lua @@ -212,6 +212,7 @@ return { "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "copyparameters", + "getdummyparameters", "dummyparameter", "directdummyparameter", -- "processcommalist", "processcommacommand", "quitcommalist", "quitprevcommalist", "processaction", "processallactions", "processfirstactioninset", "processallactionsinset", diff --git a/tex/context/base/mult-nl.mkii b/tex/context/base/mult-nl.mkii index 88d3ffe58..07165f02c 100644 --- a/tex/context/base/mult-nl.mkii +++ b/tex/context/base/mult-nl.mkii @@ -773,6 +773,7 @@ \setinterfaceconstant{leftsubsentence}{linkersubzin} \setinterfaceconstant{lefttext}{linkertekst} \setinterfaceconstant{leftwidth}{linkerbreedte} +\setinterfaceconstant{less}{minder} \setinterfaceconstant{level}{niveau} \setinterfaceconstant{levels}{niveaus} \setinterfaceconstant{limittext}{limiettekst} @@ -811,6 +812,7 @@ \setinterfaceconstant{minheight}{minhoogte} \setinterfaceconstant{minwidth}{minbreedte} \setinterfaceconstant{monthconversion}{maandconversie} +\setinterfaceconstant{more}{meer} \setinterfaceconstant{n}{n} \setinterfaceconstant{name}{naam} \setinterfaceconstant{namesep}{namesep} @@ -973,6 +975,7 @@ \setinterfaceconstant{sign}{teken} \setinterfaceconstant{size}{formaat} \setinterfaceconstant{small}{klein} +\setinterfaceconstant{solution}{oplossing} \setinterfaceconstant{sort}{sort} \setinterfaceconstant{sorttype}{sortering} \setinterfaceconstant{source}{bron} diff --git a/tex/context/base/mult-pe.mkii b/tex/context/base/mult-pe.mkii index 8bf67b339..6f7e245ff 100644 --- a/tex/context/base/mult-pe.mkii +++ b/tex/context/base/mult-pe.mkii @@ -773,6 +773,7 @@ \setinterfaceconstant{leftsubsentence}{زیرجمله‌چپ} \setinterfaceconstant{lefttext}{متن‌چپ} \setinterfaceconstant{leftwidth}{عرض‌خط} +\setinterfaceconstant{less}{less} \setinterfaceconstant{level}{مرحله} \setinterfaceconstant{levels}{مرحله‌ها} \setinterfaceconstant{limittext}{مرزمتن} @@ -811,6 +812,7 @@ \setinterfaceconstant{minheight}{کمترین‌ارتفاع} \setinterfaceconstant{minwidth}{کمترین‌عرض} \setinterfaceconstant{monthconversion}{monthconversion} +\setinterfaceconstant{more}{more} \setinterfaceconstant{n}{n} \setinterfaceconstant{name}{نام} \setinterfaceconstant{namesep}{namesep} @@ -973,6 +975,7 @@ \setinterfaceconstant{sign}{علامت} \setinterfaceconstant{size}{اندازه} \setinterfaceconstant{small}{کوچک} +\setinterfaceconstant{solution}{solution} \setinterfaceconstant{sort}{sort} \setinterfaceconstant{sorttype}{ترتیب‌تایپ} \setinterfaceconstant{source}{منبع} diff --git a/tex/context/base/mult-ro.mkii b/tex/context/base/mult-ro.mkii index 8495878cd..015603b9b 100644 --- a/tex/context/base/mult-ro.mkii +++ b/tex/context/base/mult-ro.mkii @@ -773,6 +773,7 @@ \setinterfaceconstant{leftsubsentence}{subpropozitiestanga} \setinterfaceconstant{lefttext}{textstanga} \setinterfaceconstant{leftwidth}{latimestanga} +\setinterfaceconstant{less}{less} \setinterfaceconstant{level}{nivel} \setinterfaceconstant{levels}{nivele} \setinterfaceconstant{limittext}{limittext} @@ -811,6 +812,7 @@ \setinterfaceconstant{minheight}{inaltimeminima} \setinterfaceconstant{minwidth}{latimeminima} \setinterfaceconstant{monthconversion}{monthconversion} +\setinterfaceconstant{more}{more} \setinterfaceconstant{n}{n} \setinterfaceconstant{name}{nume} \setinterfaceconstant{namesep}{namesep} @@ -973,6 +975,7 @@ \setinterfaceconstant{sign}{semn} \setinterfaceconstant{size}{dimensiune} \setinterfaceconstant{small}{mic} +\setinterfaceconstant{solution}{solution} \setinterfaceconstant{sort}{sort} \setinterfaceconstant{sorttype}{sorttype} \setinterfaceconstant{source}{sursa} diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv index 06e6787c6..1eecbaf2f 100644 --- a/tex/context/base/mult-sys.mkiv +++ b/tex/context/base/mult-sys.mkiv @@ -520,7 +520,6 @@ \definesystemvariable {nm} % Nummering \definesystemvariable {np} % NaastPlaatsen \definesystemvariable {nr} % Nummeren -\definesystemvariable {ob} % OBjects \definesystemvariable {oi} % OmlijndInstellingen \definesystemvariable {ol} % OmLijnd \definesystemvariable {od} % Omlijnd Defaults (simple) @@ -530,7 +529,6 @@ \definesystemvariable {ph} % ParagrapH \definesystemvariable {pn} % PaginaNummer \definesystemvariable {pr} % PRogrammas -\definesystemvariable {ps} % PoSitioneren \definesystemvariable {px} % Parallel \definesystemvariable {py} % PropertYs \definesystemvariable {pv} % PublicationVariable diff --git a/tex/context/base/node-par.lua b/tex/context/base/node-par.lua deleted file mode 100644 index 423d69fc7..000000000 --- a/tex/context/base/node-par.lua +++ /dev/null @@ -1,124 +0,0 @@ -if not modules then modules = { } end modules ['node-par'] = { - version = 1.001, - comment = "companion to node-par.mkiv", - author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", - copyright = "PRAGMA ADE / ConTeXt Development Team", - license = "see context related readme files" -} - -local builders, nodes, node = builders, nodes, node - -builders.paragraphs = builders.paragraphs or { } -local parbuilders = builders.paragraphs - -parbuilders.constructors = parbuilders.constructors or { } -local constructors = parbuilders.constructors - -constructors.names = constructors.names or { } -local names = constructors.names - -constructors.numbers = constructors.numbers or { } -local numbers = constructors.numbers - -constructors.methods = constructors.methods or { } -local methods = constructors.methods - -local p_attribute = attributes.numbers['parbuilder'] or 999 -constructors.attribute = p_attribute - -local has_attribute = node.has_attribute -local starttiming = statistics.starttiming -local stoptiming = statistics.stoptiming - -storage.register("builders/paragraphs/constructors/names", names, "builders.paragraphs.constructors.names") -storage.register("builders/paragraphs/constructors/numbers", numbers, "builders.paragraphs.constructors.numbers") - -local report_parbuilders = logs.reporter("parbuilders") - -local texnest = tex.nest - -local mainconstructor = nil -- not stored in format - -function constructors.register(name,number) - names[number] = name - numbers[name] = number -end - -function constructors.set(name) - mainconstructor = numbers[name] -end - --- return values: --- --- true : tex will break itself --- false : idem but dangerous --- head : list of valid vmode nodes with last being hlist - -function constructors.handler(head,followed_by_display) - if type(head) == "boolean" then - return head - else - local attribute = has_attribute(head,p_attribute) or mainconstructor - if attribute then - local method = names[attribute] - if method then - local handler = methods[method] - if handler then - return handler(head,followed_by_display) - else - report_parbuilders("contructor method '%s' is not defined",tostring(method)) - return true -- let tex break - end - end - end - return true -- let tex break - end -end - --- just for testing - -function constructors.methods.default(head,followed_by_display) - return true -- let tex break -end - --- also for testing (no surrounding spacing done) - -function constructors.methods.oneline(head,followed_by_display) - local h = node.hpack(head) - local p = texnest.ptr - texnest[p].prevgraf = 1 - texnest[p].prevdepth = h.depth - return h -end - --- It makes no sense to have a sequence here as we already have --- pre and post hooks and only one parbuilder makes sense, so no: --- --- local actions = nodes.tasks.actions("parbuilders") --- --- yet (maybe some day). --- --- todo: enable one as main - -local actions = constructors.handler -local enabled = false - -function constructors.enable () enabled = true end -function constructors.disable() enabled = false end - -local function processor(head,followed_by_display) - if enabled then - starttiming(parbuilders) - local head = actions(head,followed_by_display) - stoptiming(parbuilders) - return head - else - return true -- let tex do the work - end -end - -callbacks.register('linebreak_filter', processor, "breaking paragraps into lines") - -statistics.register("linebreak processing time", function() - return statistics.elapsedseconds(parbuilders) -end) diff --git a/tex/context/base/node-par.mkiv b/tex/context/base/node-par.mkiv deleted file mode 100644 index 685167e8a..000000000 --- a/tex/context/base/node-par.mkiv +++ /dev/null @@ -1,82 +0,0 @@ -%D \module -%D [ file=node-par, -%D version=2008.09.30, -%D title=\CONTEXT\ Node Macros, -%D subtitle=Paragraph Building, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\writestatus{loading}{ConTeXt Node Macros / Paragraph Building} - -%D This is very experimental, undocumented, subjected to changes, etc. just as -%D the underlying interfaces. - -% \enableparbuilders -% -% \startparbuilder[default] -% \input tufte \par -% \startparbuilder[oneline] -% \input tufte \par -% \stopparbuilder -% \input tufte \par -% \stopparbuilder - -\unprotect - -\registerctxluafile{node-par}{1.001} - -\definesystemattribute[parbuilder][public] - -% todo auto-enable - -% management (enable/disable) is global and will move to lua - -\installcorenamespace {parbuilder} - -\newcount\c_node_paragraphs_n_of_builders - -\let\m_node_paragraphs_current_builder\empty - -\unexpanded\def\defineparbuilder[#1]% - {\global\advance\c_node_paragraphs_n_of_builders\plusone - \ctxlua{builders.paragraphs.constructors.register("#1",\number\c_node_paragraphs_n_of_builders)}% - \setxvalue{\??parbuilder#1}{\attribute\parbuilderattribute\number\c_node_paragraphs_n_of_builders}} - -\unexpanded\def\startparbuilder[#1]% - {\edef\m_node_paragraphs_current_builder{\number\attribute\parbuilderattribute}% - \globalpushmacro\m_node_paragraphs_current_builder - \getvalue{\??parbuilder#1}\relax - \node_paragraphs_builders_check} - -\unexpanded\def\stopparbuilder - {\ifhmode\par\fi - \globalpopmacro\m_node_paragraphs_current_builder - \attribute\parbuilderattribute\m_node_paragraphs_current_builder\relax - \node_paragraphs_builders_check} - -\unexpanded\def\setmainparbuilder[#1]% - {\ctxlua{builders.paragraphs.constructors.set("#1")}} - -% no high level interface, after all implementing a linebreaker is not something that -% the average user will do - -\defineparbuilder[default] % just for testing -\defineparbuilder[oneline] % just for testing -\defineparbuilder[basic] % just for testing - -\def\enableparbuilders {\ctxlua{builders.paragraphs.constructors.enable ()}} -\def\disableparbuilders{\ctxlua{builders.paragraphs.constructors.disable()}} - -\def\node_paragraphs_builders_check % can be made more efficient as we don't want to do this too often - {\ifcase\attribute\parbuilderattribute - \disableparbuilders - \else - \enableparbuilders - \fi} - -\protect \endinput diff --git a/tex/context/base/node-spl.lua b/tex/context/base/node-spl.lua deleted file mode 100644 index 3b208e0e7..000000000 --- a/tex/context/base/node-spl.lua +++ /dev/null @@ -1,619 +0,0 @@ -if not modules then modules = { } end modules ['node-spl'] = { - version = 1.001, - comment = "companion to node-spl.mkiv", - author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", - copyright = "PRAGMA ADE / ConTeXt Development Team", - license = "see context related readme files" -} - --- This module is dedicated to the oriental tex project and for --- the moment is too experimental to be publicly supported. --- --- We could cache solutions: say that we store the featureset and --- all 'words' -> replacement ... so we create a large solution --- database (per font) --- --- This module can be optimized by using a dedicated dynamics handler --- but I'll only do that when the rest of the code is stable. --- --- Todo: bind setups to paragraph. - -local gmatch, concat, format, remove = string.gmatch, table.concat, string.format, table.remove -local next, tostring, tonumber = next, tostring, tonumber -local utfchar = utf.char -local random = math.random - -local trace_split = false trackers.register("builders.paragraphs.solutions.splitters.splitter", function(v) trace_split = v end) -local trace_optimize = false trackers.register("builders.paragraphs.solutions.splitters.optimizer", function(v) trace_optimize = v end) -local trace_colors = false trackers.register("builders.paragraphs.solutions.splitters.colors", function(v) trace_colors = v end) -local trace_goodies = false trackers.register("fonts.goodies", function(v) trace_goodies = v end) - -local report_solutions = logs.reporter("fonts","solutions") -local report_splitters = logs.reporter("nodes","splitters") -local report_optimizers = logs.reporter("nodes","optimizers") - -local nodes, node = nodes, node - -local variables = interfaces.variables - -local settings_to_array = utilities.parsers.settings_to_array -local settings_to_hash = utilities.parsers.settings_to_hash - -local find_node_tail = node.tail or node.slide -local free_node = node.free -local free_nodelist = node.flush_list -local has_attribute = node.has_attribute -local set_attribute = node.set_attribute -local new_node = node.new -local copy_node = node.copy -local copy_nodelist = node.copy_list -local traverse_nodes = node.traverse -local traverse_ids = node.traverse_id -local protect_glyphs = nodes.handlers.protectglyphs or node.protect_glyphs -local hpack_nodes = node.hpack -local insert_node_before = node.insert_before -local insert_node_after = node.insert_after -local repack_hlist = nodes.repackhlist - -local setnodecolor = nodes.tracers.colors.set - -local nodecodes = nodes.nodecodes -local whatsitcodes = nodes.whatsitcodes - -local glyph_code = nodecodes.glyph -local disc_code = nodecodes.disc -local hlist_code = nodecodes.hlist -local whatsit_code = nodecodes.whatsit - -local localpar_code = whatsitcodes.localpar -local dir_code = whatsitcodes.dir -local userdefined_code = whatsitcodes.userdefined - -local nodepool = nodes.pool -local tasks = nodes.tasks -local usernodeids = nodepool.userids - -local new_textdir = nodepool.textdir -local new_usernumber = nodepool.usernumber - -local starttiming = statistics.starttiming -local stoptiming = statistics.stoptiming -local process_characters = nodes.handlers.characters -local inject_kerns = nodes.injections.handler -local fontdata = fonts.hashes.identifiers -local setfontdynamics = fonts.hashes.setdynamics -local fontprocesses = fonts.hashes.processes - -local parbuilders = builders.paragraphs -parbuilders.solutions = parbuilders.solutions or { } -parbuilders.solutions.splitters = parbuilders.solutions.splitters or { } - -local splitters = parbuilders.solutions.splitters - -local preroll = true -local variant = "normal" -local split = attributes.private('splitter') -local cache = { } -local solutions = { } -- attribute sets -local variants = { } -local max_less = 0 -local max_more = 0 -local criterium = 0 -local randomseed = nil -local optimize = nil -- set later - -function splitters.setup(setups) - local method = settings_to_hash(setups.method or "") - if method[variables.preroll] then - preroll = true - else - preroll = false - end - for k, v in next, method do - if variants[k] then - optimize = variants[k] - end - end - randomseed = tonumber(setups.randomseed) - criterium = tonumber(setups.criterium) or criterium -end - -local contextsetups = fonts.specifiers.contextsetups - -local function convert(featuresets,name,set,what) - local list, numbers, nofnumbers = set[what], { }, 0 - if list then - for i=1,#list do - local feature = list[i] - local fs = featuresets[feature] - local fn = fs and fs.number - if not fn then - -- fall back on global features - fs = contextsetups[feature] - fn = fs and fs.number - end - if fn then - nofnumbers = nofnumbers + 1 - numbers[nofnumbers] = fn - if trace_goodies or trace_optimize then - report_solutions("solution %s of '%s' uses feature '%s' with number %s",i,name,feature,fn) - end - else - report_solutions("solution %s has an invalid feature reference '%s'",i,name,tostring(feature)) - end - end - return nofnumbers > 0 and numbers - end -end - -local function initialize(goodies) - local solutions = goodies.solutions - if solutions then - local featuresets = goodies.featuresets - local goodiesname = goodies.name - if trace_goodies or trace_optimize then - report_solutions("checking solutions in '%s'",goodiesname) - end - for name, set in next, solutions do - set.less = convert(featuresets,name,set,"less") - set.more = convert(featuresets,name,set,"more") - end - end -end - -fonts.goodies.register("solutions",initialize) - -function splitters.define(name,parameters) - local settings = settings_to_hash(parameters) -- todo: interfacing - local goodies, solution, less, more = settings.goodies, settings.solution, settings.less, settings.more - local less_set, more_set - local l = less and settings_to_array(less) - local m = more and settings_to_array(more) - if goodies then - goodies = fonts.goodies.load(goodies) -- also in tfmdata - if goodies then - local featuresets = goodies.featuresets - local solution = solution and goodies.solutions[solution] - if l and #l > 0 then - less_set = convert(featuresets,name,settings,"less") -- take from settings - else - less_set = solution and solution.less -- take from goodies - end - if m and #m > 0 then - more_set = convert(featuresets,name,settings,"more") -- take from settings - else - more_set = solution and solution.more -- take from goodies - end - end - else - if l then - local n = #less_set - for i=1,#l do - local ss = contextsetups[l[i]] - if ss then - n = n + 1 - less_set[n] = ss.number - end - end - end - if m then - local n = #more_set - for i=1,#m do - local ss = contextsetups[m[i]] - if ss then - n = n + 1 - more_set[n] = ss.number - end - end - end - end - if trace_optimize then - report_solutions("defining solutions '%s', less: '%s', more: '%s'",name,concat(less_set or {}," "),concat(more_set or {}," ")) - end - local nofsolutions = #solutions + 1 - solutions[nofsolutions] = { - solution = solution, - less = less_set or { }, - more = more_set or { }, - settings = settings, -- for tracing - } - context(nofsolutions) -end - -local nofwords, noftries, nofadapted, nofkept, nofparagraphs = 0, 0, 0, 0, 0 - -local splitter_one = usernodeids["splitters.one"] -local splitter_two = usernodeids["splitters.two"] - -function splitters.split(head) - -- quite fast - local current, done, rlmode, start, stop, attribute = head, false, false, nil, nil, 0 - cache, max_less, max_more = { }, 0, 0 - local function flush() -- we can move this - local font = start.font - local last = stop.next - local list = last and copy_nodelist(start,last) or copy_nodelist(start) - local n = #cache + 1 - local user_one = new_usernumber(splitter_one,n) - local user_two = new_usernumber(splitter_two,n) - head, start = insert_node_before(head,start,user_one) - insert_node_after(head,stop,user_two) - if rlmode == "TRT" or rlmode == "+TRT" then - local dirnode = new_textdir("+TRT") - list.prev = dirnode - dirnode.next = list - list = dirnode - end - local c = { - original = list, - attribute = attribute, - direction = rlmode, - font = font - } - if trace_split then - report_splitters("cached %4i: font: %s, attribute: %s, word: %s, direction: %s", n, - font, attribute, nodes.listtoutf(list,true), rlmode) - end - cache[n] = c - local solution = solutions[attribute] - local l, m = #solution.less, #solution.more - if l > max_less then max_less = l end - if m > max_more then max_more = m end - start, stop, done = nil, nil, true - end - while current do - local id = current.id - if id == glyph_code and current.subtype < 256 then - local a = has_attribute(current,split) - if not a then - start, stop = nil, nil - elseif not start then - start, stop, attribute = current, current, a - elseif a ~= attribute then - start, stop = nil, nil - else - stop = current - end - current = current.next - elseif id == disc_code then - start, stop, current = nil, nil, current.next - elseif id == whatsit_code then - if start then - flush() - end - local subtype = current.subtype - if subtype == dir_code or subtype == localpar_code then - rlmode = current.dir - end - current = current.next - else - if start then - flush() - end - current = current.next - end - end - if start then - flush() - end - nofparagraphs = nofparagraphs + 1 - nofwords = nofwords + #cache - return head, done -end - -local function collect_words(list) - local words, w, word = { }, 0, nil - for current in traverse_ids(whatsit_code,list) do - if current.subtype == userdefined_code then - local user_id = current.user_id - if user_id == splitter_one then - word = { current.value, current, current } - w = w + 1 - words[w] = word - elseif user_id == splitter_two then - word[3] = current - end - end - end - return words -- check for empty (elsewhere) -end - --- we could avoid a hpack but hpack is not that slow - -local function doit(word,list,best,width,badness,line,set,listdir) - local changed = 0 - local n = word[1] - local found = cache[n] - if found then - local original, attribute, direction = found.original, found.attribute, found.direction - local solution = solutions[attribute] - local features = solution and solution[set] - if features then - local featurenumber = features[best] -- not ok probably - if featurenumber then - noftries = noftries + 1 - local first = copy_nodelist(original) - if not trace_colors then - for n in traverse_nodes(first) do -- maybe fast force so no attr needed - set_attribute(n,0,featurenumber) -- this forces dynamics - end - elseif set == "less" then - for n in traverse_nodes(first) do - setnodecolor(n,"font:isol") - set_attribute(n,0,featurenumber) - end - else - for n in traverse_nodes(first) do - setnodecolor(n,"font:medi") - set_attribute(n,0,featurenumber) - end - end - local font = found.font - -- local dynamics = found.dynamics - -- local shared = fontdata[font].shared - -- if not dynamics then -- we cache this - -- dynamics = shared.dynamics - -- found.dynamics = dynamics - -- end - -- local processors = found[featurenumber] - -- if not processors then -- we cache this too - -- processors = fonts.handlers.otf.setdynamics(font,featurenumber) - -- found[featurenumber] = processors - -- end - local setdynamics = setfontdynamics[font] - if setdynamics then - local processes = setdynamics(font,featurenumber) - for i=1,#processes do -- often more than 1 - first = processes[i](first,font,featurenumber) - end - else - report_solutions("fatal error, no dynamics for font %s",font) - end - first = inject_kerns(first) - local h = word[2].next -- head of current word - local t = word[3].prev -- tail of current word - if first.id == whatsit_code then - local temp = first - first = first.next - free_node(temp) - end - local last = find_node_tail(first) - -- replace [u]h->t by [u]first->last - local next, prev = t.next, h.prev - prev.next, first.prev = first, prev - if next then - last.next, next.prev = next, last - end - -- check new pack - local temp, b = repack_hlist(list,width,'exactly',listdir) - if b > badness then - if trace_optimize then - report_optimizers("line %s, badness before: %s, after: %s, criterium: %s -> quit",line,badness,b,criterium) - end - -- remove last insert - prev.next, h.prev = h, prev - if next then - t.next, next.prev = next, t - else - t.next = nil - end - last.next = nil - free_nodelist(first) - else - if trace_optimize then - report_optimizers("line %s, badness before: %s, after: %s, criterium: %s -> continue",line,badness,b,criterium) - end - -- free old h->t - t.next = nil - free_nodelist(h) - changed, badness = changed + 1, b - end - if b <= criterium then - return true, changed - end - end - end - end - return false, changed -end - --- We repeat some code but adding yet another layer of indirectness is not --- making things better. - -variants[variables.normal] = function(words,list,best,width,badness,line,set,listdir) - local changed = 0 - for i=1,#words do - local done, c = doit(words[i],list,best,width,badness,line,set,listdir) - changed = changed + c - if done then - break - end - end - if changed > 0 then - nofadapted = nofadapted + 1 - -- todo: get rid of pack when ok because we already have packed and we only need the last b - local list, b = repack_hlist(list,width,'exactly',listdir) - return list, true, changed, b -- badness - else - nofkept = nofkept + 1 - return list, false, 0, badness - end -end - -variants[variables.reverse] = function(words,list,best,width,badness,line,set,listdir) - local changed = 0 - for i=#words,1,-1 do - local done, c = doit(words[i],list,best,width,badness,line,set,listdir) - changed = changed + c - if done then - break - end - end - if changed > 0 then - nofadapted = nofadapted + 1 - -- todo: get rid of pack when ok because we already have packed and we only need the last b - local list, b = repack_hlist(list,width,'exactly',listdir) - return list, true, changed, b -- badness - else - nofkept = nofkept + 1 - return list, false, 0, badness - end -end - -variants[variables.random] = function(words,list,best,width,badness,line,set,listdir) - local changed = 0 - while #words > 0 do - local done, c = doit(remove(words,random(1,#words)),list,best,width,badness,line,set,listdir) - changed = changed + c - if done then - break - end - end - if changed > 0 then - nofadapted = nofadapted + 1 - -- todo: get rid of pack when ok because we already have packed and we only need the last b - local list, b = repack_hlist(list,width,'exactly',listdir) - return list, true, changed, b -- badness - else - nofkept = nofkept + 1 - return list, false, 0, badness - end -end - -optimize = variants.normal -- the default - -local function show_quality(current,what,line) - local set = current.glue_set - local sign = current.glue_sign - local order = current.glue_order - local amount = set * ((sign == 2 and -1) or 1) - report_optimizers("line %s, %s, amount %s, set %s, sign %s (%s), order %s",line,what,amount,set,sign,how,order) -end - -function splitters.optimize(head) - local nc = #cache - if nc > 0 then - starttiming(splitters) - local listdir = nil -- todo ! ! ! - if randomseed then - math.setrandomseedi(randomseed) - randomseed = nil - end - local line = 0 - local tex_hbadness, tex_hfuzz = tex.hbadness, tex.hfuzz - tex.hbadness, tex.hfuzz = 10000, number.maxdimen - if trace_optimize then - report_optimizers("preroll: %s, variant: %s, preroll criterium: %s, cache size: %s", - tostring(preroll),variant,criterium,nc) - end - for current in traverse_ids(hlist_code,head) do - -- report_splitters("before: [%s] => %s",current.dir,nodes.tosequence(current.list,nil)) - line = line + 1 - local sign, dir, list, width = current.glue_sign, current.dir, current.list, current.width - local temp, badness = repack_hlist(list,width,'exactly',dir) -- it would be nice if the badness was stored in the node - if badness > 0 then - if sign == 0 then - if trace_optimize then - report_optimizers("line %s, badness %s, okay",line,badness) - end - else - local set, max - if sign == 1 then - if trace_optimize then - report_optimizers("line %s, badness %s, underfull, trying more",line,badness) - end - set, max = "more", max_more - else - if trace_optimize then - report_optimizers("line %s, badness %s, overfull, trying less",line,badness) - end - set, max = "less", max_less - end - -- we can keep the best variants - local lastbest, lastbadness = nil, badness - if preroll then - local bb, base - for i=1,max do - if base then - free_nodelist(base) - end - base = copy_nodelist(list) - local words = collect_words(base) -- beware: words is adapted - for j=i,max do - local temp, done, changes, b = optimize(words,base,j,width,badness,line,set,dir) - base = temp - if trace_optimize then - report_optimizers("line %s, alternative: %s.%s, changes: %s, badness %s",line,i,j,changes,b) - end - bb = b - if b <= criterium then - break - end - -- if done then - -- break - -- end - end - if bb and bb > criterium then -- needs checking - if not lastbest then - lastbest, lastbadness = i, bb - elseif bb > lastbadness then - lastbest, lastbadness = i, bb - end - else - break - end - end - free_nodelist(base) - end - local words = collect_words(list) - for best=lastbest or 1,max do - local temp, done, changes, b = optimize(words,list,best,width,badness,line,set,dir) - current.list = temp - if trace_optimize then - report_optimizers("line %s, alternative: %s, changes: %s, badness %s",line,best,changes,b) - end - if done then - if b <= criterium then -- was == 0 - protect_glyphs(list) - break - end - end - end - end - else - if trace_optimize then - report_optimizers("line %s, not bad enough",line) - end - end - -- we pack inside the outer hpack and that way keep the original wd/ht/dp as bonus - current.list = hpack_nodes(current.list,width,'exactly',listdir) - -- report_splitters("after: [%s] => %s",temp.dir,nodes.tosequence(temp.list,nil)) - end - for i=1,nc do - local ci = cache[i] - free_nodelist(ci.original) - end - cache = { } - tex.hbadness, tex.hfuzz = tex_hbadness, tex_hfuzz - stoptiming(splitters) - end -end - -statistics.register("optimizer statistics", function() - if nofwords > 0 then - local elapsed = statistics.elapsedtime(splitters) - local average = noftries/elapsed - return format("%s words identified in %s paragraphs, %s words retried, %s lines tried, %0.3f seconds used, %s adapted, %0.1f lines per second", - nofwords,nofparagraphs,noftries,nofadapted+nofkept,elapsed,nofadapted,average) - end -end) - -function splitters.enable() - tasks.enableaction("processors", "builders.paragraphs.solutions.splitters.split") - tasks.enableaction("finalizers", "builders.paragraphs.solutions.splitters.optimize") -end - -function splitters.disable() - tasks.disableaction("processors", "builders.paragraphs.solutions.splitters.split") - tasks.disableaction("finalizers", "builders.paragraphs.solutions.splitters.optimize") -end diff --git a/tex/context/base/node-spl.mkiv b/tex/context/base/node-spl.mkiv deleted file mode 100644 index 3630212af..000000000 --- a/tex/context/base/node-spl.mkiv +++ /dev/null @@ -1,114 +0,0 @@ -%D \module -%D [ file=node-spl, -%D version=2009.05.19, -%D title=\CONTEXT\ Node Macros, -%D subtitle=Splitters, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\writestatus{loading}{ConTeXt Node Support / Splitters} - -\registerctxluafile{node-spl}{1.001} - -\definesystemattribute[splitter][public] - -%D This module is specially made for the oriental \TEX\ project. The working is as -%D follows (and tuned for fonts like Idris' Husayni. The following method came to -%D my mind after a couple of Skype sessions with Idris while working on the rough -%D edges of the Husayni font and playing with font dynamics. -%D -%D \startitemize[packed] -%D -%D \item We define a couple of features sets, some can have stylistics variants -%D that result in the same words getting a different width. Normally this -%D happens in a goodies file. -%D -%D \item We group such features in a solution set. A solutionset can be enabled -%D by setting an attribute. -%D -%D \item For each paragraph we identify words that get this set applied. We replace -%D these words by a user node that refers to the original. -%D -%D \item For each word we apply the features to a copy that we associate with this -%D original word. -%D -%D \item At the end we have a paragraph (node list) with user nodes that point to a -%D cache that has originals and processed variants. -%D -%D \item When the paragraph is broken into lines we optimize the spacing by -%D substituting variants. -%D -%D \stopitemize -%D -%D This approach permits us to use a dedicated paragraph builder, one that treats -%D the user nodes special and takes the alternatives into account. -%D -%D Currently we assume only one solution being active. Maybe some day I'll support -%D a mixture. This is only one way of optimizing and after several experiments this -%D one was chosen as testcase. It took quite some experiments (and time) to get thus -%D far. -%D -%D The is experimental code for the Oriental \TEX\ project and aspects of it might -%D change. -%D -%D \starttyping -%D \setupfontsolutions[method={random,preroll},criterium=1,randomseed=101] -%D -%D \definefontsolution % actually only the last run needs to be done this way -%D [FancyHusayni] -%D [goodies=husayni, -%D solution=experimental] -%D -%D \definedfont[husayni*husayni-default at 24pt] -%D \setupinterlinespace[line=36pt] -%D \righttoleft -%D \enabletrackers[parbuilders.solutions.splitters.colors] -%D \setfontsolution[FancyHusayni] -%D alb alb alb \par -%D \resetfontsolution -%D \disabletrackers[parbuilders.solutions.splitters.colors] -%D \stoptyping - -\unprotect - -\newtoks\everysetupfontsolutions - -\unexpanded\def\definefontsolution - {\dodoubleargument\dodefinefontsolution} - -\def\dodefinefontsolution[#1][#2]% we could set the attribute at the lua end - {\setxvalue{\??fu:#1}{\attribute\splitterattribute\ctxlua{builders.paragraphs.solutions.splitters.define("#1","#2")}\relax}} - -\unexpanded\def\setfontsolution[#1]% - {\ctxlua{builders.paragraphs.solutions.splitters.enable()}% - \csname\??fu:#1\endcsname} - -\unexpanded\def\resetfontsolution - {\ctxlua{builders.paragraphs.solutions.splitters.disable()}% - \attribute\splitterattribute\attributeunsetvalue} - -\letvalue{\??fu:\v!reset}\resetfontsolution - -\unexpanded\def\setupfontsolutions[#1]% - {\getparameters[\??fu][#1]% - \the\everysetupfontsolutions} - -\appendtoks - \ctxlua{builders.paragraphs.solutions.splitters.setup { - method = "\@@fumethod", - criterium = "\@@fucriterium", - }}% -\to \everysetupfontsolutions - -% We initialize this module at the \LUA\ end. -% -% \setupfontsolutions -% [\c!method={\v!normal,preroll}, -% \c!criterium=0] - -\protect diff --git a/tex/context/base/pack-bar.mkiv b/tex/context/base/pack-bar.mkiv index 6967173e2..692b6f1f3 100644 --- a/tex/context/base/pack-bar.mkiv +++ b/tex/context/base/pack-bar.mkiv @@ -13,55 +13,80 @@ \writestatus{loading}{ConTeXt Packaging Macros / Bars} -%D This code has been moved from scrn-int to here (was some old -%D experimental code). It could be in scrn-bar but it's static. \unprotect +%D This code has been moved from scrn-int to here (was some old +%D experimental code). It could be in scrn-bar but it's static. In +%D the meantime the interface has been adapted to a key|/|value one. +%D %D \startbuffer -%D \dorecurse{10} -%D {\horizontalpositionbar -%D \pos\recurselevel \min1 \max10 -%D \token\framed{\recurselevel}% -%D \\} +%D \dorecurse{10}{ +%D \ruledhbox{\horizontalpositionbar[n=#1,min=1,max=10,text=!,color=red]} +%D \par +%D } +%D \stopbuffer +%D +%D \typebuffer \stoplinecorrection \getbuffer \stoplinecorrection %D -%D \hbox to 15em -%D {\hss -%D \dorecurse{10} -%D {\verticalpositionbar\pos\recurselevel\min1\max10\token\blackrule\\ -%D \hss}} +%D \startbuffer +%D \dorecurse{10}{ +%D \ruledhbox{\horizontalgrowingbar[n=#1,min=1,max=10,text=!,color=red]} +%D \par +%D } %D \stopbuffer +%D +%D \typebuffer \stoplinecorrection \getbuffer \stoplinecorrection + +\installcorenamespace{positionbar} + +\installsimplecommandhandler \??positionbar {positionbar} + +\setuppositionbar + [\c!min=1, + \c!max=1, + \c!n=1, + \c!text=?, + \c!width=\emwidth, + \c!height=\strutheight, + \c!depth=\strutdepth] -\def\horizontalpositionbar\pos#1\min#2\max#3\token#4\\% +\unexpanded\def\horizontalpositionbar[#1]% {\hbox to \hsize - {\hskip\zeropoint\!!plus #1\!!fill - \hskip\zeropoint\!!plus-#2\!!fill - #4\relax - \hskip\zeropoint\!!plus #3\!!fill - \hskip\zeropoint\!!plus-#1\!!fill}} + {\setuppositionbar[#1]% + \usepositionbarstyleandcolor\c!style\c!color + \hskip\zeropoint\!!plus \positionbarparameter\c!n \!!fill + \hskip\zeropoint\!!plus-\positionbarparameter\c!min\!!fill + \positionbarparameter\c!text\relax + \hskip\zeropoint\!!plus \positionbarparameter\c!max\!!fill + \hskip\zeropoint\!!plus-\positionbarparameter\c!n \!!fill}} -\def\verticalpositionbar\pos#1\min#2\max#3\token#4\\% +\unexpanded\def\verticalpositionbar[#1]% {\vbox to \vsize - {\vskip\zeropoint\!!plus #1\!!fill - \vskip\zeropoint\!!plus-#2\!!fill - \hbox{#4}\relax - \vskip\zeropoint\!!plus #3\!!fill - \vskip\zeropoint\!!plus-#1\!!fill}} + {\setuppositionbar[#1]% + \usepositionbarstyleandcolor\c!style\c!color + \vskip\zeropoint\!!plus \positionbarparameter\c!n \!!fill + \vskip\zeropoint\!!plus-\positionbarparameter\c!min\!!fill + \positionbarparameter\c!text\relax + \vskip\zeropoint\!!plus \positionbarparameter\c!max\!!fill + \vskip\zeropoint\!!plus-\positionbarparameter\c!n \!!fill}} -\def\horizontalgrowingbar\pos#1\min#2\max#3\height#4\depth#5\\% +\unexpanded\def\horizontalgrowingbar[#1]% {\hbox to \hsize - {\scratchcounter\numexpr#1-#2+\plusone\relax - \leaders\vrule\hskip\zeropoint\!!plus \scratchcounter\!!fill - \vrule\!!width\zeropoint\!!height#4\!!depth#5% - \hskip\zeropoint\!!plus #3\!!fill - \hskip\zeropoint\!!plus-#1\!!fill}} + {\setuppositionbar[#1]% + \usepositionbarstyleandcolor\c!style\c!color + \leaders\vrule\hskip\zeropoint\!!plus \numexpr\positionbarparameter\c!n-\positionbarparameter\c!min+\plusone\relax\!!fill + \vrule\!!width\zeropoint\!!height\positionbarparameter\c!height\!!depth\positionbarparameter\c!depth + \hskip\zeropoint\!!plus \positionbarparameter\c!max\!!fill + \hskip\zeropoint\!!plus-\positionbarparameter\c!n \!!fill}} -\def\verticalgrowingbar\pos#1\min#2\max#3\width#4\\% +\unexpanded\def\verticalgrowingbar[#1]% {\vbox to \vsize - {\scratchcounter\numexpr#1-#2+\plusone\relax - \leaders\hrule\vskip\zeropoint\!!plus\scratchcounter\!!fill - \hrule\!!width#4\!!height\zeropoint\!!depth\zeropoint - \vskip\zeropoint\!!plus #3\!!fill - \vskip\zeropoint\!!plus-#1\!!fill}} + {\setuppositionbar[#1]% + \usepositionbarstyleandcolor\c!style\c!color + \leaders\hrule\vskip\zeropoint\!!plus\numexpr\positionbarparameter\c!n-\positionbarparameter\c!min+\plusone\relax\!!fill + \hrule\!!width\positionbarparameter\c!width\!!height\zeropoint\!!depth\zeropoint + \vskip\zeropoint\!!plus \positionbarparameter\c!max\!!fill + \vskip\zeropoint\!!plus-\positionbarparameter\c!n \!!fill}} \protect \endinput diff --git a/tex/context/base/pack-box.mkiv b/tex/context/base/pack-box.mkiv index 41a17953b..b36ae1f11 100644 --- a/tex/context/base/pack-box.mkiv +++ b/tex/context/base/pack-box.mkiv @@ -13,7 +13,9 @@ \writestatus{loading}{ConTeXt Packaging Macros / Boxes} -% to be cleaned up +% to be cleaned up (boring ... so when on long trip or so) +% to be documented (up to users) +% some code can be sped up %D This module contains all kind of macros for moving content %D around. Many macros here come from other modules, but @@ -32,17 +34,8 @@ \definelayer[\v!text+1][\c!position=\v!yes,\c!region=,\c!width=\overlaywidth,\c!height=\overlayheight] \definelayer[\v!text+2][\c!position=\v!yes,\c!region=,\c!width=\overlaywidth,\c!height=\overlayheight] -% \unexpanded\def\positionregionlayer#1#2% -% {\composedlayer{#2}} -% -% \def\internaltextoverlay#1% will become more generic and installable -% {\startoverlay % i.e. probably an overlay by itself -% {\positionregionoverlay\textanchor{\v!text#1}}% see later -% {\positionregionlayer \textanchor{\v!text#1}}% -% \stopoverlay} - -\def\internaltextoverlay#1% will become more generic and installable - {\startoverlay % i.e. probably an overlay by itself +\unexpanded\def\internaltextoverlay#1% will become more generic and installable + {\startoverlay % i.e. probably an overlay by itself {\positionregionoverlay\textanchor{\v!text#1}}% see later {\composedlayer {\v!text#1}}% \stopoverlay} @@ -52,75 +45,6 @@ \defineoverlay[\v!text+1][\internaltextoverlay{+1}] \defineoverlay[\v!text+2][\internaltextoverlay{+2}] -% to be documented - -% \definelayer[anchor] -% -% \unexpanded\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} -% -% \unexpanded\def\anchor -% {\dosingleargument\pack_anchor} -% -% \def\pack_anchor[#1]% -% {\ifcsname\??an#1\endcsname\@EA\nonoanchor\else\@EA\dodoanchor\fi[#1]} -% -% \def\nonoanchor[#1]% -% {\csname\??an#1\endcsname} -% -% \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]% brrr: we need to apply offset only once .. a bit messy -% {\dowithnextbox -% {\bgroup -% % \checktextbackgrounds -% \setbox\scratchbox\emptyhbox -% \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} - \installcorenamespace {anchor} \unexpanded\def\defineanchor @@ -204,22 +128,22 @@ % collectors -\def\@@collectorbox{@@collectorbox} +\installcorenamespace{collectorbox} \unexpanded\def\definecollector {\dodoubleargument\dodefinecollector} \def\dodefinecollector[#1][#2]% - {\ifcsname\@@collectorbox#1\endcsname \else - \expandafter\newbox\csname\@@collectorbox#1\endcsname + {\ifcsname\??collectorbox#1\endcsname \else + \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!x=\zeropoint,\c!y=\zeropoint, + \c!offset=\zeropoint,\c!rotation=, % geen 0 ! + \c!hoffset=\zeropoint,\c!voffset=\zeropoint, \c!location=rb,\c!corner=,#2]} \unexpanded\def\setupcollector @@ -237,7 +161,7 @@ \forgetall \dontcomplain \dowithnextbox - {\ifcsname\@@collectorbox#1\endcsname + {\ifcsname\??collectorbox#1\endcsname \dodosetcollector[#1][#2]% \else \writestatus{collector}{unknown layer #1}% @@ -249,7 +173,7 @@ \def\dodosetcollector[#1][#2]% todo: keep reference point {\def\currentcollector{#1}% - \chardef\collectorbox\csname\@@collectorbox#1\endcsname + \chardef\collectorbox\csname\??collectorbox#1\endcsname \getparameters[\??cb#1][#2]% \d_pack_layers_x_size\wd\collectorbox \d_pack_layers_y_size\ht\collectorbox @@ -321,14 +245,14 @@ \fi} \def\flushcollector[#1]% - {\ifcsname\@@collectorbox#1\endcsname + {\ifcsname\??collectorbox#1\endcsname \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}}}% + \raise\dp\csname\??collectorbox#1\endcsname + \next\csname\??collectorbox#1\endcsname}}}% \else \writestatus{collector}{unknown collector #1}% \fi} @@ -336,8 +260,8 @@ \def\composedcollector#1{\flushcollector[#1]} \def\resetcollector[#1]% - {\ifcsname\@@collectorbox#1\endcsname - \global\setbox\csname\@@collectorbox#1\endcsname\emptybox + {\ifcsname\??collectorbox#1\endcsname + \global\setbox\csname\??collectorbox#1\endcsname\emptybox \fi} \def\adaptcollector @@ -346,7 +270,7 @@ \def\doadaptcollector[#1][#2]% % a typical case where \global\wd looks better in the code {\bgroup \def\currentcollector{#1}% - \chardef\collectorbox\csname\@@collectorbox#1\endcsname + \chardef\collectorbox\csname\??collectorbox#1\endcsname \getparameters[\??cb#1][\c!voffset=\zeropoint,\c!hoffset=\zeropoint,#2]% \scratchdimen\wd\collectorbox \advance\scratchdimen\collectorparameter\c!hoffset @@ -406,51 +330,6 @@ % [frame=on,offset=0pt] % {gans} % {\externalfigure[koe][width=3cm]} - -% lean and mean: -% -% \installcorenamespace {layeredtext} -% -% \newdimen\d_pack_layeredtexts_width -% \newdimen\d_pack_layeredtexts_height -% -% \definelayer -% [\??layeredtextlayer] -% -% \setuplayer -% [\??layeredtextlayer]% -% [\c!width=\d_pack_layeredtexts_width,\c!height=\d_pack_layeredtexts_height]% -% -% \unexpanded\def\layeredtext -% {\dodoubleempty\dolayeredtext} -% -% \def\dolayeredtext[#1][#2]#3% -% {\bgroup -% \dowithnextbox -% {\d_pack_layeredtexts_width \wd\nextbox -% \d_pack_layeredtexts_height\ht\nextbox -% \begingroup % preserve \nextbox -% \setlayer -% [\??layeredtextlayer]% -% [#1]% -% {\getparameters[\??du][\c!style=,\c!color=,#2]% -% \dousestyleparameter\@@dustyle -% \setupinterlinespace -% \framed -% [\c!frame=\v!overlay,\c!foregroundcolor=\@@ducolor,\c!foregroundstyle=\@@dustyle,#2]% -% {#3}}% -% \endgroup -% \framed -% [\c!offset=\v!overlay, -% \c!frame=\v!off, -% \c!background={\v!foreground,\??layeredtextlayer}, -% \c!width=\d_pack_layeredtexts_width, -% \c!height=\d_pack_layeredtexts_height]% -% {\flushnextbox}% -% \egroup}% -% \hbox} -% -% maybe faster but more code: \installcorenamespace {layeredtext} \installcorenamespace {layeredtextlayer} @@ -531,15 +410,15 @@ % [frame=on,offset=0pt] % {gans} % {\externalfigure[koe][width=3cm]} - -\def\ornamenttext - {\dodoubleempty\doornamenttext} -\def\doornamenttext[#1][#2]% +\unexpanded\def\ornamenttext + {\dodoubleempty\pack_ornament_text} + +\def\pack_ornament_text[#1][#2]% {\bgroup \doifassignmentelse{#1} - {\getparameters[\s!dummy][\c!alternative=\v!a,#1]% - \doifelse\dummyalternative\v!a + {\getdummyparameters[\c!alternative=\v!a,#1]% + \doifelse{\directdummyparameter\c!alternative}\v!a {\egroup\collectedtext}% {\egroup\layeredtext }% [#1][#2]}% @@ -549,7 +428,7 @@ {\dotripleempty\dodefineornament} \def\dodefineornament[#1][#2][#3]% - {\setvalue{#1}{\doornamenttext[#2][#3]}} + {\setuvalue{#1}{\pack_ornament_text[#2][#3]}} % \defineornament % [affiliation] @@ -582,7 +461,7 @@ % [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 @@ -680,9 +559,13 @@ \fi \egroup} -\setupbleeding[\c!stretch=\v!yes] +\setupbleeding + [\c!stretch=\v!yes] -\defineexternalfigure[bleed][\c!width=\bleedwidth,\c!height=\bleedheight] % should be \v!bleed +\defineexternalfigure + [bleed] % should be \v!bleed + [\c!width=\bleedwidth, + \c!height=\bleedheight] % \placefigure[left]{none} % {\bleed[width=5cm,height=3cm,location=lt]{\externalfigure[koe][bleed]}} @@ -804,22 +687,6 @@ [\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] @@ -911,9 +778,9 @@ {\getparameters[\??ox] [\c!x=\zeropoint, \c!y=\zeropoint, - \c!width=\nextboxwd, - \c!height=\nextboxht, - \c!depth=\nextboxdp, + \c!width=\wd\nextbox, + \c!height=\ht\nextbox, + \c!depth=\dp\nextbox, \c!location=, \c!leftoffset=\zeropoint, \c!rightoffset=\zeropoint, @@ -1020,15 +887,14 @@ \unexpanded\def\phantombox[#1]% == \framed[\c!empty=\v!yes,\c!offset=\v!overlay,#1]{} {\hbox\bgroup - \getparameters - [\??ol] % brrr + \getdummyparameters [\c!width=\zeropoint,% \c!height=\zeropoint,% \c!depth=\zeropoint,#1]% \setbox\scratchbox\emptyhbox - \wd\scratchbox\@@olwidth - \ht\scratchbox\@@olheight - \dp\scratchbox\@@oldepth + \wd\scratchbox\directdummyparameter\c!width + \ht\scratchbox\directdummyparameter\c!height + \dp\scratchbox\directdummyparameter\c!depth \box\scratchbox \egroup} diff --git a/tex/context/base/pack-cut.mkiv b/tex/context/base/pack-cut.mkiv new file mode 100644 index 000000000..1afccee50 --- /dev/null +++ b/tex/context/base/pack-cut.mkiv @@ -0,0 +1,162 @@ +%D \module +%D [ file=pack-cut, % comes from core-vis/trac-vis +%D version=1996.06.01, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Cut boxes, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +%D \macros +%D {makecutbox, cuthbox, cutvbox, cutvtop} +%D +%D Although mainly used for marking the page, these macros can +%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. + +\newdimen\d_pack_cutmarks_width +\newdimen\d_pack_cutmarks_height +\newdimen\d_pack_cutmarks_depth + +\newcount\horizontalcutmarks \horizontalcutmarks \plustwo +\newcount\verticalcutmarks \verticalcutmarks \plustwo +\newcount\cutmarkoffset \cutmarkoffset \plusone + +\let\cutmarksymbol \relax +\let\cutmarktoptext \empty +\let\cutmarkbottomtext\empty +\let\cutmarkhoffset \empty +\let\cutmarkvoffset \empty +\def\cutmarklength {2\bodyfontsize} + +\unexpanded\def\horizontalcuts + {\normalhbox to \d_pack_cutmarks_width + {\dorecurse\horizontalcutmarks{\vrule\!!width\boxrulewidth\!!height\cutmarklength\normalhfill}% + \unskip}} + +\unexpanded\def\verticalcuts + {\normalvbox to \dimexpr\d_pack_cutmarks_height+\d_pack_cutmarks_depth\relax + {\hsize\cutmarklength + \dorecurse\verticalcutmarks{\vrule\!!height\boxrulewidth\!!width\hsize\normalvfill}% + \unskip}} + +\unexpanded\def\baselinecuts + {\ifdim\d_pack_cutmarks_depth>\zeropoint + \normalvbox to \dimexpr\d_pack_cutmarks_height+\d_pack_cutmarks_depth\relax + {\hsize\dimexpr\cutmarklength/2\relax + \normalvskip\zeropoint\!!plus\d_pack_cutmarks_height + \vrule\!!height\boxrulewidth\!!width\hsize + \normalvskip\zeropoint\!!plus\d_pack_cutmarks_depth}% + \fi} + +\unexpanded\def\cutmarksymbols#1% + {\normalhbox to \d_pack_cutmarks_width + {\setbox\scratchbox\normalhbox to \cutmarklength + {\normalhss\infofont\cutmarksymbol\normalhss}% + \normalhss + \normalvbox to \cutmarklength + {\scratchdimen\dimexpr\cutmarklength/2\relax + \scratchskip \ifx\cutmarkhoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkhoffset\fi + \normalvss + \hbox to \d_pack_cutmarks_width + {\llap{\copy\scratchbox\normalhskip\scratchskip}% + \normalhskip\scratchdimen\hss\infofont#1\hss\normalhskip\scratchdimen + \rlap{\normalhskip\scratchskip\copy\scratchbox}}% + \normalvss}% + \normalhss}} + +\unexpanded\def\makecutbox#1% + {\bgroup + \d_pack_cutmarks_height\ht#1% + \d_pack_cutmarks_depth \dp#1% + \d_pack_cutmarks_width \wd#1% + \setbox#1\normalhbox + {\dontcomplain + \forgetall + \boxmaxdepth\maxdimen + \offinterlineskip + \scratchdimen\dimexpr\cutmarklength/2\relax + \hsize\d_pack_cutmarks_width + \setbox\scratchbox\normalvbox + {\setbox\scratchbox\normalhbox{\horizontalcuts}% + \scratchskip\ifx\cutmarkvoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi + \tlap{\copy\scratchbox\normalvskip\scratchskip}% + \hbox to \d_pack_cutmarks_width + {\scratchskip\ifx\cutmarkhoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkhoffset\fi + \setbox\scratchbox\normalhbox{\verticalcuts}% + \llap{\copy\scratchbox\normalhskip\scratchskip}% + \ifdim\d_pack_cutmarks_depth=\zeropoint + \normalhfill + \else + \bgroup + \setbox\scratchbox\normalhbox{\baselinecuts}% + \llap{\copy\scratchbox\normalhskip\scratchskip}% + \normalhfill + \rlap{\normalhskip\scratchskip\copy\scratchbox}% + \egroup + \fi + \rlap{\normalhskip\scratchskip\copy\scratchbox}}% + \blap{\normalvskip\scratchskip\copy\scratchbox}}% + \ht\scratchbox\d_pack_cutmarks_height + \dp\scratchbox\d_pack_cutmarks_depth + \wd\scratchbox\zeropoint + \startcolor[\defaulttextcolor]% + \box\scratchbox + \ifx\cutmarksymbol\relax \else + \setbox\scratchbox\normalvbox + {\scratchskip\ifx\cutmarkvoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi + \vskip-\dimexpr\scratchskip+\cutmarklength\relax + \normalhbox{\cutmarksymbols\cutmarktoptext}% + \vskip\dimexpr\scratchskip+\d_pack_cutmarks_height+\d_pack_cutmarks_depth+\scratchskip\relax + \normalhbox{\cutmarksymbols\cutmarkbottomtext}}% + \ht\scratchbox\d_pack_cutmarks_height + \dp\scratchbox\d_pack_cutmarks_depth + \wd\scratchbox\zeropoint + \box\scratchbox + \fi + \stopcolor + \box#1}% + \wd#1\d_pack_cutmarks_width + \ht#1\d_pack_cutmarks_height + \dp#1\d_pack_cutmarks_depth + \egroup} + +\unexpanded\def\cuthbox{\normalhbox\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalhbox} +\unexpanded\def\cutvbox{\normalvbox\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalvbox} +\unexpanded\def\cutvtop{\normalvtop\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\normalvtop} + +\protect \endinput diff --git a/tex/context/base/pack-obj.lua b/tex/context/base/pack-obj.lua index c580aaa62..a54a48d22 100644 --- a/tex/context/base/pack-obj.lua +++ b/tex/context/base/pack-obj.lua @@ -46,15 +46,30 @@ end function jobobjects.number(tag,default) local o = collected[tag] or tobesaved[tag] - context((o and o[1]) or default) + return o and o[1] or default end function jobobjects.page(tag,default) local o = collected[tag] or tobesaved[tag] - context((o and o[2]) or default) + return o and o[2] or default end -function jobobjects.doifelse(tag) +-- interface + +commands.saveobject = jobobjects.save +commands.setobject = jobobjects.set + +function commands.objectnumber(tag,default) + local o = collected[tag] or tobesaved[tag] + context(o and o[1] or default) +end + +function commands.objectpage(tag,default) + local o = collected[tag] or tobesaved[tag] + context(o and o[2] or default) +end + +function commands.doifobjectreferencefoundelse(tag) commands.testcase(collected[tag] or tobesaved[tag]) end diff --git a/tex/context/base/pack-obj.mkiv b/tex/context/base/pack-obj.mkiv index 6c9848a01..1e2c392a2 100644 --- a/tex/context/base/pack-obj.mkiv +++ b/tex/context/base/pack-obj.mkiv @@ -105,29 +105,27 @@ % % \everyobject{\the\pdfbackendeveryxform} % -% \let\doresetobjects\relax -% -% \def\setobject #1#2{\begingroup\objectoff\objectoffset\inobjecttrue\the\everyobject\dowithnextbox{\dosetobject{#1}{#2}}} -% \def\settightobject#1#2{\begingroup\objectoff\zeropoint \inobjecttrue\the\everyobject\dowithnextbox{\dosetobject{#1}{#2}}} +% \unexpanded\def\setobject #1#2{\begingroup\objectoff\objectoffset\inobjecttrue\the\everyobject\dowithnextbox{\pack_objects_set{#1}{#2}}} +% \unexpanded\def\settightobject#1#2{\begingroup\objectoff\zeropoint \inobjecttrue\the\everyobject\dowithnextbox{\pack_objects_set{#1}{#2}}} % % \let\objectsetvbox\vbox %\def\objectsetvbox{\ruledvbox} % \let\objectgetvbox\vbox %\def\objectgetvbox{\ruledvbox} % \let\objectsethbox\hbox %\def\objectsethbox{\ruledhbox} % \let\objectgethbox\hbox %\def\objectgethbox{\ruledhbox} % -% \def\dosetobject#1#2% +% \unexpanded\def\pack_objects_set#1#2% % {\objectwd\wd\nextbox % \objectht\ht\nextbox % \objectdp\dp\nextbox % \ifdim\objectoff=\zeropoint\relax % \setbox\objectbox\box\nextbox % \else -% \setbox\objectbox\objectsetvbox spread 2\objectoff{\vss\objectsethbox spread 2\objectoff{\hss\flushnextbox\hss}\vss}% +% \setbox\objectbox\objectsetvbox spread 2\objectoff{\vss\objectsethbox spread 2\objectoff{\hss\box\nextbox\hss}\vss}% % \fi % \ctxlua{objects.register("#1::#2")}% % \endgroup} % -% \def\getobject#1#2% +% \unexpanded\def\getobject#1#2% % {\begingroup % \ctxlua{objects.restore("#1::#2")}% % \ifdim\objectoff=\zeropoint\relax \else @@ -140,7 +138,7 @@ % \box\objectbox % \endgroup} % -% \def\getpageobject#1#2% +% \unexpanded\def\getpageobject#1#2% % {\begingroup % \ctxlua{objects.restore("#1::#2")}% % \ifdim\objectoff=\zeropoint\relax @@ -155,25 +153,25 @@ % \box\objectbox % \endgroup} % -% \def\setobjectdirectly #1#2{\ctxlua{objects.register("#1::#2")}} -% \def\getobjectdirectly #1#2{\ctxlua{objects.restore ("#1::#2")}} -% \def\getobjectdimensions #1#2{\ctxlua{objects.restore ("#1::#2")}} -% \def\doifobjectfoundelse #1#2{\ctxlua{objects.doifelse("#1::#2")}} -% \def\doifobjectreferencefoundelse#1#2{\ctxlua{objects.doifelse("#1::#2")}} +% \unexpanded\def\setobjectdirectly #1#2{\ctxlua{objects.register("#1::#2")}} +% \unexpanded\def\getobjectdirectly #1#2{\ctxlua{objects.restore ("#1::#2")}} +% \unexpanded\def\getobjectdimensions #1#2{\ctxlua{objects.restore ("#1::#2")}} +% \unexpanded\def\doifobjectfoundelse #1#2{\ctxlua{objects.doifelse("#1::#2")}} +% \unexpanded\def\doifobjectreferencefoundelse#1#2{\ctxlua{objects.doifelse("#1::#2")}} % % \let\objectreferenced\relax % \let\driverreferenced\relax % -% \def\doregisterobjectreference{\writestatus{objects}{obsolete: register object reference}\gobblethreearguments} -% \def\dooverloadobjectreference{\writestatus{objects}{obsolete: overload object reference}\gobblethreearguments} -% \def\dosetobjectreference {\writestatus{objects}{obsolete: set object reference}\gobblethreearguments} -% \def\dosetdriverreference {\writestatus{objects}{obsolete: set driver reference}\gobblethreearguments} +% \unexpanded\def\pack_objects_register_reference{\writestatus{objects}{obsolete: register object reference}\gobblethreearguments} +% \unexpanded\def\pack_objects_overload_reference{\writestatus{objects}{obsolete: overload object reference}\gobblethreearguments} +% \unexpanded\def\dosetobjectreference {\writestatus{objects}{obsolete: set object reference}\gobblethreearguments} +% \unexpanded\def\dosetdriverreference {\writestatus{objects}{obsolete: set driver reference}\gobblethreearguments} % % \def\defaultobjectreference{0} % \def\defaultobjectpage {\realfolio} % -% \def\dogetobjectreference #1#2#3{\xdef#3{\ctxlua{objects.reference("#1::#2)}}} -% \def\dogetobjectreferencepage#1#2#3{\xdef#3{\ctxlua{objects.page("#1::#2))}}} +% \unexpanded\def\dogetobjectreference #1#2#3{\xdef#3{\ctxlua{objects.reference("#1::#2)}}} +% \unexpanded\def\dogetobjectreferencepage#1#2#3{\xdef#3{\ctxlua{objects.page("#1::#2))}}} % % \protect % @@ -219,26 +217,27 @@ %D housekeeping to the driver. The current approach permits %D us to keep the box characteristic too. -\newif\ifinobject +\installcorenamespace {objects} + +\newif\ifinobject % public (might become a conditional) -\def\objectplaceholder{NOT YET FLUSHED}% +\def\objectplaceholder{NOT YET FLUSHED} -\def\presetobject#1#2% \global added - {\ifcsname\??ob:#1::#2\endcsname\else - \global\@EA\let\csname\??ob:#1::#2\endcsname\objectplaceholder +\unexpanded\def\presetobject#1#2% \global added + {\ifcsname\??objects#1::#2\endcsname\else + \global\expandafter\let\csname\??objects#1::#2\endcsname\objectplaceholder \fi} -\def\dosetobject#1#2#3% \initializepaper this will move to \everyshipout - {% \initializepaper - \ifcsname\??ob:#2::#3\endcsname +\unexpanded\def\pack_objects_set#1#2#3% + {\ifcsname\??objects#2::#3\endcsname \expandafter\gobblefivearguments \else % tzt, overload internal referenced objects to save entries - \expandafter\dodosetobject + \expandafter\pack_objects_set_indeed \fi {#1}{#2}{#3}} -\def\resetobject#1#2% - {\letbeundefined{\??ob:#1::#2}} +\unexpanded\def\resetobject#1#2% + {\letbeundefined{\??objects#1::#2}} %D \macros %D {finalizeobjectbox} @@ -246,7 +245,7 @@ %D This one provides a hook for last minute object box processing %D we need this in \MKIV. -\ifx\finalizeobjectbox\undefined +\ifdefined\finalizeobjectbox \else \let\finalizeobjectbox\gobbleoneargument \fi @@ -257,47 +256,54 @@ \def\objectoffset{1cm} -\def\dodosetobject#1#2#3% +\unexpanded\def\pack_objects_set_indeed#1#2#3% {\bgroup - \globalpushmacro\crossreferenceobject \objectreferenced + \globalpushmacro\crossreferenceobject + \objectreferenced \inobjecttrue \dowithnextbox {\globalpopmacro\crossreferenceobject - \dododosetobject{#1}{#2}{#3}\egroup}} + \pack_objects_set_indeed_indeed{#1}{#2}{#3}% + \egroup}} % in luatex version < 66 we had a 1bp compensation (hardcoded in luatex) -\def\dododosetobject#1#2#3% +\let\pack_objects_handle\relax + +\unexpanded\def\pack_objects_set_indeed_indeed#1#2#3% {\begingroup \scratchdimen\objectoffset - \@EA\xdef\csname\??ob:#2::#3\endcsname - {\noexpand\dohandleobject{#2}{#3}% + \expandafter\xdef\csname\??objects#2::#3\endcsname + {\pack_objects_handle + {#2}% + {#3}% {\ifhbox\nextbox\hbox\else\vbox\fi}% - {\number\nextboxwd}{\number\nextboxht}{\number\nextboxdp}% + {\number\wd\nextbox}% + {\number\ht\nextbox}% + {\number\dp\nextbox}% {\number\scratchdimen}}% \expanded % freeze the dimensions since \dostartobject may use \nextbox - {\dostartobject{#2}{#3}{\the\nextboxwd}{\the\nextboxht}{\the\nextboxdp}}% + {\dostartobject{#2}{#3}{\the\wd\nextbox}{\the\ht\nextbox}{\the\dp\nextbox}}% \ifcase#1\relax\else \ifdim\objectoffset>\zeropoint - \setbox\nextbox\vbox spread 2\scratchdimen + \setbox\nextbox\vbox \!!spread 2\scratchdimen {\forgetall \offinterlineskip - \vss\hbox spread 2\scratchdimen{\hss\flushnextbox\hss}\vss}% + \vss\hbox \!!spread 2\scratchdimen{\hss\box\nextbox\hss}\vss}% \fi \fi - \flushnextbox + \box\nextbox \dostopobject \endgroup} -\def\getobject#1#2% - {\ifcsname\??ob:#1::#2\endcsname +\unexpanded\def\getobject#1#2% + {\ifcsname\??objects#1::#2\endcsname \begingroup - \let\dohandleobject\dogetobject - \csname\??ob:#1::#2\expandafter\endcsname + \let\pack_objects_handle\pack_objects_get + \csname\??objects#1::#2\expandafter\endcsname \else {\infofont[object #1::#2]}% \fi} -\def\dogetobject#1#2#3#4#5#6#7% don't change this, should work for dvi & pdf - {% \initializepaper - \forgetall +\unexpanded\def\pack_objects_get#1#2#3#4#5#6#7% don't change this, should work for dvi & pdf + {\forgetall % todo: if no attr then faster \setbox\scratchbox\vbox attr \viewerlayerattribute \attribute\viewerlayerattribute {\doinsertobject{#1}{#2}}% @@ -323,18 +329,18 @@ %D The results are reported in \type {\objectwidth}, \type %D {\objectheight} and \type {\objectdepth}. -\def\dogetobjectdimensions#1#2#3#4#5#6#7% +\unexpanded\def\pack_objects_get_dimensions#1#2#3#4#5#6#7% {\def\objectwidth {#4\s!sp}% \def\objectheight{#5\s!sp}% \def\objectdepth {#6\s!sp}% \def\objectmargin{#7\s!sp}} -\def\getobjectdimensions#1#2% - {\let\dohandleobject\dogetobjectdimensions +\unexpanded\def\getobjectdimensions#1#2% + {\let\pack_objects_handle\pack_objects_get_dimensions \let\objectwidth \!!zeropoint \let\objectheight\!!zeropoint \let\objectdepth \!!zeropoint - \csname\??ob:#1::#2\endcsname} + \csname\??objects#1::#2\endcsname} %D Apart from this kind of objects, that have typeset content, %D we can have low level driver specific objects. Both types @@ -352,35 +358,35 @@ %D These commands are to be called by the \type{\startobject}, %D \type{\stopobject} and \type{\insertobject} specials. -\def\objectreferenced{\global\chardef\crossreferenceobject\plusone} -\def\driverreferenced{\global\chardef\crossreferenceobject\zerocount} +\unexpanded\def\objectreferenced{\global\chardef\crossreferenceobject\plusone} +\unexpanded\def\driverreferenced{\global\chardef\crossreferenceobject\zerocount} \objectreferenced % no undefined test ! ! ! ! (pdftex fails on undefined objects) -\def\doregisterobjectreference#1#2#3{\normalexpanded{\noexpand\ctxlatelua{job.objects.save("#1::#2",#3,\noexpand\the\realpageno)}}} -\def\dooverloadobjectreference#1#2#3{\ctxlua{job.objects.set("#1::#2",#3,\the\realpageno)}} +\unexpanded\def\pack_objects_register_reference#1#2#3{\normalexpanded{\noexpand\ctxlatecommand{saveobject("#1::#2",#3,\noexpand\the\realpageno)}}} +\unexpanded\def\pack_objects_overload_reference#1#2#3{\ctxcommand{setobject("#1::#2",#3,\the\realpageno)}} -\def\dosetobjectreference +\unexpanded\def\dosetobjectreference {\ifcase\crossreferenceobject \objectreferenced - \expandafter\dooverloadobjectreference + \expandafter\pack_objects_overload_reference \else - \expandafter\doregisterobjectreference + \expandafter\pack_objects_register_reference \fi} -\def\dosetdriverreference +\unexpanded\def\dosetdriverreference {\driverreferenced\dosetobjectreference} \def\defaultobjectreference#1#2{0} % driver dependent \def\defaultobjectpage #1#2{\realfolio} -\def\dogetobjectreference #1#2#3{\xdef#3{\ctxlua{job.objects.number("#1::#2","\defaultobjectreference{#1}{#2}")}}} -\def\dogetobjectreferencepage#1#2#3{\xdef#3{\ctxlua{job.objects.page("#1::#2","\defaultobjectpage{#1}{#2}")}}} +\unexpanded\def\dogetobjectreference #1#2#3{\xdef#3{\ctxcommand{objectnumber("#1::#2","\defaultobjectreference{#1}{#2}")}}} +\unexpanded\def\dogetobjectreferencepage#1#2#3{\xdef#3{\ctxcommand{objectpage("#1::#2","\defaultobjectpage{#1}{#2}")}}} -\def\setobject {\driverreferenced\dosetobject1} -\def\settightobject{\driverreferenced\dosetobject0} +\unexpanded\def\setobject {\driverreferenced\pack_objects_set1} +\unexpanded\def\settightobject{\driverreferenced\pack_objects_set0} %D \macros %D {doifobjectfoundelse,doifobjectreferencefoundelse} @@ -393,13 +399,14 @@ %D \doifobjectreferencefoundelse{class}{object}{do then}{do else} %D \stoptyping -\def\doifobjectfoundelse#1#2% - {\ifcsname\??ob:#1::#2\endcsname +\unexpanded\def\doifobjectfoundelse#1#2% + {\ifcsname\??objects#1::#2\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} -\def\doifobjectreferencefoundelse#1#2{\ctxlua{job.objects.doifelse("#1::#2")}} +\unexpanded\def\doifobjectreferencefoundelse#1#2% + {\ctxcommand{doifobjectreferencefoundelse("#1::#2")}} \protect \endinput diff --git a/tex/context/base/pack-pos.mkiv b/tex/context/base/pack-pos.mkiv index fab73bc4a..d14d53751 100644 --- a/tex/context/base/pack-pos.mkiv +++ b/tex/context/base/pack-pos.mkiv @@ -23,65 +23,82 @@ % \position[ystep=relative](3,-1){test} % \position(10,10){test} % \stoppositioning} +% +% watch out: rather global -\newdimen\positioningxposition \newdimen\positioningyposition -\newdimen\positioningxdimension \newdimen\positioningydimension -\newdimen\positioningxoffset \newdimen\positioningyoffset +\installcorenamespace {positioning} -\newbox\positioningbox +\installcommandhandler \??positioning {positioning} \??positioning -\unexpanded\def\startpositioning - {\dosingleempty\dostartpositioning} +\setuppositioning + [\c!state=\v!start, + \c!unit=\s!cm, + \c!factor=\plusone, + \c!scale =\plusone, + \c!xfactor=\positioningparameter\c!factor, + \c!yfactor=\positioningparameter\c!factor, + \c!xscale=\positioningparameter\c!scale, + \c!yscale=\positioningparameter\c!scale, + \c!xstep=\v!absolute, + \c!ystep=\v!absolute, + \c!xoffset=\zeropoint, + \c!yoffset=\zeropoint] + +\newdimen\d_pack_positioning_x_position +\newdimen\d_pack_positioning_y_position +\newdimen\d_pack_positioning_x_dimension +\newdimen\d_pack_positioning_y_dimension +\newdimen\d_pack_positioning_x_offset +\newdimen\d_pack_positioning_y_offset -\def\dostartpositioning[#1]% +\newbox\b_pack_positioning + +\unexpanded\def\startpositioning {\bgroup - \getparameters[\??ps][#1]% - \positioningxposition \zeropoint \positioningyposition \zeropoint - \positioningxdimension\zeropoint \positioningydimension\zeropoint - \positioningxoffset \zeropoint \positioningyoffset \zeropoint - \hfuzz \paperwidth \vfuzz \paperheight - \setbox\positioningbox\hbox\bgroup + \dodoubleempty\pack_positioning_start} + +\def\pack_positioning_start[#1][#2]% + {\ifsecondargument + \edef\currentpositioning{#1}% + \setupcurrentpositioning[#2]% + \else\iffirstargument + \doifassignmentelse{#1} + {\let\currentpositioning\empty + \setupcurrentpositioning[#1]}% + {\edef\currentpositioning{#1}}% + \else + \let\currentpositioning\empty + \fi\fi + \d_pack_positioning_x_position \zeropoint + \d_pack_positioning_y_position \zeropoint + \d_pack_positioning_x_dimension\zeropoint + \d_pack_positioning_y_dimension\zeropoint + \d_pack_positioning_x_offset \zeropoint + \d_pack_positioning_y_offset \zeropoint + \hfuzz\paperwidth + \vfuzz\paperheight + \setbox\b_pack_positioning\hbox\bgroup \ignorespaces} \unexpanded\def\stoppositioning {\removeunwantedspaces - \doifnot\@@psoffset\v!yes - {\global\positioningxoffset\zeropoint - \global\positioningyoffset\zeropoint}% - \global\advance\positioningxdimension \positioningxoffset - \global\advance\positioningydimension \positioningyoffset + \doifnot{\positioningparameter\c!offset}\v!yes + {\global\d_pack_positioning_x_offset\zeropoint + \global\d_pack_positioning_y_offset\zeropoint}% + \global\advance\d_pack_positioning_x_dimension\d_pack_positioning_x_offset + \global\advance\d_pack_positioning_y_dimension\d_pack_positioning_y_offset \egroup - \vbox to \positioningydimension - {\vskip\positioningyoffset - \hbox to \positioningxdimension - {\hskip\positioningxoffset - \box\positioningbox + \vbox to \d_pack_positioning_y_dimension + {\vskip\d_pack_positioning_y_offset + \hbox to \d_pack_positioning_x_dimension + {\hskip\d_pack_positioning_x_offset + \box\b_pack_positioning \hfill} \vfill}% \egroup} -\def\resetpositioning - {\let\@@psstate \v!start - \let\@@psunit \s!cm - \let\@@psfactor \plusone - \let\@@psscale \plusone - \def\@@psxfactor{\@@psfactor}% - \def\@@psyfactor{\@@psfactor}% - \def\@@psxscale {\@@psscale}% - \def\@@psyscale {\@@psscale}% - \let\@@psxstep \v!absolute - \let\@@psystep \v!absolute - \let\@@psxoffset \zeropoint - \let\@@psyoffset \zeropoint} - -\resetpositioning - -\unexpanded\def\setuppositioning - {\resetpositioning - \dodoubleargument\getparameters[\??ps]} - -\def\calculateposition#1#2#3#4#5#6#7#8#9% - {\setdimensionwithunit\scratchdimen{#1}\@@psunit +\unexpanded\def\pack_positioning_calculate#1#2#3#4#5#6#7#8#9% + {\setdimensionwithunit\scratchdimen{#1}{\positioningparameter\c!unit}% \scratchdimen#8\scratchdimen \scratchdimen#9\scratchdimen \advance\scratchdimen #4\relax @@ -90,47 +107,58 @@ {\advance\scratchdimen#3% \let#4\zeropoint}% #3\scratchdimen - \doifnot\@@psstate\v!overlay + \doifnot{\positioningparameter\c!state}\v!overlay {\scratchdimen\dimexpr#5+#3\relax \ifdim #3<-#7\relax \global#7-#3\relax \fi \ifdim\scratchdimen> #6\relax \global#6\scratchdimen\fi}} -\def\position - {\dosingleempty\doposition} +\unexpanded\def\position + {\bgroup + \dosingleempty\pack_positioning_position} -\def\doposition[#1]#2(#3,#4)% - {\removeunwantedspaces - \dowithnextbox{\dodoposition{#1}{#2}{#3}{#4}}\hbox} +\def\pack_positioning_position[#1]#2(#3,#4)% + {\iffirstargument + \setupcurrentpositioning[#1]% + \fi + \removeunwantedspaces + \dowithnextbox{\pack_positioning_position_indeed{#3}{#4}}\hbox} -\def\dodoposition#1#2#3#4% - {\bgroup - \dontcomplain - \getparameters[\??ps][#1]% - \calculateposition{#3}\@@psxstep\positioningxposition\@@psxoffset\nextboxwd \positioningxdimension\positioningxoffset\@@psxscale\@@psxfactor - \calculateposition{#4}\@@psystep\positioningyposition\@@psyoffset\nextboxhtdp\positioningydimension\positioningyoffset\@@psyscale\@@psyfactor +\def\pack_positioning_position_indeed#1#2% + {\dontcomplain + \normalexpanded + {\pack_positioning_calculate + {#1}% + {\positioningparameter\c!xstep}% + \d_pack_positioning_x_position + {\positioningparameter\c!xoffset}% + {\wd\nextbox}% + \d_pack_positioning_x_dimension + \d_pack_positioning_x_offset + {\positioningparameter\c!xscale}% + {\positioningparameter\c!xfactor}% + \pack_positioning_calculate + {#2}% + {\positioningparameter\c!ystep}% + \d_pack_positioning_y_position + {\positioningparameter\c!yoffset}% + {\htdp\nextbox}% + \d_pack_positioning_y_dimension + \d_pack_positioning_y_offset + {\positioningparameter\c!yscale}% + {\positioningparameter\c!yfactor}}% \vbox to \zeropoint - {\vskip\positioningyposition + {\vskip\d_pack_positioning_y_position \hbox to \zeropoint - {\hskip\positioningxposition - \flushnextbox + {\hskip\d_pack_positioning_x_position + \box\nextbox \hss} \vss}% \normalexpanded {\egroup - \positioningxposition\the\positioningxposition - \positioningyposition\the\positioningyposition - \def\noexpand\@@psxoffset{\the\dimexpr\@@psxoffset}% - \def\noexpand\@@psyoffset{\the\dimexpr\@@psyoffset}}% + \d_pack_positioning_x_position\the\d_pack_positioning_x_position + \d_pack_positioning_y_position\the\d_pack_positioning_y_position + \setexpandedpositioningparameter\c!xoffset{\the\dimexpr\positioningparameter\c!xoffset}% + \setexpandedpositioningparameter\c!yoffset{\the\dimexpr\positioningparameter\c!yoffset}}% \ignorespaces} -\setuppositioning - [\c!unit=\s!cm, - \c!factor=\plusone, - \c!scale=\plusone, - \c!xstep=\v!absolute, - \c!ystep=\v!absolute, - \c!offset=\v!yes, - \c!xoffset=\zeropoint, - \c!yoffset=\zeropoint] - \protect \endinput diff --git a/tex/context/base/page-col.mkiv b/tex/context/base/page-col.mkiv index 50a05d351..87591e336 100644 --- a/tex/context/base/page-col.mkiv +++ b/tex/context/base/page-col.mkiv @@ -13,7 +13,7 @@ \writestatus{loading}{ConTeXt Page Macros / Column Helpers} -%D Here we implement a coouple of helpers for dealing with +%D Here we implement a couple of helpers for dealing with %D columns. For the moment we keep the names. \unprotect diff --git a/tex/context/base/page-inf.mkiv b/tex/context/base/page-inf.mkiv index 6c220fb31..acfbf26f6 100644 --- a/tex/context/base/page-inf.mkiv +++ b/tex/context/base/page-inf.mkiv @@ -24,7 +24,7 @@ \let\currentversioninfo\empty -\def\setupversion +\unexpanded\def\setupversion {\dosingleargument\page_info_setup} \let\version\setupversion @@ -52,7 +52,7 @@ {\csname\??layoutinfo#1\endcsname} \installversioninfo\v!concept - {\vskip\!!sixpoint + {\vskip6\points \hbox to \makeupwidth {\infofont \v!concept:\space\currentdate @@ -60,7 +60,7 @@ \page_adapts_status_info}} \installversioninfo\v!file - {\vskip\!!sixpoint + {\vskip6\points \hbox to \makeupwidth {\infofont \getmessage\m!system{27}:\space\currentdate\space diff --git a/tex/context/base/page-par.mkiv b/tex/context/base/page-par.mkiv index 26e306ef5..868cdec51 100644 --- a/tex/context/base/page-par.mkiv +++ b/tex/context/base/page-par.mkiv @@ -15,49 +15,59 @@ \unprotect -\newcount\internalparagraphnumber - -\unexpanded\def\setupparagraphnumbering - {\dosingleempty\dosetupparagraphnumbering} - -\def\dosetupparagraphnumbering[#1]% - {\getparameters - [\??ph][#1]% - \processaction - [\@@phstate] - [\v!start=>\let\showparagraphnumber\doshowparagraphnumberA, - \v!stop=>\let\showparagraphnumber\relax, - \v!line=>\let\showparagraphnumber\doshowparagraphnumberB, - \v!reset=>\global\internalparagraphnumber\zerocount - \let\showparagraphnumber\doshowparagraphnumberA]} - -\def\dodoshowparagraphnumber - {\global\advance\internalparagraphnumber \plusone - \inleftmargin % \tf normalizes em - {\tf - \dousestyleparameter\@phstyle - \dousecolorparameter\@phcolor - \the\internalparagraphnumber - \kern\@@phdistance}} - -\def\doshowparagraphnumberA - {%\ifprocessingverbatim - % \iflinepar - % % obsolete: \dodoshowparagraphnumber - % \fi - %\else - \dodoshowparagraphnumber - }%\fi} - -\def\doshowparagraphnumberB +\installcorenamespace {paragraphnumbering} +\installcorenamespace {paragraphnumberingvariants} + +\installsimplecommandhandler \??paragraphnumbering {paragraphnumbering} \??paragraphnumbering + +\definecounter[\v!paragraph] + +\let\showparagraphnumber\relax + +\appendtoks + \page_par_check_state +\to \everysetupparagraphnumbering + +\unexpanded\def\page_par_check_state + {\rawprocesscommacommand[\paragraphnumberingparameter\c!state]\page_par_check_state_step} + +\def\page_par_check_state_step#1% + {\ifcsname\??paragraphnumberingvariants#1\endcsname + \csname\??paragraphnumberingvariants#1\endcsname + \fi} + +\setvalue{\??paragraphnumberingvariants\v!start}% + {\let\showparagraphnumber\page_par_show_number_normal} + +\setvalue{\??paragraphnumberingvariants\v!stop}% + {\let\showparagraphnumber\relax} + +\setvalue{\??paragraphnumberingvariants\v!line}% + {\let\showparagraphnumber\page_par_show_number_lines} + +\setvalue{\??paragraphnumberingvariants\v!reset}% + {\strc_counters_reset\v!paragraph + \let\showparagraphnumber\page_par_show_number_normal} + +\unexpanded\def\page_par_show_number_normal + {\strc_counters_increment\v!paragraph + \inleftmargin % todo: \c!location, only a few make sense + {\hfill % no complaints + \tf % \tf normalizes em + \useparagraphnumberingstyleandcolor\c!style\c!color + \convertedcounter[\v!paragraph]% + \kern\paragraphnumberingparameter\c!distance}} + +\unexpanded\def\page_par_show_number_lines {\ifnumberinglines - \doshowparagraphnumberA + \page_par_show_number_normal \fi} \setupparagraphnumbering [\c!state=\v!stop, - \c!style=, - \c!color=, - \c!distance=\ifcase\linenumberlocation2em\else\!!zeropoint\fi] % will change + %\c!location, + %\c!style=, + %\c!color=, + \c!distance=\ifcase\linenumberlocation2\emwidth\else\zeropoint\fi] % will change \protect \endinput diff --git a/tex/context/base/page-sel.mkiv b/tex/context/base/page-sel.mkiv index 1e706aa22..cfa9b3737 100644 --- a/tex/context/base/page-sel.mkiv +++ b/tex/context/base/page-sel.mkiv @@ -111,7 +111,7 @@ {\hsize\textwidth \scratchdimen\@@ipoffset \centeredbox - {\doifelse\@@ipmarking\v!on\cuthbox\hbox + {\doifelse\@@ipmarking\v!on\cuthbox\hbox % only place where cuthbox is used {\ifdim\scratchdimen>\zeropoint\relax \advance\vsize -2\scratchdimen \advance\hsize -2\scratchdimen diff --git a/tex/context/base/page-str.mkiv b/tex/context/base/page-str.mkiv index f14f2f716..47eb5e3bf 100644 --- a/tex/context/base/page-str.mkiv +++ b/tex/context/base/page-str.mkiv @@ -43,18 +43,18 @@ \page_otr_command_flush_side_floats \to \everyenableoutputstream -\def\initializeoutputstreams +\unexpanded\def\initializeoutputstreams {\ctxlua{streams.initialize()}% \glet\initializeoutputstreams\relax} -\def\enableoutputstream[#1]% could be \startoutputsubstream +\unexpanded\def\enableoutputstream[#1]% could be \startoutputsubstream {\initializeoutputstreams \the\everyenableoutputstream \inoutputstreamtrue \xdef\currentoutputstream{#1}% \ctxlua{streams.enable("#1")}} -\def\disableoutputstream +\unexpanded\def\disableoutputstream {\inoutputstreamfalse \global\let\currentoutputstream\s!default \ctxlua{streams.disable()}} @@ -73,11 +73,11 @@ \let\currentoutputsubstream\empty -\def\startoutputsubstream[#1]% +\unexpanded\def\startoutputsubstream[#1]% just push/pop instead {\glet\savedcurrentoutputstream\currentoutputstream \enableoutputstream[#1]} -\def\stopoutputsubstream +\unexpanded\def\stopoutputsubstream {\glet\currentoutputstream\savedcurrentoutputstream \enableoutputstream[\savedcurrentoutputstream]} @@ -89,7 +89,8 @@ \def\synchronizestreams [#1]{\ctxlua{streams.synchronize("#1")}} \def\dopushoutputstream [#1]{\ctxlua{streams.push("#1")}} -\def\pushoutputstream {\dosingleempty\dopushoutputstream} +\unexpanded\def\pushoutputstream + {\dosingleempty\dopushoutputstream} % \unexpanded\def\defineoutputstream[#1]% % {\doifundefined{otrs:#1}{\expandafter\newbox\csname otrs:#1\endcsname}} @@ -103,13 +104,15 @@ % \directsetup{stream:\firstoutputstream:bottom} % \directsetup{stream:\firstoutputstream:reset} -%D Obsolete in \MKIV: - -\unexpanded\def\definemarknote {\dodoubleempty\dodefinemarknote} -\def\dodefinemarknote[#1][#2]{} -\def\setmarknote [#1]{\gobbleoneargument} -\def\flushmarknotes [#1]{} -\def\erasemarknotes [#1]{} +% Obsolete in \MKIV: +% +% \unexpanded\def\definemarknote +% {\dodoubleempty\dodefinemarknote} +% +% \def\dodefinemarknote[#1][#2]{} +% \def\setmarknote [#1]{\gobbleoneargument} +% \def\flushmarknotes [#1]{} +% \def\erasemarknotes [#1]{} \protect \endinput diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 6e6ab9c07..0a7e12e4e 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 9690b7ed0..7483bbd83 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua index f6096863e..6d5ba34f7 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -232,9 +232,9 @@ return { comment = "needs integration and configuration", }, { - filename = "node-par", + filename = "typo-bld", marktype = "mkiv", - status = "experimental", + status = "okay", }, { filename = "back-ini", @@ -415,9 +415,9 @@ return { status = "okay", }, { - filename = "trac-vis", + filename = "pack-cut", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "lang-mis", @@ -644,7 +644,8 @@ return { { filename = "pack-obj", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "will change when we have objects at lua end", }, { filename = "strc-itm", @@ -717,7 +718,8 @@ return { { filename = "page-inf", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "room for improvement and extension", }, { filename = "page-grd", @@ -799,7 +801,7 @@ return { { filename = "pack-pos", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "page-mak", @@ -814,7 +816,8 @@ return { { filename = "page-par", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "might get extended", }, { filename = "typo-pag", @@ -1204,7 +1207,7 @@ return { { filename = "page-mrk", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "page-flw", @@ -1354,9 +1357,10 @@ return { comment = "maybe some cleanup is needed", }, { - filename = "node-spl", + filename = "font-sol", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "needs testing", }, { filename = "strc-not", @@ -1412,7 +1416,7 @@ return { { filename = "pack-bar", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "page-app", diff --git a/tex/context/base/status-mkiv.tex b/tex/context/base/status-mkiv.tex index 0d22d51a1..e9b12b130 100644 --- a/tex/context/base/status-mkiv.tex +++ b/tex/context/base/status-mkiv.tex @@ -1,4 +1,4 @@ - \setupbodyfont[dejavu,10pt] +\setupbodyfont[dejavu,10pt] \setuplayout [width=middle, @@ -17,7 +17,7 @@ [location=] \setupheadertexts - [\currentdate][MkIV cleanup Status / Page \pagenumber] + [\currentdate][MkIV Cleanup Status / Page \pagenumber] \starttext diff --git a/tex/context/base/trac-vis.mkiv b/tex/context/base/trac-vis.mkiv deleted file mode 100644 index e906bb50d..000000000 --- a/tex/context/base/trac-vis.mkiv +++ /dev/null @@ -1,721 +0,0 @@ -%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 ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -%D This module 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\plustenthousand - \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. - -\newdimen\tractempwidth -\newdimen\tractempheight -\newdimen\tractempdepth - -\def \cutmarklength {2\bodyfontsize} - -\newcount\horizontalcutmarks \horizontalcutmarks = 2 -\newcount\verticalcutmarks \verticalcutmarks = 2 -\newcount\cutmarkoffset \cutmarkoffset = 1 - -\let \cutmarksymbol \relax -\let \cutmarktoptext \empty -\let \cutmarkbottomtext \empty -\let \cutmarkhoffset \empty -\let \cutmarkvoffset \empty - -\def\horizontalcuts - {\normalhbox to \tractempwidth - {\dorecurse\horizontalcutmarks{\vrule\!!width\boxrulewidth\!!height\cutmarklength\normalhfill}% - \unskip}} - -\def\verticalcuts - {\normalvbox to \dimexpr\tractempheight+\tractempdepth\relax - {\hsize\cutmarklength - \dorecurse\verticalcutmarks{\vrule\!!height\boxrulewidth\!!width\hsize\normalvfill}% - \unskip}} - -\def\baselinecuts - {\ifdim\tractempdepth>\zeropoint - \normalvbox to \dimexpr\tractempheight+\tractempdepth\relax - {\hsize\dimexpr\cutmarklength/2\relax - \normalvskip\zeropoint\!!plus\tractempheight - \vrule\!!height\boxrulewidth\!!width\hsize - \normalvskip\zeropoint\!!plus\tractempdepth}% - \fi} - -\def\cutmarksymbols#1% - {\normalhbox to \tractempwidth - {\setbox\scratchbox\normalhbox to \cutmarklength - {\normalhss\infofont\cutmarksymbol\normalhss}% - \normalhss - \normalvbox to \cutmarklength - {\scratchdimen\dimexpr\cutmarklength/2\relax - \scratchskip \ifx\cutmarkhoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkhoffset\fi - \normalvss - \hbox to \tractempwidth - {\llap{\copy\scratchbox\normalhskip\scratchskip}% - \normalhskip\scratchdimen\hss\infofont#1\hss\normalhskip\scratchdimen - \rlap{\normalhskip\scratchskip\copy\scratchbox}}% - \normalvss}% - \normalhss}} - -\def\makecutbox#1% simplier with layers, todo - {\tractempheight\ht#1% - \tractempdepth \dp#1% - \tractempwidth \wd#1% - \setbox#1\normalhbox - {\dontcomplain - \forgetall - \boxmaxdepth\maxdimen - \offinterlineskip - \scratchdimen\dimexpr\cutmarklength/2\relax - \hsize\tractempwidth - \setbox\scratchbox\normalvbox - {\setbox\scratchbox\normalhbox{\horizontalcuts}% - \scratchskip\ifx\cutmarkvoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi -% \normalvskip\dimexpr-\scratchskip-2\scratchdimen\relax -% \copy\scratchbox -% \normalvskip\scratchskip - \tlap{\copy\scratchbox\normalvskip\scratchskip}% - \hbox to \tractempwidth - {\scratchskip\ifx\cutmarkhoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkhoffset\fi - \setbox\scratchbox\normalhbox{\verticalcuts}% - \llap{\copy\scratchbox\normalhskip\scratchskip}% - \ifdim\tractempdepth=\zeropoint - \normalhfill - \else - \bgroup - \setbox\scratchbox\normalhbox{\baselinecuts}% - \llap{\copy\scratchbox\normalhskip\scratchskip}% - \normalhfill - \rlap{\normalhskip\scratchskip\copy\scratchbox}% - \egroup - \fi - \rlap{\normalhskip\scratchskip\copy\scratchbox}}% -% \normalvskip\scratchskip -% \copy\scratchbox}% - \blap{\normalvskip\scratchskip\copy\scratchbox}}% - \ht\scratchbox\tractempheight - \dp\scratchbox\tractempdepth - \wd\scratchbox\zeropoint - \startcolor[\defaulttextcolor]% - \box\scratchbox - \ifx\cutmarksymbol\relax \else - \setbox\scratchbox\normalvbox - {\scratchskip\ifx\cutmarkvoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi - \vskip-\scratchskip - \vskip-\cutmarklength - \normalhbox{\cutmarksymbols\cutmarktoptext}% - \vskip\scratchskip - \vskip\tractempheight - \vskip\tractempdepth - \vskip\scratchskip - \normalhbox{\cutmarksymbols\cutmarkbottomtext}}% - \ht\scratchbox\tractempheight - \dp\scratchbox\tractempdepth - \wd\scratchbox\zeropoint - \box\scratchbox - \fi - \stopcolor - \box#1}% - \wd#1\tractempwidth - \ht#1\tractempheight - \dp#1\tractempdepth} - -\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\dodocolorrangeA#1% - {\fastcolored[#1]{\hrule\!!width3em\!!height\scratchdimen\!!depth\zeropoint}} - -\def\docolorrangeA#1 #2 % - {\vbox - {\hsize3em % \scratchdimen - \ifcase#1\or - \dodocolorrangeA{c=#2}\or - \dodocolorrangeA{m=#2}\or - \dodocolorrangeA{y=#2}\or - \dodocolorrangeA{m=#2,y=#2}\or - \dodocolorrangeA{c=#2,y=#2}\or - \dodocolorrangeA{c=#2,m=#2}\fi - \ifdim\scratchdimen>1ex - \vskip-\scratchdimen - \vbox to \scratchdimen - {\vss\hbox to 3em{\hss#2\hss}\vss}% - \fi}} - -\def\colorrangeA#1% - {\vbox - {\startcolor[\s!white]% - \scratchdimen\dimexpr(-\colormarklength*4+\tractempheight+\tractempdepth)/21\relax - \offinterlineskip - \docolorrangeA #1 1.00 \docolorrangeA #1 0.95 - \docolorrangeA #1 0.75 - \docolorrangeA #1 0.50 - \docolorrangeA #1 0.25 \docolorrangeA #1 0.05 - \docolorrangeA #1 0.00 - \stopcolor}} - -\def\docolorrangeB #1 #2 #3 #4 #5 % - {\fastcolored - [\c!c=#2,\c!m=#3,\c!y=#4,\c!k=#5] - {\vrule\!!width\scratchdimen\!!height\colormarklength\!!depth\zeropoint}% - \ifdim\scratchdimen>2em - \hskip-\scratchdimen - \vbox to \colormarklength - {\vss\hbox to \scratchdimen{\hss#1\hss}\vss}% - \fi} - -\def\colorrangeB - {\hbox - {\startcolor[\s!white]% - \scratchdimen\dimexpr(-\colormarklength*\plustwo+\tractempwidth)/11\relax - \docolorrangeB .5~C .5 0 0 0 - \docolorrangeB .5~M 0 .5 0 0 - \docolorrangeB .5~Y 0 0 .5 0 - \docolorrangeB .5~K 0 0 0 .5 - \docolorrangeB C 1 0 0 0 - \docolorrangeB G 1 0 1 0 - \docolorrangeB Y 0 0 1 0 - \docolorrangeB R 0 1 1 0 - \docolorrangeB M 0 1 0 0 - \docolorrangeB B 1 1 0 0 - \docolorrangeB K 0 0 0 1 - \stopcolor}} - -\def\docolorrangeC#1 % - {\fastcolored - [\c!s=#1]% - {\vrule\!!width\scratchdimen\!!height\colormarklength\!!depth\zeropoint}% - \ifdim\scratchdimen>2em - \hskip-\scratchdimen - \vbox to \colormarklength - {\vss\hbox to \scratchdimen{\hss#1\hss}\vss}% - \fi} - -\def\colorrangeC - {\hbox - {\startcolor[\s!white]% - \scratchdimen\dimexpr(-\colormarklength*2+\tractempwidth)/14\relax - \docolorrangeC 1 \docolorrangeC .95 - \docolorrangeC .9 \docolorrangeC .85 - \docolorrangeC .8 \docolorrangeC .75 - \docolorrangeC .7 - \docolorrangeC .6 - \docolorrangeC .5 - \docolorrangeC .4 - \docolorrangeC .3 - \docolorrangeC .2 - \docolorrangeC .1 - \docolorrangeC 0 - \stopcolor}} - -\def\docolormarkbox#1#2% - {\tractempheight\ht#2% - \tractempdepth \dp#2% - \tractempwidth \wd#2% - \setbox#2\hbox - {\scratchdimen\dimexpr\colormarklength/2\relax - \forgetall - \ssxx - \setbox\scratchbox\vbox - {\offinterlineskip - \vskip\dimexpr-\colormarkoffset\scratchdimen-2\scratchdimen\relax - \ifcase#1\relax - \vskip\dimexpr\colormarklength+\scratchdimen+\tractempheight\relax - \else - \hbox to \tractempwidth{\hss\hbox{\colorrangeB}\hss}% - \vskip\colormarkoffset\scratchdimen - \vbox to \tractempheight - {\vss - \hbox to \tractempwidth - {\llap{\colorrangeA1\hskip\colormarkoffset\scratchdimen}\hfill - \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA4}}% - \vss - \hbox to \tractempwidth - {\llap{\colorrangeA2\hskip\colormarkoffset\scratchdimen}\hfill - \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA5}}% - \vss - \hbox to \tractempwidth - {\llap{\colorrangeA3\hskip\colormarkoffset\scratchdimen}\hfill - \rlap{\hskip\colormarkoffset\scratchdimen\colorrangeA6}}% - \vss}% - \fi - \vskip\colormarkoffset\scratchdimen - \hbox to \tractempwidth - {\hss\lower\tractempdepth\hbox{\colorrangeC}\hss}}% - \ht\scratchbox\tractempheight - \dp\scratchbox\tractempdepth - \wd\scratchbox\zeropoint - \box\scratchbox - \box#2}% - \wd#2\tractempwidth - \ht#2\tractempheight - \dp#2\tractempdepth} - -\def\colormarkbox {\docolormarkbox\plusone } % #1 -\def\rastermarkbox{\docolormarkbox\zerocount} % #1 - -%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 - \colored[r=#1,g=#2,b=#3]{#5}% temp hack - \else - \colored[s=0]{#5}% temp hack - \fi}% - \setbox\scratchbox\hbox - {\ifdone - \colored[r=#1,g=#2,b=#3]{\vrule\!!width\wd\scratchbox}% temp hack - \else - \colored[s=0]{\vrule\!!width\wd\scratchbox}% temp hack - \fi - \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-bld.lua b/tex/context/base/typo-bld.lua new file mode 100644 index 000000000..87d280541 --- /dev/null +++ b/tex/context/base/typo-bld.lua @@ -0,0 +1,186 @@ +if not modules then modules = { } end modules ['typo-bld'] = { -- was node-par + version = 1.001, + comment = "companion to typo-bld.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local insert, remove = table.insert, table.remove + +local builders, nodes, node = builders, nodes, node + +builders.paragraphs = builders.paragraphs or { } +local parbuilders = builders.paragraphs + +parbuilders.constructors = parbuilders.constructors or { } +local constructors = parbuilders.constructors + +constructors.names = constructors.names or { } +local names = constructors.names + +constructors.numbers = constructors.numbers or { } +local numbers = constructors.numbers + +constructors.methods = constructors.methods or { } +local methods = constructors.methods + +local a_parbuilder = attributes.numbers['parbuilder'] or 999 -- why 999 +constructors.attribute = a_parbuilder + +local unsetvalue = attributes.unsetvalue +local texsetattribute = tex.setattribute +local has_attribute = node.has_attribute +local texnest = tex.nest + +local nodepool = nodes.pool +local new_baselineskip = nodepool.baselineskip +local new_lineskip = nodepool.lineskip +local insert_node_before = node.insert_before +local hpack_node = node.hpack + +local starttiming = statistics.starttiming +local stoptiming = statistics.stoptiming + +storage.register("builders/paragraphs/constructors/names", names, "builders.paragraphs.constructors.names") +storage.register("builders/paragraphs/constructors/numbers", numbers, "builders.paragraphs.constructors.numbers") + +local report_parbuilders = logs.reporter("parbuilders") + +local mainconstructor = nil -- not stored in format +local nofconstructors = 0 +local stack = { } + +function constructors.define(name) + nofconstructors = nofconstructors + 1 + names[nofconstructors] = name + numbers[name] = nofconstructors +end + +function constructors.set(name) --- will go + if name then + mainconstructor = numbers[name] or unsetvalue + else + mainconstructor = stack[#stack] or unsetvalue + end + texsetattribute(a_parbuilder,mainconstructor) + if mainconstructor ~= unsetvalue then + constructors.enable() + end +end + +function constructors.start(name) + local number = numbers[name] + insert(stack,number) + mainconstructor = number or unsetvalue + texsetattribute(a_parbuilder,mainconstructor) + if mainconstructor ~= unsetvalue then + constructors.enable() + end +-- report_parbuilders("start %s",name) +end + +function constructors.stop() + remove(stack) + mainconstructor = stack[#stack] or unsetvalue + texsetattribute(a_parbuilder,mainconstructor) + if mainconstructor == unsetvalue then + constructors.disable() + end +-- report_parbuilders("stop") +end + +-- return values: +-- +-- true : tex will break itself +-- false : idem but dangerous +-- head : list of valid vmode nodes with last being hlist + +function constructors.handler(head,followed_by_display) + if type(head) == "boolean" then + return head + else + local attribute = has_attribute(head,a_parbuilder) -- or mainconstructor + if attribute then + local method = names[attribute] + if method then + local handler = methods[method] + if handler then + return handler(head,followed_by_display) + else + report_parbuilders("contructor method '%s' is not defined",tostring(method)) + return true -- let tex break + end + end + end + return true -- let tex break + end +end + +-- just for testing + +function constructors.methods.default(head,followed_by_display) + return true -- let tex break +end + +-- also for testing (now also surrounding spacing done) + +function builders.paragraphs.constructors.methods.oneline(head,followed_by_display) + -- when needed we will turn this into a helper + local t = texnest[texnest.ptr] + local h = hpack_node(head) + local d = tex.baselineskip.width - t.prevdepth - h.height + t.prevdepth = h.depth + t.prevgraf = 1 + if d < tex.lineskiplimit then + return insert_node_before(h,h,new_lineskip(tex.lineskip)) + else + return insert_node_before(h,h,new_baselineskip(d)) + end +end + +-- It makes no sense to have a sequence here as we already have +-- pre and post hooks and only one parbuilder makes sense, so no: +-- +-- local actions = nodes.tasks.actions("parbuilders") +-- +-- yet ... maybe some day. + +local actions = constructors.handler +local enabled = false + +local function processor(head,followed_by_display) + -- todo: not again in otr so we need to flag + if enabled then + starttiming(parbuilders) + local head = actions(head,followed_by_display) + stoptiming(parbuilders) + return head + else + return true -- let tex do the work + end +end + +function constructors.enable() + enabled = true +end + +function constructors.disable() + enabled = false +end + + +callbacks.register('linebreak_filter', processor, "breaking paragraps into lines") + +statistics.register("linebreak processing time", function() + return statistics.elapsedseconds(parbuilders) +end) + +-- interface + +commands.defineparbuilder = constructors.define +commands.startparbuilder = constructors.start +commands.stopparbuilder = constructors.stop +commands.setparbuilder = constructors.set +commands.enableparbuilder = constructors.enable +commands.disableparbuilder = constructors.disable diff --git a/tex/context/base/typo-bld.mkiv b/tex/context/base/typo-bld.mkiv new file mode 100644 index 000000000..10502005b --- /dev/null +++ b/tex/context/base/typo-bld.mkiv @@ -0,0 +1,64 @@ +%D \module +%D [ file=typo-bld, % was node-par, +%D version=2008.09.30, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Paragraph Building, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Node Macros / Paragraph Building} + +%D This is very experimental, undocumented, subjected to changes, etc. just as +%D the underlying interfaces. But at least it's cleaned as part of the status-mkiv +%D cleanup. + +% \startparbuilder[default] +% \input tufte \par +% \startparbuilder[oneline] +% \input tufte \par +% \stopparbuilder +% \input tufte \par +% \stopparbuilder +% +% \startparbuilder[oneline] +% \dorecurse{100}{\input ward \par} +% \stopparbuilder + +\unprotect + +\registerctxluafile{typo-bld}{1.001} + +\definesystemattribute[parbuilder][public] + +\installcorenamespace {parbuilder} + +\unexpanded\def\defineparbuilder[#1]% + {\ctxcommand{defineparbuilder("#1")}} + +\unexpanded\def\startparbuilder[#1]% + {\ifhmode\par\fi + \ctxcommand{startparbuilder("#1")}} + +\unexpanded\def\stopparbuilder + {\ifhmode\par\fi + \ctxcommand{stopparbuilder()}} + +\unexpanded\def\setmainparbuilder[#1]% + {\ctxcommand{setparbuilder("#1")}} + +% no high level interface, after all implementing a linebreaker is not something that +% the average user will do + +\defineparbuilder[default] % just for testing +\defineparbuilder[oneline] % just for testing +\defineparbuilder[basic] % just for testing + +\def\enableparbuilders {\ctxcommand{enableparbuilder()}} % hooks in otr so we need to pickup +\def\disableparbuilders{\ctxcommand{disableparbuilder()}} % hooks in otr so we need to pickup + +\protect \endinput diff --git a/tex/context/interface/keys-cs.xml b/tex/context/interface/keys-cs.xml index 7feb615ef..2499ad8db 100644 --- a/tex/context/interface/keys-cs.xml +++ b/tex/context/interface/keys-cs.xml @@ -779,6 +779,7 @@ + @@ -817,6 +818,7 @@ + @@ -979,6 +981,7 @@ + diff --git a/tex/context/interface/keys-de.xml b/tex/context/interface/keys-de.xml index 0c985f851..5ba370a6d 100644 --- a/tex/context/interface/keys-de.xml +++ b/tex/context/interface/keys-de.xml @@ -779,6 +779,7 @@ + @@ -817,6 +818,7 @@ + @@ -979,6 +981,7 @@ + diff --git a/tex/context/interface/keys-en.xml b/tex/context/interface/keys-en.xml index ab43723d1..fa765aa54 100644 --- a/tex/context/interface/keys-en.xml +++ b/tex/context/interface/keys-en.xml @@ -779,6 +779,7 @@ + @@ -817,6 +818,7 @@ + @@ -979,6 +981,7 @@ + diff --git a/tex/context/interface/keys-fr.xml b/tex/context/interface/keys-fr.xml index c98e6a367..b668bd35c 100644 --- a/tex/context/interface/keys-fr.xml +++ b/tex/context/interface/keys-fr.xml @@ -779,6 +779,7 @@ + @@ -817,6 +818,7 @@ + @@ -979,6 +981,7 @@ + diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml index 08a7d7947..df260ffa4 100644 --- a/tex/context/interface/keys-it.xml +++ b/tex/context/interface/keys-it.xml @@ -779,6 +779,7 @@ + @@ -817,6 +818,7 @@ + @@ -979,6 +981,7 @@ + diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml index 6d9852258..5dd2f83dd 100644 --- a/tex/context/interface/keys-nl.xml +++ b/tex/context/interface/keys-nl.xml @@ -779,6 +779,7 @@ + @@ -817,6 +818,7 @@ + @@ -979,6 +981,7 @@ + diff --git a/tex/context/interface/keys-pe.xml b/tex/context/interface/keys-pe.xml index 232f3ce59..2128680e7 100644 --- a/tex/context/interface/keys-pe.xml +++ b/tex/context/interface/keys-pe.xml @@ -779,6 +779,7 @@ + @@ -817,6 +818,7 @@ + @@ -979,6 +981,7 @@ + diff --git a/tex/context/interface/keys-ro.xml b/tex/context/interface/keys-ro.xml index 6368aede6..915a0c226 100644 --- a/tex/context/interface/keys-ro.xml +++ b/tex/context/interface/keys-ro.xml @@ -779,6 +779,7 @@ + @@ -817,6 +818,7 @@ + @@ -979,6 +981,7 @@ + diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index b4f6f63d0..f3f55bd5a 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 06/12/12 09:56:51 +-- merge date : 06/13/12 09:57:33 do -- begin closure to overcome local limits and interference -- cgit v1.2.3