diff options
25 files changed, 701 insertions, 568 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 031d91a85..4c5d10c20 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -4779,6 +4779,8 @@ if not modules then modules = { } end modules ['util-prs'] = { license = "see context related readme files" } +local lpeg, table, string = lpeg, table, string + local P, R, V, C, Ct, Cs, Carg, Cc = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg, lpeg.Cc local lpegmatch, patterns = lpeg.match, lpeg.patterns local concat, format, gmatch, find = table.concat, string.format, string.gmatch, string.find diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 031d91a85..4c5d10c20 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -4779,6 +4779,8 @@ if not modules then modules = { } end modules ['util-prs'] = { license = "see context related readme files" } +local lpeg, table, string = lpeg, table, string + local P, R, V, C, Ct, Cs, Carg, Cc = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg, lpeg.Cc local lpegmatch, patterns = lpeg.match, lpeg.patterns local concat, format, gmatch, find = table.concat, string.format, string.gmatch, string.find diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 031d91a85..4c5d10c20 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -4779,6 +4779,8 @@ if not modules then modules = { } end modules ['util-prs'] = { license = "see context related readme files" } +local lpeg, table, string = lpeg, table, string + local P, R, V, C, Ct, Cs, Carg, Cc = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg, lpeg.Cc local lpegmatch, patterns = lpeg.match, lpeg.patterns local concat, format, gmatch, find = table.concat, string.format, string.gmatch, string.find diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 751918cc3..9f6ad7e5b 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.19 22:27} +\newcontextversion{2012.06.20 16:19} %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 89ef24be6..0d906a955 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.19 22:27} +\newcontextversion{2012.06.20 16:19} %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 88a6b4620..c1cde20ef 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 7aa0f8eb7..e740b41d1 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 51916df1f..beedad054 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.19 22:27} +\edef\contextversion{2012.06.20 16:19} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 72a9d796a..968bd1b58 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.19 22:27} +\edef\contextversion{2012.06.20 16:19} %D For those who want to use this: diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv index 1eecbaf2f..77585dac1 100644 --- a/tex/context/base/mult-sys.mkiv +++ b/tex/context/base/mult-sys.mkiv @@ -536,7 +536,6 @@ \definesystemvariable {qd} % catcode table def % already defined \definesystemvariable {qu} % catcode table ued % already defined \definesystemvariable {qm} % catcode table meaning % already defined -\definesystemvariable {rf} % ReFerencing \definesystemvariable {rn} % RegelNummer \definesystemvariable {rs} % RaSters \definesystemvariable {rt} % RoosTers @@ -545,7 +544,6 @@ \definesystemvariable {sd} % SounD \definesystemvariable {se} % SEctie \definesystemvariable {sh} % ShapeText -\definesystemvariable {si} % SplIt \definesystemvariable {sp} % SelecteerPapier \definesystemvariable {st} % STickers \definesystemvariable {sx} % Selector diff --git a/tex/context/base/node-ref.lua b/tex/context/base/node-ref.lua index dc1410282..75126d902 100644 --- a/tex/context/base/node-ref.lua +++ b/tex/context/base/node-ref.lua @@ -544,6 +544,9 @@ function references.injectcurrentset(h,d) -- used inside doifelse end end +commands.injectreference = references.inject +commands.injectcurrentreference = references.injectcurrentset + -- local function checkboth(open,close) diff --git a/tex/context/base/page-lin.mkiv b/tex/context/base/page-lin.mkiv index 7b1cbcd94..671d4c712 100644 --- a/tex/context/base/page-lin.mkiv +++ b/tex/context/base/page-lin.mkiv @@ -515,7 +515,7 @@ % eventually we will do this in lua -\def\currentreferencelinenumber{\ctxlua{structures.references.filter("linenumber")}} +\def\currentreferencelinenumber{\ctxcommand{filterreference("linenumber")}} \def\doifelsesamelinereference#1#2#3% {\doifreferencefoundelse{lr:b:#1} diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 212cbcfd1..ab9ad4f3f 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 2ff5c0720..46bf5c1a4 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua index 87b23499b..228707dce 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -525,7 +525,7 @@ return { { filename = "strc-sbe", marktype = "mkiv", - status = "unknown", + status = "okay", }, { filename = "strc-lst", @@ -550,7 +550,8 @@ return { { filename = "strc-xml", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "this module might go away", }, { filename = "strc-def", @@ -560,7 +561,8 @@ return { { filename = "strc-ref", marktype = "mkvi", - status = "unknown", + status = "okay", + comment = "some more low level names might change", }, { filename = "strc-reg", @@ -653,7 +655,7 @@ return { status = "okay", }, { - filename = "strc-des", + filename = "strc-con", marktype = "mkiv", status = "unknown", }, @@ -963,7 +965,8 @@ return { { filename = "tabl-tsp", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "will be adapted when needed (and rest is done)", }, { filename = "tabl-xtb", @@ -1095,7 +1098,8 @@ return { { filename = "blob-ini", marktype = "mkiv", - status = "unknown", + status = "okay", + comment = "work in progress", }, { filename = "typo-cln", diff --git a/tex/context/base/status-mkiv.tex b/tex/context/base/status-mkiv.tex index e9b12b130..7bb262352 100644 --- a/tex/context/base/status-mkiv.tex +++ b/tex/context/base/status-mkiv.tex @@ -46,6 +46,8 @@ module writers should {\bf not} use the core commands with \type{_} in the name \stopitem \startitem the message system will be unified \stopitem + \startitem maybe rename dowhatevertexcommand to fromluawhatevertexcommand \stopitem + \stopitemize \stopsubject diff --git a/tex/context/base/strc-doc.lua b/tex/context/base/strc-doc.lua index f10b175a4..d278107d5 100644 --- a/tex/context/base/strc-doc.lua +++ b/tex/context/base/strc-doc.lua @@ -204,7 +204,7 @@ end function sections.setblock(name) local block = name or data.block or "unknown" -- can be used to set the default data.block = block - context(block) + return block end function sections.pushblock(name) @@ -213,7 +213,7 @@ function sections.pushblock(name) data.blocks[#data.blocks+1] = block data.block = block documents.reset() - context(block) + return block end function sections.popblock() @@ -221,7 +221,7 @@ function sections.popblock() local block = data.blocks[#data.blocks] or data.block data.block = block documents.reset() - context(block) + return block end function sections.currentblock() @@ -926,3 +926,10 @@ commands.structureautocatcodedget = function(name,catcode) sections.structured commands.namedstructurevariable = function(depth,name) sections.structuredata(depth,name) end commands.namedstructureuservariable = function(depth,name) sections.userdata (depth,name) end + +-- + +function commands.setsectionblock (name) context(sections.setblock(name)) end +function commands.pushsectionblock(name) context(sections.pushblock(name)) end +function commands.popsectionblock () context(sections.popblock()) end + diff --git a/tex/context/base/strc-doc.mkiv b/tex/context/base/strc-doc.mkiv index 4e9dec32e..14c6537db 100644 --- a/tex/context/base/strc-doc.mkiv +++ b/tex/context/base/strc-doc.mkiv @@ -59,15 +59,16 @@ % maybe flags for list, bm, mark -\def\structurereferenceprefixon {+} -\def\structurereferenceprefixoff{-} +\def\m_strc_references_prefix_yes{+} +\def\m_strc_references_prefix_nop{-} -\def\setstructurereferenceprefix +\def\setstructurereferenceprefix % will move {\ifx\currentstructurereferenceprefix\empty % nothing - \else\ifx\currentstructurereferenceprefix\structurereferenceprefixon - \setupglobalreferenceprefix[\currentstructurereference]% - \else\ifx\currentstructurereferenceprefix\structurereferenceprefixoff + \else\ifx\currentstructurereferenceprefix\m_strc_references_prefix_yes + \global\advance\prefixcounter \plusone % temp here + \setupglobalreferenceprefix[\the\prefixcounter]% + \else\ifx\currentstructurereferenceprefix\m_strc_references_prefix_nop \setupglobalreferenceprefix[]% \else \setupglobalreferenceprefix[\currentstructurereferenceprefix]% diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua index 092babfae..2d6e0a1fe 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -38,6 +38,12 @@ local variables = interfaces.variables local constants = interfaces.constants local context = context +local v_default = variables.default +local v_url = variables.url +local v_file = variables.file +local v_unknown = variables.unknown +local v_yes = variables.yes + local texcount = tex.count local texconditionals = tex.conditionals @@ -237,11 +243,13 @@ references.setnextorder = setnextorder function references.setnextinternal(kind,name) setnextorder(kind,name) -- always incremented with internal - texsetcount("global","locationcount",texcount.locationcount + 1) + local n = texcount.locationcount + 1 + texsetcount("global","locationcount",n) + return n end function references.currentorder(kind,name) - context(orders[kind] and orders[kind][name] or lastorder) + return orders[kind] and orders[kind][name] or lastorder end local function setcomponent(data) @@ -257,6 +265,12 @@ local function setcomponent(data) -- but for the moment we do it here (experiment) end +commands.setnextinternalreference = references.setnextinternal + +function commands.currentreferenceorder(kind,name) + context(references.currentorder(kind,name)) +end + references.setcomponent = setcomponent function references.set(kind,prefix,tag,data) @@ -292,6 +306,8 @@ function references.enhance(prefix,tag) end end +commands.enhancereference = references.enhance + -- -- -- related to strc-ini.lua -- -- -- references.resolvers = references.resolvers or { } @@ -526,9 +542,7 @@ end function references.programs.get(name) local f = programs[name] - if f then - context(f[1]) - end + return f and f[1] end function references.checkedprogram(whatever) -- return whatever if not resolved @@ -542,10 +556,19 @@ function references.checkedprogram(whatever) -- return whatever if not resolved end end +commands.defineprogram = references.programs.define + +function commands.getprogram(name) + local f = programs[name] + if f then + context(f[1]) + end +end + -- shared by urls and files function references.whatfrom(name) - context((urls[name] and variables.url) or (files[name] and variables.file) or variables.unknown) + context((urls[name] and v_url) or (files[name] and v_file) or v_unknown) end function references.from(name) @@ -553,6 +576,31 @@ function references.from(name) if u then local url, file, description = u[1], u[2], u[3] if description ~= "" then + return description + -- ok + elseif file and file ~= "" then + return url .. "/" .. file + else + return url + end + else + local f = files[name] + if f then + local file, description = f[1], f[2] + if description ~= "" then + return description + else + return file + end + end + end +end + +function commands.from(name) + local u = urls[name] + if u then + local url, file, description = u[1], u[2], u[3] + if description ~= "" then context.dofromurldescription(description) -- ok elseif file and file ~= "" then @@ -578,10 +626,6 @@ function references.define(prefix,reference,list) d[reference] = { "defined", list } end ---~ function references.registerspecial(name,action,...) ---~ specials[name] = { action, ... } ---~ end - function references.reset(prefix,reference) local d = defined[prefix] if d then @@ -589,6 +633,9 @@ function references.reset(prefix,reference) end end +commands.definereference = references.define +commands.resetreference = references.reset + -- \primaryreferencefoundaction -- \secondaryreferencefoundaction -- \referenceunknownaction @@ -699,6 +746,8 @@ function references.expandcurrent() -- todo: two booleans: o_has_tex& a_has_tex end end +commands.expandcurrentreference = references.expandcurrent -- for the moment the same + local externals = { } -- we have prefixes but also components: @@ -1514,7 +1563,7 @@ references.identify = identify local unknowns, nofunknowns = { }, 0 -function references.doifelse(prefix,reference,highlight,newwindow,layer) +function references.valid(prefix,reference,highlight,newwindow,layer) local set, bug = identify(prefix,reference) local unknown = bug or #set == 0 if unknown then @@ -1533,7 +1582,11 @@ function references.doifelse(prefix,reference,highlight,newwindow,layer) currentreference = set[1] end -- we can do the expansion here which saves a call - commands.doifelse(not unknown) + return not unknown +end + +function commands.doifelsereference(prefix,reference,highlight,newwindow,layer) + commands.doifelse(references.valid(prefix,reference,highlight,newwindow,layer)) end function references.reportproblems() -- might become local @@ -1563,7 +1616,7 @@ function references.setinnermethod(m) if m then if m == "page" or m == "mixed" or m == "names" then innermethod = m - elseif m == true or m == variables.yes then + elseif m == true or m == v_yes then innermethod = "page" end end @@ -1612,13 +1665,14 @@ function references.setinternalreference(prefix,tag,internal,view) -- needs chec end function references.setandgetattribute(kind,prefix,tag,data,view) -- maybe do internal automatically here - if references.set(kind,prefix,tag,data) then - texcount.lastdestinationattribute = references.setinternalreference(prefix,tag,nil,view) or unsetvalue - else - texcount.lastdestinationattribute = unsetvalue - end + local attr = references.set(kind,prefix,tag,data) and references.setinternalreference(prefix,tag,nil,view) or unsetvalue + texcount.lastdestinationattribute = attr + return attr end +commands.setinternalreference = references.setinternalreference +commands.setreferenceattribute = references.setandgetattribute + function references.getinternalreference(n) -- n points into list (todo: registers) local l = lists.collected[n] return l and l.references.internal or n @@ -1637,7 +1691,11 @@ end function references.getcurrentmetadata(tag) local data = currentreference and currentreference.i - data = data and data.metadata and data.metadata[tag] + return data and data.metadata and data.metadata[tag] +end + +function commands.getcurrentreferencemetadata(tag) + local data = references.getcurrentmetadata(tag) if data then context(data) end @@ -1650,8 +1708,15 @@ end references.currentmetadata = currentmetadata -function references.getcurrentprefixspec(default) -- todo: message - context.getreferencestructureprefix(currentmetadata("kind") or "?",currentmetadata("name") or "?",default or "?") +local function getcurrentprefixspec(default) + -- todo: message + return currentmetadata("kind") or "?", currentmetadata("name") or "?", default or "?" +end + +references.getcurrentprefixspec = getcurrentprefixspec + +function commands.getcurrentprefixspec(default) + context.getreferencestructureprefix(getcurrentprefixspec(default)) end function references.filter(name,...) -- number page title ... @@ -1682,6 +1747,10 @@ function references.filter(name,...) -- number page title ... end end +function references.filterdefault() + return references.filter("default",getcurrentprefixspec(v_default)) +end + filters.generic = { } function filters.generic.title(data) @@ -2049,10 +2118,13 @@ end -- needs a better split ^^^ -commands.filterreference = references.filter +commands.filterreference = references.filter +commands.filterdefaultreference = references.filterdefault -- done differently now: function references.export(usedname) end function references.import(usedname) end function references.load (usedname) end + +commands.exportreferences = references.export diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi index ee45d76fa..91b807696 100644 --- a/tex/context/base/strc-ref.mkvi +++ b/tex/context/base/strc-ref.mkvi @@ -61,20 +61,42 @@ % \definespecial\dosetexecuteJScode % ... -%D This module deals with referencing. In \CONTEXT\ referencing -%D is one of the core features, although at a first glance -%D probably nobody will notice. This is good, because -%D referencing should be as hidden as possible. +%D This module deals with referencing. In \CONTEXT\ referencing is one of +%D the core features, although at a first glance probably nobody will +%D notice. This is good, because referencing should be as hidden as possible. %D -%D In paper documents, referencing comes down to cross -%D referencing, but in their interactive counterparts, is also -%D involves navigation. Many features implemented here are -%D therefore closely related to navigation. +%D Before we start implementing functionality we provide a way to set +%D up this mechanism. %D -%D Many \CONTEXT\ commands can optionally be fed with a -%D reference. Such a reference, when called upon, returns the -%D number of a figure, table, chapter etc, a piece of text, or -%D a pagenumber. +%D \showsetup{setupreferencing} +%D +%D In interactive documents verbose references don't always +%D make sense (what is a page number in an unnumbered +%D document). By setting the \type{interaction} variable, one +%D can influences the way interactive references are set. + +\installcorenamespace{referencing} + +\installdirectcommandhandler \??referencing {referencing} % \??referencing + +\newif\ifreferencing \referencingtrue + +\appendtoks + \edef\p_state{\referencingparameter\c!state}% + \ifx\p_state\v!start + \referencingtrue + \else + \referencingfalse + \fi +\to \everysetupreferencing + +%D In paper documents, referencing comes down to cross referencing, but in +%D their interactive counterparts, is also involves navigation. Many features +%D implemented here are therefore closely related to navigation. +%D +%D Many \CONTEXT\ commands can optionally be fed with a reference. Such a +%D reference, when called upon, returns the number of a figure, table, chapter +%D etc, a piece of text, or a pagenumber. %D %D There are three ways of defining a reference: %D @@ -108,8 +130,8 @@ \newcount\lastreferenceattribute \newcount\lastdestinationattribute -\def\dofinishfullreference#prefix#label{\normalexpanded{\ctxlatelua{structures.references.enhance("#prefix","#label")}}} -\def\dofinishtextreference#prefix#label{\normalexpanded{\ctxlatelua{structures.references.enhance("#prefix","#label",{})}}} +\def\dofinishfullreference#prefix#label{\normalexpanded{\ctxlatecommand{enhancereference("#prefix","#label")}}} +\def\dofinishtextreference#prefix#label{\normalexpanded{\ctxlatecommand{enhancereference("#prefix","#label",{})}}} \let\dofinishpagereference\dofinishfullreference \let\dofinishuserreference\dofinishfullreference @@ -143,7 +165,7 @@ \edef\currentreferencekind {#kind}% \edef\currentreferencelabels {#labels}% \edef\currentreferenceuserdata {#userdata}% - \edef\currentreferenceexpansion{\@@rfexpansion}% {\referenceparameter\c!expansion} + \edef\currentreferenceexpansion{\referencingparameter\c!expansion}% {\referenceparameter\c!expansion} \ifx\currentreferencelabels\empty \lastdestinationattribute\attributeunsetvalue \else @@ -163,7 +185,7 @@ % beware, the structures.references.set writes a % \setnextinternalreference \strc_references_start_destination_nodes - \ctxlua{structures.references.setandgetattribute("\currentreferencekind", "\referenceprefix","\currentreferencelabels", + \ctxcommand{setreferenceattribute("\currentreferencekind", "\referenceprefix","\currentreferencelabels", { references = { % internal = \nextinternalreference, % no need for an internal as we have an explicit @@ -210,7 +232,7 @@ \lastdestinationattribute\attributeunsetvalue \else \strc_references_start_destination_nodes - \ctxlua{structures.references.setandgetattribute("\s!page", "\referenceprefix","\currentreferencelabels", + \ctxcommand{setreferenceattribute("\s!page", "\referenceprefix","\currentreferencelabels", { references = { block = "\currentsectionblock", @@ -248,7 +270,7 @@ \def\strc_references_set_simple_page_reference#label% {\iflocation \strc_references_start_destination_nodes - \ctxlua{structures.references.setandgetattribute("\s!page", "\referenceprefix","#label", + \ctxcommand{setreferenceattribute("\s!page", "\referenceprefix","#label", { references = { % block = "\currentsectionblock", @@ -268,7 +290,7 @@ \def\strc_references_get_simple_page_reference#label% {\iflocation - \ctxlua{structures.references.inject("\referenceprefix","#label",\number\ht\strutbox,\number\dp\strutbox,\extrareferencearguments)}% + \ctxcommand{injectreference("\referenceprefix","#label",\number\ht\strutbox,\number\dp\strutbox,\extrareferencearguments)}% \xdef\currentreferenceattribute{\number\lastreferenceattribute}% \else \xdef\currentreferenceattribute{\number\attributeunsetvalue}% @@ -437,13 +459,13 @@ {\dodoubleempty\strc_references_define_reference} \def\strc_references_define_reference[#name][#specification]% - {\ctxlua{structures.references.define("\referenceprefix","#name",\!!bs\detokenize{#specification}\!!es)}} + {\ctxcommand{definereference("\referenceprefix","#name",\!!bs\detokenize{#specification}\!!es)}} \unexpanded\def\resetreference[#name]% - {\ctxlua{structures.references.reset("\referenceprefix","#name")}} + {\ctxcommand{resetreference("\referenceprefix","#name")}} \def\setpagereference#name#specification% hm,. low level ? - {\ctxlua{structures.references.define("","#name",\!!bs\v!page(\luaescapestring{#specification})\!!es)}} + {\ctxcommand{definereference("","#name",\!!bs\v!page(\luaescapestring{#specification})\!!es)}} %D Chained references are defined as: %D @@ -473,13 +495,13 @@ \newconditional\gotonewwindow \setfalse\gotonewwindow \def\expandtexincurrentreference % will happen in lua some time - {\ifcase\referencehastexstate\else\ctxlua{structures.references.expandcurrent()}\fi} + {\ifcase\referencehastexstate\else\ctxcommand{expandcurrentreference()}\fi} \def\expandreferenceoperation#tag#content{\ctxcommand{setreferenceoperation(#tag,\!!bs#content\!!es)}} \def\expandreferencearguments#tag#content{\ctxcommand{setreferencearguments(#tag,\!!bs#content\!!es)}} \def\doifreferencefoundelse#labels#yes#nop% - {\ctxlua{structures.references.doifelse("\referenceprefix","#labels",\luaconditional\highlighthyperlinks,\luaconditional\gotonewwindow)}% + {\ctxcommand{doifelsereference("\referenceprefix","#labels",\luaconditional\highlighthyperlinks,\luaconditional\gotonewwindow)}% {\expandtexincurrentreference #yes}% {#nop}} @@ -562,8 +584,8 @@ %D the special driver modules (see \type{spec-ini}). The flag %D \type{\iflocation} signals if we're in interactive mode. -\ifx\buttonheight\undefined \newdimen\buttonheight \fi -\ifx\buttonwidth \undefined \newdimen\buttonwidth \fi +\ifdefined\buttonheight \else \newdimen\buttonheight \fi +\ifdefined\buttonwidth \else \newdimen\buttonwidth \fi %D Internal references can best be set using the next few %D macros. Setting such references to unique values is @@ -588,14 +610,14 @@ {\global\advance\locationcount\plusone} \def\setnextinternalreferences#kind#name% plural - {\ctxlua{structures.references.setnextinternal("#kind","#name")}} + {\ctxcommand{setnextinternalreference("#kind","#name")}} \def\getinternalorderreference#kind#name% - {\ctxlua{structures.references.currentorder("#kind","#name")}} + {\ctxcommand{currentreferenceorder("#kind","#name")}} \def\thisissomeinternal#kind#name% only for old time sake {\begingroup - \ctxlua{structures.references.setinternalreference("","#kind:#name")}% + \ctxcommand{setinternalreference("","#kind:#name")}% \hbox attr \destinationattribute\lastdestinationattribute{}% \endgroup} @@ -630,8 +652,6 @@ %D \goto{some text}[\v!action(PreviousJump] %D \stoptyping -\newif\ifreferencing \referencingtrue - %D One can also activate an automatic prefix mechanism. By %D setting the \type{\prefix} variable to \type{+}, the prefix %D is incremented, when set to \type{-} or empty, the prefix is @@ -639,64 +659,24 @@ \newcount\prefixcounter -%D These settings are accomplished by: -%D -%D \showsetup{setupreferencing} -%D -%D In interactive documents verbose references don't always -%D make sense (what is a page number in an unnumbered -%D document). By setting the \type{interaction} variable, one -%D can influences the way interactive references are set. - -\newtoks \everysetupreferencing - -\unexpanded\def\setupreferencing - {\dosingleargument\strc_references_setup_referencing} - -\def\strc_references_setup_referencing[#settings]% - {\getparameters[\??rf][\c!prefix=\s!unknown,#settings]% - \the\everysetupreferencing} - -\appendtoks - \processaction - [\@@rfstate] - [ \v!stop=>\referencingfalse, - \v!start=>\referencingtrue]% -\to \everysetupreferencing - \newconditional\autocrossfilereferences \appendtoks - \doifelse\@@rfautofile\v!yes\settrue\setfalse\autocrossfilereferences + \edef\p_autofile{\referencingparameter\c!autofile}% + \ifx\p_autofile\v!yes + \settrue \autocrossfilereferences + \else + \setfalse\autocrossfilereferences + \fi \to \everysetupreferencing -\def\exportreferences - {\doif\@@rfexport\v!yes{\ctxlua{structures.references.export()}}} - \appendtoks - \exportreferences + \edef\p_export{\referencingparameter\c!export}% + \ifx\p_export\v!yes + \ctxcommand{exportreferences()}% + \fi \to \everygoodbye -\def\incrementreferenceprefix{+} -\def\decrementreferenceprefix{-} - -\unexpanded\def\setupreferenceprefix[#prefix]% - {\edef\@@rfprefix{#prefix}% - \ifx\@@rfprefix\empty - \let\referenceprefix\empty - \else\ifx\@@rfprefix\incrementreferenceprefix - \global\advance\prefixcounter \plusone - \edef\referenceprefix{\the\prefixcounter}% - \let\@@rfprefix\s!unknown - \else\ifx\@@rfprefix\decrementreferenceprefix - \let\referenceprefix\empty - \let\@@rfprefix\s!unknown - \else\ifx\@@rfprefix\s!unknown - % forget about it - \else - \edef\referenceprefix{\@@rfprefix}% expanded ! - \fi\fi\fi\fi} - \unexpanded\def\setupglobalreferenceprefix[#prefix]% {\xdef\referenceprefix{#prefix}} @@ -707,8 +687,28 @@ \unexpanded\def\popreferenceprefix {\popmacro\referenceprefix} +\def\m_strc_references_prefix_yes{+} +\def\m_strc_references_prefix_nop{-} + +\unexpanded\def\setupreferenceprefix[#prefix]% + {\edef\p_prefix{#prefix}% + \ifx\p_prefix\empty + \let\referenceprefix\empty + \else\ifx\p_prefix\m_strc_references_prefix_yes + \letreferencingparameter\c!prefix\s!unknown + \global\advance\prefixcounter\plusone + \edef\referenceprefix{\the\prefixcounter}% + \else\ifx\p_prefix\m_strc_references_prefix_nop + \letreferencingparameter\c!prefix\s!unknown + \let\referenceprefix\empty + \else\ifx\p_prefix\s!unknown + % forget about it + \else + \let\referenceprefix\p_prefix + \fi\fi\fi\fi} + \appendtoks - \setupreferenceprefix[\@@rfprefix] + \setupreferenceprefix[\referencingparameter\c!prefix] \to \everysetupreferencing %D We can typeset a reference using \type{\in}, \type{\at} and @@ -808,11 +808,11 @@ \let\crlf\space \let\\\space \postponenotes - \@@rfleft + \referencingparameter\c!left \doifreferencefoundelse{#label} - {\goto{\limitatetext\currentreferencetitle\@@rfwidth\unknown}[#label]}% not so efficient (dup lookup) + {\goto{\limitatetext\currentreferencetitle{\referencingparameter\c!width}\unknown}[#label]}% not so efficient (dup lookup) {}% todo - \@@rfright + \referencingparameter\c!right \endgroup} %D The previously discussed setup macro lets us specify the @@ -883,7 +883,9 @@ \let\leftofreference \empty \let\rightofreference \empty -\setvalue{\??rf\c!interaction\v!all}% +\installcorenamespace{referencinginteraction} + +\setvalue{\??referencinginteraction\v!all}% {\the\leftreferencetoks \doifsometokselse\leftreferencetoks \leftofreferencecontent \donothing \leftofreference @@ -892,24 +894,24 @@ \doifsometokselse\rightreferencetoks\rightofreferencecontent\donothing \the\rightreferencetoks} -\setvalue{\??rf\c!interaction\v!label}% +\setvalue{\??referencinginteraction\v!label}% {\leftofreference \the\leftreferencetoks \the\rightreferencetoks \rightofreference} -\setvalue{\??rf\c!interaction\v!text}% +\setvalue{\??referencinginteraction\v!text}% {\leftofreference \currentreferencecontent \rightofreference} -\setvalue{\??rf\c!interaction\v!symbol}% +\setvalue{\??referencinginteraction\v!symbol}% {\referencesymbol} \def\referencesequence - {\csname \??rf\c!interaction - \ifcsname\??rf\c!interaction\@@rfinteraction\endcsname - \@@rfinteraction + {\csname\??referencinginteraction + \ifcsname\??referencinginteraction\referencingparameter\c!interaction\endcsname + \referencingparameter\c!interaction \else \v!all \fi @@ -1067,7 +1069,7 @@ \def\autoreferencelabeltextflag{*} % a proper key like 'auto' or 'name' can clash with a label key \unexpanded\def\autoreferencelabeltext - {\ctxlua{structures.references.getcurrentmetadata("name")}} + {\ctxcommand{getcurrentreferencemetadata("name")}} % \starttext % \definereferenceformat[inxx] [left=(,right=),text=txt] @@ -1144,7 +1146,7 @@ \attribute\referenceattribute\attributeunsetvalue \global\lastsavedreferenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.inject("\referenceprefix","#label",\number\ht\strutbox,\number\dp\strutbox,\extrareferencearguments)}% + \ctxcommand{injectreference("\referenceprefix","#label",\number\ht\strutbox,\number\dp\strutbox,\extrareferencearguments)}% \setlocationattributes \setstrut % can be option \global\lastsavedreferenceattribute\lastreferenceattribute @@ -1163,7 +1165,7 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.inject("\referenceprefix","#label",\number\dimexpr\interactionparameter\c!height\relax,\number\dimexpr\interactionparameter\c!depth\relax,\extrareferencearguments)}% + \ctxcommand{injectreference("\referenceprefix","#label",\number\dimexpr\interactionparameter\c!height\relax,\number\dimexpr\interactionparameter\c!depth\relax,\extrareferencearguments)}% \setlocationattributes \attribute\referenceattribute\lastreferenceattribute \global\lastsavedreferenceattribute\lastreferenceattribute @@ -1182,9 +1184,9 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.doifelse("\referenceprefix","#label",\extrareferencearguments)}% + \ctxcommand{doifelsereference("\referenceprefix","#label",\extrareferencearguments)}% {\expandtexincurrentreference - \ctxlua{structures.references.injectcurrentset(\number\ht\strutbox,\number\dp\strutbox)}% + \ctxcommand{injectcurrentreference(\number\ht\strutbox,\number\dp\strutbox)}% \setlocationattributes \setstrut % can be option \global\lastsavedreferenceattribute\lastreferenceattribute @@ -1205,9 +1207,9 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.doifelse("\referenceprefix","#label",\extrareferencearguments)}% + \ctxcommand{doifelsereference("\referenceprefix","#label",\extrareferencearguments)}% {\expandtexincurrentreference - \ctxlua{structures.references.injectcurrentset(\number\dimexpr\interactionparameter\c!height\relax,\number\dimexpr\interactionparameter\c!depth\relax)}% + \ctxcommand{injectcurrentreference(\number\dimexpr\interactionparameter\c!height\relax,\number\dimexpr\interactionparameter\c!depth\relax)}% \setlocationattributes \global\lastsavedreferenceattribute\lastreferenceattribute \attribute\referenceattribute\lastreferenceattribute @@ -1226,7 +1228,7 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.inject("\referenceprefix","#label",nil,nil,\extrareferencearguments)}% + \ctxcommand{injectreference("\referenceprefix","#label",nil,nil,\extrareferencearguments)}% \setlocationattributes \global\lastsavedreferenceattribute\lastreferenceattribute \dostarttagged\t!link\empty @@ -1243,7 +1245,7 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.inject("\referenceprefix","#label",nil,nil,\extrareferencearguments)}% + \ctxcommand{injectreference("\referenceprefix","#label",nil,nil,\extrareferencearguments)}% \setlocationcolorspec{#resolver}% no consequence for strut \global\lastsavedreferenceattribute\lastreferenceattribute \dostarttagged\t!link\empty @@ -1260,7 +1262,7 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.inject("\referenceprefix","#label",nil,nil,\extrareferencearguments)}% + \ctxcommand{injectreference("\referenceprefix","#label",nil,nil,\extrareferencearguments)}% \global\lastsavedreferenceattribute\lastreferenceattribute \dostarttagged\t!link\empty \hbox attr \referenceattribute \lastreferenceattribute {#content}% @@ -1276,9 +1278,9 @@ \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue \iflocation - \ctxlua{structures.references.doifelse("\referenceprefix","#label",\extrareferencearguments)}% + \ctxcommand{doifelsereference("\referenceprefix","#label",\extrareferencearguments)}% {\expandtexincurrentreference - \ctxlua{structures.references.injectcurrentset(nil,nil)}% + \ctxcommand{injectcurrentreference(nil,nil)}% \setlocationattributes \global\lastsavedreferenceattribute\lastreferenceattribute \dostarttagged\t!link\empty @@ -1298,8 +1300,8 @@ \ht\scratchbox#height% \global\lastsavedreferenceattribute\attributeunsetvalue \attribute\referenceattribute\attributeunsetvalue - \ctxlua{structures.references.doifelse("\referenceprefix","#label",\extrareferencearguments)}% - {\ctxlua{structures.references.injectcurrentset(nil,nil)}% + \ctxcommand{doifelsereference("\referenceprefix","#label",\extrareferencearguments)}% + {\ctxcommand{injectcurrentreference(nil,nil)}% \global\lastsavedreferenceattribute\lastreferenceattribute \hbox attr \referenceattribute \lastreferenceattribute {\box\scratchbox}} {\box\scratchbox}% @@ -1425,7 +1427,7 @@ \def\strc_references_do_special_from[#label]% {\dontleavehmode - \goto{\ctxlua{structures.references.from("#label")}}[fileorurl(#label)]} + \goto{\ctxcommand{from("#label")}}[fileorurl(#label)]} \def\dofromurldescription#content% called at the lua end {#content} @@ -1470,14 +1472,14 @@ {\dotripleargument\strc_references_define_program} \def\strc_references_define_program[#name][#program][#description]% - {\ctxlua{structures.references.programs.define("#name","#program","#description")}} + {\ctxcommand{defineprogram("#name","#program","#description")}} \def\program[#name]% incompatible, more consistent, hardy used anyway {\dontleavehmode \begingroup \dousestyleparameter\@@prstyle \dousecolorparameter\@@prcolor - \ctxlua{structures.references.programs.get("#name","\@@pralternative","\@@prspace")}% + \ctxcommand{getprogram("#name","\@@pralternative","\@@prspace")}% \endgroup} %D As we can see, we directly use the special reference @@ -1571,7 +1573,11 @@ \setbox\scratchbox\hbox{#text}% to be solved some day \ifdim\wd\scratchbox>\zeropoint \unhbox\scratchbox - \doifsomething\@@rfseparator{\removeunwantedspaces\@@rfseparator}% remove is new + \edef\p_separator{\referencingparameter\c!separator}% + \ifx\p_separator\empty \else + \removeunwantedspaces % remove is new + \p_separator + \fi \else \unhbox\scratchbox \fi @@ -1699,7 +1705,9 @@ % todo: parameterhandler -\def\getreferencestructureprefix#kind#name#category% +\installcorenamespace{referencingprefix} + +\def\getreferencestructureprefix#kind#name#category% name will change {{ prefix = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefix", separatorset = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixseparatorset", @@ -1715,22 +1723,22 @@ \def\strc_references_setup_reference_structure_prefix[#kind][#category][#settings]% {\ifthirdargument - \getparameters[\??rf:\c!prefix:#kind:#category][#settings]% + \getparameters[\??referencingprefix#kind:#category][#settings]% \else\ifsecondargument - \getparameters[\??rf:\c!prefix::#kind][#category]% + \getparameters[\??referencingprefix:#kind][#category]% \fi\fi} \def\referencestructureprefixparameter#kind#name#category#parameter% - {\ifcsname\??rf:\c!prefix:#name:#category#parameter\endcsname - \csname\??rf:\c!prefix:#name:#category#parameter\endcsname - \else\ifcsname\??rf:\c!prefix:#kind:#category#parameter\endcsname - \csname \??rf:\c!prefix:#kind:#category#parameter\endcsname - \else\ifcsname\??rf:\c!prefix::#category#parameter\endcsname - \csname \??rf:\c!prefix::#category#parameter\endcsname + {\ifcsname\??referencingprefix#name:#category#parameter\endcsname + \csname\??referencingprefix#name:#category#parameter\endcsname + \else\ifcsname\??referencingprefix#kind:#category#parameter\endcsname + \csname \??referencingprefix#kind:#category#parameter\endcsname + \else\ifcsname\??referencingprefix:#category#parameter\endcsname + \csname \??referencingprefix:#category#parameter\endcsname \fi\fi\fi} \def\currentreferencedefault - {\ctxlua{structures.references.filter("default",\ctxlua{structures.references.getcurrentprefixspec("\v!default")})}} + {\ctxcommand{filterdefaultreference()}} %D Not all support is visible by looking at the \TEX\ code; here is one of those:^ %D diff --git a/tex/context/base/strc-sbe.mkiv b/tex/context/base/strc-sbe.mkiv index 460a5f0e1..4ea08b30c 100644 --- a/tex/context/base/strc-sbe.mkiv +++ b/tex/context/base/strc-sbe.mkiv @@ -27,78 +27,76 @@ % \chapter{second} \section{alpha} test \section{beta} test \page % \stopbodymatter % optional -\unexpanded\def\definesectionblock{\dotripleargument\dodefinesectionblock} -\unexpanded\def\setupsectionblock {\dodoubleargument\dosetupsectionblock} -\unexpanded\def\setsectionblock {\dosingleargument\dosetsectionblock} - -\def\sectionblockparameter#1% - {\csname - \ifcsname\??sb\currentsectionblock#1\endcsname\??sb\currentsectionblock#1\else\s!empty\fi - \endcsname} - -\newtoks \everybeforesectionblock -\newtoks \everyaftersectionblock - -\def\dodefinesectionblock[#1][#2][#3]% singular plural settings - {\getparameters - [\??sb#1] - [\c!number=\v!yes, - \c!page=\v!right, % anders worden marks te vroeg gereset ! - #3]% - \expandafter\newif\csname if#2\endcsname % better a mode - \setsectionblockenvironment{#1}\empty - \setvalue {\e!start#2}{\startsectionblock[#1]}% - \setvalue {\e!stop #2}{\stopsectionblock}} +\installcorenamespace{sectionblock} + +\installcommandhandler \??sectionblock {sectionblock} \??sectionblock + +\setupsectionblock + [\c!number=\v!yes, + \c!page=\v!right] % otherwise marks are reset too soon + +\newtoks\everybeforesectionblock +\newtoks\everyaftersectionblock + +\let\strc_sectionblock_define_normal\definesectionblock + +\unexpanded\def\definesectionblock + {\dotripleargument\strc_sectionblock_define} + +\def\strc_sectionblock_define[#1][#2][#3]% singular plural settings + {\strc_sectionblock_define_normal[#1][#3]% + \expandafter\newif\csname if#2\endcsname % obsolete + \strc_sectionblock_set_environment{#1}\empty + \setuvalue{\e!start#2}{\startsectionblock[#1]}% + \setuvalue{\e!stop #2}{\stopsectionblock}} \ifdefined \resetallstructuremarks \else \let\resetallstructuremarks\relax \fi +\def\strc_sectionblock_handle_page + {\edef\p_strc_sectionblock_page{\sectionblockparameter\c!page}% + \ifx\p_strc_sectionblock_page\empty \else + \page[\p_strc_sectionblock_page]% + \fi} + \appendtoks - \doifsomething{\sectionblockparameter\c!page}{\page[\sectionblockparameter\c!page]}% + \strc_sectionblock_handle_page \resetallstructuremarks - \getsectionblockenvironment\currentsectionblock + \strc_sectionblock_get_environment\currentsectionblock \sectionblockparameter\c!before % don't move \dostarttagged\t!division\currentsectionblock \to \everybeforesectionblock \appendtoks \sectionblockparameter\c!after % don't move - \doifsomething{\sectionblockparameter\c!page}{\page[\sectionblockparameter\c!page]}% + \strc_sectionblock_handle_page \dostoptagged \resetallstructuremarks \to \everyaftersectionblock -\def\dosetupsectionblock[#1]% - {\getparameters[\??sb#1]}% [#2] +\unexpanded\def\setsectionblock + {\dosingleargument\strc_sectionblock_set} -\def\dosetsectionblock[#1]% used to set the default - {\edef\currentsectionblock{\ctxlua{structures.sections.setblock("#1")}}} +\def\strc_sectionblock_set[#1]% used to set the default + {\edef\currentsectionblock{\ctxcommand{setsectionblock("#1")}}} \let\currentsectionblock\empty % was \s!unknown \unexpanded\def\startsectionblock[#1]% {%\ctxlua{structures.counters.check(0)}% we assume sane usage of \page, as this is the only workable place (in push) \begingroup - \edef\currentsectionblock{\ctxlua{structures.sections.pushblock("#1")}}% - \csname #1true\endcsname % for old times sake + \edef\currentsectionblock{\ctxcommand{pushsectionblock("#1")}}% + \csname #1true\endcsname % obsolete \setsystemmode\currentsectionblock \the\everybeforesectionblock\relax \showmessage\m!structures1\currentsectionblock} \unexpanded\def\stopsectionblock - {\showmessage\m!structures2\currentsectionblock - \the\everyaftersectionblock\relax - \edef\currentsectionblock{\ctxlua{structures.sections.popblock()}}% - \endgroup} - -\long\def\setsectionblockenvironment#1#2% - {\long\setvalue{\??sb\s!do#1}{\do{#2}}} - -\def\getsectionblockenvironment#1% - {\let\do\firstofoneargument - %\sectionblockparameter{\s!do#1}} - \csname\??sb\s!do#1\endcsname} + {\showmessage\m!structures2\currentsectionblock + \the\everyaftersectionblock\relax + \edef\currentsectionblock{\ctxcommand{popsectionblock()}}% + \endgroup} %D \starttyping %D \startsectionblockenvironment[frontpart] @@ -120,10 +118,20 @@ %D \stoptext %D \stoptyping -\setvalue{\e!start\v!sectionblockenvironment}% - {\dosingleargument\dostartsectionblockenvironment} +\installcorenamespace{sectionblockenvironment} + +\unexpanded\def\strc_sectionblock_set_environment#1#2% + {\setvalue{\??sectionblockenvironment#1}{#2}} + +\unexpanded\def\strc_sectionblock_get_environment#1% + {\csname\??sectionblockenvironment#1\endcsname} + +\unexpanded\setvalue{\e!start\v!sectionblockenvironment}% + {\dosingleargument\strc_sectionblock_environment_start} + +\letvalue{\e!stop\v!sectionblockenvironment}\relax -\def\dostartsectionblockenvironment[#1]% evt \pushendofline \popendofline - {\grabuntil{\e!stop\v!sectionblockenvironment}{\setsectionblockenvironment{#1}}} +\def\strc_sectionblock_environment_start[#1]% evt \pushendofline \popendofline + {\grabuntil{\e!stop\v!sectionblockenvironment}{\strc_sectionblock_set_environment{#1}}} \protect \endinput diff --git a/tex/context/base/tabl-ntb.mkiv b/tex/context/base/tabl-ntb.mkiv index 86b1baec9..52cc09096 100644 --- a/tex/context/base/tabl-ntb.mkiv +++ b/tex/context/base/tabl-ntb.mkiv @@ -122,10 +122,11 @@ \newcount\c_tabl_ntb_current_row_four \newcount\c_tabl_ntb_current_col_four -\newcount\c_tabl_maximum_row -\newcount\c_tabl_maximum_col -\newcount\c_tabl_maximum_row_span -\newcount\c_tabl_maximum_col_span +\newcount\c_tabl_ntb_running_col +\newcount\c_tabl_ntb_maximum_row +\newcount\c_tabl_ntb_maximum_col +\newcount\c_tabl_ntb_maximum_row_span +\newcount\c_tabl_ntb_maximum_col_span \newtoks\t_tabl_ntb \newtoks\t_tabl_ntb_row @@ -319,32 +320,6 @@ \doubleexpandafter\tabl_ntb_setup_one \fi\fi} -% \def\tabl_ntb_setup_three[#1][#2][#3]% -% {\processaction -% [#1] -% [ \v!row=>{\tabl_ntb_setup_xy[\c!y][#2][#3]},% -% \v!column=>{\tabl_ntb_setup_xy[\c!x][#2][#3]},% -% r=>{\tabl_ntb_setup_xy[\c!y][#2][#3]},% -% c=>{\tabl_ntb_setup_xy[\c!x][#2][#3]},% -% y=>{\tabl_ntb_setup_xy[\c!y][#2][#3]},% -% x=>{\tabl_ntb_setup_xy[\c!x][#2][#3]},% -% \v!start=>{\tabl_ntb_setup_xy[#1][#2][#3]},% -% \v!header=>{\tabl_ntb_setup_xy[#1][#2][#3]},% -% \s!unknown=>{\tabl_ntb_setup_un[#1][#2][#3]}]} - -% \def\tabl_ntb_setup_two[#1][#2][#3]% -% {\processaction -% [#1] -% [ \v!row=>{\tabl_ntb_setup_xy[\c!y][\v!each][#2]},% -% \v!column=>{\tabl_ntb_setup_xy[\c!x][\v!each][#2]},% -% r=>{\tabl_ntb_setup_xy[\c!y][\v!each][#2]},% -% c=>{\tabl_ntb_setup_xy[\c!x][\v!each][#2]},% -% y=>{\tabl_ntb_setup_xy[\c!y][\v!each][#2]},% -% x=>{\tabl_ntb_setup_xy[\c!x][\v!each][#2]},% -% \v!start=>{\tabl_ntb_setup_xy[#1][\v!each][#2]},% -% \v!header=>{\tabl_ntb_setup_xy[#1][\v!each][#2]},% -% \s!unknown=>{\tabl_ntb_setup_xy[\c!x][#1][#2]}]} - \def\tabl_ntb_setup_one[#1][#2][#3]% {\setupcurrentnaturaltablelocal[#1]} @@ -474,8 +449,8 @@ {\tabl_ntb_setup_section % already forgotten \edef\m_tabl_ntb_positive_row{\number#1}% \edef\m_tabl_ntb_positive_col{\number#2}% - \edef\m_tabl_ntb_negative_row{\the\numexpr-\c_tabl_maximum_row+#1+\minusone\relax}% - \edef\m_tabl_ntb_negative_col{\the\numexpr-\c_tabl_maximum_col+#2+\minusone\relax}% + \edef\m_tabl_ntb_negative_row{\the\numexpr-\c_tabl_ntb_maximum_row+#1+\minusone\relax}% + \edef\m_tabl_ntb_negative_col{\the\numexpr-\c_tabl_ntb_maximum_col+#2+\minusone\relax}% % saves tokens (no speed gain) \edef\m_tabl_ntb_prefix{\??naturaltableset\m_tabl_tbl_level:}% % each each @@ -504,40 +479,40 @@ \csname\m_tabl_ntb_prefix\c!x\v!first\endcsname \ifcsname\m_tabl_ntb_prefix\c!x\v!first\c!y\m_tabl_ntb_positive_row\endcsname\csname\m_tabl_ntb_prefix\c!x\v!first\c!y\m_tabl_ntb_positive_row\endcsname\fi \fi - \ifnum\m_tabl_ntb_positive_row=\c_tabl_maximum_row\relax + \ifnum\m_tabl_ntb_positive_row=\c_tabl_ntb_maximum_row\relax \csname\m_tabl_ntb_prefix\c!y\v!last\endcsname \ifcsname\m_tabl_ntb_prefix\c!x\m_tabl_ntb_positive_col\c!y\v!last\endcsname\csname\m_tabl_ntb_prefix\c!x\m_tabl_ntb_positive_col\c!y\v!last\endcsname\fi \fi - \ifnum\m_tabl_ntb_positive_col=\c_tabl_maximum_col\relax + \ifnum\m_tabl_ntb_positive_col=\c_tabl_ntb_maximum_col\relax \csname\m_tabl_ntb_prefix\c!x\v!last\endcsname \ifcsname\m_tabl_ntb_prefix\c!x\v!last\c!y\m_tabl_ntb_positive_row\endcsname\csname\m_tabl_ntb_prefix\c!x\v!last\c!y\m_tabl_ntb_positive_row\endcsname\fi \fi - \ifnum\m_tabl_ntb_positive_row=\c_tabl_maximum_row\relax \ifnum\m_tabl_ntb_positive_col=\c_tabl_maximum_col\relax + \ifnum\m_tabl_ntb_positive_row=\c_tabl_ntb_maximum_row\relax \ifnum\m_tabl_ntb_positive_col=\c_tabl_ntb_maximum_col\relax \csname\m_tabl_ntb_prefix\c!x\v!last\c!y\v!last\endcsname \fi\fi \ifnum\m_tabl_ntb_positive_row=\plusone \ifnum\m_tabl_ntb_positive_col=\plusone \csname\m_tabl_ntb_prefix\c!x\v!first\c!y\v!first\endcsname \fi\fi - \ifnum\m_tabl_ntb_positive_row=\plusone \ifnum\m_tabl_ntb_positive_col=\c_tabl_maximum_col\relax + \ifnum\m_tabl_ntb_positive_row=\plusone \ifnum\m_tabl_ntb_positive_col=\c_tabl_ntb_maximum_col\relax \csname\m_tabl_ntb_prefix\c!x\v!last\c!y\v!first\endcsname \fi\fi - \ifnum\m_tabl_ntb_positive_row=\c_tabl_maximum_row\relax \ifnum\m_tabl_ntb_positive_col=\plusone + \ifnum\m_tabl_ntb_positive_row=\c_tabl_ntb_maximum_row\relax \ifnum\m_tabl_ntb_positive_col=\plusone \csname\m_tabl_ntb_prefix\c!x\v!first\c!y\v!last\endcsname \fi\fi % special case: two rows and last row : two&first and two&last (round corners) - \ifnum\c_tabl_maximum_row=\plustwo\relax - \ifnum\m_tabl_ntb_positive_row=\c_tabl_maximum_row\relax \ifnum\m_tabl_ntb_positive_col=\plusone + \ifnum\c_tabl_ntb_maximum_row=\plustwo\relax + \ifnum\m_tabl_ntb_positive_row=\c_tabl_ntb_maximum_row\relax \ifnum\m_tabl_ntb_positive_col=\plusone \csname\m_tabl_ntb_prefix\c!x\v!first\c!y\v!two\endcsname \fi\fi - \ifnum\m_tabl_ntb_positive_row=\c_tabl_maximum_row\relax \ifnum\m_tabl_ntb_positive_col=\c_tabl_maximum_col\relax + \ifnum\m_tabl_ntb_positive_row=\c_tabl_ntb_maximum_row\relax \ifnum\m_tabl_ntb_positive_col=\c_tabl_ntb_maximum_col\relax \csname\m_tabl_ntb_prefix\c!x\v!last\c!y\v!two\endcsname \fi\fi \fi - \ifnum\tabl_ntb_get_col\m_tabl_ntb_positive_row\m_tabl_ntb_positive_col=\c_tabl_maximum_col\relax % top span over whole width + \ifnum\tabl_ntb_get_col\m_tabl_ntb_positive_row\m_tabl_ntb_positive_col=\c_tabl_ntb_maximum_col\relax % top span over whole width \ifnum\m_tabl_ntb_positive_row=\plusone \csname\m_tabl_ntb_prefix\c!x\v!one\c!y\v!first\endcsname \fi - \ifnum\m_tabl_ntb_positive_row=\c_tabl_maximum_row\relax + \ifnum\m_tabl_ntb_positive_row=\c_tabl_ntb_maximum_row\relax \csname\m_tabl_ntb_prefix\c!x\v!one\c!y\v!last\endcsname \fi \fi @@ -579,8 +554,8 @@ % \eTABLE \unexpanded\def\tabl_ntb_tr - {\c_tabl_ntb_current_col\zerocount - \advance\c_tabl_maximum_row\plusone + {\c_tabl_ntb_running_col\zerocount + \advance\c_tabl_ntb_maximum_row\plusone \iffirstargument \expandafter\tabl_ntb_tr_yes \else @@ -588,13 +563,11 @@ \fi} \def\tabl_ntb_tr_yes[#1]% - {\setvalue{\??naturaltableset\m_tabl_tbl_level:\c!y++\the\c_tabl_maximum_row}{\setupcurrentnaturaltablelocal[#1]}} + {\setvalue{\??naturaltableset\m_tabl_tbl_level:\c!y++\the\c_tabl_ntb_maximum_row}{\setupcurrentnaturaltablelocal[#1]}} \def\m_tabl_ntb_default_nr{\naturaltableparameter\c!nr} \def\m_tabl_ntb_default_nc{\naturaltableparameter\c!nc} -% \naturaltableparameter\c!action => \empty (brr, only needed for nesting) - \unexpanded\def\tabl_ntb_td {\iffirstargument \expandafter\tabl_ntb_td_yes @@ -607,30 +580,30 @@ \letnaturaltableparameter\c!nx \m_tabl_ntb_default_nc \letnaturaltableparameter\c!nc \plusone \letnaturaltableparameter\c!nr \plusone - \letnaturaltableparameter\c!n \c_tabl_ntb_current_col + \letnaturaltableparameter\c!n \c_tabl_ntb_running_col \letnaturaltableparameter\c!m \empty - \letnaturaltableparameter\c!action\empty + \letnaturaltableparameter\c!action\empty % not that important \setupcurrentnaturaltable[#1]% % \c_tabl_ntb_nx\naturaltableparameter\c!nx\relax \c_tabl_ntb_ny\naturaltableparameter\c!ny\relax - % goto first cell % NEW, n/m=cellnumber + % goto first cell n/m=cellnumber \edef\m_tabl_ntb_n{\naturaltableparameter\c!n}% \edef\m_tabl_ntb_m{\naturaltableparameter\c!m}% % \ifx\m_tabl_ntb_n\empty \global\advance\c_tabl_ntb_spn\c_tabl_ntb_nx\relax - \else\ifnum\m_tabl_ntb_n=\c_tabl_ntb_current_col\else + \else\ifnum\m_tabl_ntb_n=\c_tabl_ntb_running_col\else \tabl_ntb_td_pass_n{#1}% \fi\fi \ifx\m_tabl_ntb_m\empty \else - \ifnum\m_tabl_ntb_m=\c_tabl_ntb_current_col \else + \ifnum\m_tabl_ntb_m=\c_tabl_ntb_running_col\else \tabl_ntb_td_pass_m{#1}% \fi \fi \doloop % skip over columns that result from earlier span - {\advance\c_tabl_ntb_current_col\plusone - \ifcsname\tabl_ntb_tag_pattern\c_tabl_maximum_row\c_tabl_ntb_current_col\endcsname \else + {\advance\c_tabl_ntb_running_col\plusone + \ifcsname\tabl_ntb_tag_pattern\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col\endcsname \else \exitloop \fi}% % fill r*c cells and set span @@ -638,8 +611,8 @@ \c_tabl_ntb_ny\naturaltableparameter\c!ny\relax \ifnum\c_tabl_ntb_nx=\plusone \ifnum\c_tabl_ntb_ny=\plusone - \ifnum\c_tabl_ntb_current_col>\c_tabl_maximum_col\relax - \c_tabl_maximum_col\c_tabl_ntb_current_col + \ifnum\c_tabl_ntb_running_col>\c_tabl_ntb_maximum_col\relax + \c_tabl_ntb_maximum_col\c_tabl_ntb_running_col \fi \else \tabl_ntb_cell_preset @@ -648,38 +621,38 @@ \tabl_ntb_cell_preset \fi % set values - \tabl_ntb_let_tag\c_tabl_maximum_row\c_tabl_ntb_current_col\c_tabl_ntb_cell - \tabl_ntb_set_col\c_tabl_maximum_row\c_tabl_ntb_current_col{\the\c_tabl_ntb_nx}% - \tabl_ntb_set_row\c_tabl_maximum_row\c_tabl_ntb_current_col{\the\c_tabl_ntb_ny}% + \tabl_ntb_let_tag\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col\c_tabl_ntb_cell + \tabl_ntb_set_col\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\the\c_tabl_ntb_nx}% + \tabl_ntb_set_row\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\the\c_tabl_ntb_ny}% % the action key will change! - \tabl_ntb_set_ref\c_tabl_maximum_row\c_tabl_ntb_current_col{\naturaltableparameter\c!action}% + \tabl_ntb_set_ref\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\naturaltableparameter\c!action}% % save text \normalexpanded - {\tabl_ntb_set_txt_process\c_tabl_maximum_row\c_tabl_ntb_current_col{\the\c_tabl_maximum_row}{\the\c_tabl_ntb_current_col}}% + {\tabl_ntb_set_txt_process\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\the\c_tabl_ntb_maximum_row}{\the\c_tabl_ntb_running_col}}% {#1}{#2}} \def\tabl_ntb_td_nop[#1]#2\eTD {\global\advance\c_tabl_ntb_spn\plusone\relax \doloop - {\advance\c_tabl_ntb_current_col\plusone - \ifcsname\tabl_ntb_tag_pattern\c_tabl_maximum_row\c_tabl_ntb_current_col\endcsname \else + {\advance\c_tabl_ntb_running_col\plusone + \ifcsname\tabl_ntb_tag_pattern\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col\endcsname \else \exitloop \fi}% \c_tabl_ntb_nx\plusone \c_tabl_ntb_ny\plusone - \ifnum\c_tabl_ntb_current_col>\c_tabl_maximum_col\relax - \c_tabl_maximum_col\c_tabl_ntb_current_col + \ifnum\c_tabl_ntb_running_col>\c_tabl_ntb_maximum_col\relax + \c_tabl_ntb_maximum_col\c_tabl_ntb_running_col \fi - \tabl_ntb_let_tag\c_tabl_maximum_row\c_tabl_ntb_current_col\c_tabl_ntb_cell - \tabl_ntb_set_col\c_tabl_maximum_row\c_tabl_ntb_current_col{\the\c_tabl_ntb_nx}% - \tabl_ntb_set_row\c_tabl_maximum_row\c_tabl_ntb_current_col{\the\c_tabl_ntb_ny}% - \tabl_ntb_let_ref\c_tabl_maximum_row\c_tabl_ntb_current_col\empty + \tabl_ntb_let_tag\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col\c_tabl_ntb_cell + \tabl_ntb_set_col\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\the\c_tabl_ntb_nx}% + \tabl_ntb_set_row\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\the\c_tabl_ntb_ny}% + \tabl_ntb_let_ref\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col\empty \normalexpanded - {\tabl_ntb_set_txt_process\c_tabl_maximum_row\c_tabl_ntb_current_col{\the\c_tabl_maximum_row}{\the\c_tabl_ntb_current_col}}% + {\tabl_ntb_set_txt_process\c_tabl_ntb_maximum_row\c_tabl_ntb_running_col{\the\c_tabl_ntb_maximum_row}{\the\c_tabl_ntb_running_col}}% {#1}{#2}} \def\tabl_ntb_td_pass_n#1% - {\scratchcounter\numexpr\m_tabl_ntb_n-\c_tabl_ntb_current_col+\minusone-\c_tabl_ntb_spn\relax + {\scratchcounter\numexpr\m_tabl_ntb_n-\c_tabl_ntb_running_col+\minusone-\c_tabl_ntb_spn\relax \ifnum\scratchcounter>\zerocount \normalexpanded{\tabl_ntb_td[\c!nx=\the\scratchcounter,\c!n=,\c!m=,*sq=\v!no]}\eTD \fi @@ -692,7 +665,7 @@ \letnaturaltableparameter\c!m \empty} \def\tabl_ntb_td_pass_m#1% - {\scratchcounter\numexpr\m_tabl_ntb_m-\c_tabl_ntb_current_col+\minusone-\c_tabl_ntb_spn\relax + {\scratchcounter\numexpr\m_tabl_ntb_m-\c_tabl_ntb_running_col+\minusone-\c_tabl_ntb_spn\relax \dorecurse\scratchcounter{\normalexpanded{\tabl_ntb_td[\c!n=,\c!m=]}\eTD}% % can be sped up \letnaturaltableparameter\c!ny\m_tabl_ntb_default_nr @@ -704,20 +677,20 @@ \letnaturaltableparameter\c!m \empty} \def\tabl_ntb_cell_preset - {\c_tabl_ntb_current_row\c_tabl_maximum_row - \c_tabl_ntb_current_col\c_tabl_ntb_current_col + {\c_tabl_ntb_current_row\c_tabl_ntb_maximum_row + \c_tabl_ntb_current_col\c_tabl_ntb_running_col \dorecurse\c_tabl_ntb_ny\tabl_ntb_cell_preset_rows % check max column \advance\c_tabl_ntb_current_col\minusone - \ifnum\c_tabl_ntb_current_col>\c_tabl_maximum_col\relax - \c_tabl_maximum_col\c_tabl_ntb_current_col + \ifnum\c_tabl_ntb_current_col>\c_tabl_ntb_maximum_col\relax + \c_tabl_ntb_maximum_col\c_tabl_ntb_current_col \fi} \def\tabl_ntb_cell_preset_rows - {\c_tabl_ntb_current_col\c_tabl_ntb_current_col + {\c_tabl_ntb_current_col\c_tabl_ntb_running_col \tabl_ntb_set_col\c_tabl_ntb_current_row\c_tabl_ntb_current_col{\the\c_tabl_ntb_nx}% - \ifnum\c_tabl_ntb_nx>\c_tabl_maximum_row_span\relax - \c_tabl_maximum_row_span\c_tabl_ntb_nx + \ifnum\c_tabl_ntb_nx>\c_tabl_ntb_maximum_row_span\relax + \c_tabl_ntb_maximum_row_span\c_tabl_ntb_nx \fi \dorecurse\c_tabl_ntb_nx\tabl_ntb_cell_preset_cells \advance\c_tabl_ntb_current_row\plusone} @@ -872,10 +845,10 @@ [\v!stretch=>\autoTBLspreadtrue]% \linewidth\naturaltablelocalparameter\c!rulethickness % needs to be frozen \dontcomplain - \c_tabl_ntb_current_col\zerocount - \c_tabl_maximum_row_span\plusone - \c_tabl_maximum_col\zerocount - \c_tabl_maximum_row\zerocount + \c_tabl_ntb_running_col \zerocount + \c_tabl_ntb_maximum_col \zerocount + \c_tabl_ntb_maximum_row \zerocount + \c_tabl_ntb_maximum_row_span\plusone \let\bTR\dobTR \let\bTD\dobTD \let\bTH\dobTH @@ -897,12 +870,12 @@ {% tricky and dirty order -) \doifsometokselse\t_tabl_ntb_head % slow, better a flag {\the\t_tabl_ntb_head - \c_tabl_ntb_n_of_head_lines\c_tabl_maximum_row\relax + \c_tabl_ntb_n_of_head_lines\c_tabl_ntb_maximum_row\relax \doifsometokselse\t_tabl_ntb_next {\the\t_tabl_ntb_next - \c_tabl_ntb_n_of_next_lines\numexpr\c_tabl_maximum_row-\c_tabl_ntb_n_of_head_lines\relax}% + \c_tabl_ntb_n_of_next_lines\numexpr\c_tabl_ntb_maximum_row-\c_tabl_ntb_n_of_head_lines\relax}% {\c_tabl_ntb_n_of_next_lines\zerocount}% was 1 - \c_tabl_ntb_n_of_hdnx_lines\c_tabl_maximum_row} + \c_tabl_ntb_n_of_hdnx_lines\c_tabl_ntb_maximum_row} {\c_tabl_ntb_n_of_head_lines\zerocount % was 1 \c_tabl_ntb_n_of_next_lines\zerocount \c_tabl_ntb_n_of_hdnx_lines\zerocount}% @@ -914,13 +887,13 @@ % to be sure \tabl_ntb_loop_two % check and do - \ifcase\c_tabl_maximum_col\else + \ifcase\c_tabl_ntb_maximum_col\else \startTBLprocessing \tabl_ntb_table_start - \dorecurse\c_tabl_maximum_row + \dorecurse\c_tabl_ntb_maximum_row {\tabl_ntb_row_start \c_tabl_ntb_current_row\recurselevel\relax - \dorecurse\c_tabl_maximum_col + \dorecurse\c_tabl_ntb_maximum_col {\c_tabl_ntb_current_col\recurselevel\relax \normalexpanded{\tabl_ntb_cell{\the\c_tabl_ntb_current_row}{\the\c_tabl_ntb_current_col}}}% \tabl_ntb_row_stop}% @@ -935,9 +908,9 @@ % tracing % \iftrue % \blank \tttf - % \dorecurse\c_tabl_maximum_row + % \dorecurse\c_tabl_ntb_maximum_row % {\c_tabl_ntb_current_row\recurselevel\relax - % \dorecurse\c_tabl_maximum_col + % \dorecurse\c_tabl_ntb_maximum_col % {\c_tabl_ntb_current_col\recurselevel\relax % [r=\the\c_tabl_ntb_current_row,c=\the\c_tabl_ntb_current_col,h=\the\dimexpr\tabl_ntb_get_ht\c_tabl_ntb_current_row\c_tabl_ntb_current_col,w=\the\dimexpr\tabl_ntb_get_wd\c_tabl_ntb_current_row\c_tabl_ntb_current_col]}% % \par}% @@ -947,11 +920,11 @@ \tabl_ntb_table_pop} \def\tabl_ntb_loop_one - {\dorecurse\c_tabl_maximum_row{\tabl_ntb_loop_one_rows}} + {\dorecurse\c_tabl_ntb_maximum_row{\tabl_ntb_loop_one_rows}} \def\tabl_ntb_loop_one_rows {\c_tabl_ntb_current_row\recurselevel\relax - \dorecurse\c_tabl_maximum_col\tabl_ntb_loop_one_cells} + \dorecurse\c_tabl_ntb_maximum_col\tabl_ntb_loop_one_cells} \def\tabl_ntb_loop_one_cells {\c_tabl_ntb_current_col\recurselevel\relax @@ -970,7 +943,7 @@ \exitloop \else \advance\c_tabl_ntb_current_col_one\plusone - \ifnum\c_tabl_ntb_current_col_one>\c_tabl_maximum_col\relax + \ifnum\c_tabl_ntb_current_col_one>\c_tabl_ntb_maximum_col\relax \exitloop \fi \fi}% @@ -980,12 +953,12 @@ \c_tabl_ntb_current_row_two\c_tabl_ntb_current_row_one \c_tabl_ntb_current_col_two\c_tabl_ntb_current_col_one \advance\c_tabl_ntb_current_row_one\plusone - \ifnum\c_tabl_ntb_current_row_one>\c_tabl_maximum_row + \ifnum\c_tabl_ntb_current_row_one>\c_tabl_ntb_maximum_row \exitloop \fi \fi}% - \ifnum\c_tabl_ntb_current_row_two>\c_tabl_maximum_row\c_tabl_ntb_current_row_two\c_tabl_maximum_row\fi - \ifnum\c_tabl_ntb_current_col_two>\c_tabl_maximum_col\c_tabl_ntb_current_col_two\c_tabl_maximum_col\fi + \ifnum\c_tabl_ntb_current_row_two>\c_tabl_ntb_maximum_row\c_tabl_ntb_current_row_two\c_tabl_ntb_maximum_row\fi + \ifnum\c_tabl_ntb_current_col_two>\c_tabl_ntb_maximum_col\c_tabl_ntb_current_col_two\c_tabl_ntb_maximum_col\fi \c_tabl_ntb_current_row_two\numexpr\c_tabl_ntb_current_row_two-\c_tabl_ntb_current_row+\plusone\relax \c_tabl_ntb_current_col_two\numexpr\c_tabl_ntb_current_col_two-\c_tabl_ntb_current_col+\plusone\relax \c_tabl_ntb_current_row_one\c_tabl_ntb_current_row @@ -1006,16 +979,16 @@ \fi} \def\tabl_ntb_loop_two - {\dorecurse\c_tabl_maximum_row\tabl_ntb_loop_two_rows} + {\dorecurse\c_tabl_ntb_maximum_row\tabl_ntb_loop_two_rows} \def\tabl_ntb_loop_two_rows {\c_tabl_ntb_current_row\recurselevel\relax - \dorecurse\c_tabl_maximum_col\tabl_ntb_loop_two_cells} + \dorecurse\c_tabl_ntb_maximum_col\tabl_ntb_loop_two_cells} \def\tabl_ntb_loop_two_cells {\c_tabl_ntb_current_col\recurselevel\relax \ifcsname\tabl_ntb_row_pattern\c_tabl_ntb_current_row\c_tabl_ntb_current_col\endcsname - \scratchcounter\numexpr\c_tabl_maximum_row-\c_tabl_ntb_current_row+\plusone\relax + \scratchcounter\numexpr\c_tabl_ntb_maximum_row-\c_tabl_ntb_current_row+\plusone\relax \ifnum\tabl_ntb_get_row\c_tabl_ntb_current_row\c_tabl_ntb_current_col>\scratchcounter \tabl_ntb_set_row\c_tabl_ntb_current_row\c_tabl_ntb_current_col{\the\scratchcounter}% \fi @@ -1040,20 +1013,22 @@ \def\tabl_ntb_prelocate_error {\writestatus\m!system{fatal error: use \string\prelocateTBLrows\space to increase table memory (now: \the\c_tabl_prelocated_rows)}} +% \prelocateTBLrows{1000} % may speed up large tables + +\installcorenamespace{naturaltabletok} + \def\prelocateTBLrows#1% we start at zero so we have one to much, better play safe anyway - {\dostepwiserecurse\c_tabl_prelocated_rows{#1}\plusone{\expandafter\newtoks\csname tbl:\recurselevel\endcsname}% - \def\tabl_ntb_row_stop + {\dostepwiserecurse\c_tabl_prelocated_rows{#1}\plusone{\expandafter\newtoks\csname\??naturaltabletok\recurselevel\endcsname}% + \def\tabl_ntb_row_start {\ifnum\c_tabl_ntb_row<\c_tabl_prelocated_rows\relax - \expandafter\let\expandafter\t_tabl_ntb_row\csname tbl:\the\c_tabl_ntb_row\endcsname\t_tabl_ntb_row\emptytoks + \expandafter\let\expandafter\t_tabl_ntb_row\csname\??naturaltabletok\the\c_tabl_ntb_row\endcsname\t_tabl_ntb_row\emptytoks \else \tabl_ntb_prelocate_error \fi}% \def\tabl_ntb_row_stop - {\normalexpanded{\t_tabl_ntb{\the\t_tabl_ntb\noexpand\tabl_ntb_row_align_start\the\csname tbl:\the\c_tabl_ntb_row\endcsname\tabl_ntb_row_align_stop}}}% + {\normalexpanded{\t_tabl_ntb{\the\t_tabl_ntb\noexpand\tabl_ntb_row_align_start\the\csname\??naturaltabletok\the\c_tabl_ntb_row\endcsname\tabl_ntb_row_align_stop}}}% \global\c_tabl_prelocated_rows#1\relax} -% \prelocateTBLrows{1000} % may speed up large tables - % We use aligments to handle the empty (skipped) columns, so % that we don't have to (re|)|calculate these. @@ -1099,7 +1074,7 @@ \bgroup % protect local vars \scratchcounter\numexpr\c_tabl_ntb_row+\plusone\relax \ifnum\scratchcounter>\c_tabl_ntb_n_of_hdnx_lines\relax - \ifnum\scratchcounter<\c_tabl_maximum_row\relax + \ifnum\scratchcounter<\c_tabl_ntb_maximum_row\relax \doifsomething{\naturaltablelocalparameter\c!spaceinbetween} {\blank[\naturaltablelocalparameter\c!spaceinbetween]}% \fi @@ -1119,28 +1094,40 @@ \halign\bgroup \registerparoptions % watch out: tagging the cell happens at the outer level (faster) - \ignorespaces##\unskip&&\ignorespaces##\unskip\cr % one too many + \ignorespaces\alignmark\alignmark\unskip + \aligntab\aligntab + \ignorespaces\alignmark\alignmark\unskip + \cr % one too many \the\t_tabl_ntb \dostoptagged \egroup \dostoptagged} \setvalue{\??naturaltablecell\the\c_tabl_ntb_none}#1#2% - {\tabl_ntb_span{#1}{#2}} + {\scratchcounter\tabl_ntb_get_col{#1}{#2}\relax + \ifnum\scratchcounter>\zerocount + \advance\scratchcounter\minusone + \ifnum\scratchcounter>\zerocount + \tabl_ntb_span + \fi + \t_tabl_ntb_row\expandafter{\the\t_tabl_ntb_row\tabl_ntb_column_next} + \fi} \setvalue{\??naturaltablecell\the\c_tabl_ntb_cell}#1#2% {\t_tabl_ntb_row\expandafter{\the\t_tabl_ntb_row\tabl_ntb_pass #1 #2 }% space delimited -> less tokens - \tabl_ntb_span{#1}{#2}} - -\def\tabl_ntb_span#1#2% - {\scratchcounter\tabl_ntb_get_col{#1}{#2}\relax + \scratchcounter\tabl_ntb_get_col{#1}{#2}\relax \ifnum\scratchcounter>\zerocount - \advance\scratchcounter \minusone - \dorecurse\scratchcounter{\t_tabl_ntb_row\expandafter{\the\t_tabl_ntb_row\tabl_ntb_column_span}}% - \dorecurse\scratchcounter{\t_tabl_ntb_row\expandafter{\the\t_tabl_ntb_row\tabl_ntb_column_skip}}% - \t_tabl_ntb_row\expandafter{\the\t_tabl_ntb_row\tabl_ntb_column_next}% + \advance\scratchcounter\minusone + \ifnum\scratchcounter>\zerocount + \tabl_ntb_span + \fi + \t_tabl_ntb_row\expandafter{\the\t_tabl_ntb_row\tabl_ntb_column_next} \fi} +\def\tabl_ntb_span + {\dorecurse\scratchcounter{\t_tabl_ntb_row\expandafter{\the\t_tabl_ntb_row\tabl_ntb_column_span}}% + \dorecurse\scratchcounter{\t_tabl_ntb_row\expandafter{\the\t_tabl_ntb_row\tabl_ntb_column_skip}}} + \unexpanded\def\tabl_ntb_cell#1#2% {\csname\??naturaltablecell\the\tabl_ntb_get_tag{#1}{#2}\endcsname{#1}{#2}} @@ -1163,7 +1150,7 @@ \tabl_ntb_get_wid\scratchcounter +\naturaltablelocalparameter\c!columndistance \ifnum\recurselevel<\!!counta - \tabl_ntb_get_dis\scratchcounter + +\tabl_ntb_get_dis\scratchcounter \fi \relax \advance\scratchcounter\plusone}% @@ -1184,7 +1171,7 @@ \tablecellcolumns\!!counta % used later so don't adapt these \tablecellrows \!!countb % used later so don't adapt these \d_tabl_ntb_height\zeropoint - \ifnum\!!counta=\c_tabl_maximum_col\relax + \ifnum\!!counta=\c_tabl_ntb_maximum_col\relax % case: nc=maxcolumns \else \scratchcounter#1\relax @@ -1199,8 +1186,13 @@ \d_tabl_ntb_width\zeropoint \scratchcounter\c_tabl_ntb_col \dorecurse\!!counta - {\advance\d_tabl_ntb_width\dimexpr\tabl_ntb_get_wid\scratchcounter+\naturaltablelocalparameter\c!columndistance\relax - \ifnum\recurselevel<\!!counta \advance\d_tabl_ntb_width \tabl_ntb_get_dis\scratchcounter\fi + {\advance\d_tabl_ntb_width\dimexpr + \tabl_ntb_get_wid\scratchcounter + +\naturaltablelocalparameter\c!columndistance + \ifnum\recurselevel<\!!counta + +\tabl_ntb_get_dis\scratchcounter + \fi + \relax \advance\scratchcounter\plusone}% \advance\d_tabl_ntb_width-\naturaltablelocalparameter\c!columndistance\relax % cell @@ -1208,7 +1200,7 @@ \dotagTABLEsignal % maybe we need to add some packaging in this case \tabl_ntb_get_txt{#1}{#2}% \egroup - \ifnum\!!counta=\c_tabl_maximum_col\relax + \ifnum\!!counta=\c_tabl_ntb_maximum_col\relax % case: nc=maxcolumns \else \scratchdimen\tabl_ntb_get_hei{#1}% @@ -1237,23 +1229,23 @@ {\setupcurrentnaturaltablelocal[\c!frame=\v!off,\c!background=,\c!align=\v!no]% \inheritednaturaltablelocalframed{\strut}}% \edef\minimalcellheight{\the\ht\scratchbox}% not used - \dorecurse\c_tabl_maximum_col + \dorecurse\c_tabl_ntb_maximum_col {\tabl_ntb_let_aut\recurselevel\zeropoint % new \c_tabl_ntb_current_col_one\recurselevel\relax - \dorecurse\c_tabl_maximum_row + \dorecurse\c_tabl_ntb_maximum_row {\tabl_ntb_let_wd\recurselevel\c_tabl_ntb_current_col_one\zeropoint \tabl_ntb_let_ht\recurselevel\c_tabl_ntb_current_col_one\zeropoint}% % till here \tabl_ntb_let_wid\recurselevel\zeropoint \tabl_ntb_let_dis\recurselevel\zeropoint}% - \dorecurse\c_tabl_maximum_row + \dorecurse\c_tabl_ntb_maximum_row {\tabl_ntb_let_hei\recurselevel\maxdimen}% \c_tabl_tbl_pass\plusone \let\tabl_ntb_pass\tabl_ntb_pass_one \let\tabl_ntb_cell_process\tabl_ntb_cell_process_a \setbox0\vbox{\settrialtypesetting \tabl_ntb_flush_content}% - \tabl_ntb_let_dis\c_tabl_maximum_col\zeropoint + \tabl_ntb_let_dis\c_tabl_ntb_maximum_col\zeropoint \ifautoTBLspread % experimental, stretch non fixed cells to \hsize \tabl_ntb_check_widths_one % trial run @@ -1268,7 +1260,7 @@ \let\tabl_ntb_cell_process\tabl_ntb_cell_process_b \setbox\scratchbox\vbox{\settrialtypesetting \tabl_ntb_flush_content}% \fi - \else\ifautoTBLrowspan\ifnum\c_tabl_maximum_row_span>1 % max ? + \else\ifautoTBLrowspan\ifnum\c_tabl_ntb_maximum_row_span>1 % max ? % added jan 2002 because nx=* did no longer work \edef\savedhsize{\the\hsize}% \hsize\wd0\relax % new per 17/04/2006 @@ -1297,10 +1289,10 @@ \fi\fi{\tabl_ntb_flush_content}} \def\tabl_ntb_stretch_widths % more variants, e.g. a max to \dimend - {\ifcase\c_tabl_maximum_col\else % else division by zero + {\ifcase\c_tabl_ntb_maximum_col\else % else division by zero \!!dimend\zeropoint \!!dimene\hsize - \dorecurse\c_tabl_maximum_col + \dorecurse\c_tabl_ntb_maximum_col {\advance\!!dimend\dimexpr\tabl_ntb_get_wid\recurselevel+\naturaltablelocalparameter\c!columndistance\relax \advance\!!dimene-\tabl_ntb_get_dis\recurselevel}% \advance\!!dimend\dimexpr-\naturaltablelocalparameter\c!columndistance+\naturaltablelocalparameter\c!leftmargindistance+\naturaltablelocalparameter\c!rightmargindistance\relax @@ -1308,8 +1300,8 @@ \ifdim\!!dimend<\!!dimene \advance\!!dimend-\!!dimene \!!dimend-\!!dimend - \divide\!!dimend\c_tabl_maximum_col - \dorecurse\c_tabl_maximum_col + \divide\!!dimend\c_tabl_ntb_maximum_col + \dorecurse\c_tabl_ntb_maximum_col {\tabl_ntb_set_wid\recurselevel{\the\dimexpr\tabl_ntb_get_wid\recurselevel+\!!dimend\relax}}% \fi \fi} @@ -1377,7 +1369,7 @@ {\iftraceTABLE\tabl_ntb_show_widths{B#1}\fi \!!counta\zerocount \!!dimena\dimexpr\hsize-\naturaltablelocalparameter\c!leftmargindistance-\naturaltablelocalparameter\c!rightmargindistance-\naturaltablelocalparameter\c!columndistance\relax - \dorecurse\c_tabl_maximum_col + \dorecurse\c_tabl_ntb_maximum_col {\scratchdimen\tabl_ntb_get_aut\recurselevel\relax \advance\!!dimena-\tabl_ntb_get_dis\recurselevel\relax \ifdim\scratchdimen>\zeropoint\relax @@ -1398,7 +1390,7 @@ \fi \fi}% \ifcase\!!counta \else \divide\!!dimena \!!counta \fi - \dorecurse\c_tabl_maximum_col + \dorecurse\c_tabl_ntb_maximum_col {\scratchdimen\tabl_ntb_get_wid\recurselevel\relax \ifcase#1\relax \ifdim\scratchdimen<\!!dimena % take natural width @@ -1419,7 +1411,7 @@ \dimen0=\tabl_ntb_get_ht\c_tabl_ntb_current_row_three\c_tabl_ntb_current_col_three % find nearest height in row \dimen2=\zeropoint - \dorecurse\c_tabl_maximum_col + \dorecurse\c_tabl_ntb_maximum_col {\ifnum\recurselevel=\c_tabl_ntb_current_col_three\else \ifcsname\tabl_ntb_row_pattern\c_tabl_ntb_current_row_three\recurselevel\endcsname \!!countc=\tabl_ntb_get_row\c_tabl_ntb_current_row_three\recurselevel\relax @@ -1453,7 +1445,7 @@ \c_tabl_ntb_current_row_four\c_tabl_ntb_current_row_three \tabl_ntb_set_hei\c_tabl_ntb_current_row_three{\the\dimen2}% \dorecurse\!!countb - {\dorecurse\c_tabl_maximum_col + {\dorecurse\c_tabl_ntb_maximum_col {\ifnum\recurselevel=\c_tabl_ntb_current_col_three\else \scratchdimen\dimexpr\tabl_ntb_get_ht\c_tabl_ntb_current_row_four\recurselevel+\dimen0\relax \tabl_ntb_set_ht\c_tabl_ntb_current_row_four\recurselevel{\the\scratchdimen}% @@ -1472,9 +1464,9 @@ \def\tabl_ntb_check_heights_one - {\dorecurse\c_tabl_maximum_row + {\dorecurse\c_tabl_ntb_maximum_row {\c_tabl_ntb_current_row_three\recurselevel\relax - \dorecurse\c_tabl_maximum_col + \dorecurse\c_tabl_ntb_maximum_col {\c_tabl_ntb_current_col_three\recurselevel\relax \ifcsname\tabl_ntb_row_pattern\c_tabl_ntb_current_row_three\c_tabl_ntb_current_col_three\endcsname \tabl_ntb_check_heights_one_indeed @@ -1485,7 +1477,7 @@ \def\tabl_ntb_show_widths#1% {\vbox - {\forgetall\tttf[#1]\dorecurse\c_tabl_maximum_col + {\forgetall\tttf[#1]\dorecurse\c_tabl_ntb_maximum_col {\scratchdimen\tabl_ntb_get_wid\recurselevel\relax [\recurselevel:\the\scratchdimen]}}} @@ -1591,7 +1583,7 @@ \else \scratchdimen\tabl_ntb_get_wid\c_tabl_ntb_col\relax \ifdim\scratchdimen>\zeropoint\relax - \ifnum\tabl_ntb_get_col{#1}{#2}=\c_tabl_maximum_col\relax + \ifnum\tabl_ntb_get_col{#1}{#2}=\c_tabl_ntb_maximum_col\relax \scratchdimen\hsize \fi \fi diff --git a/tex/context/base/tabl-tsp.mkiv b/tex/context/base/tabl-tsp.mkiv index 21182a988..34d3df780 100644 --- a/tex/context/base/tabl-tsp.mkiv +++ b/tex/context/base/tabl-tsp.mkiv @@ -13,8 +13,11 @@ \writestatus{loading}{ConTeXt Table Macros / Splitting} -%D The code in this file is move here from other places and needs -%D a mkiv cleanup. +%D The code in this file is moved here from other places and needs +%D a mkiv cleanup. As it mostly targets at tables the code lives in +%D the tabl and page namespaces. + +% work in progress \unprotect @@ -26,8 +29,6 @@ % \splitfloat [settings] {\placetable[optional args]{test}} {content} -% there is no need for a tracked structure number here - %D When \type {inbetween} is made empty instead of the %D default \type {\page}, we will get delayed flushing %D and text may continue below the graphic. @@ -55,61 +56,81 @@ %D \dorecurse{10}{\input tufte } %D \stoptyping -\newcount\noffloatssplits - -\settrue \onlyonesplitofffloat -\setfalse\somenextsplitofffloat +\installcorenamespace{floatsplitting} -\newconditional\splitfloatdone - -\newif\ifinsidesplitfloat % will become chardef +\installdirectcommandhandler \??floatsplitting {floatsplitting} % \??floatsplitting -\newtoks\everysplitfloatsetup +\setupfloatsplitting + [\c!conversion=\v!character, % \v!romannumerals + \c!lines=3, + \c!before=, + \c!inbetween=\page, + \c!after=] -\def\extrasplitfloatlines{0} +\newconditional\splitfloatfirstdone +\newconditional\somenextsplitofffloat +\newconditional\splitfloatdone +\newconditional\onlyonesplitofffloat \settrue\onlyonesplitofffloat -\let\splitfloatfinalizer\relax +\newif \ifinsidesplitfloat % will become conditional -\ifx\floatcaptionsuffix\undefined \else - \let\floatcaptionsuffix\empty % will become \splitfloatcaptionsuffix -\fi +\newcount \noffloatssplits +\newtoks \everysplitfloatsetup -\unexpanded\def\setupfloatsplitting - {\dodoubleargument\getparameters[\??si]} +\let \extrasplitfloatlines \!!zerocount +\let \splitfloatfinalizer \relax +\let \floatcaptionsuffix \empty \unexpanded\def\splitfloat - {\dosingleempty\dosplitfloat} + {\dosingleempty\page_split_float} -\def\dosplitfloat[#1]#2% nog dubbele refs +\def\page_split_float[#1]#2% nog dubbele refs {\bgroup \global\setfalse\splitfloatdone - \aftergroup\checksplitfloat + \aftergroup\page_split_float_check \insidefloattrue \insidesplitfloattrue - \getparameters[\??si][#1]% + \setupcurrentfloatsplitting[#1]% \global\noffloatssplits\zerocount - \def\floatcaptionsuffix{\convertnumber\@@siconversion\noffloatssplits}% - \let\extrasplitfloatlines\@@silines + \let\floatcaptionsuffix\page_split_float_suffix + \edef\extrasplitfloatlines{\floatsplittingparameter\c!lines}% \the\everysplitfloatsetup \def\splitfloatcommand{#2}% \global\settrue \onlyonesplitofffloat \global\setfalse\somenextsplitofffloat \dopushsavedfloats - \@@sibefore + \floatsplittingparameter\c!before \let\next} % \bgroup -\unexpanded\def\checksplitfloat +\unexpanded\def\page_split_float_suffix + {\begingroup + \usefloatsplittingstyleandcolor\c!style\c!color % only the suffix + \convertnumber{\floatsplittingparameter\c!conversion}\noffloatssplits + \endgroup} + +\unexpanded\def\page_split_float_check {\ifconditional\splitfloatdone \splitfloatfinalizer % a weird place (could interfere with flushing) \else - \blank{\tttf \getmessage\m!floatblocks{13}\empty}\blank + \blank + \begingroup + \tttf \dontleavehmode \getmessage\m!floatblocks{13}\empty + \endgroup + \blank \showmessage\m!floatblocks{13}\empty \fi} -\def\dodowithsplitofffloat - {\dowithnextboxcs\dodowithsplitofffloatfinish\vbox} +\def\page_split_float_process % nextbox + {\ifinsidesplitfloat + \expandafter\page_split_float_process_yes + \else + \expandafter\page_split_float_process_nop + \fi} + +\def\page_split_float_process_yes + {\dowithnextboxcs\page_split_float_process_finish\vbox} -\def\dodowithsplitofffloatfinish +\def\page_split_float_process_finish {\forgetall \dontcomplain \global\settrue\splitfloatdone @@ -127,26 +148,29 @@ \splitfloatcommand{\box\nextbox}% \egroup \ifconditional\somenextsplitofffloat - \doifelsenothing\@@siinbetween - {\ifconditional\splitfloatfirstdone\else\page\fi} - \@@siinbetween + \edef\p_inbetween{\floatsplittingparameter\c!inbetween}% + \ifx\p_inbetween\empty + \ifconditional\splitfloatfirstdone\else\page\fi + \else + \p_inbetween + \fi \else - \@@siafter + \floatsplittingparameter\c!after \dopopsavedfloats \doflushsavedfloats \fi \global\settrue\splitfloatfirstdone} -\def\nodowithsplitofffloat - {\dowithnextboxcs\nodowithsplitofffloatfinish\vbox} +\def\page_split_float_process_nop + {\dowithnextboxcs\page_split_float_process_nop_finish\vbox} -\def\nodowithsplitofffloatfinish +\def\page_split_float_process_nop_finish {\forgetall \dontcomplain \box\nextbox % maybe an option to unvbox \global\settrue\splitfloatfirstdone} -\def\dochecksplitofffloat#1% box +\def\page_split_float_check_content#1% box {\ifinsidesplitfloat % \ifdim\ht#1=\zeropoint % funny: \ifcase does not check for overflow \ifcase\ht#1\relax @@ -157,7 +181,7 @@ \fi \fi} -\def\analyzesplitfloatcaption#1% depends on page-flt .. pretty messy +\def\page_split_float_check_caption#1% depends on page-flt .. pretty messy {\edef\extrasplitfloatlines{\extrasplitfloatlines}% \ifx\extrasplitfloatlines\v!auto \bgroup @@ -174,27 +198,15 @@ \doifnumberelse\extrasplitfloatlines\donothing{\def\extrasplitfloatlines{1}}% \fi} -\def\dowithsplitofffloat % nextbox +\unexpanded\def\doifnotinsidesplitfloat {\ifinsidesplitfloat - \expandafter\dodowithsplitofffloat - \else - \expandafter\nodowithsplitofffloat + \expandafter\gobbleoneargument \fi} -\def\doifnotinsidesplitfloat - {\ifinsidesplitfloat\expandafter\gobbleoneargument\fi} - -%D Some defaults: - -\setupfloatsplitting - [\c!conversion=\v!character, % \v!romannumerals - \c!lines=3, - \c!before=, - \c!inbetween=\page, - \c!after=] - %D Table splitter, on top of previous code: +% todo: keep tail to rest, so we need a lookahead + \newbox\tsplitcontent \newbox\tsplitresult \newbox\tsplithead @@ -203,198 +215,216 @@ \newtoks\everyresettsplit -\def\resettsplit{\the\everyresettsplit} - \appendtoks - \def\tsplitminimumfreelines{0}% - \def\tsplitminimumfreespace{0pt}% - \setbox\tsplitcontent\emptyvbox - \setbox\tsplitresult \emptyvbox - \setbox\tsplithead \emptyvbox - \setbox\tsplitnext \emptyvbox - \setbox\tsplittail \emptyvbox - \let\tsplitbeforeresult\donothing - \let\tsplitafterresult \donothing - \let\tsplitinbetween \donothing - \let\tsplitbefore \donothing - \let\tsplitafter \donothing - \let\postprocesstsplit \donothing + \let \tsplitminimumfreelines\!!zerocount + \let \tsplitminimumfreespace\!!zeropoint + \setbox\tsplitcontent \emptyvbox + \setbox\tsplitresult \emptyvbox + \setbox\tsplithead \emptyvbox + \setbox\tsplitnext \emptyvbox + \setbox\tsplittail \emptyvbox + \let \tsplitbeforeresult \donothing + \let \tsplitafterresult \donothing + \let \tsplitinbetween \donothing + \let \tsplitbefore \donothing + \let \tsplitafter \donothing + \let \postprocesstsplit \donothing \to \everyresettsplit +\unexpanded\def\resettsplit + {\the\everyresettsplit} + \resettsplit -% todo: keep tail to rest, so we need a lookahead +\def\tsplitdirectwidth{\hsize} -\newconditional\splitfloatfirstdone +\newconditional\c_tabl_split_done +\newconditional\c_tabl_split_head +\newconditional\c_tabl_split_full -\def\handletsplit - {\analyzesplitfloatcaption{\wd\tsplitcontent}% +\newdimen \d_tabl_split_available + +\unexpanded\def\handletsplit + {\page_split_float_check_caption{\wd\tsplitcontent}% \global\setfalse\splitfloatfirstdone \testpagesync % new, sync, but still tricky [\tsplitminimumfreelines] [\dimexpr\tsplitminimumfreespace+\extrasplitfloatlines\lineheight\relax]% \setbox\scratchbox\vbox{\tsplitinbetween}% \edef\tsplitinbetweenheight{\the\htdp\scratchbox}% etex - \!!doneafalse - \doloop - {\ifinsidecolumns - % brrr, assumes empty columns - \global\setfalse\splitfloatfirstdone - \scratchdimen\textheight - \!!donectrue - \else - \ifconditional\splitfloatfirstdone - \scratchdimen\textheight - \!!donectrue - \else\ifdim\pagegoal<\maxdimen - \scratchdimen\dimexpr\pagegoal-\pagetotal\relax - \!!donecfalse - \else - \scratchdimen\textheight - \!!donectrue - \fi\fi - \fi - \scratchdimen\dimexpr\scratchdimen-\tsplitinbetweenheight-\tsplitminimumfreespace-\extrasplitfloatlines\lineheight\relax - \ifdim\htdp\tsplittail>\zeropoint - \advance\scratchdimen-\htdp\tsplittail - \fi - \setbox\tsplitresult\vbox - {\ifdim\ht\tsplithead>\zeropoint - \unvcopy\tsplithead + \setfalse\c_tabl_split_done + \doloop\tabl_split_loop_body + \global\setfalse\usesamefloatnumber % new, prevent next increment + \global\setfalse\splitfloatfirstdone} % we can use this one for tests + +\def\tabl_split_loop_body + {\ifinsidecolumns + % brrr, assumes empty columns + \global\setfalse\splitfloatfirstdone + \d_tabl_split_available\textheight + \settrue\c_tabl_split_full + \else + \ifconditional\splitfloatfirstdone + \d_tabl_split_available\textheight + \settrue\c_tabl_split_full + \else\ifdim\pagegoal<\maxdimen + \d_tabl_split_available\dimexpr\pagegoal-\pagetotal\relax + \setfalse\c_tabl_split_full + \else + \d_tabl_split_available\textheight + \settrue\c_tabl_split_full + \fi\fi + \fi + \d_tabl_split_available \dimexpr + \d_tabl_split_available + -\tsplitinbetweenheight + -\tsplitminimumfreespace + -\extrasplitfloatlines\lineheight + \relax + \ifdim\htdp\tsplittail>\zeropoint + \advance\d_tabl_split_available-\htdp\tsplittail + \fi + \setbox\tsplitresult\vbox + {\ifdim\ht\tsplithead>\zeropoint + \unvcopy\tsplithead + \tsplitinbetween + \fi}% + \ifconditional\c_tabl_split_done \else + \ifdim\ht\tsplitnext>\zeropoint + \setbox\tsplithead\box\tsplitnext + \fi + \fi + \settrue\c_tabl_split_done + \ifdim\ht\tsplitresult>\zeropoint + \settrue\c_tabl_split_head % table head + \else + \setfalse\c_tabl_split_head % no tablehead + \fi + \splittopskip\zeropoint + \doloop % inner loop + {\setbox\scratchbox\vsplit\tsplitcontent to \onepoint % \lineheight + \setbox\scratchbox\vbox{\unvbox\scratchbox}% + \ifdim\dimexpr\d_tabl_split_available-\htdp\scratchbox-\htdp\tsplitresult\relax>\zeropoint + \setbox\tsplitresult\vbox + {\unvbox\tsplitresult \tsplitinbetween - \fi}% - \if!!donea\else\ifdim\ht\tsplitnext>\zeropoint - \setbox\tsplithead\box\tsplitnext - \fi\fi - \!!doneatrue - \ifdim\ht\tsplitresult>\zeropoint - \!!donedtrue % table head - \else - \!!donedfalse % no tablehead - \fi - \splittopskip\zeropoint - \doloop - {\setbox\scratchbox\vsplit\tsplitcontent to \onepoint % \lineheight - \setbox\scratchbox\vbox{\unvbox\scratchbox}% - \ifdim\dimexpr\scratchdimen-\htdp\scratchbox-\htdp\tsplitresult\relax>\zeropoint - \setbox\tsplitresult\vbox - {\unvbox\tsplitresult - \tsplitinbetween - \unvbox\scratchbox}% - \ifvoid\tsplitcontent \exitloop \fi - \else\if!!doned - % we only have a tablehead so far - \setbox\tsplitresult\vbox{\unvbox\tsplitresult\unvbox\scratchbox}% - \exitloop - \else\if!!donec - % we have text height available, but the (one) cell is too - % large to fit, so, in order to avoid loops/deadcycles we do: - \setbox\tsplitresult\vbox - {\unvbox\tsplitresult - \tsplitinbetween - \unvbox\scratchbox}% - \exitloop - \else - \setbox\tsplitcontent\vbox - {\unvbox\scratchbox - \tsplitinbetween - \ifvoid\tsplitcontent\else\unvbox\tsplitcontent\fi}% - \exitloop - \fi\fi\fi - \!!donedfalse - \!!donecfalse}% - \postprocesstsplit - \dochecksplitofffloat\tsplitcontent - \ifvoid\tsplitcontent + \unvbox\scratchbox}% + \ifvoid\tsplitcontent \exitloop \fi + \else\ifconditional\c_tabl_split_head + % we only have a tablehead so far + \setbox\tsplitresult\vbox{\unvbox\tsplitresult\unvbox\scratchbox}% + \exitloop + \else\ifconditional\c_tabl_split_full + % we have text height available, but the (one) cell is too + % large to fit, so, in order to avoid loops/deadcycles we do: \setbox\tsplitresult\vbox {\unvbox\tsplitresult \tsplitinbetween - \unvcopy\tsplittail}% - \dowithsplitofffloat{\tsplitbeforeresult\box\tsplitresult\tsplitafterresult}% - \doifnotinsidesplitfloat\tsplitafter - \endgraf + \unvbox\scratchbox}% \exitloop \else - % hack - \ifdim\pagegoal<\maxdimen - \global\pagegoal\dimexpr\pagegoal+\lineheight\relax % etex - \fi - % brrr - \ifdim\ht\tsplitresult>\zeropoint - \setbox\tsplitresult\vbox - {\unvbox\tsplitresult - \tsplitinbetween - \unvcopy\tsplittail}% - \dowithsplitofffloat{\tsplitbeforeresult\box\tsplitresult\tsplitafterresult}% - \doifnotinsidesplitfloat\tsplitafter - \endgraf - \fi - \ifinsidecolumns - \goodbreak % was \doifnotinsidesplitfloat\goodbreak - \else - \page % was \doifnotinsidesplitfloat\page - \fi - \global\settrue\usesamefloatnumber % new, prevent next increment - \fi}% - \global\setfalse\usesamefloatnumber % new, prevent next increment - \global\setfalse\splitfloatfirstdone} % we can use this one for tests + \setbox\tsplitcontent\vbox + {\unvbox\scratchbox + \tsplitinbetween + \ifvoid\tsplitcontent\else\unvbox\tsplitcontent\fi}% + \exitloop + \fi\fi\fi + \setfalse\c_tabl_split_head + \setfalse\c_tabl_split_full}% + \postprocesstsplit + \page_split_float_check_content\tsplitcontent + \ifvoid\tsplitcontent + \setbox\tsplitresult\vbox + {\unvbox\tsplitresult + \tsplitinbetween + \unvcopy\tsplittail}% + \page_split_float_process{\tsplitbeforeresult\box\tsplitresult\tsplitafterresult}% + \doifnotinsidesplitfloat\tsplitafter + \endgraf + \exitloop + \else + % hack + \ifdim\pagegoal<\maxdimen + \global\pagegoal\dimexpr\pagegoal+\lineheight\relax % etex + \fi + % brrr + \ifdim\ht\tsplitresult>\zeropoint + \setbox\tsplitresult\vbox + {\unvbox\tsplitresult + \tsplitinbetween + \unvcopy\tsplittail}% + \page_split_float_process{\tsplitbeforeresult\box\tsplitresult\tsplitafterresult}% + \doifnotinsidesplitfloat\tsplitafter + \endgraf + \fi + \ifinsidecolumns + \goodbreak % was \doifnotinsidesplitfloat\goodbreak + \else + \page % was \doifnotinsidesplitfloat\page + \fi + \global\settrue\usesamefloatnumber % new, prevent next increment + \fi} %D The next one assumes that the split takes place elsewhere. This is %D used in xtables. \let\resetdirecttsplit\resettsplit -\def\tsplitdirectwidth{\hsize} - -\def\handledirecttsplit - {\analyzesplitfloatcaption{\tsplitdirectwidth}% +\unexpanded\def\handledirecttsplit + {\page_split_float_check_caption{\tsplitdirectwidth}% \global\setfalse\splitfloatfirstdone \testpagesync % new, sync, but still tricky [\tsplitminimumfreelines] [\dimexpr\tsplitminimumfreespace+\extrasplitfloatlines\lineheight\relax]% - \doloop - {\ifinsidecolumns - \global\setfalse\splitfloatfirstdone - \scratchdimen\textheight - \else\ifconditional\splitfloatfirstdone - \scratchdimen\textheight - \else\ifdim\pagegoal<\maxdimen - \scratchdimen\dimexpr\pagegoal-\pagetotal\relax - \else - \scratchdimen\textheight - \fi\fi\fi - \scratchdimen\dimexpr\scratchdimen-\tsplitminimumfreespace-\extrasplitfloatlines\lineheight\relax - \tsplitdirectsplitter\scratchdimen % also sets state - \ifdim\ht\tsplitresult>\zeropoint - \ifconditional\somenextsplitofffloat - \global\setfalse\onlyonesplitofffloat - \fi - \ifdim\pagegoal<\maxdimen - \global\pagegoal\dimexpr\pagegoal+\lineheight\relax % etex - \fi - \dowithsplitofffloat{\tsplitbeforeresult\box\tsplitresult\tsplitafterresult}% - \global\settrue\usesamefloatnumber % new, prevent next increment - \endgraf - \ifconditional\somenextsplitofffloat - \ifinsidecolumns - \goodbreak - \else - \page - \fi - \fi - \global\settrue\splitfloatfirstdone - \else\ifconditional\somenextsplitofffloat - \ifinsidecolumns - \goodbreak - \else - \page % no room - \fi - \else - \exitloop - \fi\fi}% - \global\setfalse\usesamefloatnumber % new, prevent next increment + \doloop\tabl_split_direct_loop_body + \global\setfalse\usesamefloatnumber % new, prevent next increment \global\setfalse\splitfloatfirstdone} % we can use this one for tests +\def\tabl_split_direct_loop_body + {\ifinsidecolumns + \global\setfalse\splitfloatfirstdone + \d_tabl_split_available\textheight + \else\ifconditional\splitfloatfirstdone + \d_tabl_split_available\textheight + \else\ifdim\pagegoal<\maxdimen + \d_tabl_split_available\dimexpr\pagegoal-\pagetotal\relax + \else + \d_tabl_split_available\textheight + \fi\fi\fi + \d_tabl_split_available\dimexpr + \d_tabl_split_available + -\tsplitminimumfreespace + -\extrasplitfloatlines\lineheight + \relax + \tsplitdirectsplitter\d_tabl_split_available % also sets state + \ifdim\ht\tsplitresult>\zeropoint + \ifconditional\somenextsplitofffloat + \global\setfalse\onlyonesplitofffloat + \fi + \ifdim\pagegoal<\maxdimen + \global\pagegoal\dimexpr\pagegoal+\lineheight\relax % etex + \fi + \page_split_float_process{\tsplitbeforeresult\box\tsplitresult\tsplitafterresult}% + \global\settrue\usesamefloatnumber % new, prevent next increment + \endgraf + \ifconditional\somenextsplitofffloat + \ifinsidecolumns + \goodbreak + \else + \page + \fi + \fi + \global\settrue\splitfloatfirstdone + \else\ifconditional\somenextsplitofffloat + \ifinsidecolumns + \goodbreak + \else + \page % no room + \fi + \else + \exitloop + \fi\fi} + \protect \endinput % test cases diff --git a/tex/context/base/util-prs.lua b/tex/context/base/util-prs.lua index 66ada23fd..3d3ef6610 100644 --- a/tex/context/base/util-prs.lua +++ b/tex/context/base/util-prs.lua @@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['util-prs'] = { license = "see context related readme files" } +local lpeg, table, string = lpeg, table, string + local P, R, V, C, Ct, Cs, Carg, Cc = lpeg.P, lpeg.R, lpeg.V, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg, lpeg.Cc local lpegmatch, patterns = lpeg.match, lpeg.patterns local concat, format, gmatch, find = table.concat, string.format, string.gmatch, string.find diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 7a76bc33c..139a8ee2c 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/19/12 22:27:34 +-- merge date : 06/20/12 16:19:05 do -- begin closure to overcome local limits and interference |