diff options
Diffstat (limited to 'tex')
45 files changed, 487 insertions, 88 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index a439529d3..53fe67bc2 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -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 %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 14b60ec69..d022b1626 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2016.12.05 14:44} +\edef\contextversion{2016.12.21 18:51} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-cs.mkii b/tex/context/base/mkii/mult-cs.mkii index a32302fe2..6294d6b29 100644 --- a/tex/context/base/mkii/mult-cs.mkii +++ b/tex/context/base/mkii/mult-cs.mkii @@ -76,6 +76,7 @@ \setinterfacevariable{all}{vse} \setinterfacevariable{alphabetic}{alphabetic} \setinterfacevariable{always}{vzdy} +\setinterfacevariable{anchor}{anchor} \setinterfacevariable{and}{and} \setinterfacevariable{answerarea}{answerarea} \setinterfacevariable{appendices}{dodatky} diff --git a/tex/context/base/mkii/mult-de.mkii b/tex/context/base/mkii/mult-de.mkii index d3e4f6865..6993afa4d 100644 --- a/tex/context/base/mkii/mult-de.mkii +++ b/tex/context/base/mkii/mult-de.mkii @@ -76,6 +76,7 @@ \setinterfacevariable{all}{alles} \setinterfacevariable{alphabetic}{alphabetic} \setinterfacevariable{always}{immer} +\setinterfacevariable{anchor}{anchor} \setinterfacevariable{and}{und} \setinterfacevariable{answerarea}{answerarea} \setinterfacevariable{appendices}{anhaenge} diff --git a/tex/context/base/mkii/mult-en.mkii b/tex/context/base/mkii/mult-en.mkii index 07359c8c8..8865cd201 100644 --- a/tex/context/base/mkii/mult-en.mkii +++ b/tex/context/base/mkii/mult-en.mkii @@ -76,6 +76,7 @@ \setinterfacevariable{all}{all} \setinterfacevariable{alphabetic}{alphabetic} \setinterfacevariable{always}{always} +\setinterfacevariable{anchor}{anchor} \setinterfacevariable{and}{and} \setinterfacevariable{answerarea}{answerarea} \setinterfacevariable{appendices}{appendices} diff --git a/tex/context/base/mkii/mult-fr.mkii b/tex/context/base/mkii/mult-fr.mkii index 87e6b3a2c..45f382ec5 100644 --- a/tex/context/base/mkii/mult-fr.mkii +++ b/tex/context/base/mkii/mult-fr.mkii @@ -76,6 +76,7 @@ \setinterfacevariable{all}{tout} \setinterfacevariable{alphabetic}{alphabetic} \setinterfacevariable{always}{toujours} +\setinterfacevariable{anchor}{anchor} \setinterfacevariable{and}{and} \setinterfacevariable{answerarea}{answerarea} \setinterfacevariable{appendices}{annexes} diff --git a/tex/context/base/mkii/mult-it.mkii b/tex/context/base/mkii/mult-it.mkii index 39bd65cf9..05c72b1f1 100644 --- a/tex/context/base/mkii/mult-it.mkii +++ b/tex/context/base/mkii/mult-it.mkii @@ -76,6 +76,7 @@ \setinterfacevariable{all}{tutti} \setinterfacevariable{alphabetic}{alphabetic} \setinterfacevariable{always}{sempre} +\setinterfacevariable{anchor}{anchor} \setinterfacevariable{and}{and} \setinterfacevariable{answerarea}{answerarea} \setinterfacevariable{appendices}{appendici} diff --git a/tex/context/base/mkii/mult-nl.mkii b/tex/context/base/mkii/mult-nl.mkii index 9e2b2cc2a..6e87a52fc 100644 --- a/tex/context/base/mkii/mult-nl.mkii +++ b/tex/context/base/mkii/mult-nl.mkii @@ -76,6 +76,7 @@ \setinterfacevariable{all}{alles} \setinterfacevariable{alphabetic}{alphabetic} \setinterfacevariable{always}{altijd} +\setinterfacevariable{anchor}{anker} \setinterfacevariable{and}{en} \setinterfacevariable{answerarea}{antwoordgebied} \setinterfacevariable{appendices}{bijlagen} diff --git a/tex/context/base/mkii/mult-pe.mkii b/tex/context/base/mkii/mult-pe.mkii index 399155996..61b14382a 100644 --- a/tex/context/base/mkii/mult-pe.mkii +++ b/tex/context/base/mkii/mult-pe.mkii @@ -76,6 +76,7 @@ \setinterfacevariable{all}{همه} \setinterfacevariable{alphabetic}{alphabetic} \setinterfacevariable{always}{همواره} +\setinterfacevariable{anchor}{anchor} \setinterfacevariable{and}{and} \setinterfacevariable{answerarea}{answerarea} \setinterfacevariable{appendices}{پیوستها} diff --git a/tex/context/base/mkii/mult-ro.mkii b/tex/context/base/mkii/mult-ro.mkii index 886bc6c2b..7edb17d65 100644 --- a/tex/context/base/mkii/mult-ro.mkii +++ b/tex/context/base/mkii/mult-ro.mkii @@ -76,6 +76,7 @@ \setinterfacevariable{all}{tot} \setinterfacevariable{alphabetic}{alphabetic} \setinterfacevariable{always}{totdeauna} +\setinterfacevariable{anchor}{anchor} \setinterfacevariable{and}{and} \setinterfacevariable{answerarea}{answerarea} \setinterfacevariable{appendices}{apendixuri} diff --git a/tex/context/base/mkii/pack-box.mkii b/tex/context/base/mkii/pack-box.mkii index 1752e2b91..928450385 100644 --- a/tex/context/base/mkii/pack-box.mkii +++ b/tex/context/base/mkii/pack-box.mkii @@ -27,7 +27,7 @@ % \definelayer[\v!tekst+2][\c!positie=\v!ja] % we need to set the size, else we get dimensions depending -% on the content, which in itsel fis ok, but can lead to loops +% on the content, which in itself is ok, but can lead to loops % due to rounding errors (happened in demo-obv) \definelayer[\v!text-2][\c!position=\v!yes,\c!width=\overlaywidth,\c!height=\overlayheight] 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 Binary files differindex 8f0dca563..0a9d95fef 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 79290af72..b7090d2a8 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf 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}} diff --git a/tex/context/interface/mkii/keys-cs.xml b/tex/context/interface/mkii/keys-cs.xml index 5a59e9fae..ad166f2f9 100644 --- a/tex/context/interface/mkii/keys-cs.xml +++ b/tex/context/interface/mkii/keys-cs.xml @@ -79,6 +79,7 @@ <cd:variable name='all' value='vse'/> <cd:variable name='alphabetic' value='alphabetic'/> <cd:variable name='always' value='vzdy'/> + <cd:variable name='anchor' value='anchor'/> <cd:variable name='and' value='and'/> <cd:variable name='answerarea' value='answerarea'/> <cd:variable name='appendices' value='dodatky'/> diff --git a/tex/context/interface/mkii/keys-de.xml b/tex/context/interface/mkii/keys-de.xml index 939b6ee1e..19ffc98e7 100644 --- a/tex/context/interface/mkii/keys-de.xml +++ b/tex/context/interface/mkii/keys-de.xml @@ -79,6 +79,7 @@ <cd:variable name='all' value='alles'/> <cd:variable name='alphabetic' value='alphabetic'/> <cd:variable name='always' value='immer'/> + <cd:variable name='anchor' value='anchor'/> <cd:variable name='and' value='und'/> <cd:variable name='answerarea' value='answerarea'/> <cd:variable name='appendices' value='anhaenge'/> diff --git a/tex/context/interface/mkii/keys-en.xml b/tex/context/interface/mkii/keys-en.xml index 5eb518a75..80f348b9e 100644 --- a/tex/context/interface/mkii/keys-en.xml +++ b/tex/context/interface/mkii/keys-en.xml @@ -79,6 +79,7 @@ <cd:variable name='all' value='all'/> <cd:variable name='alphabetic' value='alphabetic'/> <cd:variable name='always' value='always'/> + <cd:variable name='anchor' value='anchor'/> <cd:variable name='and' value='and'/> <cd:variable name='answerarea' value='answerarea'/> <cd:variable name='appendices' value='appendices'/> diff --git a/tex/context/interface/mkii/keys-fr.xml b/tex/context/interface/mkii/keys-fr.xml index 9f7ea64b1..ae600f5f9 100644 --- a/tex/context/interface/mkii/keys-fr.xml +++ b/tex/context/interface/mkii/keys-fr.xml @@ -79,6 +79,7 @@ <cd:variable name='all' value='tout'/> <cd:variable name='alphabetic' value='alphabetic'/> <cd:variable name='always' value='toujours'/> + <cd:variable name='anchor' value='anchor'/> <cd:variable name='and' value='and'/> <cd:variable name='answerarea' value='answerarea'/> <cd:variable name='appendices' value='annexes'/> diff --git a/tex/context/interface/mkii/keys-it.xml b/tex/context/interface/mkii/keys-it.xml index 9e9b4cdf0..49902eee5 100644 --- a/tex/context/interface/mkii/keys-it.xml +++ b/tex/context/interface/mkii/keys-it.xml @@ -79,6 +79,7 @@ <cd:variable name='all' value='tutti'/> <cd:variable name='alphabetic' value='alphabetic'/> <cd:variable name='always' value='sempre'/> + <cd:variable name='anchor' value='anchor'/> <cd:variable name='and' value='and'/> <cd:variable name='answerarea' value='answerarea'/> <cd:variable name='appendices' value='appendici'/> diff --git a/tex/context/interface/mkii/keys-nl.xml b/tex/context/interface/mkii/keys-nl.xml index 6466aa7f8..a8f65b552 100644 --- a/tex/context/interface/mkii/keys-nl.xml +++ b/tex/context/interface/mkii/keys-nl.xml @@ -79,6 +79,7 @@ <cd:variable name='all' value='alles'/> <cd:variable name='alphabetic' value='alphabetic'/> <cd:variable name='always' value='altijd'/> + <cd:variable name='anchor' value='anker'/> <cd:variable name='and' value='en'/> <cd:variable name='answerarea' value='antwoordgebied'/> <cd:variable name='appendices' value='bijlagen'/> diff --git a/tex/context/interface/mkii/keys-pe.xml b/tex/context/interface/mkii/keys-pe.xml index 224ec2b6a..b31c3ee97 100644 --- a/tex/context/interface/mkii/keys-pe.xml +++ b/tex/context/interface/mkii/keys-pe.xml @@ -79,6 +79,7 @@ <cd:variable name='all' value='همه'/> <cd:variable name='alphabetic' value='alphabetic'/> <cd:variable name='always' value='همواره'/> + <cd:variable name='anchor' value='anchor'/> <cd:variable name='and' value='and'/> <cd:variable name='answerarea' value='answerarea'/> <cd:variable name='appendices' value='پیوستها'/> diff --git a/tex/context/interface/mkii/keys-ro.xml b/tex/context/interface/mkii/keys-ro.xml index 477ef7115..707082d64 100644 --- a/tex/context/interface/mkii/keys-ro.xml +++ b/tex/context/interface/mkii/keys-ro.xml @@ -79,6 +79,7 @@ <cd:variable name='all' value='tot'/> <cd:variable name='alphabetic' value='alphabetic'/> <cd:variable name='always' value='totdeauna'/> + <cd:variable name='anchor' value='anchor'/> <cd:variable name='and' value='and'/> <cd:variable name='answerarea' value='answerarea'/> <cd:variable name='appendices' value='apendixuri'/> diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex e3dd2d9ed..0f76a4ac2 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-floats.xml b/tex/context/interface/mkiv/i-floats.xml index 153078fb4..edc7f7f03 100644 --- a/tex/context/interface/mkiv/i-floats.xml +++ b/tex/context/interface/mkiv/i-floats.xml @@ -64,6 +64,9 @@ <cd:constant type="grid"/> <cd:constant type="normal" default="yes"/> </cd:parameter> + <cd:parameter name="grid"> + <cd:constant type="cd:string"/> + </cd:parameter> <!-- <cd:parameter name="topoffset"> <cd:constant type="cd:dimension"/> diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 4d81dd35b..5a55f45de 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/context/modules/mkiv/s-domotica-settings.lua b/tex/context/modules/mkiv/s-domotica-settings.lua index e7e8c309b..a564ddf0e 100644 --- a/tex/context/modules/mkiv/s-domotica-settings.lua +++ b/tex/context/modules/mkiv/s-domotica-settings.lua @@ -12,6 +12,7 @@ moduledata.domotica.settings = moduledata.domotica.settings or { } -- bah, no proper wrapper around value|help moduledata.zwave = moduledata.zwave or { } +moduledata.hue = moduledata.hue or { } local NC = context.NC local BC = context.BC @@ -96,3 +97,69 @@ function moduledata.zwave.show_settings(pattern) end end + +function moduledata.hue.show_state(filename) + + require("control-common") + require("control-hue") + + local specification = domotica.hue.check(filename) + local instances = specification.instances + + local ctx_NC, ctx_BC, ctx_NR = context.NC, context.BC, context.NR + + for i=1,#instances do + local known = instances[i].knowndevices + + if #instances > 1 then + context.subject("instance %i",i) + end + + context.starttabulate { "|l|c|c|c|c|c|l|" } + ctx_BC() context("light name") + ctx_BC() context("id") + ctx_BC() context("state") + ctx_BC() context("level") + ctx_BC() context("color") + ctx_BC() context("seen") + ctx_BC() context("internal") + ctx_BC() ctx_NR() + for id, entry in table.sortedhash(known.lights) do + if entry.used then + local state = entry.state + local name = entry.name + local internal = entry.internalname + ctx_NC() context(entry.name) + ctx_NC() context(entry.identifier) + ctx_NC() context(state.on and "on " or "off") + ctx_NC() context(state.brightness or 0) + ctx_NC() context(state.temperature or 0) + ctx_NC() context((state.reachable or entry.reachable) and "yes" or "no ") + ctx_NC() if name == internal then context(name) else context.emphasized(internal) end + ctx_NC() ctx_NR() + end + end + context.stoptabulate() + context.starttabulate { "|l|c|c|c|l|" } + ctx_BC() context("sensor name") + ctx_BC() context("id") + ctx_BC() context("seen") + ctx_BC() context("battery") + ctx_BC() context("internal") + ctx_BC() ctx_NR() + for id, entry in table.sortedhash(known.sensors) do + if entry.used then + local state = entry.state + local name = entry.name + local internal = entry.internalname + ctx_NC() context(name) + ctx_NC() context(entry.identifier) + ctx_NC() context((state.reachable or entry.reachable) and "yes" or "no ") + ctx_NC() context(entry.battery or "") + ctx_NC() if name == internal then context(name) else context.emphasized(internal) end + ctx_NC() ctx_NR() + end + end + context.stoptabulate() + end +end diff --git a/tex/context/modules/mkiv/s-domotica-settings.mkiv b/tex/context/modules/mkiv/s-domotica-settings.mkiv index e8c483e32..d32e53830 100644 --- a/tex/context/modules/mkiv/s-domotica-settings.mkiv +++ b/tex/context/modules/mkiv/s-domotica-settings.mkiv @@ -17,7 +17,7 @@ % see mtx-context-domotica.tex for usage example(s) -\startmodule[domotica-] +\startmodule[domotica-settings] \registerctxluafile{s-domotica-settings}{} diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 9ce686896..c503add27 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 : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 12/05/16 14:44:50 +-- merge date : 12/21/16 18:51:59 do -- begin closure to overcome local limits and interference @@ -1739,6 +1739,38 @@ local function flattened(t,f,depth) return f 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 +table.collapsedhash=collapsedhash local function unnest(t,f) if not f then f={} |