summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/base/lpdf-ano.lua71
-rw-r--r--tex/context/base/lpdf-wid.lua2
-rw-r--r--tex/context/base/mult-cld.lua65
-rw-r--r--tex/context/base/mult-sys.tex6
-rw-r--r--tex/context/base/node-ref.lua5
-rw-r--r--tex/context/base/page-flt.lua51
-rw-r--r--tex/context/base/page-flt.mkiv61
-rw-r--r--tex/context/base/page-mul.mkiv14
-rw-r--r--tex/context/base/page-one.mkiv14
-rw-r--r--tex/context/base/page-set.mkiv8
-rw-r--r--tex/context/base/sort-ini.lua2
-rw-r--r--tex/context/base/strc-flt.mkii2
-rw-r--r--tex/context/base/strc-flt.mkiv74
-rw-r--r--tex/context/base/strc-num.lua8
-rw-r--r--tex/context/base/strc-ref.lua110
-rw-r--r--tex/context/base/strc-reg.lua10
-rw-r--r--tex/context/base/strc-reg.mkiv1
-rw-r--r--tex/context/base/syst-lua.mkiv5
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua2
22 files changed, 333 insertions, 184 deletions
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 33f4b7d6d..e400dfaa0 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -45,6 +45,4 @@
buffers.change_state = logs.obsolete("buffers.change_state","buffers.finishstate")
\stopluacode
-\def\luaexpr#1{\ctxlua{tex.sprint(tex.ctxcatcodes,tostring(#1))}} % todo: other catcode regimes
-
\protect \endinput
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 3020a29c8..eaec0cc5c 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2010.10.11 01:11}
+\newcontextversion{2010.10.12 01:03}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index d2c821541..218dba703 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2010.10.11 01:11}
+\edef\contextversion{2010.10.12 01:03}
%D For those who want to use this:
diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua
index 05be69810..839930238 100644
--- a/tex/context/base/lpdf-ano.lua
+++ b/tex/context/base/lpdf-ano.lua
@@ -33,7 +33,6 @@ local javascriptcode = interactions.javascripts.code
local references = structures.references
local bookmarks = structures.bookmarks
-local references = structures.references
local runners = references.runners
local specials = references.specials
@@ -131,44 +130,26 @@ local function link(url,filename,destination,page,actions)
NewWindow = (actions.newwindow and true) or nil,
}
elseif destination and destination ~= "" then
- local realpage, p = texcount.realpageno, tonumber(page)
- if not p then
- -- sorry
- elseif p > realpage then
- texcount.referencepagestate = 3
- elseif p < realpage then
- texcount.referencepagestate = 2
- else
- texcount.referencepagestate = 1
- end
+ local p = references.checkedpage(actions.n,page)
return pdfdictionary { -- can be cached
S = pdf_goto,
D = destination,
}
elseif page and page ~= "" then
- local realpage, p = texcount.realpageno, tonumber(page)
- if p then
- if p > realpage then
- texcount.referencepagestate = 3
- elseif p < realpage then
- texcount.referencepagestate = 2
- else
- texcount.referencepagestate = 1
- end
- if p > 0 then
- --~ return gotopagedestination(p)
- --~ return pdfdictionary { -- can be cached
- --~ S = pdf_goto,
- --~ D = pagedestination(p),
- --~ }
- return pdfdictionary { -- can be cached
- S = pdf_goto,
- D = pdfarray {
- pdfreference(pdfpagereference(p)),
- pdf_fit,
- }
+ local p = references.checkedpage(actions.n,page)
+ if p and p > 0 then
+ --~ return gotopagedestination(p)
+ --~ return pdfdictionary { -- can be cached
+ --~ S = pdf_goto,
+ --~ D = pagedestination(p),
+ --~ }
+ return pdfdictionary { -- can be cached
+ S = pdf_goto,
+ D = pdfarray {
+ pdfreference(pdfpagereference(p)),
+ pdf_fit,
}
- end
+ }
else
commands.writestatus("references","invalid page reference: %s",page or "?")
end
@@ -227,7 +208,7 @@ local function pdfaction(actions)
return nil
end
end
- return first
+ return first, actions.n
end
end
end
@@ -235,16 +216,18 @@ end
lpdf.action = pdfaction
function codeinjections.prerollreference(actions) -- share can become option
- local main = actions and pdfaction(actions)
- if main then
- main = pdfdictionary {
- Subtype = pdf_link,
- Border = pdf_border,
- H = (not actions.highlight and pdf_n) or nil,
- A = pdfshareobjectreference(main),
- F = 4, -- print (mandate in pdf/a)
- }
- return main("A")
+ if actions then
+ local main, n = pdfaction(actions)
+ if main then
+ main = pdfdictionary {
+ Subtype = pdf_link,
+ Border = pdf_border,
+ H = (not actions.highlight and pdf_n) or nil,
+ A = pdfshareobjectreference(main),
+ F = 4, -- print (mandate in pdf/a)
+ }
+ return main("A"), n
+ end
end
end
diff --git a/tex/context/base/lpdf-wid.lua b/tex/context/base/lpdf-wid.lua
index fe02196dc..e45e9727c 100644
--- a/tex/context/base/lpdf-wid.lua
+++ b/tex/context/base/lpdf-wid.lua
@@ -10,7 +10,7 @@ local format, gmatch, gsub, find = string.format, string.gmatch, string.gsub, st
local texsprint, ctxcatcodes, texbox, texcount = tex.sprint, tex.ctxcatcodes, tex.box, tex.count
local settings_to_array = utilities.parsers.settings_to_array
-local report_media = logs.report("media")
+local report_media = logs.new("media")
local backends, lpdf, nodes = backends, lpdf, nodes
diff --git a/tex/context/base/mult-cld.lua b/tex/context/base/mult-cld.lua
index 3d3194b69..edc4253a9 100644
--- a/tex/context/base/mult-cld.lua
+++ b/tex/context/base/mult-cld.lua
@@ -16,6 +16,8 @@ if not modules then modules = { } end modules ['mult-cld'] = {
-- Todo: optional checking against interface
-- Todo: coroutine trickery
+-- tflush needs checking ... sort of weird that it's not a table
+
context = context or { }
local context = context
@@ -26,6 +28,7 @@ local insert, remove = table.insert, table.remove
local tex = tex
local texsprint = tex.sprint
+local textprint = tex.tprint
local texprint = tex.print
local texiowrite = texio.write
local texcount = tex.count
@@ -33,7 +36,7 @@ local ctxcatcodes = tex.ctxcatcodes
local prtcatcodes = tex.prtcatcodes
local vrbcatcodes = tex.vrbcatcodes
-local flush = texsprint or function(cct,...) print(concat{...}) end
+local flush = texsprint
local report_cld = logs.new("cld")
@@ -99,10 +102,10 @@ local trace_context = logs.new("context") -- here
function context.trace(intercept)
local normalflush = flush
- flush = function(c,...)
- trace_context(concat({...}))
+ flush = function(...)
+ trace_context(concat({...},"",2))
if not intercept then
- normalflush(c,...)
+ normalflush(...)
end
end
context.trace = function() end
@@ -114,13 +117,18 @@ end
function context.setflush(newflush)
local oldflush = flush
- flush = newflush
+ flush = newflush or flush
return oldflush
end
trackers.register("context.flush", function(v) if v then context.trace() end end)
trackers.register("context.intercept", function(v) if v then context.trace(true) end end)
+--~ context.trace()
+
+-- beware, we had command as part of the flush and made it "" afterwards so that we could
+-- keep it there (...,command,...) but that really confuses the tex machinery
+
local function writer(command,first,...) -- 5% faster than just ... and separate flush of command
if not command then
-- error
@@ -128,25 +136,37 @@ local function writer(command,first,...) -- 5% faster than just ... and separate
flush(currentcatcodes,command)
else
local t = { first, ... }
+ flush(currentcatcodes,command)
for i=1,#t do
- if i == 2 then
- command = ""
- end
local ti = t[i]
local typ = type(ti)
if ti == nil then
- flush(currentcatcodes,command)
- elseif typ == "string" or typ == "number" then
- flush(currentcatcodes,command,"{",ti,"}")
+ -- nothing
+ elseif typ == "string" then
+ if ti == "" then
+ flush(currentcatcodes,"{}")
+ else
+ flush(currentcatcodes,"{",ti,"}")
+ end
+ elseif typ == "number" then
+ flush(currentcatcodes,"{",ti,"}")
elseif typ == "table" then
local tn = #ti
if tn == 0 then
local done = false
for k, v in next, ti do
if done then
- flush(currentcatcodes,",",k,'=',v)
+ if v == "" then
+ flush(currentcatcodes,",",k,'=')
+ else
+ flush(currentcatcodes,",",k,'=',v)
+ end
else
- flush(currentcatcodes,command,"[",k,'=',v)
+ if v == "" then
+ flush(currentcatcodes,"[",k,'=')
+ else
+ flush(currentcatcodes,"[",k,'=',v)
+ end
done = true
end
end
@@ -154,34 +174,32 @@ local function writer(command,first,...) -- 5% faster than just ... and separate
elseif tn == 1 then -- some 20% faster than the next loop
local tj = ti[1]
if type(tj) == "function" then
- flush(currentcatcodes,command,"[\\mkivflush{",_store_(tj),"}]")
+ flush(currentcatcodes,"[\\mkivflush{",_store_(tj),"}]")
else
- flush(currentcatcodes,command,"[",tj,"]")
+ flush(currentcatcodes,"[",tj,"]")
end
- else -- is concat really faster than flushes here?
+ else -- is concat really faster than flushes here? probably needed anyway (print artifacts)
for j=1,tn do
local tj = ti[j]
if type(tj) == "function" then
ti[j] = "\\mkivflush{" .. _store_(tj) .. "}"
end
end
- flush(currentcatcodes,command,"[",concat(ti,","),"]")
+ flush(currentcatcodes,"[",concat(ti,","),"]")
end
elseif typ == "function" then
- flush(currentcatcodes,command,"{\\mkivflush{",_store_(ti),"}}")
+ flush(currentcatcodes,"{\\mkivflush{",_store_(ti),"}}")
-- elseif typ == "boolean" then
-- flush(currentcatcodes,"\n")
elseif ti == true then
- flush(currentcatcodes,command,"\n")
+ flush(currentcatcodes,"\n")
elseif typ == false then
-- if force == "direct" then
- flush(currentcatcodes,command,tostring(ti))
+ flush(currentcatcodes,tostring(ti))
-- end
elseif typ == "thread" then
- flush(currentcatcodes,command)
trace_context("coroutines not supported as we cannot yield across boundaries")
else
- flush(currentcatcodes,command)
trace_context("error: %s gets a weird argument %s",command,tostring(ti))
end
end
@@ -191,9 +209,6 @@ end
--~ experiments.register("context.writer",function()
--~ writer = newwriter
--~ end)
-
--- -- --
-
local function indexer(t,k)
local c = "\\" .. k .. " "
local f = function(...) return writer(c,...) end
diff --git a/tex/context/base/mult-sys.tex b/tex/context/base/mult-sys.tex
index 4f0f6c28b..760c83033 100644
--- a/tex/context/base/mult-sys.tex
+++ b/tex/context/base/mult-sys.tex
@@ -204,6 +204,12 @@
\definesystemconstant {default}
\definesystemconstant {smallcaps}
+\definesystemconstant {text}
+\definesystemconstant {page}
+\definesystemconstant {leftpage}
+\definesystemconstant {rightpage}
+\definesystemconstant {somewhere}
+
%D A more experienced \TEX\ user will recognize the next four
%D constants. We need these because font-definitions are
%D partially english.
diff --git a/tex/context/base/node-ref.lua b/tex/context/base/node-ref.lua
index 0473e4523..082f1c8b0 100644
--- a/tex/context/base/node-ref.lua
+++ b/tex/context/base/node-ref.lua
@@ -16,6 +16,8 @@ if not modules then modules = { } end modules ['node-bck'] = {
-- is grouplevel still used?
+local allocate, mark = utilities.storage.allocate, utilities.storage.mark
+
local cleanupreferences, cleanupdestinations = false, true
local attributes, nodes, node = attributes, nodes, node
@@ -378,7 +380,7 @@ local function makereference(width,height,depth,reference)
if trace_references then
report_backends("resolving reference attribute %s",reference)
end
- local resolved, ht, dp, set = sr[1], sr[2], sr[3], sr[4]
+ local resolved, ht, dp, set, n = sr[1], sr[2], sr[3], sr[4], sr[5]
if ht then
if height < ht then height = ht end
if depth < dp then depth = dp end
@@ -398,6 +400,7 @@ local function makereference(width,height,depth,reference)
else
result = annot
end
+ references.registerpage(n)
result = hpack_list(result,0)
result.width, result.height, result.depth = 0, 0, 0
if cleanupreferences then stack[reference] = nil end
diff --git a/tex/context/base/page-flt.lua b/tex/context/base/page-flt.lua
index 6b6755c22..a1798adc9 100644
--- a/tex/context/base/page-flt.lua
+++ b/tex/context/base/page-flt.lua
@@ -18,6 +18,8 @@ local trace_floats = false trackers.register("graphics.floats", function(v) tra
local report_floats = logs.new("floats")
+local C, S, P, lpegmatch = lpeg.C, lpeg.S, lpeg.P, lpeg.match
+
-- we use floatbox, floatwidth, floatheight
-- text page leftpage rightpage (todo: top, bottom, margin, order)
@@ -32,6 +34,7 @@ local function initialize()
page = { },
leftpage = { },
rightpage = { },
+ somewhere = { },
}
end
@@ -76,12 +79,21 @@ local function setdimensions(b)
return w, h, d
end
-local function get(stack,n)
- n = n or #stack
- if n > 0 then
- local t = stack[n]
- if t then
- return t, t.box, n
+local function get(stack,n,bylabel)
+ if bylabel then
+ for i=1,#stack do
+ local s = stack[i]
+ if s.data.label == n then
+ return s, s.box, i
+ end
+ end
+ else
+ n = n or #stack
+ if n > 0 then
+ local t = stack[n]
+ if t then
+ return t, t.box, n
+ end
end
end
end
@@ -131,10 +143,10 @@ function floats.resave(which)
end
end
-function floats.flush(which,n)
+function floats.flush(which,n,bylabel)
which = which or default
local stack = stacks[which]
- local t, b, n = get(stack,n or 1)
+ local t, b, n = get(stack,n or 1,bylabel)
if t then
local w, h, d = setdimensions(b)
if trace_floats then
@@ -234,3 +246,26 @@ function floats.thecheckedpagefloat(packed)
end
texsprint(ctxcatcodes,result)
end
+
+local method = C((1-S(", :"))^1)
+local position = P(":") * C((1-S("*,"))^1) * P("*") * C((1-S(","))^1)
+local label = P(":") * C((1-S(",*: "))^0)
+
+local pattern = method * (label * position + C("") * position + label + C("") * C("") * C(""))
+
+-- table.print { lpeg.match(pattern,"somewhere:blabla,crap") }
+-- table.print { lpeg.match(pattern,"somewhere:1*2") }
+-- table.print { lpeg.match(pattern,"somewhere:blabla:1*2") }
+-- table.print { lpeg.match(pattern,"somewhere::1*2") }
+-- table.print { lpeg.match(pattern,"somewhere,") }
+-- table.print { lpeg.match(pattern,"somewhere") }
+
+function floats.analysemethod(str)
+ if str ~= "" then -- extra check, already done at the tex end
+ local method, label, row, column = lpegmatch(pattern,str)
+ context.setvalue("floatmethod",method or "")
+ context.setvalue("floatlabel", label or "")
+ context.setvalue("floatrow", row or "")
+ context.setvalue("floatcolumn",column or "")
+ end
+end
diff --git a/tex/context/base/page-flt.mkiv b/tex/context/base/page-flt.mkiv
index 370b40e89..9857bb0ea 100644
--- a/tex/context/base/page-flt.mkiv
+++ b/tex/context/base/page-flt.mkiv
@@ -75,6 +75,10 @@
{\ctxlua{floats.flush("#1",\number#2)}%
\the\everyfloatscheck}
+\def\dofloatsflushbylabel#1#2%
+ {\ctxlua{floats.flush("#1","#2",true)}%
+ \the\everyfloatscheck}
+
\def\dofloatssave#1%
{\ctxlua{floats.save("#1")}%
\the\everyfloatscheck}
@@ -112,6 +116,31 @@
\def\dofloatssavepagefloat#1#2%
{\ctxlua{floats.save("#1", { specification = "#2" })}}
+\def\dofloatssavesomewherefloat#1#2% #1=method
+ {\ctxlua{floats.save("#1", { specification = "#2", label = "\floatlabel" })}}
+
+%D This is an experimental new feature (for Alan Braslau), a prelude to more:
+%D
+%D \starttyping
+%D test \placefigure{}{}
+%D test \placefigure[somewhere:123][whatever]{}{}
+%D test \placefigure[somewhere:456][whatever]{}{}
+%D test \placefigure{}{}
+%D
+%D \placenamedfloat[figure][456]
+%D \placenamedfloat[figure][123]
+%D \stoptyping
+
+\def\placenamedfloat
+ {\dodoubleargument\doplacenamedfloat}
+
+\def\doplacenamedfloat[#1][#2]%
+ {\def\currentfloat{#1}%
+ \blank[\@@bkspacebefore]%
+ \dofloatsflushbylabel\s!somewhere{#2}%
+ \box\floatbox
+ \blank[\@@bkspaceafter]}
+
%D The following code is in transition as we don't want to break the
%D current single column, multi column, and columnset mechanism.
%D
@@ -119,7 +148,7 @@
\def\dogetfloat
{\ifsomefloatwaiting
- \dofloatsflush{text}{1}%
+ \dofloatsflush\s!text{1}%
\ifcenterfloatbox
\ifdim\wd\globalscratchbox<\hsize
\global\setbox\floatbox\hbox to \hsize{\hss\box\floatbox\hss}%
@@ -138,14 +167,14 @@
\fi}
\def\dosavefloat
- {\dofloatssave{text}%
+ {\dofloatssave\s!text
\nonoindentation} % brrr nonoindentation here
\def\doresavefloat
- {\dofloatsresave{text}}
+ {\dofloatsresave\s!text}
\def\doreversesavefloat
- {\dofloatsresave{text}}
+ {\dofloatsresave\s!text}
\def\doflushsavedfloats % simplified \OTRONEdodoflushfloats
{\doloop
@@ -177,21 +206,21 @@
% \def\doflushpagefloats
% {\doifoddpageelse
-% {\ifnum\dofloatsnofstacked{rightpage}>\zerocount
-% \doflushsomepagefloat{rightpage}%
-% \else\ifnum\dofloatsnofstacked{page}>\zerocount
-% \doflushsomepagefloat{page}
-% \else\ifnum\dofloatsnofstacked{leftpage}>\zerocount
+% {\ifnum\dofloatsnofstacked\s!rightpage>\zerocount
+% \doflushsomepagefloat\s!rightpage
+% \else\ifnum\dofloatsnofstacked\s!page>\zerocount
+% \doflushsomepagefloat\s!page
+% \else\ifnum\dofloatsnofstacked\s!leftpage>\zerocount
% \null\vfill\eject
-% %\doflushsomepagefloat{leftpage}%
+% %\doflushsomepagefloat\s!leftpage
% \fi\fi\fi}
-% {\ifnum\dofloatsnofstacked{leftpage}>\zerocount
-% \doflushsomepagefloat{leftpage}%
-% \else\ifnum\dofloatsnofstacked{page}>\zerocount
-% \doflushsomepagefloat{page}
-% \else\ifnum\dofloatsnofstacked{rightpage}>\zerocount
+% {\ifnum\dofloatsnofstacked\s!leftpage>\zerocount
+% \doflushsomepagefloat\s!leftpage
+% \else\ifnum\dofloatsnofstacked\s!page>\zerocount
+% \doflushsomepagefloat\s!page
+% \else\ifnum\dofloatsnofstacked\s!rightpage>\zerocount
% \null\vfill\eject
-% %\doflushsomepagefloat{rightpage}%
+% %\doflushsomepagefloat\s!rightpage
% \fi\fi\fi}}
\def\doflushpagefloats
diff --git a/tex/context/base/page-mul.mkiv b/tex/context/base/page-mul.mkiv
index 70f5bd337..b7efb8782 100644
--- a/tex/context/base/page-mul.mkiv
+++ b/tex/context/base/page-mul.mkiv
@@ -1329,7 +1329,7 @@
\else
\bgroup
\getcolumnstatus\column\count255\total\dimen0\goal\dimen2\\%
- \dofloatsgetinfo{text}%
+ \dofloatsgetinfo\s!text
\setbox\scratchbox\vbox % tricky met objecten ?
{\blank[\@@bkspacebefore]
\snaptogrid\vbox{\vskip\floatheight}}% copy?
@@ -1359,7 +1359,7 @@
\let\doflushcolumnfloat\relax
\getcolumnstatus\column\mofcolumns\total\dimen0\goal\dimen2\\%
\ifdim\dimen0>\zeropoint
- \dofloatsgetinfo{text}%
+ \dofloatsgetinfo\s!text
\ifdim\floatwidth>\hsize
% dropped ?
\else
@@ -1371,7 +1371,7 @@
\ifnum\mofcolumns<\nofcolumns
\advance\mofcolumns \plusone
\ifdim\ht\currenttopcolumnbox=\zeropoint
- \dofloatsflush{text}{1}%
+ \dofloatsflush\s!text{1}%
\global\setbox\currenttopcolumnbox\vbox
{\snaptogrid\vbox{\box\floatbox}
\whitespace % nodig ?
@@ -1395,7 +1395,7 @@
\blank[\@@bkspacebefore]
\nobreak
\fi
- \dofloatsflush{text}{1}%
+ \dofloatsflush\s!text{1}%
\flushfloatbox
\blank[\@@bkspaceafter]
\fi
@@ -1436,7 +1436,7 @@
\whitespace % nodig ?
\blank[\@@bkspaceafter]}%
\else
- \dofloatsgetinfo{text}%
+ \dofloatsgetinfo\s!text
\ifdim\floatwidth>\hsize
\dimen0\dimexpr\floatwidth+\intercolumnwidth+.5pt\relax
\dimen2\dimexpr\hsize +\intercolumnwidth+.5pt\relax
@@ -1447,7 +1447,7 @@
\count0\zerocount
\else
\dimen0\dimexpr\count0\hsize+\count0\intercolumnwidth-\intercolumnwidth\relax
- \dofloatsflush{text}{1}%
+ \dofloatsflush\s!text{1}%
\ifdim\floatwidth>\finalcolumntextwidth % better somewhere else too
\global\setbox\floatbox\hbox to \finalcolumntextwidth{\hss\box\floatbox\hss}%
\fi % otherwise the graphic may disappear
@@ -1460,7 +1460,7 @@
\fi
\showmessage\m!columns{13}\empty
\else
- \dofloatsflush{text}{1}%
+ \dofloatsflush\s!text{1}%
\ifdim\floatwidth>\finalcolumntextwidth % better somewhere else too
\global\setbox\floatbox\hbox to \finalcolumntextwidth{\hss\box\floatbox\hss}%
\fi % otherwise the graphic may disappear
diff --git a/tex/context/base/page-one.mkiv b/tex/context/base/page-one.mkiv
index 1ac769637..e150d453a 100644
--- a/tex/context/base/page-one.mkiv
+++ b/tex/context/base/page-one.mkiv
@@ -343,15 +343,15 @@
{\ifsomefloatwaiting
\ifpackflushedfloats
\centerfloatboxfalse % not needed as we do call directly
- \dofloatscollect{text}{\hsize}{1em}%
+ \dofloatscollect\s!text{\hsize}{1em}%
\OTRONEsetvsize
\global\setbox\floatbox\hbox to \hsize
{\hfil
\dorecurse\nofcollectedfloats
{\ifcase\columndirection % nog document wide
- \dofloatsflush{text}{1}%
+ \dofloatsflush\s!text{1}%
\else
- \dofloatsflushn{text}{\the\numexpr\nofcollectedfloats-\recurselevel+1\relax}%
+ \dofloatsflushn\s!text{\the\numexpr\nofcollectedfloats-\recurselevel+1\relax}%
\fi
\ifdim\wd\floatbox>\makeupwidth % \hsize
\hbox to \makeupwidth{\hss\box\floatbox\hss}%
@@ -490,9 +490,11 @@
\doifinset\v!tall{#1}\flushsidefloatsafterpar
\fi}
-\def\OTRONEsomepagefloat [#1]{\dofloatssavepagefloat{page} {#1}}
-\def\OTRONEsomeleftpagefloat [#1]{\dofloatssavepagefloat{leftpage} {#1}}
-\def\OTRONEsomerightpagefloat[#1]{\dofloatssavepagefloat{rightpage}{#1}}
+\def\OTRONEsomepagefloat [#1]{\dofloatssavepagefloat {\s!page} {#1}}
+\def\OTRONEsomeleftpagefloat [#1]{\dofloatssavepagefloat {\s!leftpage} {#1}}
+\def\OTRONEsomerightpagefloat[#1]{\dofloatssavepagefloat {\s!rightpage}{#1}}
+
+%def\OTRONEsomesoemwherefloat[#1]{\dofloatssavesomewherefloat{\s!somewhere}{#1}}
\def\OTRONEsometopsfloat[#1]%
{\ifdim\topinserted=\zeropoint
diff --git a/tex/context/base/page-set.mkiv b/tex/context/base/page-set.mkiv
index 0cb83a1dc..f2e11e8a0 100644
--- a/tex/context/base/page-set.mkiv
+++ b/tex/context/base/page-set.mkiv
@@ -1333,11 +1333,11 @@
\def\OTRSETsavebox#1% clean up the skips
{\OTRSETunpreparebox{#1}%
- \dofloatssave{text}}
+ \dofloatssave\s!text}
\def\OTRSETresavebox#1% clean up the skips
{\OTRSETunpreparebox{#1}%
- \dofloatsresave{text}}
+ \dofloatsresave\s!text}
\def\OTRSETflushfloatbox % nog verder doorvoeren en meer info in marge
{\iftestfloatbox\ruledhbox\fi{\box\floatbox}}
@@ -1348,10 +1348,10 @@
\doloop
{\ifsomefloatwaiting
\OTRSETskipstart
- \dofloatsgetinfo{text}%
+ \dofloatsgetinfo\s!text
\ifdim\floatwidth>\zeropoint
\!!doneatrue
- \dofloatsflush{text}{1}%
+ \dofloatsflush\s!text{1}%
\dp\floatbox\zeropoint
\OTRSETstoreincolumnslot{TBLR}\floatbox
\if!!donea
diff --git a/tex/context/base/sort-ini.lua b/tex/context/base/sort-ini.lua
index a8ad1a6e0..548a92efe 100644
--- a/tex/context/base/sort-ini.lua
+++ b/tex/context/base/sort-ini.lua
@@ -103,7 +103,7 @@ local replacements, m_mappings, z_mappings, p_mappings, entries, orders, lower,
local mte = {
__index = function(t,k)
- if utfbyte(k) < digitsoffset then
+ if k ~= "" and utfbyte(k) < digitsoffset then
local el
if k then
local l = lower[k] or lcchars[k]
diff --git a/tex/context/base/strc-flt.mkii b/tex/context/base/strc-flt.mkii
index 62d02aa2a..3d07cdc20 100644
--- a/tex/context/base/strc-flt.mkii
+++ b/tex/context/base/strc-flt.mkii
@@ -2035,7 +2035,7 @@
\c!nbottom=0,
\c!nlines=4,
\c!local=,
- \c!default=\v!figure,
+ \c!default=, % was \v!figure but this is the location
\c!numbering=\v!yes]
% float strategy, replaces some of the above macros
diff --git a/tex/context/base/strc-flt.mkiv b/tex/context/base/strc-flt.mkiv
index ff849517f..ce101c870 100644
--- a/tex/context/base/strc-flt.mkiv
+++ b/tex/context/base/strc-flt.mkiv
@@ -110,17 +110,17 @@
\c!textcolor=,
\c!align=,
\c!number=\v!yes,
-% \c!prefix=\v!no,
-% \c!prefixconnector=.,
-% \c!way=\v!by\v!chapter,
-% \c!prefixsegments=2:2,
-% \c!way=\@@nrway,
-% \c!blockway=\@@nrblockway,
-% \c!sectionnumber=\@@nrsectionnumber,
-% \c!separator=\@@koseparator,
-% \c!starter=\@@kostarter,
-% \c!stopper=\@@kostopper,
-% \c!suffix=\floatcaptionsuffix, % hook
+ % \c!prefix=\v!no,
+ % \c!prefixconnector=.,
+ % \c!way=\v!by\v!chapter,
+ % \c!prefixsegments=2:2,
+ % \c!way=\@@nrway,
+ % \c!blockway=\@@nrblockway,
+ % \c!sectionnumber=\@@nrsectionnumber,
+ % \c!separator=\@@koseparator,
+ % \c!starter=\@@kostarter,
+ % \c!stopper=\@@kostopper,
+ % \c!suffix=\floatcaptionsuffix, % hook
\c!distance=1em,
\c!conversion=\v!numbers,
\c!command=]
@@ -169,7 +169,7 @@
\c!local=,
\c!bottombefore=, % e.g. \vfill
\c!bottomafter=,
- \c!default=\v!figure,
+ \c!default=, % default location
\c!numbering=\v!yes]
\def\@@bknumbering {\floatsharedparameter\c!numbering } % global one
@@ -206,7 +206,6 @@
% \c!sectionnumber=\floatcaptionparameter\c!sectionnumber,
% \c!conversion=\floatcaptionparameter\c!conversion]%
-
%D Individial settings:
\unexpanded\def\setupfloat {\dodoubleargument\dosetupfloat}
@@ -302,14 +301,6 @@
\installstructurelistprocessor{float}{\usestructurelistprocessor{number+title}}
-% \def\thecurrentfloatnumber
-% {\ifnofloatcaption \else \ifnofloatnumber \else
-% % \labeltexts\currentfloat{\convertedstructurecounter[\currentfloat]}% ! ! todo: use a lua call instead
-% \ifx\currentfloatnumber\relax\else
-% \labeltexts\currentfloat{\ctxlua{structures.lists.savednumber("\currentfloat",\currentfloatnumber)}}%
-% \fi
-% \fi \fi}
-
\def\thecurrentfloatnumber
{\ifnofloatcaption \else \ifnofloatnumber \else
\ifx\currentfloatnumber\relax\else
@@ -1872,25 +1863,34 @@
% float strategy, replaces some of the above macros
\let\floatmethod \empty
+\let\floatlabel \empty
\let\floatcolumn \empty
\let\floatrow \empty
\let\forcedfloatmethod\empty
+% \def\setfloatmethodvariables#1%
+% {\getfromcommalist[#1][1]%
+% \@EA\beforesplitstring\commalistelement\at:\to\floatmethod
+% \@EA\aftersplitstring \commalistelement\at:\to\floatcolumn
+% \@EA\aftersplitstring \floatcolumn\at*\to\floatrow
+% \@EA\beforesplitstring\floatcolumn\at*\to\floatcolumn}
+
+\def\setfloatmethodvariables#1% \floatmethod \floatlabel \floatrow \floatcolumn
+ {\ctxlua{floats.analysemethod("#1")}}
+
\def\dogetfloatbox#1#2%
{\ifvisible
- \doifelsenothing{#2}
- {\getfromcommalist[#1][1]%
- \@EA\beforesplitstring\commalistelement\at:\to\floatmethod
- \@EA\aftersplitstring \commalistelement\at:\to\floatcolumn
- \@EA\aftersplitstring \floatcolumn\at*\to\floatrow
- \@EA\beforesplitstring\floatcolumn\at*\to\floatcolumn
- % todo: nog algemeen otr
- \ifdefined\OTRSETsetpreferedcolumnslot
- \OTRSETsetpreferedcolumnslot\floatcolumn\floatrow
- \fi}
- {\let\floatcolumn\empty
- \let\floatrow\empty
- \edef\floatmethod{#2}}%
+ \let \floatlabel \empty
+ \let \floatcolumn\empty
+ \let \floatrow \empty
+ \edef\floatmethod{#2}%
+ \ifx\floatmethod\empty
+ \setfloatmethodvariables{#1}%
+ % todo: nog algemeen otr
+ \ifdefined\OTRSETsetpreferedcolumnslot
+ \OTRSETsetpreferedcolumnslot\floatcolumn\floatrow
+ \fi
+ \fi
\doifundefined{\string\floatmethod\floatmethod}
{\let\floatmethod\v!here}%
\doifsomething\forcedfloatmethod
@@ -1902,6 +1902,9 @@
\def\installfloathandler#1#2% #1=keyword #2=handler
{\setvalue{\string\floatmethod#1}{#2}}
+\def\somesomewherefloat[#1]%
+ {\dofloatssavesomewherefloat\s!somewhere{#1}}
+
\installfloathandler \v!here \someherefloat
\installfloathandler \v!force \somefixdfloat
\installfloathandler \v!left \someleftsidefloat
@@ -1923,6 +1926,8 @@
\installfloathandler \v!leftedge \someinleftedgefloat
\installfloathandler \v!rightedge \someinrightedgefloat
+\installfloathandler \v!somewhere \somesomewherefloat
+
\installfloathandler \v!backspace \somebackspacefloat
\installfloathandler \v!cutspace \somecutspacefloat
@@ -1966,6 +1971,7 @@
\unexpanded\def\placesomebotsfloat {\OTRcommand\somebotsfloat}
\unexpanded\def\placesomesidefloat {\OTRcommand\somesidefloat}
\unexpanded\def\placesomefacefloat {\OTRcommand\somefacefloat}
+%unexpanded\def\placesomesomewherefloat{\OTRcommand\somesomewherefloat}
\def\somefixdfloat {\placesomefixdfloat}
\def\somepagefloat {\placesomepagefloat}
diff --git a/tex/context/base/strc-num.lua b/tex/context/base/strc-num.lua
index 72cd75ecf..c2f989070 100644
--- a/tex/context/base/strc-num.lua
+++ b/tex/context/base/strc-num.lua
@@ -125,7 +125,8 @@ local function allocate(name,i)
-- block = "", -- todo
numbers = nil,
state = variables.start, -- true
- data = { }
+ data = { },
+ saved = { },
}
tobesaved[name] = { }
counterdata[name] = cd
@@ -360,15 +361,14 @@ end
function counters.save(name) -- or just number
local cd = counterdata[name]
if cd then
- cd.saved = table.copy(cd.data)
+ table.insert(cd.saved,table.copy(cd.data))
end
end
function counters.restore(name)
local cd = counterdata[name]
if cd and cd.saved then
- cd.data = cd.saved
- cd.saved = nil
+ cd.data = table.remove(cd.saved)
end
end
diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua
index 6811c4da3..12b4b2558 100644
--- a/tex/context/base/strc-ref.lua
+++ b/tex/context/base/strc-ref.lua
@@ -10,6 +10,7 @@ local format, find, gmatch, match, concat = string.format, string.find, string.g
local lpegmatch, lpegP, lpegCs = lpeg.match, lpeg.P, lpeg.Cs
local texsprint, texwrite, texcount, texsetcount = tex.sprint, tex.write, tex.count, tex.setcount
local allocate, mark = utilities.storage.allocate, utilities.storage.mark
+local setmetatable, rawget = setmetatable, rawget
local allocate = utilities.storage.allocate
@@ -53,18 +54,22 @@ local executers = allocate()
local handlers = allocate()
local tobesaved = allocate()
local collected = allocate()
-
-references.derived = derived
-references.specials = specials
-references.runners = runners
-references.internals = internals
-references.exporters = exporters
-references.imported = imported
-references.filters = filters
-references.executers = executers
-references.handlers = handlers
-references.tobesaved = tobesaved
-references.collected = collected
+local tobereferred = allocate()
+local referred = allocate()
+
+references.derived = derived
+references.specials = specials
+references.runners = runners
+references.internals = internals
+references.exporters = exporters
+references.imported = imported
+references.filters = filters
+references.executers = executers
+references.handlers = handlers
+references.tobesaved = tobesaved
+references.collected = collected
+references.tobereferred = tobereferred
+references.referred = referred
storage.register("structures/references/defined", references.defined, "structures.references.defined")
@@ -87,6 +92,7 @@ local function initializer() -- can we use a tobesaved as metatable for collecte
initializers[i](tobesaved,collected)
end
end
+
local function finalizer()
-- tobesaved = mark(references.tobesaved)
for i=1,#finalizers do
@@ -94,10 +100,68 @@ local function finalizer()
end
end
-if job then
- job.register('structures.references.collected', tobesaved, initializer, finalizer)
+job.register('structures.references.collected', tobesaved, initializer, finalizer)
+
+local maxreferred = 1
+
+local function initializer() -- can we use a tobesaved as metatable for collected?
+ tobereferred = mark(references.tobereferred)
+ referred = mark(references.referred)
+
+ function get(t,n) -- catch sparse, a bit slow but who cares
+ for i=n,1,-1 do -- we could make a tree ... too much work
+ local p = rawget(t,i)
+ if p then
+ return p
+ end
+ end
+ end
+ setmetatable(referred, { __index = get })
+end
+
+local function finalizer() -- make sparse
+ local last
+ for i=1,maxreferred do
+ local r = tobereferred[i]
+ if not last then
+ last = r
+ elseif r == last then
+ tobereferred[i] = nil
+ else
+ last = r
+ end
+ end
+end
+
+function references.referredpage(n)
+ return referred[n] or referred[n] or texcount.realpageno
end
+function references.checkedpage(n,page)
+ local r, p = referred[n] or texcount.realpageno, tonumber(page)
+ if not p then
+ -- sorry
+ elseif p > r then
+ texcount.referencepagestate = 3
+ elseif p < r then
+ texcount.referencepagestate = 2
+ else
+ texcount.referencepagestate = 1
+ end
+ return p
+end
+
+function references.registerpage(n)
+ if not tobereferred[n] then
+ if n > maxreferred then
+ maxreferred = n
+ end
+ tobereferred[n] = texcount.realpageno
+ end
+end
+
+job.register('structures.references.referred', tobereferred, initializer, finalizer)
+
-- todo: delay split till later as in destinations we split anyway
local orders, lastorder = { }, 0
@@ -763,12 +827,15 @@ end
local prefixsplitter = lpegCs(lpegP((1-lpegP(":"))^1 * lpegP(":"))) * lpegCs(lpegP(1)^1)
-
-- todo: add lots of tracing here
+local n = 0
+
local function identify(prefix,reference)
local set = resolve(prefix,reference)
local bug = false
+n = n + 1
+set.n = n
for i=1,#set do
local var = set[i]
local special, inner, outer, arguments, operation = var.special, var.inner, var.outer, var.arguments, var.operation
@@ -1131,10 +1198,12 @@ function references.getcurrentmetadata(tag)
texsprint(ctxcatcodes,data)
end
end
+
local function currentmetadata(tag)
local data = currentreference and currentreference.i
return data and data.metadata and data.metadata[tag]
end
+
references.currentmetadata = currentmetadata
function references.getcurrentprefixspec(default) -- todo: message
@@ -1328,16 +1397,7 @@ function references.analyze(actions)
what = what(a,actions)
end
end
- local realpage, p = texcount.realpageno, tonumber(actions.realpage)
- if not p then
- -- sorry
- elseif p > realpage then
- texcount.referencepagestate = 3
- elseif p < realpage then
- texcount.referencepagestate = 2
- else
- texcount.referencepagestate = 1
- end
+ references.checkedpage(actions.n,actions.realpage)
end
end
return actions
diff --git a/tex/context/base/strc-reg.lua b/tex/context/base/strc-reg.lua
index e2fbb9527..59356bf30 100644
--- a/tex/context/base/strc-reg.lua
+++ b/tex/context/base/strc-reg.lua
@@ -292,14 +292,20 @@ function registers.extend(name,tag,rawdata) -- maybe do lastsection internally
rr.lastrealpage = texcount.realpageno
rr.lastsection = sections.currentid()
if rawdata then
- preprocessentries(rawdata)
+ if rawdata.entries then
+ preprocessentries(rawdata)
+ end
for k,v in next, rawdata do
if not r[k] then
r[k] = v
else
local rk = r[k]
for kk,vv in next, v do
- if vv ~= "" then
+ if type(vv) == "table" then
+ if next(vv) then
+ rk[kk] = vv
+ end
+ elseif vv ~= "" then
rk[kk] = vv
end
end
diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv
index f4782d477..f16c27663 100644
--- a/tex/context/base/strc-reg.mkiv
+++ b/tex/context/base/strc-reg.mkiv
@@ -332,6 +332,7 @@
\fi
\globallet\currentregistercoding\s!tex
\fi
+ % I hate this kind of mess ... but it's a user request.
\ifx\currentregisterentries\empty
\normalexpanded{\ctxlua{structures.registers.extend("\currentregister","\currentregisterlabel", {
metadata = {
diff --git a/tex/context/base/syst-lua.mkiv b/tex/context/base/syst-lua.mkiv
index 40cd9f756..f9be10e6d 100644
--- a/tex/context/base/syst-lua.mkiv
+++ b/tex/context/base/syst-lua.mkiv
@@ -34,4 +34,9 @@
\def\writestatus#1#2{\ctxlua{commands.writestatus(\!!bs#1\!!es,\!!bs#2\!!es)}}
+% a handy helper (we can probably omit the tex.ctxcatcodes here as nowadays we seldom
+% change the regime at the tex end
+
+\def\luaexpr#1{\ctxlua{tex.sprint(tex.ctxcatcodes,tostring(#1))}}
+
\protect \endinput
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 23e16c428..415fff8dd 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 10/11/10 01:11:52
+-- merge date : 10/12/10 01:03:01
do -- begin closure to overcome local limits and interference