diff options
author | Hans Hagen <pragma@wxs.nl> | 2012-07-17 16:42:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2012-07-17 16:42:00 +0200 |
commit | b118ddb35b0a15f0a1f4868e93ca5833d833f371 (patch) | |
tree | 3551c2c7d70394b2e49b97bb598a932e05268e15 /tex | |
parent | cc4b51097349dc33a2364d2ee87ec9b6b87fdcac (diff) | |
download | context-b118ddb35b0a15f0a1f4868e93ca5833d833f371.tar.gz |
beta 2012.07.17 16:42
Diffstat (limited to 'tex')
35 files changed, 263 insertions, 102 deletions
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 9a3834e56..7ec44d2eb 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.07.17 00:23} +\newcontextversion{2012.07.17 16:42} %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 03f998078..4a0b05102 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.07.17 00:23} +\newcontextversion{2012.07.17 16:42} %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 3268979c2..75a91cef5 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 7e7b3e6d5..52f10ed09 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 8cd630ac1..ea8dbda6b 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.07.17 00:23} +\edef\contextversion{2012.07.17 16:42} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 0eb100895..d07eddc07 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.07.17 00:23} +\edef\contextversion{2012.07.17 16:42} %D For those who want to use this: diff --git a/tex/context/base/mult-de.mkii b/tex/context/base/mult-de.mkii index 6d4e3734a..7ed54524b 100644 --- a/tex/context/base/mult-de.mkii +++ b/tex/context/base/mult-de.mkii @@ -456,6 +456,7 @@ \setinterfacevariable{subforward}{untervorwaerts} \setinterfacevariable{subject}{thema} \setinterfacevariable{subpage}{unterseite} +\setinterfacevariable{subs}{subs} \setinterfacevariable{subsection}{unterabsatz} \setinterfacevariable{subsubject}{unterthema} \setinterfacevariable{subsubsection}{unterunterabsatz} diff --git a/tex/context/base/mult-def.lua b/tex/context/base/mult-def.lua index 89ef990c7..b67ddaf9b 100644 --- a/tex/context/base/mult-def.lua +++ b/tex/context/base/mult-def.lua @@ -15756,6 +15756,9 @@ return { ["pe"]="زیرصفحه", ["ro"]="subpagina", }, + ["subs"]={ + ["en"]="subs", + }, ["subsection"]={ ["cs"]="podsekce", ["de"]="unterabsatz", diff --git a/tex/context/base/mult-en.mkii b/tex/context/base/mult-en.mkii index 6325765e0..9ea02f924 100644 --- a/tex/context/base/mult-en.mkii +++ b/tex/context/base/mult-en.mkii @@ -456,6 +456,7 @@ \setinterfacevariable{subforward}{subforward} \setinterfacevariable{subject}{subject} \setinterfacevariable{subpage}{subpage} +\setinterfacevariable{subs}{subs} \setinterfacevariable{subsection}{subsection} \setinterfacevariable{subsubject}{subsubject} \setinterfacevariable{subsubsection}{subsubsection} diff --git a/tex/context/base/mult-fr.mkii b/tex/context/base/mult-fr.mkii index 6b3acd811..017ac5fd2 100644 --- a/tex/context/base/mult-fr.mkii +++ b/tex/context/base/mult-fr.mkii @@ -456,6 +456,7 @@ \setinterfacevariable{subforward}{sousavance} \setinterfacevariable{subject}{sujet} \setinterfacevariable{subpage}{souspage} +\setinterfacevariable{subs}{subs} \setinterfacevariable{subsection}{soussection} \setinterfacevariable{subsubject}{soussujet} \setinterfacevariable{subsubsection}{soussoussection} diff --git a/tex/context/base/mult-it.mkii b/tex/context/base/mult-it.mkii index c901f1816..235280e60 100644 --- a/tex/context/base/mult-it.mkii +++ b/tex/context/base/mult-it.mkii @@ -456,6 +456,7 @@ \setinterfacevariable{subforward}{sottoavanti} \setinterfacevariable{subject}{argomento} \setinterfacevariable{subpage}{sottopagina} +\setinterfacevariable{subs}{subs} \setinterfacevariable{subsection}{sottocapoverso} \setinterfacevariable{subsubject}{sottoargomento} \setinterfacevariable{subsubsection}{sottosottocapoverso} diff --git a/tex/context/base/mult-nl.mkii b/tex/context/base/mult-nl.mkii index 07165f02c..1315ac931 100644 --- a/tex/context/base/mult-nl.mkii +++ b/tex/context/base/mult-nl.mkii @@ -456,6 +456,7 @@ \setinterfacevariable{subforward}{subvooruit} \setinterfacevariable{subject}{onderwerp} \setinterfacevariable{subpage}{subpagina} +\setinterfacevariable{subs}{subs} \setinterfacevariable{subsection}{subparagraaf} \setinterfacevariable{subsubject}{subonderwerp} \setinterfacevariable{subsubsection}{subsubparagraaf} diff --git a/tex/context/base/mult-pe.mkii b/tex/context/base/mult-pe.mkii index 6f7e245ff..965a95a8b 100644 --- a/tex/context/base/mult-pe.mkii +++ b/tex/context/base/mult-pe.mkii @@ -456,6 +456,7 @@ \setinterfacevariable{subforward}{زیرجلوگرد} \setinterfacevariable{subject}{موضوع} \setinterfacevariable{subpage}{زیرصفحه} +\setinterfacevariable{subs}{subs} \setinterfacevariable{subsection}{زیربخش} \setinterfacevariable{subsubject}{زیرموضوع} \setinterfacevariable{subsubsection}{زیرزیربخش} diff --git a/tex/context/base/mult-ro.mkii b/tex/context/base/mult-ro.mkii index 015603b9b..2468a4251 100644 --- a/tex/context/base/mult-ro.mkii +++ b/tex/context/base/mult-ro.mkii @@ -456,6 +456,7 @@ \setinterfacevariable{subforward}{subavans} \setinterfacevariable{subject}{subiect} \setinterfacevariable{subpage}{subpagina} +\setinterfacevariable{subs}{subs} \setinterfacevariable{subsection}{subsectiune} \setinterfacevariable{subsubject}{subsubiect} \setinterfacevariable{subsubsection}{subsubsectiune} diff --git a/tex/context/base/page-ins.lua b/tex/context/base/page-ins.lua index 1b8b8583b..44de95ea1 100644 --- a/tex/context/base/page-ins.lua +++ b/tex/context/base/page-ins.lua @@ -27,6 +27,13 @@ local report_inserts = logs.reporter("inserts") inserts.stored = inserts.stored or { } -- combining them in one is inefficient in the inserts.data = inserts.data or { } -- bytecode storage pool +local variables = interfaces.variables +local v_page = variables.page +local v_columns = variables.columns +local v_firstcolumn = variables.firstcolumn +local v_lastcolumn = variables.lastcolumn +local v_text = variables.text + storage.register("structures/inserts/stored", inserts.stored, "structures.inserts.stored") local data = inserts.data @@ -37,13 +44,34 @@ for name, specification in next, stored do data[name] = specification end -function inserts.define(specification) - local name = specification.name or "unknown" +function inserts.define(name,specification) + specification.name= name local number = specification.number or 0 data[name] = specification data[number] = specification -- only needed at runtime as this get stored in a bytecode register stored[name] = specification + if not specification.location then + specification.location = v_page + end + return specification +end + +function inserts.setup(name,settings) + local specification = data[name] + for k, v in next, settings do + -- maybe trace change + specification[k] = v + end + return specification +end + +function inserts.setlocation(name,location) -- a practical fast one + data[name].location = location +end + +function inserts.getlocation(name,location) + return data[name].location or v_page end function inserts.getdata(name) -- or number @@ -60,6 +88,8 @@ end -- interface -commands.defineinsertion = inserts.define -commands.insertionnumber = function(name) context(data[name].number or 0) end +commands.defineinsertion = inserts.define +commands.setupinsertion = inserts.setup +commands.setinsertionlocation = inserts.setlocation +commands.insertionnumber = function(name) context(data[name].number or 0) end diff --git a/tex/context/base/page-ins.mkiv b/tex/context/base/page-ins.mkiv index cb952e6e7..11b025ee0 100644 --- a/tex/context/base/page-ins.mkiv +++ b/tex/context/base/page-ins.mkiv @@ -31,6 +31,13 @@ \installcommandhandler \??insertion {insertion} \??insertion +\setupinsertion + [%c!n=\plusone, + %c!distance=\zeropoint, + %c!maxheight=\maxdimen, + %c!factor=\plusthousand, + \c!location=\v!page] + \newcount\currentinsertionnumber % This is a count and not a macro ! \newtoks\t_page_inserts_list @@ -48,22 +55,17 @@ \unexpanded\def\page_inserts_synchronize_registers {\currentinsertionnumber\csname\??insertionnumber\currentinsertion\endcsname} +% for practical reasone we still set these elsewhere but that might chaneg in the future +% +% \global\count\currentinsertionnumber\numexpr\insertionparameter\c!factor/\insertionparameter\c!n\relax +% \global\skip \currentinsertionnumber\insertionparameter\c!distance \relax +% \global\dimen\currentinsertionnumber\insertionparameter\c!maxheight\relax} + \appendtoks \page_inserts_synchronize_registers \to \everysetupinsertion -% \setupinsertion -% [\c!distance=\zeropoint, -% \c!maxheight=\maxdimen, -% \c!factor=\plusthousand] -% -% \unexpanded\def\page_inserts_synchronize_registers -% {\currentinsertionnumber\csname\??insertionnumber\currentinsertion\endcsname -% \global\count\currentinsertionnumber\insertionparameter\c!factor \relax -% \global\skip \currentinsertionnumber\insertionparameter\c!distance \relax -% \global\dimen\currentinsertionnumber\insertionparameter\c!maxheight\relax} - -\unexpanded\def\page_inserts_process#1% +\unexpanded\def\page_inserts_process#1% beware, this addapts currentinsertion ! {\edef\currentinsertion{#1}% \currentinsertionnumber\csname\??insertionnumber\currentinsertion\endcsname \doprocessinsert\currentinsertionnumber} % old method @@ -105,13 +107,7 @@ \else \expandafter\newinsert\csname\??insertionnumber\currentinsertion\endcsname \page_inserts_synchronize_registers - \ctxcommand{defineinsertion - { - name = "\currentinsertion", - number = \number\currentinsertionnumber, - } - }% - % + \ctxcommand{defineinsertion("\currentinsertion",{ number = \number\currentinsertionnumber })}% \t_page_inserts_list\expandafter\expandafter\expandafter {\expandafter\the\expandafter\t_page_inserts_list \expandafter\page_inserts_process\csname\??insertionnumber\currentinsertion\endcsname}% @@ -121,6 +117,15 @@ \fi \to \everydefineinsertion +\appendtoks + \ctxcommand{setupinsertion("\currentinsertion",{ + location = "\insertionparameter\c!location", + })}% +\to \everysetupinsertion + +\unexpanded\def\page_inserts_set_location#1#2% fast one + {\ctxcommand{setinsertionlocation("#1","#2")}} + %D Auxiliary macros: \def\page_insert_insertion_height#1% diff --git a/tex/context/base/page-mix.lua b/tex/context/base/page-mix.lua index 75e013ce4..6b7f88830 100644 --- a/tex/context/base/page-mix.lua +++ b/tex/context/base/page-mix.lua @@ -45,6 +45,7 @@ local variables = interfaces.variables local v_yes = variables.yes local v_global = variables["global"] local v_local = variables["local"] +local v_columns = variables.columns local trace_state = false trackers.register("mixedcolumns.trace", function(v) trace_state = v end) local trace_detail = false trackers.register("mixedcolumns.detail", function(v) trace_detail = v end) @@ -60,6 +61,16 @@ local forcedbreak = -123 -- initializesplitter(specification) -- cleanupsplitter() +-- Inserts complicate matters a lot. In order to deal with them well, we need to +-- distinguish several cases. +-- +-- (1) full page columns: firstcolumn, columns, lastcolumn, page +-- (2) mid page columns : firstcolumn, columns, lastcolumn, page +-- +-- We need to collect: +-- +-- + local function collectinserts(result,nxt,nxtid) local inserts, currentskips, nextskips, inserttotal = { }, 0, 0, 0 while nxt do diff --git a/tex/context/base/s-def-01.mkiv b/tex/context/base/s-def-01.mkiv index 1c8ee9469..49e585bd0 100644 --- a/tex/context/base/s-def-01.mkiv +++ b/tex/context/base/s-def-01.mkiv @@ -4,7 +4,7 @@ \startsetups defaults:frontpart:pagenumbers:roman \defineconversionset[\c!frontpart:\c!pagenumber][][romannumerals] - \setupuserpagenumber[\c!way=\v!byblock] + \setupuserpagenumber[\c!way=\v!by\v!block] \stopsetups \protect diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 5fb854019..6f6736e91 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 9c7987cca..6499327bd 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/strc-def.mkiv b/tex/context/base/strc-def.mkiv index bd7c25170..0738bdf29 100644 --- a/tex/context/base/strc-def.mkiv +++ b/tex/context/base/strc-def.mkiv @@ -49,7 +49,7 @@ % \startsetups defaults:frontpart:pagenumbers:roman % \defineconversionset[\c!frontpart:\c!pagenumber][][romannumerals] -% \setupuserpagenumber[\c!way=\v!byblock] +% \setupuserpagenumber[\c!way=\v!by\v!block] % \stopsetups % \definesectionblock @@ -180,7 +180,7 @@ \c!marking=\v!page, \c!header=, \c!style=\tfc, - \c!distance=.75em, + \c!distance=.75\emwidth, \c!before={\blank[2*\v!big]}, \c!after={\blank[2*\v!big]}] @@ -189,7 +189,7 @@ [%\c!align=, %\c!indentnext=\v!no, \c!style=\tfa, - \c!distance=.75em, + \c!distance=.75\emwidth, \c!before={\blank[2*\v!big]}, \c!after=\blank] diff --git a/tex/context/base/strc-not.mkvi b/tex/context/base/strc-not.mkvi index 05bca36ba..a81d3deb9 100644 --- a/tex/context/base/strc-not.mkvi +++ b/tex/context/base/strc-not.mkvi @@ -922,7 +922,7 @@ \unexpanded\def\strc_notes_set_variants {\normalexpanded{\rawprocesscommalist[\noteparameter\c!location]\strc_notes_set_location_step}} -\unexpanded\def\strc_notes_set_location_step#1% +\unexpanded\def\strc_notes_set_location_step#1% the insert related one {\ifcsname\??notelocation#1\endcsname \csname\??notelocation#1\endcsname \fi} @@ -957,6 +957,7 @@ {\setfalse\c_strc_notes_delayed \strc_notes_set_distance \strc_notes_set_columns + \page_inserts_set_location\currentnote\v!page % \setupinsertion[\currentnote][\c!location=\v!page]% \global\count\namedinsertionnumber\currentnote\numexpr\plusthousand/\c_strc_notes_columns\relax \global\dimen\namedinsertionnumber\currentnote\ifnotelimit\dimexpr\noteparameter\c!height*\c_strc_notes_columns\relax\else\maxdimen\fi \global\skip \namedinsertionnumber\currentnote\s_strc_notes_distance} @@ -968,23 +969,27 @@ \ifnum\currentnofcolumns=\zerocount \c_strc_notes_columns\plusone \fi + \page_inserts_set_location\currentnote\v!columns % \setupinsertion[\currentnote][\c!location=\v!columns]% \global\count\namedinsertionnumber\currentnote\numexpr\plusthousand/\c_strc_notes_columns\relax \global\dimen\namedinsertionnumber\currentnote\ifnotelimit\dimexpr\noteparameter\c!height*\c_strc_notes_columns\relax\else\maxdimen\fi \global\skip \namedinsertionnumber\currentnote\s_strc_notes_distance} -\def\strc_notes_set_location_firstcolumn +\def\strc_notes_set_location_somecolumn#whatcolumn% {\setfalse\c_strc_notes_delayed \strc_notes_set_distance \strc_notes_set_columns + \page_inserts_set_location\currentnote#whatcolumn% \setupinsertion[\currentnote][\c!location=#whatcolumn]% \global\count\namedinsertionnumber\currentnote\plusthousand \global\dimen\namedinsertionnumber\currentnote\ifnotelimit\noteparameter\c!height\else\maxdimen\fi \global\skip \namedinsertionnumber\currentnote\s_strc_notes_distance} -\let\strc_notes_set_location_lastcolumn\strc_notes_set_location_firstcolumn +\def\strc_notes_set_location_firstcolumn{\strc_notes_set_location_somecolumn\v!firstcolumn} +\def\strc_notes_set_location_lastcolumn {\strc_notes_set_location_somecolumn\v!lastcolumn } \def\strc_notes_set_location_text % we don't use inserts anyway (e.g. endnotes) {\settrue\c_strc_notes_delayed \ctxlua{structures.notes.setstate("\currentnote","store")}% + \page_inserts_set_location\currentnote\v!text % \setupinsertion[\currentnote][\c!location=\v!text]% \global\count\namedinsertionnumber\currentnote\zerocount \global\dimen\namedinsertionnumber\currentnote\maxdimen \global\skip \namedinsertionnumber\currentnote\zeropoint} diff --git a/tex/context/base/strc-num.lua b/tex/context/base/strc-num.lua index 0715a9e49..3189adacb 100644 --- a/tex/context/base/strc-num.lua +++ b/tex/context/base/strc-num.lua @@ -6,12 +6,13 @@ if not modules then modules = { } end modules ['strc-num'] = { license = "see context related readme files" } --- this will be reimplemented and some more will move to the commands namespace - local format = string.format local next, type = next, type local min, max = math.min, math.max -local texcount = tex.count +local texcount, texsetcount = tex.count, tex.setcount + +-- Counters are managed here. They can have multiple levels which makes it easier to synchronize +-- them. Synchronization is sort of special anyway, as it relates to document structuring. local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex @@ -26,8 +27,23 @@ local counters = structures.counters local documents = structures.documents local variables = interfaces.variables - --- state: start stop none reset +local v_start = variables.start +local v_page = variables.page +local v_reverse = variables.reverse +local v_first = variables.first +local v_next = variables.next +local v_previous = variables.previous +local v_prev = variables.prev +local v_last = variables.last +----- v_no = variables.no +local v_backward = variables.backward +local v_forward = variables.forward +----- v_subs = variables.subs or "subs" + +-- states: start stop none reset + +-- specials are used for counters that are set and incremented in special ways, like +-- pagecounters that get this treatment in the page builder counters.specials = counters.specials or { } local counterspecials = counters.specials @@ -66,54 +82,83 @@ end job.register('structures.counters.collected', tobesaved, initializer, finalizer) -local function constructor(t,s,name,i) -- variables ? - if s == "last" then +local constructor = { -- maybe some day we will provide an installer for more variants + + last = function(t,name,i) local cc = collected[name] - t.stop = (cc and cc[i] and cc[i][t.range]) or 0 -- stop is available for diagnostics purposes only + local stop = (cc and cc[i] and cc[i][t.range]) or 0 -- stop is available for diagnostics purposes only + t.stop = stop if t.offset then - return t.stop - t.step + return stop - t.step else - return t.stop + return stop end - elseif s == "first" then - if t.start > 0 then - return t.start -- brrr + end, + + first = function(t,name,i) + local start = t.start + if start > 0 then + return start -- brrr elseif t.offset then - return t.start + t.step + 1 + return start + t.step + 1 else - return t.start + 1 + return start + 1 end - elseif s == "prev" or s == "previous" then + end, + + prev = function(t,name,i) + return max(t.first,t.number-1) -- todo: step + end, + + previous = function(t,name,i) return max(t.first,t.number-1) -- todo: step - elseif s == "next" then + end, + + next = function(t,name,i) return min(t.last,t.number+1) -- todo: step - elseif s == "backward" then + end, + + backward =function(t,name,i) if t.number - 1 < t.first then return t.last else return t.previous end - elseif s == "forward" then + end, + + forward = function(t,name,i) if t.number + 1 > t.last then return t.first else return t.next end - elseif s == "subs" then + end, + + subs = function(t,name,i) local cc = collected[name] t.subs = (cc and cc[i+1] and cc[i+1][t.range]) or 0 return t.subs - else - return nil -- was 0, but that is fuzzy in testing for e.g. own - end + end, + +} + +local function dummyconstructor(t,name,i) + return nil -- was 0, but that is fuzzy in testing for e.g. own end +setmetatableindex(constructor,function(t,k) + if trace_counters then + report_counters("unknown constructor %q",tostring(k)) + end + return dummyconstructor +end) + local function enhance() for name, cd in next, counterdata do local data = cd.data for i=1,#data do local ci = data[i] - setmetatableindex(ci, function(t,s) return constructor(t,s,name,i) end) + setmetatableindex(ci, function(t,s) return constructor[s](t,name,i) end) end end enhance = nil @@ -126,7 +171,7 @@ local function allocate(name,i) -- can be metatable level = 1, -- block = "", -- todo numbers = nil, - state = variables.start, -- true + state = v_start, -- true data = { }, saved = { }, } @@ -145,7 +190,7 @@ local function allocate(name,i) -- can be metatable offset = false, stop = 0, -- via metatable: last, first, stop only for tracing } - setmetatableindex(ci, function(t,s) return constructor(t,s,name,i) end) + setmetatableindex(ci, function(t,s) return constructor[s](t,name,i) end) cd[i] = ci tobesaved[name][i] = { } else @@ -164,12 +209,12 @@ local function savevalue(name,i) local cs = tobesaved[name][i] local cc = collected[name] if trace_counters then - report_counters("saving value %s of counter named %s",cd.number,name) + report_counters("saving, counter: %s, value: %s",name,cd.number) end local cr = cd.range local old = (cc and cc[i] and cc[i][cr]) or 0 local number = cd.number - if cd.method == variables.page then + if cd.method == v_page then -- we can be one page ahead number = number - 1 end @@ -186,8 +231,8 @@ function counters.define(specification) if name and name ~= "" then -- todo: step local d = allocate(name,1) - d.start = specification.start - d.state = variables.start or "" + d.start = tonumber(specification.start) or 0 + d.state = v_state or "" local counter = specification.counter if counter and counter ~= "" then d.counter = counter -- only for special purposes, cannot be false @@ -202,18 +247,15 @@ end function counters.compact(name,level,onlynumbers) local cd = counterdata[name] ---~ print(name,cd) if cd then local data = cd.data local compact = { } for i=1,level or #data do local d = data[i] ---~ print(name,i,d.number) if d.number ~= 0 then compact[i] = (onlynumbers and d.number) or d end end ---~ print(table.serialize(compact)) return compact end end @@ -246,65 +288,76 @@ function counters.subs(name,n) return counterdata[name].data[n].subs or 0 end -function counters.setvalue(name,tag,value) +local function setvalue(name,tag,value) local cd = counterdata[name] if cd then cd[tag] = value end end +counters.setvalue = setvalue + function counters.setstate(name,value) -- true/false value = variables[value] if value then - counters.setvalue(name,"state",value) + setvalue(name,"state",value) end end function counters.setlevel(name,value) - counters.setvalue(name,"level",value) + setvalue(name,"level",value) end function counters.setoffset(name,value) - counters.setvalue(name,"offset",value) + setvalue(name,"offset",value) end local function synchronize(name,d) local dc = d.counter if dc then if trace_counters then - report_counters("setting counter %s with name %s to %s",dc,name,d.number) + report_counters("synchronize, counter: %s, name: %s, value: %s, action: setting",dc,name,d.number) end - tex.setcount("global",dc,d.number) + texsetcount("global",dc,d.number) end local cs = counterspecials[name] if cs then if trace_counters then - report_counters("invoking special for name %s",name) + report_counters("synchronize, counter: %s, name: %s, action: special",dc,name) end cs() end end -function counters.reset(name,n) +local function reset(name,n) local cd = counterdata[name] if cd then for i=n or 1,#cd.data do local d = cd.data[i] savevalue(name,i) - d.number = d.start or 0 + local number = d.start or 0 + d.number = number d.own = nil + if trace_counters then + report_counters("resetting, name: %s, sub: %s, value: %s",name,i,number) + end synchronize(name,d) end cd.numbers = nil + else end end -function counters.set(name,n,value) +local function set(name,n,value) local cd = counterdata[name] if cd then local d = allocate(name,n) - d.number = value or 0 + local number = value or 0 + d.number = number d.own = nil + if trace_counters then + report_counters("setting, name: %s, value: %s",name,number) + end synchronize(name,d) end end @@ -313,12 +366,19 @@ local function check(name,data,start,stop) for i=start or 1,stop or #data do local d = data[i] savevalue(name,i) - d.number = d.start or 0 + local number = d.start or 0 + d.number = number d.own = nil + if trace_counters then + report_counters("checking, name: %s, sub: %s, value: %s",name,i,number) + end synchronize(name,d) end end +counters.reset = reset +counters.set = set + function counters.setown(name,n,value) local cd = counterdata[name] if cd then @@ -345,7 +405,7 @@ function counters.restart(name,n,newstart,noreset) local d = allocate(name,n) d.start = newstart if not noreset then - counters.reset(name,n) -- hm + reset(name,n) -- hm end end end @@ -367,24 +427,38 @@ end function counters.add(name,n,delta) local cd = counterdata[name] --- inspect(cd) - if cd and (cd.state == variables.start or cd.state == "") then + if cd and (cd.state == v_start or cd.state == "") then local data = cd.data local d = allocate(name,n) d.number = (d.number or d.start or 0) + delta*(d.step or 0) -- d.own = nil local level = cd.level --- print(name,n,delta,level) if not level or level == -1 then -- -1 is signal that we reset manually + if trace_counters then + report_counters("adding, name: %s, level: manually, action: no checking",name) + end elseif level == -2 then -- -2 is signal that we work per text + if trace_counters then + report_counters("adding, name: %s, level: text, action: checking",name) + end check(name,data,n+1) elseif level > 0 then -- within countergroup + if trace_counters then + report_counters("adding, name: %s, level: %s, action: checking within group",name,level) + end check(name,data,n+1) elseif level == 0 then -- happens elsewhere + if trace_counters then + report_counters("adding, name: %s, level: %s, action: no checking",name,level) + end + else + if trace_counters then + report_counters("adding, name: %s, level: unknown, action: no checking",name) + end end synchronize(name,d) return d.number -- not needed @@ -392,19 +466,18 @@ function counters.add(name,n,delta) return 0 end -function counters.check(level) -- not used (yet) +function counters.check(level) for name, cd in next, counterdata do - -- report_counters("%s %s %s",name,cd.level,level) if cd.level == level then if trace_counters then - report_counters("resetting %s at level %s",name,level) + report_counters("resetting, name: %s, level: %s",name,level) end - counters.reset(name) + reset(name) end end end -function counters.get(name,n,key) +local function get(name,n,key) local d = allocate(name,n) d = d and d[key] if not d then @@ -416,8 +489,10 @@ function counters.get(name,n,key) end end +counters.get = get + function counters.value(name,n) -- what to do with own - return counters.get(name,n or 1,'number') or 0 + return get(name,n or 1,'number') or 0 end function counters.converted(name,spec) -- name can be number and reference to storage @@ -431,9 +506,8 @@ function counters.converted(name,spec) -- name can be number and reference to st if cd then local spec = spec or { } local numbers, ownnumbers = { }, { } - local reverse = spec.order == variables.reverse + local reverse = spec.order == v_reverse local kind = spec.type or "number" - local v_first, v_next, v_previous, v_last = variables.first, variables.next, variables.previous, variables.last local data = cd.data for k=1,#data do local v = data[k] @@ -446,7 +520,7 @@ function counters.converted(name,spec) -- name can be number and reference to st vn = v.first elseif kind == v_next then vn = v.next - elseif kind == v_previous then + elseif kind == v_prev or kind == v_previous then vn = v.prev elseif kind == v_last then vn = v.last @@ -498,7 +572,7 @@ function commands.showcounter(name) local data = cd.data for i=1,#data do local d = data[i] - context(" (%s: %s,%s,%s s:%s r:%s)",i,(d.start or 0),d.number or 0,d.last,d.step or 0,d.range or 0) + context(" (%s: %s,%s,%s s:%s r:%s)",i,d.start or 0,d.number or 0,d.last,d.step or 0,d.range or 0) end context("]") end @@ -543,7 +617,7 @@ end --~ return cd, false, "no section data" --~ end --~ -- local preferences ---~ local no = variables.no +--~ local no = v_no --~ if counterspecification and counterspecification.prefix == no then --~ return cd, false, "current spec blocks prefix" --~ end diff --git a/tex/context/base/strc-num.mkiv b/tex/context/base/strc-num.mkiv index 0b8f72e53..2209540ac 100644 --- a/tex/context/base/strc-num.mkiv +++ b/tex/context/base/strc-num.mkiv @@ -19,6 +19,7 @@ % work in progress % to be checked: can we use the command handler code here? +% all settings will move to lua \installcorenamespace{counter} @@ -31,7 +32,7 @@ % \c!prefixstopper=, \c!prefixconnector=., \c!prefixsegments=\autostructureprefixsegments\sharedcounterparameter, - \c!start=0, + \c!start=\zerocount, \c!prefix=\v!yes, \c!state=\v!start] @@ -79,9 +80,10 @@ \def\strc_counters_define_yes[#1][#2]% {\getparameters[\??counter#1][\s!counter=,#2]% counter is for internal purposes + \edef\p_start{\counterparameter{#1}\c!start}% \ctxcommand{definecounter { name = "#1", - start = tonumber("\counterparameter{#1}\c!start") or 0, + start = \ifx\p_start\empty0\else\number\p_start\fi, counter = "\counterparameter{#1}\s!counter", method = "\counterparameter{#1}\c!method", }}% @@ -94,8 +96,12 @@ \unexpanded\def\setupcounter {\dodoubleargument\strc_counters_setup} +% \def\strc_counters_setup[#1][#2]% +% {\getparameters[\??counter#1][\c!start=,#2]% hm, start +% \strc_counters_check_setup{#1}} + \def\strc_counters_setup[#1][#2]% - {\getparameters[\??counter#1][\c!start=,#2]% + {\getparameters[\??counter#1][#2]% no start here \strc_counters_check_setup{#1}} % % % % @@ -119,7 +125,8 @@ % it's a clone \else \edef\currentcounterlevel{\thenamedcounterlevel{#1}}% - \ctxcommand{checkcountersetup("#1",\currentcounterlevel,"\counterparameter{#1}\c!start","\counterparameter{#1}\c!state")}% + \edef\p_start{\counterparameter{#1}\c!start}% + \ctxcommand{checkcountersetup("#1",\currentcounterlevel,\ifx\p_start\empty0\else\number\p_start\fi,"\counterparameter{#1}\c!state")}% \fi} \unexpanded\def\doifcounterelse #1{\ctxcommand{doifelsecounter("\strc_counters_the{#1}")}} @@ -635,9 +642,10 @@ \let\m_strc_counters_last_registered_synchronize\relax \def\strc_counter_setup_using_parameter#1#2% name \someparameter - {\setupcounter + {\edef\p_start{#2\c!start}% + \setupcounter [#1] - [ \c!start=#2\c!start, + [ \c!start=\ifx\p_start\empty0\else\number\p_start\fi, \c!state=#2\c!state, % beware, "" == start \c!way=#2\c!way, % diff --git a/tex/context/base/strc-pag.lua b/tex/context/base/strc-pag.lua index 460d4ff00..e154c4d26 100644 --- a/tex/context/base/strc-pag.lua +++ b/tex/context/base/strc-pag.lua @@ -69,6 +69,9 @@ function pages.save(prefixdata,numberdata) end end +-- We can set th epagenumber but as it only get incremented in the page +-- builder we have to make sure it starts at least at 1. + function counters.specials.userpage() local r = texcount.realpageno if r > 0 then @@ -78,8 +81,15 @@ function counters.specials.userpage() if trace_pages then report_pages("forcing pagenumber of realpage %s to %s",r,t.number) end + return end end + local u = texcount.userpageno + if u == 0 then + report_pages("forcing pagenumber of realpage %s to %s (probably a bug)",r,1) + counter.setvalue("userpage",1) + texcount.userpageno = 1 + end end local function convertnumber(str,n) diff --git a/tex/context/base/strc-ren.mkiv b/tex/context/base/strc-ren.mkiv index ba14bb59f..f22df120f 100644 --- a/tex/context/base/strc-ren.mkiv +++ b/tex/context/base/strc-ren.mkiv @@ -635,8 +635,8 @@ \stopsetups \defineheadalternative - [\v!inmargin] [\v!margin] + [\v!inmargin] % \startsetups[\??headrenderings:\v!vertical:\v!margin] % \directsetup{\??headrenderings:\v!vertical:\v!inmargin} diff --git a/tex/context/interface/keys-cs.xml b/tex/context/interface/keys-cs.xml index 2499ad8db..3a1e12ed3 100644 --- a/tex/context/interface/keys-cs.xml +++ b/tex/context/interface/keys-cs.xml @@ -459,6 +459,7 @@ <cd:variable name='subforward' value='podvpred'/> <cd:variable name='subject' value='tema'/> <cd:variable name='subpage' value='podstranka'/> + <cd:variable name='subs' value='subs'/> <cd:variable name='subsection' value='podsekce'/> <cd:variable name='subsubject' value='podtema'/> <cd:variable name='subsubsection' value='podpodsekce'/> diff --git a/tex/context/interface/keys-de.xml b/tex/context/interface/keys-de.xml index 5ba370a6d..a19679f49 100644 --- a/tex/context/interface/keys-de.xml +++ b/tex/context/interface/keys-de.xml @@ -459,6 +459,7 @@ <cd:variable name='subforward' value='untervorwaerts'/> <cd:variable name='subject' value='thema'/> <cd:variable name='subpage' value='unterseite'/> + <cd:variable name='subs' value='subs'/> <cd:variable name='subsection' value='unterabsatz'/> <cd:variable name='subsubject' value='unterthema'/> <cd:variable name='subsubsection' value='unterunterabsatz'/> diff --git a/tex/context/interface/keys-en.xml b/tex/context/interface/keys-en.xml index fa765aa54..264e9086a 100644 --- a/tex/context/interface/keys-en.xml +++ b/tex/context/interface/keys-en.xml @@ -459,6 +459,7 @@ <cd:variable name='subforward' value='subforward'/> <cd:variable name='subject' value='subject'/> <cd:variable name='subpage' value='subpage'/> + <cd:variable name='subs' value='subs'/> <cd:variable name='subsection' value='subsection'/> <cd:variable name='subsubject' value='subsubject'/> <cd:variable name='subsubsection' value='subsubsection'/> diff --git a/tex/context/interface/keys-fr.xml b/tex/context/interface/keys-fr.xml index b668bd35c..bd1215a05 100644 --- a/tex/context/interface/keys-fr.xml +++ b/tex/context/interface/keys-fr.xml @@ -459,6 +459,7 @@ <cd:variable name='subforward' value='sousavance'/> <cd:variable name='subject' value='sujet'/> <cd:variable name='subpage' value='souspage'/> + <cd:variable name='subs' value='subs'/> <cd:variable name='subsection' value='soussection'/> <cd:variable name='subsubject' value='soussujet'/> <cd:variable name='subsubsection' value='soussoussection'/> diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml index df260ffa4..a4af3e41f 100644 --- a/tex/context/interface/keys-it.xml +++ b/tex/context/interface/keys-it.xml @@ -459,6 +459,7 @@ <cd:variable name='subforward' value='sottoavanti'/> <cd:variable name='subject' value='argomento'/> <cd:variable name='subpage' value='sottopagina'/> + <cd:variable name='subs' value='subs'/> <cd:variable name='subsection' value='sottocapoverso'/> <cd:variable name='subsubject' value='sottoargomento'/> <cd:variable name='subsubsection' value='sottosottocapoverso'/> diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml index 5dd2f83dd..7428ac813 100644 --- a/tex/context/interface/keys-nl.xml +++ b/tex/context/interface/keys-nl.xml @@ -459,6 +459,7 @@ <cd:variable name='subforward' value='subvooruit'/> <cd:variable name='subject' value='onderwerp'/> <cd:variable name='subpage' value='subpagina'/> + <cd:variable name='subs' value='subs'/> <cd:variable name='subsection' value='subparagraaf'/> <cd:variable name='subsubject' value='subonderwerp'/> <cd:variable name='subsubsection' value='subsubparagraaf'/> diff --git a/tex/context/interface/keys-pe.xml b/tex/context/interface/keys-pe.xml index 2128680e7..832bb60e6 100644 --- a/tex/context/interface/keys-pe.xml +++ b/tex/context/interface/keys-pe.xml @@ -459,6 +459,7 @@ <cd:variable name='subforward' value='زیرجلوگرد'/> <cd:variable name='subject' value='موضوع'/> <cd:variable name='subpage' value='زیرصفحه'/> + <cd:variable name='subs' value='subs'/> <cd:variable name='subsection' value='زیربخش'/> <cd:variable name='subsubject' value='زیرموضوع'/> <cd:variable name='subsubsection' value='زیرزیربخش'/> diff --git a/tex/context/interface/keys-ro.xml b/tex/context/interface/keys-ro.xml index 915a0c226..8b6aac94e 100644 --- a/tex/context/interface/keys-ro.xml +++ b/tex/context/interface/keys-ro.xml @@ -459,6 +459,7 @@ <cd:variable name='subforward' value='subavans'/> <cd:variable name='subject' value='subiect'/> <cd:variable name='subpage' value='subpagina'/> + <cd:variable name='subs' value='subs'/> <cd:variable name='subsection' value='subsectiune'/> <cd:variable name='subsubject' value='subsubiect'/> <cd:variable name='subsubsection' value='subsubsectiune'/> diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index b92bf2ab3..b6eabbeb4 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 : 07/17/12 00:23:01 +-- merge date : 07/17/12 16:42:27 do -- begin closure to overcome local limits and interference |