From 9b1c3470a7a222ef9ae20106d750c4a0127819a7 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 30 Dec 2021 19:47:30 +0100 Subject: 2021-12-30 19:03:00 --- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkii/mult-ro.mkii | 4 +- tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/mult-def.lua | 10 + tex/context/base/mkiv/mult-low.lua | 8 + tex/context/base/mkiv/mult-prm.lua | 7 + tex/context/base/mkiv/page-sid.mkiv | 2 +- tex/context/base/mkiv/status-files.pdf | Bin 24743 -> 24764 bytes tex/context/base/mkiv/status-lua.pdf | Bin 257235 -> 257473 bytes tex/context/base/mkiv/util-prs.lua | 11 +- tex/context/base/mkxl/anch-loc.lmt | 1 + tex/context/base/mkxl/cont-new.mkxl | 2 +- tex/context/base/mkxl/context.mkxl | 2 +- tex/context/base/mkxl/driv-shp.lmt | 447 ++++++++++++++++----- tex/context/base/mkxl/driv-usr.lmt | 261 ++++++++++-- tex/context/base/mkxl/grph-rul.lmt | 14 +- tex/context/base/mkxl/grph-rul.mkxl | 2 +- tex/context/base/mkxl/lang-ini.lmt | 39 +- tex/context/base/mkxl/lpdf-lmt.lmt | 4 +- tex/context/base/mkxl/lpdf-rul.lmt | 16 +- tex/context/base/mkxl/luat-log.lmt | 15 + tex/context/base/mkxl/mult-sys.mkxl | 3 + tex/context/base/mkxl/node-bck.lmt | 10 +- tex/context/base/mkxl/node-fin.lmt | 8 +- tex/context/base/mkxl/node-nut.lmt | 5 + tex/context/base/mkxl/node-shp.lmt | 4 + tex/context/base/mkxl/pack-box.mkxl | 126 ++++++ tex/context/base/mkxl/page-sid.mkxl | 55 ++- tex/context/base/mkxl/page-txt.mklx | 8 +- tex/context/base/mkxl/spac-ver.lmt | 110 ++++- tex/context/base/mkxl/strc-flt.mklx | 3 + tex/context/base/mkxl/strc-reg.lmt | 16 +- tex/context/base/mkxl/strc-ren.mkxl | 1 + tex/context/base/mkxl/strc-sec.mkxl | 3 +- tex/context/base/mkxl/supp-box.mkxl | 14 + tex/context/base/mkxl/toks-aux.lmt | 2 + tex/context/base/mkxl/trac-vis.lmt | 13 +- tex/context/interface/mkii/keys-ro.xml | 4 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 41 files changed, 1012 insertions(+), 228 deletions(-) (limited to 'tex') diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index f0147a089..907bf60cf 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{2021.12.25 00:55} +\newcontextversion{2021.12.30 19:00} %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 6632c422d..6e89044ab 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{2021.12.25 00:55} +\edef\contextversion{2021.12.30 19:00} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-ro.mkii b/tex/context/base/mkii/mult-ro.mkii index 65c52c639..cee725d43 100644 --- a/tex/context/base/mkii/mult-ro.mkii +++ b/tex/context/base/mkii/mult-ro.mkii @@ -300,6 +300,7 @@ \setinterfacevariable{july}{iulie} \setinterfacevariable{june}{iunie} \setinterfacevariable{keep}{mentine} +\setinterfacevariable{keeptogether}{keeptogether} \setinterfacevariable{kerncharacters}{kerncharacters} \setinterfacevariable{knockout}{knockout} \setinterfacevariable{label}{eticheta} @@ -1229,7 +1230,7 @@ \setinterfaceconstant{solution}{solution} \setinterfaceconstant{sort}{sort} \setinterfaceconstant{sorttype}{sorttype} -\setinterfaceconstant{source}{sursa} +\setinterfaceconstant{source}{source} \setinterfaceconstant{space}{spatiu} \setinterfaceconstant{spaceafter}{spatiudupa} \setinterfaceconstant{spaceafterside}{spaceafterside} @@ -1280,6 +1281,7 @@ \setinterfaceconstant{synonymcommand}{synonymcommand} \setinterfaceconstant{synonymstyle}{stilsinonim} \setinterfaceconstant{tab}{tab} +\setinterfaceconstant{target}{target} \setinterfaceconstant{text}{text} \setinterfaceconstant{textalign}{textalign} \setinterfaceconstant{textalternative}{textalternative} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 383351dd3..bdb0d03a6 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.12.25 00:55} +\newcontextversion{2021.12.30 19:00} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 3d9e02e03..61f239979 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -49,7 +49,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2021.12.25 00:55} +\edef\contextversion{2021.12.30 19:00} %D Kind of special: diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua index 7389fa9d9..9992de8f6 100644 --- a/tex/context/base/mkiv/mult-def.lua +++ b/tex/context/base/mkiv/mult-def.lua @@ -12796,6 +12796,12 @@ return { ["pe"]="گام‌وای", ["ro"]="ystep", }, + ["source"]={ + ["en"]="source", + }, + ["target"]={ + ["en"]="target", + }, }, ["elements"]={ ["answerlines"]={ @@ -16460,6 +16466,10 @@ return { ["pe"]="نگهدار", ["ro"]="mentine", }, + ["keeptogether"]={ + ["en"]="keeptogether", + ["fr"]="conserverensemble", + }, ["kerncharacters"]={ ["en"]="kerncharacters", ["fr"]="approchercaracteres", diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index 9c4c35037..979fef710 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -116,6 +116,14 @@ return { "vadjustparcontextcode", "insertparcontextcode", "outputparcontextcode", "alignparcontextcode", "noalignparcontextcode", "spanparcontextcode", "resetparcontextcode", -- + "leftoriginlistanchorcode", "leftheightlistanchorcode", "leftdepthlistanchorcode", + "rightoriginlistanchorcode", "rightheightlistanchorcode", "rightdepthlistanchorcode", + "centeroriginlistanchorcode", "centerheightlistanchorcode", "centerdepthlistanchorcode", + "halfwaytotallistanchorcode", "halfwayheightlistanchorcode", "halfwaydepthlistanchorcode", + "halfwayleftlistanchorcode", "halfwayrightlistanchorcode", + -- + "negatexlistsigncode", "negateylistsigncode", "negatelistsigncode", + -- "fontslantperpoint", "fontinterwordspace", "fontinterwordstretch", "fontinterwordshrink", "fontexheight", "fontemwidth", "fontextraspace", "slantperpoint", "mathexheight", "mathemwidth", diff --git a/tex/context/base/mkiv/mult-prm.lua b/tex/context/base/mkiv/mult-prm.lua index 0249b906b..2803448d9 100644 --- a/tex/context/base/mkiv/mult-prm.lua +++ b/tex/context/base/mkiv/mult-prm.lua @@ -285,10 +285,15 @@ return { "begincsname", "beginlocalcontrol", "boundary", + "boxanchor", + "boxanchors", "boxattribute", "boxdirection", + "boxgeometry", "boxorientation", "boxshift", + "boxsource", + "boxtarget", "boxtotal", "boxxmove", "boxxoffset", @@ -496,6 +501,7 @@ return { "overloaded", "overloadmode", "pageboundary", + "pageboundarypenalty", "pagevsize", "parametercount", "parametermark", @@ -544,6 +550,7 @@ return { "tracinginserts", "tracingmarks", "tracingmath", + "tracingnodes", "undent", "unexpandedloop", "unletfrozen", diff --git a/tex/context/base/mkiv/page-sid.mkiv b/tex/context/base/mkiv/page-sid.mkiv index e6c1be985..88e4fb116 100644 --- a/tex/context/base/mkiv/page-sid.mkiv +++ b/tex/context/base/mkiv/page-sid.mkiv @@ -292,7 +292,7 @@ \box\floatbox % somehow we need this \scratchbox magic, but at least it's the same as the % tracer now - \setbox\scratchbox\emptybox + \setbox\scratchbox\emptyhbox \wd\scratchbox\hsize \ht\scratchbox\d_page_sides_bottomtotal \box\scratchbox diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index 94dd23ff5..5d46013f9 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index a9934cf42..03cb36fc9 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/base/mkiv/util-prs.lua b/tex/context/base/mkiv/util-prs.lua index 438fa78bd..204611dbe 100644 --- a/tex/context/base/mkiv/util-prs.lua +++ b/tex/context/base/mkiv/util-prs.lua @@ -71,11 +71,12 @@ local spaces = space^0 local argument = Cs((lbrace/"") * ((nobrace + nestedbraces)^0) * (rbrace/"")) local content = (1-endofstring)^0 -lpegpatterns.nestedbraces = nestedbraces -- no capture -lpegpatterns.nestedparents = nestedparents -- no capture -lpegpatterns.nested = nestedbraces -- no capture -lpegpatterns.argument = argument -- argument after e.g. = -lpegpatterns.content = content -- rest after e.g = +lpegpatterns.nestedbraces = nestedbraces -- no capture +lpegpatterns.nestedparents = nestedparents -- no capture +lpegpatterns.nestedbrackets = nestedbrackets -- no capture +lpegpatterns.nested = nestedbraces -- no capture +lpegpatterns.argument = argument -- argument after e.g. = +lpegpatterns.content = content -- rest after e.g = local value = lbrace * C((nobrace + nestedbraces)^0) * rbrace + C((nestedbraces + (1-comma))^0) diff --git a/tex/context/base/mkxl/anch-loc.lmt b/tex/context/base/mkxl/anch-loc.lmt index 054d4dd07..14efab260 100644 --- a/tex/context/base/mkxl/anch-loc.lmt +++ b/tex/context/base/mkxl/anch-loc.lmt @@ -327,6 +327,7 @@ implement { context(new_usernode(whatever,{ name = name, kind = "sync", x = x, y = y })) end } + implement { name = "setlocalalignanchor", arguments = { "argument", "integerargument", "integerargument", "argument" }, diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index c7b619601..35e8bf03d 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.12.25 00:55} +\newcontextversion{2021.12.30 19:00} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index 91db54550..385a2c13a 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2021.12.25 00:55} +\immutable\edef\contextversion{2021.12.30 19:00} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/driv-shp.lmt b/tex/context/base/mkxl/driv-shp.lmt index 0ab9dacc2..620c69484 100644 --- a/tex/context/base/mkxl/driv-shp.lmt +++ b/tex/context/base/mkxl/driv-shp.lmt @@ -7,7 +7,7 @@ if not modules then modules = { } end modules ['driv-shp'] = { license = "see context related readme files" } -local type, next = type, next +local type, next, rawget, rawset = type, next, rawget, rawset local setmetatableindex = table.setmetatableindex local formatters = string.formatters @@ -27,6 +27,8 @@ local getdirection = nuts.getdirection local getlist = nuts.getlist local getoffsets = nuts.getoffsets local getorientation = nuts.getorientation +local getanchors = nuts.getanchors +local getgeometry = nuts.getgeometry local getxyscales = nuts.getxyscales local getwhd = nuts.getwhd local getkern = nuts.getkern @@ -93,6 +95,9 @@ local drivers = drivers local report = logs.reporter("drivers") +--------------------------------------------------------------------------------------- +-- For the moment rules need at least some height but maybe some day we let user rules +-- fall through or have some way to force a rule via some property. --------------------------------------------------------------------------------------- local lastfont = nil @@ -609,23 +614,75 @@ end -- -- local dirstack = setmetatableindex(dirstackentry) -- --- local function reset_dir_stack() +-- local function reset_directions() -- dirstack = setmetatableindex(dirstackentry) -- end local dirstack = { } +local anchors = { } +----- befores = setmetatableindex("table") +----- afters = setmetatableindex("table") -local function reset_dir_stack() +local function reset_directions() dirstack = { } end +local function reset_anchors() + anchors = { } +end + +-- interfaces.implement { +-- name = "registeranchorbox", +-- arguments = { "integer", "integer", "box" }, +-- actions = function(anchor,where,box) +-- box = tonut(box) +-- if where < 0 then +-- table.insert(befores[anchor],box) +-- else +-- table.insert(afters[anchor],box) +-- end +-- end +-- } + local hlist_out, vlist_out do - local function applyanchor(orientation,x,y,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset) - local ot = (orientation>> 0) & 0x0F - local ay = (orientation>> 4) & 0x0F - local ax = (orientation>> 8) & 0x0F - local of = (orientation>>12) & 0x0F + local finalize = nodes.handlers.finalizelist + -- local takebox = nuts.takebox + local flushnode = nuts.flushnode + + -- local function flushstored(current,source,before) + -- local s = nil + -- if before then + -- s = rawget(befores,source) + -- else + -- s = rawget(afters,source) + -- end + -- if s then + -- for i=1,#s do + -- local si = s[i] + -- if si then + -- finalize(si) -- tricky: we might need to group + -- if getid(si) == vlist_code then + -- vlist_out(current,si) + -- else + -- hlist_out(current,si) + -- end + -- flushnode(si) + -- s[i] = false + -- end + -- end + -- if before then + -- rawset(befores,source,nil) + -- else + -- rawset(afters,source,nil) + -- end + -- end + -- end + + local function applyorientation(orientation,x,y,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset) + local ot = (orientation >> 0) & 0x0F + local ay = (orientation >> 4) & 0x0F + local ax = (orientation >> 8) & 0x0F if ot == 4 then ot, ay = 0, 1 elseif ot == 5 then @@ -663,7 +720,71 @@ local hlist_out, vlist_out do return ot, x + xoffset, y - yoffset end - drivers.applyanchor = applyanchor + local function applyanchor(anchor,shift,anchor_h,anchor_v,width,height,depth) + local h = 0 + local v = 0 + if shift then + anchor = (anchor & 0xFFFF0000) >> 16 + else + anchor = (anchor & 0x0000FFFF) + end + local a = anchor & 0x00FF + local s = anchor & 0x0F00 + if a == 0x02 then + v = height + elseif a == 0x03 then + v = - depth + elseif a == 0x04 then + h = width + elseif a == 0x05 then + h = width + v = height + elseif a == 0x06 then + h = width + v = - depth + elseif a == 0x07 then + h = width/2 + elseif a == 0x08 then + h = width/2 + v = height + elseif a == 0x09 then + h = width/2 + v = - depth + elseif a == 0x0A then -- halfway_total_anchor + h = width/2 + v = height/2 - depth/2 + elseif a == 0x0B then -- halfway_height_anchor + h = width/2 + v = height/2 + elseif a == 0x0C then -- halfway_depth_anchor + h = width/2 + v = - depth/2 + elseif a == 0x0D then -- halfway_left_anchor + v = height/2 - depth/2 + elseif a == 0x0E then -- halfway_right_anchor + h = width + v = height/2 - depth/2 + end + if not shift then + h = -h + v = -v + end + if s == 0x100 then + h = -h + elseif s == 0x200 then + v = -v + elseif s == 0x300 then + h = -h + v = -v + else + end + anchor_h = anchor_h + h + anchor_v = anchor_v + v + return anchor_h, anchor_v + end + + drivers.applyanchor = applyanchor + drivers.applyorientation = applyorientation -- to be checked: begin- or enddir kan nil zijn, weird @@ -745,12 +866,10 @@ local hlist_out, vlist_out do local save_h = cur_h if pos_r == righttoleft_code then cur_h = ref_h - shipbox_h + cur_h --- cur_h = width * (cur_h // width) cur_h = width * (cur_h / width) cur_h = ref_h - shipbox_h - cur_h else cur_h = ref_h - shipbox_h - cur_h --- cur_h = width * (cur_h // width) cur_h = width * (cur_h / width) cur_h = ref_h - shipbox_h - cur_h end @@ -759,7 +878,6 @@ local hlist_out, vlist_out do end elseif subtype == leaders_code then local save_h = cur_h --- cur_h = width * (cur_h // width) cur_h = width * (cur_h / width) if cur_h < save_h then cur_h = cur_h + width @@ -768,12 +886,9 @@ local hlist_out, vlist_out do lq = gluewidth / width lr = gluewidth % width if subtype == cleaders_code then --- cur_h = cur_h + lr // 2 cur_h = cur_h + lr / 2 else --- lx = lr // (lq + 1) lx = lr / (lq + 1) --- cur_h = cur_h + (lr - (lq - 1) * lx) // 2 cur_h = cur_h + (lr - (lq - 1) * lx) / 2 end end @@ -863,57 +978,42 @@ local hlist_out, vlist_out do local list = getlist(current) if list then local boxdir = getdirection(current) or lefttoright_code - local shift, orientation = getshift(current) - if not orientation then - local basepoint_h = boxdir ~= pos_r and width or 0 - -- local basepoint_v = shift - if pos_r == righttoleft_code then - pos_h = ref_h - (cur_h + basepoint_h) - else - pos_h = ref_h + (cur_h + basepoint_h) - end - pos_v = ref_v - shift - -- synced - if id == vlist_code then - vlist_out(current,list) - else - hlist_out(current,list) - end - elseif orientation == 0x1000 then - local orientation, xoffset, yoffset = getorientation(current) - local basepoint_h = boxdir ~= pos_r and width or 0 - -- local basepoint_v = shift - if pos_r == righttoleft_code then - pos_h = ref_h - (cur_h + basepoint_h + xoffset) - else - pos_h = ref_h + (cur_h + basepoint_h + xoffset) - end - pos_v = ref_v - (shift - yoffset) - -- pushorientation(orientation,pos_h,pos_v,pos_r) - -- synced - if id == vlist_code then - vlist_out(current,list) - else - hlist_out(current,list) - end - -- poporientation(orientation,pos_h,pos_v,pos_r) - else + local shift = getshift(current) + local geometry, hasoffset, hasorientation, hasanchor = getgeometry(current,true) + local anchor, source, target, targetdata + local anc_h, anc_v + local usedorientation = false + if hasanchor then + anchor, source, target = getanchors(current) + end + if hasorientation then local orientation, xoffset, yoffset, woffset, hoffset, doffset = getorientation(current) - local orientation, basepoint_h, basepoint_v = applyanchor(orientation,0,shift,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset) + local orientation, basepoint_h, basepoint_v = applyorientation(orientation,0,shift,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset) if orientation == 1 then basepoint_h = basepoint_h + doffset if boxdir == pos_r then basepoint_v = basepoint_v - height end + usedorientation = orientation elseif orientation == 2 then if boxdir == pos_r then basepoint_h = basepoint_h + width end + usedorientation = orientation elseif orientation == 3 then basepoint_h = basepoint_h + hoffset if boxdir ~= pos_r then basepoint_v = basepoint_v - height end + usedorientation = orientation + end + if target then + targetdata = anchors[target] + if targetdata then + anc_h = basepoint_h + anc_v = - basepoint_v + goto posdone + end end if pos_r == righttoleft_code then pos_h = ref_h - (cur_h + basepoint_h) @@ -922,14 +1022,88 @@ local hlist_out, vlist_out do end -- pos_v = ref_v - (cur_v + basepoint_v) pos_v = ref_v - basepoint_v - -- synced - pushorientation(orientation,pos_h,pos_v,pos_r) - if id == vlist_code then - vlist_out(current,list) + elseif hasoffset then + local orientation, xoffset, yoffset = getorientation(current) + local basepoint_h = boxdir ~= pos_r and width or 0 + local basepoint_v = shift + if target then + targetdata = anchors[target] + if targetdata then + anc_h = xoffset + basepoint_h + anc_v = yoffset - basepoint_v + goto posdone + end + end + if pos_r == righttoleft_code then + pos_h = ref_h - (cur_h + basepoint_h + xoffset) + else + pos_h = ref_h + (cur_h + basepoint_h + xoffset) + end + pos_v = ref_v - (basepoint_v - yoffset) + elseif hasanchor then + local basepoint_h = boxdir ~= pos_r and width or 0 + local basepoint_v = shift + if target then + targetdata = anchors[target] + if targetdata then + anc_h = basepoint_h + anc_v = - basepoint_v + goto posdone + end + end + if pos_r == righttoleft_code then + pos_h = ref_h - (cur_h + basepoint_h) else - hlist_out(current,list) + pos_h = ref_h + (cur_h + basepoint_h) end - poporientation(orientation,pos_h,pos_v,pos_r) + pos_v = ref_v - basepoint_v + else + local basepoint_h = boxdir ~= pos_r and width or 0 + local basepoint_v = shift + if pos_r == righttoleft_code then + pos_h = ref_h - (cur_h + basepoint_h) + else + pos_h = ref_h + (cur_h + basepoint_h) + end + pos_v = ref_v - basepoint_v + end + goto process + ::posdone:: + if pos_r == righttoleft_code then + pos_h = targetdata[1] - anc_h + else + pos_h = targetdata[1] + anc_h + end + pos_v = targetdata[2] + anc_v + if anchor and anchor > 0 then + pos_h, pos_v = applyanchor(anchor,true,pos_h,pos_v,targetdata[3],targetdata[4],targetdata[5]) + pos_h, pos_v = applyanchor(anchor,false,pos_h,pos_v,width,height,depth) + end + ::process:: + if source then + local anchor_h = pos_h + local anchor_v = pos_v + if usedorientation then + if usedorientation == 1 then + anchor_v = anchor_v - (width - height) + elseif usedorientation == 2 then + anchor_v = anchor_v - (depth - height) + elseif usedorientation == 3 then -- weird + anchor_v = anchor_v + (height - width) + end + end + anchors[source] = { anchor_h, anchor_v, width, height, depth } + end + if usedorientation then + pushorientation(usedorientation,pos_h,pos_v,pos_r) + end + if id == vlist_code then + vlist_out(current,list) + else + hlist_out(current,list) + end + if usedorientation then + poporientation(usedorientation,pos_h,pos_v,pos_r) end end cur_h = cur_h + width @@ -1183,70 +1357,146 @@ local hlist_out, vlist_out do local list = getlist(current) if list then local boxdir = getdirection(current) or lefttoright_code - local shift, orientation = getshift(current) - if not orientation then - -- local basepoint_h = shift - -- local basepoint_v = height - if boxdir ~= pos_r then - shift = shift + width + local shift = getshift(current) + local geometry, hasoffset, hasorientation, hasanchor = getgeometry(current,true) + local anchor, source, target, targetdata + local usedorientation = false + if hasanchor then + anchor, source, target = getanchors(current) + end + if hasorientation then + local orientation, xoffset, yoffset, woffset, hoffset, doffset = getorientation(current) + local orientation, basepoint_h, basepoint_v = applyorientation(orientation,shift,height,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset) + if orientation == 1 then + basepoint_h = basepoint_h + width - height -- hm + basepoint_v = basepoint_v - height + usedorientation = orientation + elseif orientation == 2 then + basepoint_h = basepoint_h + width + basepoint_v = basepoint_v + depth - height + usedorientation = orientation + elseif orientation == 3 then -- weird + basepoint_h = basepoint_h + height + usedorientation = orientation end - if pos_r == righttoleft_code then - pos_h = ref_h - shift - else - pos_h = ref_h + shift + if target then + targetdata = anchors[target] + if targetdata then + if pos_r == righttoleft_code then + pos_h = targetdata[1] - basepoint_h + else + pos_h = targetdata[1] + basepoint_h + end + pos_v = targetdata[2] - basepoint_v + goto posdone + end end - pos_v = ref_v - (cur_v + height) - -- synced - if id == vlist_code then - vlist_out(current,list) + if pos_r == righttoleft_code then + pos_h = ref_h - basepoint_h else - hlist_out(current,list) + pos_h = ref_h + basepoint_h end - elseif orientation == 0x1000 then + pos_v = ref_v - (cur_v + basepoint_v) + elseif hasoffset then local orientation, xoffset, yoffset = getorientation(current) -- local basepoint_h = shift -- local basepoint_v = height if boxdir ~= pos_r then shift = shift + width end + if target then + targetdata = anchors[target] + if targetdata then + if pos_r == righttoleft_code then + pos_h = targetdata[1] - (shift + xoffset) + else + pos_h = targetdata[1] + (shift + xoffset) + end + pos_v = targetdata[2] - (height - yoffset) + goto posdone + end + end if pos_r == righttoleft_code then pos_h = ref_h - (shift + xoffset) else pos_h = ref_h + (shift + xoffset) end pos_v = ref_v - (cur_v + height - yoffset) - -- synced - if id == vlist_code then - vlist_out(current,list) + elseif hasanchor then + -- local basepoint_h = shift + -- local basepoint_v = height + if boxdir ~= pos_r then + shift = shift + width + end + if target then + local a = anchors[target] + if a then + if pos_r == righttoleft_code then + pos_h = targetdata[1] - shift + else + pos_h = targetdata[1] + shift + end + pos_v = targetdata[2] - height + goto posdone + end + end + if pos_r == righttoleft_code then + pos_h = ref_h - shift else - hlist_out(current,list) + pos_h = ref_h + shift end + pos_v = ref_v - (cur_v + height) else - local orientation, xoffset, yoffset, woffset, hoffset, doffset = getorientation(current) - local orientation, basepoint_h, basepoint_v = applyanchor(orientation,shift,height,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset) - if orientation == 1 then - basepoint_h = basepoint_h + width - height - basepoint_v = basepoint_v - height - elseif orientation == 2 then - basepoint_h = basepoint_h + width - basepoint_v = basepoint_v + depth - height - elseif orientation == 3 then -- weird - basepoint_h = basepoint_h + height + -- local basepoint_h = shift + -- local basepoint_v = height + if boxdir ~= pos_r then + shift = shift + width end if pos_r == righttoleft_code then - pos_h = ref_h - basepoint_h + pos_h = ref_h - shift else - pos_h = ref_h + basepoint_h + pos_h = ref_h + shift end - pos_v = ref_v - (cur_v + basepoint_v) - -- synced - pushorientation(orientation,pos_h,pos_v,pos_r) - if id == vlist_code then - vlist_out(current,list) - else - hlist_out(current,list) + pos_v = ref_v - (cur_v + height) + end + goto process + ::posdone:: + if anchor and anchor > 0 then + pos_h, pos_v = applyanchor(anchor,true,pos_h,pos_v,targetdata[3],targetdata[4],targetdata[5]) + pos_h, pos_v = applyanchor(anchor,false,pos_h,pos_v,width,height,depth) + end + ::process:: + if source then + -- move this into apply_anchor + local anchor_h = pos_h + local anchor_v = pos_v + if usedorientation then + if usedorientation == 1 then + anchor_v = anchor_v - (width - height) + elseif usedorientation == 2 then + anchor_v = anchor_v - (depth - height) + elseif usedorientation == 3 then -- weird + anchor_v = anchor_v + (height - width) + end end - poporientation(orientation,pos_h,pos_v,pos_r) + anchors[source] = { anchor_h, anchor_v, width, height, depth } + end + if usedorientation then + pushorientation(usedorientation,pos_h,pos_v,pos_r) + end + -- if source then + -- flushstored(current,source,true) + -- end + if id == vlist_code then + vlist_out(current,list) + else + hlist_out(current,list) + end + -- if source then + -- flushstored(current,source,false) + -- end + if usedorientation then + poporientation(usedorientation,pos_h,pos_v,pos_r) end end cur_v = cur_v + height + depth @@ -1332,7 +1582,8 @@ function drivers.converters.lmtx(driver,box,smode,objnum,specification) flushliteral = flushers.literal flushwhatsit = flushers.whatsit - reset_dir_stack() + reset_directions() + reset_anchors() reset_state() shippingmode = smode diff --git a/tex/context/base/mkxl/driv-usr.lmt b/tex/context/base/mkxl/driv-usr.lmt index 2dc3cda73..5ff601f2a 100644 --- a/tex/context/base/mkxl/driv-usr.lmt +++ b/tex/context/base/mkxl/driv-usr.lmt @@ -14,6 +14,8 @@ local getdirection = nuts.getdirection local getlist = nuts.getlist local getoffsets = nuts.getoffsets local getorientation = nuts.getorientation +local getanchors = nuts.getanchors +local getgeometry = nuts.getgeometry local getwhd = nuts.getwhd local getkern = nuts.getkern local getwidth = nuts.getwidth @@ -67,6 +69,7 @@ local pos_h = 0 local pos_v = 0 local pos_r = lefttoright_code +local applyorientation = drivers.applyorientation local applyanchor = drivers.applyanchor local initialize @@ -119,42 +122,88 @@ hlist_out = function(this_box,current) local list = getlist(current) if list then local boxdir = getdirection(current) or lefttoright_code - local shift, orientation = getshift(current) - if not orientation then - local basepoint_h = boxdir ~= pos_r and width or 0 - if pos_r == righttoleft_code then - pos_h = ref_h - (cur_h + basepoint_h) - else - pos_h = ref_h + (cur_h + basepoint_h) - end - pos_v = ref_v - shift - elseif orientation == 0x1000 then - local orientation, xoffset, yoffset = getorientation(current) - local basepoint_h = boxdir ~= pos_r and width or 0 - if pos_r == righttoleft_code then - pos_h = ref_h - (cur_h + basepoint_h + xoffset) - else - pos_h = ref_h + (cur_h + basepoint_h + xoffset) - end - pos_v = ref_v - (shift - yoffset) - else + local shift = getshift(current) + local geometry, hasoffset, hasorientation, hasanchor = getgeometry(current,true) + local anchor, source, target, targetdata + local anc_h, anc_v + local usedorientation = false + if hasanchor then + anchor, source, target = getanchors(current) + end + if hasorientation then local orientation, xoffset, yoffset, woffset, hoffset, doffset = getorientation(current) - local orientation, basepoint_h, basepoint_v = applyanchor(orientation,0,shift,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset) + local orientation, basepoint_h, basepoint_v = applyorientation(orientation,0,shift,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset) if orientation == 1 then basepoint_h = basepoint_h + doffset if boxdir == pos_r then basepoint_v = basepoint_v - height end + usedorientation = orientation elseif orientation == 2 then if boxdir == pos_r then basepoint_h = basepoint_h + width end + usedorientation = orientation elseif orientation == 3 then basepoint_h = basepoint_h + hoffset if boxdir ~= pos_r then basepoint_v = basepoint_v - height end + usedorientation = orientation + end + if target then + targetdata = anchors[target] + if targetdata then + anc_h = basepoint_h + anc_v = - basepoint_v + goto posdone + end + end + if pos_r == righttoleft_code then + pos_h = ref_h - (cur_h + basepoint_h) + else + pos_h = ref_h + (cur_h + basepoint_h) + end + -- pos_v = ref_v - (cur_v + basepoint_v) + pos_v = ref_v - basepoint_v + elseif hasoffset then + local orientation, xoffset, yoffset = getorientation(current) + local basepoint_h = boxdir ~= pos_r and width or 0 + local basepoint_v = shift + if target then + targetdata = anchors[target] + if targetdata then + anc_h = xoffset + basepoint_h + anc_v = yoffset - basepoint_v + goto posdone + end + end + if pos_r == righttoleft_code then + pos_h = ref_h - (cur_h + basepoint_h + xoffset) + else + pos_h = ref_h + (cur_h + basepoint_h + xoffset) + end + pos_v = ref_v - (basepoint_v - yoffset) + elseif hasanchor then + local basepoint_h = boxdir ~= pos_r and width or 0 + local basepoint_v = shift + if target then + targetdata = anchors[target] + if targetdata then + anc_h = basepoint_h + anc_v = - basepoint_v + goto posdone + end + end + if pos_r == righttoleft_code then + pos_h = ref_h - (cur_h + basepoint_h) + else + pos_h = ref_h + (cur_h + basepoint_h) end + pos_v = ref_v - basepoint_v + else + local basepoint_h = boxdir ~= pos_r and width or 0 + local basepoint_v = shift if pos_r == righttoleft_code then pos_h = ref_h - (cur_h + basepoint_h) else @@ -162,13 +211,47 @@ hlist_out = function(this_box,current) end pos_v = ref_v - basepoint_v end + goto process + ::posdone:: + if pos_r == righttoleft_code then + pos_h = targetdata[1] - anc_h + else + pos_h = targetdata[1] + anc_h + end + pos_v = targetdata[2] + anc_v + if anchor and anchor > 0 then + pos_h, pos_v = applyanchor(anchor,true,pos_h,pos_v,targetdata[3],targetdata[4],targetdata[5]) + pos_h, pos_v = applyanchor(anchor,false,pos_h,pos_v,width,height,depth) + end + ::process:: + if source then + local anchor_h = pos_h + local anchor_v = pos_v + if usedorientation then + if usedorientation == 1 then + anchor_v = anchor_v - (width - height) + elseif usedorientation == 2 then + anchor_v = anchor_v - (depth - height) + elseif usedorientation == 3 then -- weird + anchor_v = anchor_v + (height - width) + end + end + anchors[source] = { anchor_h, anchor_v, width, height, depth } + end + -- if usedorientation then + -- pushorientation(usedorientation,pos_h,pos_v,pos_r) + -- end if id == vlist_code then vlist_out(current,list) else hlist_out(current,list) end + -- if usedorientation then + -- poporientation(usedorientation,pos_h,pos_v,pos_r) + -- end end cur_h = cur_h + width + elseif id == kern_code then local kern, factor = getkern(current,true) if kern ~= 0 then @@ -271,54 +354,150 @@ vlist_out = function(this_box,current) local list = getlist(current) if list then local boxdir = getdirection(current) or lefttoright_code - local shift, orientation = getshift(current) - if not orientation then - if boxdir ~= pos_r then - shift = shift + width + local shift = getshift(current) + local geometry, hasoffset, hasorientation, hasanchor = getgeometry(current,true) + local anchor, source, target, targetdata + local usedorientation = false + if hasanchor then + anchor, source, target = getanchors(current) + end + if hasorientation then + local orientation, xoffset, yoffset, woffset, hoffset, doffset = getorientation(current) + local orientation, basepoint_h, basepoint_v = applyorientation(orientation,shift,height,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset) + if orientation == 1 then + basepoint_h = basepoint_h + width - height -- hm + basepoint_v = basepoint_v - height + usedorientation = orientation + elseif orientation == 2 then + basepoint_h = basepoint_h + width + basepoint_v = basepoint_v + depth - height + usedorientation = orientation + elseif orientation == 3 then -- weird + basepoint_h = basepoint_h + height + usedorientation = orientation + end + if target then + targetdata = anchors[target] + if targetdata then + if pos_r == righttoleft_code then + pos_h = targetdata[1] - basepoint_h + else + pos_h = targetdata[1] + basepoint_h + end + pos_v = targetdata[2] - basepoint_v + goto posdone + end end if pos_r == righttoleft_code then - pos_h = ref_h - shift + pos_h = ref_h - basepoint_h else - pos_h = ref_h + shift + pos_h = ref_h + basepoint_h end - pos_v = ref_v - (cur_v + height) - elseif orientation == 0x1000 then + pos_v = ref_v - (cur_v + basepoint_v) + elseif hasoffset then local orientation, xoffset, yoffset = getorientation(current) + -- local basepoint_h = shift + -- local basepoint_v = height if boxdir ~= pos_r then shift = shift + width end + if target then + targetdata = anchors[target] + if targetdata then + if pos_r == righttoleft_code then + pos_h = targetdata[1] - (shift + xoffset) + else + pos_h = targetdata[1] + (shift + xoffset) + end + pos_v = targetdata[2] - (height - yoffset) + goto posdone + end + end if pos_r == righttoleft_code then pos_h = ref_h - (shift + xoffset) else pos_h = ref_h + (shift + xoffset) end pos_v = ref_v - (cur_v + height - yoffset) + elseif hasanchor then + -- local basepoint_h = shift + -- local basepoint_v = height + if boxdir ~= pos_r then + shift = shift + width + end + if target then + local a = anchors[target] + if a then + if pos_r == righttoleft_code then + pos_h = targetdata[1] - shift + else + pos_h = targetdata[1] + shift + end + pos_v = targetdata[2] - height + goto posdone + end + end + if pos_r == righttoleft_code then + pos_h = ref_h - shift + else + pos_h = ref_h + shift + end + pos_v = ref_v - (cur_v + height) else - local orientation, xoffset, yoffset, woffset, hoffset, doffset = getorientation(current) - local orientation, basepoint_h, basepoint_v = applyanchor(orientation,shift,height,width,height,depth,woffset,hoffset,doffset,xoffset,yoffset) - if orientation == 1 then - basepoint_h = basepoint_h + width - height - basepoint_v = basepoint_v - height - elseif orientation == 2 then - basepoint_h = basepoint_h + width - basepoint_v = basepoint_v + depth - height - elseif orientation == 3 then -- weird - basepoint_h = basepoint_h + height + -- local basepoint_h = shift + -- local basepoint_v = height + if boxdir ~= pos_r then + shift = shift + width end if pos_r == righttoleft_code then - pos_h = ref_h - basepoint_h + pos_h = ref_h - shift else - pos_h = ref_h + basepoint_h + pos_h = ref_h + shift end - pos_v = ref_v - (cur_v + basepoint_v) + pos_v = ref_v - (cur_v + height) + end + goto process + ::posdone:: + if anchor and anchor > 0 then + pos_h, pos_v = applyanchor(anchor,true,pos_h,pos_v,targetdata[3],targetdata[4],targetdata[5]) + pos_h, pos_v = applyanchor(anchor,false,pos_h,pos_v,width,height,depth) + end + ::process:: + if source then + -- move this into apply_anchor + local anchor_h = pos_h + local anchor_v = pos_v + if usedorientation then + if usedorientation == 1 then + anchor_v = anchor_v - (width - height) + elseif usedorientation == 2 then + anchor_v = anchor_v - (depth - height) + elseif usedorientation == 3 then -- weird + anchor_v = anchor_v + (height - width) + end + end + anchors[source] = { anchor_h, anchor_v, width, height, depth } end + -- if usedorientation then + -- pushorientation(usedorientation,pos_h,pos_v,pos_r) + -- end + -- if source then + -- flushstored(current,source,true) + -- end if id == vlist_code then vlist_out(current,list) else hlist_out(current,list) end + -- if source then + -- flushstored(current,source,false) + -- end + -- if usedorientation then + -- poporientation(usedorientation,pos_h,pos_v,pos_r) + -- end end cur_v = cur_v + height + depth + elseif id == kern_code then cur_v = cur_v + getkern(current) elseif id == rule_code then diff --git a/tex/context/base/mkxl/grph-rul.lmt b/tex/context/base/mkxl/grph-rul.lmt index 50a40155e..b1de3a6a6 100644 --- a/tex/context/base/mkxl/grph-rul.lmt +++ b/tex/context/base/mkxl/grph-rul.lmt @@ -22,6 +22,8 @@ local tonode = nuts.tonode local getattribute = tex.getattribute +local direct_value = tokens.values.direct + local a_color = attributes.private('color') local a_transparency = attributes.private('transparency') local a_colormodel = attributes.private('colormodel') @@ -40,6 +42,8 @@ end) interfaces.implement { name = "frule", + public = true, + protected = true, arguments = { { { "width", "dimension" }, { "height", "dimension" }, @@ -52,7 +56,7 @@ interfaces.implement { { "radius", "dimension" }, { "corner", "string" }, } } , - actions = function(t) + actions = function(t,...) local rule = userrule(t) if t.type == "mp" then t.ma = getattribute(a_colormodel) or 1 @@ -61,7 +65,7 @@ interfaces.implement { else setattrlist(rule,true) end - context(tonode(rule)) -- will become context.nodes.flush + context(nuts.tonode(rule)) end } @@ -78,17 +82,19 @@ interfaces.implement { actions = function(t) local rule = outlinerule(t.width,t.height,t.depth,t.line) setattrlist(rule,true) - context(tonode(rule)) -- will become context.nodes.flush + context(tonode(rule)) end } interfaces.implement { name = "framedoutline", + -- public = true, + -- protected = true, arguments = { "dimension", "dimension", "dimension", "dimension" }, actions = function(w,h,d,l) local rule = outlinerule(w,h,d,l) setattrlist(rule,true) - context(tonode(rule)) -- will become context.nodes.flush + context(tonode(rule)) end } diff --git a/tex/context/base/mkxl/grph-rul.mkxl b/tex/context/base/mkxl/grph-rul.mkxl index 034e91734..5c192e345 100644 --- a/tex/context/base/mkxl/grph-rul.mkxl +++ b/tex/context/base/mkxl/grph-rul.mkxl @@ -17,7 +17,7 @@ \unprotect -\permanent\protected\def\frule{\relax\clf_frule} % will become a public implementer +% \permanent\protected\def\frule{\relax\clf_frule} % will become a public implementer % just for fun: diff --git a/tex/context/base/mkxl/lang-ini.lmt b/tex/context/base/mkxl/lang-ini.lmt index 2030fb697..7919df530 100644 --- a/tex/context/base/mkxl/lang-ini.lmt +++ b/tex/context/base/mkxl/lang-ini.lmt @@ -607,25 +607,25 @@ end do - local nuts = nodes.nuts - local nextglyph = nuts.traversers.glyph - local setoptions = nuts.setoptions - - local getnext = nuts.getnext - local getprev = nuts.getprev - local setchar = nuts.setchar - local setnext = nuts.setnext - local setlink = nuts.setlink - local setfield = nuts.setfield - local setdisc = nuts.setdisc - local getprop = nuts.getprop - local setprop = nuts.setprop - local setattrlist = nuts.setattrlist - - local new_disc = nuts.pool.disc - local new_glyph = nuts.pool.glyph - local copy_node = nuts.copy - local flushlist = nuts.flushlist + local nuts = nodes.nuts + local nextglyph = nuts.traversers.glyph + local setoptions = nuts.setoptions + + local getnext = nuts.getnext + local getprev = nuts.getprev + local setchar = nuts.setchar + local setnext = nuts.setnext + local setlink = nuts.setlink + local setfield = nuts.setfield + local setdisc = nuts.setdisc + local getprop = nuts.getprop + local setprop = nuts.setprop + local setattrlist = nuts.setattrlist + + local new_disc = nuts.pool.disc + local new_glyph = nuts.pool.glyph + local copy_node = nuts.copy + local flushlist = nuts.flushlist local glyphoptioncodes = tex.glyphoptioncodes @@ -794,6 +794,7 @@ do local sequencers = utilities.sequencers local newsequencer = sequencers.new local appendgroup = sequencers.appendgroup + local prependaction = sequencers.prependaction local appendaction = sequencers.appendaction local enableaction = sequencers.enableaction local disableaction = sequencers.disableaction diff --git a/tex/context/base/mkxl/lpdf-lmt.lmt b/tex/context/base/mkxl/lpdf-lmt.lmt index 321dea935..0861e0916 100644 --- a/tex/context/base/mkxl/lpdf-lmt.lmt +++ b/tex/context/base/mkxl/lpdf-lmt.lmt @@ -1429,15 +1429,13 @@ local flushimage do -- small sizes which is needed for inaccurate viewers. flushers.rule = function(current,pos_h,pos_v,pos_r,size_h,size_v,subtype) - if subtype == emptyrule_code then return elseif subtype == boxrule_code then return flushpdfxform(current,pos_h,pos_v,pos_r,size_h,size_v) elseif subtype == imagerule_code then return flushpdfximage(current,pos_h,pos_v,pos_r,size_h,size_v) - end - if subtype == userrule_code or subtype >= overrule_code and subtype <= radicalrule_code then + elseif subtype == userrule_code or (subtype >= overrule_code and subtype <= radicalrule_code) then pdf_goto_pagemode() b = b + 1 ; buffer[b] = s_b pdf_set_pos_temp(pos_h,pos_v) diff --git a/tex/context/base/mkxl/lpdf-rul.lmt b/tex/context/base/mkxl/lpdf-rul.lmt index 4c7bcf633..96b4597bb 100644 --- a/tex/context/base/mkxl/lpdf-rul.lmt +++ b/tex/context/base/mkxl/lpdf-rul.lmt @@ -101,12 +101,18 @@ def RuleColor = %color% enddef ; local initialized = false ; local function rule_mp(p,h,v,i,n) - local name = p.name or "fake:rest" - local code = (predefined[name] or predefined["fake:rest"]) { + local name = p.name or "fake:rest" + local ht = p.height or 0 + local dp = p.depth or 0 + local total = ht + dp + local code = (predefined[name] or predefined["fake:rest"]) { data = p.data or "", - width = p.width * bpfactor, - height = p.height * bpfactor, - depth = p.depth * bpfactor, + -- width = p.width * bpfactor, + -- height = p.height * bpfactor, + -- depth = p.depth * bpfactor, + width = h * bpfactor, + height = v * bpfactor * ht / total, + depth = v * bpfactor * dp / total, factor = (p.factor or 0) * bpfactor, -- needs checking offset = p.offset or 0, line = (p.line or 65536) * bpfactor, diff --git a/tex/context/base/mkxl/luat-log.lmt b/tex/context/base/mkxl/luat-log.lmt index 2b5b60dd9..dd6c1b990 100644 --- a/tex/context/base/mkxl/luat-log.lmt +++ b/tex/context/base/mkxl/luat-log.lmt @@ -626,6 +626,11 @@ if package.helpers.report then package.helpers.report = logs.reporter("package loader") -- when used outside mtxrun end +-- logs.errors=missing references,missing characters +-- logs.errors=characters +-- logs.errors=missing +-- logs.errors=* + do local finalactions = { } @@ -641,6 +646,9 @@ do loggingerrors = v if type(v) == "string" then fatalerrors = settings_to_hash(v) + for k, v in next, fatalerrors do + fatalerrors[k] = string.topattern(k) + end else fatalerrors = { } end @@ -704,6 +712,13 @@ do end if fatalerrors[w] then possiblefatal[w] = true + else + for k, v in next, fatalerrors do + if find(w,v) then + possiblefatal[w] = true + break + end + end end return startlogging("terminal",r,w,...) end diff --git a/tex/context/base/mkxl/mult-sys.mkxl b/tex/context/base/mkxl/mult-sys.mkxl index 500d929c6..48a35e0b2 100644 --- a/tex/context/base/mkxl/mult-sys.mkxl +++ b/tex/context/base/mkxl/mult-sys.mkxl @@ -106,6 +106,7 @@ \definesystemconstant {action} \definesystemconstant {all} \definesystemconstant {ampersand} +\definesystemconstant {anchor} \definesystemconstant {ascii} \definesystemconstant {attribute} \definesystemconstant {attr} @@ -357,6 +358,7 @@ \definesystemconstant {smallcaps} \definesystemconstant {small} \definesystemconstant {somewhere} +\definesystemconstant {source} \definesystemconstant {special} \definesystemconstant {spec} \definesystemconstant {spot} @@ -375,6 +377,7 @@ \definesystemconstant {text} \definesystemconstant {tex} \definesystemconstant {tf} +\definesystemconstant {target} \definesystemconstant {third} \definesystemconstant {topfloat} \definesystemconstant {top} diff --git a/tex/context/base/mkxl/node-bck.lmt b/tex/context/base/mkxl/node-bck.lmt index ff48ff8b5..ad8f8d59e 100644 --- a/tex/context/base/mkxl/node-bck.lmt +++ b/tex/context/base/mkxl/node-bck.lmt @@ -65,7 +65,7 @@ local linefillers = nodes.linefillers local a_background = privateattributes("background") local a_alignbackground = privateattributes("alignbackground") local a_linefiller = privateattributes("linefiller") -local a_ruled = privateattributes("ruled") +----- a_ruled = privateattributes("ruled") local trace_alignment = false local report_alignment = logs.reporter("backgrounds","alignment") @@ -146,7 +146,7 @@ local function add_alignbackgrounds(head,list,data) for template in nexthlist, list do local background = getattr(template,a_alignbackground) if background then - local list = colored_a(current,list,template,data) + local list = colored_a(current,list,template,id,data) if list then setlist(current,list) end @@ -169,7 +169,7 @@ local function add_backgrounds(head,id,list,data) if list then for current, id, subtype, list in nextlist, list do if list then - if alignments and subtype == alignmentlist_code then + if data and alignments and subtype == alignmentlist_code then local l = add_alignbackgrounds(current,list,data) if l then list = l @@ -197,9 +197,9 @@ end function nodes.handlers.backgrounds(head) local data = attributes.values[a_linefiller] - if data then +-- if data then add_backgrounds(head,getid(head),getlist(head),data) - end +-- end return head end diff --git a/tex/context/base/mkxl/node-fin.lmt b/tex/context/base/mkxl/node-fin.lmt index 4bf8663be..7093638de 100644 --- a/tex/context/base/mkxl/node-fin.lmt +++ b/tex/context/base/mkxl/node-fin.lmt @@ -23,7 +23,7 @@ local getattr = nuts.getattr local getattrs = nuts.getattrs local getwidth = nuts.getwidth local getwhd = nuts.getwhd -local getorientation = nuts.getorientation +local hasgeometry = nuts.hasgeometry local hasdimensions = nuts.hasdimensions local getbox = nuts.getbox @@ -184,7 +184,7 @@ local function process(attribute,head,inheritance,default) -- one attribute elseif id == hlist_code or id == vlist_code then -- tricky checking local outer - if subtype == container_code or getorientation(stack) then + if subtype == container_code or hasgeometry(stack) then outer = getattr(stack,attribute) if outer then if default and outer == inheritance then @@ -271,7 +271,7 @@ local function simple(attribute,head) check = true leader = content elseif id == hlist_code or id == vlist_code then - if subtype == container_code or getorientation(stack) then + if subtype == container_code or hasgeometry(stack) then local outer = getattr(stack,attribute) if outer then if current ~= outer then @@ -349,7 +349,7 @@ local function selective(attribute,head,inheritance,default) -- two attributes leader = content elseif id == hlist_code or id == vlist_code then local outer, s - if subtype == container_code or getorientation(stack) then + if subtype == container_code or hasgeometry(stack) then outer, s = getattrs(stack,attribute,nsselector) if outer then if default and outer == inheritance then diff --git a/tex/context/base/mkxl/node-nut.lmt b/tex/context/base/mkxl/node-nut.lmt index dfa89e4ab..fa98d26fe 100644 --- a/tex/context/base/mkxl/node-nut.lmt +++ b/tex/context/base/mkxl/node-nut.lmt @@ -112,6 +112,8 @@ local nuts = { getnucleus = direct.getnucleus, getoffsets = direct.getoffsets, getoptions = direct.getoptions, + getanchors = direct.getanchors, + getgeometry = direct.getgeometry, getorientation = direct.getorientation, getpenalty = direct.getpenalty, getpost = direct.getpost, @@ -141,6 +143,7 @@ local nuts = { hasattribute = direct.hasattribute, hasdimensions = direct.hasdimensions, hasfield = direct.hasfield, + hasgeometry = direct.hasgeometry, hasglyph = direct.hasglyph, hasglyphoption = direct.hasglyphoption, hpack = direct.hpack, @@ -215,6 +218,8 @@ local nuts = { setnucleus = direct.setnucleus, setoffsets = direct.setoffsets, setoptions = direct.setoptions, + setanchors = direct.setanchors, + setgeometry = direct.setgeometry, setorientation = direct.setorientation, setpenalty = direct.setpenalty, setpost = direct.setpost, diff --git a/tex/context/base/mkxl/node-shp.lmt b/tex/context/base/mkxl/node-shp.lmt index 6cae39517..7848c623e 100644 --- a/tex/context/base/mkxl/node-shp.lmt +++ b/tex/context/base/mkxl/node-shp.lmt @@ -38,6 +38,10 @@ function handlers.finalizebox(box) actions(getbox(box)) -- nut end +function handlers.finalizelist(list) + actions(list) -- nut +end + do local flattendiscretionaries = nuts.flattendiscretionaries diff --git a/tex/context/base/mkxl/pack-box.mkxl b/tex/context/base/mkxl/pack-box.mkxl index 43934f7f7..9ed90a885 100644 --- a/tex/context/base/mkxl/pack-box.mkxl +++ b/tex/context/base/mkxl/pack-box.mkxl @@ -1118,4 +1118,130 @@ [\c!width=\overlaywidth,\c!height=\overlayheight] {\overlayimage{#1}}} +%D Here is an end December 2021 experimental feature: anchored boxes. This will move to +%D pack-box.mkxl + +\installcorenamespace{boxanchor} +\installcorenamespace{boxanchorid} +\installcorenamespace{boxanchorbox} +\installcorenamespace{boxpreset} + +\installparameterhandler \??boxanchor {boxanchor} +\installsetuphandler \??boxanchor {boxanchor} + +\setupboxanchor + [\c!xoffset=\zeropoint, + \c!yoffset=\zeropoint] + +\newcount\c_boxes_n_of_anchors + +\permanent\protected\def\defineanchorbox[#1]% + {\ifcsname\??boxanchorid#1\endcsname + \box\lastnamedcs\emptybox + \else + \global\advance\c_boxes_n_of_anchors\plusone + \expandafter\integerdef\csname\??boxanchorid #1\endcsname\c_boxes_n_of_anchors + \expandafter\newbox \csname\??boxanchorbox#1\endcsname + \fi} + +\permanent\protected\def\defineanchorboxoverlay[#1]% + {\defineanchorbox[#1:\v!background]% + \defineanchorbox[#1:\v!foreground]% + \defineoverlay[#1:\v!background][\overlayanchorbox{#1:\v!background}]% + \defineoverlay[#1:\v!foreground][\overlayanchorbox{#1:\v!foreground}]} + +\permanent\def\namedboxanchor#1% + {\csname\??boxanchorid#1\endcsname} % no checking + +% \permanent\protected\def\overlayanchorbox#1% +% {\begingroup +% \scratchcounter\csname\??boxanchorbox#1\endcsname +% \ifvoid\scratchcounter\else +% \setbox\scratchbox\hpack \s!source \namedboxanchor{#1}\bgroup +% % \setbox\scratchbox\hpack\bgroup +% \box\scratchcounter +% \egroup +% % \boxsource\scratchbox\namedboxanchor{#1}% +% \wd\scratchbox\overlaywidth +% \ht\scratchbox\overlayheight +% \dp\scratchbox\overlaydepth +% \box\scratchbox +% \fi +% \endgroup} + +\permanent\protected\def\overlayanchorbox#1% + {\begingroup + \scratchcounter\csname\??boxanchorbox#1\endcsname + \ifvoid\scratchcounter\else + \boxsource\scratchcounter\namedboxanchor{#1}% + \wd\scratchcounter\d_overlay_width + \ht\scratchcounter\d_overlay_height + \dp\scratchcounter\d_overlay_depth + \box\scratchcounter + \fi + \endgroup} + +\permanent\tolerant\protected\def\setanchorbox[#1]#*[#2]% + {\begingroup + \dowithnextbox + {\def\currentanchorbox{#1}% + \setupboxanchor[#2]% + \scratchcounterone\csname\??boxanchorbox#1\endcsname\relax + \scratchxoffset\boxanchorparameter\c!xoffset\relax + \scratchyoffset\boxanchorparameter\c!yoffset\relax + \boxtarget\nextbox \namedboxanchor {#1}\relax + \boxanchors\nextbox + % target + \ifcsname\??boxpreset\boxanchorparameter\c!target\endcsname + \lastnamedcs + \else + \halfwaytotallistanchorcode + \fi + % source + \ifcsname\??boxpreset\boxanchorparameter\c!source\endcsname + \lastnamedcs + \else + \halfwaytotallistanchorcode + \fi + \ifdim\scratchxoffset=\zeropoint\else + \boxxoffset\nextbox\scratchxoffset + \fi + \ifdim\scratchyoffset=\zeropoint\else + \boxyoffset\nextbox\scratchyoffset + \fi + \global\setbox\scratchcounterone\hpack\bgroup + \unhbox\scratchcounterone + \hskip-\wd\nextbox + \box\nextbox + \egroup + \endgroup}} + +\expandafter\integerdef\csname\??boxpreset\v!left \endcsname\leftoriginlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!left,\v!height \endcsname\leftheightlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!left,\v!top \endcsname\leftheightlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!left,\v!depth \endcsname\leftdepthlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!left,\v!bottom \endcsname\leftdepthlistanchorcode +% +\expandafter\integerdef\csname\??boxpreset\v!right \endcsname\rightoriginlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!right,\v!height \endcsname\rightheightlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!right,\v!top \endcsname\rightheightlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!right,\v!depth \endcsname\rightdepthlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!right,\v!bottom \endcsname\rightdepthlistanchorcode + +% \centeroriginlistanchorcode +% \centerheightlistanchorcode +% \centerdepthlistanchorcode + +\expandafter\integerdef\csname\??boxpreset\v!middle \endcsname\halfwaytotallistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!middle,\v!height\endcsname\halfwayheightlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!middle,\v!top \endcsname\halfwayheightlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!middle,\v!depth \endcsname\halfwaydepthlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!middle,\v!bottom\endcsname\halfwaydepthlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!middle,\v!left \endcsname\halfwayleftlistanchorcode +\expandafter\integerdef\csname\??boxpreset\v!middle,\v!right \endcsname\halfwayrightlistanchorcode + +% \negatexlistsigncode +% \negateylistsigncode +% \negatelistsigncode + \protect \endinput diff --git a/tex/context/base/mkxl/page-sid.mkxl b/tex/context/base/mkxl/page-sid.mkxl index fb1022c2a..1ff587120 100644 --- a/tex/context/base/mkxl/page-sid.mkxl +++ b/tex/context/base/mkxl/page-sid.mkxl @@ -46,6 +46,7 @@ \newdimen \d_page_sides_rightoffset %newbox \b_page_sides_bottom +\newbox \b_page_sides_spill_over \newcount \c_page_sides_lines_done \newcount \c_page_sides_checks_done @@ -57,6 +58,7 @@ \newconditional \c_page_sides_short \newconditional \c_page_sides_flag \newconditional \c_page_sides_shape_down +\newconditional \c_page_sides_keep_together \newdimen \d_page_sides_shift \newdimen \d_page_sides_extrashift @@ -294,7 +296,7 @@ \box\floatbox % somehow we need this \scratchbox magic, but at least it's the same as the % tracer now - \setbox\scratchbox\emptybox + \setbox\scratchbox\emptyhbox \wd\scratchbox\hsize \ht\scratchbox\d_page_sides_bottomtotal \box\scratchbox @@ -387,7 +389,6 @@ \fi \global\d_page_sides_downshift\zeropoint} - %D We have a few virtual dimensions. I'm not sure what to do with \type %D {\pagedepth} and \type {\pageshrink} in the next two. If we ever need %D that it will become options. @@ -448,7 +449,10 @@ \penalty\zerocount % works too \else %\tracingpages\plusone \tracingonline\plustwo + \begingroup + \pageboundarypenalty\plustenthousand \pageboundary % becomes a penalty (after triggering the callback) (experimental!) + \endgroup %\tracingpages\zerocount \fi \page_otr_command_set_vsize} % new, no longer really needed @@ -895,6 +899,40 @@ \prevdepth\strutdp} %\ignoreparskip} +% \def\page_sides_handle_float#1% +% {\page_sides_initialize_checker +% \page_sides_check_horizontal_skips +% \page_sides_check_vertical_skips +% \page_sides_apply_horizontal_shift +% \page_sides_check_previous_float +% \page_sides_inject_before +% \page_sides_inject_dummy_lines +% \page_sides_relocate_float{#1}% +% \page_sides_apply_vertical_shift +% \page_sides_analyse_space +% \ifconditional\c_page_floats_room +% \global\setfalse\c_page_sides_delayed +% % we're ok +% \else +% \global\settrue\c_page_sides_delayed +% \global\c_page_sides_m_of_lines\c_page_sides_n_of_lines +% \ifcase\c_page_sides_page_method +% \page_otr_fill_and_eject_page +% \or +% \page_otr_force_new_page_one +% \else +% \page_otr_fill_and_eject_page +% \fi +% \global\c_page_sides_n_of_lines\c_page_sides_m_of_lines +% \page_sides_analyse_space +% %\page_sides_inject_before +% \page_sides_inject_dummy_lines +% \fi +% \page_sides_place_float +% \global\setfalse\c_page_sides_delayed +% \page_sides_check_floats_reset +% \page_sides_wrapup} + \def\page_sides_handle_float#1% {\page_sides_initialize_checker \page_sides_check_horizontal_skips @@ -910,16 +948,21 @@ \global\setfalse\c_page_sides_delayed % we're ok \else + \ifconditional\c_page_sides_keep_together + \clf_interceptsamepagecontent\b_page_sides_spill_over + \fi \global\settrue\c_page_sides_delayed \global\c_page_sides_m_of_lines\c_page_sides_n_of_lines \ifcase\c_page_sides_page_method - \page_otr_fill_and_eject_page + \page_otr_fill_and_eject_page \or - \page_otr_force_new_page_one + \page_otr_force_new_page_one \else - \page_otr_fill_and_eject_page + \page_otr_fill_and_eject_page + \fi + \ifvoid\b_page_sides_spill_over\else + \box\b_page_sides_spill_over \fi - \global\c_page_sides_n_of_lines\c_page_sides_m_of_lines \page_sides_analyse_space %\page_sides_inject_before \page_sides_inject_dummy_lines diff --git a/tex/context/base/mkxl/page-txt.mklx b/tex/context/base/mkxl/page-txt.mklx index 27cf50773..4d80cfa76 100644 --- a/tex/context/base/mkxl/page-txt.mklx +++ b/tex/context/base/mkxl/page-txt.mklx @@ -495,10 +495,10 @@ \ifempty\p_text \kern\leftedgewidth \else - \hbox to \leftedgewidth\bgroup - \hss - \page_layouts_process_element_indeed#style#color#width% - \egroup + \hbox to \leftedgewidth\bgroup + \hss + \page_layouts_process_element_indeed#style#color#width% + \egroup \fi} \def\page_layouts_left_edge_element#text#style#color#width% diff --git a/tex/context/base/mkxl/spac-ver.lmt b/tex/context/base/mkxl/spac-ver.lmt index 955d65f4f..9d58ff167 100644 --- a/tex/context/base/mkxl/spac-ver.lmt +++ b/tex/context/base/mkxl/spac-ver.lmt @@ -33,7 +33,6 @@ if not modules then modules = { } end modules ['spac-ver'] = { local next, type, tonumber = next, type, tonumber local gmatch, concat = string.gmatch, table.concat -local ceil, floor, abs = math.ceil, math.floor, math.abs local lpegmatch = lpeg.match local unpack = unpack or table.unpack local allocate = utilities.storage.allocate @@ -147,6 +146,7 @@ local getheight = nuts.getheight local setdepth = nuts.setdepth local getdepth = nuts.getdepth local setnext = nuts.setnext +local setprev = nuts.setprev local find_node_tail = nuts.tail local flushnode = nuts.flushnode @@ -197,6 +197,8 @@ local splittopskip_code = gluecodes.splittopskip local linelist_code = nodes.listcodes.line +local setvisual = function(...) setvisual = nuts.setvisual return setvisual(...) end + local properties = nodes.properties.data local vspacing = builders.vspacing or { } @@ -355,6 +357,9 @@ end local snap_hlist do + local floor = math.floor + local ceil = math.ceil + local function fixedprofile(current) local profiling = builders.profiling return profiling and profiling.fixedprofile(current) @@ -749,6 +754,8 @@ local method = 1 -- better tracing -- local method = 3 -- local method = 4 +-- todo: not true but only visual a_visual,tex.getattribute(a_visual) + if method == 1 then local registervalue = attributes.registervalue @@ -939,6 +946,7 @@ do local function inject() local n = new_glue(b_amount,b_stretch,b_shrink) setspecification(n,b_category,b_penalty,b_order or 1) + setvisual(k) write_node(n) end @@ -1064,6 +1072,7 @@ do local n = new_glue() -- setattrs(n,false,a_skipcategory,categories.penalty,a_skippenalty,penalty,a_skiporder,1) setspecification(n,categories.penalty,penalty,1) + setvisual(k) write_node(n) end @@ -1071,6 +1080,7 @@ do local n = new_glue(amount) -- setattrs(n,false,a_skipcategory,categories.largest,a_skippenalty,false,a_skiporder,1) setspecification(n,categories.largest,false,1) + setvisual(k) write_node(n) end @@ -1078,6 +1088,7 @@ do local n = new_glue() -- setattrs(n,false,a_skipcategory,categories.disable,a_skippenalty,false,a_skiporder,1) setspecification(n,categories.disable,false,1) + setvisual(k) write_node(n) end @@ -1239,16 +1250,22 @@ do end if width == 0 then -- do nothing - elseif where == "after" then - head, current = insertnodeafter(head,current,new_rule(w,h,d)) - head, current = insertnodeafter(head,current,new_kern(width)) - head, current = insertnodeafter(head,current,new_rule(w,h,d)) else - local c = current - head, current = insertnodebefore(head,current,new_rule(w,h,d)) - head, current = insertnodebefore(head,current,new_kern(width)) - head, current = insertnodebefore(head,current,new_rule(w,h,d)) - current = c + local b = new_rule(w,h,d) + local k = new_kern(width) + local a = new_rule(w,h,d) + setvisual(k) + if where == "after" then + head, current = insertnodeafter(head,current,b) + head, current = insertnodeafter(head,current,k) + head, current = insertnodeafter(head,current,a) + else + local c = current + head, current = insertnodebefore(head,current,b) + head, current = insertnodebefore(head,current,k) + head, current = insertnodebefore(head,current,a) + current = c + end end if trace then report_vspacing("inserting forced skip of %p",width) @@ -1428,9 +1445,11 @@ do texsetdimen("global","d_spac_overlay",-delta) -- for tracing -- we should adapt pagetotal ! (need a hook for that) .. now we have the wrong pagebreak local k = new_kern(-delta) + setvisual(k) head = insertnodebefore(head,n,k) if n_ht > p_ht then local k = new_kern(n_ht-p_ht) + setvisual(k) head = insertnodebefore(head,p,k) end if trace_vspacing then @@ -1577,6 +1596,7 @@ do local d = g - t if d < -e then local penalty = new_penalty(1000000) + setvisual(penalty) setlink(penalty,head) head = penalty report_snapper("force pagebreak due to extra space at bottom: %p",e) @@ -1605,6 +1625,7 @@ do local function flush(why) if penalty_data then local p = new_penalty(penalty_data) + setvisual(p) if trace then trace_done("flushed due to " .. why,p) end @@ -2100,6 +2121,7 @@ do if penalty_data then tail = find_node_tail(head) local p = new_penalty(penalty_data) + setvisual(p) if trace then trace_done("result",p) end @@ -2372,6 +2394,7 @@ do end local trace = false + local abs = math.abs -- local last = nil local vmode_code = tex.modelevels.vertical local temp_code = nodecodes.temp @@ -2503,14 +2526,13 @@ do local trace = false trackers.register("otr.forcestrutdepth", function(v) trace = v and function(n) - nuts.setvisual(nuts.tonut(n),nodes.visualizers.modes.depth) + setvisual(nuts.tonut(n),nodes.visualizers.modes.depth) end end) local treversenode = nuts.treversers.node - function vspacing.forcestrutdepth() - -- check if in mvl + local function flushcontributions() if texgetnest("ptr") == 0 then -- this flushes the contributions local prev = nil @@ -2526,6 +2548,17 @@ do prev = head end end + return true + else + return false + end + end + + vspacing.flushcontributions = flushcontributions + + function vspacing.forcestrutdepth() + -- check if in mvl + if flushcontributions() then -- now we consult the last line (if present) local head, tail = getspeciallist("pagehead") if tail then @@ -2569,6 +2602,57 @@ do end end + -- highly experimental, only for m4all now; todo: tracing + + local setbox = nuts.setbox + + function vspacing.interceptsamepagecontent(box) + if vspacing.flushcontributions() then + -- now we consult the last line (if present) + local head, tail = getspeciallist("pagehead") + if tail and getid(tail) == glue_code then + local prev = getprev(tail) + if prev and getid(prev) == penalty_code then + if getpenalty(prev) >= 10000 then + local state = nil + local first = nil + local last = tail + local c = getprev(prev) + while c do + if getid(c) == glue_code then + local p = getprev(c) + if p and getid(p) == penalty_code then + if getpenalty(p) < 10000 then + state = 1 + end + else + state = 2 + break + end + end + first = c + c = getprev(c) + end + if first and first ~= head then + setnext(getprev(first)) + setprev(first) + local vbox = vpack_node(first) + setvisual(vbox) + setbox(box,vbox) + report_vspacing("same page intercept, case %i") + end + end + end + end + end + end + + interfaces.implement { + name = "interceptsamepagecontent", + arguments = "integer", + actions = vspacing.interceptsamepagecontent, + } + -- interfaces.implement { -- name = "removelastline", -- actions = function() diff --git a/tex/context/base/mkxl/strc-flt.mklx b/tex/context/base/mkxl/strc-flt.mklx index 94d06fd92..862aa7ff9 100644 --- a/tex/context/base/mkxl/strc-flt.mklx +++ b/tex/context/base/mkxl/strc-flt.mklx @@ -977,6 +977,9 @@ \doifelseinset\v!force\floatlocation {\global\settrue\c_page_sides_shape_down} {\global\setfalse\c_page_sides_shape_down}% + \doifelseinset\v!keeptogether\floatlocation + {\global\settrue\c_page_sides_keep_together} + {\global\setfalse\c_page_sides_keep_together}% \doifelseinset\v!nonumber\floatlocation {\global\nofloatnumbertrue}% {\doifelse{\floatcaptionparameter\c!number}\v!yes diff --git a/tex/context/base/mkxl/strc-reg.lmt b/tex/context/base/mkxl/strc-reg.lmt index ccb43bc28..a45f23bf0 100644 --- a/tex/context/base/mkxl/strc-reg.lmt +++ b/tex/context/base/mkxl/strc-reg.lmt @@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['strc-reg'] = { local next, type, tonumber, rawget = next, type, tonumber, rawget local char, format, gmatch = string.char, string.format, string.gmatch local equal, concat, remove = table.are_equal, table.concat, table.remove -local lpegmatch, P, C, Ct = lpeg.match, lpeg.P, lpeg.C, lpeg.Ct +local lpegmatch, lpegpatterns, P, C, Ct, Cs = lpeg.match, lpeg.patterns, lpeg.P, lpeg.C, lpeg.Ct, lpeg.Cs local allocate = utilities.storage.allocate local trace_registers = false trackers.register("structures.registers", function(v) trace_registers = v end) @@ -442,13 +442,21 @@ implement { arguments = "2 strings", } - -local p_s = P("+") +local p_s = P("+") -- & obsolete in mkiv local p_e = P("&") * (1-P(";"))^0 * P(";") local p_r = C((p_e + (1-p_s))^0) +local p_t = Cs ( ( + lpegpatterns.nestedbraces +--+ lpegpatterns.nestedbrackets + + lpegpatterns.nestedparents + + P("$") * (1-P("$"))^1 * P("$") + + (1-p_s) + )^1) + local entrysplitter_xml = Ct(p_r * (p_s * p_r)^0) -- bah -local entrysplitter_tex = lpeg.tsplitat('+') -- & obsolete in mkiv +----- entrysplitter_tex = lpeg.tsplitat('+') +local entrysplitter_tex = Ct((p_t * p_s^-1)^0) local tagged = { } diff --git a/tex/context/base/mkxl/strc-ren.mkxl b/tex/context/base/mkxl/strc-ren.mkxl index f7a1ec686..012722f6e 100644 --- a/tex/context/base/mkxl/strc-ren.mkxl +++ b/tex/context/base/mkxl/strc-ren.mkxl @@ -395,6 +395,7 @@ \noindentation \else \ignoreparskip + \doindentation \fi} % nice testcase diff --git a/tex/context/base/mkxl/strc-sec.mkxl b/tex/context/base/mkxl/strc-sec.mkxl index ba250311e..0776249fa 100644 --- a/tex/context/base/mkxl/strc-sec.mkxl +++ b/tex/context/base/mkxl/strc-sec.mkxl @@ -1240,7 +1240,7 @@ \spac_vspacing_same_page\currentheadlevel\zerocount \fi \headparameter\c!before\relax - \indent + \indent % hm, not a clever one? \else \page_otr_command_flush_side_floats \ifconditional\c_strc_sectioning_auto_break @@ -1275,7 +1275,6 @@ \spac_vspacing_same_page\currentheadlevel\plustwo \fi} - % We do support negative numbers but it can have side effects that we won't catch: % % \chapter{some} \setupheadnumber[chapter][3] \chapter{more} diff --git a/tex/context/base/mkxl/supp-box.mkxl b/tex/context/base/mkxl/supp-box.mkxl index 8e5b38365..b980107e4 100644 --- a/tex/context/base/mkxl/supp-box.mkxl +++ b/tex/context/base/mkxl/supp-box.mkxl @@ -17,6 +17,11 @@ \registerctxluafile{supp-box}{autosuffix,optimize} +\permanent\integerdef\negatelistsigncode\numexpr + \negatexlistsigncode + +\negateylistsigncode +\relax + %D And some dimensions: \newdimen\givenwidth @@ -2893,6 +2898,15 @@ \untraced\permanent\protected\def\showboxhere{\showbox nolevels content online } +% % possible extra interface, currently disabled +% +% \permanent\tolerant\protected\def\registeranchorbox[#1]#*[#2]% +% {\dowithnextbox +% {\clf_registeranchorbox +% \namedboxanchor{#1}% +% \ifcstok{#2}\v!before\minusone\else\plusone\fi +% \box\nextbox}} + \protect \endinput % a bit of test code: diff --git a/tex/context/base/mkxl/toks-aux.lmt b/tex/context/base/mkxl/toks-aux.lmt index 1d48d8838..c7d2fb2fc 100644 --- a/tex/context/base/mkxl/toks-aux.lmt +++ b/tex/context/base/mkxl/toks-aux.lmt @@ -171,6 +171,8 @@ tex.normalizecodes = getthem(tex.getnormalizevalues, "normalizecode") tex.automigrationcodes = getthem(tex.getautomigrationvalues, "automigrationcode") -- only at lua end tex.parcontextcodes = getthem(tex.getparcontextvalues, "parcontextcode") tex.textcontrolcodes = getthem(tex.gettextcontrolvalues, "") -- only at lua end +tex.listanchorcodes = getthem(tex.getlistanchorvalues, "listanchorcode") +tex.listsigncodes = getthem(tex.getlistsignvalues, "listsigncode") function tex.stringtocodesbitmap(str,codes) local bitmap = 0 diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt index 7f9341722..e2c4133b4 100644 --- a/tex/context/base/mkxl/trac-vis.lmt +++ b/tex/context/base/mkxl/trac-vis.lmt @@ -292,7 +292,14 @@ local function setvisual(n,a,what,list) -- this will become more efficient when end function nuts.setvisual(n,mode) - setattr(n,a_visual,setvisual(mode,getattr(n,a_visual),true)) + if mode then + setattr(n,a_visual,setvisual(mode,getattr(n,a_visual),true)) + else + local a = texgetattribute(a_visual) + if a ~= unsetvalue then + setattr(n,a_visual,a) + end + end end function nuts.setvisuals(n,mode) -- currently the same @@ -792,7 +799,6 @@ local ruledbox do local getshift = nuts.getshift local getorientation = nuts.getorientation - local setorientation = nuts.setorientation setmetatableindex(o_cache,function(t,size) local rule = new_rule(2*size,size,size) @@ -808,7 +814,7 @@ local ruledbox do local wd, ht, dp = getwhd(current) local force_origin = wd == 0 or (dp + ht) == 0 local shift = getshift(current) -local orientation, xoffset, yoffset = getorientation(current) + local orientation, xoffset, yoffset = getorientation(current) local next = getnext(current) local prev = previous setboth(current) @@ -884,7 +890,6 @@ local orientation, xoffset, yoffset = getorientation(current) end info = new_hlist(info,wd,ht,dp,shift) end --- setorientation(info,orientation,xoffset,yoffset) if next then setlink(info,next) end diff --git a/tex/context/interface/mkii/keys-ro.xml b/tex/context/interface/mkii/keys-ro.xml index 3516282e1..824015281 100644 --- a/tex/context/interface/mkii/keys-ro.xml +++ b/tex/context/interface/mkii/keys-ro.xml @@ -303,6 +303,7 @@ + @@ -1235,7 +1236,7 @@ - + @@ -1286,6 +1287,7 @@ + diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index c42285235..f4d50e351 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 : 2021-12-25 00:55 +-- merge date : 2021-12-30 19:00 do -- begin closure to overcome local limits and interference -- cgit v1.2.3