diff options
29 files changed, 306 insertions, 240 deletions
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 432269867..caf609b45 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2010.09.27 23:32} +\newcontextversion{2010.09.28 23: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.tex b/tex/context/base/context.tex index f1f0a2c95..993eecd1d 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2010.09.27 23:32} +\edef\contextversion{2010.09.28 23:57} %D For those who want to use this: diff --git a/tex/context/base/core-con.mkiv b/tex/context/base/core-con.mkiv index 364372a46..58dc2f68e 100644 --- a/tex/context/base/core-con.mkiv +++ b/tex/context/base/core-con.mkiv @@ -225,9 +225,9 @@ \def\monthshort{\doconvertmonthshort} \def\month {\doconvertmonth} -\def\MONTH #1{{\let\labeltext\LABELTEXT\month {#1}}} -\def\MONTHLONG #1{{\let\labeltext\LABELTEXT\monthlong {#1}}} -\def\MONTHSHORT#1{{\let\labeltext\LABELTEXT\monthshort{#1}}} +\def\MONTH #1{{\WORD{\month {#1}}}} +\def\MONTHLONG #1{{\WORD{\monthlong {#1}}}} +\def\MONTHSHORT#1{{\WORD{\monthshort{#1}}}} %D We never explicitly needed this, but Tobias Burnus pointed %D out that it would be handy to convert to the day of the @@ -304,7 +304,7 @@ {\doconvertday} \def\WEEKDAY#1% - {{\let\labeltext\LABELTEXT\doconvertday{#1}}} + {{\WORD{\doconvertday{#1}}}} %D \macros %D {weekoftheday} diff --git a/tex/context/base/lang-lab.mkiv b/tex/context/base/lang-lab.mkiv index 545a64455..1ef27c6c3 100644 --- a/tex/context/base/lang-lab.mkiv +++ b/tex/context/base/lang-lab.mkiv @@ -13,6 +13,9 @@ \unprotect +%C The UPPERCASE variants are obsolete as we can now use \WORD +%C in an non-interfering way. + %D In this module we deal with language dependant labels and %D prefixes, like in {\em Figure~12} and {\em Chapter 1}. In %D this file we set the default values. Users can easily @@ -28,6 +31,9 @@ %D in front as well as after a part number. This is why the %D current implementation of labels supports two labels too. +\ifdefined\simplifiedcommands \else \newtoks\simplifiedcommands \fi +\ifdefined\Word \else \let\Word\relax \fi + %D \macros %D {setupheadtext, setuplabeltext} %D @@ -38,19 +44,117 @@ %D \showsetup{setuplabeltext} %D %D A regular \CONTEXT\ stores some 1500 labels at most. +%D +%D These commands accept all kind of inputs: +%D +%D \starttyping +%D \setuplabeltext [language] [labellabel=text] +%D \setuplabeltext [language] [labellabel=text,labellabel=text,...] +%D \setuplabeltext [labellabel=text] +%D \setuplabeltext [labellabel=text,labellabel=text,...] +%D \stoptyping +%D +%D The last two cases concern the current language. + +\def\definelabelclass + {\dodoubleempty\dodefinelabelclass} + +\def\dodefinelabelclass[#1][#2]% + {\normalexpanded + {\noexpand\dododefinelabelclass + {#1}% + {\ifsecondargument#2\else\zerocount\fi}% + \expandafter\noexpand\csname dogetupsome#1text\endcsname + \expandafter\noexpand\csname #1language\endcsname + \expandafter\noexpand\csname dodogetupsome#1text\endcsname + \expandafter\noexpand\csname left#1text\endcsname + \expandafter\noexpand\csname right#1text\endcsname + \expandafter\noexpand\csname #1texts\endcsname + \expandafter\noexpand\csname #1text\endcsname}} + +\def\dododefinelabelclass#1#2#3#4#5#6#7#8#9% + {\unexpanded\def#3{#5#4}% + \def#4{\reallanguagetag{\defaultlanguage\currentmainlanguage}}% + \setuvalue{setup#1text}{\protecttextprefixes#2\def\currenttextprefixclass{#1}\dodoubleempty\dosetupsometextprefix}% + \setuvalue{preset#1text}{\protecttextprefixes1\def\currenttextprefixclass{#1}\dodoubleempty\dosetupsometextprefix}% + \ifnum#2=\plustwo + \unexpanded\def#5##1##2% ##1=language + {\ifcsname\??ml:#1:##1:##2\endcsname + \csname\??ml:#1:##1:##2\endcsname + \else\ifcsname\??la#4\s!default\endcsname + \expandafter#5\csname\??la#4\s!default\endcsname{##2}% + \else\ifcsname\??ml:#1:##2\endcsname + \csname\??ml:#1:##2\endcsname + \else\ifcsname\??ml:#1:\s!en:##2\endcsname + \csname\??ml:#1:\s!en:##2\endcsname + \else + #2% + \fi\fi\fi\fi}% + \let#6\gobbleoneargument + \let#7\gobbleoneargument + \let#8\gobbletwoarguments + \let#9#3% + \else + \unexpanded\def#5##1##2% + {\ifcsname\??ml:#1:##1:##2\endcsname + \expandafter\let\expandafter\thetextprefix\csname\??ml:#1:##1:##2\endcsname + \else\ifcsname\??la#4\s!default\endcsname + \expandafter#5\csname\??la#4\s!default\endcsname{##2}% + \else\ifcsname\??ml:#1:##2\endcsname + \expandafter\let\expandafter\thetextprefix\csname\??ml:#1:##2\endcsname + \else\ifcsname\??ml:#1:\s!en:##2\endcsname + \expandafter\let\expandafter\thetextprefix\csname\??ml:#1:\s!en:##2\endcsname + \else + \let\thetextprefix\dummytextprefix + \fi\fi\fi\fi}% + \unexpanded\def#6##1{#3{##1}\expandafter\flushleftlabelclass \thetextprefix}% + \unexpanded\def#7##1{#3{##1}\expandafter\flushrightlabelclass\thetextprefix}% + \unexpanded\def#8##1{#3{##1}\expandafter\flushbothlabelclass \thetextprefix}% #2 + \unexpanded\def#9##1{#3{##1}\expandafter\flushleftlabelclass \thetextprefix}% + \fi + \appendtoks + \let#6\firstofoneargument % to be checked + \let#7\firstofoneargument % to be checked + \let#8\firstofoneargument % to be checked + \let#9\firstofoneargument % to be checked + \to \simplifiedcommands + } + +\let\flushleftlabelclass \firstoftwoarguments +\let\flushrightlabelclass\secondoftwoarguments +\def\flushbothlabelclass #1#2#3{#1#3#2} +\def\dummytextprefix {\empty\empty} + +%D \macros +%D {headtext, +%D labeltext, leftlabeltext, rightlabeltext, labeltexts, +%D LABELTEXT, LEFTLABELTEXT, RIGHTLABELTEXT, LABELTEXTS} +%D +%D Once defined, head and label texts can be called upon using: +%D +%D \showsetup{headtext} +%D \showsetup{labeltext} +%D +%D The latter one has an upcased alternative \type{\LABELTEXT}. +%D +%D \macros +%D {presetheadtext,presetlabeltext} +%D +%D These macros enable us to automatically define head and label +%D texts without replacing predefined ones. They are internal macros. -\let\handletextprefix\relax +\definelabelclass [head] [0] +\definelabelclass [label] [0] +\definelabelclass [mathlabel] [0] +\definelabelclass [taglabel] [2] -\let\protecttextprefixes\zerocount +\appendtoks \let\labellanguage\currentlanguage \to \everycurrentdate + +\newconstant\protecttextprefixes \let\currenttextprefixtag \s!unknown \let\currenttextprefixclass\s!unknown -\unexpanded\def\setupheadtext {\let\protecttextprefixes\zerocount\let\currenttextprefixclass\??mh\dodoubleempty\dosetupsometextprefix} -\unexpanded\def\setuplabeltext {\let\protecttextprefixes\zerocount\let\currenttextprefixclass\??ml\dodoubleempty\dosetupsometextprefix} -\unexpanded\def\setupmathlabeltext{\let\protecttextprefixes\zerocount\let\currenttextprefixclass\??mm\dodoubleempty\dosetupsometextprefix} -\unexpanded\def\setuptaglabeltext {\let\protecttextprefixes\plustwo \let\currenttextprefixclass\??me\dodoubleempty\dosetupsometextprefix} - \def\dosetupsometextprefix[#1][#2]% {\ifsecondargument \edef\currenttextprefixtag{\reallanguagetag{#1}}% @@ -72,7 +176,7 @@ \expandafter\doassignsometextprefixyes \or % checking - \ifcsname\currenttextprefixclass\currenttextprefixtag#1\endcsname + \ifcsname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname \expandafter\expandafter\expandafter\doassignsometextprefixnop \else \expandafter\expandafter\expandafter\doassignsometextprefixyes @@ -82,180 +186,29 @@ \expandafter\doassignsometextprefixdumb \fi{#1}} -\ifdefined\Word\else \let\Word\relax \fi - -% Checking saves some 8K in the compressed format and getting rid of the embedded -% \handletextprefix was good for another 6K. In the end the new solution is not -% even that inefficient. And the checking is done at format generation time anyway. - \def\doassignsometextprefixyes#1[#2,#3,#4]% {\edef\!!stringa{#2}% \edef\!!stringb{#3}% \ifx\!!stringb\empty \ifx\!!stringa\empty - \expandafter\def\csname\currenttextprefixclass\currenttextprefixtag#1\endcsname{\empty\empty}% + \expandafter\def\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{\empty\empty}% \else - \expandafter\def\csname\currenttextprefixclass\currenttextprefixtag#1\endcsname{{#2}\empty}% + \expandafter\def\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{{#2}\empty}% \fi \else - \expandafter\def\csname\currenttextprefixclass\currenttextprefixtag#1\endcsname{{#2}{#3}}% + \expandafter\def\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{{#2}{#3}}% \fi} \def\doassignsometextprefixnop#1[#2]% {} \def\doassignsometextprefixdumb#1[#2,#3]% - {\expandafter\def\csname\currenttextprefixclass\currenttextprefixtag#1\endcsname{#2}} - -%D By changing the meaning of \type {\handletextprefix} we -%D can filter the left and right labeltext as well as convert -%D labels to uppercase. -%D -%D These commands accept all kind of inputs: -%D -%D \starttyping -%D \setuplabeltext [language] [labellabel=text] -%D \setuplabeltext [language] [labellabel=text,labellabel=text,...] -%D \setuplabeltext [labellabel=text] -%D \setuplabeltext [labellabel=text,labellabel=text,...] -%D \stoptyping -%D -%D The last two cases concern the current language. - -%D \macros -%D {headtext, -%D labeltext, leftlabeltext, rightlabeltext, labeltexts, -%D LABELTEXT, LEFTLABELTEXT, RIGHTLABELTEXT, LABELTEXTS} -%D -%D Once defined, head and label texts can be called upon using: -%D -%D \showsetup{headtext} -%D \showsetup{labeltext} -%D -%D The latter one has an upcased alternative \type{\LABELTEXT}. - -\def\labellanguage {\reallanguagetag{\defaultlanguage\currentmainlanguage}} -\def\headlanguage {\reallanguagetag{\defaultlanguage\currentmainlanguage}} -\def\mathlabellanguage{\reallanguagetag{\defaultlanguage\currentmainlanguage}} -\def\taglabellanguage {\reallanguagetag{\defaultlanguage\currentmainlanguage}} - -\appendtoks \let\labellanguage\currentlanguage \to \everycurrentdate - -\def\dummytextprefix{\empty\empty} - -\def\dogetupsomelabeltext {\dodogetupsomelabeltext \labellanguage } % second argument is textlabel -\def\dogetupsomeheadtext {\dodogetupsomeheadtext \headlanguage } % second argument is headlabel -\def\dogetupsomemathlabeltext{\dodogetupsomemathlabeltext\mathlabellanguage } -\def\dogetupsometaglabeltext {\dodogetupsometaglabeltext \taglabellanguage } - -\def\dodogetupsomelabeltext#1#2% - {\ifcsname\??ml#1#2\endcsname - \expandafter\let\expandafter\thetextprefix\csname\??ml#1#2\endcsname - \else\ifcsname\??la\labellanguage\s!default\endcsname - \expandafter\dodogetupsomelabeltext\csname\??la\labellanguage\s!default\endcsname{#2}% - \else\ifcsname\??ml#2\endcsname - \expandafter\let\expandafter\thetextprefix\csname\??ml#2\endcsname - \else\ifcsname\??ml\s!en#2\endcsname - \expandafter\let\expandafter\thetextprefix\csname\??ml\s!en#2\endcsname - \else - \let\thetextprefix\dummytextprefix - \fi\fi\fi\fi} - -\def\dodogetupsomeheadtext#1#2% - {\ifcsname\??mh#1#2\endcsname - \expandafter\let\expandafter\thetextprefix\csname\??mh#1#2\endcsname - \else\ifcsname\??la\headlanguage\s!default\endcsname - \expandafter\dodogetupsomeheadtext\csname\??la\headlanguage\s!default\endcsname{#2}% - \else\ifcsname\??mh#2\endcsname - \expandafter\let\expandafter\thetextprefix\csname\??mh#2\endcsname - \else\ifcsname\??mh\s!en#2\endcsname - \expandafter\let\expandafter\thetextprefix\csname\??mh\s!en#2\endcsname - \else - \let\thetextprefix\dummytextprefix - \fi\fi\fi\fi} - -\def\dodogetupsomemathlabeltext#1#2% - {\ifcsname\??mm#1#2\endcsname - \expandafter\let\expandafter\thetextprefix\csname\??mm#1#2\endcsname - \else\ifcsname\??la\mathlabellanguage\s!default\endcsname - \expandafter\dodogetupsomemathlabeltext\csname\??la\mathlabellanguage\s!default\endcsname{#2}% - \else\ifcsname\??mm#2\endcsname - \expandafter\let\expandafter\thetextprefix\csname\??mm#2\endcsname - \else\ifcsname\??mm\s!en#2\endcsname - \expandafter\let\expandafter\thetextprefix\csname\??mm\s!en#2\endcsname - \else - \let\thetextprefix\dummytextprefix - \fi\fi\fi\fi} - -\def\dodogetupsometaglabeltext#1#2% special - {\ifcsname\??me#1#2\endcsname - \csname\??me#1#2\endcsname - \else\ifcsname\??la\mathlabellanguage\s!default\endcsname - \expandafter\dodogetupsomemathlabeltext\csname\??la\mathlabellanguage\s!default\endcsname{#2}% - \else\ifcsname\??me#2\endcsname - \csname\??me#2\endcsname - \else\ifcsname\??me\s!en#2\endcsname - \csname\??me\s!en#2\endcsname - \else - #2% - \fi\fi\fi\fi} - -% The WORD variants are a bit inefficient when #1/#2 are empty but they are -% seldom used (one can better set the style). - -\let\flushleftlabeltext \firstoftwoarguments -\let\flushrightlabeltext \secondoftwoarguments -\let\flushleftmathlabeltext \firstoftwoarguments -\let\flushrightmathlabeltext\secondoftwoarguments - -\def\flushleftlabelWORD #1#2{\WORD{#1}} -\def\flushrightlabelWORD #1#2{\WORD{#2}} -\def\flushbothlabeltexts #1#2#3{#1#3#2} -\def\flushbothlabelTEXTS #1#2#3{\WORD{#1}#3\WORD{#2}} - -\unexpanded\def\headtext #1{\dogetupsomeheadtext {#1}\expandafter\flushleftlabeltext \thetextprefix} -\unexpanded\def\leftlabeltext #1{\dogetupsomelabeltext {#1}\expandafter\flushleftlabeltext \thetextprefix} -\unexpanded\def\rightlabeltext #1{\dogetupsomelabeltext {#1}\expandafter\flushrightmathlabeltext\thetextprefix} -\unexpanded\def\LEFTLABELTEXT #1{\dogetupsomelabeltext {#1}\expandafter\flushleftlabelWORD \thetextprefix} -\unexpanded\def\RIGHTLABELTEXT #1{\dogetupsomelabeltext {#1}\expandafter\flushrightlabelWORD \thetextprefix} -\unexpanded\def\labeltexts #1{\dogetupsomelabeltext {#1}\expandafter\flushbothlabeltexts \thetextprefix} % #2 -\unexpanded\def\LABELTEXTS #1{\dogetupsomelabeltext {#1}\expandafter\flushbothlabelTEXTS \thetextprefix} % #2 -\unexpanded\def\leftmathlabeltext #1{\dogetupsomemathlabeltext{#1}\expandafter\flushleftmathlabeltext \thetextprefix} -\unexpanded\def\rightmathlabeltext#1{\dogetupsomemathlabeltext{#1}\expandafter\flushrightlabeltext \thetextprefix} - -\let\labeltext \leftlabeltext -\let\LABELTEXT \LEFTLABELTEXT -\let\mathlabeltext\leftmathlabeltext - -\ifx\simplifiedcommands\undefined \newtoks\simplifiedcommands \fi - -\appendtoks - \let \headtext \firstofoneargument - \let \labeltext \firstofoneargument - \let \leftlabeltext \firstofoneargument - \let \rightlabeltext \firstofoneargument - \let \HEADTEXT \firstofoneargument - \let \LABELTEXT \firstofoneargument - \let \LEFTLABELTEXT \firstofoneargument - \let \RIGHTLABELTEXT \firstofoneargument - \let \mathlabeltext \firstofoneargument -\to \simplifiedcommands - -%D \macros -%D {presetheadtext,presetlabeltext} -%D -%D The next two macros enable us to automatically define -%D head and label texts without replacing predefined ones. -%D These are internal macros. - -\def\presetheadtext {\let\protecttextprefixes\plusone\let\currenttextprefixclass\??mh\dodoubleempty\dosetupsometextprefix} -\def\presetlabeltext {\let\protecttextprefixes\plusone\let\currenttextprefixclass\??ml\dodoubleempty\dosetupsometextprefix} -\def\presetmathlabeltext{\let\protecttextprefixes\plusone\let\currenttextprefixclass\??mm\dodoubleempty\dosetupsometextprefix} + {\expandafter\def\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{#2}} %D \macros %D {translate} %D -%D Sometismes macros contain language specific words that are to +%D Sometimes macros contain language specific words that are to %D be typeset. Such macros can be made (more) language %D independant by using: %D diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua index 03dd19eaa..05be69810 100644 --- a/tex/context/base/lpdf-ano.lua +++ b/tex/context/base/lpdf-ano.lua @@ -429,6 +429,8 @@ end specials.i = specials.internal +local pages = references.pages + function specials.page(var,actions) -- better resolve in strc-ref local file = var.f if file then @@ -436,13 +438,36 @@ function specials.page(var,actions) -- better resolve in strc-ref return link(nil,file,nil,var.operation,actions) else local p = references.pages[var.operation] - if type(p) == "function" then + if type(p) == "function" then -- double p = p() end return link(nil,nil,nil,p or var.operation,actions) end end +function specials.realpage(var,actions) -- better resolve in strc-ref + local file = var.f + if file then + file = references.checkedfile(file) + return link(nil,file,nil,var.operation,actions) + else + return link(nil,nil,nil,var.operation,actions) + end +end + +function specials.userpage(var,actions) + local p = references.realpageofpage(tonumber(var.operation or 0)) + if p then + local file = var.f + if file then + -- file = references.checkedfile(file) + -- return link(nil,file,nil,p,actions) + else + return link(nil,nil,nil,p,actions) + end + end +end + -- todo, do this in references namespace ordered instead (this is an experiment) local splitter = lpeg.splitat(":") diff --git a/tex/context/base/luat-run.lua b/tex/context/base/luat-run.lua index 46173ecf8..f22470f5f 100644 --- a/tex/context/base/luat-run.lua +++ b/tex/context/base/luat-run.lua @@ -9,9 +9,11 @@ if not modules then modules = { } end modules ['luat-run'] = { local format, rpadd = string.format, string.rpadd local insert = table.insert -local trace_lua_dump = false trackers .register("system.dump", function(v) trace_lua_dump = v end) +local trace_lua_dump = false trackers.register("system.dump", function(v) trace_lua_dump = v end) +local trace_temp_files = false trackers.register("system.tempfiles", function(v) trace_temp_files = v end) -local report_lua_dump = logs.new("lua dump actions") +local report_lua_dump = logs.new("lua dump actions") +local report_temp_files = logs.new("temporary files") luatex = luatex or { } local luatex = luatex @@ -86,3 +88,28 @@ callbacks.register('process_input_buffer', false, "actions perfor callbacks.register('process_output_buffer', false, "actions performed when writing data") callbacks.register("pre_dump", pre_dump_actions, "lua related finalizers called before we dump the format") -- comes after \everydump + +-- an example: + +local tempfiles = { } + +function luatex.registertempfile(name) + name = name .. ".mkiv-tmp" -- maybe just .tmp + if trace_temp_files and not tempfiles[name] then + report_temp_files("registering: %s",name) + end + tempfiles[name] = true + return name +end + +function luatex.cleanuptempfiles() + for name, _ in next, tempfiles do + if trace_temp_files then + report_temp_files("removing: %s",name) + end + os.remove(name) + end + tempfiles = { } +end + +luatex.registerstopactions(luatex.cleanuptempfiles) diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua index bcf94249f..9e8ad4ba0 100644 --- a/tex/context/base/mlib-pps.lua +++ b/tex/context/base/mlib-pps.lua @@ -675,6 +675,8 @@ local function checktexts(str) return lpegmatch(parser,str), found, forced end +metapost.checktexts = checktexts + local no_trial_run = "_trial_run_ := false ;" local do_trial_run = "if unknown _trial_run_ : boolean _trial_run_ fi ; _trial_run_ := true ;" local text_data_template = "_tt_w_[%i]:=%f;_tt_h_[%i]:=%f;_tt_d_[%i]:=%f;" diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua index fc993861c..7d670b77d 100644 --- a/tex/context/base/mlib-run.lua +++ b/tex/context/base/mlib-run.lua @@ -35,7 +35,7 @@ local report_mplib = logs.new("mplib") local texerrormessage = logs.texerrormessage -local format, gsub, match = string.format, string.gsub, string.match +local format, gsub, match, find = string.format, string.gsub, string.match, string.find local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming @@ -57,8 +57,8 @@ function metapost.resetlastlog() metapost.lastlog = "" end -local function finder(name, mode, ftype) - if mode=="w" then +local function finder(name, mode, ftype) -- we can use the finder to intercept btex/etex + if mode == "w" then return name elseif file.is_qualified_path(name) then return name @@ -67,6 +67,23 @@ local function finder(name, mode, ftype) end end +local function finder(name, mode, ftype) -- we use the finder to intercept btex/etex + if mode ~= "w" then + name = file.is_qualified_path(name) and name or resolvers.findfile(name,ftype) + if not (find(name,"/metapost/context/base/") or find(name,"/metapost/context/") or find(name,"/metapost/base/")) then + local data, found, forced = metapost.checktexts(io.loaddata(name) or "") + if found then + local temp = luatex.registertempfile(name) + io.savedata(temp,data) + name = temp + end + end + end + return name +end + +-- -- -- + metapost.finder = finder function metapost.reporterror(result) diff --git a/tex/context/base/mult-de.tex b/tex/context/base/mult-de.tex index 6f9dca7c6..a06c6c633 100644 --- a/tex/context/base/mult-de.tex +++ b/tex/context/base/mult-de.tex @@ -1052,7 +1052,6 @@ \setinterfacecommand{CAPPED}{KAP} \setinterfacecommand{Character}{Buchstabe} \setinterfacecommand{Characters}{Buchstaben} -\setinterfacecommand{LABELTEXT}{LABELTEXT} \setinterfacecommand{MONTH}{MONAT} \setinterfacecommand{Numbers}{Ziffern} \setinterfacecommand{Romannumerals}{Roemischezahlen} diff --git a/tex/context/base/mult-def.lua b/tex/context/base/mult-def.lua index 6f63d4072..ec10d39e2 100644 --- a/tex/context/base/mult-def.lua +++ b/tex/context/base/mult-def.lua @@ -38,16 +38,16 @@ return { ["pe"]="Characters", ["ro"]="Litere", }, - ["LABELTEXT"]={ - ["cs"]="TEXTPOPISKU", - ["de"]="LABELTEXT", - ["en"]="LABELTEXT", - ["fr"]="LABELTEXTE", - ["it"]="TESTOETICHETTA", - ["nl"]="LABELTEKST", - ["pe"]="LABELTEXT", - ["ro"]="TEXTETICHETA", - }, +--~ ["LABELTEXT"]={ +--~ ["cs"]="TEXTPOPISKU", +--~ ["de"]="LABELTEXT", +--~ ["en"]="LABELTEXT", +--~ ["fr"]="LABELTEXTE", +--~ ["it"]="TESTOETICHETTA", +--~ ["nl"]="LABELTEKST", +--~ ["pe"]="LABELTEXT", +--~ ["ro"]="TEXTETICHETA", +--~ }, ["MONTH"]={ ["cs"]="MESIC", ["de"]="MONAT", diff --git a/tex/context/base/mult-en.tex b/tex/context/base/mult-en.tex index 53df30f02..c8d0d3b28 100644 --- a/tex/context/base/mult-en.tex +++ b/tex/context/base/mult-en.tex @@ -1052,7 +1052,6 @@ \setinterfacecommand{CAPPED}{CAP} \setinterfacecommand{Character}{Character} \setinterfacecommand{Characters}{Characters} -\setinterfacecommand{LABELTEXT}{LABELTEXT} \setinterfacecommand{MONTH}{MONTH} \setinterfacecommand{Numbers}{Numbers} \setinterfacecommand{Romannumerals}{Romannumerals} diff --git a/tex/context/base/mult-fr.tex b/tex/context/base/mult-fr.tex index 50da78c48..cbe16592f 100644 --- a/tex/context/base/mult-fr.tex +++ b/tex/context/base/mult-fr.tex @@ -1052,7 +1052,6 @@ \setinterfacecommand{CAPPED}{CAP} \setinterfacecommand{Character}{Caractere} \setinterfacecommand{Characters}{Caracteres} -\setinterfacecommand{LABELTEXT}{LABELTEXTE} \setinterfacecommand{MONTH}{MOIS} \setinterfacecommand{Numbers}{Numeros} \setinterfacecommand{Romannumerals}{Chiffresromains} diff --git a/tex/context/base/mult-it.tex b/tex/context/base/mult-it.tex index 71e1f8ac5..8351025cc 100644 --- a/tex/context/base/mult-it.tex +++ b/tex/context/base/mult-it.tex @@ -1052,7 +1052,6 @@ \setinterfacecommand{CAPPED}{CAP} \setinterfacecommand{Character}{Lettera} \setinterfacecommand{Characters}{Lettere} -\setinterfacecommand{LABELTEXT}{TESTOETICHETTA} \setinterfacecommand{MONTH}{MESE} \setinterfacecommand{Numbers}{Numeri} \setinterfacecommand{Romannumerals}{Numeriromani} diff --git a/tex/context/base/mult-nl.tex b/tex/context/base/mult-nl.tex index d1406e1f5..2a3758254 100644 --- a/tex/context/base/mult-nl.tex +++ b/tex/context/base/mult-nl.tex @@ -1052,7 +1052,6 @@ \setinterfacecommand{CAPPED}{KAP} \setinterfacecommand{Character}{Letter} \setinterfacecommand{Characters}{Letters} -\setinterfacecommand{LABELTEXT}{LABELTEKST} \setinterfacecommand{MONTH}{MAAND} \setinterfacecommand{Numbers}{Cijfers} \setinterfacecommand{Romannumerals}{Romeins} diff --git a/tex/context/base/mult-ro.tex b/tex/context/base/mult-ro.tex index 2a19ca229..072e513ec 100644 --- a/tex/context/base/mult-ro.tex +++ b/tex/context/base/mult-ro.tex @@ -1052,7 +1052,6 @@ \setinterfacecommand{CAPPED}{KAP} \setinterfacecommand{Character}{Litera} \setinterfacecommand{Characters}{Litere} -\setinterfacecommand{LABELTEXT}{TEXTETICHETA} \setinterfacecommand{MONTH}{LUNA} \setinterfacecommand{Numbers}{Numere} \setinterfacecommand{Romannumerals}{Numereromane} diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv index 0c7c7b769..aad3a7bb8 100644 --- a/tex/context/base/page-lay.mkiv +++ b/tex/context/base/page-lay.mkiv @@ -667,31 +667,54 @@ \def\dodefinelayout[#1][#2]% {\getparameters[\??ly#1][\c!state=\v!start,#2]} -% \def\dodosetuplayout[#1][#2]% -% {\ConvertToConstant\doifnot{#2}\v!reset % #2 ? -% {\getparameters[\??ly#1][#2]% -% \checkforems[#2]}} - \def\dodosetuplayout[#1][#2]% {\doifnot{#2}\v!reset{\getparameters[\??ly#1][#2]}} % global needed for non-doublesided standardmakeup +\unexpanded\def\setuplayout + {\dodoubleempty\dosetuplayout} + +% \def\dosetuplayout[#1][#2]% +% {\globallet\currentlayout\empty % new, global +% \ifsecondargument +% \dodosetuplayout[#1][#2]% +% \else\iffirstargument +% \doifassignmentelse{#1} +% {\dodosetuplayout[][#1]} +% {\doifnot{#1}\v!reset{\xdef\currentlayout{#1}}}% new, global +% \fi\fi +% \recalculatelayout +% \checkcurrentlayout % here ? +% \presetcenterpagebox} + \def\dosetuplayout[#1][#2]% - {\globallet\currentlayout\empty % new, global + {\globallet\currentlayout\empty \ifsecondargument \dodosetuplayout[#1][#2]% \else\iffirstargument \doifassignmentelse{#1} {\dodosetuplayout[][#1]} - {\doifnot{#1}\v!reset{\xdef\currentlayout{#1}}}% new, global + {\doifelse{#1}\v!reset + {\let\@@lymethod\v!normal}% hardcodes, assumes a definition + {\xdef\currentlayout{#1}}}% \fi\fi \recalculatelayout - \checkcurrentlayout % here ? + %\checkcurrentlayout % here? + \dochecknextlayout % here? \presetcenterpagebox} -\unexpanded\def\setuplayout - {\dodoubleempty\dosetuplayout} +\def\installlayouthandler#1#2% + {\setgvalue{\??ly:\c!method:#1}{#2}} + +\installlayouthandler\v!default + {\checkcurrentlayout} + +\installlayouthandler\v!normal + {\checkcurrentlayout} + +\def\dochecknextlayout + {\executeifdefined{\??ly:\c!method:\@@lymethod}\checkcurrentlayout} \let\@@zaheight\!!zeropoint diff --git a/tex/context/base/sort-ini.lua b/tex/context/base/sort-ini.lua index d7ef6b0c1..28bd3b4d8 100644 --- a/tex/context/base/sort-ini.lua +++ b/tex/context/base/sort-ini.lua @@ -37,8 +37,9 @@ local lcchars = characters.lcchars local shchars = characters.shchars local variables = interfaces.variables +local v_numbers = variables.numbers -local validmethods = table.tohash{ "mm", "zm", "pm", "mc", "zc", "pc", "uc" } +local validmethods = table.tohash { "mm", "zm", "pm", "mc", "zc", "pc", "uc" } local predefinedmethods = { [variables.before] = "mm,mc,uc", @@ -58,23 +59,22 @@ sorters = { digitsoffset = digitsoffset, digitsmaximum = digitsmaximum, defaultlanguage = variables.default, - defaultmethod = "before", + defaultmethod = variables.before, + defaultdigits = v_numbers, } } local sorters = sorters local constants = sorters.constants -local data, language, method +local data, language, method, digits local replacements, m_mappings, z_mappings, p_mappings, entries, orders, lower, upper, method, sequence --~ local shchars = characters.specialchars -- no specials for AE and ae -local usemetatable = true - local mte = { __index = function(t,k) - if usemetatable then + if utfbyte(k) < digitsoffset then local el if k then local l = lower[k] or lcchars[k] @@ -212,12 +212,13 @@ local function update() -- prepare parent chains, needed when new languages are end end -local function setlanguage(l,m) +local function setlanguage(l,m,d) language = (l ~= "" and l) or constants.defaultlanguage data = definitions[language or constants.defaultlanguage] or definitions[constants.defaultlanguage] - method = (m ~= "" and m) or data.method or constants.defaultmethod + method = (m ~= "" and m) or data.method or constants.defaultmethod + digits = (d ~= "" and d) or data.digits or constants.defaultdigits if trace_tests then - report_sorters("setting language '%s', method '%s'",language,method) + report_sorters("setting language '%s', method '%s', digits '%s'",language,method,digits) end replacements = data.replacements entries = data.entries @@ -232,6 +233,8 @@ local function setlanguage(l,m) method = predefinedmethods[method] or method data.method = method -- + data.digits = digite + -- local seq = utilities.parsers.settings_to_array(method or "") -- check the list sequence = { } for i=1,#seq do @@ -250,12 +253,12 @@ end function sorters.update() update() - setlanguage(language,method) -- resync current language and method + setlanguage(language,method,numberorder) -- resync current language and method end -function sorters.setlanguage(language,method) +function sorters.setlanguage(language,method,numberorder) update() - setlanguage(language,method) -- new language and method + setlanguage(language,method,numberorder) -- new language and method end local function basicsort(sort_a,sort_b) @@ -346,9 +349,9 @@ function comparers.basic(a,b) -- trace ea and eb end end -local function numify(s) - return rep(" ",10-#s) .. s -- or format with padd -end +-- local function numify(s) +-- return rep(" ",10-#s) .. s -- or format with padd +-- end local function numify(s) s = digitsoffset + tonumber(s) -- alternatively we can create a consecutive range @@ -361,8 +364,11 @@ end function sorters.strip(str) -- todo: only letters and such utf.gsub("([^%w%d])","") if str then str = gsub(str,"\\%S*","") + str = gsub(str,"%s","\001") -- can be option str = gsub(str,"[%s%[%](){}%$\"\']*","") - str = gsub(str,"(%d+)",numify) -- sort numbers properly + if digits == v_numbers then + str = gsub(str,"(%d+)",numify) -- sort numbers properly + end return str else return "" @@ -377,10 +383,8 @@ local function firstofsplit(entry) else split = split.ch end - usemetatable = false -- ugly hack local entry = split and split[1] or "" local tag = entries[entry] or "\000" - usemetatable = true return entry, tag end diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua index c1152250f..6811c4da3 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -1348,6 +1348,21 @@ function references.realpage() -- special case, we always want result texwrite(cs.realpage or 0) end +local plist + +function realpageofpage(p) + if not plist then + local pages = structures.pages.collected + plist = { } + for rp=1,#pages do + plist[pages[rp].number] = rp + end + end + return plist[p] +end + +references.realpageofpage = realpageofpage + -- references.pages = allocate { @@ -1383,8 +1398,6 @@ end runners["special operation"] = runners["special"] runners["special operation with arguments"] = runners["special"] -local pages = references.pages - function specials.internal(var,actions) local v = references.internals[tonumber(var.operation)] local r = v and v.references.realpage @@ -1395,6 +1408,10 @@ end specials.i = specials.internal +-- weird, why is this code here and in lpdf-ano + +local pages = references.pages + function specials.page(var,actions) -- is this ok? local p = pages[var.operation] if type(p) == "function" then @@ -1404,3 +1421,12 @@ function specials.page(var,actions) -- is this ok? actions.realpage = p end end + +function specials.realpage(var,actions) -- is this ok? + actions.realpage = tonumber(var.operation) +end + + +function specials.userpage(var,actions) -- is this ok? + actions.realpage = tonumber(realpageofpage(var.operation)) +end diff --git a/tex/context/base/strc-reg.lua b/tex/context/base/strc-reg.lua index 23ce4d221..b08d73159 100644 --- a/tex/context/base/strc-reg.lua +++ b/tex/context/base/strc-reg.lua @@ -418,7 +418,7 @@ function registers.analyzed(class,options) local data = collected[class] if data and data.entries then options = options or { } - sorters.setlanguage(options.language,options.method) + sorters.setlanguage(options.language,options.method,options.numberorder) registers.filter(data,options) -- filter entries into results (criteria) registers.prepare(data,options) -- adds split table parallel to list table registers.sort(data,options) -- sorts results diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv index 37c849790..b1d0692fb 100644 --- a/tex/context/base/strc-reg.mkiv +++ b/tex/context/base/strc-reg.mkiv @@ -123,6 +123,7 @@ \c!file=\jobname, %\c!deeptextcommand=, % undefined by default ! \c!method=, % no default as we have them in the module, maybe some day in lang-* + \c!numberorder=\v!numbers, % \v!characters \s!language=\currentmainlanguage]% %D Definition: @@ -456,10 +457,11 @@ \edef\currentregister{#1}% \setupregister[\currentregister][#2]% \normalexpanded{\endgroup\noexpand\xdef\noexpand\utilityregisterlength{\ctxlua{structures.registers.analyze('\currentregister',{ - language = "\registerparameter\s!language", - method = "\registerparameter\c!method", - compress = "\registerparameter\c!compress", - criterium = "\registerparameter\c!criterium", + language = "\registerparameter\s!language", + method = "\registerparameter\c!method", + numberorder = "\registerparameter\c!numberorder", + compress = "\registerparameter\c!compress", + criterium = "\registerparameter\c!criterium", })}}}% brrr \ifcase\utilityregisterlength\relax \resetsystemmode\v!register @@ -490,10 +492,11 @@ \c!tolerance=\registerparameter\c!tolerance]% \startpacked[\v!blank]% \ctxlua{structures.registers.process('\currentregister',{ - language = "\registerparameter\s!language", - method = "\registerparameter\c!method", - compress = "\registerparameter\c!compress", - criterium = "\registerparameter\c!criterium", + language = "\registerparameter\s!language", + method = "\registerparameter\c!method", + numberorder = "\registerparameter\c!numberorder", + compress = "\registerparameter\c!compress", + criterium = "\registerparameter\c!criterium", }, { % prefix = "\registerparameter\c!pageprefix", diff --git a/tex/context/interface/keys-cs.xml b/tex/context/interface/keys-cs.xml index 4001b5808..4de09d222 100644 --- a/tex/context/interface/keys-cs.xml +++ b/tex/context/interface/keys-cs.xml @@ -1064,7 +1064,6 @@ <cd:command name='CAPPED' value='KAP'/> <cd:command name='Character' value='Znak'/> <cd:command name='Characters' value='Znaky'/> - <cd:command name='LABELTEXT' value='TEXTPOPISKU'/> <cd:command name='MONTH' value='MESIC'/> <cd:command name='Numbers' value='Cisla'/> <cd:command name='Romannumerals' value='Rimskecislice'/> diff --git a/tex/context/interface/keys-de.xml b/tex/context/interface/keys-de.xml index a5a6052c1..8b0b17c7b 100644 --- a/tex/context/interface/keys-de.xml +++ b/tex/context/interface/keys-de.xml @@ -1064,7 +1064,6 @@ <cd:command name='CAPPED' value='KAP'/> <cd:command name='Character' value='Buchstabe'/> <cd:command name='Characters' value='Buchstaben'/> - <cd:command name='LABELTEXT' value='LABELTEXT'/> <cd:command name='MONTH' value='MONAT'/> <cd:command name='Numbers' value='Ziffern'/> <cd:command name='Romannumerals' value='Roemischezahlen'/> diff --git a/tex/context/interface/keys-en.xml b/tex/context/interface/keys-en.xml index 6e38271af..dd3932d8b 100644 --- a/tex/context/interface/keys-en.xml +++ b/tex/context/interface/keys-en.xml @@ -1064,7 +1064,6 @@ <cd:command name='CAPPED' value='CAP'/> <cd:command name='Character' value='Character'/> <cd:command name='Characters' value='Characters'/> - <cd:command name='LABELTEXT' value='LABELTEXT'/> <cd:command name='MONTH' value='MONTH'/> <cd:command name='Numbers' value='Numbers'/> <cd:command name='Romannumerals' value='Romannumerals'/> diff --git a/tex/context/interface/keys-fr.xml b/tex/context/interface/keys-fr.xml index 4496a84e5..d21a28e73 100644 --- a/tex/context/interface/keys-fr.xml +++ b/tex/context/interface/keys-fr.xml @@ -1064,7 +1064,6 @@ <cd:command name='CAPPED' value='CAP'/> <cd:command name='Character' value='Caractere'/> <cd:command name='Characters' value='Caracteres'/> - <cd:command name='LABELTEXT' value='LABELTEXTE'/> <cd:command name='MONTH' value='MOIS'/> <cd:command name='Numbers' value='Numeros'/> <cd:command name='Romannumerals' value='Chiffresromains'/> diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml index 24079698f..680ac0a0c 100644 --- a/tex/context/interface/keys-it.xml +++ b/tex/context/interface/keys-it.xml @@ -1064,7 +1064,6 @@ <cd:command name='CAPPED' value='CAP'/> <cd:command name='Character' value='Lettera'/> <cd:command name='Characters' value='Lettere'/> - <cd:command name='LABELTEXT' value='TESTOETICHETTA'/> <cd:command name='MONTH' value='MESE'/> <cd:command name='Numbers' value='Numeri'/> <cd:command name='Romannumerals' value='Numeriromani'/> diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml index 17e3586d3..9aa4efa2d 100644 --- a/tex/context/interface/keys-nl.xml +++ b/tex/context/interface/keys-nl.xml @@ -1064,7 +1064,6 @@ <cd:command name='CAPPED' value='KAP'/> <cd:command name='Character' value='Letter'/> <cd:command name='Characters' value='Letters'/> - <cd:command name='LABELTEXT' value='LABELTEKST'/> <cd:command name='MONTH' value='MAAND'/> <cd:command name='Numbers' value='Cijfers'/> <cd:command name='Romannumerals' value='Romeins'/> diff --git a/tex/context/interface/keys-pe.xml b/tex/context/interface/keys-pe.xml index 22148fd09..fabb5c821 100644 --- a/tex/context/interface/keys-pe.xml +++ b/tex/context/interface/keys-pe.xml @@ -1064,7 +1064,6 @@ <cd:command name='CAPPED' value='CAP'/> <cd:command name='Character' value='Character'/> <cd:command name='Characters' value='Characters'/> - <cd:command name='LABELTEXT' value='LABELTEXT'/> <cd:command name='MONTH' value='MONTH'/> <cd:command name='Numbers' value='Numbers'/> <cd:command name='Romannumerals' value='Romannumerals'/> diff --git a/tex/context/interface/keys-ro.xml b/tex/context/interface/keys-ro.xml index c529e10de..e71ddff85 100644 --- a/tex/context/interface/keys-ro.xml +++ b/tex/context/interface/keys-ro.xml @@ -1064,7 +1064,6 @@ <cd:command name='CAPPED' value='KAP'/> <cd:command name='Character' value='Litera'/> <cd:command name='Characters' value='Litere'/> - <cd:command name='LABELTEXT' value='TEXTETICHETA'/> <cd:command name='MONTH' value='LUNA'/> <cd:command name='Numbers' value='Numere'/> <cd:command name='Romannumerals' value='Numereromane'/> diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 502b6b1c2..8778ad879 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 09/27/10 23:32:54 +-- merge date : 09/28/10 23:57:54 do -- begin closure to overcome local limits and interference |