summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2016-12-21 20:09:16 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-12-21 20:09:16 +0100
commit72e032447232f3f89056f352d3f6b8e2abc499cb (patch)
treedcce6719b22076c68a286ac202ea4245999c0843 /tex/context/base/mkiv
parentae375264381ae74f70415b2351bdbf209248e1af (diff)
downloadcontext-72e032447232f3f89056f352d3f6b8e2abc499cb.tar.gz
2016-12-21 18:57:00
Diffstat (limited to 'tex/context/base/mkiv')
-rw-r--r--tex/context/base/mkiv/back-pdf.mkiv3
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/font-nod.lua18
-rw-r--r--tex/context/base/mkiv/grph-inc.lua14
-rw-r--r--tex/context/base/mkiv/l-number.lua23
-rw-r--r--tex/context/base/mkiv/l-table.lua35
-rw-r--r--tex/context/base/mkiv/mlib-lua.lua76
-rw-r--r--tex/context/base/mkiv/mtx-context-domotica.tex48
-rw-r--r--tex/context/base/mkiv/mult-def.lua4
-rw-r--r--tex/context/base/mkiv/pack-box.mkiv152
-rw-r--r--tex/context/base/mkiv/pack-lyr.mkiv2
-rw-r--r--tex/context/base/mkiv/page-sid.mkiv23
-rw-r--r--tex/context/base/mkiv/publ-dat.lua8
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin25603 -> 25587 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin368575 -> 369201 bytes
-rw-r--r--tex/context/base/mkiv/strc-flt.mkvi1
-rw-r--r--tex/context/base/mkiv/strc-ref.lua4
-rw-r--r--tex/context/base/mkiv/supp-box.lua11
-rw-r--r--tex/context/base/mkiv/supp-box.mkiv21
20 files changed, 364 insertions, 83 deletions
diff --git a/tex/context/base/mkiv/back-pdf.mkiv b/tex/context/base/mkiv/back-pdf.mkiv
index 8c4061f2e..84e58d84c 100644
--- a/tex/context/base/mkiv/back-pdf.mkiv
+++ b/tex/context/base/mkiv/back-pdf.mkiv
@@ -296,7 +296,8 @@
% clipping
\unexpanded\def\dostartclipping#1#2#3% we can move this to lua and only set a box here
- {\PointsToBigPoints{#2}\width
+ {\forcecolorhack
+ \PointsToBigPoints{#2}\width
\PointsToBigPoints{#3}\height
\meta_grab_clip_path{#1}\width\height{%
0 0 m %
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index 5751a60da..d31d880f7 100644
--- a/tex/context/base/mkiv/cont-new.mkiv
+++ b/tex/context/base/mkiv/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2016.12.05 14:44}
+\newcontextversion{2016.12.21 18:51}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv
index b338d3c43..86722cf34 100644
--- a/tex/context/base/mkiv/context.mkiv
+++ b/tex/context/base/mkiv/context.mkiv
@@ -39,7 +39,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2016.12.05 14:44}
+\edef\contextversion{2016.12.21 18:51}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/font-nod.lua b/tex/context/base/mkiv/font-nod.lua
index 519a5c478..41fc215b1 100644
--- a/tex/context/base/mkiv/font-nod.lua
+++ b/tex/context/base/mkiv/font-nod.lua
@@ -469,16 +469,16 @@ end
--
-local threshold = 65536
+local threshold = 65536 -- 1pt
-local function toutf(list,result,nofresult,stopcriterium)
+local function toutf(list,result,nofresult,stopcriterium,nostrip)
if list then
for n in traverse_nodes(tonut(list)) do
local c, id = isglyph(n)
if c then
local components = getfield(n,"components")
if components then
- result, nofresult = toutf(components,result,nofresult)
+ result, nofresult = toutf(components,result,nofresult,false,true)
elseif c > 0 then
local fc = fontcharacters[getfont(n)]
if fc then
@@ -510,20 +510,20 @@ local function toutf(list,result,nofresult,stopcriterium)
result[nofresult] = f_badcode(c)
end
elseif id == disc_code then
- result, nofresult = toutf(getfield(n,"replace"),result,nofresult) -- needed?
+ result, nofresult = toutf(getfield(n,"replace"),result,nofresult,false,true) -- needed?
elseif id == hlist_code or id == vlist_code then
-- if nofresult > 0 and result[nofresult] ~= " " then
-- nofresult = nofresult + 1
-- result[nofresult] = " "
-- end
- result, nofresult = toutf(getlist(n),result,nofresult)
+ result, nofresult = toutf(getlist(n),result,nofresult,false,true)
elseif id == glue_code then
- if nofresult > 0 and result[nofresult] ~= " " then
+ if nofresult > 0 and result[nofresult] ~= " " and getfield(n,"width") > threshold then
nofresult = nofresult + 1
result[nofresult] = " "
end
- elseif id == kern_code and getfield(n,"kern") > threshold then
- if nofresult > 0 and result[nofresult] ~= " " then
+ elseif id == kern_code then
+ if nofresult > 0 and result[nofresult] ~= " " and getfield(n,"kern") > threshold then
nofresult = nofresult + 1
result[nofresult] = " "
end
@@ -533,7 +533,7 @@ local function toutf(list,result,nofresult,stopcriterium)
end
end
end
- if nofresult > 0 and result[nofresult] == " " then
+ if not nostrip and nofresult > 0 and result[nofresult] == " " then
result[nofresult] = nil
nofresult = nofresult - 1
end
diff --git a/tex/context/base/mkiv/grph-inc.lua b/tex/context/base/mkiv/grph-inc.lua
index d948d9ad8..901d31827 100644
--- a/tex/context/base/mkiv/grph-inc.lua
+++ b/tex/context/base/mkiv/grph-inc.lua
@@ -1252,9 +1252,17 @@ function figures.done(data)
-- somehow this fails on some of tacos files
-- ds.xscale = ds.width /(du.width or 1)
-- ds.yscale = ds.height/(du.height or 1)
- -- so we add some extra safeguards
- ds.xscale = ds.width /(du.width and du.width>0 and du.width or du.xsize) or 1
- ds.yscale = ds.height/(du.height and du.height>0 and du.height or du.ysize) or 1
+ -- du.width and du.height can be false
+ if du.width and du.height and du.width > 0 and du.height > 0 then
+ ds.xscale = ds.width /du.width
+ ds.yscale = ds.height/du.height
+ elseif du.xsize and du.ysize and du.xsize > 0 and du.ysize > 0 then
+ ds.xscale = ds.width /du.xsize
+ ds.yscale = ds.height/du.ysize
+ else
+ ds.xscale = 1
+ ds.yscale = 1
+ end
-- sort of redundant but can be limited
ds.page = ds.page or du.page or dr.page
return data
diff --git a/tex/context/base/mkiv/l-number.lua b/tex/context/base/mkiv/l-number.lua
index 001ca31f7..c6f1e3359 100644
--- a/tex/context/base/mkiv/l-number.lua
+++ b/tex/context/base/mkiv/l-number.lua
@@ -13,6 +13,7 @@ local tostring, tonumber = tostring, tonumber
local format, floor, match, rep = string.format, math.floor, string.match, string.rep
local concat, insert = table.concat, table.insert
local lpegmatch = lpeg.match
+local floor = math.floor
number = number or { }
local number = number
@@ -205,3 +206,25 @@ end
function number.bits(n)
return { bits(n,1) }
end
+
+function number.bytetodecimal(b)
+ local d = floor(b * 100 / 255 + 0.5)
+ if d > 100 then
+ return 100
+ elseif d < -100 then
+ return -100
+ else
+ return d
+ end
+end
+
+function number.decimaltobyte(d)
+ local b = floor(d * 255 / 100 + 0.5)
+ if b > 255 then
+ return 255
+ elseif b < -255 then
+ return -255
+ else
+ return b
+ end
+end
diff --git a/tex/context/base/mkiv/l-table.lua b/tex/context/base/mkiv/l-table.lua
index 1cf63db0c..39357bd25 100644
--- a/tex/context/base/mkiv/l-table.lua
+++ b/tex/context/base/mkiv/l-table.lua
@@ -971,6 +971,41 @@ end
table.flattened = flattened
+local function collapsed(t,f,h)
+ if f == nil then
+ f = { }
+ h = { }
+ end
+ for k=1,#t do
+ local v = t[k]
+ if type(v) == "table" then
+ collapsed(v,f,h)
+ elseif not h[v] then
+ f[#f+1] = v
+ h[v] = true
+ end
+ end
+ return f
+end
+
+local function collapsedhash(t,h)
+ if h == nil then
+ h = { }
+ end
+ for k=1,#t do
+ local v = t[k]
+ if type(v) == "table" then
+ collapsedhash(v,h)
+ else
+ h[v] = true
+ end
+ end
+ return h
+end
+
+table.collapsed = collapsed -- 20% faster than unique(collapsed(t))
+table.collapsedhash = collapsedhash
+
local function unnest(t,f) -- only used in mk, for old times sake
if not f then -- and only relevant for token lists
f = { } -- this one can become obsolete
diff --git a/tex/context/base/mkiv/mlib-lua.lua b/tex/context/base/mkiv/mlib-lua.lua
index c5893ee90..2b5648e16 100644
--- a/tex/context/base/mkiv/mlib-lua.lua
+++ b/tex/context/base/mkiv/mlib-lua.lua
@@ -11,7 +11,7 @@ if not modules then modules = { } end modules ['mlib-lua'] = {
-- maybe we need mplib.model, but how with instances
local type, tostring, select, loadstring = type, tostring, select, loadstring
-local find, gsub = string.find, string.gsub
+local find, match, gsub, gmatch = string.find, string.match, string.gsub, string.gmatch
local formatters = string.formatters
local concat = table.concat
@@ -62,6 +62,7 @@ end
local f_code = formatters["%s return mp._f_()"]
local f_numeric = formatters["%.16f"]
+local f_integer = formatters["%i"]
local f_pair = formatters["(%.16f,%.16f)"]
local f_triplet = formatters["(%.16f,%.16f,%.16f)"]
local f_quadruple = formatters["(%.16f,%.16f,%.16f,%.16f)"]
@@ -99,17 +100,22 @@ mp.print = mpprint
--
-- lua.mp("somedefdname","foo")
-
table.setmetatablecall(mp,function(t,k,...) return t[k](...) end)
-function mp.boolean(n)
+function mp.boolean(b)
+ n = n + 1
+ buffer[n] = b and "true" or "false"
+end
+
+function mp.numeric(f)
n = n + 1
- buffer[n] = n and "true" or "false"
+ buffer[n] = f and f_numeric(f) or "0"
end
-function mp.numeric(n)
+function mp.integer(i)
n = n + 1
- buffer[n] = n and f_numeric(n) or "0"
+ -- buffer[n] = i and f_integer(i) or "0"
+ buffer[n] = i or "0"
end
function mp.pair(x,y)
@@ -204,7 +210,7 @@ function mp.format(fmt,...)
buffer[n] = formatters[fmt](...)
end
-function mp.quoted(fmt,s,...)
+local function mpquoted(fmt,s,...)
n = n + 1
if s then
if not find(fmt,"%%") then
@@ -218,6 +224,8 @@ function mp.quoted(fmt,s,...)
end
end
+mp.quoted = mpquoted
+
function mp.n(t)
return type(t) == "table" and #t or 0
end
@@ -440,7 +448,7 @@ end
function mp.inhash(n,key)
local h = hashes[n]
- mpprint(h and h[key] or false)
+ mpprint(h and h[key] and true or false)
end
function mp.tohash(n,key)
@@ -449,3 +457,55 @@ function mp.tohash(n,key)
h[key] = true
end
end
+
+local modes = tex.modes
+local systemmodes = tex.systemmodes
+
+function mp.mode(s)
+ mpprint(modes[s] and true or false)
+end
+
+function mp.systemmode(s)
+ mpprint(systemmodes[s] and true or false)
+end
+
+-- for alan's nodes:
+
+function mp.isarray(str)
+ mpprint(find(str,"%d") and true or false)
+end
+
+function mp.prefix(str)
+ mpquoted(match(str,"^(.-)[%d%[]") or str)
+end
+
+function mp.dimensions(str)
+ local n = 0
+ for s in gmatch(str,"%[?%-?%d+%]?") do --todo: lpeg
+ n = n + 1
+ end
+ mpprint(n)
+end
+
+-- faster and okay as we don't have many variables but probably only
+-- basename makes sense and even then it's not called that often
+
+-- local hash = table.setmetatableindex(function(t,k)
+-- local v = find(k,"%d") and true or false
+-- t[k] = v
+-- return v
+-- end)
+--
+-- function mp.isarray(str)
+-- mpprint(hash[str])
+-- end
+--
+-- local hash = table.setmetatableindex(function(t,k)
+-- local v = '"' .. (match(k,"^(.-)%d") or k) .. '"'
+-- t[k] = v
+-- return v
+-- end)
+--
+-- function mp.prefix(str)
+-- mpprint(hash[str])
+-- end
diff --git a/tex/context/base/mkiv/mtx-context-domotica.tex b/tex/context/base/mkiv/mtx-context-domotica.tex
index a904d865b..62e6e8786 100644
--- a/tex/context/base/mkiv/mtx-context-domotica.tex
+++ b/tex/context/base/mkiv/mtx-context-domotica.tex
@@ -23,11 +23,13 @@
% --verycompact : small margins, 7pt font
%
% --openzwave : process openzwave xml files
+% --hue : process hue task file
%
% --pattern=spec : files to process
%
% example: context --extra=domotica --openzwave ./config/fibaro/fgms.xml ./open-zwave-master/config/aeotec/zw100.xml
% example: context --extra=domotica --openzwave --pattern="./open-zwave-master/config/**.xml"
+% example: context --extra=domotica --hue hue-pragma-tasks.lua
%
% end help
@@ -64,7 +66,12 @@
[\getdocumentargument{paperformat_paper}]
[\getdocumentargument{paperformat_print}]
+\setuphead
+ [section]
+ [style=bold]
+
\doifdocumentargument {openzwave} {\enablemode[openzwave]}
+\doifdocumentargument {hue} {\enablemode[hue]}
\startmode[openzwave]
@@ -79,18 +86,11 @@
[section]
[width=4em]
- \setuphead
- [section]
- [style=bold]
-
\setupheadertexts
\setupheadertexts
[chapter][pagenumber]
- \setupheader
- [style=bold]
-
\starttitle[title=Zwave devices]
\placelist[chapter,section]
@@ -131,3 +131,37 @@
\stopmode
+\startmode[hue]
+
+ \starttext
+
+ \setupheadertexts
+
+ \startluacode
+
+ local arguments = document.arguments
+ local files = document.files
+ local pattern = arguments.pattern
+ local filename = files[1]
+
+ if filename then
+ context.starttitle { title = "Hue: " .. file.nameonly(filename) }
+ filename = file.addsuffix(filename,"lua")
+ if lfs.isfile(filename) then
+ moduledata.hue.show_state(filename)
+ else
+ context("unknown file %a",filename)
+ end
+ context.stoptitle()
+ else
+ context("no files given")
+ context.stoptitle()
+ end
+
+ \stopluacode
+
+ \stoptext
+
+\stopmode
+
+
diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua
index 8bd8bb802..e41f7f342 100644
--- a/tex/context/base/mkiv/mult-def.lua
+++ b/tex/context/base/mkiv/mult-def.lua
@@ -12414,6 +12414,10 @@ return {
["pe"]="قطعی",
["ro"]="absolut",
},
+ ["anchor"]={
+ ["en"]="anchor",
+ ["nl"]="anker",
+ },
["action"]={
["cs"]="akce",
["de"]="aktion",
diff --git a/tex/context/base/mkiv/pack-box.mkiv b/tex/context/base/mkiv/pack-box.mkiv
index fad7d6e18..ab9fc465e 100644
--- a/tex/context/base/mkiv/pack-box.mkiv
+++ b/tex/context/base/mkiv/pack-box.mkiv
@@ -24,10 +24,15 @@
%D which in itself is ok, but can lead to loops due to rounding errors (happened
%D in demo-obv).
-\definelayer[\v!text-2][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height]
-\definelayer[\v!text-1][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height]
-\definelayer[\v!text+1][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height]
-\definelayer[\v!text+2][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height]
+% \definelayer[\v!text-2][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height]
+% \definelayer[\v!text-1][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height]
+% \definelayer[\v!text+1][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height]
+% \definelayer[\v!text+2][\c!position=\v!yes,\c!region=,\c!width=\d_overlay_width,\c!height=\d_overlay_height]
+
+\definelayer[\v!text-2][\c!position=\v!yes,\c!region=,\c!width=\textwidth,\c!height=\textheight]
+\definelayer[\v!text-1][\c!position=\v!yes,\c!region=,\c!width=\textwidth,\c!height=\textheight]
+\definelayer[\v!text+1][\c!position=\v!yes,\c!region=,\c!width=\textwidth,\c!height=\textheight]
+\definelayer[\v!text+2][\c!position=\v!yes,\c!region=,\c!width=\textwidth,\c!height=\textheight]
\unexpanded\def\internaltextoverlay#1% will become more generic and installable
{\startoverlay % i.e. probably an overlay by itself
@@ -42,6 +47,10 @@
\installcorenamespace {anchor}
+% produces a box too
+%
+% \anchor[text-1][preset=lefttop][framed settings]{HELLO WORLD}
+
\unexpanded\def\defineanchor
{\doquadrupleempty\pack_anchors_define}
@@ -64,13 +73,14 @@
{\begingroup
\edef\currentanchor{#1}%
\ifcsname\??anchor\currentanchor\endcsname
- \expandafter\pack_anchor_predefined
+% \expandafter\pack_anchor_predefined
+ \expandafter\lastnamedcs
\else
\expandafter\pack_anchor_notdefined
\fi}
-\def\pack_anchor_predefined
- {\csname\??anchor\currentanchor\endcsname}
+% \def\pack_anchor_predefined
+% {\csname\??anchor\currentanchor\endcsname}
\def\pack_anchor_notdefined
{\dodoubleempty\pack_anchor_notdefined_indeed}
@@ -93,33 +103,121 @@
\newdimen\d_pack_anchors_height
\newdimen\d_pack_anchors_depth
-\definelayer[anchor] % \defineoverlay[anchor][\ruledhbox{\flushlayer[anchor]}]
+% \definelayer[anchor]
+
+% % old and no longer valid
+%
+% \def\pack_anchors_process_finish#1#2#3% brrr: we need to apply offset only once .. a bit messy
+% {\checkpositionoverlays
+% % for the moment we ignore the depth
+% \setbox\b_pack_anchors\box\nextbox
+% \d_pack_anchors_width \wd\b_pack_anchors
+% \d_pack_anchors_height\ht\b_pack_anchors
+% \d_pack_anchors_depth \dp\b_pack_anchors
+% \setbox\scratchbox\emptyhbox
+% \wd\scratchbox\d_pack_anchors_width
+% \ht\scratchbox\d_pack_anchors_height
+% \dp\scratchbox\d_pack_anchors_depth
+% \setlayer
+% [anchor]%
+% [\c!width=\d_pack_anchors_width,%
+% \c!height=\d_pack_anchors_height,%
+% \c!offset=\zeropoint,%
+% #2,#3]%
+% {\setlayer[#1]{\box\b_pack_anchors}}% % #1 uses overlaywidth/height
+% \framed % could be a predefined framed
+% [#2,%
+% \c!background=anchor,%
+% \c!offset=\v!overlay,%
+% \c!frame=\v!off,%
+% #3]%
+% {\box\scratchbox}%
+% \endgroup}
+
+% % new and ok but not synced
+%
+% \def\pack_anchors_process_finish#1#2#3% brrr: we need to apply offset only once .. a bit messy
+% {\checkpositionoverlays
+% \setbox\b_pack_anchors\box\nextbox
+% \framed % could be a predefined framed
+% %[#2,\c!offset=\v!overlay,\c!frame=\v!off,#3]
+% [\c!offset=\v!overlay,\c!frame=\v!off,#3]
+% {\novrule % hm, not needed as we frame the size (but kind of default)
+% \s!width \wd\b_pack_anchors
+% \s!height\ht\b_pack_anchors
+% \s!depth \dp\b_pack_anchors}%
+% \setlayer[#1][#2,\c!position=\v!no]{\box\b_pack_anchors}% no position
+% \endgroup}
+
+\newcount\c_pack_anchors_n
+\newtoks \t_pack_anchors_flush
+
+\unexpanded\def\pack_anchors_register#1#2%
+ {\global\advance\c_pack_anchors_n\plusone
+ \pagereference[\v!layer:\v!anchor:\number\c_pack_anchors_n]%
+ \putboxincache{\v!anchor}{\number\c_pack_anchors_n}\b_pack_anchors
+ \doglobal\appendetoks
+ \pack_anchors_flush{\number\c_pack_anchors_n}{#1}{#2}%
+ \to \t_pack_anchors_flush
+ \glet\pack_anchors_flush_all\pack_anchors_flush_all_indeed}
+
+\unexpanded\def\pack_anchors_flush#1#2#3%
+ {\doifelseboxincache{\v!anchor}{#1}
+ {\doifelsereferencefound{\v!layer:\v!anchor:#1}
+ {\ifnum\currentreferencerealpage=\realpageno\relax
+ \setlayer[#2][#3,\c!position=\v!no]{\directboxfromcache{\v!anchor}{#1}}%
+ \else
+ \donetrue
+ \fi
+ }\donetrue}%
+ \donetrue}%
+
+\unexpanded\def\pack_anchors_flush_all_indeed
+ {\donefalse
+ \the\t_pack_anchors_flush
+ \ifdone\else
+ \global\t_pack_anchors_flush\emptytoks
+ \glet\pack_anchors_flush_all\relax
+ \fi}
+
+\let\pack_anchors_flush_all\relax
+
+\appendtoks
+ \pack_anchors_flush_all
+\to \everybeforepagebody
\def\pack_anchors_process_finish#1#2#3% brrr: we need to apply offset only once .. a bit messy
{\checkpositionoverlays
- % for the moment we ignore the depth
\setbox\b_pack_anchors\box\nextbox
- \d_pack_anchors_width \wd\b_pack_anchors
- \d_pack_anchors_height\ht\b_pack_anchors
- \d_pack_anchors_depth \dp\b_pack_anchors
- \setbox\scratchbox\emptyhbox
- \wd\scratchbox\d_pack_anchors_width
- \ht\scratchbox\d_pack_anchors_height
- \dp\scratchbox\d_pack_anchors_depth
- \setlayer
- [anchor]
- [\c!width=\d_pack_anchors_width,
- \c!height=\d_pack_anchors_height,
- \c!offset=\zeropoint,
- #2,#3]
- {\setlayer[#1]{\box\b_pack_anchors}}% % #1 uses ovelaywidth/height
\framed % could be a predefined framed
- [\c!background=anchor,
+ [%#2,
+ %\c!background=\v!color,
+ %\c!backgroundcolor=darkblue,
\c!offset=\v!overlay,
\c!frame=\v!off,
#3]
- {\box\scratchbox}%
- \endgroup}
+ {\pack_anchors_register{#1}{#2}%
+ \novrule % hm, not needed as we frame the size (but kind of default)
+ \s!width \wd\b_pack_anchors
+ \s!height\ht\b_pack_anchors
+ \s!depth \dp\b_pack_anchors}%
+ \endgroup}
+
+% \setlayeranchored[text-1][preset=lefttop]{HELLO WORLD} produces a simple (empty) hbox
+% synchronizes per page
+
+\unexpanded\def\setlayeranchored
+ {\begingroup
+ \dodoubleempty\pack_anchors_set_finish}
+
+\def\pack_anchors_set_finish[#1][#2]%
+ {\dowithnextbox
+ {\iffirstargument
+ \checkpositionoverlays
+ \setbox\b_pack_anchors\box\nextbox
+ \dontleavehmode\hpack{\pack_anchors_register{#1}{#2}}%
+ \fi
+ \endgroup}\hbox}
% collectors
@@ -573,7 +671,7 @@
\ifconditional\c_pack_boxes_t
\paperheight -\MPy\currentbgposition+\MPy\currentpageposition % not checked
\else\ifconditional\c_pack_boxes_b
- \scratchheight+\MPy\currentbgposition-\MPy\currentpageposition % not checked
+ \scratchheight+\MPy\currentbgposition-\MPy\currentpageposition + \MPh\currentbgposition % not checked (\MPh added)
\else
\scratchheight
\fi\fi
diff --git a/tex/context/base/mkiv/pack-lyr.mkiv b/tex/context/base/mkiv/pack-lyr.mkiv
index 1235c47ce..8661fe57a 100644
--- a/tex/context/base/mkiv/pack-lyr.mkiv
+++ b/tex/context/base/mkiv/pack-lyr.mkiv
@@ -433,6 +433,8 @@
\smashbox\nextbox
\vskip\dimexpr\d_pack_layers_y_position+\d_pack_layers_y_offset\relax
\hskip\dimexpr\d_pack_layers_x_position+\d_pack_layers_x_offset\relax
+ % or maybe instead of the \vskip
+ % \raise-\dimexpr\d_pack_layers_y_position+\d_pack_layers_y_offset\relax
\box\nextbox
\ifvoid\layerpagebox
% already flushed
diff --git a/tex/context/base/mkiv/page-sid.mkiv b/tex/context/base/mkiv/page-sid.mkiv
index 2c1c624df..501f24e88 100644
--- a/tex/context/base/mkiv/page-sid.mkiv
+++ b/tex/context/base/mkiv/page-sid.mkiv
@@ -38,7 +38,6 @@
\newdimen \d_page_sides_progress
\newdimen \d_page_sides_page_total
\newdimen \d_page_sides_saved_depth
-\newdimen \d_page_sides_grid_shift
\newbox \b_page_sides_bottom
@@ -552,31 +551,21 @@
\prevdepth\d_page_sides_saved_depth}
\def\page_sides_place_float_normal
- {\d_page_sides_grid_shift\zeropoint % be nice
- \page_sides_push_float_inline\firstofoneargument}
+ {\page_sides_push_float_inline\firstofoneargument}
% The following needs some more work .. consider this a quick hack. We
% probably need an mkiv hanging grid option.
\def\page_sides_place_snap_to_grid#1%
- {\snaptogrid[\v!line,\v!offset:\the\d_page_sides_grid_shift]\hbox{#1}}
-
-% this will be a grid option in float placement:
-
-\newconstant\c_page_sides_place_grid_shift \c_page_sides_place_grid_shift\plustwo
+ {\edef\p_grid{\floatparameter\c!grid}%
+ \ifx\p_grid\empty\else
+ \snaptogrid[\p_grid]%
+ \fi
+ \hbox{#1}}
\def\page_sides_place_float_grid
{\getrawnoflines\d_page_sides_height % raw ?
\d_page_sides_height\noflines\lineheight
- \d_page_sides_grid_shift\the\dimexpr \plustwo\lineheight
- \ifcase\c_page_sides_place_grid_shift
- -3\lineheight % high
- \or
- -2.5\lineheight % half (does not work currently)
- \else
- -2\lineheight % low
- \fi
- \relax
\page_sides_push_float_inline\page_sides_place_snap_to_grid}
\def\page_sides_push_float_inline#1%
diff --git a/tex/context/base/mkiv/publ-dat.lua b/tex/context/base/mkiv/publ-dat.lua
index 5fc1031cd..f6650dd4d 100644
--- a/tex/context/base/mkiv/publ-dat.lua
+++ b/tex/context/base/mkiv/publ-dat.lua
@@ -609,7 +609,13 @@ do
local d_value = (double/"") * (unbalanced + d_quoted) * (double/"")
local r_value = reference * Carg(1) / resolve
- local somevalue = d_value + b_value + s_value + r_value
+-- local e_value = (1-S(",}"))^0 / function(s)
+ local e_value = Cs((left * balanced * right + (1 - S(",}")))^0) / function(s)
+ report("error in database, invalid value %a",s)
+ return "[invalid: " .. s .. "]"
+ end
+
+ local somevalue = d_value + b_value + s_value + r_value + e_value
local value = Cs((somevalue * ((spacing * hash * spacing)/"" * somevalue)^0))
local stripper = lpegpatterns.stripper
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 8f0dca563..0a9d95fef 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index 79290af72..b7090d2a8 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/strc-flt.mkvi b/tex/context/base/mkiv/strc-flt.mkvi
index e28039716..b63d678ab 100644
--- a/tex/context/base/mkiv/strc-flt.mkvi
+++ b/tex/context/base/mkiv/strc-flt.mkvi
@@ -126,6 +126,7 @@
\c!strut=\v!no,
\c!radius=.5\bodyfontsize,
\c!corner=\v!rectangular,
+ \c!grid=,
%\c!background=,
%\c!backgroundcolor=,
\c!backgroundoffset=\!!zeropoint,
diff --git a/tex/context/base/mkiv/strc-ref.lua b/tex/context/base/mkiv/strc-ref.lua
index b678bd0d7..23aa79ed4 100644
--- a/tex/context/base/mkiv/strc-ref.lua
+++ b/tex/context/base/mkiv/strc-ref.lua
@@ -2507,8 +2507,8 @@ implement {
arguments = { "string", "boolean", "boolean" }
}
-local function referencerealpage(actions)
- actions = actions or references.currentset
+local function referencerealpage()
+ local actions = references.currentset
return not actions and 0 or actions.realpage or setreferencerealpage(actions)
end
diff --git a/tex/context/base/mkiv/supp-box.lua b/tex/context/base/mkiv/supp-box.lua
index c12cca2c2..f5974daf7 100644
--- a/tex/context/base/mkiv/supp-box.lua
+++ b/tex/context/base/mkiv/supp-box.lua
@@ -472,6 +472,11 @@ name = tonumber(name) or name
cache[category][name] = b or false
end
+ function boxes.found(category,name)
+name = tonumber(name) or name
+ return cache[category][name] and true or false
+ end
+
function boxes.direct(category,name,copy)
name = tonumber(name) or name
local c = cache[category]
@@ -578,6 +583,12 @@ name = tonumber(name) or name
}
interfaces.implement {
+ name = "doifelseboxincache",
+ arguments = { "string", "string" },
+ actions = { boxes.found, doifelse },
+ }
+
+ interfaces.implement {
name = "resetboxesincache",
arguments = { "string" },
actions = boxes.reset,
diff --git a/tex/context/base/mkiv/supp-box.mkiv b/tex/context/base/mkiv/supp-box.mkiv
index ba00a9e1d..6e31d2139 100644
--- a/tex/context/base/mkiv/supp-box.mkiv
+++ b/tex/context/base/mkiv/supp-box.mkiv
@@ -2550,9 +2550,15 @@
\fi
\setstackbox{#1}{#2}}
+\unexpanded\def\flushbox#1#2% unwrapped
+ {\ifcsname\??stackbox#1:#2\endcsname
+ \box\lastnamedcs
+ \else
+ \emptybox
+ \fi}
+
\unexpanded\def\restorebox#1#2% unwrapped
{\ifcsname\??stackbox#1:#2\endcsname
- %\copy\csname\??stackbox#1:#2\endcsname
\copy\lastnamedcs
\else
\emptybox
@@ -2561,16 +2567,18 @@
\unexpanded\def\foundbox#1#2% wrapped
{\vpack
{\ifcsname\??stackbox#1:#2\endcsname
- %\copy\csname\??stackbox#1:#2\endcsname
\copy\lastnamedcs
\fi}}
-\unexpanded\def\doifelsebox#1#2#3#4%
+\unexpanded\def\doifelsebox#1#2%
{\ifcsname\??stackbox#1:#2\endcsname
- %\ifvoid\csname\??stackbox#1:#2\endcsname#4\else#3\fi
- \ifvoid\lastnamedcs#4\else#3\fi
+ \ifvoid\lastnamedcs
+ \doubleexpandafter\secondoftwoarguments
+ \else
+ \doubleexpandafter\firstoftwoarguments
+ \fi
\else
- #4%
+ \expandafter\secondoftwoarguments
\fi}
\let\doifboxelse\doifelsebox
@@ -2622,6 +2630,7 @@
\unexpanded\def\putboxincache #1#2#3{\clf_putboxincache {#1}{#2}#3\relax}
\unexpanded\def\getboxfromcache #1#2#3{\clf_getboxfromcache {#1}{#2}#3\relax}
+\unexpanded\def\doifelseboxincache #1#2{\clf_doifelseboxincache {#1}{#2}}
\unexpanded\def\copyboxfromcache #1#2#3{\clf_copyboxfromcache {#1}{#2}#3\relax}
\unexpanded\def\directboxfromcache #1#2{\clf_directboxfromcache {#1}{#2}}
\unexpanded\def\directcopyboxfromcache#1#2{\clf_directcopyboxfromcache{#1}{#2}}