diff options
30 files changed, 245 insertions, 146 deletions
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 1e5b4059c..853ce38de 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", "startdocument", "stopdocument", "documentvariable", "startmodule", "stopmodule", "usemodule", "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", "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "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", "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", "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", "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "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", "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/lexers/scite-context-lexer-lua.lua b/context/data/scite/lexers/scite-context-lexer-lua.lua index 4f48fb2a5..0ace7afc6 100644 --- a/context/data/scite/lexers/scite-context-lexer-lua.lua +++ b/context/data/scite/lexers/scite-context-lexer-lua.lua @@ -142,7 +142,7 @@ local identifier = token("default",validword) ----- operator = token("special", P('..') + P('~=') + S('+-*/%^#=<>;:,.{}[]()')) -- maybe split off {}[]() ----- operator = token("special", S('+-*/%^#=<>;:,{}[]()') + P('..') + P('.') + P('~=') ) -- maybe split off {}[]() -local operator = token("special", S('+-*/%^#=<>;:,{}[]().') + P('~=') ) +local operator = token("special", S('+-*/%^#=<>;:,{}[]().') + P('~=') ) -- no ^1 because of nested lexers local structure = token("special", S('{}[]()')) diff --git a/context/data/scite/lexers/scite-context-lexer-pdf-object.lua b/context/data/scite/lexers/scite-context-lexer-pdf-object.lua index 3694b24d8..b1d87e080 100644 --- a/context/data/scite/lexers/scite-context-lexer-pdf-object.lua +++ b/context/data/scite/lexers/scite-context-lexer-pdf-object.lua @@ -60,9 +60,12 @@ local whatsit = token("quote", langle) local keyword = token("command", name) local constant = token("constant", name) local number = token('number', real) -local reference = token("number", cardinal) +-- local reference = token("number", cardinal) +-- * t_spacing +-- * token("number", cardinal) +local reference = token("warning", cardinal) * t_spacing - * token("number", cardinal) + * token("warning", cardinal) * t_spacing * token("keyword", p_reference) local t_comment = token("comment", p_comment) @@ -92,9 +95,10 @@ local t_dictionary = { "dictionary", } local t_object = { "object", -- weird that we need to catch the end here (probably otherwise an invalid lpeg) - object = t_spaces * (V("dictionary") * t_spaces * t_stream^-1 + V("array") + t_spaces) * t_spaces * t_closeobject, + object = t_spaces * (V("dictionary") * t_spaces * t_stream^-1 + V("array") + V("number") + t_spaces) * t_spaces * t_closeobject, dictionary = t_opendictionary * (t_spaces * keyword * t_spaces * V("whatever"))^0 * t_spaces * t_closedictionary, array = t_openarray * (t_spaces * V("whatever"))^0 * t_spaces * t_closearray, + number = number, whatever = V("dictionary") + V("array") + constant + reference + string + unicode + number + whatsit, } diff --git a/context/data/scite/lexers/scite-context-lexer-pdf-xref.lua b/context/data/scite/lexers/scite-context-lexer-pdf-xref.lua index 827926185..f205e9130 100644 --- a/context/data/scite/lexers/scite-context-lexer-pdf-xref.lua +++ b/context/data/scite/lexers/scite-context-lexer-pdf-xref.lua @@ -8,7 +8,12 @@ local info = { local lexer = lexer local token = lexer.token -local P = lpeg.P +local P, R = lpeg.P, lpeg.R + +-- xref +-- cardinal cardinal [character] +-- .. +-- %%EOF | startxref | trailer local pdfxreflexer = { _NAME = "pdf-xref", _FILENAME = "scite-context-lexer-pdf-xref" } local whitespace = lexer.WHITESPACE -- triggers states @@ -23,10 +28,18 @@ local t_spacing = token(whitespace, spacing) local p_trailer = P("trailer") -local t_xref = token("default", (1-p_trailer)^1) - * token("keyword", p_trailer) +local t_number = token("number", R("09")^1) + * t_spacing + * token("number", R("09")^1) * t_spacing - * pdfobjectlexer._shared.dictionary + * (token("keyword", R("az","AZ")) * t_spacing)^-1 + +local t_xref = t_number^1 + +-- local t_xref = token("default", (1-p_trailer)^1) +-- * token("keyword", p_trailer) +-- * t_spacing +-- * pdfobjectlexer._shared.dictionary pdfxreflexer._rules = { { 'whitespace', t_spacing }, diff --git a/context/data/scite/lexers/scite-context-lexer-pdf.lua b/context/data/scite/lexers/scite-context-lexer-pdf.lua index c89270c64..8687a5226 100644 --- a/context/data/scite/lexers/scite-context-lexer-pdf.lua +++ b/context/data/scite/lexers/scite-context-lexer-pdf.lua @@ -34,29 +34,48 @@ local p_obj = P("obj") local p_endobj = P("endobj") local p_xref = P("xref") local p_startxref = P("startxref") +local p_eof = P("%%EOF") +local p_trailer = P("trailer") local p_objectnumber = patterns.cardinal local p_comment = P('%') * restofline local t_comment = token("comment", p_comment) -local t_openobject = token("number", p_objectnumber) +-- local t_openobject = token("number", p_objectnumber) +-- * t_spacing +-- * token("number", p_objectnumber) +local t_openobject = token("warning", p_objectnumber) * t_spacing - * token("number", p_objectnumber) + * token("warning", p_objectnumber) * t_spacing * token("keyword", p_obj) * t_spacing^0 local t_closeobject = token("keyword", p_endobj) -local t_openxref = token("keyword", p_xref) -local t_closexref = token("keyword", p_startxref) +-- We could do clever xref parsing but why should we (i.e. we should check for +-- the xref body. As a pdf file is not edited, we could do without a nested +-- lexer anyway. + +local t_trailer = token("keyword", p_trailer) + * t_spacing + * pdfobjectlexer._shared.dictionary + +local t_openxref = token("plain", p_xref) +local t_closexref = token("plain", p_startxref) + + token("comment", p_eof) + + t_trailer +local t_startxref = token("plain", p_startxref) + * t_spacing + * token("number", R("09")^1) lexer.embed_lexer(pdflexer, pdfobjectlexer, t_openobject, t_closeobject) lexer.embed_lexer(pdflexer, pdfxreflexer, t_openxref, t_closexref) pdflexer._rules = { - { 'whitespace', t_spacing }, - { 'comment', t_comment }, - { 'rest', t_rest }, + { 'whitespace', t_spacing }, + { 'comment', t_comment }, + { 'xref', t_startxref }, + { 'rest', t_rest }, } pdflexer._tokenstyles = context.styleset diff --git a/context/data/scite/lexers/scite-context-lexer.lua b/context/data/scite/lexers/scite-context-lexer.lua index 457b855d2..1218d1f51 100644 --- a/context/data/scite/lexers/scite-context-lexer.lua +++ b/context/data/scite/lexers/scite-context-lexer.lua @@ -16,25 +16,13 @@ local info = { -- change in 3.03 is that no longer a script can be specified. This means that instead -- of loading the extensions via the properties file, we now need to load them in our -- own lexers, unless of course we replace lexer.lua completely (which adds another --- installation issue). The loading takes place with: --- --- if not lexer._CONTEXTEXTENSIONS then --- dofile(_LEXERHOME .. "/scite-context-lexer.lua") --- end --- --- So, where pre 3.03 we loaded that file and in that file the original lexing code, we --- now do the reverse. I also moved some helpers here because the new module structure --- hides some (now local) functions. +-- installation issue). -- -- Another change has been that _LEXERHOME is no longer available. It looks like more and -- more functionality gets dropped so maybe at some point we need to ship our own dll/so --- files. For instance, I'd like to have access to the current filename etc. --- --- An increase in the number of built in styles made our own crash (probably due to some --- maximum being reached) so some measures has been taken. We now get pretty close to --- replacing the main lexer.lua file. --- --- Also needed: preamble scan once. Can be handled in caller below and _M.preamble. +-- files. For instance, I'd like to have access to the current filename and other scite +-- properties. For instance, we could cache some info with each file, if only we had +-- knowledge of what file we're dealing with. -- -- For huge files folding can be pretty slow and I do have some large ones that I keep -- open all the time. Loading is normally no ussue, unless one has remembered the status @@ -42,16 +30,32 @@ local info = { -- brought down loading of char-def.lua from 14 sec => 8 sec. Replacing the word_match -- function and optimizing the lex function gained another 2+ seconds. A 6 second load -- is quite ok for me. - +-- +-- When the lexer path is copied to the textadept lexer path, and the theme definition to +-- theme path (as lexer.lua), the lexer works there as well. When I have time and motive +-- I will make a proper setup file to tune the look and feel a bit and associate suffixes +-- with the context lexer. The textadept editor has a nice style tracing option but lacks +-- the tabs for selecting files that scite has. It also has no integrated run that pipes +-- to the log pane (I wonder if it could borrow code from the console2 project). Interesting +-- is that the jit version of textadept crashes on lexing large files (and does not feel +-- faster either). +-- -- Function load(lexer_name) starts with _M.WHITESPACE = lexer_name..'_whitespace' which -- means that we need to have it frozen at the moment we load another lexer. Because spacing -- is used to revert to a parent lexer we need to make sure that we load children as late -- as possible in order not to get the wrong whitespace trigger. This took me quite a while -- to figure out (not being that familiar with the internals). The lex and fold functions --- have been optimized. It is a pitty that there is no proper print available. - --- Maybe it's safer to copy the other methods here so that we have no dependencies, apart --- from the c library. We need to copy anyway as helpers are local +-- have been optimized. It is a pitty that there is no proper print available. Another thing +-- needed is a default style in ourown theme style definition, as otherwise we get wrong +-- nested lexers, especially if they are larger than a view. This is the hardest part of +-- getting things right. +-- +-- Eventually it might be safer to copy the other methods from lexer.lua here as well so +-- that we have no dependencies, apart from the c library (for which at some point the api +-- will be stable I guess). +-- +-- It's a pitty that there is no scintilua library for the OSX version of scite. Even +-- better would be to have scintilua as integral part of scite. local lpeg = require 'lpeg' diff --git a/context/data/scite/scite-context-data-context.properties b/context/data/scite/scite-context-data-context.properties index b5a4d1b1f..e2c1bb853 100644 --- a/context/data/scite/scite-context-data-context.properties +++ b/context/data/scite/scite-context-data-context.properties @@ -38,36 +38,36 @@ doifvaluenothing doifvaluesomething doifelsevaluenothing doifdimensionelse doifn doifcommonelse doifcommon doifnotcommon doifinstring doifnotinstring \ doifinstringelse doifassignmentelse tracingall tracingnone loggingall \ appendtoks prependtoks appendtotoks prependtotoks to \ -endgraf empty null space 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 \ -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 +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 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/context/data/scite/scite-ctx.lua b/context/data/scite/scite-ctx.lua index 9f3526dc3..3557994f3 100644 --- a/context/data/scite/scite-ctx.lua +++ b/context/data/scite/scite-ctx.lua @@ -80,8 +80,6 @@ function traceln(str) io.flush() end --- require "lpeg" - function string.grab(str,delimiter) local list = { } for snippet in gmatch(str,delimiter) do @@ -518,7 +516,7 @@ local worddone = 0 -- end -- end -function check_text() +function check_text() -- obsolete, replaced by lexer local dlanguage = props["ctx.spellcheck.language"] local dwordsize = props["ctx.spellcheck.wordsize"] @@ -838,3 +836,15 @@ menufunctions[14] = process_template_two function open_log() scite.Open(props['FileName'] .. ".log") end + +if not lpeg then + + local okay, root = pcall(function() return require "lpeg" end) + + if okay then + lpeg = root + else + trace("\nwarning: lpeg not loaded\n") + end + +end diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 8f098c1e3..41adb5d43 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -8607,6 +8607,7 @@ local lp_builtin = P ( P("element") / "(ll.ei or 1)" + P("index") / "(ll.ni or 1)" + P("match") / "(ll.mi or 1)" + + -- P("namespace") / "ll.ns" + P("ns") / "ll.ns" ) * ((spaces * P("(") * spaces * P(")"))/"") @@ -8630,11 +8631,11 @@ local lp_function = C(R("az","AZ","__")^1) * P("(") / function(t) -- todo: bett end end -local lparent = lpeg.P("(") -local rparent = lpeg.P(")") +local lparent = P("(") +local rparent = P(")") local noparent = 1 - (lparent+rparent) -local nested = lpeg.P{lparent * (noparent + lpeg.V(1))^0 * rparent} -local value = lpeg.P(lparent * lpeg.C((noparent + nested)^0) * rparent) -- lpeg.P{"("*C(((1-S("()"))+V(1))^0)*")"} +local nested = P{lparent * (noparent + V(1))^0 * rparent} +local value = P(lparent * C((noparent + nested)^0) * rparent) -- P{"("*C(((1-S("()"))+V(1))^0)*")"} local lp_child = Cc("expr.child(ll,'") * R("az","AZ","--","__")^1 * Cc("')") local lp_number = S("+-") * R("09")^1 @@ -8846,7 +8847,7 @@ local pathparser = Ct { "patterns", -- can be made a bit faster by moving some p expressions = expression / register_expression, letters = R("az")^1, - name = (1-lpeg.S("/[]()|:*!"))^1, -- make inline + name = (1-S("/[]()|:*!"))^1, -- make inline negate = P("!") * Cc(false), nodefunction = V("negate") + P("not") * Cc(false) + Cc(true), diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 8f098c1e3..41adb5d43 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -8607,6 +8607,7 @@ local lp_builtin = P ( P("element") / "(ll.ei or 1)" + P("index") / "(ll.ni or 1)" + P("match") / "(ll.mi or 1)" + + -- P("namespace") / "ll.ns" + P("ns") / "ll.ns" ) * ((spaces * P("(") * spaces * P(")"))/"") @@ -8630,11 +8631,11 @@ local lp_function = C(R("az","AZ","__")^1) * P("(") / function(t) -- todo: bett end end -local lparent = lpeg.P("(") -local rparent = lpeg.P(")") +local lparent = P("(") +local rparent = P(")") local noparent = 1 - (lparent+rparent) -local nested = lpeg.P{lparent * (noparent + lpeg.V(1))^0 * rparent} -local value = lpeg.P(lparent * lpeg.C((noparent + nested)^0) * rparent) -- lpeg.P{"("*C(((1-S("()"))+V(1))^0)*")"} +local nested = P{lparent * (noparent + V(1))^0 * rparent} +local value = P(lparent * C((noparent + nested)^0) * rparent) -- P{"("*C(((1-S("()"))+V(1))^0)*")"} local lp_child = Cc("expr.child(ll,'") * R("az","AZ","--","__")^1 * Cc("')") local lp_number = S("+-") * R("09")^1 @@ -8846,7 +8847,7 @@ local pathparser = Ct { "patterns", -- can be made a bit faster by moving some p expressions = expression / register_expression, letters = R("az")^1, - name = (1-lpeg.S("/[]()|:*!"))^1, -- make inline + name = (1-S("/[]()|:*!"))^1, -- make inline negate = P("!") * Cc(false), nodefunction = V("negate") + P("not") * Cc(false) + Cc(true), diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 8f098c1e3..41adb5d43 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -8607,6 +8607,7 @@ local lp_builtin = P ( P("element") / "(ll.ei or 1)" + P("index") / "(ll.ni or 1)" + P("match") / "(ll.mi or 1)" + + -- P("namespace") / "ll.ns" + P("ns") / "ll.ns" ) * ((spaces * P("(") * spaces * P(")"))/"") @@ -8630,11 +8631,11 @@ local lp_function = C(R("az","AZ","__")^1) * P("(") / function(t) -- todo: bett end end -local lparent = lpeg.P("(") -local rparent = lpeg.P(")") +local lparent = P("(") +local rparent = P(")") local noparent = 1 - (lparent+rparent) -local nested = lpeg.P{lparent * (noparent + lpeg.V(1))^0 * rparent} -local value = lpeg.P(lparent * lpeg.C((noparent + nested)^0) * rparent) -- lpeg.P{"("*C(((1-S("()"))+V(1))^0)*")"} +local nested = P{lparent * (noparent + V(1))^0 * rparent} +local value = P(lparent * C((noparent + nested)^0) * rparent) -- P{"("*C(((1-S("()"))+V(1))^0)*")"} local lp_child = Cc("expr.child(ll,'") * R("az","AZ","--","__")^1 * Cc("')") local lp_number = S("+-") * R("09")^1 @@ -8846,7 +8847,7 @@ local pathparser = Ct { "patterns", -- can be made a bit faster by moving some p expressions = expression / register_expression, letters = R("az")^1, - name = (1-lpeg.S("/[]()|:*!"))^1, -- make inline + name = (1-S("/[]()|:*!"))^1, -- make inline negate = P("!") * Cc(false), nodefunction = V("negate") + P("not") * Cc(false) + Cc(true), diff --git a/tex/context/base/char-def.lua b/tex/context/base/char-def.lua index b76886882..1e3b8a595 100644 --- a/tex/context/base/char-def.lua +++ b/tex/context/base/char-def.lua @@ -401,20 +401,20 @@ characters.data={ adobename="comma", category="po", cjkwd="na", + contextname="textcomma", description="COMMA", direction="cs", linebreak="is", mathclass="punctuation", - mathspec={ - { - class="punctuation", - name="textcomma", - }, - { - class="ord", - name="mathcomma", - }, - }, +--mathspec={ +-- { +-- class="punctuation", +-- }, +-- { +-- class="ord", +-- name="mathcomma", +-- }, +--}, unicodeslot=0x002C, }, { @@ -431,19 +431,18 @@ characters.data={ adobename="period", category="po", cjkwd="na", + contextname="textperiod", description="FULL STOP", direction="cs", linebreak="is", mathclass="ord", mathspec={ - { - class="ord", - name="mathperiod", - }, - { - class="punctuation", - name="textperiod", - }, +-- { +-- class="ord", +-- }, +-- { +-- class="punctuation", +-- }, { class="punctuation", name="ldotp", diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 494b78b13..8fb40a354 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.04.19 23:18} +\newcontextversion{2012.04.23 15:58} %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 3cd207ede..c3ec87d67 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.04.19 23:18} +\newcontextversion{2012.04.23 15:58} %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 Binary files differindex 14d3139ce..0d24263e5 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png Binary files differindex a150ec151..4f24bf5ea 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 63c2dc542..5a707ff4c 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.04.19 23:18} +\edef\contextversion{2012.04.23 15:58} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index dd5905ab0..1de954260 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.04.19 23:18} +\edef\contextversion{2012.04.23 15:58} %D For those who want to use this: diff --git a/tex/context/base/core-mis.mkiv b/tex/context/base/core-mis.mkiv index 06939ac89..5c364f3c4 100644 --- a/tex/context/base/core-mis.mkiv +++ b/tex/context/base/core-mis.mkiv @@ -689,12 +689,10 @@ \def\commacommandsentence[#1]{\@EA\commalistsentence\@EA[#1]} -\ifx\textcomma\undefined \def\textcomma{,} \fi - -\setuplabeltext [\s!nl] [and-1=\textcomma\ , and-2= en ] -\setuplabeltext [\s!en] [and-1=\textcomma\ , and-2=\textcomma\ and ] -\setuplabeltext [\s!de] [and-1=\textcomma\ , and-2= und ] -\setuplabeltext [\s!hr] [and-1=\textcomma\ , and-2= i ] +\setuplabeltext [\s!nl] [and-1={,} , and-2= en ] % 1, 2 en 3 +\setuplabeltext [\s!en] [and-1={,} , and-2={,} ] % 1, 2, 3 +\setuplabeltext [\s!de] [and-1={,} , and-2= und ] % 1, 2 und 3 +\setuplabeltext [\s!hr] [and-1={,} , and-2= i ] % 1, 2 i 3 %D \macros %D {somekindoftab} diff --git a/tex/context/base/lxml-lpt.lua b/tex/context/base/lxml-lpt.lua index 2644abf88..44dd97155 100644 --- a/tex/context/base/lxml-lpt.lua +++ b/tex/context/base/lxml-lpt.lua @@ -532,6 +532,7 @@ local lp_builtin = P ( P("element") / "(ll.ei or 1)" + P("index") / "(ll.ni or 1)" + P("match") / "(ll.mi or 1)" + + -- P("namespace") / "ll.ns" + P("ns") / "ll.ns" ) * ((spaces * P("(") * spaces * P(")"))/"") @@ -555,11 +556,11 @@ local lp_function = C(R("az","AZ","__")^1) * P("(") / function(t) -- todo: bett end end -local lparent = lpeg.P("(") -local rparent = lpeg.P(")") +local lparent = P("(") +local rparent = P(")") local noparent = 1 - (lparent+rparent) -local nested = lpeg.P{lparent * (noparent + lpeg.V(1))^0 * rparent} -local value = lpeg.P(lparent * lpeg.C((noparent + nested)^0) * rparent) -- lpeg.P{"("*C(((1-S("()"))+V(1))^0)*")"} +local nested = P{lparent * (noparent + V(1))^0 * rparent} +local value = P(lparent * C((noparent + nested)^0) * rparent) -- P{"("*C(((1-S("()"))+V(1))^0)*")"} local lp_child = Cc("expr.child(ll,'") * R("az","AZ","--","__")^1 * Cc("')") local lp_number = S("+-") * R("09")^1 @@ -773,7 +774,7 @@ local pathparser = Ct { "patterns", -- can be made a bit faster by moving some p expressions = expression / register_expression, letters = R("az")^1, - name = (1-lpeg.S("/[]()|:*!"))^1, -- make inline + name = (1-S("/[]()|:*!"))^1, -- make inline negate = P("!") * Cc(false), nodefunction = V("negate") + P("not") * Cc(false) + Cc(true), diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv index 50a44d5b0..710a65f5b 100644 --- a/tex/context/base/math-ini.mkiv +++ b/tex/context/base/math-ini.mkiv @@ -1111,7 +1111,7 @@ % force text mode, will be overloaded later -\ifx\text\undefined \let\text\hbox \fi +\ifdefined\text\else \let\text\hbox \fi \unexpanded\def\mathoptext#1{\mathop{\text{#1}}} diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua index c08247afd..9690f6c47 100644 --- a/tex/context/base/mult-low.lua +++ b/tex/context/base/mult-low.lua @@ -190,7 +190,7 @@ return { -- "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", -- - "endgraf", "empty", "null", "space", "obeyspaces", "obeylines", "normalspace", + "endgraf", "empty", "null", "space", "quad", "enspace", "obeyspaces", "obeylines", "normalspace", -- "executeifdefined", -- diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 060bb72f6..5db71ebeb 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 10850803d..c53a0179f 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv index 1857c5a8a..ab4005fb7 100644 --- a/tex/context/base/tabl-tbl.mkiv +++ b/tex/context/base/tabl-tbl.mkiv @@ -1900,10 +1900,10 @@ {\c_tabl_tabulate_pass\plusone \tabl_tabulate_check_full_content \edef\v_tabl_tabulate_align{\executeifdefined{\??tabulatealigning\p_align}0}% - \s_tabl_tabulate_post.5\d_tabl_tabulate_unit + \s_tabl_tabulate_post\zeropoint \s_tabl_tabulate_pre\zeropoint - \s_tabl_tabulate_first\s_tabl_tabulate_post - \s_tabl_tabulate_last\s_tabl_tabulate_post + \s_tabl_tabulate_first.5\d_tabl_tabulate_unit + \s_tabl_tabulate_last\s_tabl_tabulate_first \global\c_tabl_tabulate_columns\zerocount \global\c_tabl_tabulate_nofauto\zerocount \global\c_tabl_tabulate_noflines\zerocount diff --git a/tex/context/base/tabl-xtb.lua b/tex/context/base/tabl-xtb.lua index 6ac5e1835..395d65a03 100644 --- a/tex/context/base/tabl-xtb.lua +++ b/tex/context/base/tabl-xtb.lua @@ -44,6 +44,8 @@ local context_nointerlineskip = context.nointerlineskip local variables = interfaces.variables local setmetatableindex = table.setmetatableindex +local settings_to_hash = utilities.parsers.settings_to_hash + local copy_node_list = node.copy_list local hpack_node_list = node.hpack local vpack_node_list = node.vpack @@ -62,6 +64,7 @@ local v_width = variables.width local v_height = variables.height local v_repeat = variables["repeat"] local v_max = variables.max +local v_fixed = variables.fixed local xtables = { } typesetters.xtables = xtables @@ -89,16 +92,18 @@ local stack, data = { }, nil function xtables.create(settings) table.insert(stack,data) - local rows = { } - local widths = { } - local heights = { } - local depths = { } - local spans = { } - local distances = { } - local autowidths = { } - local modes = { } - local fixedrows = { } - local fixedcolumns = { } + local rows = { } + local widths = { } + local heights = { } + local depths = { } + local spans = { } + local distances = { } + local autowidths = { } + local modes = { } + local fixedrows = { } + local fixedcolumns = { } + local frozencolumns = { } + local options = { } data = { rows = rows, widths = widths, @@ -110,6 +115,8 @@ function xtables.create(settings) autowidths = autowidths, fixedrows = fixedrows, fixedcolumns = fixedcolumns, + frozencolumns = frozencolumns, + options = options, nofrows = 0, nofcolumns = 0, currentrow = 0, @@ -120,6 +127,11 @@ function xtables.create(settings) t[k] = 0 return 0 end + local function add_table(t,k) + local v = { } + t[k] = v + return v + end local function add_cell(row,c) local cell = { nx = 0, @@ -149,12 +161,13 @@ function xtables.create(settings) setmetatableindex(modes,add_zero) setmetatableindex(fixedrows,add_zero) setmetatableindex(fixedcolumns,add_zero) + setmetatableindex(options,add_table) -- settings.columndistance = tonumber(settings.columndistance) or 0 settings.rowdistance = tonumber(settings.rowdistance) or 0 settings.leftmargindistance = tonumber(settings.leftmargindistance) or 0 settings.rightmargindistance = tonumber(settings.rightmargindistance) or 0 - settings.options = utilities.parsers.settings_to_hash(settings.option) + settings.options = settings_to_hash(settings.option) settings.textwidth = tonumber(settings.textwidth) or tex.hsize settings.lineheight = tonumber(settings.lineheight) or texdimen.lineheight settings.maxwidth = tonumber(settings.maxwidth) or settings.textwidth/8 @@ -166,7 +179,7 @@ function xtables.create(settings) end -function xtables.initialize_reflow_width() +function xtables.initialize_reflow_width(option) local r = data.currentrow local c = data.currentcolumn + 1 local drc = data.rows[r][c] @@ -177,6 +190,13 @@ function xtables.initialize_reflow_width() if distance > distances[c] then distances[c] = distance end + if option and option ~= "" then + local options = settings_to_hash(option) + data.options[r][c] = options + if options[v_fixed] then + data.frozencolumns[c] = true + end + end data.currentcolumn = c end @@ -385,6 +405,7 @@ function xtables.reflow_width() local distances = data.distances local autowidths = data.autowidths local fixedcolumns = data.fixedcolumns + local frozencolumns = data.frozencolumns local width = 0 local distance = 0 local nofwide = 0 @@ -393,6 +414,7 @@ function xtables.reflow_width() if trace_xtable then showwidths("stage 1",widths,autowidths) end + local noffrozen = 0 if options[v_max] then for c=1,nofcolumns do width = width + widths[c] @@ -404,6 +426,9 @@ function xtables.reflow_width() if c < nofcolumns then distance = distance + distances[c] end + if frozencolumns[c] then + noffrozen = noffrozen + 1 -- brr, should be nx or so + end end else for c=1,nofcolumns do -- also keep track of forced @@ -422,6 +447,9 @@ function xtables.reflow_width() if c < nofcolumns then distance = distance + distances[c] end + if frozencolumns[c] then + noffrozen = noffrozen + 1 -- brr, should be nx or so + end end end if trace_xtable then @@ -450,13 +478,16 @@ function xtables.reflow_width() widths[c] = widths[c] + factor * widths[c] end else - local extra = delta / nofcolumns + -- frozen -> a column with option=fixed will not stretch + local extra = delta / (nofcolumns - noffrozen) if trace_xtable then report_xtable("normal stretch, delta: %s, extra: %s", points(delta),points(extra)) end for c=1,nofcolumns do - widths[c] = widths[c] + extra + if not frozencolumns[c] then + widths[c] = widths[c] + extra + end end end elseif nofwide > 0 then diff --git a/tex/context/base/tabl-xtb.mkvi b/tex/context/base/tabl-xtb.mkvi index 86bc3f346..2382cae21 100644 --- a/tex/context/base/tabl-xtb.mkvi +++ b/tex/context/base/tabl-xtb.mkvi @@ -64,6 +64,8 @@ % option=stretch : equal distribution % option={stretch,width} : proportional distribution % option={max} : prefer max over forced width/height +% +% cells: option=fixed : nils autostretch (not yet complete) % \setbox\scratchbox\hbox attr \taggedattribute \attribute\taggedattribute {...} % @@ -251,6 +253,8 @@ header = "\xtableparameter\c!header", footer = "\xtableparameter\c!footer", } }% + % + \letxtableparameter\c!option\empty % not so nice but needed as we use this in the setup \linewidth\xtableparameter\c!rulethickness\relax % so we freeze it @@ -424,7 +428,7 @@ \fi % \d_tabl_x_distance\xtableparameter\c!distance\relax - \ctxcommand{x_table_init_reflow_width()}% + \ctxcommand{x_table_init_reflow_width("\xtableparameter\c!option")}% \inheritedxtableframed\bgroup \tabl_x_begin_of_cell \tabl_x_set_hsize} diff --git a/tex/context/base/x-cals.mkiv b/tex/context/base/x-cals.mkiv index 4b9195fad..4e68c3400 100644 --- a/tex/context/base/x-cals.mkiv +++ b/tex/context/base/x-cals.mkiv @@ -26,11 +26,13 @@ % \xmlregistersetup{xml:cals:process} \startxmlsetups xml:cals:process - \xmlsetfunction {\xmldocument} {cals:table} {moduledata.cals.table} +% \xmlsetfunction {\xmldocument} {cals:table} {moduledata.cals.table} + \xmlsetfunction {#1} {cals:table} {moduledata.cals.table} \stopxmlsetups \startxmlsetups xml:cals:nonamespace - \xmlsetfunction {\xmldocument} {table} {moduledata.cals.table} +% \xmlsetfunction {\xmldocument} {table} {moduledata.cals.table} + \xmlsetfunction {#1} {table} {moduledata.cals.table} \stopxmlsetups \xmlregistersetup{xml:cals:process} diff --git a/tex/context/base/x-ct.lua b/tex/context/base/x-ct.lua index 1d0e63dae..2dee985c3 100644 --- a/tex/context/base/x-ct.lua +++ b/tex/context/base/x-ct.lua @@ -24,16 +24,27 @@ local halignments = { justify = '', } +local templates = { } + +function moduledata.ct.registertabulatetemplate(name,str) + templates[name] = str +end + local function roottemplate(root) local rt = root.at.template if rt then - if not find(rt,"|") then - rt = gsub(rt,",","|") + local template = templates[rt] + if template then + return template + else + if not find(rt,"|") then + rt = gsub(rt,",","|") + end + if not find(rt,"^|") then rt = "|" .. rt end + if not find(rt,"|$") then rt = rt .. "|" end + return rt end - if not find(rt,"^|") then rt = "|" .. rt end - if not find(rt,"|$") then rt = rt .. "|" end end - return rt end local function specifiedtemplate(root,templatespec) diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 28b06e1dc..c4939d8ba 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 : 04/19/12 23:18:52 +-- merge date : 04/23/12 15:58:30 do -- begin closure to overcome local limits and interference |