diff options
Diffstat (limited to 'tex/context/base/mkxl')
102 files changed, 3264 insertions, 1473 deletions
diff --git a/tex/context/base/mkxl/anch-bck.mklx b/tex/context/base/mkxl/anch-bck.mklx index bf3885539..1d0009949 100644 --- a/tex/context/base/mkxl/anch-bck.mklx +++ b/tex/context/base/mkxl/anch-bck.mklx @@ -353,9 +353,6 @@ \definesystemattribute[textbackground][public] -% \def\page_prepare_backgrounds#1% -% {\clf_collectbackgrounds\realpageno#1\relax} - \def\anch_backgrounds_bpos {\ifconditional\c_anch_backgrounds_pos_no_shape \c_attr_textbackground\attributeunsetvalue diff --git a/tex/context/base/mkxl/anch-pgr.lmt b/tex/context/base/mkxl/anch-pgr.lmt index e561f8b79..8a329fd13 100644 --- a/tex/context/base/mkxl/anch-pgr.lmt +++ b/tex/context/base/mkxl/anch-pgr.lmt @@ -94,9 +94,9 @@ local getdepth = nuts.getdepth local nodecodes = nodes.nodecodes local par_code = nodecodes.par -local start_of_par = nuts.start_of_par -local insert_before = nuts.insert_before -local insert_after = nuts.insert_after +local startofpar = nuts.startofpar +local insertbefore = nuts.insertbefore +local insertafter = nuts.insertafter local processranges = nuts.processranges @@ -115,6 +115,7 @@ local enabled = false -- many pages but for an arbitrary background shape that is not so common. local function check(specification) + -- local a = specification.attribute local index = specification.index local depth = specification.depth @@ -181,12 +182,12 @@ local function flush(head,f,l,a,parent,depth) ln = new_hlist(setlink(new_rule(65536,65536*4,0),new_kern(-65536),ln)) rn = new_hlist(setlink(new_rule(65536,0,65536*4),new_kern(-65536),rn)) end - if getid(f) == par_code and start_of_par(f) then -- we need to clean this mess - insert_after(head,f,ln) + if getid(f) == par_code and startofpar(f) then -- we need to clean this mess + insertafter(head,f,ln) else - head, f = insert_before(head,f,ln) + head, f = insertbefore(head,f,ln) end - insert_after(head,l,rn) + insertafter(head,l,rn) end return head, true end @@ -221,24 +222,10 @@ local function registerbackground(name) end end --- local function collectbackgrounds(r,n) --- if enabled then --- local parent = getbox(n) --- local head = getlist(parent) --- realpage = r --- processranges(a_textbackground,flush,head) -- ,parent) --- end --- end --- --- interfaces.implement { --- name = "collectbackgrounds", --- actions = collectbackgrounds, --- arguments = { "integer", "integer" } --- } - nodes.handlers.textbackgrounds = function(head,where,parent) -- we have hlistdir and local dir -- todo enable action in register - index = index + 1 + index = index + 1 + realpage = texgetcount("realpageno") return processranges(a_textbackground,flush,head,parent) end diff --git a/tex/context/base/mkxl/back-exp.lmt b/tex/context/base/mkxl/back-exp.lmt index 1375d2655..f0d8e120e 100644 --- a/tex/context/base/mkxl/back-exp.lmt +++ b/tex/context/base/mkxl/back-exp.lmt @@ -1456,7 +1456,7 @@ local collectresults do -- too many locals otherwise local getkern = nuts.getkern local getwidth = nuts.getwidth - local start_of_par = nuts.start_of_par + local startofpar = nuts.startofpar local nexthlist = nuts.traversers.hlist local nextnode = nuts.traversers.node @@ -1826,7 +1826,7 @@ end last = nil currentparagraph = nil end - elseif not paragraph and id == par_code and start_of_par(n) then + elseif not paragraph and id == par_code and startofpar(n) then paragraph = getattr(n,a_taggedpar) elseif id == disc_code then -- very unlikely because we stripped them diff --git a/tex/context/base/mkxl/blob-ini.lmt b/tex/context/base/mkxl/blob-ini.lmt index 42a18fddd..a2244dcdd 100644 --- a/tex/context/base/mkxl/blob-ini.lmt +++ b/tex/context/base/mkxl/blob-ini.lmt @@ -25,28 +25,26 @@ if not modules then modules = { } end modules ['blob-ini'] = { local type, tostring = type, tostring local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns -local report_blobs = logs.reporter("blobs") +local report_blobs = logs.reporter("blobs") -local flush_node_list = node.flush_list -local hpack_node_list = node.hpack ------ vpack_node_list = node.vpack -local write_node = node.write +local flushnodelist = nodes.flushlist +local hpacknodelist = nodes.hpack -local typesetters = nodes.typesetters -local tonodes = typesetters.tonodes -local tohpack = typesetters.tohpack -local tovpack = typesetters.tovpack +local typesetters = nodes.typesetters +local tonodes = typesetters.tonodes +local tohpack = typesetters.tohpack +local tovpack = typesetters.tovpack -local implement = interfaces.implement +local context = context --- provide copies here (nicer for manuals) +local implement = interfaces.implement -blobs = blobs or { } -local blobs = blobs +blobs = blobs or { } +local blobs = blobs -blobs.tonodes = tonodes -blobs.tohpack = tohpack -blobs.tovpack = tovpack +blobs.tonodes = tonodes +blobs.tohpack = tohpack +blobs.tovpack = tovpack -- end of helpers @@ -68,7 +66,7 @@ function blobs.dispose(t) local li = list[i] local pack = li.pack if pack then - flush_node_list(pack) + flushnodelist(pack) li.pack = nil end end @@ -96,14 +94,14 @@ function blobs.pack(t,how) for i=1,#list do local pack = list[i].pack if pack then - flush_node_list(node.pack) + flushnodelist(pack) end if how == "vertical" then -- we need to prepend a local par node -- list[i].pack = vpack_node_list(list[i].head,"exactly") report_blobs("vpack not yet supported") else - list[i].pack = hpack_node_list(list[i].head,"exactly") + list[i].pack = hpacknodelist(list[i].head,"exactly") end end end @@ -114,8 +112,8 @@ function blobs.write(t) local li = list[i] local pack = li.pack if pack then - write_node(pack) - flush_node_list(pack) + context(pack) + flushnodelist(pack) li.pack = nil end end @@ -158,28 +156,28 @@ end local function strwd(str) local l = tohpack(str) local w = l.width - flush_node_list(l) + flushnodelist(l) return w end local function strht(str) local l = tohpack(str) local h = l.height - flush_node_list(l) + flushnodelist(l) return h end local function strdp(str) local l = tohpack(str) local d = l.depth - flush_node_list(l) + flushnodelist(l) return d end local function strhd(str) local l = tohpack(str) local s = l.height + l.depth - flush_node_list(l) + flushnodelist(l) return s end @@ -196,7 +194,7 @@ local scan_hbox = tokens.scanners.hbox local function action(field,what) local l = scan_hbox() local d = l[field] - flush_node_list(l) + flushnodelist(l) if what == "value" then return dimension_code, d else diff --git a/tex/context/base/mkxl/buff-ini.lmt b/tex/context/base/mkxl/buff-ini.lmt index 41e8a5078..107ff3fdd 100644 --- a/tex/context/base/mkxl/buff-ini.lmt +++ b/tex/context/base/mkxl/buff-ini.lmt @@ -38,14 +38,12 @@ local scaninteger = scanners.integer local scanboolean = scanners.boolean local scancode = scanners.code local scantokencode = scanners.tokencode ------ scantoken = scanners.token local getters = tokens.getters local gettoken = getters.token -local getcommand = token.get_command ------ getcsname = token.get_csname -local getnextchar = token.scan_next_char or token.get_next_char +local getcommand = tokens.accessors.command +local getnextchar = tokens.scanners.nextchar local variables = interfaces.variables local settings_to_array = utilities.parsers.settings_to_array diff --git a/tex/context/base/mkxl/cldf-lmt.lmt b/tex/context/base/mkxl/cldf-lmt.lmt index 1c1b6a353..0c9da145f 100644 --- a/tex/context/base/mkxl/cldf-lmt.lmt +++ b/tex/context/base/mkxl/cldf-lmt.lmt @@ -41,7 +41,7 @@ local scankeyword = scanners.keyword local peekchar = scanners.peekchar local skipnext = scanners.skip -local getindex = token.get_index +local getindex = tokens.accessors.index local texsetdimen = tex.setdimen local texsetcount = tex.setcount @@ -957,8 +957,8 @@ do local global_code = tex.flagcodes.global - local savelua = token.save_lua - local isdefined = token.is_defined + local savelua = token.savelua + local isdefined = token.isdefined local newsparse = sparse.new local setsparse = sparse.set diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index bcd32fcda..fd33d7db1 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.05.09 17:12} +\newcontextversion{2021.05.15 22:41} %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 47f4f3e1a..0f19da913 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.05.09 17:12} +\immutable\edef\contextversion{2021.05.15 22:41} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/core-env.lmt b/tex/context/base/mkxl/core-env.lmt index 388e96787..486beeec4 100644 --- a/tex/context/base/mkxl/core-env.lmt +++ b/tex/context/base/mkxl/core-env.lmt @@ -19,7 +19,7 @@ local context = context local ctxcore = context.core local texgetcount = tex.getcount -local texgetintegervalue = token.get_integer -- todo: in tex namespace +local texgetintegervalue = token.getinteger -- todo local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex diff --git a/tex/context/base/mkxl/driv-shp.lmt b/tex/context/base/mkxl/driv-shp.lmt index 0fe0e5f9f..3b865492f 100644 --- a/tex/context/base/mkxl/driv-shp.lmt +++ b/tex/context/base/mkxl/driv-shp.lmt @@ -55,9 +55,9 @@ local isglyph = nuts.isglyph local nextdir = nuts.traversers.dir local nextnode = nuts.traversers.node ------ rangedimensions = node.direct.rangedimensions -- nuts ? -local effectiveglue = nuts.effective_glue -local start_of_par = nuts.start_of_par +----- rangedimensions = nuts.rangedimensions +local effectiveglue = nuts.effectiveglue +----- startofpar = nuts.startofpar local dirdimensions = nuts.dirdimensions local texget = tex.get @@ -212,6 +212,8 @@ local flush_character do end end + local refactored = 1000000 + for i=1,#vfcommands do local packet = vfcommands[i] local command = packet[1] @@ -269,7 +271,7 @@ local flush_character do local h = packet[2] -- already scaled if h ~= 0 then if factor ~= 0 then - h = h + h * factor / 1000 -- expansion + h = h + h * factor / refactored -- expansion end pos_h = pos_h + h * sx end @@ -277,7 +279,7 @@ local flush_character do local h = packet[2] -- already scaled if h ~= 0 then if factor ~= 0 then - h = h + h * factor / 1000 -- expansion + h = h + h * factor / refactored -- expansion end pos_h = pos_h - h * sx end @@ -299,7 +301,7 @@ local flush_character do local c = packet[4] if h ~= 0 then if factor ~= 0 then - h = h + h * factor / 1000 -- expansion + h = h + h * factor / refactored -- expansion end pos_h = pos_h + h * sx end @@ -319,7 +321,7 @@ local flush_character do local c = packet[4] if h ~= 0 then if factor ~= 0 then - h = h + h * factor / 1000 -- expansion + h = h + h * factor / refactored -- expansion end pos_h = pos_h + h * sx end @@ -370,7 +372,7 @@ local flush_character do local total = height + depth if width > 0 and total > 0 then if factor ~= 0 then - width = width + width * factor / 1000 + width = width + width * factor / refactored end if width > 0 then local line = packet[5] or default @@ -404,7 +406,7 @@ local flush_character do local size_h = packet[3] if size_h > 0 and size_v > 0 then if factor ~= 0 then - size_h = size_h + size_h * factor / 1000 + size_h = size_h + size_h * factor / refactored end if size_h > 0 then size_h = size_h * sx @@ -419,7 +421,7 @@ local flush_character do local dp = packet[4] or 0 if wd > 0 and ht ~= 0 and dp ~= 0 then if factor ~= 0 then - wd = wd + wd * factor / 1000 + wd = wd + wd * factor / refactored end if wd > 0 then wd = wd * sx @@ -599,10 +601,10 @@ 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) & x0F - local ay = (orientation>> 4) & x0F - local ax = (orientation>> 8) & x0F - local of = (orientation>>12) & x0F + local ot = (orientation>> 0) & 0x0F + local ay = (orientation>> 4) & 0x0F + local ax = (orientation>> 8) & 0x0F + local of = (orientation>>12) & 0x0F if ot == 4 then ot, ay = 0, 1 elseif ot == 5 then @@ -975,7 +977,7 @@ local hlist_out, vlist_out do setlink(current,replace) setreplace(current) end - -- elseif id == par_code and start_of_par(current) then + -- elseif id == par_code and startofpar(current) then -- local pardir = getdirection(current) or lefttoright_code -- if pardir == righttoleft_code then -- end @@ -1375,7 +1377,7 @@ do ----- tonut = nodes.tonut local properties = nodes.properties.data local flush = texio.write - local flushline = texio.write_nl + local flushline = texio.writenl local periods = utilities.strings.newrepeater(".") @@ -1431,4 +1433,10 @@ do end end) + local names = attributes.names + + callback.register("get_attribute",function(k,v) + return attributes.names[k], nil -- we show the name and number + end) + end diff --git a/tex/context/base/mkxl/font-chk.lmt b/tex/context/base/mkxl/font-chk.lmt index fa1167b1c..eb1be3f1b 100644 --- a/tex/context/base/mkxl/font-chk.lmt +++ b/tex/context/base/mkxl/font-chk.lmt @@ -64,7 +64,7 @@ local implement = interfaces.implement local glyph_code = nodes.nodecodes.glyph -local hpack_node = node.hpack +local hpack_node = nodes.hpack local nuts = nodes.nuts local tonut = nuts.tonut @@ -75,8 +75,8 @@ local setchar = nuts.setchar local nextglyph = nuts.traversers.glyph local remove_node = nuts.remove -local insert_node_after = nuts.insert_after -local insert_node_before = nuts.insert_before +local insertnodeafter = nuts.insertafter +local insertnodebefore = nuts.insertbefore local copy_node = nuts.copy local actions = false @@ -208,7 +208,7 @@ function checkers.missing(head) onetimemessage(font,char,"missing (decomposed)") setchar(n,s[l]) for i=l-1,2,-1 do - head, o = insert_node_before(head,o,copy_node(n)) + head, o = insertnodebefore(head,o,copy_node(n)) setchar(o,s[i]) end goto DONE diff --git a/tex/context/base/mkxl/font-col.lmt b/tex/context/base/mkxl/font-col.lmt index d60efb216..12603a0dd 100644 --- a/tex/context/base/mkxl/font-col.lmt +++ b/tex/context/base/mkxl/font-col.lmt @@ -22,7 +22,6 @@ local nuts = nodes.nuts local setfont = nuts.setfont ------ traverse_char = nuts.traverse_char local nextchar = nuts.traversers.char local getscales = nuts.getscales local setscales = nuts.setscales diff --git a/tex/context/base/mkxl/font-ota.lmt b/tex/context/base/mkxl/font-ota.lmt index 6475c57e6..157270ef1 100644 --- a/tex/context/base/mkxl/font-ota.lmt +++ b/tex/context/base/mkxl/font-ota.lmt @@ -42,7 +42,7 @@ local ischar = nuts.ischar local isnextchar = nuts.isnextchar ----- isprevchar = nuts.isprevchar -local end_of_math = nuts.end_of_math +local endofmath = nuts.endofmath local nodecodes = nodes.nodecodes local disc_code = nodecodes.disc @@ -216,8 +216,8 @@ function analyzers.setstate(head,font) -- latin end first = false if id == math_code then - -- current = end_of_math(current) - nxt = getnext(end_of_math(current)) + -- current = endofmath(current) + nxt = getnext(endofmath(current)) end elseif id == disc_code then -- always in the middle .. it doesn't make much sense to assign a property @@ -231,7 +231,7 @@ function analyzers.setstate(head,font) -- latin end first = false if id == math_code then - current = end_of_math(current) + current = endofmath(current) end end ::NEXT:: @@ -430,8 +430,8 @@ function methods.arab(head,font,attr) first = nil end if id == math_code then -- a bit duplicate as we test for glyphs twice - -- current = end_of_math(current) - nxt = getnext(end_of_math(current)) + -- current = endofmath(current) + nxt = getnext(endofmath(current)) end end -- current = getnext(current) @@ -560,8 +560,8 @@ do wrapup() end if id == math_code then -- a bit duplicate as we test for glyphs twice - -- current = end_of_math(current) - nxt = getnext(end_of_math(current)) + -- current = endofmath(current) + nxt = getnext(endofmath(current)) end end -- current = getnext(current) diff --git a/tex/context/base/mkxl/font-otj.lmt b/tex/context/base/mkxl/font-otj.lmt index adbce23e1..800628934 100644 --- a/tex/context/base/mkxl/font-otj.lmt +++ b/tex/context/base/mkxl/font-otj.lmt @@ -116,8 +116,8 @@ local setattrlist = nuts.setattrlist local nextchar = nuts.traversers.char local nextglue = nuts.traversers.glue -local insert_node_before = nuts.insert_before -local insert_node_after = nuts.insert_after +local insertnodebefore = nuts.insertbefore +local insertnodeafter = nuts.insertafter local properties = nodes.properties.data @@ -665,12 +665,12 @@ end -- addmargins(current,-leftkern) -- elseif prev and getid(prev) == glue_code then -- if useitalickerns then --- head = insert_node_before(head,current,italickern(leftkern)) +-- head = insertnodebefore(head,current,italickern(leftkern)) -- else -- setwidth(prev, getwidth(prev) + leftkern) -- end -- else --- head = insert_node_before(head,current,fontkern(leftkern)) +-- head = insertnodebefore(head,current,fontkern(leftkern)) -- end -- end -- end @@ -748,7 +748,7 @@ end -- if useadvance then -- addmargins(n,-leftkern) -- else --- pre = insert_node_before(pre,n,fontkern(leftkern)) +-- pre = insertnodebefore(pre,n,fontkern(leftkern)) -- done = true -- end -- end @@ -769,7 +769,7 @@ end -- if useadvance then -- addmargins(n,-leftkern) -- else --- post = insert_node_before(post,n,fontkern(leftkern)) +-- post = insertnodebefore(post,n,fontkern(leftkern)) -- done = true -- end -- end @@ -790,7 +790,7 @@ end -- if useadvance then -- addmargins(n,-leftkern) -- else --- replace = insert_node_before(replace,n,fontkern(leftkern)) +-- replace = insertnodebefore(replace,n,fontkern(leftkern)) -- done = true -- end -- end @@ -848,12 +848,12 @@ local function inject_kerns_only_kerns(head,where) leftkern = xscaled(current,leftkern) if prev and getid(prev) == glue_code then if useitalickerns then - head = insert_node_before(head,current,italickern(leftkern)) + head = insertnodebefore(head,current,italickern(leftkern)) else setwidth(prev,getwidth(prev) + leftkern) end else - head = insert_node_before(head,current,somekern(fontkern,leftkern,current)) + head = insertnodebefore(head,current,somekern(fontkern,leftkern,current)) end end end @@ -912,7 +912,7 @@ local function inject_kerns_only_kerns(head,where) if i then local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - pre = insert_node_before(pre,n,somekern(fontkern,xscaled(n,leftkern),n)) + pre = insertnodebefore(pre,n,somekern(fontkern,xscaled(n,leftkern),n)) done = true end end @@ -928,7 +928,7 @@ local function inject_kerns_only_kerns(head,where) if i then local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - post = insert_node_before(post,n,somekern(fontkern,xscaled(n,leftkern),n)) + post = insertnodebefore(post,n,somekern(fontkern,xscaled(n,leftkern),n)) done = true end end @@ -944,7 +944,7 @@ local function inject_kerns_only_kerns(head,where) if i then local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - replace = insert_node_before(replace,n,somekern(fontkern,xscaled(n,leftkern),n)) + replace = insertnodebefore(replace,n,somekern(fontkern,xscaled(n,leftkern),n)) done = true end end @@ -1141,23 +1141,23 @@ end -- rightkern = 0 -- elseif prev and getid(prev) == glue_code then -- if useitalickerns then --- head = insert_node_before(head,current,italickern(leftkern)) +-- head = insertnodebefore(head,current,italickern(leftkern)) -- else -- setwidth(prev,getwidth(prev)+leftkern) -- end -- else --- head = insert_node_before(head,current,fontkern(leftkern)) +-- head = insertnodebefore(head,current,fontkern(leftkern)) -- end -- end -- if rightkern ~= 0 then -- if next and getid(next) == glue_code then -- if useitalickerns then --- insert_node_after(head,current,italickern(rightkern)) +-- insertnodeafter(head,current,italickern(rightkern)) -- else -- setwidth(next, getwidth(next)+rightkern) -- end -- else --- insert_node_after(head,current,fontkern(rightkern)) +-- insertnodeafter(head,current,fontkern(rightkern)) -- end -- end -- end @@ -1260,11 +1260,11 @@ end -- end -- else -- if leftkern ~= 0 then --- pre = insert_node_before(pre,n,fontkern(leftkern)) +-- pre = insertnodebefore(pre,n,fontkern(leftkern)) -- done = true -- end -- if rightkern ~= 0 then --- insert_node_after(pre,n,fontkern(rightkern)) +-- insertnodeafter(pre,n,fontkern(rightkern)) -- done = true -- end -- end @@ -1298,11 +1298,11 @@ end -- end -- else -- if leftkern ~= 0 then --- post = insert_node_before(post,n,fontkern(leftkern)) +-- post = insertnodebefore(post,n,fontkern(leftkern)) -- done = true -- end -- if rightkern ~= 0 then --- insert_node_after(post,n,fontkern(rightkern)) +-- insertnodeafter(post,n,fontkern(rightkern)) -- done = true -- end -- end @@ -1336,11 +1336,11 @@ end -- end -- else -- if leftkern ~= 0 then --- replace = insert_node_before(replace,n,fontkern(leftkern)) +-- replace = insertnodebefore(replace,n,fontkern(leftkern)) -- done = true -- end -- if rightkern ~= 0 then --- insert_node_after(replace,n,fontkern(rightkern)) +-- insertnodeafter(replace,n,fontkern(rightkern)) -- done = true -- end -- end @@ -1361,7 +1361,7 @@ end -- if useadvance then -- addmargins(pre,-rightkern) -- else --- pre = insert_node_before(pre,pre,fontkern(rightkern)) +-- pre = insertnodebefore(pre,pre,fontkern(rightkern)) -- done = true -- end -- end @@ -1380,7 +1380,7 @@ end -- if useadvance then -- addmargins(replace,-rightkern) -- else --- replace = insert_node_before(replace,replace,fontkern(rightkern)) +-- replace = insertnodebefore(replace,replace,fontkern(rightkern)) -- done = true -- end -- end @@ -1454,23 +1454,23 @@ local function inject_positions_only_kerns(head,where) rightkern = 0 elseif prev and getid(prev) == glue_code then if useitalickerns then - head = insert_node_before(head,current,italickern(leftkern)) + head = insertnodebefore(head,current,italickern(leftkern)) else setwidth(prev,getwidth(prev)+leftkern) end else - head = insert_node_before(head,current,somekern(fontkern,leftkern,current)) + head = insertnodebefore(head,current,somekern(fontkern,leftkern,current)) end end if rightkern ~= 0 then if next and getid(next) == glue_code then if useitalickerns then - insert_node_after(head,current,italickern(rightkern)) + insertnodeafter(head,current,italickern(rightkern)) else setwidth(next, getwidth(next)+rightkern) end else - insert_node_after(head,current,somekern(fontkern,rightkern,current)) + insertnodeafter(head,current,somekern(fontkern,rightkern,current)) end end else @@ -1549,11 +1549,11 @@ local function inject_positions_only_kerns(head,where) addyoffset(n,yscaled(n,yoffset)) end if leftkern and leftkern ~= 0 then - pre = insert_node_before(pre,n,somekern(fontkern,xscaled(n,leftkern),n)) + pre = insertnodebefore(pre,n,somekern(fontkern,xscaled(n,leftkern),n)) done = true end if rightkern and rightkern ~= 0 then - insert_node_after(pre,n,somekern(fontkern,xscaled(n,rightkern),n)) + insertnodeafter(pre,n,somekern(fontkern,xscaled(n,rightkern),n)) done = true end end @@ -1574,11 +1574,11 @@ local function inject_positions_only_kerns(head,where) addyoffset(n,yscaled(n,yoffset)) end if leftkern and leftkern ~= 0 then - post = insert_node_before(post,n,somekern(fontkern,xscaled(n,leftkern),n)) + post = insertnodebefore(post,n,somekern(fontkern,xscaled(n,leftkern),n)) done = true end if rightkern and rightkern ~= 0 then - insert_node_after(post,n,somekern(fontkern,xscaled(n,rightkern),n)) + insertnodeafter(post,n,somekern(fontkern,xscaled(n,rightkern),n)) done = true end end @@ -1599,11 +1599,11 @@ local function inject_positions_only_kerns(head,where) addyoffset(n,yscaled(n,yoffset)) end if leftkern and leftkern ~= 0 then - replace = insert_node_before(replace,n,somekern(fontkern,xscaled(n,leftkern),n)) + replace = insertnodebefore(replace,n,somekern(fontkern,xscaled(n,leftkern),n)) done = true end if rightkern and rightkern ~= 0 then - insert_node_after(replace,n,somekern(fontkern,xscaled(n,rightkern),n)) + insertnodeafter(replace,n,somekern(fontkern,xscaled(n,rightkern),n)) done = true end end @@ -1620,7 +1620,7 @@ local function inject_positions_only_kerns(head,where) -- glyph|pre glyphs local rightkern = i.rightkern if rightkern and rightkern ~= 0 then - pre = insert_node_before(pre,pre,somekern(fontkern,xscaled(prevglyph,rightkern),prevglyph)) + pre = insertnodebefore(pre,pre,somekern(fontkern,xscaled(prevglyph,rightkern),prevglyph)) done = true end end @@ -1634,7 +1634,7 @@ local function inject_positions_only_kerns(head,where) -- glyph|replace glyphs local rightkern = i.rightkern if rightkern and rightkern ~= 0 then - replace = insert_node_before(replace,replace,somekern(fontkern,xscaled(prevglyph,rightkern),prevglyph)) + replace = insertnodebefore(replace,replace,somekern(fontkern,xscaled(prevglyph,rightkern),prevglyph)) done = true end end @@ -1923,8 +1923,8 @@ local function processmark(p,n,pn) -- p = basenode -- -- todo: head and check for prev / next kern -- - insert_node_before(n,n,somekern(fontkern,-wn,n)) - insert_node_after(n,n,somekern(fontkern,-wn,n)) + insertnodebefore(n,n,somekern(fontkern,-wn,n)) + insertnodeafter(n,n,somekern(fontkern,-wn,n)) end end end @@ -2046,24 +2046,24 @@ local function inject_everything(head,where) rightkern = 0 elseif prev and getid(prev) == glue_code then if useitalickerns then - head = insert_node_before(head,current,italickern(leftkern)) + head = insertnodebefore(head,current,italickern(leftkern)) else setwidth(prev, getwidth(prev) + leftkern) end else - head = insert_node_before(head,current,somekern(fontkern,leftkern,current)) + head = insertnodebefore(head,current,somekern(fontkern,leftkern,current)) end end if rightkern and rightkern ~= 0 then rightkern = xscaled(current,rightkern) if next and getid(next) == glue_code then if useitalickerns then - insert_node_after(head,current,italickern(rightkern)) + insertnodeafter(head,current,italickern(rightkern)) else setwidth(next, getwidth(next) + rightkern) end else - insert_node_after(head,current,somekern(fontkern,rightkern,current)) + insertnodeafter(head,current,somekern(fontkern,rightkern,current)) end end end @@ -2157,12 +2157,12 @@ local function inject_everything(head,where) end local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - pre = insert_node_before(pre,n,somekern(fontkern,xscaled(n,leftkern),n)) + pre = insertnodebefore(pre,n,somekern(fontkern,xscaled(n,leftkern),n)) done = true end local rightkern = i.rightkern if rightkern and rightkern ~= 0 then - insert_node_after(pre,n,somekern(fontkern,xscaled(n,rightkern),n)) + insertnodeafter(pre,n,somekern(fontkern,xscaled(n,rightkern),n)) done = true end if hasmarks then @@ -2188,13 +2188,13 @@ local function inject_everything(head,where) end local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - post = insert_node_before(post,n,somekern(fontkern,xscaled(n,leftkern),n)) + post = insertnodebefore(post,n,somekern(fontkern,xscaled(n,leftkern),n)) done = true end local rightkern = i.rightkern if rightkern and rightkern ~= 0 then done = true - insert_node_after(post,n,somekern(fontkern,xscaled(n,rightkern),n)) + insertnodeafter(post,n,somekern(fontkern,xscaled(n,rightkern),n)) end if hasmarks then local pm = i.markbasenode @@ -2219,12 +2219,12 @@ local function inject_everything(head,where) end local leftkern = i.leftkern if leftkern and leftkern ~= 0 then - replace = insert_node_before(replace,n,somekern(fontkern,xscaled(n,leftkern),n)) + replace = insertnodebefore(replace,n,somekern(fontkern,xscaled(n,leftkern),n)) done = true end local rightkern = i.rightkern if rightkern and rightkern ~= 0 then - insert_node_after(replace,n,somekern(fontkern,xscaled(n,rightkern),n)) + insertnodeafter(replace,n,somekern(fontkern,xscaled(n,rightkern),n)) done = true end if hasmarks then @@ -2246,7 +2246,7 @@ local function inject_everything(head,where) -- glyph|pre glyphs local rightkern = i.rightkern if rightkern and rightkern ~= 0 then - pre = insert_node_before(pre,pre,somekern(fontkern,xscaled(prevglyph,rightkern),prevglyph)) + pre = insertnodebefore(pre,pre,somekern(fontkern,xscaled(prevglyph,rightkern),prevglyph)) done = true end end @@ -2260,7 +2260,7 @@ local function inject_everything(head,where) -- glyph|replace glyphs local rightkern = i.rightkern if rightkern and rightkern ~= 0 then - replace = insert_node_before(replace,replace,somekern(fontkern,xscaled(prevglyph,rightkern),prevglyph)) + replace = insertnodebefore(replace,replace,somekern(fontkern,xscaled(prevglyph,rightkern),prevglyph)) done = true end end @@ -2446,8 +2446,8 @@ local function injectspaces(head) end lnew = lnew * xscale rnew = rnew * xscale - head = insert_node_before(head,n,italickern(lnew)) - insert_node_after(head,n,italickern(rnew)) + head = insertnodebefore(head,n,italickern(lnew)) + insertnodeafter(head,n,italickern(rnew)) else local new = old + (leftkern + rightkern) * factor if trace_spaces then @@ -2463,7 +2463,7 @@ local function injectspaces(head) report_spaces("%C [%p + %p]",prevchar,old,new) end new = new * xscale - insert_node_after(head,n,italickern(new)) -- tricky with traverse but ok + insertnodeafter(head,n,italickern(new)) -- tricky with traverse but ok else local new = old + leftkern * factor * xscale if trace_spaces then @@ -2482,7 +2482,7 @@ local function injectspaces(head) if trace_spaces then report_spaces("[%p + %p] %C",old,new,nextchar) end - insert_node_after(head,n,italickern(new)) + insertnodeafter(head,n,italickern(new)) else new = old + new if trace_spaces then diff --git a/tex/context/base/mkxl/font-ots.lmt b/tex/context/base/mkxl/font-ots.lmt index 84ca14488..def09684a 100644 --- a/tex/context/base/mkxl/font-ots.lmt +++ b/tex/context/base/mkxl/font-ots.lmt @@ -213,29 +213,31 @@ local getscales = nuts.getscales -- their positions because some complex ligatures might need that. For the moment we -- use an x_ prefix because for now generic follows the other approach. -local copy_no_components = nuts.copy_no_components -local copy_only_glyphs = nuts.copy_only_glyphs -local count_components = nuts.count_components -local set_components = nuts.set_components -local get_components = nuts.get_components -local flush_components = nuts.flush_components +local components = nuts.components +local copynocomponents = components.copynocomponents +local copyonlyglyphs = components.copyonlyglyphs +local countcomponents = components.count +local setcomponents = components.set +local getcomponents = components.get +local flushcomponents = components.flush --------------------------------------------------------------------------------------- local ischar = nuts.ischar local isnextchar = nuts.isnextchar -- only makes sense when we know we need next local isprevchar = nuts.isprevchar -- only makes sense when we know we need prev -local usesfont = nuts.uses_font - -local insert_node_after = nuts.insert_after -local copy_node = nuts.copy -local copy_node_list = nuts.copy_list -local remove_node = nuts.remove -local find_node_tail = nuts.tail -local flush_node_list = nuts.flush_list -local flush_node = nuts.flush_node -local end_of_math = nuts.end_of_math -local start_of_par = nuts.start_of_par +local usesfont = nuts.usesfont + +local insertnodeafter = nuts.insertafter +local copynode = nuts.copy +local copynodelist = nuts.copylist +local removenode = nuts.remove +local findnodetail = nuts.tail +local flushnodelist = nuts.flushlist +local flushnode = nuts.flushnode +local endofmath = nuts.endofmath + +local startofpar = nuts.startofpar local setmetatable = setmetatable local setmetatableindex = table.setmetatableindex @@ -320,13 +322,6 @@ local checkstep = (tracers and tracers.steppers.check) or function() local registerstep = (tracers and tracers.steppers.register) or function() end local registermessage = (tracers and tracers.steppers.message) or function() end --- local function checkdisccontent(d) --- local pre, post, replace = getdisc(d) --- if pre then for n in traverse_id(glue_code,pre) do report("pre: %s",nodes.idstostring(pre)) break end end --- if post then for n in traverse_id(glue_code,post) do report("pos: %s",nodes.idstostring(post)) break end end --- if replace then for n in traverse_id(glue_code,replace) do report("rep: %s",nodes.idstostring(replace)) break end end --- end - local function logprocess(...) if trace_steps then registermessage(...) @@ -426,12 +421,12 @@ local function flattendisk(head,disc) local prev, next = getboth(disc) local ishead = head == disc setdisc(disc) - flush_node(disc) + flushnode(disc) if pre then - flush_node_list(pre) + flushnodelist(pre) end if post then - flush_node_list(post) + flushnodelist(post) end if ishead then if replace then @@ -461,7 +456,7 @@ end local function appenddisc(disc,list) local pre, post, replace, pretail, posttail, replacetail = getdisc(disc,true) local posthead = list - local replacehead = copy_node_list(list) + local replacehead = copynodelist(list) if post then setlink(posttail,posthead) else @@ -483,16 +478,16 @@ local function markstoligature(head,start,stop,char) local next = getnext(stop) setprev(start) setnext(stop) - local base = copy_no_components(start,copyinjection) + local base = copynocomponents(start,copyinjection) if head == start then head = base end resetinjection(base) setchar(base,char) setsubtype(base,ligatureglyph_code) - set_components(base,start) + setcomponents(base,start) setlink(prev,base,next) - flush_components(start) + flushcomponents(start) return head, base end end @@ -514,7 +509,7 @@ local no_right_ligature_code = glyphoptioncodes.norightligature local no_left_kern_code = glyphoptioncodes.noleftkern local no_right_kern_code = glyphoptioncodes.norightkern -local has_glyph_option = nuts.has_glyph_option +local hasglyphoption = nuts.hasglyphoption -- in lmtx we need to check the components and can be slightly more clever @@ -522,18 +517,18 @@ local function inhibited(start,stop) for n in nextnode, start do -- we asume glyph nodes if n == start then - if has_glyph_option(n,no_right_ligature_code) then + if hasglyphoption(n,no_right_ligature_code) then return true end elseif n == stop then - if has_glyph_option(n,no_left_ligature_code) then + if hasglyphoption(n,no_left_ligature_code) then return true else return false end - elseif has_glyph_option(n,no_left_ligature_code) then + elseif hasglyphoption(n,no_left_ligature_code) then return true - elseif has_glyph_option(n,no_right_ligature_code) then + elseif hasglyphoption(n,no_right_ligature_code) then return true end end @@ -554,7 +549,7 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou local comp = start setprev(start) setnext(stop) - local base = copy_no_components(start,copyinjection) + local base = copynocomponents(start,copyinjection) if start == head then head = base end @@ -562,7 +557,7 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou setchar(base,char) setoptions(base,getoptions(start) | getoptions(stop)) -- maybe only lig options setsubtype(base,ligatureglyph_code) - set_components(base,comp) + setcomponents(base,comp) setlink(prev,base,next) if not discfound then local deletemarks = not skiphash or hasmarks @@ -576,7 +571,7 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou local char = getchar(start) if not marks[char] then baseindex = baseindex + componentindex - componentindex = count_components(start,marks) + componentindex = countcomponents(start,marks) -- we can be more clever here: "not deletemarks or (skiphash and not skiphash[char])" -- and such: elseif not deletemarks then @@ -585,9 +580,9 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou if trace_marks then logwarning("%s: keep ligature mark %s, gets index %s",pref(dataset,sequence),gref(char),getligaindex(start)) end - local n = copy_node(start) + local n = copynode(start) copyinjection(n,start) -- is this ok ? we position later anyway - head, current = insert_node_after(head,current,n) -- unlikely that mark has components + head, current = insertnodeafter(head,current,n) -- unlikely that mark has components elseif trace_marks then logwarning("%s: delete ligature mark %s",pref(dataset,sequence),gref(char)) end @@ -612,7 +607,7 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou break end end - flush_components(components) + flushcomponents(components) else -- discfound ... forget about marks .. probably no scripts that hyphenate and have marks local discprev, discnext = getboth(discfound) @@ -624,8 +619,8 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou if not replace then -- looks like we never come here as it's not okay local prev = getprev(base) - -- local comp = get_components(base) -- already set - local copied = copy_only_glyphs(comp) + -- local comp = getcomponents(base) -- already set + local copied = copyonlyglyphs(comp) if pre then setlink(discprev,pre) else @@ -642,7 +637,7 @@ local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfou setlink(prev,discfound,next) setboth(base) -- here components have a pointer so we can't free it! - set_components(base,copied) + setcomponents(base,copied) replace = base if forcediscretionaries then setdisc(discfound,pre,post,replace,discretionarydisc_code) @@ -669,10 +664,10 @@ local function multiple_glyphs(head,start,multiple,skiphash,what,stop) -- what t -- while ignoremarks and marks[getchar(sn)] then -- local sn = getnext(sn) -- end - local n = copy_node(start) -- ignore components + local n = copynode(start) -- ignore components resetinjection(n) setchar(n,multiple[k]) - insert_node_after(head,start,n) + insertnodeafter(head,start,n) start = n end if what == true then @@ -680,10 +675,10 @@ local function multiple_glyphs(head,start,multiple,skiphash,what,stop) -- what t elseif what > 1 then local m = multiple[nofmultiples] for i=2,what do - local n = copy_node(start) -- ignore components + local n = copynode(start) -- ignore components resetinjection(n) setchar(n,m) - insert_node_after(head,start,n) + insertnodeafter(head,start,n) start = n end end @@ -782,7 +777,7 @@ end -- Blocking is nasty: (ff\zwj l) vs (ff\zwj l) vs (ffl) vs (f\zwj fl} function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skiphash) - if start and has_glyph_option(start,no_right_ligature_code) then + if start and hasglyphoption(start,no_right_ligature_code) then return head, start, false, nil end local current = getnext(start) @@ -794,7 +789,7 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip if skiphash and skiphash[startchar] then while current do local nxt, char = isnextchar(current,currentfont,currentdynamic,currentscale,currentxscale,currentyscale) - if char and not has_glyph_option(current,no_left_ligature_code) then + if char and not hasglyphoption(current,no_left_ligature_code) then local lg = ligature[char] if lg then stop = current @@ -830,7 +825,7 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip if char then if skiphash and skiphash[char] then current = nxt - elseif has_glyph_option(current,no_left_ligature_code) then + elseif hasglyphoption(current,no_left_ligature_code) then break else local lg = ligature[char] @@ -868,13 +863,13 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip local match if replace then local nxt, char = isnextchar(replace,currentfont,currentdynamic,currentscale,currentxscale,currentyscale) - if char and ligature[char] and not has_glyph_option(replace,no_left_ligature_code) then + if char and ligature[char] and not hasglyphoption(replace,no_left_ligature_code) then match = true end end if not match and pre then local nxt, char = isnextchar(pre,currentfont,currentdynamic,currentscale,currentxscale,currentyscale) - if char and ligature[char] and not has_glyph_option(pre,no_left_ligature_code) then + if char and ligature[char] and not hasglyphoption(pre,no_left_ligature_code) then match = true end end @@ -882,7 +877,7 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip if not match and not pre or not replace then local ndf = getnext(discfound) local nxt, char = isnextchar(ndf,currentfont,currentdynamic,currentscale,currentxscale,currentyscale) - if char and ligature[char] and not has_glyph_option(ndf,no_left_ligature_code) then + if char and ligature[char] and not hasglyphoption(ndf,no_left_ligature_code) then match = true end end @@ -892,9 +887,9 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip local prev = getprev(start) if stop then setnext(stop) - local copy = copy_node_list(start) + local copy = copynodelist(start) local tail = stop -- was: getprev(stop) -- Kai: needs checking on your samples - local liat = find_node_tail(copy) + local liat = findnodetail(copy) if pre then setlink(liat,pre) end @@ -905,7 +900,7 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip replace = start else setnext(start) - local copy = copy_node(start) + local copy = copynode(start) if pre then setlink(copy,pre) end @@ -957,7 +952,7 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip end function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection) - if has_glyph_option(start,no_right_kern_code) then + if hasglyphoption(start,no_right_kern_code) then return head, start, false else local startchar = getchar(start) @@ -978,7 +973,7 @@ function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,skiphash, end function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection) - if has_glyph_option(start,no_right_kern_code) then + if hasglyphoption(start,no_right_kern_code) then return head, start, false else local snext = getnext(start) @@ -1357,7 +1352,7 @@ function chainprocs.gsub_remove(head,start,stop,dataset,sequence,currentlookup,r if trace_chains then logprocess("%s: removing character %s",cref(dataset,sequence,chainindex),gref(getchar(start))) end - head, start = remove_node(head,start,true) + head, start = removenode(head,start,true) return head, getprev(start), true end @@ -1486,7 +1481,7 @@ assume rather stupid ligatures (no complex disc nodes).</p> -- compare to handlers.gsub_ligature which is more complex ... why function chainprocs.gsub_ligature(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) - if start and has_glyph_option(start,no_right_ligature_code) then + if start and hasglyphoption(start,no_right_ligature_code) then return head, start, false, 0, false end local mapping = currentlookup.mapping @@ -1509,7 +1504,7 @@ function chainprocs.gsub_ligature(head,start,stop,dataset,sequence,currentlookup while current do local nxt, schar, id = isnextchar(current,currentfont,currentdynamic,currentscale,currentxscale,currentyscale) if schar then -if current and has_glyph_option(current,no_left_ligature_code) then +if current and hasglyphoption(current,no_left_ligature_code) then break end if skiphash and skiphash[schar] then -- marks @@ -1577,7 +1572,7 @@ end function chainprocs.gpos_single(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) -- we actually should check no_left_kern_code with next - if not has_glyph_option(start,no_right_kern_code) then + if not hasglyphoption(start,no_right_kern_code) then local mapping = currentlookup.mapping if mapping == nil then mapping = getmapping(dataset,sequence,currentlookup) @@ -1607,7 +1602,7 @@ end function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) -- todo: injections ? -- we actually should check no_left_kern_code with next - if not has_glyph_option(start,no_right_kern_code) then + if not hasglyphoption(start,no_right_kern_code) then local mapping = currentlookup.mapping if mapping == nil then mapping = getmapping(dataset,sequence,currentlookup) @@ -1959,7 +1954,7 @@ do if not userkern then -- generic local setkern = nuts.setkern -- not injections.setkern userkern = function(k) - local n = copy_node(thekern) + local n = copynode(thekern) setkern(n,k) return n end @@ -1976,13 +1971,13 @@ local function checked(head) if next then setlink(kern,next) end - flush_node(current) + flushnode(current) head = kern current = next else local prev, next = getboth(current) setlink(prev,kern,next) - flush_node(current) + flushnode(current) current = next end else @@ -2216,7 +2211,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck) tail = prev setprev(current,sweepnode) else - tail = find_node_tail(head) + tail = findnodetail(head) end setnext(sweepnode,current) setprev(head) @@ -2334,13 +2329,13 @@ local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck) head = lookaheaddisc end local pre, post, replace = getdisc(lookaheaddisc) - local new = copy_node_list(cf) -- br, how often does that happen + local new = copynodelist(cf) -- br, how often does that happen local cnew = new if pre then - setlink(find_node_tail(cf),pre) + setlink(findnodetail(cf),pre) end if replace then - local tail = find_node_tail(new) + local tail = findnodetail(new) setlink(tail,replace) end for i=1,insertedmarks do @@ -2396,8 +2391,8 @@ local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck) setprev(cf) setnext(cl) local pre, post, replace, pretail, posttail, replacetail = getdisc(backtrackdisc,true) - local new = copy_node_list(cf) - local cnew = find_node_tail(new) + local new = copynodelist(cf) + local cnew = findnodetail(new) for i=1,insertedmarks do cnew = getprev(cnew) end @@ -3297,7 +3292,7 @@ local function testrun(disc,t_run,c_run,...) next = getnext(tail) setnext(tail) setprev(head) - local new = copy_node_list(head) + local new = copynodelist(head) if posttail then setlink(posttail,head) else @@ -3794,7 +3789,7 @@ do local initialrl = 0 - if getid(head) == par_code and start_of_par(head) then + if getid(head) == par_code and startofpar(head) then initialrl = pardirstate(head) elseif direction == righttoleft_code then initialrl = -1 @@ -3839,7 +3834,7 @@ do -- the before and after lists in the loader. But first I need to see a font that uses multiple -- matches. -- - local start = find_node_tail(head) + local start = findnodetail(head) local rlmode = 0 -- how important is this .. do we need to check for dir? local merged = steps.merged while start do @@ -3917,11 +3912,11 @@ do start = nxt end elseif id == math_code then - start = getnext(end_of_math(start)) + start = getnext(endofmath(start)) elseif id == dir_code then topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode) start = nxt - -- elseif id == par_code and start_of_par(start) then + -- elseif id == par_code and startofpar(start) then -- rlparmode, rlmode = pardirstate(start) -- start = nxt else @@ -3984,11 +3979,11 @@ do start = nxt end elseif id == math_code then - start = getnext(end_of_math(start)) + start = getnext(endofmath(start)) elseif id == dir_code then topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode) start = nxt - -- elseif id == par_code and start_of_par(start) then + -- elseif id == par_code and startofpar(start) then -- rlparmode, rlmode = pardirstate(start) -- start = nxt else @@ -4103,11 +4098,11 @@ do -- a different font|state or glue (happens often) start = nxt elseif id == math_code then - start = getnext(end_of_math(start)) + start = getnext(endofmath(start)) elseif id == dir_code then topstack, rlmode = txtdirstate(start,dirstack,topstack,rlparmode) start = nxt - -- elseif id == par_code and start_of_par(start) then + -- elseif id == par_code and startofpar(start) then -- rlparmode, rlmode = pardirstate(start) -- start = nxt else diff --git a/tex/context/base/mkxl/font-phb.lmt b/tex/context/base/mkxl/font-phb.lmt index 43edfd33f..67b068885 100644 --- a/tex/context/base/mkxl/font-phb.lmt +++ b/tex/context/base/mkxl/font-phb.lmt @@ -388,7 +388,7 @@ local function harfbuzz(head,font,dynamic,rlmode,start,stop,text,leading,trailin if trace_colors then resetcolor(g) end - setlink(current,g,getnext(current)) -- insert_before + setlink(current,g,getnext(current)) current = g copied = true else diff --git a/tex/context/base/mkxl/font-txt.lmt b/tex/context/base/mkxl/font-txt.lmt index bc2f15464..29d3ca240 100644 --- a/tex/context/base/mkxl/font-txt.lmt +++ b/tex/context/base/mkxl/font-txt.lmt @@ -103,15 +103,15 @@ local getwidth = nuts.getwidth local ischar = nuts.ischar local isnextchar = nuts.isnextchar local isglyph = nuts.isglyph -local traverse_id = nuts.traverse_id -local usesfont = nuts.uses_font +local usesfont = nuts.usesfont -local copy_node_list = nuts.copy_list +local copy_node_list = nuts.copylist local find_node_tail = nuts.tail -local flush_list = nuts.flush_list -local free_node = nuts.free -local end_of_math = nuts.end_of_math -local start_of_par = nuts.start_of_par +local flushlist = nuts.flushlist +local freenode = nuts.free +local endofmath = nuts.endofmath + +local startofpar = nuts.startofpar local nodecodes = nodes.nodecodes @@ -140,10 +140,10 @@ local function deletedisc(head) local pre, post, replace, pre_tail, post_tail, replace_tail = getdisc(current,true) setdisc(current) if pre then - flush_list(pre) + flushlist(pre) end if post then - flush_list(post) + flushlist(post) end local p, n = getboth(current) if replace then @@ -160,7 +160,7 @@ local function deletedisc(head) else setlink(p,n) end - free_node(current) + freenode(current) end current = next end @@ -264,7 +264,7 @@ do stopspacing = false end - if getid(head) == par_code and start_of_par(head) then + if getid(head) == par_code and startofpar(head) then rlmode = pardirstate(head) elseif rlmode == righttoleft_code then rlmode = -1 @@ -448,7 +448,7 @@ do else setnext(getprev(cpostnew)) end - flush_list(cpostnew) + flushlist(cpostnew) if creplacenew == current_replace then current_replace = nil else @@ -481,7 +481,7 @@ do setprev(current_pre) end setnext(cprenew) - flush_list(cpre) + flushlist(cpre) creplace = current_replace current_replace = getnext(creplacenew) if current_replace then @@ -502,12 +502,12 @@ do startspacing = false stopspacing = false if id == math_code then - current = getnext(end_of_math(current)) + current = getnext(endofmath(current)) elseif id == dir_code then startspacing = false topstack, rlmode = txtdirstate(current,dirstack,topstack,rlparmode) current = getnext(current) - -- elseif id == par_code and start_of_par(current) then + -- elseif id == par_code and startofpar(current) then -- startspacing = false -- rlparmode, rlmode = pardirstate(current) -- current = getnext(current) diff --git a/tex/context/base/mkxl/good-mth.lmt b/tex/context/base/mkxl/good-mth.lmt index 578ea8555..c78fdbf71 100644 --- a/tex/context/base/mkxl/good-mth.lmt +++ b/tex/context/base/mkxl/good-mth.lmt @@ -36,7 +36,7 @@ local new_glyph = nodepool.glyph local new_hlist = nodepool.hlist local new_vlist = nodepool.vlist -local insert_node_after = nuts.insert_after +local insertnodeafter = nuts.insertafter local helpers = fonts.helpers local upcommand = helpers.commands.up @@ -367,7 +367,7 @@ local function mathradicalaction(n,h,v,font,mchar,echar) local kern = new_kern(height-v) list = setlink(kern,list) local list = new_vlist(kern) - insert_node_after(n,n,list) + insertnodeafter(n,n,list) end local function mathhruleaction(n,h,v,font,bchar,mchar,echar) @@ -403,7 +403,7 @@ local function mathhruleaction(n,h,v,font,bchar,mchar,echar) local kern = new_kern(height-v) list = setlink(kern,list) local list = new_vlist(kern) - insert_node_after(n,n,list) + insertnodeafter(n,n,list) end local function initialize(tfmdata) diff --git a/tex/context/base/mkxl/grph-inc.lmt b/tex/context/base/mkxl/grph-inc.lmt index f644e9b5b..4ac980682 100644 --- a/tex/context/base/mkxl/grph-inc.lmt +++ b/tex/context/base/mkxl/grph-inc.lmt @@ -78,9 +78,10 @@ local resolveprefix = resolvers.resolve local texgetbox = tex.getbox local texsetbox = tex.setbox -local hpack = node.hpack +local hpack = nodes.hpack local new_latelua = nodes.pool.latelua +local new_hlist = nodes.pool.hlist local context = context @@ -1392,7 +1393,7 @@ end function figures.dummy(data) data = data or callstack[#callstack] or lastfiguredata local dr, du, nr = data.request, data.used, figures.boxnumber - local box = hpack(node.new("hlist")) -- we need to set the dir (luatex 0.60 buglet) + local box = hpack(new_hlist()) -- we need to set the dir (luatex 0.60 buglet) du.width = du.width or figures.defaultwidth du.height = du.height or figures.defaultheight du.depth = du.depth or figures.defaultdepth diff --git a/tex/context/base/mkxl/lang-dis.lmt b/tex/context/base/mkxl/lang-dis.lmt index 263225691..1236ba749 100644 --- a/tex/context/base/mkxl/lang-dis.lmt +++ b/tex/context/base/mkxl/lang-dis.lmt @@ -36,8 +36,7 @@ local isglyph = nuts.isglyph local copy_node = nuts.copy local remove_node = nuts.remove -local flush_list = nuts.flush_list -local flush_node = nuts.flush_node +----- flushnode = nuts.flushnode local nextdisc = nuts.traversers.disc @@ -124,12 +123,12 @@ end local wiped = 0 -local flatten_discretionaries = nuts.flatten_discretionaries -- todo in nodes +local flattendiscretionaries = nuts.flattendiscretionaries -- todo in nodes --- if flatten_discretionaries then +-- if flattendiscretionaries then function languages.flatten(head) - local h, n = flatten_discretionaries(head) + local h, n = flattendiscretionaries(head) wiped = wiped + n return h, n > 0 end @@ -152,7 +151,7 @@ local flatten_discretionaries = nuts.flatten_discretionaries -- todo in nodes -- head = h -- end -- wiped = wiped + 1 --- flush_node(delayed) +-- flushnode(delayed) -- return head -- end -- diff --git a/tex/context/base/mkxl/lang-hyp.lmt b/tex/context/base/mkxl/lang-hyp.lmt index d75af4f46..590528495 100644 --- a/tex/context/base/mkxl/lang-hyp.lmt +++ b/tex/context/base/mkxl/lang-hyp.lmt @@ -656,12 +656,12 @@ if context then local setprev = nuts.setprev local setnext = nuts.setnext - local insert_before = nuts.insert_before - local insert_after = nuts.insert_after + local insertbefore = nuts.insertbefore + local insertafter = nuts.insertafter local copy_node = nuts.copy - local copy_list = nuts.copy_list + local copylist = nuts.copylist local remove_node = nuts.remove - local end_of_math = nuts.end_of_math + local endofmath = nuts.endofmath local node_tail = nuts.tail local nexthlist = nuts.traversers.hlist @@ -1087,7 +1087,7 @@ featureset.hyphenonly = hyphenonly == v_yes nuts.setvisual(p,"penalty") end last = getprev(last) - first, last = insert_after(first,last,p) + first, last = insertafter(first,last,p) end local function synchronizefeatureset(a) @@ -1245,7 +1245,7 @@ featureset.hyphenonly = hyphenonly == v_yes local glyph = copy_node(stop) setchar(glyph,characters[replacement]) if head then - insert_after(current,current,glyph) + insertafter(current,current,glyph) else head = glyph end @@ -1256,7 +1256,7 @@ featureset.hyphenonly = hyphenonly == v_yes local glyph = copy_node(stop) setchar(glyph,characters[list[i]]) if head then - insert_after(current,current,glyph) + insertafter(current,current,glyph) else head = glyph end @@ -1265,7 +1265,7 @@ featureset.hyphenonly = hyphenonly == v_yes end if rightchar then local glyph = copy_node(stop) - insert_after(current,current,glyph) + insertafter(current,current,glyph) setchar(glyph,rightchar) end return head @@ -1291,7 +1291,7 @@ featureset.hyphenonly = hyphenonly == v_yes setattrlist(disc,attrnode) end -- could be a replace as well - insert_before(first,current,disc) + insertbefore(first,current,disc) elseif type(r) == "table" then local disc = new_disc() local pre = r[1] @@ -1325,7 +1325,7 @@ featureset.hyphenonly = hyphenonly == v_yes if attrnode then setattrlist(disc,attrnode) end - insert_before(first,current,disc) + insertbefore(first,current,disc) else setchar(current,characters[r]) if i < rsize then @@ -1347,7 +1347,7 @@ featureset.hyphenonly = hyphenonly == v_yes if first ~= current then local disc = new_disc() first, current, glyph = remove_node(first,current) - first, current = insert_before(first,current,disc) + first, current = insertbefore(first,current,disc) if trace_visualize then setcolor(glyph,"darkred") -- these get checked setcolor(disc,"darkgreen") -- in the colorizer @@ -1372,7 +1372,7 @@ featureset.hyphenonly = hyphenonly == v_yes local function injectseries(current,last,next,attrnode) local disc = new_disc() local start = current - first, current = insert_before(first,current,disc) + first, current = insertbefore(first,current,disc) setprev(start) setnext(last) if next then @@ -1380,7 +1380,7 @@ featureset.hyphenonly = hyphenonly == v_yes else setnext(current) end - local pre = copy_list(start) + local pre = copylist(start) local post = nil local replace = start setdisc(disc,pre,post,replace,automaticdisc_code,hyphenpenalty) -- ex ? @@ -1547,10 +1547,10 @@ featureset.hyphenonly = hyphenonly == v_yes skipping = true end -- elseif strict and strict[id] then - -- current = id == math_code and getnext(end_of_math(current)) or getnext(current) + -- current = id == math_code and getnext(endofmath(current)) or getnext(current) -- size = 0 else - current = id == math_code and getnext(end_of_math(current)) or getnext(current) + current = id == math_code and getnext(endofmath(current)) or getnext(current) end if size > 0 then if dictionary and size > charmin and leftmin + rightmin <= size then diff --git a/tex/context/base/mkxl/lang-ini.lmt b/tex/context/base/mkxl/lang-ini.lmt index c80c57a73..5bfc9e1bb 100644 --- a/tex/context/base/mkxl/lang-ini.lmt +++ b/tex/context/base/mkxl/lang-ini.lmt @@ -15,8 +15,6 @@ if not modules then modules = { } end modules ['lang-ini'] = { -- 2011 : nonbreakable hyphen -- 2013 : endash (compound hyphen) ---~ language:hyphenation(string) string = language:hyphenation() language:clear_hyphenation() - -- todo: no foo:bar but foo(bar,...) -- https://wortschatz.uni-leipzig.de/de/download/German : lots of lists @@ -363,8 +361,8 @@ local function loaddefinitions(tag,specification) if trace_patterns then report_initialization("clearing patterns for language %a",tag) end - instance:clear_patterns() - instance:clear_hyphenation() + instance:clearpatterns() + instance:clearhyphenation() ploaded = { } eloaded = { } elseif not dataused[definition] then @@ -405,12 +403,12 @@ local function loaddefinitions(tag,specification) end if #ploaded > 0 then -- why not always clear - instance:clear_patterns() + instance:clearpatterns() instance:patterns(unique(tag,requested,ploaded)) end if #eloaded > 0 then -- why not always clear - instance:clear_hyphenation() + instance:clearhyphenation() instance:hyphenation(concat(eloaded," ")) end if type(shared) == "string" then @@ -623,7 +621,7 @@ do local new_disc = nuts.pool.disc local new_glyph = nuts.pool.glyph local copy_node = nuts.copy - local flush_list = nuts.flush_list + local flushlist = nuts.flushlist local glyphoptioncodes = tex.glyphoptioncodes @@ -720,7 +718,7 @@ do local before = getprev(first) setnext(last) setlink(before,after) - flush_list(first) + flushlist(first) end else local i = 0 diff --git a/tex/context/base/mkxl/lpdf-emb.lmt b/tex/context/base/mkxl/lpdf-emb.lmt index 928aea7cf..bfbbf118d 100644 --- a/tex/context/base/mkxl/lpdf-emb.lmt +++ b/tex/context/base/mkxl/lpdf-emb.lmt @@ -1514,7 +1514,7 @@ do local f_image_w = formatters["%.6N 0 d0 %s"] local f_image_d = formatters["%.6N 0 d0 1 0 0 1 0 %.6N cm /%s Do"] local f_stream = formatters["%.6N 0 d0 %s"] - local f_stream_c = formatters["%.6N 0 0 0 0 0 d1 %s"] + local f_stream_c = formatters["%.6N 0 0 0 0 0 d1 %s"] -- last four bbox local f_stream_d = formatters["%.6N 0 d0 1 0 0 1 0 %.6N cm %s"] -- local f_stream_s = formatters["%.6N 0 0 %.6N 0 0 cm /%s Do"] @@ -1534,7 +1534,7 @@ do -- pk inclusion (not really tested but not really used either) function methods.pk(filename) - local pkfullname = resolvers.findpk(basedfontname,resolution) + local pkfullname = resolvers.findpk(filename,resolution) if not pkfullname or pkfullname == "" then return end @@ -1845,7 +1845,7 @@ do if not method then return end - local glyphs, scalefactor, glyphtopdf, reset, getresources = method(basedfontname,details) + local glyphs, scalefactor, glyphtopdf, reset, getresources = method(basefontname,details) if not glyphs then return end diff --git a/tex/context/base/mkxl/lpdf-fld.lmt b/tex/context/base/mkxl/lpdf-fld.lmt index eacbb085d..4c17a47fe 100644 --- a/tex/context/base/mkxl/lpdf-fld.lmt +++ b/tex/context/base/mkxl/lpdf-fld.lmt @@ -107,7 +107,7 @@ local pdfcolor = lpdf.color local pdfcolorvalues = lpdf.colorvalues local pdflayerreference = lpdf.layerreference -local hpack_node = node.hpack +local hpack_node = nodes.hpack local submitoutputformat = 0 -- 0=unknown 1=HTML 2=FDF 3=XML => not yet used, needs to be checked diff --git a/tex/context/base/mkxl/lpdf-img.lmt b/tex/context/base/mkxl/lpdf-img.lmt index e1b822210..6914b2b29 100644 --- a/tex/context/base/mkxl/lpdf-img.lmt +++ b/tex/context/base/mkxl/lpdf-img.lmt @@ -18,6 +18,15 @@ if not modules then modules = { } end modules ['lpdf-img'] = { -- wanted but best gain a little. The idea is that we collect striped (in stages) so -- that we can play with substitutions. We keep this variant commented but not -- embedding it saves some 14K bytecode in the format. +-- +-- We keep the \LUA\ code commented because it is what I started with from the \PNG\ +-- specification. It was one fo the first things needed for dropping the backend so +-- actually this was part of the first \LUA\ based \PDF\ backend, the one that for a +-- while was part of \MKIV. That bit of development was not widely advertized and +-- just for me to make the transition and prove that it could be done. At some point +-- I decided to not provide a generic backend so that cdoe went away. Reminder: +-- there ended up some code here that was needed for font related png too (and I'd +-- already forgotten about: I need to document that). local type = type local concat, move = table.concat, table.move @@ -198,6 +207,7 @@ do local pnginterlace = pngdecode.interlace local pngexpand = pngdecode.expand local pngtocmyk = pngdecode.tocmyk + local pngtomask = pngdecode.tomask local filtermask, decodemask, decodestrip, transpose, expand, tocmyk @@ -206,7 +216,7 @@ do local function newoutput(size) if newindex then - return newindex(size,0) + return newindex(size,char(0)) end local t = newtable and newtable(size,0) or { } for i=1,size do @@ -806,52 +816,65 @@ do -- end -- end + -- We had this for a while (the reference now): + -- + -- local function createmask_c(content,palette,transparent,xsize,ysize,colordepth,colorspace) + -- if palette then + -- local r = expandvector(transparent) + -- local size = xsize*ysize + -- local len = ceil(xsize*colordepth/8) + -- local o = newoutput(size) + -- content = zlibdecompress(content) + -- content = pngapplyfilter(content,len,ysize,1) -- nostrip (saves copy) + -- content = openstring(content) + -- for i=0,ysize-1 do + -- local t = readbytetable(content,len) + -- local k = i * xsize + -- if colordepth == 8 then + -- for j=1,len do + -- local v = t[j] + -- k = k + 1 ; o[k] = r[v] + -- end + -- elseif colordepth == 4 then + -- for j=1,len do + -- local v = t[j] + -- k = k + 1 ; o[k] = r[(v >> 4) & 0x0F] -- r[extract4(v,4)] + -- k = k + 1 ; o[k] = r[(v >> 0) & 0x0F] -- r[extract4(v,0)] + -- end + -- elseif colordepth == 2 then + -- for j=1,len do + -- local v = t[j] + -- k = k + 1 ; o[k] = r[(v >> 6) & 0x03] -- r[extract2(v,6)] + -- k = k + 1 ; o[k] = r[(v >> 4) & 0x03] -- r[extract2(v,4)] + -- k = k + 1 ; o[k] = r[(v >> 2) & 0x03] -- r[extract2(v,2)] + -- k = k + 1 ; o[k] = r[(v >> 0) & 0x03] -- r[extract2(v,0)] + -- end + -- else + -- for j=1,len do + -- local v = t[j] + -- k = k + 1 ; o[k] = r[(v >> 7) & 0x01] -- r[extract1(v,7)] + -- k = k + 1 ; o[k] = r[(v >> 6) & 0x01] -- r[extract1(v,6)] + -- k = k + 1 ; o[k] = r[(v >> 5) & 0x01] -- r[extract1(v,5)] + -- k = k + 1 ; o[k] = r[(v >> 4) & 0x01] -- r[extract1(v,4)] + -- k = k + 1 ; o[k] = r[(v >> 3) & 0x01] -- r[extract1(v,3)] + -- k = k + 1 ; o[k] = r[(v >> 2) & 0x01] -- r[extract1(v,2)] + -- k = k + 1 ; o[k] = r[(v >> 1) & 0x01] -- r[extract1(v,1)] + -- k = k + 1 ; o[k] = r[(v >> 0) & 0x01] -- r[extract1(v,0)] + -- end + -- end + -- end + -- return concat(o,"",1,size) + -- end + -- end + -- + -- But this is nicer for memory usage: + local function createmask_c(content,palette,transparent,xsize,ysize,colordepth,colorspace) if palette then - local r = expandvector(transparent) - local size = xsize*ysize - local len = ceil(xsize*colordepth/8) - local o = newoutput(size) - content = zlibdecompress(content) - content = pngapplyfilter(content,len,ysize,1) -- nostrip (saves copy) - content = openstring(content) - for i=0,ysize-1 do - local t = readbytetable(content,len) - local k = i * xsize - if colordepth == 8 then - for j=1,len do - local v = t[j] - k = k + 1 ; o[k] = r[v] - end - elseif colordepth == 4 then - for j=1,len do - local v = t[j] - k = k + 1 ; o[k] = r[(v >> 4) & 0x0F] -- r[extract4(v,4)] - k = k + 1 ; o[k] = r[(v >> 0) & 0x0F] -- r[extract4(v,0)] - end - elseif colordepth == 2 then - for j=1,len do - local v = t[j] - k = k + 1 ; o[k] = r[(v >> 6) & 0x03] -- r[extract2(v,6)] - k = k + 1 ; o[k] = r[(v >> 4) & 0x03] -- r[extract2(v,4)] - k = k + 1 ; o[k] = r[(v >> 2) & 0x03] -- r[extract2(v,2)] - k = k + 1 ; o[k] = r[(v >> 0) & 0x03] -- r[extract2(v,0)] - end - else - for j=1,len do - local v = t[j] - k = k + 1 ; o[k] = r[(v >> 7) & 0x01] -- r[extract1(v,7)] - k = k + 1 ; o[k] = r[(v >> 6) & 0x01] -- r[extract1(v,6)] - k = k + 1 ; o[k] = r[(v >> 5) & 0x01] -- r[extract1(v,5)] - k = k + 1 ; o[k] = r[(v >> 4) & 0x01] -- r[extract1(v,4)] - k = k + 1 ; o[k] = r[(v >> 3) & 0x01] -- r[extract1(v,3)] - k = k + 1 ; o[k] = r[(v >> 2) & 0x01] -- r[extract1(v,2)] - k = k + 1 ; o[k] = r[(v >> 1) & 0x01] -- r[extract1(v,1)] - k = k + 1 ; o[k] = r[(v >> 0) & 0x01] -- r[extract1(v,0)] - end - end - end - return concat(o,"",1,size) + local len = ceil(xsize*colordepth/8) + content = zlibdecompress(content) + content = pngapplyfilter(content,len,ysize,1) -- nostrip (saves copy) + return pngtomask(content,transparent,xsize,ysize,colordepth) end end diff --git a/tex/context/base/mkxl/lpdf-lmt.lmt b/tex/context/base/mkxl/lpdf-lmt.lmt index 6e6d7c4c9..036c64da9 100644 --- a/tex/context/base/mkxl/lpdf-lmt.lmt +++ b/tex/context/base/mkxl/lpdf-lmt.lmt @@ -602,12 +602,12 @@ do local move = calc_pdfpos(pos_h,pos_v) -if trace_threshold then + if trace_threshold then report( - "before: font %i, char %C, factor %i, naturalwidth %p, move %l, tm %l, hpos %p, delta %p, threshold %p, cw %p", - font,char,factor,naturalwidth[char],move,need_tm,pos_h,tj_delta,threshold,cw - ) -end + "before: font %i, char %C, factor %i, naturalwidth %p, move %l, tm %l, hpos %p, delta %p, threshold %p, cw %p", + font,char,factor,naturalwidth[char],move,need_tm,pos_h,tj_delta,threshold,cw + ) + end if move or need_tm then if not need_tm then @@ -647,12 +647,13 @@ end end end -if trace_threshold then + if trace_threshold then report( "after : font %i, char %C, factor %i, naturalwidth %p, move %l, tm %l, hpos %p, delta %p, threshold %p, cw %p", font,char,factor,naturalwidth[char],move,need_tm,pos_h,tj_delta,threshold,cw ) -end + end + if mode == "chararray" then begin_charmode() end @@ -971,7 +972,7 @@ local flushimage do local getprop = nuts.getprop local getwhd = nuts.getwhd - local flushlist = nuts.flush_list + local flushlist = nuts.flushlist local getdata = nuts.getdata local normalrule_code = rulecodes.normal diff --git a/tex/context/base/mkxl/lpdf-mov.lmt b/tex/context/base/mkxl/lpdf-mov.lmt index 42ba6fb00..a0f82b25b 100644 --- a/tex/context/base/mkxl/lpdf-mov.lmt +++ b/tex/context/base/mkxl/lpdf-mov.lmt @@ -16,7 +16,6 @@ local pdfconstant = lpdf.constant local pdfdictionary = lpdf.dictionary local pdfarray = lpdf.array local pdfborder = lpdf.border -local write_node = node.write function nodeinjections.insertmovie(specification) -- managed in figure inclusion: width, height, factor, repeat, controls, preview, label, foundname @@ -41,7 +40,7 @@ function nodeinjections.insertmovie(specification) Movie = moviedict, A = controldict, } - write_node(nodeinjections.annotation(width,height,0,action())) -- test: context(...) + context(nodeinjections.annotation(width,height,0,action())) -- test: context(...) end function nodeinjections.insertsound(specification) @@ -63,6 +62,6 @@ function nodeinjections.insertsound(specification) Movie = sounddict, A = controldict, } - write_node(nodeinjections.annotation(0,0,0,action())) -- test: context(...) + context(nodeinjections.annotation(0,0,0,action())) -- test: context(...) end end diff --git a/tex/context/base/mkxl/lpdf-wid.lmt b/tex/context/base/mkxl/lpdf-wid.lmt index 53ba32812..8c0aa74af 100644 --- a/tex/context/base/mkxl/lpdf-wid.lmt +++ b/tex/context/base/mkxl/lpdf-wid.lmt @@ -43,6 +43,8 @@ local context = context local texgetcount = tex.getcount +local hpacknode = nodes.hpack + local nodeinjections = backends.pdf.nodeinjections local codeinjections = backends.pdf.codeinjections local registrations = backends.pdf.registrations @@ -86,10 +88,6 @@ updaters.register("backend.update.lpdf",function() pdfshareobjectreference = lpdf.shareobjectreference end) - -local hpack_node = node.hpack -local write_node = node.write -- test context(...) instead - -- symbols local presets = { } -- xforms @@ -464,7 +462,7 @@ function nodeinjections.attachfile(specification) local width = specification.width or 0 local height = specification.height or 0 local depth = specification.depth or 0 - local box = hpack_node(nodeinjections.annotation(width,height,depth,d())) + local box = hpacknode(nodeinjections.annotation(width,height,depth,d())) box.width = width box.height = height box.depth = depth @@ -565,12 +563,12 @@ function nodeinjections.comment(specification) -- brrr: seems to be done twice Parent = pdfreference(nd), } d.Popup = pdfreference(nc) - box = hpack_node( + box = hpacknode( nodeinjections.annotation(0,0,0,d(),nd), nodeinjections.annotation(width,height,depth,c(),nc) ) else - box = hpack_node(nodeinjections.annotation(width,height,depth,d())) + box = hpacknode(nodeinjections.annotation(width,height,depth,d())) end box.width = width -- redundant box.height = height -- redundant @@ -663,7 +661,7 @@ local function insertrenderingwindow(specification) if height == 0 or width == 0 then -- todo: sound needs no window end - write_node(nodeinjections.annotation(width,height,0,d(),r)) -- save ref + context(nodeinjections.annotation(width,height,0,d(),r)) -- save ref return pdfreference(r) end diff --git a/tex/context/base/mkxl/luat-cod.lmt b/tex/context/base/mkxl/luat-cod.lmt index 9a74e4238..64c5e71f3 100644 --- a/tex/context/base/mkxl/luat-cod.lmt +++ b/tex/context/base/mkxl/luat-cod.lmt @@ -91,7 +91,7 @@ function lua.registercode(filename,options) lua.lastbytecode = n end elseif environment.initex then - texio.write_nl(format("\nerror loading file: %s (aborting)",filename)) + texio.writenl(format("\nerror loading file: %s (aborting)",filename)) os.exit() end end @@ -298,7 +298,7 @@ callback.register("trace_memory", function(what,success) logs.report("tex memory","bumping category %a %s, details: %s", what,success,table.sequenced(status["get"..what.."state"]())) elseif texio then - texio.write_nl(format("bumping tex '%s' memory %s", + texio.writenl(format("bumping tex '%s' memory %s", what,success)) end -- os.exit() diff --git a/tex/context/base/mkxl/luat-fio.lmt b/tex/context/base/mkxl/luat-fio.lmt index c70ed54e4..228b346bc 100644 --- a/tex/context/base/mkxl/luat-fio.lmt +++ b/tex/context/base/mkxl/luat-fio.lmt @@ -32,7 +32,7 @@ if not resolvers.initialized() then local ioflush = io.flush local ioread = io.read - local writenl = texio.write_nl + local writenl = texio.writenl local function terminal() writenl("\ntex console > ") diff --git a/tex/context/base/mkxl/luat-log.lmt b/tex/context/base/mkxl/luat-log.lmt index 522f4ac4f..fe55368f3 100644 --- a/tex/context/base/mkxl/luat-log.lmt +++ b/tex/context/base/mkxl/luat-log.lmt @@ -24,8 +24,8 @@ local utfchar = utf.char local datetime = os.date local openfile = io.open -local write_nl = texio.write_nl -local write = texio.write +local writenl = texio.writeselectornl +local write = texio.writeselector local setmetatableindex = table.setmetatableindex local formatters = string.formatters @@ -120,13 +120,20 @@ do status_nop = formatters["%-15s :\n"], }, targets = setmetatableindex( { - logfile = "logfile", - log = "logfile", - file = "logfile", - console = "terminal", - terminal = "terminal", - both = "terminal_and_logfile", - }, function(t,k) t[k] = "terminal_and_logfile" end), +-- logfile = "logfile", +-- log = "logfile", +-- file = "logfile", +-- console = "terminal", +-- terminal = "terminal", +-- both = "terminal_and_logfile", + logfile = 2, + log = 2, + file = 2, + console = 1, + terminal = 1, + both = 3, +-- }, function(t,k) local v = "terminal_and_logfile" t[k] = v return v end), + }, function(t,k) local v = 3 t[k] = v return v end), }, ansi = { formats = { @@ -145,10 +152,14 @@ do logfile = false, log = false, file = false, - console = "terminal", - terminal = "terminal", - both = "terminal", - }, function(t,k) t[k] = "terminal" end), +-- console = "terminal", +-- terminal = "terminal", +-- both = "terminal", + console = 1, + terminal = 1, + both = 1, +-- }, function(t,k) local v = "terminal" t[k] = v return v end), + }, function(t,k) local v = 1 t[k] = v return v end), } } @@ -161,13 +172,13 @@ do writer = function(...) if target then - write_nl(target,...) + writenl(target,...) end end newline = function() if target then - write_nl(target,"\n") + writenl(target) end end @@ -175,13 +186,13 @@ do if not target then -- ignore elseif c ~= nil then - write_nl(target,report_yes(translations[a],formatters[formats[b]](c,...))) + writenl(target,report_yes(translations[a],formatters[formats[b]](c,...))) elseif b then - write_nl(target,report_yes(translations[a],formats[b])) + writenl(target,report_yes(translations[a],formats[b])) elseif a then - write_nl(target,report_nop(translations[a])) + writenl(target,report_nop(translations[a])) else - write_nl(target,"\n") + writenl(target) end end @@ -203,13 +214,13 @@ do if not target then -- ignore elseif c ~= nil then - write_nl(target,subreport_yes(translations[a],translations[s],formatters[formats[b]](c,...))) + writenl(target,subreport_yes(translations[a],translations[s],formatters[formats[b]](c,...))) elseif b then - write_nl(target,subreport_yes(translations[a],translations[s],formats[b])) + writenl(target,subreport_yes(translations[a],translations[s],formats[b])) elseif a then - write_nl(target,subreport_nop(translations[a],translations[s])) + writenl(target,subreport_nop(translations[a],translations[s])) else - write_nl(target,"\n") + writenl(target) end end @@ -231,13 +242,13 @@ do if not target then -- ignore elseif c ~= nil then - write_nl(target,status_yes(translations[a],formatters[formats[b]](c,...))) + writenl(target,status_yes(translations[a],formatters[formats[b]](c,...))) elseif b then - write_nl(target,status_yes(translations[a],formats[b])) + writenl(target,status_yes(translations[a],formats[b])) elseif a then - write_nl(target,status_nop(translations[a])) + writenl(target,status_nop(translations[a])) else - write_nl(target,"\n") + writenl(target) end end @@ -277,8 +288,8 @@ do end setprocessor = function(f) - local writeline = write_nl - write_nl = function(target,...) + local writeline = writenl + writenl = function(target,...) if target then writeline(target,f(...)) end diff --git a/tex/context/base/mkxl/math-ini.mkxl b/tex/context/base/mkxl/math-ini.mkxl index 46d1871a2..33e52ebbf 100644 --- a/tex/context/base/mkxl/math-ini.mkxl +++ b/tex/context/base/mkxl/math-ini.mkxl @@ -102,12 +102,6 @@ \permanent\def\Umathtopaccent{\Umathaccent \s!top } \permanent\def\Umathaccents {\Umathaccent \s!both } % strange highlighting -\ifdefined\Umathcharclass \else - \permanent\def\Umathcharclass{\numexpr\cldcontext{tex.getmathcode(token.scan_int())[1]}\relax} - \permanent\def\Umathcharfam {\numexpr\cldcontext{tex.getmathcode(token.scan_int())[2]}\relax} - \permanent\def\Umathcharslot {\numexpr\cldcontext{tex.getmathcode(token.scan_int())[3]}\relax} -\fi - %D The attributes that we will use (todo: pack some into one but uglier code): \definesystemattribute[mathalphabet] [public] diff --git a/tex/context/base/mkxl/math-noa.lmt b/tex/context/base/mkxl/math-noa.lmt index fd30db573..0b9b132e1 100644 --- a/tex/context/base/mkxl/math-noa.lmt +++ b/tex/context/base/mkxl/math-noa.lmt @@ -135,12 +135,12 @@ local setsup = nuts.setsup local setsubpre = nuts.setsubpre local setsuppre = nuts.setsuppre -local flush_node = nuts.flush +local flushnode = nuts.flush local copy_node = nuts.copy local slide_nodes = nuts.slide local set_visual = nuts.setvisual -local mlist_to_hlist = nuts.mlist_to_hlist +local mlisttohlist = nuts.mlisttohlist local new_kern = nodepool.kern local new_submlist = nodepool.submlist @@ -897,7 +897,7 @@ do end setchar(d,chr) setfam(d,fam) - flush_node(sym) + flushnode(sym) end setattrlist(d,char) setattrlist(f,char) @@ -943,7 +943,7 @@ do if midl then local fence = makefence(middlefence_code,current) setnucleus(current) - flush_node(current) + flushnode(current) middle[current] = nil -- replace_node setlink(prev,fence,next) @@ -969,7 +969,7 @@ do local f_c = makefence(rightfence_code,close) makelist(middle,open,f_o,o_next,c_prev,f_c) setnucleus(close) - flush_node(close) + flushnode(close) -- open is now a list setlink(open,c_next) return open @@ -1894,7 +1894,7 @@ do end while c ~= l do local n = getnext(c) - flush_node(c) + flushnode(c) c = n end setlink(parent,l) @@ -2108,7 +2108,7 @@ do end setprev(next,pointer) setnext(parent,getnext(next)) - flush_node(next) + flushnode(next) end end end @@ -2361,12 +2361,12 @@ do -- force_penalties = v -- end) - function builders.kernel.mlist_to_hlist(head,style,penalties) - return mlist_to_hlist(head,style,force_penalties or penalties) + function builders.kernel.mlisttohlist(head,style,penalties) + return mlisttohlist(head,style,force_penalties or penalties) end - -- function builders.kernel.mlist_to_hlist(head,style,penalties) - -- local h = mlist_to_hlist(head,style,force_penalties or penalties) + -- function builders.kernel.mlisttohlist(head,style,penalties) + -- local h = mlisttohlist(head,style,force_penalties or penalties) -- inspect(nodes.totree(h,true,true,true)) -- return h -- end @@ -2385,14 +2385,14 @@ local actions = tasks.actions("math") -- head, style, penalties local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming -function processors.mlist_to_hlist(head,style,penalties) +function processors.mlisttohlist(head,style,penalties) starttiming(noads) head = actions(head,style,penalties) stoptiming(noads) return head end -callbacks.register('mlist_to_hlist',processors.mlist_to_hlist,"preprocessing math list") +callbacks.register('mlisttohlist',processors.mlisttohlist,"preprocessing math list") -- tracing diff --git a/tex/context/base/mkxl/math-tag.lmt b/tex/context/base/mkxl/math-tag.lmt index 0d02d271c..a602870c9 100644 --- a/tex/context/base/mkxl/math-tag.lmt +++ b/tex/context/base/mkxl/math-tag.lmt @@ -37,7 +37,7 @@ local getnucleus = nuts.getnucleus local getsub = nuts.getsub local getsup = nuts.getsup -local set_attributes = nuts.setattributes +local setattributes = nuts.setattributes local nextnode = nuts.traversers.node @@ -285,7 +285,7 @@ process = function(start) -- we cannot use the processor as we have no finalizer -- empty list elseif not attr then -- box comes from strange place - set_attributes(list,a_tagged,text) -- only the first node ? + setattributes(list,a_tagged,text) -- only the first node ? else -- Beware, the first node in list is the actual list so we definitely -- need to nest. This approach is a hack, maybe I'll make a proper diff --git a/tex/context/base/mkxl/mlib-lua.lmt b/tex/context/base/mkxl/mlib-lua.lmt index e5737be8c..479dbcae1 100644 --- a/tex/context/base/mkxl/mlib-lua.lmt +++ b/tex/context/base/mkxl/mlib-lua.lmt @@ -35,44 +35,44 @@ local stack = { } local function reports(s) report("%a scan %s", tostring(currentmpx),s) end -- temporary, till we're okay local function reporti(s) report("%a inject %s",tostring(currentmpx),s) end -- temporary, till we're okay -local scan_next = mplib.scan_next -local scan_expression = mplib.scan_expression -local scan_token = mplib.scan_token -local scan_symbol = mplib.scan_symbol -local scan_property = mplib.scan_property -local scan_numeric = mplib.scan_numeric -local scan_integer = mplib.scan_integer -local scan_boolean = mplib.scan_boolean -local scan_string = mplib.scan_string -local scan_pair = mplib.scan_pair -local scan_color = mplib.scan_color -local scan_cmykcolor = mplib.scan_cmykcolor -local scan_transform = mplib.scan_transform -local scan_path = mplib.scan_path -local scan_pen = mplib.scan_pen - -local skip_token = mplib.skip_token - -local get_hashentry = mplib.gethashentry - -scan.next = function(k) if trace then reporti("next") end return scan_next (currentmpx,k) end -scan.expression = function(k) if trace then reporti("expression") end return scan_expression(currentmpx,k) end -scan.token = function(k) if trace then reporti("token") end return scan_token (currentmpx,k) end -scan.symbol = function(k,e) if trace then reporti("symbol") end return scan_symbol (currentmpx,k,e) end -scan.property = function(k) if trace then reporti("property") end return scan_property (currentmpx,k) end -scan.numeric = function() if trace then reporti("numeric") end return scan_numeric (currentmpx) end -scan.integer = function() if trace then reporti("integer") end return scan_integer (currentmpx) end -scan.boolean = function() if trace then reporti("boolean") end return scan_boolean (currentmpx) end -scan.string = function() if trace then reporti("string") end return scan_string (currentmpx) end -scan.pair = function(t) if trace then reporti("pair") end return scan_pair (currentmpx,t) end -scan.color = function(t) if trace then reporti("color") end return scan_color (currentmpx,t) end -scan.cmykcolor = function(t) if trace then reporti("cmykcolor") end return scan_cmykcolor (currentmpx,t) end -scan.transform = function(t) if trace then reporti("transform") end return scan_transform (currentmpx,t) end -scan.path = function(t) if trace then reporti("path") end return scan_path (currentmpx,t) end -scan.pen = function(t) if trace then reporti("pen") end return scan_pen (currentmpx,t) end - -skip.token = function(t) return skip_token (currentmpx,t) end -get.hashentry = function(n) return get_hashentry(currentmpx,n) end +local scannext = mplib.scannext +local scanexpression = mplib.scanexpression +local scantoken = mplib.scantoken +local scansymbol = mplib.scansymbol +local scanproperty = mplib.scanproperty +local scannumeric = mplib.scannumeric +local scaninteger = mplib.scaninteger +local scanboolean = mplib.scanboolean +local scanstring = mplib.scanstring +local scanpair = mplib.scanpair +local scancolor = mplib.scancolor +local scancmykcolor = mplib.scancmykcolor +local scantransform = mplib.scantransform +local scanpath = mplib.scanpath +local scanpen = mplib.scanpen + +local skiptoken = mplib.skiptoken + +local gethashentry = mplib.gethashentry + +scan.next = function(k) if trace then reporti("next") end return scannext (currentmpx,k) end +scan.expression = function(k) if trace then reporti("expression") end return scanexpression(currentmpx,k) end +scan.token = function(k) if trace then reporti("token") end return scantoken (currentmpx,k) end +scan.symbol = function(k,e) if trace then reporti("symbol") end return scansymbol (currentmpx,k,e) end +scan.property = function(k) if trace then reporti("property") end return scanproperty (currentmpx,k) end +scan.numeric = function() if trace then reporti("numeric") end return scannumeric (currentmpx) end +scan.integer = function() if trace then reporti("integer") end return scaninteger (currentmpx) end +scan.boolean = function() if trace then reporti("boolean") end return scanboolean (currentmpx) end +scan.string = function() if trace then reporti("string") end return scanstring (currentmpx) end +scan.pair = function(t) if trace then reporti("pair") end return scanpair (currentmpx,t) end +scan.color = function(t) if trace then reporti("color") end return scancolor (currentmpx,t) end +scan.cmykcolor = function(t) if trace then reporti("cmykcolor") end return scancmykcolor (currentmpx,t) end +scan.transform = function(t) if trace then reporti("transform") end return scantransform (currentmpx,t) end +scan.path = function(t) if trace then reporti("path") end return scanpath (currentmpx,t) end +scan.pen = function(t) if trace then reporti("pen") end return scanpen (currentmpx,t) end + +skip.token = function(t) return skiptoken (currentmpx,t) end +get.hashentry = function(n) return gethashentry(currentmpx,n) end local solvepath = mplib.solvepath local getstatus = mplib.getstatus @@ -81,27 +81,27 @@ local expandtex = mplib.expandtex mp.solve = function(...) return solvepath(currentmpx,...) end mp.expandtex = function(...) expandtex(currentmpx,...) end -local inject_path = mplib.inject_path -local inject_numeric = mplib.inject_numeric -local inject_pair = mplib.inject_pair -local inject_boolean = mplib.inject_boolean -local inject_integer = mplib.inject_integer -local inject_string = mplib.inject_string -local inject_color = mplib.inject_color -local inject_cmykcolor = mplib.inject_cmykcolor -local inject_transform = mplib.inject_transform -local inject_whatever = mplib.inject_whatever - -------.path = function(t,cycle,curled) if trace then reporti("path") end return inject_path (currentmpx,t,cycle,curled) end -inject.numeric = function(n) if trace then reporti("numeric") end return inject_numeric (currentmpx,n) end -inject.pair = function(x,y) if trace then reporti("pair") end return inject_pair (currentmpx,x,y) end -inject.boolean = function(b) if trace then reporti("boolean") end return inject_boolean (currentmpx,b) end -inject.integer = function(i) if trace then reporti("integer") end return inject_integer (currentmpx,i) end -inject.string = function(s) if trace then reporti("string") end return inject_string (currentmpx,s) end -inject.color = function(r,g,b) if trace then reporti("color") end return inject_color (currentmpx,r,g,b) end -inject.cmykcolor = function(c,m,y,k) if trace then reporti("cmykcolor") end return inject_cmykcolor(currentmpx,c,m,y,k) end -inject.transform = function(x,y,xx,xy,yx,yy) if trace then reporti("transform") end return inject_transform(currentmpx,x,y,xx,xy,yx,yy) end -inject.whatever = function(...) if trace then reporti("whatever") end return inject_whatever (currentmpx,...) end +local injectpath = mplib.injectpath +local injectnumeric = mplib.injectnumeric +local injectpair = mplib.injectpair +local injectboolean = mplib.injectboolean +local injectinteger = mplib.injectinteger +local injectstring = mplib.injectstring +local injectcolor = mplib.injectcolor +local injectcmykcolor = mplib.injectcmykcolor +local injecttransform = mplib.injecttransform +local injectwhatever = mplib.injectwhatever + +------.path = function(t,cycle,curled) if trace then reporti("path") end return injectpath (currentmpx,t,cycle,curled) end +inject.numeric = function(n) if trace then reporti("numeric") end return injectnumeric (currentmpx,n) end +inject.pair = function(x,y) if trace then reporti("pair") end return injectpair (currentmpx,x,y) end +inject.boolean = function(b) if trace then reporti("boolean") end return injectboolean (currentmpx,b) end +inject.integer = function(i) if trace then reporti("integer") end return injectinteger (currentmpx,i) end +inject.string = function(s) if trace then reporti("string") end return injectstring (currentmpx,s) end +inject.color = function(r,g,b) if trace then reporti("color") end return injectcolor (currentmpx,r,g,b) end +inject.cmykcolor = function(c,m,y,k) if trace then reporti("cmykcolor") end return injectcmykcolor(currentmpx,c,m,y,k) end +inject.transform = function(x,y,xx,xy,yx,yy) if trace then reporti("transform") end return injecttransform(currentmpx,x,y,xx,xy,yx,yy) end +inject.whatever = function(...) if trace then reporti("whatever") end return injectwhatever (currentmpx,...) end inject.triplet = inject.color inject.quadruplet = inject.cmykcolor @@ -145,7 +145,7 @@ function inject.path(p,close,connector) end end if trace then reporti("path") end - return inject_path(currentmpx,p,close,curled) + return injectpath(currentmpx,p,close,curled) end -- bonus: @@ -154,7 +154,7 @@ scan .number = scan .numeric inject.number = inject.numeric table.setmetatablecall(inject,function(t,...) - inject_whatever(currentmpx,...) + injectwhatever(currentmpx,...) end) -- experiment @@ -164,20 +164,20 @@ function mp.autoinject(m) if t == "table" then local n = #t if n == 2 then - inject_pair(currentmpx,m) + injectpair(currentmpx,m) elseif n == 3 then - inject_color(currentmpx,m) + injectcolor(currentmpx,m) elseif n == 4 then - inject_cmykcolor(currentmpx,m) + injectcmykcolor(currentmpx,m) elseif n == 6 then - inject_transform(currentmpx,m) + injecttransform(currentmpx,m) end elseif t == "number" then - inject_numeric(currentmpx,m) + injectnumeric(currentmpx,m) elseif t == "string" then - inject_string(currentmpx,m) + injectstring(currentmpx,m) elseif t == "boolean" then - inject_boolean(currentmpx,m) + injectboolean(currentmpx,m) end end diff --git a/tex/context/base/mkxl/mlib-pdf.lmt b/tex/context/base/mkxl/mlib-pdf.lmt index 0373c22f8..ac84e4f3e 100644 --- a/tex/context/base/mkxl/mlib-pdf.lmt +++ b/tex/context/base/mkxl/mlib-pdf.lmt @@ -23,10 +23,7 @@ local context = context local allocate = utilities.storage.allocate -local copy_node = node.copy -local write_node = node.write - -local pen_info = mplib.pen_info +local peninfo = mplib.peninfo local getfields = mplib.getfields or mplib.fields -- todo: in lmtx get them once and then use gettype local save_table = false @@ -114,7 +111,7 @@ end local rx, sx, sy, ry, tx, ty, divider = 1, 0, 0, 1, 0, 0, 1 local function pen_characteristics(object) - local t = pen_info(object) + local t = peninfo(object) rx, ry, sx, sy, tx, ty = t.rx, t.ry, t.sx, t.sy, t.tx, t.ty divider = sx*sy - rx*ry return not (sx == 1 and rx == 0 and ry == 0 and sy == 1 and tx == 0 and ty == 0), t.width @@ -359,7 +356,7 @@ local function pushproperties(figure) width = figure:width(), height = figure:height(), depth = figure:depth(), - italic = figure:italcorr(), -- figure:italic() in lmtx + italic = figure:italic(), number = slot, } insert(stack,properties) diff --git a/tex/context/base/mkxl/mlib-pps.lmt b/tex/context/base/mkxl/mlib-pps.lmt index 0d6beee00..1ed98bdf3 100644 --- a/tex/context/base/mkxl/mlib-pps.lmt +++ b/tex/context/base/mkxl/mlib-pps.lmt @@ -36,8 +36,8 @@ local setmacro = interfaces.setmacro local texsetbox = tex.setbox local textakebox = tex.takebox -- or: nodes.takebox local texrunlocal = tex.runlocal -local copy_list = node.copy_list -local flush_list = node.flush_list +local copylist = nodes.copylist +local flushlist = nodes.flushlist local setmetatableindex = table.setmetatableindex local sortedhash = table.sortedhash @@ -283,7 +283,7 @@ local function stopjob() if top then for slot, content in next, top.textexts do if content then - flush_list(content) + flushlist(content) if trace_textexts then report_textexts("freeing text %s",slot) end @@ -1051,7 +1051,7 @@ local tx_reset, tx_process do local donebox = fasttrack and top.textexts[mp_index] if mp_hash == "no" then if donebox then - box = copy_list(donebox) + box = copylist(donebox) else texrunlocal("mptexttoks") box = textakebox("mptextbox") @@ -1085,10 +1085,10 @@ end end box = cache[mp_hash] if box then - box = copy_list(box) + box = copylist(box) else if donebox then - box = copy_list(donebox) + box = copylist(donebox) else texrunlocal("mptexttoks") box = textakebox("mptextbox") diff --git a/tex/context/base/mkxl/mlib-scn.lmt b/tex/context/base/mkxl/mlib-scn.lmt index 0a0e96105..217a57ae4 100644 --- a/tex/context/base/mkxl/mlib-scn.lmt +++ b/tex/context/base/mkxl/mlib-scn.lmt @@ -137,11 +137,6 @@ scanset = function() -- can be optimized, we now read twice end end -local function scan_pair () return scanpair (true) end -local function scan_color () return scancolor (true) end -local function scan_cmykcolor() return scancmykcolor(true) end -local function scan_transform() return scantransform(true) end - tokenscanners = { [leftbrace_code] = scanset, [numeric_code] = scannumeric, @@ -154,10 +149,10 @@ typescanners = { [types.numeric] = scannumeric, [types.string] = scanstring, [types.boolean] = scanboolean, - [types.pair] = scan_pair, - [types.color] = scan_color, - [types.cmykcolor] = scan_cmykcolor, - [types.transform] = scan_transform, + [types.pair] = function() return scanpair (true) end, + [types.color] = function() return scancolor (true) end, + [types.cmykcolor] = function() return scancmykcolor(true) end, + [types.transform] = function() return scantransform(true) end, [types.path] = scanpath, [types.pen] = scanpen, } diff --git a/tex/context/base/mkxl/node-acc.lmt b/tex/context/base/mkxl/node-acc.lmt index 2c3302a3e..328074428 100644 --- a/tex/context/base/mkxl/node-acc.lmt +++ b/tex/context/base/mkxl/node-acc.lmt @@ -34,7 +34,6 @@ local nextglyph = nuts.traversers.glyph local nextnode = nuts.traversers.node local copy_node = nuts.copy -local insert_after = nuts.insert_after local nodecodes = nodes.nodecodes local gluecodes = nodes.gluecodes diff --git a/tex/context/base/mkxl/node-aux.lmt b/tex/context/base/mkxl/node-aux.lmt index 27f248c58..1aeae3b45 100644 --- a/tex/context/base/mkxl/node-aux.lmt +++ b/tex/context/base/mkxl/node-aux.lmt @@ -53,12 +53,12 @@ local traversers = nuts.traversers local nextnode = traversers.node local nextglyph = traversers.glyph -local flush_node = nuts.flush -local flush_list = nuts.flush_list +local flushnode = nuts.flush +local flushlist = nuts.flushlist local hpack_nodes = nuts.hpack local vpack_nodes = nuts.vpack -local unset_attribute = nuts.unset_attribute -local first_glyph = nuts.first_glyph +local unsetattribute = nuts.unsetattribute +local firstglyph = nuts.firstglyph local copy_node = nuts.copy local find_tail = nuts.tail local getbox = nuts.getbox @@ -112,7 +112,7 @@ end function nuts.takelist(n) local l = getlist(n) setlist(n) - flush_node(n) + flushnode(n) return l end @@ -125,7 +125,7 @@ local function repackhlist(list,...) local temp, b = hpack_nodes(list,...) list = getlist(temp) setlist(temp) - flush_node(temp) + flushnode(temp) return list, b end @@ -136,50 +136,38 @@ function nodes.repackhlist(list,...) return tonode(list), b end -local function set_attributes(head,attr,value) +local function setattributes(head,attr,value) for n, id in nextnode, head do setattr(n,attr,value) if id == hlist_node or id == vlist_node then - set_attributes(getlist(n),attr,value) + setattributes(getlist(n),attr,value) end end end -local function set_unset_attributes(head,attr,value) +local function setunsetattributes(head,attr,value) for n, id in nextnode, head do if not getattr(n,attr) then setattr(n,attr,value) end if id == hlist_code or id == vlist_code then - set_unset_attributes(getlist(n),attr,value) + setunsetattributes(getlist(n),attr,value) end end end -local function unset_attributes(head,attr) +local function unsetattributes(head,attr) for n, id in nextnode, head do setattr(n,attr,unsetvalue) if id == hlist_code or id == vlist_code then - unset_attributes(getlist(n),attr) + unsetattributes(getlist(n),attr) end end end --- for old times sake - -nuts.setattribute = nuts.setattr nodes.setattribute = nodes.setattr -nuts.getattribute = nuts.getattr nodes.getattribute = nodes.getattr -nuts.unsetattribute = nuts.unset_attribute nodes.unsetattribute = nodes.unset_attribute -nuts.has_attribute = nuts.has_attribute nodes.has_attribute = nodes.has_attribute -nuts.firstglyph = nuts.first_glyph nodes.firstglyph = nodes.first_glyph - -nuts.setattributes = set_attributes nodes.setattributes = vianuts(set_attributes) -nuts.setunsetattributes = set_unset_attributes nodes.setunsetattributes = vianuts(set_unset_attributes) -nuts.unsetattributes = unset_attributes nodes.unsetattributes = vianuts(unset_attributes) - function nuts.firstcharacter(n,untagged) -- tagged == subtype > 255 if untagged then - return first_glyph(n) + return firstglyph(n) else for g in nextglyph ,n do return g @@ -353,7 +341,7 @@ local function rehpack(n,width) local set, order, sign = getboxglue(temp) setboxglue(n,set,order,sign) setlist(temp) - flush_node(temp) + flushnode(temp) return n end @@ -387,11 +375,10 @@ do end end - local getsubtype = nodes.getsubtype + local startofpar = nuts.startofpar - function nodes.start_of_par(n) - local s = getsubtype(n) - return s == hmodepar_code or s == vmodepar_code + function nodes.startofpar(n) + return startofpar(tonut(n)) end end diff --git a/tex/context/base/mkxl/node-bck.lmt b/tex/context/base/mkxl/node-bck.lmt index a814b329d..ba0e508b6 100644 --- a/tex/context/base/mkxl/node-bck.lmt +++ b/tex/context/base/mkxl/node-bck.lmt @@ -51,7 +51,7 @@ local nextnode = nuts.traversers.node local nexthlist = nuts.traversers.hlist local nextlist = nuts.traversers.list -local flush_node_list = nuts.flush_list +local flushnodelist = nuts.flushlist local new_rule = nodepool.rule local new_kern = nodepool.kern @@ -159,7 +159,7 @@ local function add_alignbackgrounds(head,list) local template = getprop(head,"alignmentchecked") if template then list = colored_b(head,list,template[1],hlist_code,template[2]) - flush_node_list(template) + flushnodelist(template) templates[currentrow] = false return list end diff --git a/tex/context/base/mkxl/node-bwc.lmt b/tex/context/base/mkxl/node-bwc.lmt new file mode 100644 index 000000000..a2e9d566d --- /dev/null +++ b/tex/context/base/mkxl/node-bwc.lmt @@ -0,0 +1,168 @@ +if not modules then modules = { } end modules ['node-bwc'] = { + version = 1.001, + comment = "companion to node-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- This is a backward compatinility list. Eventually it will go away although a few +-- might stay around. We start with some real low level ones. But ... users are +-- supposed to use nodes and nuts. + +local node = node +local direct = node.direct + +node .copy_list = node .copylist +node .current_attributes = node .currentattributes +node .effective_glue = node .effectiveglue +node .end_of_math = node .endofmath +node .first_glyph = node .firstglyph +node .flush_list = node .flushlist +node .flush_node = node .flushnode +node .get_attribute = node .getattribute +node .get_attributes = node .getattributes +------.get_properties_table = node .getpropertiestable +node .has_attribute = node .hasattribute +node .has_field = node .hasfield +node .has_glyph = node .hasglyph +node .insert_after = node .insertafter +node .insert_before = node .insertbefore +node .is_node = node .isnode or node.is_node +node .is_zero_glue = node .iszeroglue +node .last_node = node .lastnode +node .mlist_to_hlist = node .mlisttohlist +node .protect_glyph = node .protectglyph +node .protect_glyphs = node .protectglyphs +---- .protrusion_skippable = node .protrusionskippable +node .set_attribute = node .setattribute +node .set_attributes = node .setattributes +node .traverse_id = node .traverseid or node.traverse_id +node .unprotect_glyph = node .unprotectglyph +node .unprotect_glyphs = node .unprotectglyphs +node .unset_attribute = node .unsetattribute +node .unset_attributes = node .unsetattributes + +direct.copy_list = direct.copylist +direct.current_attributes = direct.currentattributes +direct.effective_glue = direct.effectiveglue +direct.end_of_math = direct.endofmath +direct.find_node = direct.findnode +direct.first_glyph = direct.firstglyph +direct.flush_list = direct.flushlist +direct.flush_node = direct.flushnode +direct.get_attribute = direct.getattribute +direct.get_attributes = direct.getattributes +------.get_properties_table = direct.getpropertiestable +direct.has_attribute = direct.hasattribute +direct.hasdimensions = direct.hasdimensions +direct.has_field = direct.hasfield +direct.has_glyph = direct.hasglyph +direct.insert_after = direct.insertafter +direct.insert_before = direct.insertbefore +direct.is_char = direct.ischar +direct.is_direct = direct.isdirect +direct.is_glyph = direct.isglyph +direct.is_node = direct.isnode +direct.is_valid = direct.isvalid +direct.is_zero_glue = direct.iszeroglue +direct.last_node = direct.lastnode +direct.mlist_to_hlist = direct.mlisttohlist +direct.protect_glyph = direct.protectglyph +direct.protect_glyphs = direct.protectglyphs +------.protrusion_skippable = direct.protrusionskippable +direct.set_attribute = direct.setattribute +direct.set_attributes = direct.setattributes +direct.start_of_par = direct.startofpar +direct.traverse_char = direct.traversechar or direct.traverse_char +direct.traverse_content = direct.traversecontent or direct.traverse_content +direct.traverse_glyph = direct.traverseglyph or direct.traverse_glyph +direct.traverse_id = direct.traverseid or direct.traverse_id +direct.traverse_list = direct.traverselist or direct.traverse_list +direct.unprotect_glyph = direct.unprotectglyph +direct.unprotect_glyphs = direct.unprotectglyphs +direct.unset_attribute = direct.unsetattribute +direct.unset_attributes = direct.unsetattributes +direct.uses_font = direct.usesfont + +-- Now come the nodes and nuts. + +local nodes = nodes +local nuts = nodes.nuts + +-----.check_discretionaries = nuts .checkdiscretionaries +nuts .copy_list = nuts .copylist +nuts .copy_node = nuts .copynode +nuts .copy_only = nuts .copyonly +nuts .current_attr = nuts .currentattributes +nuts .effective_glue = nuts .effectiveglue +nuts .end_of_math = nuts .endofmath +nuts .find_attribute = nuts .findattribute +nuts .first_glyph = nuts .firstglyph +-----.flatten_discretionaries = nuts .flattendiscretionaries +nuts .flush_list = nuts .flushlist +nuts .flush_node = nuts .flushnode +nuts .get_attribute = nuts .getattribute +nuts .get_synctex_fields = nuts .getsynctexfields +nuts .has_attribute = nuts .hasattribute +nuts .has_dimensions = nuts .hasdimensions +nuts .has_field = nuts .hasfield +nuts .has_glyph = nuts .hasglyph +nuts .insert_after = nuts .insertafter +nuts .insert_before = nuts .insertbefore +nuts .is_direct = nuts .isdirect +nuts .is_node = nuts .isnode +nuts .is_nut = nuts .isnut +nuts .is_zero_glue = nuts .iszeroglue +nuts .mlist_to_hlist = nuts .mlisttohlist +nuts .protect_glyph = nuts .protectglyph +nuts .protect_glyphs = nuts .protectglyphs +-----.protrusion_skippable = nuts .protrusionskippable +nuts .set_attribute = nuts .setattribute +-----.set_synctex_fields = nuts .setsynctexfields +nuts .start_of_par = nuts .startofpar +nuts .traverse_id = nuts .traverseid +nuts .traverse_char = nuts .traversechar +nuts .traverse_glyph = nuts .traverseglyph +nuts .traverse_id = nuts .traverseid +nuts .traverse_list = nuts .traverselist +nuts .unprotect_glyph = nuts .unprotectglyph +nuts .unprotect_glyphs = nuts .unprotectglyphs +nuts .unset_attribute = nuts .unsetattribute +nuts .uses_font = nuts .usesfont + +-----.check_discretionaries = nodes.check_discretionaries +nodes.copy_list = nodes.copylist +nodes.copy_node = nodes.copynode +nodes.current_attributes = nodes.currentattributes +nodes.effective_glue = nodes.effectiveglue +nodes.end_of_math = nodes.endofmath +nodes.find_attribute = nodes.findattribute +nodes.first_glyph = nodes.firstglyph +-----.flatten_discretionaries = nodes.flattendiscretionaries +nodes.flush_list = nodes.flushlist +nodes.flush_node = nodes.flushnode +nodes.has_attribute = nodes.hasattribute +nodes.has_field = nodes.hasfield +nodes.has_glyph = nodes.hasglyph +nodes.insert_after = nodes.insertafter +nodes.insert_before = nodes.insertbefore +nodes.is_direct = nodes.isdirect +nodes.is_node = nodes.isnode +nodes.is_nut = nodes.isnut +nodes.is_zero_glue = nodes.iszeroglue +nodes.last_node = nodes.lastnode +nodes.mlist_to_hlist = nodes.mlisttohlist +nodes.protect_glyph = nodes.protectglyph +nodes.protect_glyphs = nodes.protectglyphs +-----.protrusion_skippable = nodes.protrusionskippable +nodes.set_attribute = nodes.setattribute +nodes.traverse_id = nodes.traverseid +nodes.traverse_char = nodes.traversechar +nodes.traverse_glyph = nodes.traverseglyph +nodes.traverse_id = nodes.traverseid +nodes.traverse_list = nodes.traverselist +nodes.unprotect_glyph = nodes.unprotectglyph +nodes.unprotect_glyphs = nodes.unprotectglyphs +nodes.unset_attribute = nodes.unsetattribute +nodes.uses_font = nodes.usesfont diff --git a/tex/context/base/mkxl/node-cmp.lmt b/tex/context/base/mkxl/node-cmp.lmt index 21fd700f0..8f805abd9 100644 --- a/tex/context/base/mkxl/node-cmp.lmt +++ b/tex/context/base/mkxl/node-cmp.lmt @@ -75,47 +75,42 @@ function node.kerning(first,last) end end -local protect_glyph = direct.protect_glyph -local unprotect_glyph = direct.unprotect_glyph -local protect_glyphs = direct.protect_glyphs -local unprotect_glyphs = direct.unprotect_glyphs +local protectglyph = direct.protectglyph +local unprotectglyph = direct.unprotectglyph +local protectglyphs = direct.protectglyphs +local unprotectglyphs = direct.unprotectglyphs -function node.protect_glyphs(first,last) - protect_glyphs(todirect(first), last and todirect(last) or nil) +function node.protectglyphs(first,last) + protectglyphs(todirect(first), last and todirect(last) or nil) end -function node.unprotect_glyphs(first,last) - unprotect_glyphs(todirect(first), last and todirect(last) or nil) +function node.unprotectglyphs(first,last) + unprotectglyphs(todirect(first), last and todirect(last) or nil) end -function node.protect_glyph(first) - protect_glyph(todirect(first)) +function node.protectglyph(first) + protectglyph(todirect(first)) end -function node.unprotect_glyph(first) - unprotect_glyph(todirect(first)) +function node.unprotectglyph(first) + unprotectglyph(todirect(first)) end -local flatten_discretionaries = direct.flatten_discretionaries -local check_discretionaries = direct.check_discretionaries -local check_discretionary = direct.check_discretionary +local flattendiscretionaries = direct.flattendiscretionaries +local checkdiscretionaries = direct.checkdiscretionaries +local checkdiscretionary = direct.checkdiscretionary -function node.flatten_discretionaries(first) - local h, count = flatten_discretionaries(todirect(first)) +function node.flattendiscretionaries(first) + local h, count = flattendiscretionaries(todirect(first)) return tonode(h), count end -function node.check_discretionaries(n) - check_discretionaries(todirect(n)) -end - -function node.check_discretionary(n) - check_discretionary(todirect(n)) -end +function node.checkdiscretionaries(n) checkdiscretionaries(todirect(n)) end +function node.checkdiscretionary (n) checkdiscretionary (todirect(n)) end -local hpack = direct.hpack -local vpack = direct.vpack -local list_to_hlist = direct.mlist_to_hlist +local hpack = direct.hpack +local vpack = direct.vpack +local mlisttohlist = direct.mlisttohlist function node.hpack(head,...) local h, badness = hpack(head and todirect(head) or nil,...) @@ -127,17 +122,17 @@ function node.vpack(head,...) return tonode(h), badness end -function node.mlist_to_hlist(head,...) - return tonode(mlist_to_hlist(head and todirect(head) or nil,...)) +function node.mlisttohlist(head,...) + return tonode(mlisttohlist(head and todirect(head) or nil,...)) end -local end_of_math = direct.end_of_math -local find_attribute = direct.find_attribute -local first_glyph = direct.first_glyph +local endofmath = direct.endofmath +local findattribute = direct.findattribute +local firstglyph = direct.firstglyph -function node.end_of_math(n) +function node.endofmath(n) if n then - n = end_of_math(todirect(n)) + n = endofmath(todirect(n)) if n then return tonode(n) end @@ -145,9 +140,9 @@ function node.end_of_math(n) return nil end -function node.find_attribute(n,a) +function node.findattribute(n,a) if n then - local v, n = find_attribute(todirect(n),a) + local v, n = findattribute(todirect(n),a) if n then return v, tonode(n) end @@ -155,14 +150,14 @@ function node.find_attribute(n,a) return nil end -function node.first_glyph(first,last) - local n = first_glyph(todirect(first), last and todirect(last) or nil) +function node.firstglyph(first,last) + local n = firstglyph(todirect(first), last and todirect(last) or nil) return n and tonode(n) or nil end local dimensions = direct.dimensions local rangedimensions = direct.rangedimensions -local effective_glue = direct.effective_glue +local effectiveglue = direct.effectiveglue function node.dimensions(a,b,c,d,e) if type(a) == "userdata" then @@ -185,53 +180,34 @@ function node.rangedimensions(parent,first,last) return rangedimenensions(todirect(parent),todirect(first),last and todirect(last)) end -function node.effective_glue(list,parent) - return effective_glue(list and todirect(list) or nil,parent and todirect(parent) or nil) -end - -local uses_font = direct.uses_font -local has_glyph = direct.has_glyph -local protrusion_skippable = direct.protrusion_skippable -local make_extensible = direct.make_extensible - -function node.uses_font(n,f) - return uses_font(todirect(n),f) -end - -function node.has_glyph(n) - return has_glyph(todirect(n)) +function node.effectiveglue(list,parent) + return effectiveglue(list and todirect(list) or nil,parent and todirect(parent) or nil) end -function node.protrusion_skippable(n) - return protrusion_skippable(todirect(n)) -end +local usesfont = direct.usesfont +local hasglyph = direct.hasglyph +local protrusionskippable = direct.protrusionskippable -function node.make_extensible(...) - local n = make_extensible(...) - return n and tonode(n) or nil -end +function node.usesfont (n,f) return usesfont(todirect(n),f) end +function node.hasglyph (n) return hasglyph(todirect(n)) end +function node.protrusionskippable(n) return protrusionskippable(todirect(n)) end -local last_node = direct.last_node +local makeextensible = direct.make_extensible +local lastnode = direct.lastnode -function node.last_node() - local n = last_node() - return n and tonode(n) or nil -end +function node.makeextensible(...) local n = makeextensible(...) return n and tonode(n) or nil end +function node.lastnode () local n = lastnode() return n and tonode(n) or nil end -local is_zero_glue = direct.is_zero_glue -local getglue = direct.getglue -local setglue = direct.setglue +local iszeroglue = direct.iszeroglue +local getglue = direct.getglue +local setglue = direct.setglue -function node.is_zero_glue(n) - return is_zero_glue(todirect(n)) -end +function node.iszeroglue(n) return iszeroglue(todirect(n)) end +function node.getglue (n) return getglue (todirect(n)) end +function node.setglue (n) return setglue (todirect(n)) end -function node.get_glue(n) - return get_glue(todirect(n)) -end +node.family_font = tex.getfontoffamily -function node.set_glue(n) - return set_glue(todirect(n)) -end +-- node.get_glue = node.getglue +-- node.set_glue = node.setglue -node.family_font = tex.getfontoffamily diff --git a/tex/context/base/mkxl/node-dir.lmt b/tex/context/base/mkxl/node-dir.lmt index c959fef07..246bf34e4 100644 --- a/tex/context/base/mkxl/node-dir.lmt +++ b/tex/context/base/mkxl/node-dir.lmt @@ -28,8 +28,8 @@ local nextdir = nuts.traversers.dir local nextlist = nuts.traversers.list local rangedimensions = nuts.rangedimensions -local insert_before = nuts.insert_before -local insert_after = nuts.insert_after +local insertbefore = nuts.insertbefore +local insertafter = nuts.insertafter local new_rule = nuts.pool.rule local new_kern = nuts.pool.kern @@ -61,8 +61,8 @@ local function colorit(list,current,dir,w,h,d) local color = dir == lefttoright_code and "trace:s" or "trace:o" setcolor(rule,color) settransparency(rule,color) - list, current = insert_before(list,current,kern) - list, current = insert_before(list,current,rule) + list, current = insertbefore(list,current,kern) + list, current = insertbefore(list,current,rule) return list, current end diff --git a/tex/context/base/mkxl/node-ext.lmt b/tex/context/base/mkxl/node-ext.lmt index 2f909cd3d..9068cd976 100644 --- a/tex/context/base/mkxl/node-ext.lmt +++ b/tex/context/base/mkxl/node-ext.lmt @@ -18,7 +18,8 @@ local allocate = utilities.storage.allocate local formatters = string.formatters -local get = token.get_index -- getters +local get = tokens.accessors.index + local scanners = tokens.scanners local scaninteger = scanners.integer local scanstring = scanners.string diff --git a/tex/context/base/mkxl/node-fin.lmt b/tex/context/base/mkxl/node-fin.lmt index 2ca7491a1..464f17f83 100644 --- a/tex/context/base/mkxl/node-fin.lmt +++ b/tex/context/base/mkxl/node-fin.lmt @@ -17,62 +17,62 @@ local setmetatableindex = table.setmetatableindex local attributes, nodes, node = attributes, nodes, node -local nuts = nodes.nuts -local tonut = nodes.tonut - -local getnext = nuts.getnext -local getid = nuts.getid -local getlist = nuts.getlist -local getleader = nuts.getleader -local getattr = nuts.getattr -local getattrs = nuts.getattrs -local getwidth = nuts.getwidth -local getwhd = nuts.getwhd -local getorientation = nuts.getorientation -local has_dimensions = nuts.has_dimensions -local getbox = nuts.getbox - -local setlist = nuts.setlist -local setleader = nuts.setleader - -local copy_node = nuts.copy -local find_tail = nuts.tail -local insert_node_before = nuts.insert_before -local insert_node_after = nuts.insert_after - -local nextnode = nuts.traversers.node -local nextcontent = nuts.traversers.content - -local nodecodes = nodes.nodecodes -local rulecodes = nodes.rulecodes - -local boxrule_code = rulecodes.box -local imagerule_code = rulecodes.image -local emptyrule_code = rulecodes.empty - -local container_code = nodes.listcodes.container - -local glyph_code = nodecodes.glyph -local disc_code = nodecodes.disc -local glue_code = nodecodes.glue -local rule_code = nodecodes.rule -local hlist_code = nodecodes.hlist -local vlist_code = nodecodes.vlist - -local texlists = tex.lists -local texgetnest = tex.getnest - -local states = attributes.states -local numbers = attributes.numbers -local a_trigger = attributes.private('trigger') -local triggering = false - -local implement = interfaces.implement - -local starttiming = statistics.starttiming -local stoptiming = statistics.stoptiming -local loadstripped = utilities.lua.loadstripped -local unsetvalue = attributes.unsetvalue +local nuts = nodes.nuts +local tonut = nodes.tonut + +local getnext = nuts.getnext +local getid = nuts.getid +local getlist = nuts.getlist +local getleader = nuts.getleader +local getattr = nuts.getattr +local getattrs = nuts.getattrs +local getwidth = nuts.getwidth +local getwhd = nuts.getwhd +local getorientation = nuts.getorientation +local hasdimensions = nuts.hasdimensions +local getbox = nuts.getbox + +local setlist = nuts.setlist +local setleader = nuts.setleader + +local copy_node = nuts.copy +local find_tail = nuts.tail +local insertnodebefore = nuts.insertbefore +local insertnodeafter = nuts.insertafter + +local nextnode = nuts.traversers.node +local nextcontent = nuts.traversers.content + +local nodecodes = nodes.nodecodes +local rulecodes = nodes.rulecodes + +local boxrule_code = rulecodes.box +local imagerule_code = rulecodes.image +local emptyrule_code = rulecodes.empty + +local container_code = nodes.listcodes.container + +local glyph_code = nodecodes.glyph +local disc_code = nodecodes.disc +local glue_code = nodecodes.glue +local rule_code = nodecodes.rule +local hlist_code = nodecodes.hlist +local vlist_code = nodecodes.vlist + +local texlists = tex.lists +local texgetnest = tex.getnest + +local states = attributes.states +local numbers = attributes.numbers +local a_trigger = attributes.private('trigger') +local triggering = false + +local implement = interfaces.implement + +local starttiming = statistics.starttiming +local stoptiming = statistics.stoptiming +local loadstripped = utilities.lua.loadstripped +local unsetvalue = attributes.unsetvalue -- these two will be like trackers @@ -168,15 +168,15 @@ function states.finalize(namespace,attribute,head) -- is this one ok? if id == hlist_code or id == vlist_code then local content = getlist(head) if content then --- local list = insert_node_before(content,content,copy_node(nsnone)) -- two return values - local list = insert_node_after(content,find_tail(content),copy_node(nsnone)) -- two return values +-- local list = insertnodebefore(content,content,copy_node(nsnone)) -- two return values + local list = insertnodeafter(content,find_tail(content),copy_node(nsnone)) -- two return values if list ~= content then setlist(head,list) end end else --- head = insert_node_before(head,head,copy_node(nsnone)) - head = insert_node_after(find_tail(head),head,copy_node(nsnone)) +-- head = insertnodebefore(head,head,copy_node(nsnone)) + head = insertnodeafter(find_tail(head),head,copy_node(nsnone)) end return head, true end @@ -206,20 +206,20 @@ current = 0 if outer then if default and outer == inheritance then if current ~= default then - head = insert_node_before(head,stack,copy_node(nsdata[default])) + head = insertnodebefore(head,stack,copy_node(nsdata[default])) current = default end elseif current ~= outer then - head = insert_node_before(head,stack,copy_node(nsdata[c])) + head = insertnodebefore(head,stack,copy_node(nsdata[c])) current = outer end elseif default and inheritance then if current ~= default then - head = insert_node_before(head,stack,copy_node(nsdata[default])) + head = insertnodebefore(head,stack,copy_node(nsdata[default])) current = default end elseif current > 0 then - head = insert_node_before(head,stack,copy_node(nsnone)) + head = insertnodebefore(head,stack,copy_node(nsnone)) current = 0 end end @@ -242,7 +242,7 @@ current = 0 end -- end nested -- elseif id == rule_code then - check = has_dimensions(stack) + check = hasdimensions(stack) end -- much faster this way than using a check() and nested() function if check then @@ -250,11 +250,11 @@ current = 0 if c then if default and c == inheritance then if current ~= default then - head = insert_node_before(head,stack,copy_node(nsdata[default])) + head = insertnodebefore(head,stack,copy_node(nsdata[default])) current = default end elseif current ~= c then - head = insert_node_before(head,stack,copy_node(nsdata[c])) + head = insertnodebefore(head,stack,copy_node(nsdata[c])) current = c end if leader then @@ -287,11 +287,11 @@ current = 0 end elseif default and inheritance then if current ~= default then - head = insert_node_before(head,stack,copy_node(nsdata[default])) + head = insertnodebefore(head,stack,copy_node(nsdata[default])) current = default end elseif current > 0 then - head = insert_node_before(head,stack,copy_node(nsnone)) + head = insertnodebefore(head,stack,copy_node(nsnone)) current = 0 end check = false @@ -323,13 +323,13 @@ current = 0 if outer then if current ~= outer then if current > 0 then - head = insert_node_before(head,stack,copy_node(nsnone)) + head = insertnodebefore(head,stack,copy_node(nsnone)) end - head = insert_node_before(head,stack,copy_node(nsdata[c])) + head = insertnodebefore(head,stack,copy_node(nsdata[c])) current = outer end elseif current > 0 then - head = insert_node_before(head,stack,copy_node(nsnone)) + head = insertnodebefore(head,stack,copy_node(nsnone)) current = 0 end end @@ -338,16 +338,16 @@ current = 0 setlist(stack,list) end elseif id == rule_code then - check = has_dimensions(stack) + check = hasdimensions(stack) end if check then local c = getattr(stack,attribute) if c then if current ~= c then if current > 0 then - head = insert_node_before(head,stack,copy_node(nsnone)) + head = insertnodebefore(head,stack,copy_node(nsnone)) end - head = insert_node_before(head,stack,copy_node(nsdata[c])) + head = insertnodebefore(head,stack,copy_node(nsdata[c])) current = c end if leader then @@ -364,7 +364,7 @@ current = 0 leader = false end elseif current > 0 then - head = insert_node_before(head,stack,copy_node(nsnone)) + head = insertnodebefore(head,stack,copy_node(nsnone)) current = 0 end check = false @@ -405,7 +405,7 @@ end -- if default and outer == inheritance then -- if current ~= default then -- local data = nsdata[default] --- head = insert_node_before(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector])) +-- head = insertnodebefore(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector])) -- current = default -- end -- else @@ -413,7 +413,7 @@ end -- -- local s = nsforced or getattr(stack,nsselector) -- if current ~= outer or current_selector ~= s then -- local data = nsdata[outer] --- head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) +-- head = insertnodebefore(head,stack,copy_node(data[nsforced or s or nsselector])) -- current = outer -- current_selector = s -- end @@ -421,11 +421,11 @@ end -- elseif default and inheritance then -- if current ~= default then -- local data = nsdata[default] --- head = insert_node_before(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector])) +-- head = insertnodebefore(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector])) -- current = default -- end -- elseif current > 0 then --- head = insert_node_before(head,stack,copy_node(nsnone)) +-- head = insertnodebefore(head,stack,copy_node(nsnone)) -- current, current_selector = 0, 0 -- end -- end @@ -452,7 +452,7 @@ end -- -- so no redundant color stuff (only here, layers for instance should obey) -- check = false -- else --- check = has_dimensions(stack) +-- check = hasdimensions(stack) -- end -- end -- if check then @@ -461,7 +461,7 @@ end -- if default and c == inheritance then -- if current ~= default then -- local data = nsdata[default] --- head = insert_node_before(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector])) +-- head = insertnodebefore(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector])) -- current = default -- end -- else @@ -469,7 +469,7 @@ end -- -- local s = nsforced or getattr(stack,nsselector) -- if current ~= c or current_selector ~= s then -- local data = nsdata[c] --- head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) +-- head = insertnodebefore(head,stack,copy_node(data[nsforced or s or nsselector])) -- current = c -- current_selector = s -- end @@ -496,11 +496,11 @@ end -- elseif default and inheritance then -- if current ~= default then -- local data = nsdata[default] --- head = insert_node_before(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector])) +-- head = insertnodebefore(head,stack,copy_node(data[nsforced or getattr(stack,nsselector) or nsselector])) -- current = default -- end -- elseif current > 0 then --- head = insert_node_before(head,stack,copy_node(nsnone)) +-- head = insertnodebefore(head,stack,copy_node(nsnone)) -- current, current_selector = 0, 0 -- end -- check = false @@ -531,23 +531,23 @@ current = 0 if default and outer == inheritance then if current ~= default then local data = nsdata[default] - head = insert_node_before(head,stack,copy_node(data[nsforced or nsselector])) + head = insertnodebefore(head,stack,copy_node(data[nsforced or nsselector])) current = default end elseif current ~= outer or current_selector ~= s then local data = nsdata[outer] - head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) + head = insertnodebefore(head,stack,copy_node(data[nsforced or s or nsselector])) current = outer current_selector = s end elseif default and inheritance then if current ~= default then local data = nsdata[default] - head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) + head = insertnodebefore(head,stack,copy_node(data[nsforced or s or nsselector])) current = default end elseif current > 0 then - head = insert_node_before(head,stack,copy_node(nsnone)) + head = insertnodebefore(head,stack,copy_node(nsnone)) current, current_selector = 0, 0 end end @@ -574,7 +574,7 @@ current = 0 -- so no redundant color stuff (only here, layers for instance should obey) check = false else - check = has_dimensions(stack) + check = hasdimensions(stack) end end if check then @@ -583,12 +583,12 @@ current = 0 if default and c == inheritance then if current ~= default then local data = nsdata[default] - head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) + head = insertnodebefore(head,stack,copy_node(data[nsforced or s or nsselector])) current = default end elseif current ~= c or current_selector ~= s then local data = nsdata[c] - head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) + head = insertnodebefore(head,stack,copy_node(data[nsforced or s or nsselector])) current = c current_selector = s end @@ -614,11 +614,11 @@ current = 0 elseif default and inheritance then if current ~= default then local data = nsdata[default] - head = insert_node_before(head,stack,copy_node(data[nsforced or s or nsselector])) + head = insertnodebefore(head,stack,copy_node(data[nsforced or s or nsselector])) current = default end elseif current > 0 then - head = insert_node_before(head,stack,copy_node(nsnone)) + head = insertnodebefore(head,stack,copy_node(nsnone)) current, current_selector = 0, 0 end check = false @@ -669,9 +669,9 @@ current = 0 if a and current ~= a and nslistwise[a] then -- viewerlayer / needs checking, see below local p = current current = a - head = insert_node_before(head,stack,copy_node(nsdata[a])) + head = insertnodebefore(head,stack,copy_node(nsdata[a])) list = stacked(attribute,content,current) -- two return values - head, stack = insert_node_after(head,stack,copy_node(nsnone)) + head, stack = insertnodeafter(head,stack,copy_node(nsnone)) current = p else list = stacked(attribute,content,current) @@ -684,13 +684,13 @@ current = 0 end end elseif id == rule_code then - check = has_dimensions(stack) + check = hasdimensions(stack) end if check then local a = getattr(stack,attribute) if a then if current ~= a then - head = insert_node_before(head,stack,copy_node(nsdata[a])) + head = insertnodebefore(head,stack,copy_node(nsdata[a])) depth = depth + 1 current = a end @@ -707,7 +707,7 @@ current = 0 elseif default > 0 then -- elseif current > 0 then - head = insert_node_before(head,stack,copy_node(nsnone)) + head = insertnodebefore(head,stack,copy_node(nsnone)) depth = depth - 1 current = 0 end @@ -716,7 +716,7 @@ current = 0 stack = getnext(stack) end while depth > 0 do - head = insert_node_after(head,stack,copy_node(nsnone)) + head = insertnodeafter(head,stack,copy_node(nsnone)) depth = depth - 1 end return head @@ -759,12 +759,12 @@ end -- if nslistwise then -- local a = getattr(current,attribute) -- if a and attrib ~= a and nslistwise[a] then -- viewerlayer --- head = insert_node_before(head,current,copy_node(nsdata[a])) +-- head = insertnodebefore(head,current,copy_node(nsdata[a])) -- list = stacker(attribute,content,a) -- if list ~= content then -- setlist(current,list) -- end --- head, current = insert_node_after(head,current,copy_node(nsnone)) +-- head, current = insertnodeafter(head,current,copy_node(nsnone)) -- else -- list = stacker(attribute,content,attrib) -- if list ~= content then @@ -779,7 +779,7 @@ end -- end -- end -- elseif id == rule_code then --- check = has_dimensions(current) +-- check = hasdimensions(current) -- end -- -- if check then @@ -791,7 +791,7 @@ end -- end -- local n = nsstep(a) -- if n then --- head = insert_node_before(head,current,n) -- a +-- head = insertnodebefore(head,current,n) -- a -- end -- attrib = a -- if leader then @@ -820,7 +820,7 @@ end -- if stacked then -- local n = nsend() -- while n do --- head = insert_node_after(head,previous,n) +-- head = insertnodeafter(head,previous,n) -- n = nsend() -- end -- end @@ -854,12 +854,12 @@ local function stacker(attribute,head,default) -- no triggering, no inheritance, if nslistwise then local a = getattr(current,attribute) if a and attrib ~= a and nslistwise[a] then -- viewerlayer - head = insert_node_before(head,current,copy_node(nsdata[a])) + head = insertnodebefore(head,current,copy_node(nsdata[a])) list = stacker(attribute,content,a) if list ~= content then setlist(current,list) end - head, current = insert_node_after(head,current,copy_node(nsnone)) + head, current = insertnodeafter(head,current,copy_node(nsnone)) else list = stacker(attribute,content,attrib) if list ~= content then @@ -877,7 +877,7 @@ local function stacker(attribute,head,default) -- no triggering, no inheritance, -- so no redundant color stuff (only here, layers for instance should obey) check = false else - check = has_dimensions(current) + check = hasdimensions(current) end end @@ -890,7 +890,7 @@ local function stacker(attribute,head,default) -- no triggering, no inheritance, end local n = nsstep(a) if n then - head = insert_node_before(head,current,n) -- a + head = insertnodebefore(head,current,n) -- a end attrib = a if leader then @@ -918,7 +918,7 @@ local function stacker(attribute,head,default) -- no triggering, no inheritance, if stacked then local n = nsend() while n do - head = insert_node_after(head,previous,n) + head = insertnodeafter(head,previous,n) n = nsend() end end diff --git a/tex/context/base/mkxl/node-fnt.lmt b/tex/context/base/mkxl/node-fnt.lmt index c96bdde3d..f3e8c212f 100644 --- a/tex/context/base/mkxl/node-fnt.lmt +++ b/tex/context/base/mkxl/node-fnt.lmt @@ -64,15 +64,15 @@ local nextboundary = nuts.traversers.boundary local nextdisc = nuts.traversers.disc local nextchar = nuts.traversers.char -local flush_node = nuts.flush +local flushnode = nuts.flush local disc_code = nodecodes.disc local boundary_code = nodecodes.boundary local wordboundary_code = boundarycodes.word -local protect_glyphs = nuts.protect_glyphs -local unprotect_glyphs = nuts.unprotect_glyphs +local protectglyphs = nuts.protectglyphs +local unprotectglyphs = nuts.unprotectglyphs local setmetatableindex = table.setmetatableindex @@ -186,7 +186,7 @@ do local d, u, b, r local function protectnone() - protect_glyphs(firstnone,lastnone) + protectglyphs(firstnone,lastnone) firstnone = nil end @@ -399,7 +399,7 @@ do end end end - flush_node(r) + flushnode(r) end end @@ -546,5 +546,5 @@ do end -handlers.protectglyphs = protect_glyphs -handlers.unprotectglyphs = unprotect_glyphs +handlers.protectglyphs = protectglyphs +handlers.unprotectglyphs = unprotectglyphs diff --git a/tex/context/base/mkxl/node-gcm.lmt b/tex/context/base/mkxl/node-gcm.lmt index 7f2a7bded..03a4acda8 100644 --- a/tex/context/base/mkxl/node-gcm.lmt +++ b/tex/context/base/mkxl/node-gcm.lmt @@ -14,8 +14,8 @@ local nuts = nodes.nuts local getnext = nuts.getnext local getsubtype = nuts.getsubtype -local copy_node = nuts.copy -local flush_list = nuts.flush_list +local copynode = nuts.copy +local flushlist = nuts.flushlist local count = nuts.count local isglyph = nuts.isglyph local getprop = nuts.getprop @@ -25,7 +25,7 @@ local fastcopy = table.fastcopy local report_error = logs.reporter("node-aux:error") -local function set_components(base,list) +local function setcomponents(base,list) local t = { } local n = 0 local l = list @@ -39,35 +39,35 @@ local function set_components(base,list) end -- not yet as we need them -- - -- flush_list(l) + -- flushlist(l) -- setprop(base,"components",n > 0 and t or false) end -local function get_components(base) +local function getcomponents(base) return getprop(base,"components") end -local function copy_no_components(base) - local copy = copy_node(base) +local function copynocomponents(base) + local copy = copynode(base) setprop(copy,"components",false) -- no metatable lookup! return copy end -local function copy_only_glyphs(base) +local function copyonlyglyphs(base) local t = getprop(base,"components") -- also metatable if t then return fastcopy(t) end end -local function do_count(t,marks) +local function docount(t,marks) local n = 0 if t then for i=1,#t do local c = t[i] if type(c) == "table" then - n = n + do_count(t,marks) + n = n + docount(t,marks) elseif not marks[c] then n = n + 1 else @@ -82,19 +82,19 @@ end local done = false -local function count_components(base,marks) +local function countcomponents(base,marks) local char = isglyph(base) if char then if getsubtype(base) == ligature_code then if not done then logs.report("fonts","!") - logs.report("fonts","! check count_components with mkiv !") + logs.report("fonts","! check countcomponents with mkiv !") logs.report("fonts","!") done = true end local t = getprop(base,"components") if t then - return do_count(t,marks) + return docount(t,marks) end elseif not marks[char] then return 1 @@ -103,12 +103,14 @@ local function count_components(base,marks) return 0 end -nuts.set_components = set_components -nuts.get_components = get_components -nuts.copy_only_glyphs = copy_only_glyphs -nuts.copy_no_components = copy_no_components -nuts.count_components = count_components -nuts.flush_components = flush_list +nuts.components = { + set = setcomponents, + get = getcomponents, + copyonlyglyphs = copyonlyglyphs, + copynocomponents = copynocomponents, + count = countcomponents, + flush = flushlist, +} nuts.setcomponents = function() report_error("unsupported: %a","setcomponents") end nuts.getcomponents = function() report_error("unsupported: %a","getcomponents") end diff --git a/tex/context/base/mkxl/node-ini.mkxl b/tex/context/base/mkxl/node-ini.mkxl index 438e6ff01..09ac085c4 100644 --- a/tex/context/base/mkxl/node-ini.mkxl +++ b/tex/context/base/mkxl/node-ini.mkxl @@ -39,6 +39,7 @@ \registerctxluafile{node-scn}{autosuffix} \registerctxluafile{node-syn}{autosuffix} \registerctxluafile{node-par}{autosuffix} +\registerctxluafile{node-bwc}{autosuffix} % for a while %D This might go away (needs checking anyway, very old code): diff --git a/tex/context/base/mkxl/node-met.lmt b/tex/context/base/mkxl/node-met.lmt index 0186f2860..f24200e97 100644 --- a/tex/context/base/mkxl/node-met.lmt +++ b/tex/context/base/mkxl/node-met.lmt @@ -10,7 +10,7 @@ if not modules then modules = { } end modules ['node-MET'] = { -- the regular code is proven stable. No support otherwise. -- luatex: todo: copylist should return h, t --- todo: see if using insert_before and insert_after makes sense here +-- todo: see if using insertbefore and insertafter makes sense here -- This file is a side effect of the \LUATEX\ speed optimization project of Luigi -- Scarso and me. As \CONTEXT\ spends over half its time in \LUA, we though that @@ -65,39 +65,41 @@ end -- We start with some helpers and provide all relevant basic functions in the -- node namespace as well. -nodes = nodes or { } -local nodes = nodes - -local nodecodes = nodes.nodecodes - -nodes.copy = node.copy -nodes.copy_list = node.copy_list -nodes.copy_node = node.copy -nodes.current_attributes = node.current_attributes -nodes.remove = node.remove -nodes.fields = node.fields -nodes.flush = node.flush_node -nodes.flush_list = node.flush_list -nodes.flush_node = node.flush_node -nodes.get_attribute = node.get_attribute -nodes.has_attribute = node.has_attribute -nodes.has_field = node.has_field -nodes.insert_after = node.insert_after -nodes.insert_before = node.insert_before -nodes.is_node = node.is_node -nodes.new = node.new -nodes.set_attribute = node.set_attribute -nodes.tail = node.tail -nodes.tostring = node.tostring or tostring -nodes.traverse = node.traverse -nodes.traverse_id = node.traverse_id -nodes.unset_attribute = node.unset_attribute -nodes.write = node.write -nodes.usedlist = node.usedlist - -nodes.get_properties_table = node.get_properties_table -nodes.getproperty = node.getproperty -nodes.setproperty = node.setproperty +nodes = nodes or { } +local nodes = nodes + +local nodecodes = nodes.nodecodes + +nodes.copy = node.copy +nodes.copylist = node.copylist +nodes.copy_node = node.copy +nodes.currentattributes = node.currentattributes +nodes.remove = node.remove +nodes.fields = node.fields +nodes.flush = node.flushnode +nodes.flushlist = node.flushlist +nodes.flushnode = node.flushnode +nodes.getattribute = node.getattribute +nodes.hasattribute = node.hasattribute +nodes.hasfield = node.hasfield +nodes.insertafter = node.insertafter +nodes.insertbefore = node.insertbefore +nodes.isnode = node.isnode +nodes.isdirect = node.isdirect +nodes.isnut = node.isdirect +nodes.new = node.new +nodes.setattribute = node.setattribute +nodes.tail = node.tail +nodes.tostring = node.tostring or tostring +nodes.traverse = node.traverse +nodes.traverseid = node.traverseid +nodes.unsetattribute = node.unsetattribute +nodes.write = node.write +nodes.usedlist = node.usedlist + +nodes.getpropertiestable = node.get_properties_table +nodes.getproperty = node.getproperty +nodes.setproperty = node.setproperty -- nodes.usedlist", -- nodes.inuse", @@ -118,7 +120,7 @@ nodes.setproperty = node.setproperty -- Fot now I keep them in \LMTX\ but they will go away! local n_getfield = node.getfield -local n_getattr = node.get_attribute +local n_getattr = node.getattribute local n_setfield = node.setfield local n_setattr = n_setfield @@ -127,7 +129,7 @@ nodes.getfield = n_getfield nodes.setfield = n_setfield nodes.getattr = n_getattr nodes.setattr = n_setattr -nodes.takeattr = nodes.unset_attribute +nodes.takeattr = nodes.unsetattribute local function n_getid (n) return n_getfield(n,"id") end local function n_getsubtype(n) return n_getfield(n,"subtype") end @@ -191,12 +193,12 @@ nodes.setlink = n_setlink nodes.getbox = node.getbox or tex.getbox nodes.setbox = node.setbox or tex.setbox -local n_flush_node = nodes.flush +local n_flushnode = nodes.flushnode local n_copy_node = nodes.copy -local n_copy_list = nodes.copy_list +local n_copy_list = nodes.copylist local n_find_tail = nodes.tail -local n_insert_after = nodes.insert_after -local n_insert_before = nodes.insert_before +local n_insertafter = nodes.insertafter +local n_insertbefore = nodes.insertbefore local n_slide = nodes.slide local n_remove_node = node.remove -- not yet nodes.remove @@ -207,7 +209,7 @@ local function remove(head,current,free_too) if not t then -- forget about it elseif free_too then - n_flush_node(t) + n_flushnode(t) t = nil else n_setboth(t) @@ -244,10 +246,10 @@ function nodes.replace(head,current,new) -- no head returned if false if head == current then head = new end - n_flush_node(current) + n_flushnode(current) return head, new else - n_flush_node(current) + n_flushnode(current) return new end end @@ -256,14 +258,14 @@ end function nodes.append(head,current,...) for i=1,select("#",...) do - head, current = n_insert_after(head,current,(select(i,...))) + head, current = n_insertafter(head,current,(select(i,...))) end return head, current end function nodes.prepend(head,current,...) for i=1,select("#",...) do - head, current = n_insert_before(head,current,(select(i,...))) + head, current = n_insertbefore(head,current,(select(i,...))) end return head, current end @@ -408,7 +410,7 @@ metatable.__sub = function(first,second) local tail = n_find_tail(first) for i=1,second do local prev = n_getprev(tail) - n_flush_node(tail) -- can become flushlist/flushnode + n_flushnode(tail) -- can become flushlist/flushnode if prev then tail = prev else @@ -443,7 +445,7 @@ metatable.__add = function(first,second) local head = second for i=1,first do local second = n_getnext(head) - n_flush_node(head) -- can become flushlist/flushnode + n_flushnode(head) -- can become flushlist/flushnode if second then head = second else diff --git a/tex/context/base/mkxl/node-mig.lmt b/tex/context/base/mkxl/node-mig.lmt index c19913509..cc0e4c981 100644 --- a/tex/context/base/mkxl/node-mig.lmt +++ b/tex/context/base/mkxl/node-mig.lmt @@ -6,8 +6,6 @@ if not modules then modules = { } end modules ['node-mig'] = { license = "see context related readme files" } --- todo: insert_after - local format = string.format local trace_migrations = false trackers.register("nodes.migrations", function(v) trace_migrations = v end) diff --git a/tex/context/base/mkxl/node-nut.lmt b/tex/context/base/mkxl/node-nut.lmt index 9bd7b1889..d8dfbdb9e 100644 --- a/tex/context/base/mkxl/node-nut.lmt +++ b/tex/context/base/mkxl/node-nut.lmt @@ -26,52 +26,57 @@ local glyph_code = nodecodes.glyph local tonode = direct.tonode local tonut = direct.todirect -local is_node = direct.is_node -local is_nut = direct.is_direct +local isnode = direct.isnode +local isnut = direct.isdirect +local isdirect = direct.isdirect local d_remove_node = direct.remove -local d_flush_node = direct.flush_node +local d_flushnode = direct.flushnode local d_getnext = direct.getnext local d_getprev = direct.getprev local d_getid = direct.getid local d_getlist = direct.getlist local d_find_tail = direct.tail -local d_insert_after = direct.insert_after -local d_insert_before = direct.insert_before +local d_insertafter = direct.insertafter +local d_insertbefore = direct.insertbefore local d_slide = direct.slide local d_traverse = direct.traverse local d_setlink = direct.setlink local d_getboth = direct.getboth local nuts = { - check_discretionaries = direct.check_discretionaries, + addmargins = direct.addmargins, + addxoffset = direct.addxoffset, + addxymargins = direct.addxymargins, + addyoffset = direct.addyoffset, + append = direct.append, + checkdiscretionaries = direct.checkdiscretionaries, collapsing = direct.collapsing, copy = direct.copy, - copy_list = direct.copy_list, - copy_node = direct.copy, - copy_only = direct.copy_only or direct.copy, + copynode = direct.copy, + copylist = direct.copylist, + copyonly = direct.copyonly, count = direct.count, - current_attributes = direct.current_attributes, + currentattributes = direct.currentattributes, delete = direct.delete, dimensions = direct.dimensions, - naturalhsize = direct.naturalhsize, - naturalwidth = direct.naturalwidth, - effective_glue = direct.effective_glue, - end_of_math = direct.end_of_math, + effectiveglue = direct.effectiveglue, + endofmath = direct.endofmath, exchange = direct.exchange, - find_attribute = direct.find_attribute, - first_glyph = direct.first_glyph, - flatten_discretionaries = direct.flatten_discretionaries, - flush = d_flush_node, - flush_components = direct.flush_components, - flush_list = direct.flush_list, - flush_node = direct.flush_node, + findattribute = direct.findattribute, + findnode = direct.findnode, + firstglyph = direct.firstglyph, + flattendiscretionaries = direct.flattendiscretionaries, + flush = d_flushnode, + flushlist = direct.flushlist, + flushnode = d_flushnode, free = direct.free, - getsynctexfields = direct.get_synctex_fields, - getattr = direct.get_attribute, - getattrs = direct.get_attributes, + getattr = direct.getattribute, + getattribute = direct.getattribute, getattributelist = direct.getattributelist, + getattributes = direct.getattributes, getattrlist = direct.getattributelist, + getattrs = direct.getattributes, getboth = d_getboth, getbox = direct.getbox, getboxglue = direct.getglue, @@ -83,17 +88,19 @@ local nuts = { getdir = direct.getdir, getdirection = direct.getdirection, getdisc = direct.getdisc, - getdiscretionary = direct.getdisc, getdiscpart = direct.getdiscpart, + getdiscretionary = direct.getdisc, getexpansion = direct.getexpansion, getfam = direct.getfam, getfield = direct.getfield, getfont = direct.getfont, getglue = direct.getglue, getglyphdata = direct.getglyphdata, + getglyphdimensions = direct.getglyphdimensions, getheight = direct.getheight, getid = d_getid, getkern = direct.getkern, + getkerndimension = direct.getkerndimension, getlang = direct.getlanguage,-- will become obsolete getlanguage = direct.getlanguage, getleader = direct.getleader, @@ -102,22 +109,16 @@ local nuts = { getnormalizedline = direct.getnormalizedline, getnucleus = direct.getnucleus, getoffsets = direct.getoffsets, - -- getxyoffsets = direct.getxyoffsets, - getscale = direct.getscale, - getscales = direct.getscales, - getxscale = direct.getxscale, - getyscale = direct.getyscale, - xscaled = direct.xscaled, - yscaled = direct.yscaled, - getxyscales = direct.getxyscales, - getorientation = direct.getorientation, getoptions = direct.getoptions, + getorientation = direct.getorientation, getpenalty = direct.getpenalty, getpost = direct.getpost, getpre = direct.getpre, getprev = d_getprev, getreplace = direct.getreplace, getruledata = direct.getdata, -- obsolete when we have the split + getscale = direct.getscale, + getscales = direct.getscales, getscript = direct.setscript, getshift = direct.getshift, getstate = direct.getstate, @@ -127,50 +128,56 @@ local nuts = { getsup = direct.getsup, getsuppre = direct.getsuppre, getsurround = direct.getkern, + getsynctexfields = direct.getsynctexfields, gettotal = direct.gettotal, getvalue = direct.getdata, -- obsolete getwhd = direct.getwhd, getwidth = direct.getwidth, - has_attribute = direct.has_attribute, - has_dimensions = direct.has_dimensions, - has_field = direct.has_field, - has_glyph = direct.has_glyph or direct.first_glyph, + getxscale = direct.getxscale, + getxyscales = direct.getxyscales, + getyscale = direct.getyscale, + hasattribute = direct.hasattribute, + hasdimensions = direct.hasdimensions, + hasfield = direct.hasfield, + hasglyph = direct.hasglyph, + hasglyphoption = direct.hasglyphoption, hpack = direct.hpack, hyphenating = direct.hyphenating, - insert_after = d_insert_after, - insert_before = d_insert_before, - is_direct = is_direct, - is_node = is_node, - is_nut = direct.is_direct, - is_zero_glue = direct.is_zero_glue, - ischar = direct.is_char, - isprevchar = direct.is_prev_char, - isnextchar = direct.is_next_char, - isprevglyph = direct.is_prev_glyph, - isnextglyph = direct.is_next_glyph, - isglyph = direct.is_glyph, + ignoremathskip = direct.ignoremathskip, + insertafter = d_insertafter, + insertbefore = d_insertbefore, + isdirect = isdirect, + isnode = isnode, + isnut = isdirect, + ischar = direct.ischar, + isglyph = direct.isglyph, + isnextchar = direct.isnextchar, + isnextglyph = direct.isnextglyph, + isprevchar = direct.isprevchar, + isprevglyph = direct.isprevglyph, + iszeroglue = direct.iszeroglue, kerning = direct.kerning, - last_node = direct.last_node, + lastnode = direct.lastnode, length = direct.length, ligaturing = direct.ligaturing, + makextensible = direct.makextensible, migrate = direct.migrate, - mlist_to_hlist = direct.mlist_to_hlist, + mlisttohlist = direct.mlisttohlist, + naturalhsize = direct.naturalhsize, + naturalwidth = direct.naturalwidth, new = direct.new, - protect_glyph = direct.protect_glyph, - protect_glyphs = direct.protect_glyphs, - protrusion_skippable = direct.protrusion_skippable, + protectglyph = direct.protectglyph, + protectglyphs = direct.protectglyphs, + protrusionskippable = direct.protrusionskippable, rangedimensions = direct.rangedimensions, - getglyphdimensions = direct.getglyphdimensions, - getkerndimension = direct.getkerndimension, remove = d_remove_node, reverse = direct.reverse, - set_attribute = direct.set_attribute, - addmargins = direct.addmargins, - addxymargins = direct.addxymargins, - setattr = direct.set_attribute, - setattrs = direct.set_attributes, + setattr = direct.setattribute, + setattr = direct.setattribute, + setattribute = direct.setattribute, setattributelist = direct.setattributelist, setattrlist = direct.setattributelist, + setattrs = direct.setattributes, setboth = direct.setboth, setbox = direct.setbox, setboxglue = direct.setglue, @@ -181,8 +188,8 @@ local nuts = { setdir = direct.setdir, setdirection = direct.setdirection, setdisc = direct.setdisc, - setdiscretionary = direct.setdisc, setdiscpart = direct.setdiscpart, + setdiscretionary = direct.setdisc, setexpansion = direct.setexpansion, setfam = direct.setfam, setfield = direct.setfield, @@ -198,19 +205,17 @@ local nuts = { setlist = direct.setlist, setnext = direct.setnext, setnucleus = direct.setnucleus, - setscale = direct.setscale or direct.setscales, - setscales = direct.setscales, setoffsets = direct.setoffsets, - addxoffset = direct.addxoffset, - addyoffset = direct.addyoffset, - setorientation = direct.setorientation, setoptions = direct.setoptions, + setorientation = direct.setorientation, setpenalty = direct.setpenalty, setpost = direct.setpost, setpre = direct.setpre, setprev = direct.setprev, setreplace = direct.setreplace, setruledata = direct.setdata, -- obsolete when we have the split + setscale = direct.setscale or direct.setscales, + setscales = direct.setscales, setscript = direct.getscript, setshift = direct.setshift, setsplit = direct.setsplit, @@ -221,44 +226,46 @@ local nuts = { setsup = direct.setsup, setsuppre = direct.setsuppre, setsurround = direct.setkern, - setsynctexfields = direct.set_synctex_fields, + setsynctexfields = direct.setsynctexfields, setvalue = direct.setdata, -- obsolete setwhd = direct.setwhd, setwidth = direct.setwidth, + show = direct.show, slide = d_slide, - start_of_par = direct.start_of_par, + startofpar = direct.startofpar, tail = d_find_tail, - takeattr = direct.unset_attribute, -- ? + takeattr = direct.unsetattribute, -- ? tonode = tonode, tonut = tonut, tostring = direct.tostring, traverse = d_traverse, - traverse_char = direct.traverse_char, - traverse_glyph = direct.traverse_glyph, - traverse_id = direct.traverse_id, - traverse_list = direct.traverse_list, - traverse_content = direct.traverse_content, - unprotect_glyph = direct.unprotect_glyph, - unprotect_glyphs = direct.unprotect_glyphs, - unset_attribute = direct.unset_attribute, - unset_attributes = direct.unset_attributes, + traversechar = direct.traversechar, + traversecontent = direct.traversecontent, + traverseglyph = direct.traverseglyph, + traverseid = direct.traverseid, + traverselist = direct.traverselist, + unprotectglyph = direct.unprotectglyph, + unprotectglyphs = direct.unprotectglyphs, + unsetattribute = direct.unsetattribute, + unsetattributes = direct.unsetattributes, usedlist = direct.usedlist, - uses_font = direct.uses_font, + usesfont = direct.usesfont, + verticalbreak = direct.verticalbreak, vpack = direct.vpack, write = direct.write, - append = direct.append, - has_glyph_option = direct.has_glyph_option, - show = direct.show, + xscaled = direct.xscaled, + yscaled = direct.yscaled, + -- getxyoffsets = direct.getxyoffsets, } -nodes.nuts = nuts +nodes.nuts = nuts -nodes.is_node = is_node -nodes.is_direct = is_nut -nodes.is_nut = is_nut +nodes.isnode = isnode +nodes.isdirect = isnut +nodes.isnut = isnut -nodes.tonode = tonode -nodes.tonut = tonut +nodes.tonode = tonode +nodes.tonut = tonut function nuts.delete(head,current) return d_remove_node(head,current,true) @@ -276,10 +283,10 @@ function nuts.replace(head,current,new) -- no head returned if false if head == current then head = new end - d_flush_node(current) + d_flushnode(current) return head, new else - d_flush_node(current) + d_flushnode(current) return new end end @@ -311,14 +318,14 @@ end function nuts.append(head,current,...) for i=1,select("#",...) do - head, current = d_insert_after(head,current,(select(i,...))) + head, current = d_insertafter(head,current,(select(i,...))) end return head, current end function nuts.prepend(head,current,...) for i=1,select("#",...) do - head, current = d_insert_before(head,current,(select(i,...))) + head, current = d_insertbefore(head,current,(select(i,...))) end return head, current end @@ -365,7 +372,7 @@ function nuts.vianodes(f) return function(n,...) return tonut (f(tonode(n),...)) nodes.vianuts = nuts.vianuts nodes.vianodes = nuts.vianodes -function nodes.insert_list_after(h,c,n) +function nodes.insertlistafter(h,c,n) local t = n_tail(n) if c then local cn = n_getnext(c) @@ -383,7 +390,7 @@ function nodes.insert_list_after(h,c,n) return n, t end -function nuts.insert_list_after(h,c,n) +function nuts.insertlistafter(h,c,n) local t = d_tail(n) if c then local cn = d_getnext(c) @@ -509,7 +516,7 @@ nuts.nestedtracedslide = nestedtracedslide -- this might move -local propertydata = direct.get_properties_table(true) +local propertydata = direct.getpropertiestable(true) local getattr = nuts.getattr local setattr = nuts.setattr diff --git a/tex/context/base/mkxl/node-pro.lmt b/tex/context/base/mkxl/node-pro.lmt index e736f2b76..e84730b87 100644 --- a/tex/context/base/mkxl/node-pro.lmt +++ b/tex/context/base/mkxl/node-pro.lmt @@ -69,7 +69,6 @@ processors.enabled = true -- this will become a proper state (like trackers) do - -- local has_glyph = nodes.has_glyph local count_nodes = nodes.countall local texget = tex.get @@ -79,7 +78,7 @@ do -- We've set \hlistcallbackmode=1 so glyph checking happens at the other end! local function pre_linebreak_filter(head,groupcode) - -- local found = force_processors or has_glyph(head) + -- local found = force_processors or hasglyph(head) -- if found then if trace_callbacks then local before = count_nodes(head,true) @@ -97,7 +96,7 @@ do end local function hpack_filter(head,groupcode,size,packtype,direction,attributes) - -- local found = force_processors or has_glyph(head) + -- local found = force_processors or hasglyph(head) -- if found then -- -- yes or no or maybe an option @@ -150,7 +149,7 @@ do end do - -- Beware, these are packaged boxes so no first_glyph test needed. Maybe some day I'll add a hash + -- Beware, these are packaged boxes so no firstglyph test needed. Maybe some day I'll add a hash -- with valid groupcodes. Watch out, much can pass twice, for instance vadjust passes two times, local actions = tasks.actions("finalizers") -- head, where diff --git a/tex/context/base/mkxl/node-ref.lmt b/tex/context/base/mkxl/node-ref.lmt index c02a37dd1..78ff824c9 100644 --- a/tex/context/base/mkxl/node-ref.lmt +++ b/tex/context/base/mkxl/node-ref.lmt @@ -80,7 +80,8 @@ local getdimensions = nuts.dimensions local getrangedimensions = nuts.rangedimensions local traverse = nuts.traverse local find_node_tail = nuts.tail -local start_of_par = nuts.start_of_par + +local startofpar = nuts.startofpar local nodecodes = nodes.nodecodes local gluecodes = nodes.gluecodes @@ -109,7 +110,7 @@ local new_rule = nodepool.rule local new_kern = nodepool.kern local new_hlist = nodepool.hlist -local flush_node = nuts.flush +local flushnode = nuts.flush local tosequence = nodes.tosequence @@ -147,7 +148,7 @@ local inject_areas do local v = vpack_list(start) -- use helper but happens seldom anyway so ... local w, h, d = getwhd(v) setlist(v) -- not needed - flush_node(v) + flushnode(v) if temp then setnext(stop,temp) end @@ -352,7 +353,7 @@ local inject_areas do txtdir = not pop and direction -- we might need a stack goto NEXT elseif id == par_code then - if start_of_par(current) then + if startofpar(current) then pardir = getdirection(current) end goto NEXT diff --git a/tex/context/base/mkxl/node-res.lmt b/tex/context/base/mkxl/node-res.lmt index 9c291fcbf..fbf52ae3b 100644 --- a/tex/context/base/mkxl/node-res.lmt +++ b/tex/context/base/mkxl/node-res.lmt @@ -78,7 +78,7 @@ local setdata = nuts.setdata local setruledata = nuts.setruledata local setvalue = nuts.setvalue -local copy_nut = nuts.copy_only or nuts.copy +local copy_nut = nuts.copyonly local new_nut = nuts.new local flush_nut = nuts.flush @@ -542,22 +542,22 @@ lua.registerfinalizer(cleanup, "cleanup reserved nodes") do - local glyph = glyph - local traverse_id = nuts.traverse_id + local glyph = glyph + local traverseid = nuts.traverseid - local traversers = table.setmetatableindex(function(t,k) - local v = traverse_id(type(k) == "number" and k or nodecodes[k],glyph) + local traversers = table.setmetatableindex(function(t,k) + local v = traverseid(type(k) == "number" and k or nodecodes[k],glyph) t[k] = v return v end) -- these are special: - traversers.node = nuts.traverse (glyph) - traversers.char = nuts.traverse_char (glyph) - traversers.glyph = nuts.traverse_glyph (glyph) - traversers.list = nuts.traverse_list (glyph) - traversers.content = nuts.traverse_content(glyph) + traversers.node = nuts.traverse (glyph) + traversers.char = nuts.traversechar (glyph) + traversers.glyph = nuts.traverseglyph (glyph) + traversers.list = nuts.traverselist (glyph) + traversers.content = nuts.traversecontent(glyph) nuts.traversers = traversers diff --git a/tex/context/base/mkxl/node-rul.lmt b/tex/context/base/mkxl/node-rul.lmt index a95c5272d..a1857bd6e 100644 --- a/tex/context/base/mkxl/node-rul.lmt +++ b/tex/context/base/mkxl/node-rul.lmt @@ -55,15 +55,15 @@ local getruledata = nuts.getruledata local isglyph = nuts.isglyph -local flushlist = nuts.flush_list -local effective_glue = nuts.effective_glue -local insert_node_after = nuts.insert_after -local insert_node_before = nuts.insert_before +local flushlist = nuts.flushlist +local effectiveglue = nuts.effectiveglue +local insertnodeafter = nuts.insertafter +local insertnodebefore = nuts.insertbefore local find_tail = nuts.tail local setglue = nuts.setglue local getrangedimensions = nuts.rangedimensions local hpack_nodes = nuts.hpack -local copy_list = nuts.copy_list +local copylist = nuts.copylist local nextlist = nuts.traversers.list local nextglue = nuts.traversers.glue @@ -312,7 +312,7 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a setattr(r,a_viewerlayer,layer) end if empty then - head = insert_node_before(head,f,r) + head = insertnodebefore(head,f,r) setlink(r,getnext(l)) setprev(f) setnext(l) @@ -320,12 +320,12 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a else local k = new_kern(-wd) if foreground then - insert_node_after(head,l,k) - insert_node_after(head,k,r) + insertnodeafter(head,l,k) + insertnodeafter(head,k,r) l = r else - head = insert_node_before(head,f,r) - insert_node_after(head,r,k) + head = insertnodebefore(head,f,r) + insertnodeafter(head,r,k) end end if trace_ruled then @@ -352,7 +352,7 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a else local tx = d.text if tx then - local l = copy_list(tx) + local l = copylist(tx) if d["repeat"] == v_yes then l = new_leader(wd,l) setattrlist(l,tx) @@ -560,7 +560,7 @@ function linefillers.handler(head) if location == v_left or location == v_both then local indentation = is and getwidth(is) or 0 local leftfixed = ls and getwidth(ls) or 0 - local lefttotal = ls and effective_glue(ls,current) or 0 + local lefttotal = ls and effectiveglue(ls,current) or 0 local width = lefttotal - (leftlocal and leftfixed or 0) + indentation - distance if width > threshold then if is then @@ -568,17 +568,17 @@ function linefillers.handler(head) end setglue(ls,leftlocal and getwidth(ls) or nil) if distance > 0 then - insert_node_after(list,ls,new_kern(distance)) + insertnodeafter(list,ls,new_kern(distance)) end - insert_node_after(list,ls,linefiller(current,data,width,"left")) + insertnodeafter(list,ls,linefiller(current,data,width,"left")) end end -- if location == v_right or location == v_both then local rightfixed = rs and getwidth(rs) or 0 - local righttotal = rs and effective_glue(rs,current) or 0 + local righttotal = rs and effectiveglue(rs,current) or 0 local parfixed = pr and getwidth(pr) or 0 - local partotal = pr and effective_glue(pr,current) or 0 + local partotal = pr and effectiveglue(pr,current) or 0 local width = righttotal - (rightlocal and rightfixed or 0) + partotal - distance if width > threshold then if pr then @@ -586,9 +586,9 @@ function linefillers.handler(head) end setglue(rs,rightlocal and getwidth(rs) or nil) if distance > 0 then - insert_node_before(list,rs,new_kern(distance)) + insertnodebefore(list,rs,new_kern(distance)) end - insert_node_before(list,rs,linefiller(current,data,width,"right")) + insertnodebefore(list,rs,linefiller(current,data,width,"right")) end end else diff --git a/tex/context/base/mkxl/node-scn.lmt b/tex/context/base/mkxl/node-scn.lmt index 3c1dd2d88..55f39a74b 100644 --- a/tex/context/base/mkxl/node-scn.lmt +++ b/tex/context/base/mkxl/node-scn.lmt @@ -21,8 +21,6 @@ local getsubtype = nuts.getsubtype local getlist = nuts.getlist local setlist = nuts.setlist -local end_of_math = nuts.end_of_math - local nodecodes = nodes.nodecodes local gluecodes = nodes.gluecodes local kerncodes = nodes.kerncodes diff --git a/tex/context/base/mkxl/node-ser.lmt b/tex/context/base/mkxl/node-ser.lmt index 8fcbb31e4..c14a3826f 100644 --- a/tex/context/base/mkxl/node-ser.lmt +++ b/tex/context/base/mkxl/node-ser.lmt @@ -14,15 +14,11 @@ local allocate = utilities.storage.allocate local context = context local nodes = nodes -local node = node - -local getfields = node.fields - -local is_node = nodes.is_node +local getfields = nodes.fields +local isnode = nodes.isnode local nodecodes = nodes.nodecodes local subtypes = nodes.subtypes - local tonode = nodes.tonode local tonut = nodes.tonut @@ -109,7 +105,7 @@ end nodes.astable = astable -setinspector("node",function(v) if is_node(v) then printtable(astable(v),tostring(v)) return true end end) +setinspector("node",function(v) if isnode(v) then printtable(astable(v),tostring(v)) return true end end) local function to_table(n,flat,verbose,noattributes,done) local d = tonut(n) diff --git a/tex/context/base/mkxl/node-shp.lmt b/tex/context/base/mkxl/node-shp.lmt index 64508ecc7..8a0a26510 100644 --- a/tex/context/base/mkxl/node-shp.lmt +++ b/tex/context/base/mkxl/node-shp.lmt @@ -34,7 +34,7 @@ function handlers.finalizebox(box) actions(getbox(box)) -- nut end -handlers.cleanuppage = nuts.flatten_discretionaries +handlers.cleanuppage = nuts.flattendiscretionaries -- interface diff --git a/tex/context/base/mkxl/node-syn.lmt b/tex/context/base/mkxl/node-syn.lmt index ce5f0d2dd..5b0a92a38 100644 --- a/tex/context/base/mkxl/node-syn.lmt +++ b/tex/context/base/mkxl/node-syn.lmt @@ -162,8 +162,8 @@ local fontkern_code = kerncodes.fontkern local cancel_code = nodes.dircodes.cancel -local insert_before = nuts.insert_before -local insert_after = nuts.insert_after +local insertbefore = nuts.insertbefore +local insertafter = nuts.insertafter local nodepool = nuts.pool local new_latelua = nodepool.latelua @@ -173,7 +173,7 @@ local new_kern = nodepool.kern local getdimensions = nuts.dimensions local getrangedimensions = nuts.rangedimensions -local getsynctexfields = nuts.getsynctexfields or nuts.get_synctex_fields +local getsynctexfields = nuts.getsynctexfields local forcesynctextag = tex.forcesynctextag or tex.force_synctex_tag local forcesynctexline = tex.forcesynctexline or tex.force_synctex_line local getsynctexline = tex.getsynctexline or tex.get_synctex_line @@ -396,7 +396,7 @@ local x_hlist do x_hlist = function(head,current,t,l,w,h,d) if filehandle then - return insert_before(head,current,new_latelua(function() doaction(t,l,w,h,d) end)) + return insertbefore(head,current,new_latelua(function() doaction(t,l,w,h,d) end)) else return head end @@ -432,8 +432,8 @@ local function inject(head,first,last,tag,line) d = depth end if trace then - head = insert_before(head,first,new_rule(w,fulltrace and h or traceheight,fulltrace and d or tracedepth)) - head = insert_before(head,first,new_kern(-w)) + head = insertbefore(head,first,new_rule(w,fulltrace and h or traceheight,fulltrace and d or tracedepth)) + head = insertbefore(head,first,new_kern(-w)) end head = x_hlist(head,first,tag,line,w,h,d) return head @@ -499,8 +499,8 @@ local function inject(parent,head,first,last,tag,line) d = depth end if trace then - head = insert_before(head,first,new_rule(w,fulltrace and h or traceheight,fulltrace and d or tracedepth)) - head = insert_before(head,first,new_kern(-w)) + head = insertbefore(head,first,new_rule(w,fulltrace and h or traceheight,fulltrace and d or tracedepth)) + head = insertbefore(head,first,new_kern(-w)) end head = x_hlist(head,first,tag,line,w,h,d) return head diff --git a/tex/context/base/mkxl/node-tra.lmt b/tex/context/base/mkxl/node-tra.lmt index 6060522be..8ed14b305 100644 --- a/tex/context/base/mkxl/node-tra.lmt +++ b/tex/context/base/mkxl/node-tra.lmt @@ -52,7 +52,6 @@ local isglyph = nuts.isglyph local getdirection = nuts.getdirection local getwidth = nuts.getwidth -local flush_list = nuts.flush_list local count_nodes = nuts.countall local used_nodes = nuts.usedlist @@ -86,7 +85,7 @@ local whatsit_code = nodecodes.whatsit local dimenfactors = number.dimenfactors local formatters = string.formatters -local start_of_par = nuts.start_of_par +local startofpar = nuts.startofpar -- this will be reorganized: @@ -157,7 +156,7 @@ local function tosequence(start,stop,compact) elseif id == dir_code then local d, p = getdirection(start) n = n + 1 ; t[n] = "[<" .. (p and "-" or "+") .. d .. ">]" -- todo l2r etc - elseif id == par_code and start_of_par(current) then + elseif id == par_code and startofpar(current) then n = n + 1 ; t[n] = "[<" .. getdirection(start) .. ">]" -- todo l2r etc elseif compact then n = n + 1 ; t[n] = "[]" diff --git a/tex/context/base/mkxl/pack-rul.lmt b/tex/context/base/mkxl/pack-rul.lmt index 62f305cba..bac21e91c 100644 --- a/tex/context/base/mkxl/pack-rul.lmt +++ b/tex/context/base/mkxl/pack-rul.lmt @@ -60,7 +60,7 @@ local getboxglue = nuts.getglue local hpack = nuts.hpack local getdimensions = nuts.dimensions local naturalhsize = nuts.naturalhsize -local flush_node = nuts.flush +local flushnode = nuts.flush local traversers = nuts.traversers local nexthlist = traversers.hlist @@ -143,7 +143,7 @@ local function doreshapeframedbox(n) local set, order, sign = getboxglue(p) setboxglue(h,set,order,sign) setlist(p) - flush_node(p) + flushnode(p) elseif checkformath and subtype == equationlist_code then -- display formulas use a shift if nofnonzero == 1 then @@ -177,7 +177,7 @@ local function doreshapeframedbox(n) texsetdimen("global","framedaveragewidth",averagewidth) end -local function doanalyzeframedbox(n) -- traverse_list +local function doanalyzeframedbox(n) local box = getbox(n) local noflines = 0 local firstheight = nil diff --git a/tex/context/base/mkxl/page-ini.lmt b/tex/context/base/mkxl/page-ini.lmt new file mode 100644 index 000000000..bb5ea2b5d --- /dev/null +++ b/tex/context/base/mkxl/page-ini.lmt @@ -0,0 +1,356 @@ +if not modules then modules = { } end modules ['page-ini'] = { + version = 1.001, + comment = "companion to page-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- Some day I need to make this more efficient. + +local tonumber, rawget, rawset, type, next = tonumber, rawget, rawset, type, next +local match = string.match +local sort, tohash, insert, remove, sortedkeys = table.sort, table.tohash, table.insert, table.remove, table.sortedkeys +local settings_to_array, settings_to_hash = utilities.parsers.settings_to_array, utilities.parsers.settings_to_hash + +local texgetcount = tex.getcount + +local tonut = nodes.tonut +local nextlist = nodes.nuts.traversers.list +local texlists = tex.lists + +local context = context +local ctx_doif = commands.doif +local ctx_doifelse = commands.doifelse + +local implement = interfaces.implement + +local data = table.setmetatableindex("table") +local last = 0 +local pages = structures.pages +local autolist = { } +local report = logs.reporter("pages","mark") +local active = false + +local trace = false trackers.register("pages.mark",function(v) trace = v end) + +function pages.mark(name,list,settings) + active = true + -- + local realpage = texgetcount("realpageno") + if type(settings) == "string" then + settings = settings_to_hash(settings) + end + if not list or list == "" then + if trace then + report("marking current page %i as %a",realpage,name) + end + data[realpage][name] = settings or true + return + end + if type(list) == "string" then + list = settings_to_array(list) + end + if type(list) == "table" then + for i=1,#list do + local page = list[i] + local sign = false + if type(page) == "string" then + local f, t = match(page,"(%d+)[:%-](%d+)") + if f and t then + f, t = tonumber(f), tonumber(t) + if f and t and f <= t then + if trace then + report("marking page %i upto %i as %a",f,t,name) + end + for page=f,t do + data[page][name] = settings or true + end + end + page = false + else + local s, p = match(page,"([%+%-])(%d+)") + if s then + sign, page = s, p + end + end + end + if page then + page = tonumber(page) + if page then + if sign == "+" then + page = realpage + page + end + if sign == "-" then + report("negative page numbers are not supported") + else + if trace then + report("marking page %i as %a",page,name) + end + data[page][name] = settings or true + end + end + end + end + else + if trace then + report("marking current page %i as %a",realpage,name) + end + data[realpage][name] = settings or true + end +end + +local tobemarked = { } + +function pages.markedlist(realpage) + if active and realpage then + local m = rawget(tobemarked,realpage) or rawget(data,realpage) + return m and next(m) and sortedkeys(m) + end +end + +local function marked(name) + if active then + local realpage = texgetcount("realpageno") + if last ~= 0 then + for i=last,realpage-1 do + -- print(last) + local di = data[i] + if di then + tobemarked[i] = di + rawset(data,i,nil) + end + end + last = 0 -- needs checking + end + local pagedata = rawget(data,realpage) + return pagedata and pagedata[name] and true or false + else + return false + end +end + +local function markedparameter(name,key) + if active then + local pagedata = rawget(data,texgetcount("realpageno")) + if pagedata then + pagedata = pagedata[name] + if pagedata then + pagedata = pagedata[key] + end + end + return pagedata + end +end + +local function toranges(marked) + local list = { } + local size = #marked + if size > 0 then + local first = marked[1] + local last = first + for i=2,size do + local page = marked[i] + if page > last + 1 then + list[#list+1] = { first, last } + first = page + end + last = page + end + list[#list+1] = { first, last } + -- + active = true + end + return list +end + +local function allmarked(list) + if active and list then + local collected = pages.collected + if collected then + if type(list) == "string" then + list = settings_to_hash(list) + elseif type(list) == "table" and #list > 0 then + list = tohash(list) + end + if type(list) == "table" then + local found = { } + for name in next, list do + for page, list in next, data do + if list[name] and collected[page] then + found[#found+1] = page + end + end + end + if #found > 0 then + sort(found) + if trace then + local ranges = toranges(found) + for i=1,#ranges do + local range = ranges[i] + local first = range[1] + local last = range[2] + if first == last then + report("marked page : %i",first) + else + report("marked range: %i upto %i",first,last) + end + end + end + return found + end + end + end + end +end + +pages.marked = marked +pages.toranges = toranges +pages.allmarked = allmarked + +-- An alternative is to use an attribute and identify the state by parsing the node +-- list but that's a bit overkill for a hardly used feature like this. + +-- Page actions are bound to a real page. When we set one, we need to bind to the +-- current page unless we just flushed. So we also need to check the current page. + +-- \page ... \start : sync realpage +-- \page \start : sync realpage +-- \page \stop : reset synced because no content yet +-- \page ... \stop : keep sync + +local function autopageaction() + if active then + local nofauto = #autolist + if nofauto > 0 then + local realpage = texgetcount("realpageno") + for i=1,nofauto do + local entry = autolist[i] + local names = entry[1] + local settings = entry[2] + for j=1,#names do + local name = names[j] + local list = data[realpage] + if not list[name] then + if trace then + report("automatically marking page %i as %a",realpage,name) + end + list[name] = settings or true + end + end + end + end + end +end + +local function startmarked(name,settings) + active = true + -- + insert(autolist, { settings_to_array(name), settings_to_hash(settings) }) + autopageaction(true) +end + +local function stopmarked() + local nofauto = #autolist + if nofauto > 0 then + if not texlists.pagehead then + local realpage = texgetcount("realpageno") + for i=1,nofauto do + local entry = autolist[i] + local names = entry[1] + for j=1,#names do + local name = names[j] + local list = data[realpage] + if list[name] then + if trace then + report("automatically unmarking page %i as %a",realpage,name) + end + list[name] = nil + end + end + end + end + remove(autolist) + end +end + +implement { + name = "checkmarkedpages", + protected = true, + public = true, + actions = autopageaction, +} + +implement { + name = "markpage", + arguments = "3 strings", + actions = pages.mark +} + +implement { + name = "doifelsemarkedpage", + arguments = "argument", + protected = true, + public = true, + actions = { marked, ctx_doifelse } +} + +implement { + name = "doifmarkedpage", + arguments = "argument", + protected = true, + public = true, + actions = { marked, ctx_doif } +} + +implement { + name = "markedpageparameter", + arguments = "2 arguments", + public = true, + actions = function(name,key) + local value = markedparameter(name,key) + if value then + context(value) + end + end +} + +implement { + name = "markedpages", + arguments = "string", + actions = function(name) + local t = allmarked(name) + if t then + context("%,t",t) + end + end +} + +implement { + name = "startmarkpages", + arguments = "2 strings", + actions = startmarked, +} + +implement { + name = "stopmarkpages", + protected = true, + public = true, + actions = stopmarked, +} + +implement { + name = "doifelsependingpagecontent", + actions = function() + local h = texlists.contrib_head + -- local t = texlists.contrib_tail + local p = false + if h then + for n in nextlist, tonut(h) do + p = true + break + end + end + ctx_doifelse(p) + end, +} diff --git a/tex/context/base/mkxl/page-ini.mkxl b/tex/context/base/mkxl/page-ini.mkxl index 0a0993d44..fe07f9fb5 100644 --- a/tex/context/base/mkxl/page-ini.mkxl +++ b/tex/context/base/mkxl/page-ini.mkxl @@ -13,7 +13,7 @@ \writestatus{loading}{ConTeXt Page Macros / Initializations} -\registerctxluafile{page-ini}{} +\registerctxluafile{page-ini}{autosuffix} %D The \type {\processpage} command has become obsolete. It's original %D purpose was to flush only parts of a document but nowadays we have @@ -336,11 +336,18 @@ % todo: just define at the lua end ... less hassle -\permanent\tolerant\protected\def\markpage [#1]#*[#2]{\clf_markpage {#1}{#2}} -\permanent \def\markedpages [#1]{\clf_markedpages {#1}} % expandable -\permanent\protected \def\doifelsemarkedpage#1{\clf_doifelsemarkedpage{#1}} -\permanent\protected \def\startmarkpages [#1]{\clf_startmarkpages {#1}} -\permanent\protected \def\stopmarkpages {\clf_stopmarkpages } +\permanent\tolerant\protected\def\markpage [#1]#*[#2]#*[#3]{\clf_markpage{#1}{#2}{#3}} +\permanent\tolerant\protected\def\startmarkpages [#1]#*[#2]{\clf_startmarkpages{#1}{#2}} +%permanent \protected\def\stopmarkpages {\clf_stopmarkpages} +\permanent \def\markedpages [#1]{\clf_markedpages{#1}} % expandable +%permanent \protected\def\doifmarkedpage #1{\clf_doifmarkedpage{#1}} +%permanent \protected\def\doifelsemarkedpage #1{\clf_doifelsemarkedpage{#1}} +% \def\markedpageparameter #1#2{\clf_markedpageparameter{#1}{#2}} +%permanent \protected\def\checkmarkedpages {\clf_checkmarkedpages} + +\appendtoks + \checkmarkedpages % defined at lua end +\to \everyaftershipout %D Experimental: diff --git a/tex/context/base/mkxl/page-mix.mkxl b/tex/context/base/mkxl/page-mix.mkxl index 86abaca2f..daafa4843 100644 --- a/tex/context/base/mkxl/page-mix.mkxl +++ b/tex/context/base/mkxl/page-mix.mkxl @@ -31,10 +31,6 @@ % offsets (inner ones, so we change the hsize ... needed with backgrounds % when no content we currently loose the page -% luatex buglet: -% -% \ctxlua{tex.setbox("global",0,node.hpack(nodes.pool.glyph("a",font.current())))}\box0 - \registerctxluafile{page-mix}{} \unprotect diff --git a/tex/context/base/mkxl/page-one.mkxl b/tex/context/base/mkxl/page-one.mkxl index a6890c8a6..4b4416fe1 100644 --- a/tex/context/base/mkxl/page-one.mkxl +++ b/tex/context/base/mkxl/page-one.mkxl @@ -111,6 +111,103 @@ % % we can also have bottom notes on top of bottom insertions +% \protected\def\page_one_command_package_contents#1#2% \box<n> \unvbox<n> % this one will be redone (checked) +% {\bgroup +% \strc_notes_check_if_bottom_present +% \d_page_one_natural_depth\dp#2\relax +% % we need to set the height as otherwise the shrink will not kick in so the following +% % no longer applies: +% % +% % \setbox\b_page_one_contents\vbox \ifconditional\c_notes_bottom_present to \textheight \fi +% % +% \setbox\b_page_one_contents\vbox to \textheight % probably no pack +% {\page_otr_command_flush_top_insertions +% % this is messy ... we will provide a more tight area (no big deal as we can +% % do that at the lua end) +% % \parfillskip\zeropoint +% \page_one_registered_text_area_a#1#2% \unvbox <box> +% % +% \ifgridsnapping +% \unskip % new per 2019-06-18, otherwise weird bottom floats +% \vkern\dimexpr\openstrutdepth-\d_page_one_natural_depth\relax +% \prevdepth\openstrutdepth +% \page_otr_command_flush_bottom_insertions +% \vfil +% \orelse\ifcase\bottomraggednessmode +% % ragged (default) +% \unskip % new per 2019-06-18, otherwise weird bottom floats +% \vkern\dimexpr\openstrutdepth-\d_page_one_natural_depth\relax +% \prevdepth\openstrutdepth +% % these have whitespace before but we can have some more options +% % like a \vfill or so +% \page_otr_command_flush_bottom_insertions +% \vfil +% \or +% % align (normal) +% \page_otr_command_flush_bottom_insertions +% \or +% % baseline +% \unskip % new per 2019-06-18, otherwise weird bottom floats +% \vkern\dimexpr\maxdepth-\d_page_one_natural_depth\relax +% \page_otr_command_flush_bottom_insertions +% \fi +% \fakepagenotes}% +% \page_one_command_package_show_state +% \ifconditional\c_notes_bottom_present +% \ifgridsnapping +% \ifcase\layoutlines +% \getrawnoflines\textheight +% \else +% \noflines\layoutlines +% \fi +% \scratchoffset\dimexpr\numexpr\noflines-\plusone\relax\lineheight+\topskip\relax +% \else +% \scratchoffset\ht\b_page_one_contents +% \fi +% \setbox\b_page_one_bottom_notes\hpack +% {\lower\scratchoffset\vbox{\placebottomnotes\par\kern\zeropoint}}% kerns makes notes sit on bottom % pack ? +% \smashbox\b_page_one_bottom_notes +% \ht\b_page_one_contents\zeropoint +% \page_one_registered_text_area_b +% {\vpack to \textheight +% {\box\b_page_one_contents +% \box\b_page_one_bottom_notes}}% +% \else +% \ht\b_page_one_contents\textheight +% \page_one_registered_text_area_b +% {\box\b_page_one_contents}% +% \fi +% \egroup} + +%D \starttyping +%D \setuplayout[height=middle] \showframe +%D +%D % \markpages[stretch][lines=2] % current page +%D +%D \starttext +%D \brokenpenalty 10000 \clubpenalty 20000 \widowpenalty 20000 +%D \dorecurse{10}{\samplefile{tufte}\par} \page +%D \startmarkpages[stretch][lines=2] +%D \dorecurse{10}{\samplefile{tufte}\par} \page +%D \stopmarkpages +%D \dorecurse{10}{\samplefile{tufte}\par} \page +%D \stoptext +%D \stoptyping + +\newcount\c_page_one_stretch % we use marked pages which actually slow down a little + +\def\page_one_check_stretch_contents + {\ifdim\dimexpr\textheight-\ht\b_page_one_contents\relax<\c_page_one_stretch\lineheight + \setbox\b_page_one_contents\vpack\bgroup + % no need to speed up low level + \scale[\c!height=\textheight,\c!width=\textwidth]{\box\b_page_one_contents}% + \egroup + \fi} + +\def\page_one_check_stretch_lines + {\edef\m_lines{\markedpageparameter\v!stretch\v!lines}% + \ifempty\m_lines\else\c_page_one_stretch\m_lines\fi} + \protected\def\page_one_command_package_contents#1#2% \box<n> \unvbox<n> % this one will be redone (checked) {\bgroup \strc_notes_check_if_bottom_present @@ -120,11 +217,14 @@ % % \setbox\b_page_one_contents\vbox \ifconditional\c_notes_bottom_present to \textheight \fi % - \setbox\b_page_one_contents\vbox to \textheight % probably no pack + \ifconditional\c_notes_bottom_present\else + \doifmarkedpage\v!stretch\page_one_check_stretch_lines + \fi + \setbox\b_page_one_contents\vbox \ifcase\c_page_one_stretch to \textheight\fi % probably no pack {\page_otr_command_flush_top_insertions % this is messy ... we will provide a more tight area (no big deal as we can % do that at the lua end) -% \parfillskip\zeropoint + % \parfillskip\zeropoint \page_one_registered_text_area_a#1#2% \unvbox <box> % \ifgridsnapping @@ -173,6 +273,9 @@ {\box\b_page_one_contents \box\b_page_one_bottom_notes}}% \else + \ifcase\c_page_one_stretch\else + \page_one_check_stretch_contents + \fi \ht\b_page_one_contents\textheight \page_one_registered_text_area_b {\box\b_page_one_contents}% diff --git a/tex/context/base/mkxl/page-smp.mkxl b/tex/context/base/mkxl/page-smp.mkxl index ccb0e989e..d560843e0 100644 --- a/tex/context/base/mkxl/page-smp.mkxl +++ b/tex/context/base/mkxl/page-smp.mkxl @@ -30,6 +30,7 @@ {\bgroup \setsimplecolumnshsize[#1]% \nopenalties + \enforced\permanent\protected\def\column{\vfill\break}% quick hack \setbox\scratchbox\vbox\bgroup \forgetall} % \blank[\v!disable] diff --git a/tex/context/base/mkxl/page-txt.mklx b/tex/context/base/mkxl/page-txt.mklx index f8db27f38..b03d704c8 100644 --- a/tex/context/base/mkxl/page-txt.mklx +++ b/tex/context/base/mkxl/page-txt.mklx @@ -884,10 +884,6 @@ \smashbox\b_page_layouts_element \box\b_page_layouts_element} -% \ifdefined\page_prepare_backgrounds\else -% \let\page_prepare_backgrounds\gobbleoneargument -% \fi - % only for very special controlled cases or experiments: \let\page_scale_text_box\gobbleoneargument @@ -900,7 +896,6 @@ \page_layouts_swap_margins \vkern\dimexpr\headerheight+\headerdistance+\textdistance\relax \dontleavehmode - %\page_prepare_backgrounds{#2}% \hpack to \makeupwidth {\begingroup \page_layouts_swap_margins diff --git a/tex/context/base/mkxl/scrp-ini.lmt b/tex/context/base/mkxl/scrp-ini.lmt new file mode 100644 index 000000000..60ea15f08 --- /dev/null +++ b/tex/context/base/mkxl/scrp-ini.lmt @@ -0,0 +1,1051 @@ +if not modules then modules = { } end modules ['scrp-ini'] = { + version = 1.001, + comment = "companion to scrp-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- We need to rewrite this a bit ... rather old code ... will be done when japanese +-- is finished. + +local tonumber, next = tonumber, next +local setmetatableindex = table.setmetatableindex +local utfbyte, utfsplit = utf.byte, utf.split +local gmatch = string.gmatch + +local trace_analyzing = false trackers.register("scripts.analyzing", function(v) trace_analyzing = v end) +local trace_injections = false trackers.register("scripts.injections", function(v) trace_injections = v end) +local trace_splitting = false trackers.register("scripts.splitting", function(v) trace_splitting = v end) +local trace_splitdetails = false trackers.register("scripts.splitting.details", function(v) trace_splitdetails = v end) + +local report_preprocessing = logs.reporter("scripts","preprocessing") +local report_splitting = logs.reporter("scripts","splitting") + +local attributes = attributes +local nodes = nodes +local context = context + +local nodecodes = nodes.nodecodes + +local implement = interfaces.implement + +local glyph_code = nodecodes.glyph +local glue_code = nodecodes.glue + +local emwidths = fonts.hashes.emwidths +local exheights = fonts.hashes.exheights + +local a_script = attributes.private('script') + +local fontdata = fonts.hashes.identifiers +local allocate = utilities.storage.allocate +local setnodecolor = nodes.tracers.colors.set + +local enableaction = nodes.tasks.enableaction +local disableaction = nodes.tasks.disableaction + +local nuts = nodes.nuts + +local getnext = nuts.getnext +local getchar = nuts.getchar +local getfont = nuts.getfont +local getscript = nuts.getscript +local getid = nuts.getid +local getglyphdata = nuts.getglyphdata +local setglyphdata = nuts.setglyphdata + +local isglyph = nuts.isglyph + +local insertnodeafter = nuts.insertafter +local insertnodebefore = nuts.insertbefore + +local firstglyph = nuts.firstglyph + +local nextglyph = nuts.traversers.glyph +local nextchar = nuts.traversers.char + +local texsetglyphscript = tex.setglyphscript + +local nodepool = nuts.pool + +local new_glue = nodepool.glue +local new_rule = nodepool.rule +local new_penalty = nodepool.penalty + +scripts = scripts or { } +local scripts = scripts + +scripts.hash = scripts.hash or { } +local hash = scripts.hash + +local handlers = allocate() +scripts.handlers = handlers + +local injectors = allocate() +scripts.injectors = handlers + +local splitters = allocate() +scripts.splitters = splitters + +local hash = { -- we could put these presets in char-def.lua + -- + -- half width opening parenthesis + -- + [0x0028] = "half_width_open", + [0x005B] = "half_width_open", + [0x007B] = "half_width_open", + [0x2018] = "half_width_open", -- ‘ + [0x201C] = "half_width_open", -- “ + -- + -- full width opening parenthesis + -- + [0x3008] = "full_width_open", -- 〈 Left book quote + [0x300A] = "full_width_open", -- 《 Left double book quote + [0x300C] = "full_width_open", -- 「 left quote + [0x300E] = "full_width_open", -- 『 left double quote + [0x3010] = "full_width_open", -- 【 left double book quote + [0x3014] = "full_width_open", -- 〔 left book quote + [0x3016] = "full_width_open", --〖 left double book quote + [0x3018] = "full_width_open", -- left tortoise bracket + [0x301A] = "full_width_open", -- left square bracket + [0x301D] = "full_width_open", -- reverse double prime qm + [0xFF08] = "full_width_open", -- ( left parenthesis + [0xFF3B] = "full_width_open", -- [ left square brackets + [0xFF5B] = "full_width_open", -- { left curve bracket + -- + -- half width closing parenthesis + -- + [0x0029] = "half_width_close", + [0x005D] = "half_width_close", + [0x007D] = "half_width_close", + [0x2019] = "half_width_close", -- ’ right quote, right + [0x201D] = "half_width_close", -- ” right double quote + -- + -- full width closing parenthesis + -- + [0x3009] = "full_width_close", -- 〉 book quote + [0x300B] = "full_width_close", -- 》 double book quote + [0x300D] = "full_width_close", -- 」 right quote, right + [0x300F] = "full_width_close", -- 』 right double quote + [0x3011] = "full_width_close", -- 】 right double book quote + [0x3015] = "full_width_close", -- 〕 right book quote + [0x3017] = "full_width_close", -- 〗 right double book quote + [0x3019] = "full_width_close", -- right tortoise bracket + [0x301B] = "full_width_close", -- right square bracket + [0x301E] = "full_width_close", -- double prime qm + [0x301F] = "full_width_close", -- low double prime qm + [0xFF09] = "full_width_close", -- ) right parenthesis + [0xFF3D] = "full_width_close", -- ] right square brackets + [0xFF5D] = "full_width_close", -- } right curve brackets + -- + [0xFF62] = "half_width_open", -- left corner bracket + [0xFF63] = "half_width_close", -- right corner bracket + -- + -- vertical opening vertical + -- + -- 0xFE35, 0xFE37, 0xFE39, 0xFE3B, 0xFE3D, 0xFE3F, 0xFE41, 0xFE43, 0xFE47, + -- + -- vertical closing + -- + -- 0xFE36, 0xFE38, 0xFE3A, 0xFE3C, 0xFE3E, 0xFE40, 0xFE42, 0xFE44, 0xFE48, + -- + -- half width opening punctuation + -- + -- <empty> + -- + -- full width opening punctuation + -- + -- 0x2236, -- ∶ + -- 0xFF0C, -- , + -- + -- half width closing punctuation_hw + -- + [0x0021] = "half_width_close", -- ! + [0x002C] = "half_width_close", -- , + [0x002E] = "half_width_close", -- . + [0x003A] = "half_width_close", -- : + [0x003B] = "half_width_close", -- ; + [0x003F] = "half_width_close", -- ? + [0xFF61] = "half_width_close", -- hw full stop + -- + -- full width closing punctuation + -- + [0x3001] = "full_width_close", -- 、 + [0x3002] = "full_width_close", -- 。 + [0xFF0C] = "full_width_close", -- , + [0xFF0E] = "full_width_close", -- + -- + -- depends on font + -- + [0xFF01] = "full_width_close", -- ! + [0xFF1F] = "full_width_close", -- ? + -- + [0xFF1A] = "full_width_punct", -- : + [0xFF1B] = "full_width_punct", -- ; + -- + -- non starter + -- + [0x3005] = "non_starter", [0x3041] = "non_starter", [0x3043] = "non_starter", [0x3045] = "non_starter", [0x3047] = "non_starter", + [0x3049] = "non_starter", [0x3063] = "non_starter", [0x3083] = "non_starter", [0x3085] = "non_starter", [0x3087] = "non_starter", + [0x308E] = "non_starter", [0x3095] = "non_starter", [0x3096] = "non_starter", [0x309B] = "non_starter", [0x309C] = "non_starter", + [0x309D] = "non_starter", [0x309E] = "non_starter", [0x30A0] = "non_starter", [0x30A1] = "non_starter", [0x30A3] = "non_starter", + [0x30A5] = "non_starter", [0x30A7] = "non_starter", [0x30A9] = "non_starter", [0x30C3] = "non_starter", [0x30E3] = "non_starter", + [0x30E5] = "non_starter", [0x30E7] = "non_starter", [0x30EE] = "non_starter", [0x30F5] = "non_starter", [0x30F6] = "non_starter", + [0x30FC] = "non_starter", [0x30FD] = "non_starter", [0x30FE] = "non_starter", [0x31F0] = "non_starter", [0x31F1] = "non_starter", + [0x31F2] = "non_starter", [0x31F3] = "non_starter", [0x31F4] = "non_starter", [0x31F5] = "non_starter", [0x31F6] = "non_starter", + [0x31F7] = "non_starter", [0x31F8] = "non_starter", [0x31F9] = "non_starter", [0x31FA] = "non_starter", [0x31FB] = "non_starter", + [0x31FC] = "non_starter", [0x31FD] = "non_starter", [0x31FE] = "non_starter", [0x31FF] = "non_starter", + -- + [0x301C] = "non_starter", [0x303B] = "non_starter", [0x303C] = "non_starter", [0x309B] = "non_starter", [0x30FB] = "non_starter", + [0x30FE] = "non_starter", + -- hyphenation + -- + [0x2026] = "hyphen", -- … ellipsis + [0x2014] = "hyphen", -- — hyphen + -- + [0x1361] = "ethiopic_word", + [0x1362] = "ethiopic_sentence", + -- + -- tibetan: + -- + [0x0F0B] = "breaking_tsheg", + [0x0F0C] = "nonbreaking_tsheg", + +} + +local function provide(t,k) + local v + if not tonumber(k) then v = false + elseif (k >= 0x03040 and k <= 0x030FF) + or (k >= 0x031F0 and k <= 0x031FF) + or (k >= 0x032D0 and k <= 0x032FE) + or (k >= 0x0FF00 and k <= 0x0FFEF) then v = "katakana" + elseif (k >= 0x03400 and k <= 0x04DFF) + or (k >= 0x04E00 and k <= 0x09FFF) + or (k >= 0x0F900 and k <= 0x0FAFF) + or (k >= 0x20000 and k <= 0x2A6DF) + or (k >= 0x2F800 and k <= 0x2FA1F) then v = "chinese" + elseif (k >= 0x0AC00 and k <= 0x0D7A3) then v = "korean" + elseif (k >= 0x01100 and k <= 0x0115F) then v = "jamo_initial" + elseif (k >= 0x01160 and k <= 0x011A7) then v = "jamo_medial" + elseif (k >= 0x011A8 and k <= 0x011FF) then v = "jamo_final" + elseif (k >= 0x01200 and k <= 0x0139F) then v = "ethiopic_syllable" + elseif (k >= 0x00F00 and k <= 0x00FFF) then v = "tibetan" + else v = false + end + t[k] = v + return v +end + +setmetatableindex(hash,provide) -- should come from char-def + +scripts.hash = hash + +local numbertodataset = allocate() +local numbertohandler = allocate() + +--~ storage.register("scripts/hash", hash, "scripts.hash") + +scripts.numbertodataset = numbertodataset +scripts.numbertohandler = numbertohandler + +local defaults = { + inter_char_shrink_factor = 0, + inter_char_shrink_factor = 0, + inter_char_stretch_factor = 0, + inter_char_half_shrink_factor = 0, + inter_char_half_stretch_factor = 0, + inter_char_quarter_shrink_factor = 0, + inter_char_quarter_stretch_factor = 0, + inter_char_hangul_penalty = 0, + + inter_word_stretch_factor = 0, +} + +scripts.defaults = defaults -- so we can add more + +-- todo: copy more efficient than metatable + +function scripts.installmethod(handler) + local name = handler.name + handlers[name] = handler + local attributes = { } + local datasets = handler.datasets + if not datasets or not datasets.default then + report_preprocessing("missing (default) dataset in script %a",name) + datasets.default = { } -- slower but an error anyway + end + + for k, v in next, datasets do + setmetatableindex(v,defaults) + end + setmetatableindex(attributes, function(t,k) + local v = datasets[k] or datasets.default + local a = 0 + if v then + v.name = name -- for tracing + a = #numbertodataset + 1 + numbertodataset[a] = v + numbertohandler[a] = handler + end + t[k] = a + return a + end) + handler.attributes = attributes +end + +function scripts.installdataset(specification) -- global overload + local method = specification.method + local name = specification.name + local dataset = specification.dataset + if method and name and dataset then + local parent = specification.parent or "" + local handler = handlers[method] + if handler then + local datasets = handler.datasets + if datasets then + local defaultset = datasets.default + if defaultset then + if parent ~= "" then + local p = datasets[parent] + if p then + defaultset = p + else + report_preprocessing("dataset, unknown parent %a for method %a",parent,method) + end + end + setmetatable(dataset,defaultset) + local existing = datasets[name] + if existing then + for k, v in next, existing do + existing[k] = dataset + end + else + datasets[name] = dataset + end + else + report_preprocessing("dataset, no default for method %a",method) + end + else + report_preprocessing("dataset, no datasets for method %a",method) + end + else + report_preprocessing("dataset, no method %a",method) + end + else + report_preprocessing("dataset, invalid specification") -- maybe report table + end +end + +local injectorenabled = false +local splitterenabled = false + +local function getscriptdata(n) + local s = getscript(n) + if s then + return s and numbertodataset[s] + end +end + +local function getinjector(n) + local s = getscript(n) + if s then + s = numbertohandler[s] + return s and s.injector + end +end + +local function getsplitter(n) + local s = getscript(n) + if s then + s = numbertodataset[s] + return s and s.splitter + end +end + +scripts.getdata = getscriptdata +scripts.getinjector = getinjector +scripts.getsplitter = getsplitter + +function scripts.set(name,method,preset) + local handler = handlers[method] + if handler then + local index = handler.attributes[preset] + if handler.injector then + if not injectorenabled then + enableaction("processors","scripts.injectors.handler") + injectorenabled = true + end + end + if handler.splitter then + if not splitterenabled then + enableaction("processors","scripts.splitters.handler") + splitterenabled = true + end + end + if handler.initializer then + handler.initializer(handler) + handler.initializer = nil + end + texsetglyphscript(index) + else + texsetglyphscript() + end +end + +function scripts.reset() + texsetglyphscript() +end + +-- 0=gray 1=red 2=green 3=blue 4=yellow 5=magenta 6=cyan 7=x-yellow 8=x-magenta 9=x-cyan + +-- local categories = allocate { -- rather bound to cjk ... will be generalized +-- "korean", +-- "chinese", +-- "katakana", +-- "hiragana", +-- "full_width_open", +-- "full_width_close", +-- "half_width_open", +-- "half_width_close", +-- "full_width_punct", +-- "hyphen", +-- "non_starter", +-- "jamo_initial", +-- "jamo_medial", +-- "jamo_final", +-- "ethiopic_syllable", +-- "ethiopic_word", +-- "ethiopic_sentence", +-- "breaking_tsheg", +-- "nonbreaking_tsheg", +-- } +-- +-- scripts.categories = categories + +local scriptcolors = allocate { + -- todo: just named colors + hyphen = "trace:5", +} + +scripts.colors = scriptcolors + +-- this can become setprop ... + +local propertydata = nodes.properties.data + +local function setscriptstatus(n,s) + local p = propertydata[n] + if p then + p.scriptstatus = s + else + propertydata[n] = { scriptstatus = s } + end +end + +function getscriptstatus(n) + local p = propertydata[n] + if p then + return p.scriptstatus + end +end + +scripts.setstatus = setscriptstatus +scripts.getstatus = getscriptstatus + +-- + +local function colorize(start,stop) + for n in nextglyph, start do + local kind = getscriptstatus(n) + if kind then + local ac = scriptcolors[kind] + if ac then + setnodecolor(n,ac) + end + end + if n == stop then + break + end + end +end + +local function traced_process(head,first,last,process,a) + if start ~= last then + local f, l = first, last + local name = numbertodataset[a] + name = name and name.name or "?" + report_preprocessing("before %s: %s",name,nodes.tosequence(f,l)) + process(head,first,last) + report_preprocessing("after %s: %s", name,nodes.tosequence(f,l)) + end +end + +function scripts.injectors.handler(head) + local start = firstglyph(head) -- we already have glyphs here (subtype 1) + if not start then + return head + else + local last_a, normal_process, lastfont, originals, first, last + local ok = false + while start do + local char, id = isglyph(start) + if char then + -- local a = getinjector(start) + local a = getscript(start) + if a then + if a ~= last_a then + if first then + if ok then + if trace_analyzing then + colorize(first,last) + end + if trace_injections then + traced_process(head,first,last,normal_process,last_a) + else + normal_process(head,first,last) + end + ok = false + end + first, last = nil, nil + end + last_a = a + -- normal_process = a + normal_process = getinjector(start) + end + if normal_process then + -- id == font + if id ~= lastfont then + originals = fontdata[id].resources + if resources then + originals = resources.originals + else + originals = nil -- can't happen + end + lastfont = id + end + if originals and type(originals) == "number" then + char = originals[char] or char + end + local h = hash[char] + if h then + setscriptstatus(start,h) + if not first then + first, last = start, start + else + last = start + end + -- if cjk == "chinese" or cjk == "korean" then -- we need to prevent too much ( ) processing + ok = true + -- end + elseif first then + if ok then + if trace_analyzing then + colorize(first,last) + end + if trace_injections then + traced_process(head,first,last,normal_process,last_a) + else + normal_process(head,first,last) + end + ok = false + end + first, last = nil, nil + end + end + elseif first then + if ok then + if trace_analyzing then + colorize(first,last) + end + if trace_injections then + traced_process(head,first,last,normal_process,last_a) + else + normal_process(head,first,last) + end + ok = false + end + first, last = nil, nil + end + elseif id == glue_code then + if ok then + -- continue + elseif first then + -- no chinese or korean + first, last = nil, nil + end + elseif first then + if ok then + -- some chinese or korean + if trace_analyzing then + colorize(first,last) + end + if trace_injections then + traced_process(head,first,last,normal_process,last_a) + else + normal_process(head,first,last) + end + first, last, ok = nil, nil, false + elseif first then + first, last = nil, nil + end + end + start = getnext(start) + end + if ok then + if trace_analyzing then + colorize(first,last) + end + if trace_injections then + traced_process(head,first,last,normal_process,last_a) + else + normal_process(head,first,last) + end + end + return head + end +end + +-- kind of experimental .. might move to it's own module + +-- function scripts.splitters.handler(head) +-- return head +-- end + +local function addwords(tree,data) + if not tree then + tree = { } + end + for word in gmatch(data,"%S+") do + local root = tree + local list = utfsplit(word,true) + for i=1,#list do + local l = utfbyte(list[i]) + local r = root[l] + if not r then + r = { } + root[l] = r + end + if i == #list then + r.final = word -- true -- could be something else, like word in case of tracing + else + root = r + end + end + end + return tree +end + +local loaded = { } + +function splitters.load(handler,files) + local files = handler.files + local tree = handler.tree or { } + handler.tree = tree + if not files then + return + elseif type(files) == "string" then + files = { files } + handler.files = files + end + if trace_splitting then + report_splitting("loading splitter data for language/script %a",handler.name) + end + loaded[handler.name or "unknown"] = (loaded[handler.name or "unknown"] or 0) + 1 + statistics.starttiming(loaded) + for i=1,#files do + local filename = files[i] + local fullname = resolvers.findfile(filename) + if fullname == "" then + fullname = resolvers.findfile(filename .. ".gz") + end + if fullname ~= "" then + if trace_splitting then + report_splitting("loading file %a",fullname) + end + local suffix, gzipped = gzip.suffix(fullname) + if suffix == "lua" then + local specification = table.load(fullname,gzipped and gzip.load) + if specification then + local lists = specification.lists + if lists then + for i=1,#lists do + local entry = lists[i] + local data = entry.data + if data then + if entry.compression == "zlib" then + data = zlib.decompress(data) + if entry.length and entry.length ~= #data then + report_splitting("compression error in file %a",fullname) + end + end + if data then + addwords(tree,data) + end + end + end + end + end + else + local data = gzipped and io.loadgzip(fullname) or io.loaddata(fullname) + if data then + addwords(tree,data) + end + end + else + report_splitting("unknown file %a",filename) + end + end + statistics.stoptiming(loaded) + return tree +end + +statistics.register("loaded split lists", function() + if next(loaded) then + return string.format("%s, load time: %s",table.sequenced(loaded),statistics.elapsedtime(loaded)) + end +end) + +-- function splitters.addlist(name,filename) +-- local handler = scripts.handlers[name] +-- if handler and filename then +-- local files = handler.files +-- if not files then +-- files = { } +-- elseif type(files) == "string" then +-- files = { files } +-- end +-- handler.files = files +-- if type(filename) == "string" then +-- filename = utilities.parsers.settings_to_array(filename) +-- end +-- if type(filename) == "table" then +-- for i=1,#filename do +-- files[#files+1] = filenames[i] +-- end +-- end +-- end +-- end +-- +-- commands.setscriptsplitterlist = splitters.addlist + +local categories = characters.categories or { } + +local function hit(root,head) + local current = getnext(head) + local lastrun = false + local lastfinal = false + while current do + local char = isglyph(current) + if char then + local newroot = root[char] + if newroot then + local final = newroot.final + if final then + lastrun = current + lastfinal = final + end + root = newroot + elseif categories[char] == "mn" then + -- continue + else + return lastrun, lastfinal + end + else + break + end + end + if lastrun then + return lastrun, lastfinal + end +end + +local tree, attr, proc + +function splitters.handler(head) -- todo: also firstglyph test + local current = head + while current do + if getid(current) == glyph_code then + local a = getsplitter(current) + if a then + if a ~= attr then + local handler = numbertohandler[a] + tree = handler.tree or { } + attr = a + proc = a + end + if proc then + local root = tree[getchar(current)] + if root then + -- we don't check for attributes in the hitter (yet) + local last, final = hit(root,current) + if last then + local next = getnext(last) + if next then + local nextchar = isglyph(next) + if not nextchar then + -- we're done + elseif tree[nextchar] then + if trace_splitdetails then + if type(final) == "string" then + report_splitting("advance %s processing between <%s> and <%c>","with",final,nextchar) + else + report_splitting("advance %s processing between <%c> and <%c>","with",char,nextchar) + end + end + head, current = proc(handler,head,current,last,1) + else + if trace_splitdetails then + -- could be punctuation + if type(final) == "string" then + report_splitting("advance %s processing between <%s> and <%c>","without",final,nextchar) + else + report_splitting("advance %s processing between <%c> and <%c>","without",char,nextchar) + end + end + head, current = proc(handler,head,current,last,2) + end + end + end + end + end + end + end + current = getnext(current) + end + return head +end + +local function marker(head,current,font,color) -- could become: nodes.tracers.marker + local ex = exheights[font] + local em = emwidths [font] + head, current = insertnodeafter(head,current,new_penalty(10000)) + head, current = insertnodeafter(head,current,new_glue(-0.05*em)) + head, current = insertnodeafter(head,current,new_rule(0.05*em,1.5*ex,0.5*ex)) + setnodecolor(current,color) + return head, current +end + +local last_a, last_f, last_s, last_q + +function splitters.insertafter(handler,head,first,last,detail) + local a = getscriptdata(first) + local f = getfont(first) + if a and a ~= last_a or f ~= last_f then + last_s = emwidths[f] * data.inter_word_stretch_factor + last_a = a + last_f = f + end + if trace_splitting then + head, last = marker(head,last,f,detail == 2 and "trace:r" or "trace:g") + end + if ignore then + return head, last + else + return insertnodeafter(head,last,new_glue(0,last_s)) + end +end + +-- word-xx.lua: +-- +-- return { +-- comment = "test", +-- copyright = "not relevant", +-- language = "en", +-- timestamp = "2013-05-20 14:15:21", +-- version = "1.00", +-- lists = { +-- { +-- -- data = "we thrive information in thick worlds because of our marvelous and everyday capacity to select edit single out structure highlight group pair merge harmonize synthesize focus organize condense reduce boil down choose categorize catalog classify list abstract scan look into idealize isolate discriminate distinguish screen pigeonhole pick over sort integrate blend inspect filter lump skip smooth chunk average approximate cluster aggregate outline summarize itemize review dip into flip through browse glance into leaf through skim refine enumerate glean synopsize winnow the wheat from the chaff and separate the sheep from the goats", +-- data = "abstract aggregate and approximate average because blend boil browse capacity catalog categorize chaff choose chunk classify cluster condense dip discriminate distinguish down edit enumerate everyday filter flip focus from glance glean goats group harmonize highlight idealize in information inspect integrate into isolate itemize leaf list look lump marvelous merge of organize our out outline over pair pick pigeonhole reduce refine review scan screen select separate sheep single skim skip smooth sort structure summarize synopsize synthesize the thick thrive through to we wheat winnow worlds", +-- }, +-- }, +-- } + +scripts.installmethod { + name = "test", + splitter = splitters.insertafter, + initializer = splitters.load, + files = { + -- "scrp-imp-word-test.lua", + "word-xx.lua", + }, + datasets = { + default = { + inter_word_stretch_factor = 0.25, -- of quad + }, + }, +} + +-- new plugin: + +local registercontext = fonts.specifiers.registercontext +local mergecontext = fonts.specifiers.mergecontext + +local otfscripts = characters.otfscripts + +local report_scripts = logs.reporter("scripts","auto feature") +local trace_scripts = false trackers.register("scripts.autofeature",function(v) trace_scripts = v end) + +local autofontfeature = scripts.autofontfeature or { } +scripts.autofontfeature = autofontfeature + +local cache_yes = { } +local cache_nop = { } + +setmetatableindex(cache_yes,function(t,k) local v = { } t[k] = v return v end) +setmetatableindex(cache_nop,function(t,k) local v = { } t[k] = v return v end) + +-- beware: we need to tag a done (otherwise too many extra instances ... but how +-- often unpack? wait till we have a bitmap +-- +-- we can consider merging this in handlers.characters(head) at some point as there +-- already check for the dynamic attribute so it saves a pass, however, then we also +-- need to check for a_scriptinjection there which nils the benefit +-- +-- we can consider cheating: set all glyphs in a word as the first one but it's not +-- playing nice + +function autofontfeature.handler(head) + for n, char, font in nextchar, head do + -- if getscript(n) then + -- -- already tagged by script feature, maybe some day adapt + -- else + local script = otfscripts[char] + if script then + local dynamic = getglyphdata(n) or 0 + if dynamic > 0 then + local slot = cache_yes[font] + local attr = slot[script] + if not attr then + attr = mergecontext(dynamic,name,2) + slot[script] = attr + if trace_scripts then + report_scripts("script: %s, trigger %C, dynamic: %a, variant: %a",script,char,attr,"extended") + end + end + if attr ~= 0 then + n[0] = attr + -- maybe set scriptinjection when associated + end + else + local slot = cache_nop[font] + local attr = slot[script] + if not attr then + attr = registercontext(font,script,2) + slot[script] = attr + if trace_scripts then + report_scripts("script: %s, trigger %C, dynamic: %s, variant: %a",script,char,attr,"normal") + end + end + if attr ~= 0 then + setglyphdata(n,attr) + -- maybe set scriptinjection when associated + end + end + end + -- end + end + return head +end + +function autofontfeature.enable() + report_scripts("globally enabled") + enableaction("processors","scripts.autofontfeature.handler") +end + +function autofontfeature.disable() + report_scripts("globally disabled") + disableaction("processors","scripts.autofontfeature.handler") +end + +implement { + name = "enableautofontscript", + actions = autofontfeature.enable +} + +implement { + name = "disableautofontscript", + actions = autofontfeature.disable } + +implement { + name = "setscript", + actions = scripts.set, + arguments = "3 strings", +} + +implement { + name = "resetscript", + actions = scripts.reset +} + +-- some common helpers + +do + + local parameters = fonts.hashes.parameters + + local space, stretch, shrink, lastfont + + local inter_character_space_factor = 1 + local inter_character_stretch_factor = 1 + local inter_character_shrink_factor = 1 + + local function space_glue(current) + -- local data = numbertodataset[getattr(current,a_scriptinjection)] + local data = getscriptdata(current) + if data then + inter_character_space_factor = data.inter_character_space_factor or 1 + inter_character_stretch_factor = data.inter_character_stretch_factor or 1 + inter_character_shrink_factor = data.inter_character_shrink_factor or 1 + end + local font = getfont(current) + if lastfont ~= font then + local pf = parameters[font] + space = pf.space + stretch = pf.space_stretch + shrink = pf.space_shrink + lastfont = font + end + return new_glue( + inter_character_space_factor * space, + inter_character_stretch_factor * stretch, + inter_character_shrink_factor * shrink + ) + end + + scripts.inserters = { + + space_before = function(head,current) + return insertnodebefore(head,current,space_glue(current)) + end, + space_after = function(head,current) + return insertnodeafter(head,current,space_glue(current)) + end, + + zerowidthspace_before = function(head,current) + return insertnodebefore(head,current,new_glue(0)) + end, + zerowidthspace_after = function(head,current) + return insertnodeafter(head,current,new_glue(0)) + end, + + nobreakspace_before = function(head,current) + local g = space_glue(current) + local p = new_penalty(10000) + head, current = insertnodebefore(head,current,p) + return insertnodebefore(head,current,g) + end, + nobreakspace_after = function(head,current) + local g = space_glue(current) + local p = new_penalty(10000) + head, current = insertnodeafter(head,current,g) + return insertnodeafter(head,current,p) + end, + + } + +end + +-- end of helpers diff --git a/tex/context/base/mkxl/scrp-ini.mkxl b/tex/context/base/mkxl/scrp-ini.mkxl index 77412738b..99f064acc 100644 --- a/tex/context/base/mkxl/scrp-ini.mkxl +++ b/tex/context/base/mkxl/scrp-ini.mkxl @@ -36,7 +36,7 @@ %D Todo: as in bidi mode we need a way to globally keep the setting. -\registerctxluafile{scrp-ini}{} +\registerctxluafile{scrp-ini}{autosuffix} \registerctxluafile{scrp-cjk}{} \registerctxluafile{scrp-eth}{} \registerctxluafile{scrp-tha}{} diff --git a/tex/context/base/mkxl/spac-ali.lmt b/tex/context/base/mkxl/spac-ali.lmt index 5c434fcdf..02aaf9efd 100644 --- a/tex/context/base/mkxl/spac-ali.lmt +++ b/tex/context/base/mkxl/spac-ali.lmt @@ -51,7 +51,7 @@ local nofrealigned = 0 -- raggedright 0 0 fil -- raggedcenter 0 + 0 + - -local function handler(head,leftpage,realpageno) -- traverse_list +local function handler(head,leftpage,realpageno) for current, id, subtype, list in nextlist, head do if subtype == linelist_code then local a = takeattr(current,a_realign) diff --git a/tex/context/base/mkxl/spac-chr.lmt b/tex/context/base/mkxl/spac-chr.lmt index 52d8a7de1..e38f2a30e 100644 --- a/tex/context/base/mkxl/spac-chr.lmt +++ b/tex/context/base/mkxl/spac-chr.lmt @@ -42,11 +42,9 @@ local isglyph = nuts.isglyph local setcolor = nodes.tracers.colors.set -local insert_node_before = nuts.insert_before -local insert_node_after = nuts.insert_after +local insertnodebefore = nuts.insertbefore +local insertnodeafter = nuts.insertafter local remove_node = nuts.remove ------ traverse_id = nuts.traverse_id ------ traverse_char = nuts.traverse_char local nextchar = nuts.traversers.char local nextglyph = nuts.traversers.glyph @@ -95,7 +93,7 @@ local function inject_quad_space(unicode,head,current,fraction) setattrlist(glue,current) setattrlist(current) -- why reset all setattr(glue,a_character,unicode) - return insert_node_after(head,current,glue) + return insertnodeafter(head,current,glue) end local function inject_char_space(unicode,head,current,parent) @@ -105,7 +103,7 @@ local function inject_char_space(unicode,head,current,parent) setattrlist(glue,current) setattrlist(current) -- why reset all setattr(glue,a_character,unicode) - return insert_node_after(head,current,glue) + return insertnodeafter(head,current,glue) end local function inject_nobreak_space(unicode,head,current,space,spacestretch,spaceshrink) @@ -114,17 +112,17 @@ local function inject_nobreak_space(unicode,head,current,space,spacestretch,spac setattrlist(glue,current) setattrlist(current) -- why reset all setattr(glue,a_character,unicode) -- bombs - head, current = insert_node_after(head,current,penalty) + head, current = insertnodeafter(head,current,penalty) if trace_nbsp then local rule = new_rule(space) local kern = new_kern(-space) local penalty = new_penalty(10000) setcolor(rule,"orange") - head, current = insert_node_after(head,current,rule) - head, current = insert_node_after(head,current,kern) - head, current = insert_node_after(head,current,penalty) + head, current = insertnodeafter(head,current,rule) + head, current = insertnodeafter(head,current,kern) + head, current = insertnodeafter(head,current,penalty) end - return insert_node_after(head,current,glue) + return insertnodeafter(head,current,glue) end local function nbsp(head,current) @@ -148,7 +146,7 @@ end function characters.replacenbspaces(head) local wipe = false - for current, char, font in nextglyph, head do -- can be anytime so no traverse_char + for current, char, font in nextglyph, head do -- can be anytime so no traversechar if char == 0x00A0 then if wipe then head = remove_node(h,current,true) @@ -192,7 +190,7 @@ local methods = { head, current = remove_node(head,current,true) if not is_punctuation[char] then local p = fontparameters[font] - head, current = insert_node_before(head,current,new_glue(p.space,p.space_stretch,p.space_shrink)) + head, current = insertnodebefore(head,current,new_glue(p.space,p.space_stretch,p.space_shrink)) end end end @@ -226,7 +224,7 @@ local methods = { end, [0x00AD] = function(head,current) -- softhyphen - return insert_node_after(head,current,languages.explicithyphen(current)) + return insertnodeafter(head,current,languages.explicithyphen(current)) end, [0x2000] = function(head,current) -- enquad @@ -295,7 +293,7 @@ local methods = { characters.methods = methods --- function characters.handler(head) -- todo: use traverse_id +-- function characters.handler(head) -- todo: use traverseid -- local current = head -- while current do -- local char, id = isglyph(current) diff --git a/tex/context/base/mkxl/spac-ver.lmt b/tex/context/base/mkxl/spac-ver.lmt index 3e606552a..76d1ce9db 100644 --- a/tex/context/base/mkxl/spac-ver.lmt +++ b/tex/context/base/mkxl/spac-ver.lmt @@ -149,12 +149,13 @@ local getdepth = nuts.getdepth local setnext = nuts.setnext local find_node_tail = nuts.tail -local flush_node = nuts.flush_node +local flushnode = nuts.flushnode local remove_node = nuts.remove local count_nodes = nuts.countall local hpack_node = nuts.hpack local vpack_node = nuts.vpack -local start_of_par = nuts.start_of_par + +local startofpar = nuts.startofpar local write_node = nuts.write @@ -289,7 +290,7 @@ end local function validvbox(parentid,list) if parentid == hlist_code then local id = getid(list) - if id == par_code and start_of_par(list) then + if id == par_code and startofpar(list) then list = getnext(list) if not next then return nil @@ -323,7 +324,7 @@ local function already_done(parentid,list,a_snapmethod) -- todo: done when only -- problem: any snapped vbox ends up in a line if list and parentid == hlist_code then local id = getid(list) - if id == par_code and start_of_par(list) then + if id == par_code and startofpar(list) then list = getnext(list) if not list then return false @@ -765,7 +766,7 @@ do end end - local expandmacro = token.expand_macro + local expandmacro = token.expandmacro -- todo -- local runlocal = tex.runlocal -- local setmacro = tokens.setters.macro -- local settoks = tex.settoks @@ -1018,8 +1019,8 @@ end do - local insert_node_after = nuts.insert_after - local insert_node_before = nuts.insert_before + local insertnodeafter = nuts.insertafter + local insertnodebefore = nuts.insertbefore local abovedisplayskip_code = gluecodes.abovedisplayskip local belowdisplayskip_code = gluecodes.belowdisplayskip @@ -1116,14 +1117,14 @@ do if width == 0 then -- do nothing elseif where == "after" then - head, current = insert_node_after(head,current,new_rule(w,h,d)) - head, current = insert_node_after(head,current,new_kern(width)) - head, current = insert_node_after(head,current,new_rule(w,h,d)) + 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 = insert_node_before(head,current,new_rule(w,h,d)) - head, current = insert_node_before(head,current,new_kern(width)) - head, current = insert_node_before(head,current,new_rule(w,h,d)) + 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 end if trace then @@ -1304,10 +1305,10 @@ 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) - head = insert_node_before(head,n,k) + head = insertnodebefore(head,n,k) if n_ht > p_ht then local k = new_kern(n_ht-p_ht) - head = insert_node_before(head,p,k) + head = insertnodebefore(head,p,k) end if trace_vspacing then report_vspacing("overlaying, prev height: %p, prev depth: %p, next height: %p, skips: %p, move up: %p",p_ht,p_dp,n_ht,skips,delta) @@ -1477,12 +1478,12 @@ do local prev = getprev(current) if getid(prev) == glue_code then -- maybe go back more, or maybe even push back before any glue -- tricky case: spacing/grid-007.tex: glue penalty glue - head = insert_node_before(head,prev,p) + head = insertnodebefore(head,prev,p) else - head = insert_node_before(head,current,p) + head = insertnodebefore(head,current,p) end else - head = insert_node_before(head,current,p) + head = insertnodebefore(head,current,p) end -- if penalty_data > special_penalty_min and penalty_data < special_penalty_max then local props = properties[p] @@ -1501,22 +1502,22 @@ do trace_done("flushed due to forced " .. why,glue_data) end head = forced_skip(head,current,getwidth(glue_data,width),"before",trace) - flush_node(glue_data) + flushnode(glue_data) else local width, stretch, shrink = getglue(glue_data) if width ~= 0 then if trace then trace_done("flushed due to non zero " .. why,glue_data) end - head = insert_node_before(head,current,glue_data) + head = insertnodebefore(head,current,glue_data) elseif stretch ~= 0 or shrink ~= 0 then if trace then trace_done("flushed due to stretch/shrink in" .. why,glue_data) end - head = insert_node_before(head,current,glue_data) + head = insertnodebefore(head,current,glue_data) else -- report_vspacing("needs checking (%s): %p",gluecodes[getsubtype(glue_data)],w) - flush_node(glue_data) + flushnode(glue_data) end end end @@ -1647,7 +1648,7 @@ do if trace then trace_done("flush",glue_data) end - head = insert_node_before(head,current,glue_data) + head = insertnodebefore(head,current,glue_data) if trace then trace_natural("natural",current) end @@ -1737,7 +1738,7 @@ do trace_skip("force",sc,so,sp,current) end glue_order = so - flush_node(glue_data) + flushnode(glue_data) head, current, glue_data = remove_node(head,current) elseif glue_order == so then -- is now exclusive, maybe support goback as combi, else why a set @@ -1748,7 +1749,7 @@ do if trace then trace_skip("largest",sc,so,sp,current) end - flush_node(glue_data) + flushnode(glue_data) head, current, glue_data = remove_node(head,current) else if trace then @@ -1760,7 +1761,7 @@ do if trace then trace_skip("goback",sc,so,sp,current) end - flush_node(glue_data) + flushnode(glue_data) head, current, glue_data = remove_node(head,current) elseif sc == force then -- last one counts, some day we can provide an accumulator and largest etc @@ -1768,13 +1769,13 @@ do if trace then trace_skip("force",sc,so,sp,current) end - flush_node(glue_data) + flushnode(glue_data) head, current, glue_data = remove_node(head,current) elseif sc == penalty then if trace then trace_skip("penalty",sc,so,sp,current) end - flush_node(glue_data) + flushnode(glue_data) glue_data = nil head, current = remove_node(head,current,true) elseif sc == add then @@ -1855,7 +1856,7 @@ do elseif glue_data then local w = getwidth(current) if w ~= 0 and w > getwidth(glue_data) then -flush_node(glue_data) + flushnode(glue_data) glue_data = current if trace then trace_natural("taking parskip",current) @@ -1985,7 +1986,7 @@ flush_node(glue_data) end if force_glue then head, tail = forced_skip(head,tail,getwidth(glue_data),"after",trace) - flush_node(glue_data) + flushnode(glue_data) glue_data = nil elseif tail then setlink(tail,glue_data) diff --git a/tex/context/base/mkxl/supp-box.lmt b/tex/context/base/mkxl/supp-box.lmt index 657e3addb..24b0f3afb 100644 --- a/tex/context/base/mkxl/supp-box.lmt +++ b/tex/context/base/mkxl/supp-box.lmt @@ -7,8 +7,6 @@ if not modules then modules = { } end modules ['supp-box'] = { license = "see context related readme files" } --- this is preliminary code, use insert_before etc - local report_hyphenation = logs.reporter("languages","hyphenation") local tonumber, next, type = tonumber, next, type @@ -71,20 +69,20 @@ local setattrlist = nuts.setattrlist local setwhd = nuts.setwhd local setglue = nuts.setglue -local flush_node = nuts.flush_node -local flush_list = nuts.flush_list +local flushnode = nuts.flushnode +local flushlist = nuts.flushlist local copy_node = nuts.copy -local copy_list = nuts.copy_list +local copylist = nuts.copylist local find_tail = nuts.tail local getdimensions = nuts.dimensions local hpack = nuts.hpack local vpack = nuts.vpack -local traverse_id = nuts.traverse_id +local traverseid = nuts.traverseid local traverse = nuts.traverse local free = nuts.free local findtail = nuts.tail local reverse = nuts.reverse -local effective_glue= nuts.effective_glue +local effectiveglue = nuts.effectiveglue local nextdisc = nuts.traversers.disc local nextdir = nuts.traversers.dir @@ -122,7 +120,7 @@ local function hyphenatedlist(head,usecolor) setlistcolor(post,"darkyellow") end if replace then - flush_list(replace) + flushlist(replace) end setdisc(current) if pre then @@ -191,7 +189,7 @@ local function applytowords(current,doaction,noaction,nested) local id = getid(current) if id == glue_code then if start then - doaction(tonode(copy_list(start,current))) + doaction(tonode(copylist(start,current))) start = nil end noaction(tonode(copy_node(current))) @@ -205,7 +203,7 @@ local function applytowords(current,doaction,noaction,nested) current = getnext(current) end if start then - doaction(tonode(copy_list(start))) + doaction(tonode(copylist(start))) end end @@ -351,7 +349,7 @@ implement { else tail = prev end - flush_node(temp) + flushnode(temp) end -- done setnext(tail) @@ -434,7 +432,7 @@ local function setboxtonaturalwd(n) local old = takebox(n) local new = hpack(getlist(old)) setlist(old,nil) - flush_node(old) + flushnode(old) setbox(n,new) end @@ -488,8 +486,8 @@ do local tonut = nodes.tonut local takebox = nuts.takebox - local flush_list = nuts.flush_list - local copy_list = nuts.copy_list + local flushlist = nuts.flushlist + local copylist = nuts.copylist local getwhd = nuts.getwhd local setbox = nuts.setbox local new_hlist = nuts.pool.hlist @@ -534,7 +532,7 @@ do if not b then -- do nothing, maybe trace elseif copy then - b = copy_list(b) + b = copylist(b) else c[name] = false end @@ -551,13 +549,13 @@ do local c = cache[category] local b = takebox(box) if b then - flush_list(b) + flushlist(b) end local b = c[name] if not b then -- do nothing, maybe trace elseif copy then - b = copy_list(b) + b = copylist(b) else c[name] = false end @@ -585,7 +583,7 @@ do if name and name ~= "" then local b = c[name] if b then - flush_list(b) + flushlist(b) c[name] = false end if trace then @@ -594,7 +592,7 @@ do else for k, b in next, c do if b then - flush_list(b) + flushlist(b) end end cache[category] = { } @@ -772,7 +770,7 @@ local function stripglue(list) if first and first ~= list then -- we have discardables setsplit(getprev(first),first) - flush_list(list) + flushlist(list) list = first done = true end @@ -789,7 +787,7 @@ local function stripglue(list) end if last ~= tail then -- we have discardables - flush_list(getnext(last)) + flushlist(getnext(last)) setnext(last) done = true end @@ -843,7 +841,7 @@ local function limitate(t) -- don't pack the result ! else maxleft = maxleft - swidth end - for n in traverse_id(glue_code,list) do + for n in traverseid(glue_code,list) do local width = getdimensions(list,n) if width > maxleft then if not last then @@ -855,7 +853,7 @@ local function limitate(t) -- don't pack the result ! end end if last and maxright > 0 then - for n in traverse_id(glue_code,last) do + for n in traverseid(glue_code,last) do local width = getdimensions(n) if width < maxright then first = n @@ -884,7 +882,7 @@ local function limitate(t) -- don't pack the result ! end setlink(last,sentinel) setprev(rest) - flush_list(rest) + flushlist(rest) end end end @@ -893,11 +891,11 @@ local function limitate(t) -- don't pack the result ! if t.freeze then local l = hpack(list,total,"exactly") - for n in traverse_id(glue_code,list) do - setglue(n,(effective_glue(n,l))) + for n in traverseid(glue_code,list) do + setglue(n,(effectiveglue(n,l))) end setlist(l) - flush_node(l) + flushnode(l) end return tonode(list) @@ -1178,7 +1176,7 @@ do else setlink(p,temp,n) end - flush_node(found) + flushnode(found) getprop(box,"boxlines")[line] = temp end end @@ -1319,7 +1317,7 @@ do local getbox = tex.getbox local setfield = nodes.setfield local getfield = nodes.getfield - local flush = nodes.flush + local flush = nodes.flushnode local copynode = nodes.copy local function get(n,field,copy) diff --git a/tex/context/base/mkxl/syst-lua.lmt b/tex/context/base/mkxl/syst-lua.lmt index a89cea852..44d2fd2e9 100644 --- a/tex/context/base/mkxl/syst-lua.lmt +++ b/tex/context/base/mkxl/syst-lua.lmt @@ -15,13 +15,10 @@ local S, C, P, lpegmatch, lpegtsplitat = lpeg.S, lpeg.C, lpeg.P, lpeg.match, lpe local xmath = xmath or math local xcomplex = xcomplex or { } -local scan_next = token.scan_next or token.get_next -local scan_cmdchr = token.scan_cmdchr_expanded -local scan_token = token.scan_token - -local get_csname = token.get_csname ------ get_macro = token.get_macro ------ put_next = token.put_next +local scannext = token.scannext +local scancmdchr = token.scancmdchrexpanded +local scantoken = token.scantoken +local getcsname = token.getcsname local cmd = tokens.commands local letter_code = cmd.letter @@ -224,7 +221,7 @@ do local w = 0 local r = 1 while true do - local n, i = scan_cmdchr() + local n, i = scancmdchr() if n == letter_code then w = w + 1 ; word[w] = utfchar(i) else @@ -262,7 +259,7 @@ do elseif n == char_given_code or n == math_given_code or n == xmath_given_code then r = r + 1 ; result[r] = i elseif n == some_item_code then - local n = get_csname(t) + local n = getcsname(t) if n then local s = gettex(n) if s then @@ -274,7 +271,7 @@ do unexpected(c) end -- elseif n == call_code then - -- local n = get_csname(t) + -- local n = getcsname(t) -- if n then -- local s = get_macro(n) -- if s then @@ -287,7 +284,7 @@ do -- end -- elseif n == the_code or n == convert_code or n == lua_expandable_call_code then -- put_next(t) - -- scan_token() -- expands + -- scantoken() -- expands else unexpected(c) end diff --git a/tex/context/base/mkxl/syst-mac.lmt b/tex/context/base/mkxl/syst-mac.lmt index 410a49f8b..74502f4ee 100644 --- a/tex/context/base/mkxl/syst-mac.lmt +++ b/tex/context/base/mkxl/syst-mac.lmt @@ -17,21 +17,21 @@ if not modules then modules = { } end modules ['syst-mac'] = { local insert, remove = table.insert, table.remove -local push_macro = token.push_macro -local pop_macro = token.pop_macro -local scan_csname = token.scan_csname -local create_token = token.create -local gobble_token = token.gobble +local pushmacrotoken = token.pushmacro +local popmacrotoken = token.popmacro +local scancsname = token.scancsname +local createtoken = token.create +local gobbletoken = token.gobble -local context = context -local implement = interfaces.implement +local context = context +local implement = interfaces.implement -local report = logs.reporter("system","macrostack") +local report = logs.reporter("system","macrostack") -local stack = table.setmetatableindex("table") +local stack = table.setmetatableindex("table") local function pushmacro(name,global) - local s = push_macro(name,global) + local s = pushmacrotoken(name,global) if s then insert(stack[name],s) else @@ -43,7 +43,7 @@ end local function popmacro(name) local s = remove(stack[name]) if s then - pop_macro(s) + popmacrotoken(s) else report("no macro %a to pop",name) end @@ -57,7 +57,7 @@ implement { public = true, protected = true, actions = function() - pushmacro(scan_csname()) + pushmacro(scancsname()) end } @@ -66,7 +66,7 @@ implement { public = true, protected = true, actions = function() - pushmacro(scan_csname(),true) + pushmacro(scancsname(),true) end } @@ -75,7 +75,7 @@ implement { public = true, protected = true, actions = function() - popmacro(scan_csname()) + popmacro(scancsname()) end } @@ -84,7 +84,7 @@ implement { public = true, protected = true, actions = function() - popmacro(scan_csname()) + popmacro(scancsname()) end } @@ -93,7 +93,7 @@ implement { public = true, protected = true, actions = function() - local n = scan_csname() + local n = scancsname() local s = stack[n] local m = #s report("%s : %i stack slots used",n,m) @@ -109,7 +109,7 @@ implement { protected = true, arguments = "3 strings", actions = function(start,stop,command) - gobble_token(create_token(start),create_token(stop)) + gobbletoken(createtoken(start),createtoken(stop)) if command then context[command]() end diff --git a/tex/context/base/mkxl/task-ini.lmt b/tex/context/base/mkxl/task-ini.lmt index 933bc948d..571d31013 100644 --- a/tex/context/base/mkxl/task-ini.lmt +++ b/tex/context/base/mkxl/task-ini.lmt @@ -116,7 +116,7 @@ appendaction("math", "normalizers", "noads.handlers.italics", appendaction("math", "normalizers", "noads.handlers.kernpairs", nil, "nonut", "disabled" ) appendaction("math", "normalizers", "noads.handlers.classes", nil, "nonut", "disabled" ) -appendaction("math", "builders", "builders.kernel.mlist_to_hlist", nil, "nut", "enabled" ) -- mandate +appendaction("math", "builders", "builders.kernel.mlisttohlist", nil, "nut", "enabled" ) -- mandate appendaction("math", "builders", "typesetters.directions.processmath", nil, "nut", "disabled" ) appendaction("math", "builders", "noads.handlers.makeup", nil, "nonut", "disabled" ) appendaction("math", "builders", "noads.handlers.align", nil, "nonut", "enabled" ) diff --git a/tex/context/base/mkxl/toks-aux.lmt b/tex/context/base/mkxl/toks-aux.lmt index 46d42dfdc..a8bdae5e8 100644 --- a/tex/context/base/mkxl/toks-aux.lmt +++ b/tex/context/base/mkxl/toks-aux.lmt @@ -10,6 +10,8 @@ local max = math.max local formatters, gsub, char = string.formatters, string.gsub, string.char local concat = table.concat +-- todo : locals from scanners + local function flags(t) if type(t) == "string" then t = token.create(t) @@ -37,27 +39,27 @@ interfaces.implement { local f0 = formatters["%s: %s"] local nl = logs.newline local wr = logs.writer - local t = token.peek_next() -- local t = token.scan_next() token.put_back(t) + local t = token.peeknext() -- local t = token.scannext() token.putback(t) local n = "" local w = "" local c = t.cmdname if c == "left_brace" then w = "given token list" - t = token.scan_toks(false) + t = token.scantoks(false) elseif c == "register_toks" then - token.scan_next() + token.scannext() w = "token register" n = t.csname or t.index t = tex.gettoks(n,true) elseif c == "internal_toks" then - token.scan_next() + token.scannext() w = "internal token variable" n = t.csname or t.index t = tex.gettoks(n,true) else - n = token.scan_csname() + n = token.scancsname() local r = flags(t) - local m = token.get_meaning(n,true) + local m = token.getmeaning(n,true) r[#r+1] = "control sequence" if type(m) == "table" then t = m diff --git a/tex/context/base/mkxl/toks-ini.lmt b/tex/context/base/mkxl/toks-ini.lmt index 4b2d1facc..3e9ff362b 100644 --- a/tex/context/base/mkxl/toks-ini.lmt +++ b/tex/context/base/mkxl/toks-ini.lmt @@ -25,58 +25,59 @@ values.count = values.integer tokens.values = utilities.storage.allocate(table.swapped(values, values)) tokens.commands = utilities.storage.allocate(table.swapped(commands,commands)) -local scan_toks = token.scan_toks -local scan_string = token.scan_string -local scan_argument = token.scan_argument -local scan_delimited = token.scan_delimited -local scan_tokenlist = token.scan_tokenlist or scan_string -local scan_integer = token.scan_integer or token.scan_int -local scan_cardinal = token.scan_cardinal -local scan_code = token.scan_code -local scan_token_code = token.scan_token_code -local scan_dimen = token.scan_dimen -local scan_glue = token.scan_glue -local scan_skip = token.scan_skip -local scan_keyword = token.scan_keyword -local scan_keyword_cs = token.scan_keyword_cs or scan_keyword -local scan_token = token.scan_token -local scan_box = token.scan_box -local scan_word = token.scan_word -local scan_letters = token.scan_letters or scan_word -- lmtx -local scan_key = token.scan_key -local scan_value = token.scan_value -local scan_char = token.scan_char -local scan_number = token.scan_number -- not defined -local scan_csname = token.scan_csname -local scan_real = token.scan_real -local scan_float = token.scan_float -local scan_luanumber = token.scan_luanumber or scan_float -- only lmtx -local scan_luainteger = token.scan_luainteger or scan_integer -- only lmtx -local scan_luacardinal = token.scan_luacardinal or scan_cardinal -- only lmtx - -local scan_integer_argument = token.scan_integer_argument -local scan_dimen_argument = token.scan_dimen_argument - --- todo: gobble_integer -- might go away --- todo: gobble_dimension -- might go away - -local set_macro = token.set_macro -local set_char = token.set_char -local set_lua = token.set_lua - -local create_token = token.create -local new_token = token.new -local is_defined = token.is_defined -local is_token = token.is_token - -tokens.new = new_token -tokens.create = create_token -tokens.istoken = is_token -tokens.isdefined = is_defined -tokens.defined = is_defined - -tokens.getinteger = token.get_integer -tokens.setinteger = token.set_integer +local scantoks = token.scantoks +local scanstring = token.scanstring +local scanargument = token.scanargument +local scandelimited = token.scandelimited +local scantokenlist = token.scantokenlist +local scaninteger = token.scaninteger +local scancardinal = token.scancardinal +local scancode = token.scancode +local scantokencode = token.scantokencode +local scandimen = token.scandimen +local scanglue = token.scanglue +local scanskip = token.scanskip +local scankeyword = token.scankeyword +local scankeywordcs = token.scankeywordcs +local scantoken = token.scantoken +local scanbox = token.scanbox +local scanword = token.scanword +local scanletters = token.scanletters +local scankey = token.scankey +local scanvalue = token.scanvalue +local scanchar = token.scanchar +local scancsname = token.scancsname +local scannextchar = token.scannextchar +local scanreal = token.scanreal +local scanfloat = token.scanfloat +local scanluanumber = token.scanluanumber +local scanluainteger = token.scanluainteger +local scanluacardinal = token.scanluacardinal +local scanintegerargument = token.scanintegerargument +local scandimenargument = token.scandimenargument + +local scannumber = token.scannumber +local scanboolean = token.scanboolean + +local setmacro = token.setmacro +local setchar = token.setchar +local setlua = token.setlua + +local createtoken = token.create +local newtoken = token.new +local isdefined = token.isdefined +local istoken = token.istoken + +tokens.new = newtoken +tokens.create = createtoken +tokens.istoken = istoken +tokens.isdefined = isdefined +tokens.defined = isdefined + +tokens.gobble = token.gobble + +tokens.getinteger = token.getinteger +tokens.setinteger = token.setinteger local bits = { escape = 0x00000001, -- 2^00 @@ -110,10 +111,10 @@ tokens.bits = bits -- words are space or \relax terminated and the trailing space is gobbled; a word -- can contain any non-space letter/other (see archive for implementation in lua) -if not scan_number then +if not scannumber then -- we do have float and real .. this is actually scanluanumber - scan_number = function(base) - local s = scan_word() + scannumber = function(base) + local s = scanword() if not s then return nil elseif base then @@ -125,100 +126,89 @@ if not scan_number then end -local function scan_boolean() - local kw = scan_word() - if kw == "true" then - return true - elseif kw == "false" then - return false - else - return nil - end -end - -local function scan_verbatim() - return scan_argument(false) -end - -if not scan_box then +if not scanboolean then - local scan_list = token.scan_list - local put_next = token.put_next - - scan_box = function(s) - if s == "hbox" or s == "vbox" or s == "vtop" then - put_next(create_token(s)) + scanboolean = function() + local kw = scanword() + if kw == "true" then + return true + elseif kw == "false" then + return false + else + return nil end - return scan_list() end - token.scan_box = scan_box +end +local function scanverbatim() -- check + return scanargument(false) end tokens.scanners = { -- these expand - token = scan_token, - toks = scan_toks, - tokens = scan_toks, - box = scan_box, - hbox = function() return scan_box("hbox") end, - vbox = function() return scan_box("vbox") end, - vtop = function() return scan_box("vtop") end, - dimen = scan_dimen, - dimension = scan_dimen, - glue = scan_glue, - gluevalues = function() return scan_glue(false,false,true) end, - gluespec = scan_skip, - integer = scan_integer, - cardinal = scan_cardinal, - real = scan_real, - float = scan_float, - luanumber = scan_luanumber, - luainteger = scan_luainteger, - luacardinal = scan_luacardinal, - count = scan_integer, - string = scan_string, - argument = scan_argument, - delimited = scan_delimited, - tokenlist = scan_tokenlist, - verbatim = scan_verbatim, -- detokenize - code = scan_code, - tokencode = scan_token_code, - word = scan_word, - letters = scan_letters, - key = scan_key, - value = scan_value, - char = scan_char, - number = scan_number, - boolean = scan_boolean, - keyword = scan_keyword, - keywordcs = scan_keyword_cs, - csname = scan_csname, - - next = token.scan_next, - nextexpanded = token.scan_next_expanded, - - peek = token.peek_next, - peekexpanded = token.peek_next_expanded, - peekchar = token.peek_next_char, - - skip = token.skip_next, - skipexpanded = token.skip_next_expanded, - - cmdchr = token.scan_cmdchr, - cmdchrexpanded = token.scan_cmdchr_expanded, - - ischar = token.is_next_char, - - integerargument = scan_integer_argument, - dimenargument = scan_dimen_argument, + token = scantoken, + toks = scantoks, + tokens = scantoks, + box = scanbox, + hbox = function() return scanbox("hbox") end, + vbox = function() return scanbox("vbox") end, + vtop = function() return scanbox("vtop") end, + dimen = scandimen, + dimension = scandimen, + glue = scanglue, + gluevalues = function() return scanglue(false,false,true) end, + gluespec = scanskip, + integer = scaninteger, + cardinal = scancardinal, + real = scanreal, + float = scanfloat, + luanumber = scanluanumber, + luainteger = scanluainteger, + luacardinal = scanluacardinal, + count = scaninteger, + string = scanstring, + argument = scanargument, + delimited = scandelimited, + tokenlist = scantokenlist, + verbatim = scanverbatim, -- detokenize + code = scancode, + tokencode = scantokencode, + word = scanword, + letters = scanletters, + key = scankey, + value = scanvalue, + char = scanchar, + number = scannumber, + boolean = scanboolean, + keyword = scankeyword, + keywordcs = scankeywordcs, + csname = scancsname, + nextchar = scannextchar, + + next = token.scannext, + nextexpanded = token.scannextexpanded, + + peek = token.peeknext, + peekexpanded = token.peeknextexpanded, + peekchar = token.peeknextchar, + + skip = token.skipnext, + skipexpanded = token.skipnextexpanded, + + cmdchr = token.scancmdchr, + cmdchrexpanded = token.scancmdchrexpanded, + + ischar = token.isnextchar, + + integerargument = scanintegerargument, + dimenargument = scandimenargument, } tokens.getters = { -- these don't expand - meaning = token.get_meaning, - macro = token.get_macro, - token = token.scan_next or token.get_next, -- not here, use scanners.next or token - cstoken = token.get_cstoken, + meaning = token.getmeaning, + macro = token.getmacro, + token = token.scannext, + cstoken = token.getcstoken, count = tex.getcount, dimen = tex.getdimen, skip = tex.getglue, @@ -229,9 +219,9 @@ tokens.getters = { -- these don't expand } tokens.setters = { - macro = set_macro, - char = set_char, - lua = set_lua, + macro = setmacro, + char = setchar, + lua = setlua, count = tex.setcount, dimen = tex.setdimen, skip = tex.setglue, @@ -241,50 +231,29 @@ tokens.setters = { box = tex.setbox, } -token.accessors = { - command = token.get_command, - cmd = token.get_command, - cmdname = token.get_cmdname, - name = token.get_cmdname, - csname = token.get_csname, - index = token.get_index, - active = token.get_active, - frozen = token.get_frozen, - protected = token.get_protected, - expandable = token.get_protected, - user = token.get_user, - cmdchrcs = token.get_cmdchrcs, - active = token.get_active, - range = token.get_range, +tokens.accessors = { + command = token.getcommand, + cmd = token.getcommand, + cmdname = token.getcmdname, + name = token.getcmdname, + csname = token.getcsname, + index = token.getindex, + active = token.getactive, + frozen = token.getfrozen, + protected = token.getprotected, + expandable = token.getprotected, + user = token.getuser, + cmdchrcs = token.getcmdchrcs, + active = token.getactive, + range = token.getrange, } --- static int run_scan_token(lua_State * L) --- { --- saved_tex_scanner texstate; --- save_tex_scanner(texstate); --- get_x_token(); --- make_new_token(L, cur_cmd, cur_chr, cur_cs); --- unsave_tex_scanner(texstate); --- return 1; --- } --- --- static int run_get_future(lua_State * L) --- { --- /* saved_tex_scanner texstate; */ --- /* save_tex_scanner(texstate); */ --- get_token(); --- make_new_token(L, cur_cmd, cur_chr, cur_cs); --- back_input(); --- /* unsave_tex_scanner(texstate); */ --- return 1; --- } - -if setinspector then +if setinspector then -- can best be true local simple = { letter = "letter", other_char = "other" } local astable = function(t) - if t and is_token(t) then + if t and istoken(t) then local cmdname = t.cmdname local simple = simple[cmdname] if simple then @@ -323,10 +292,98 @@ if setinspector then end tokens.cache = table.setmetatableindex(function(t,k) - if not is_defined(k) then - set_macro(k,"","global") + if not isdefined(k) then + setmacro(k,"","global") end - local v = create_token(k) + local v = createtoken(k) t[k] = v return v end) + +-- This will go, although ... we use some old names in styles. Check what we +-- actually use. + +token.is_token = token.istoken +token.is_defined = token.isdefined +token.scan_next = token.scannext +token.scan_next_expanded = token.scannextexpanded +token.scan_next_char = token.scannextchar +token.skip_next = token.skipnext +token.skip_next_expanded = token.skipnextexpanded +token.peek_next = token.peeknext +token.peek_next_expanded = token.peeknextexpanded +token.peek_next_char = token.peeknextchar +token.scan_cmdchr = token.scancmdchr +token.scan_cmdchr_expanded = token.scancmdchrexpanded +token.scan_keyword = token.scankeyword +token.scan_keyword_cs = token.scankeywordcs +token.scan_integer = token.scaninteger +token.scan_integer_argument = token.scanintegerargument +token.scan_dimen_argument = token.scandimenargument +token.scan_cardinal = token.scancardinal +token.scan_float = token.scanfloat +token.scan_real = token.scanreal +token.scan_luanumber = token.scanluanumber +token.scan_luainteger = token.scanluainteger +token.scan_luacardinal = token.scanluacardinal +token.scan_scale = token.scanscale +token.scan_dimen = token.scandimen +token.scan_skip = token.scanskip +token.scan_glue = token.scanglue +token.scan_toks = token.scantoks +token.scan_tokenlist = token.scantokenlist +token.scan_code = token.scancode +token.scan_token_code = token.scantokencode +token.scan_string = token.scanstring +token.scan_argument = token.scanargument +token.scan_delimited = token.scandelimited +token.scan_word = token.scanword +token.scan_letters = token.scanletters +token.scan_key = token.scankey +token.scan_value = token.scanvalue +token.scan_char = token.scanchar +token.scan_csname = token.scancsname +token.scan_token = token.scantoken +token.scan_box = token.scanbox +token.is_next_char = token.isnextchar +token.put_next = token.putnext +token.put_back = token.putback +token.get_command = token.getcommand +token.get_index = token.getindex +token.get_range = token.getrange +token.get_cmdname = token.getcmdname +token.get_csname = token.getcsname +token.get_id = token.getid +token.get_tok = token.gettok +token.get_active = token.getactive +token.get_expandable = token.getexpandable +token.get_protected = token.getprotected +token.get_frozen = token.getfrozen +token.get_tolerant = token.gettolerant +token.get_noaligned = token.getnoaligned +token.get_primitive = token.getprimitive +token.get_permanent = token.getpermanent +token.get_immutable = token.getimmutable +token.get_instance = token.getinstance +token.get_flags = token.getflags +token.get_parameters = token.getparameters +token.get_macro = token.getmacro +token.get_meaning = token.getmeaning +token.get_cmdchrcs = token.getcmdchrcs +token.get_cstoken = token.getcstoken +token.get_fields = token.getfields +token.set_macro = token.setmacro +token.undefine_macro = token.undefinemacro +token.expand_macro = token.expandmacro +token.set_char = token.setchar +token.set_lua = token.setlua +token.set_integer = token.setinteger +token.get_integer = token.getinteger +token.set_dimension = token.setdimension +token.get_dimension = token.getdimension +token.gobble_integer = token.gobbleinteger +token.gobble_dimen = token.gobbledimen +token.future_expand = token.futureexpand +token.push_macro = token.pushmacro +token.pop_macro = token.popmacro +token.save_lua = token.savelua diff --git a/tex/context/base/mkxl/trac-deb.lmt b/tex/context/base/mkxl/trac-deb.lmt index 8ff124105..506a4e9cd 100644 --- a/tex/context/base/mkxl/trac-deb.lmt +++ b/tex/context/base/mkxl/trac-deb.lmt @@ -24,7 +24,7 @@ local implement = interfaces.implement local ioflush = io.flush local ioread = io.read -local writenl = texio.write_nl +local writenl = texio.writenl local write = texio.write local runlocal = tex.runlocal diff --git a/tex/context/base/mkxl/trac-vis.lmt b/tex/context/base/mkxl/trac-vis.lmt index 72835165d..d278a40b0 100644 --- a/tex/context/base/mkxl/trac-vis.lmt +++ b/tex/context/base/mkxl/trac-vis.lmt @@ -61,12 +61,12 @@ local isglyph = nuts.isglyph local hpack_nodes = nuts.hpack local vpack_nodes = nuts.vpack -local copy_list = nuts.copy_list -local copy_node = nuts.copy_node -local flush_node_list = nuts.flush_list -local insert_node_before = nuts.insert_before -local insert_node_after = nuts.insert_after +local copylist = nuts.copylist +local copy_node = nuts.copy +local insertnodebefore = nuts.insertbefore +local insertnodeafter = nuts.insertafter local apply_to_nodes = nuts.apply +local flushnodelist = nuts.flushlist local hpack_string = nuts.typesetters.tohpack @@ -462,7 +462,7 @@ local fontkern, italickern, marginkern, mathlistkern do setattr(info,a_layer,layer) f_cache[kern] = info end - head = insert_node_before(head,current,copy_list(info)) + head = insertnodebefore(head,current,copylist(info)) return head, current end @@ -510,7 +510,7 @@ local glyphexpansion do setattr(info,a_layer,l_expansion) f_cache[extra] = info end - head = insert_node_before(head,current,copy_list(info)) + head = insertnodebefore(head,current,copylist(info)) return head, current end return head, current @@ -546,7 +546,7 @@ local kernexpansion do setattr(info,a_layer,l_expansion) f_cache[extra] = info end - head = insert_node_before(head,current,copy_list(info)) + head = insertnodebefore(head,current,copylist(info)) return head, current end return head, current @@ -594,7 +594,7 @@ local whatsit do setattr(info,a_layer,l_whatsit) w_cache[what] = info end - head, current = insert_node_after(head,current,copy_list(info)) + head, current = insertnodeafter(head,current,copylist(info)) return head, current end @@ -669,7 +669,7 @@ local user do setattr(info,a_layer,l_user) u_cache[what] = info end - head, current = insert_node_after(head,current,copy_list(info)) + head, current = insertnodeafter(head,current,copylist(info)) return head, current end @@ -708,7 +708,7 @@ local math do setattr(info,a_layer,l_math) m_cache[tag][skip] = info end - head, current = insert_node_after(head,current,copy_list(info)) + head, current = insertnodeafter(head,current,copylist(info)) return head, current end @@ -768,7 +768,7 @@ local ruledbox do end -- we need to trigger the right mode (else sometimes no whatits) local info = setlink( - this and copy_list(this) or nil, + this and copylist(this) or nil, (force_origin and emptyrule(wd,ht,dp)) -- we accept some overhead or (dp == 0 and outlinerule and outlinerule(wd,ht,dp,linewidth)) or userrule { @@ -791,7 +791,7 @@ local ruledbox do elseif trace_origin or force_origin then local size = 2*size local origin = o_cache[size] - origin = copy_list(origin) + origin = copylist(origin) if getid(parent) == vlist_code then setshift(origin,-shift) info = setlink(current,new_kern(-size),origin,new_kern(-size-dp),info) @@ -811,7 +811,7 @@ local ruledbox do elseif trace_origin or force_origin then local size = 2*size local origin = o_cache[size] - origin = copy_list(origin) + origin = copylist(origin) if getid(parent) == vlist_code then info = setlink(current,new_kern(-wd-size-shift),origin,new_kern(-size+shift),info) else @@ -906,7 +906,7 @@ end local ruledglue, ruledmathglue do - local effectiveglue = nuts.effective_glue + local effectiveglue = nuts.effectiveglue local gluecodes = nodes.gluecodes @@ -1001,11 +1001,11 @@ local ruledglue, ruledmathglue do setattr(info,a_layer,layer) g_cache_gn[name] = info end - return copy_list(info) + return copylist(info) end ruledmathglue = function(head,current) - return insert_node_before(head,current,gluename(getfont(current),l_glue,"trace:m")) + return insertnodebefore(head,current,gluename(getfont(current),l_glue,"trace:m")) end ruledglue = function(head,current,vertical,parent) @@ -1049,11 +1049,11 @@ local ruledglue, ruledmathglue do end (vertical and g_cache_v or g_cache_h)[amount] = info end - info = copy_list(info) + info = copylist(info) if vertical then info = vpack_nodes(info) end - head, current = insert_node_before(head,current,info) + head, current = insertnodebefore(head,current,info) return head, getnext(current) end @@ -1077,8 +1077,8 @@ local ruledglue, ruledmathglue do g_cache_x[width] = info end end - info = copy_list(info) - head, current = insert_node_before(head,current,info) + info = copylist(info) + head, current = insertnodebefore(head,current,info) return head, getnext(current) end @@ -1104,11 +1104,11 @@ local ruledkern do end cache[kern] = info end - info = copy_list(info) + info = copylist(info) if vertical then info = vpack_nodes(info) end - head, current = insert_node_before(head,current,info) + head, current = insertnodebefore(head,current,info) return head, getnext(current) end @@ -1132,8 +1132,8 @@ local ruleditalic do end i_cache[kern] = info end - info = copy_list(info) - head, current = insert_node_before(head,current,info) + info = copylist(info) + head, current = insertnodebefore(head,current,info) return head, getnext(current) end @@ -1157,8 +1157,8 @@ local ruledmarginkern do end m_cache[kern] = info end - info = copy_list(info) - head, current = insert_node_before(head,current,info) + info = copylist(info) + head, current = insertnodebefore(head,current,info) return head, getnext(current) end @@ -1182,8 +1182,8 @@ local ruledmathlistkern do end l_cache[kern] = info end - info = copy_list(info) - head, current = insert_node_before(head,current,info) + info = copylist(info) + head, current = insertnodebefore(head,current,info) return head, getnext(current) end @@ -1205,7 +1205,7 @@ local ruleddiscretionary do d = new_hlist(kern) d_cache[true] = d end - insert_node_after(head,current,copy_list(d)) + insertnodeafter(head,current,copylist(d)) return head, current end @@ -1238,13 +1238,13 @@ local ruledpenalty do end (vertical and p_cache_v or p_cache_h)[penalty] = info end - info = copy_list(info) + info = copylist(info) if vertical then info = vpack_nodes(info) elseif raisepenalties then setshift(info,-65536*4) end - head, current = insert_node_before(head,current,info) + head, current = insertnodebefore(head,current,info) return head, getnext(current) end @@ -1563,7 +1563,7 @@ do local function cleanup() for tag, cache in next, caches do for k, v in next, cache do - flush_node_list(v) + flushnodelist(v) end end cleanup = function() diff --git a/tex/context/base/mkxl/typo-bld.lmt b/tex/context/base/mkxl/typo-bld.lmt index 599106ccd..78bdd8214 100644 --- a/tex/context/base/mkxl/typo-bld.lmt +++ b/tex/context/base/mkxl/typo-bld.lmt @@ -46,7 +46,7 @@ local nodeidstostring = nodes.idstostring local nodepool = nodes.pool local new_baselineskip = nodepool.baselineskip local new_lineskip = nodepool.lineskip -local insert_node_before = nodes.insert_before +local insertnodebefore = nodes.insertbefore local hpack_node = nodes.hpack local nuts = nodes.nuts @@ -157,9 +157,9 @@ function parbuilders.constructors.methods.oneline(head,followed_by_display) t.prevdepth = h.depth t.prevgraf = 1 if d < texget("lineskiplimit") then - return insert_node_before(h,h,new_lineskip(texget("lineskip",false))) -- no stretch etc + return insertnodebefore(h,h,new_lineskip(texget("lineskip",false))) -- no stretch etc else - return insert_node_before(h,h,new_baselineskip(d)) + return insertnodebefore(h,h,new_baselineskip(d)) end end diff --git a/tex/context/base/mkxl/typo-brk.lmt b/tex/context/base/mkxl/typo-brk.lmt index bebd4a149..f9c255608 100644 --- a/tex/context/base/mkxl/typo-brk.lmt +++ b/tex/context/base/mkxl/typo-brk.lmt @@ -45,15 +45,15 @@ local setprev = nuts.setprev local setboth = nuts.setboth local setsubtype = nuts.setsubtype -local copy_node = nuts.copy_node -local copy_node_list = nuts.copy_list -local flush_node = nuts.flush_node -local insert_node_before = nuts.insert_before -local insert_node_after = nuts.insert_after +local copy_node = nuts.copy +local copy_node_list = nuts.copylist +local flushnode = nuts.flushnode +local insertnodebefore = nuts.insertbefore +local insertnodeafter = nuts.insertafter local remove_node = nuts.remove -local end_of_math = nuts.end_of_math -local find_attribute = nuts.find_attribute -local unset_attributes = nuts.unset_attributes +local endofmath = nuts.endofmath +local findattribute = nuts.findattribute +local unsetattributes = nuts.unsetattributes local tonodes = nuts.tonodes @@ -117,15 +117,15 @@ local function insert_break(head,start,stop,before,after,kern) local g = new_glue() setattrlist(p,start) setattrlist(g,start) - insert_node_before(head,start,p) - insert_node_before(head,start,g) + insertnodebefore(head,start,p) + insertnodebefore(head,start,g) end local p = new_penalty(after) local g = new_glue() setattrlist(p,start) setattrlist(g,start) - insert_node_after(head,stop,g) - insert_node_after(head,stop,p) + insertnodeafter(head,stop,g) + insertnodeafter(head,stop,p) end methods[1] = function(head,start,stop,settings,kern) @@ -172,7 +172,7 @@ methods[2] = function(head,start) -- ( => (- local hyphen = copy_node(post) setchar(hyphen,languages.prehyphenchar(getlanguage(post))) setlink(post,hyphen) - head, start = insert_node_before(head,start,new_disc(nil,post,replace)) + head, start = insertnodebefore(head,start,new_disc(nil,post,replace)) setattrlist(start,replace) insert_break(head,start,start,10000,10000) end @@ -188,7 +188,7 @@ methods[3] = function(head,start) -- ) => -) local hyphen = copy_node(pre) setchar(hyphen,languages.prehyphenchar(getlanguage(pre))) setlink(hyphen,pre) - head, start = insert_node_before(head,start,new_disc(hyphen,nil,replace)) -- so not pre ! + head, start = insertnodebefore(head,start,new_disc(hyphen,nil,replace)) -- so not pre ! setattrlist(start,tmp) insert_break(head,start,start,10000,10000) end @@ -200,7 +200,7 @@ methods[4] = function(head,start) -- - => - - - if p and n then local tmp head, start, tmp = remove_node(head,start) - head, start = insert_node_before(head,start,new_disc()) + head, start = insertnodebefore(head,start,new_disc()) setattrlist(start,tmp) setdisc(start,copy_node(tmp),copy_node(tmp),tmp) insert_break(head,start,start,10000,10000) @@ -213,7 +213,7 @@ methods[5] = function(head,start,stop,settings) -- x => p q r if p and n then local tmp head, start, tmp = remove_node(head,start) - head, start = insert_node_before(head,start,new_disc()) + head, start = insertnodebefore(head,start,new_disc()) local attr = getattrlist(tmp) local font = getfont(tmp) local left = settings.left @@ -230,7 +230,7 @@ methods[5] = function(head,start,stop,settings) -- x => p q r end setdisc(start,left,right,middle) setattrlist(start,attr) - flush_node(tmp) + flushnode(tmp) insert_break(head,start,start,10000,10000) end return head, start @@ -241,7 +241,7 @@ end -- do we need to go into disc nodes (or do it as first step but then we need a pre/post font handler) function breakpoints.handler(head) - local _, current = find_attribute(head, a_breakpoints) + local _, current = findattribute(head, a_breakpoints) if current then local done = false local attr = nil @@ -304,7 +304,7 @@ function breakpoints.handler(head) end elseif id == math_code then attr = nil - current = end_of_math(current) + current = endofmath(current) if current then current = getnext(current) end @@ -398,7 +398,7 @@ function breakpoints.handler(head) end end if done then --- unset_attributes(a_breakpoints, head) +-- unsetattributes(a_breakpoints, head) end end return head diff --git a/tex/context/base/mkxl/typo-cap.lmt b/tex/context/base/mkxl/typo-cap.lmt index 3f53b65e0..03a04a17b 100644 --- a/tex/context/base/mkxl/typo-cap.lmt +++ b/tex/context/base/mkxl/typo-cap.lmt @@ -35,10 +35,10 @@ local setfont = nuts.setfont local setscales = nuts.setscales local copy_node = nuts.copy -local end_of_math = nuts.end_of_math -local insert_after = nuts.insert_after -local find_attribute = nuts.find_attribute -local unset_attributes = nuts.unset_attributes +local endofmath = nuts.endofmath +local insertafter = nuts.insertafter +local findattribute = nuts.findattribute +local unsetattributes = nuts.unsetattributes local nextglyph = nuts.traversers.glyph @@ -145,7 +145,7 @@ local function replacer(start,codes) else local g = copy_node(start) setchar(g,chr) - insert_after(start,start,g) + insertafter(start,start,g) end end elseif ifc[dc] then @@ -301,7 +301,7 @@ register(variables.cap, variables.capital) -- clone register(variables.Cap, variables.Capital) -- clone function cases.handler(head) - local _, start = find_attribute(head, a_cases) + local _, start = findattribute(head, a_cases) if start then local lastfont = { } local lastattr = nil @@ -387,7 +387,7 @@ function cases.handler(head) end else if id == math_code then - start = end_of_math(start) + start = endofmath(start) end count = 0 end @@ -396,7 +396,7 @@ function cases.handler(head) end end if done then - -- unset_attributes(a_cases,head) + -- unsetattributes(a_cases,head) end end return head diff --git a/tex/context/base/mkxl/typo-chr.lmt b/tex/context/base/mkxl/typo-chr.lmt index bb11f54a6..745a35a14 100644 --- a/tex/context/base/mkxl/typo-chr.lmt +++ b/tex/context/base/mkxl/typo-chr.lmt @@ -27,8 +27,8 @@ local wordboundary_code = boundarycodes.word local texgetnest = tex.getnest -- to be used local texsetcount = tex.setcount -local flush_node = nodes.flush_node -local flush_list = nodes.flush_list +local flushnode = nodes.flushnode +local flushlist = nodes.flushlist local settexattribute = tex.setattribute local punctuation = characters.is_punctuation @@ -68,7 +68,7 @@ local actions = { remove = function(specification) local n = pickup() if n then - flush_node(n) + flushnode(n) end end, push = function(specification) @@ -103,7 +103,7 @@ local function pickup(head,tail,str) while true do local prev = first.prev if prev and prev[a_marked] == attr then - if prev.id == par_code then -- and start_of_par(prev) + if prev.id == par_code then -- and startofpar(prev) break else first = prev @@ -140,7 +140,7 @@ local actions = { list.tail = prev prev.next = nil end - flush_list(first) + flushlist(first) end end end, diff --git a/tex/context/base/mkxl/typo-dig.lmt b/tex/context/base/mkxl/typo-dig.lmt index 7f6663db9..9e72d25c2 100644 --- a/tex/context/base/mkxl/typo-dig.lmt +++ b/tex/context/base/mkxl/typo-dig.lmt @@ -33,12 +33,11 @@ local setlink = nuts.setlink local setnext = nuts.setnext local setprev = nuts.setprev -local hpack_node = nuts.hpack -local traverse_id = nuts.traverse_id -local insert_node_before = nuts.insert_before -local insert_node_after = nuts.insert_after -local find_attribute = nuts.find_attribute -local unset_attributes = nuts.unset_attributes +local hpacknode = nuts.hpack +local insertnodebefore = nuts.insertbefore +local insertnodeafter = nuts.insertafter +local findattribute = nuts.findattribute +local unsetattributes = nuts.unsetattributes local texsetattribute = tex.setattribute local unsetvalue = attributes.unsetvalue @@ -75,16 +74,16 @@ local a_digits = attributes.private("digits") function nodes.aligned(head,start,stop,width,how) if how == "flushright" or how == "middle" then - head, start = insert_node_before(head,start,new_glue(0,65536,65536)) + head, start = insertnodebefore(head,start,new_glue(0,65536,65536)) end if how == "flushleft" or how == "middle" then - head, stop = insert_node_after(head,stop,new_glue(0,65536,65536)) + head, stop = insertnodeafter(head,stop,new_glue(0,65536,65536)) end local prv = getprev(start) local nxt = getnext(stop) setprev(start) setnext(stop) - local packed = hpack_node(start,width,"exactly") -- no directional mess here, just lr + local packed = hpacknode(start,width,"exactly") -- no directional mess here, just lr if prv then setlink(prv,packed) end @@ -117,7 +116,7 @@ actions[1] = function(head,start,attr) end function digits.handler(head) - local _, start = find_attribute(head, a_digits) + local _, start = findattribute(head, a_digits) if start then local current = head while current do @@ -138,7 +137,7 @@ function digits.handler(head) end end if done then - unset_attributes(a_digits, head) + unsetattributes(a_digits, head) end end return head diff --git a/tex/context/base/mkxl/typo-drp.lmt b/tex/context/base/mkxl/typo-drp.lmt index 2c53cc111..1885ce90d 100644 --- a/tex/context/base/mkxl/typo-drp.lmt +++ b/tex/context/base/mkxl/typo-drp.lmt @@ -57,10 +57,11 @@ local nodecodes = nodes.nodecodes local nodepool = nuts.pool local new_kern = nodepool.kern -local insert_before = nuts.insert_before -local insert_after = nuts.insert_after +local insertbefore = nuts.insertbefore +local insertafter = nuts.insertafter local remove_node = nuts.remove -local start_of_par = nuts.start_of_par + +local startofpar = nuts.startofpar local nextnode = nuts.traversers.node local nextglyph = nuts.traversers.glyph @@ -314,7 +315,7 @@ actions[v_default] = function(head,setting) texset("hangindent",hangindent,true) end if indent then - insert_after(first,first,new_kern(-parindent)) + insertafter(first,first,new_kern(-parindent)) end end return head @@ -323,7 +324,7 @@ end -- we can count ... when all done, we can disable ... function initials.handler(head) - if getid(head) == par_code and start_of_par(head) then + if getid(head) == par_code and startofpar(head) then local settings = getprop(head,a_initial) if settings then disableaction("processors","typesetters.initials.handler") diff --git a/tex/context/base/mkxl/typo-duc.lmt b/tex/context/base/mkxl/typo-duc.lmt index 07ae140e8..87190a1ab 100644 --- a/tex/context/base/mkxl/typo-duc.lmt +++ b/tex/context/base/mkxl/typo-duc.lmt @@ -76,9 +76,10 @@ local setattrlist = nuts.setattrlist local properties = nodes.properties.data local remove_node = nuts.remove -local insert_node_after = nuts.insert_after -local insert_node_before = nuts.insert_before -local start_of_par = nuts.start_of_par +local insertnodeafter = nuts.insertafter +local insertnodebefore = nuts.insertbefore + +local startofpar = nuts.startofpar local nodepool = nuts.pool local new_direction = nodepool.direction @@ -426,7 +427,7 @@ end local function get_baselevel(head,list,size,direction) if direction == lefttoright_code or direction == righttoleft_code then return direction, true - elseif getid(head) == par_code and start_of_par(head) then + elseif getid(head) == par_code and startofpar(head) then direction = getdirection(head) if direction == lefttoright_code or direction == righttoleft_code then return direction, true @@ -969,18 +970,18 @@ local function apply_to_list(list,size,head,pardir) c = p end -- there is always a par nodes so head will stay - head = insert_node_before(head,c,new_direction(enddir,true)) + head = insertnodebefore(head,c,new_direction(enddir,true)) enddir = false end elseif begindir then - if id == par_code and start_of_par(current) then + if id == par_code and startofpar(current) then -- par should always be the 1st node - head, current = insert_node_after(head,current,new_direction(begindir)) + head, current = insertnodeafter(head,current,new_direction(begindir)) begindir = nil end end if begindir then - head = insert_node_before(head,current,new_direction(begindir)) + head = insertnodebefore(head,current,new_direction(begindir)) end local skip = entry.skip if skip and skip > 0 then @@ -995,7 +996,7 @@ local function apply_to_list(list,size,head,pardir) end end if enddir then - head, current = insert_node_after(head,current,new_direction(enddir,true)) + head, current = insertnodeafter(head,current,new_direction(enddir,true)) end if not entry.remove then current = getnext(current) diff --git a/tex/context/base/mkxl/typo-fln.lmt b/tex/context/base/mkxl/typo-fln.lmt index fa507df4b..8d1553d4c 100644 --- a/tex/context/base/mkxl/typo-fln.lmt +++ b/tex/context/base/mkxl/typo-fln.lmt @@ -62,15 +62,15 @@ local spaceskip_code = nodes.gluecodes.spaceskip local nextglyph = nuts.traversers.glyph local nextdisc = nuts.traversers.disc -local flush_node_list = nuts.flush_list -local flush_node = nuts.flush_node -local copy_node_list = nuts.copy_list -local insert_node_before = nuts.insert_before -local insert_node_after = nuts.insert_after +local flushnodelist = nuts.flushlist +local flushnode = nuts.flushnode +local copy_node_list = nuts.copylist +local insertnodebefore = nuts.insertbefore +local insertnodeafter = nuts.insertafter local remove_node = nuts.remove local getdimensions = nuts.dimensions local hpack_node_list = nuts.hpack -local start_of_par = nuts.start_of_par +local startofpar = nuts.startofpar local setcoloring = nuts.colors.set @@ -180,7 +180,7 @@ actions[v_line] = function(head,setting) -- temp = typesetters.kerns.handler(temp) -- maybe when enabled -- temp = typesetters.cases.handler(temp) -- maybe when enabled local width = getdimensions(temp) - flush_node_list(temp) + flushnodelist(temp) return width end @@ -228,7 +228,7 @@ actions[v_line] = function(head,setting) end end - flush_node_list(temp) + flushnodelist(temp) local start = head local n = 0 @@ -288,11 +288,11 @@ actions[v_line] = function(head,setting) end end setdisc(disc,pre,post,replace) - flush_node(disc) + flushnode(disc) elseif id == glue_code then n = n + 1 if linebreak ~= n then - head = insert_node_before(head,start,newpenalty(10000)) -- nobreak + head = insertnodebefore(head,start,newpenalty(10000)) -- nobreak end end local next = getnext(start) @@ -300,11 +300,11 @@ actions[v_line] = function(head,setting) if start ~= head then local where = id == glue_code and getprev(start) or start if trace_firstlines then - head, where = insert_node_after(head,where,newpenalty(10000)) -- nobreak - head, where = insert_node_after(head,where,newkern(-65536)) - head, where = insert_node_after(head,where,tracerrule(65536,4*65536,2*65536,"darkblue")) + head, where = insertnodeafter(head,where,newpenalty(10000)) -- nobreak + head, where = insertnodeafter(head,where,newkern(-65536)) + head, where = insertnodeafter(head,where,tracerrule(65536,4*65536,2*65536,"darkblue")) end - head, where = insert_node_after(head,where,newpenalty(-10000)) -- break + head, where = insertnodeafter(head,where,newpenalty(-10000)) -- break end start = next break @@ -358,7 +358,7 @@ end actions[v_default] = actions[v_line] function firstlines.handler(head) - if getid(head) == par_code and start_of_par(head) then + if getid(head) == par_code and startofpar(head) then local settings = getprop(head,a_firstline) if settings then disableaction("processors","typesetters.firstlines.handler") diff --git a/tex/context/base/mkxl/typo-hid.lmt b/tex/context/base/mkxl/typo-hid.lmt index e3b7567d9..45dde4979 100644 --- a/tex/context/base/mkxl/typo-hid.lmt +++ b/tex/context/base/mkxl/typo-hid.lmt @@ -17,7 +17,7 @@ local getprev = nuts.getprev local setlist = nuts.setlist local setlink = nuts.setlink local nextnode = nuts.traversers.node -local flushlist = nuts.flush_list +local flushlist = nuts.flushlist local dimensions = nuts.rangedimensions local hpack = nuts.hpack local setwhd = nuts.setwhd diff --git a/tex/context/base/mkxl/typo-itc.lmt b/tex/context/base/mkxl/typo-itc.lmt index 4350053b3..74c47355f 100644 --- a/tex/context/base/mkxl/typo-itc.lmt +++ b/tex/context/base/mkxl/typo-itc.lmt @@ -44,9 +44,9 @@ local setkern = nuts.setkern local getkern = nuts.getkern local getheight = nuts.getheight -local insert_node_after = nuts.insert_after +local insertnodeafter = nuts.insertafter local remove_node = nuts.remove -local end_of_math = nuts.end_of_math +local endofmath = nuts.endofmath local texgetattribute = tex.getattribute local texsetattribute = tex.setattribute @@ -184,7 +184,7 @@ local enablemath = false local enabletext = false local function domath(head,current) - current = end_of_math(current) + current = endofmath(current) local next = getnext(current) if next then local char, id = isglyph(next) @@ -253,7 +253,7 @@ local function domath(head,current) if trace_italics then report_italics("%s italic %p between math %C and non punctuation %C","adding",a,getchar(glyph),char) end - insert_node_after(head,glyph,correction_kern(a,glyph)) + insertnodeafter(head,glyph,correction_kern(a,glyph)) end end end @@ -311,7 +311,7 @@ local function texthandler(head) if font ~= lastfont then if previtalic ~= 0 then if okay(data,current,font,prevchar,previtalic,char,"glyph") then - insert_node_after(prevhead,prev,correction_kern(previtalic,current)) + insertnodeafter(prevhead,prev,correction_kern(previtalic,current)) end elseif previnserted and data then if trace_italics then @@ -322,7 +322,7 @@ local function texthandler(head) -- if replaceitalic ~= 0 then if okay(data,replace,font,replacechar,replaceitalic,char,"replace") then - insert_node_after(replacehead,replace,correction_kern(replaceitalic,current)) + insertnodeafter(replacehead,replace,correction_kern(replaceitalic,current)) end replaceitalic = 0 elseif replaceinserted and data then @@ -334,7 +334,7 @@ local function texthandler(head) -- if postitalic ~= 0 then if okay(data,post,font,postchar,postitalic,char,"post") then - insert_node_after(posthead,post,correction_kern(postitalic,current)) + insertnodeafter(posthead,post,correction_kern(postitalic,current)) end postitalic = 0 elseif postinserted and data then @@ -486,7 +486,7 @@ local function texthandler(head) end previnserted = correction_glue(previtalic,current) -- maybe just add ? else problem with penalties previtalic = 0 - insert_node_after(prevhead,prev,previnserted) + insertnodeafter(prevhead,prev,previnserted) else if replaceitalic ~= 0 then if trace_italics then @@ -494,7 +494,7 @@ local function texthandler(head) end replaceinserted = correction_kern(replaceitalic,current) -- needs to be a kern replaceitalic = 0 - insert_node_after(replacehead,replace,replaceinserted) + insertnodeafter(replacehead,replace,replaceinserted) end if postitalic ~= 0 then if trace_italics then @@ -502,7 +502,7 @@ local function texthandler(head) end postinserted = correction_kern(postitalic,current) -- needs to be a kern postitalic = 0 - insert_node_after(posthead,post,postinserted) + insertnodeafter(posthead,post,postinserted) end end elseif id == math_code then @@ -516,14 +516,14 @@ local function texthandler(head) if mathokay then current = domath(head,current) else - current = end_of_math(current) + current = endofmath(current) end else if previtalic ~= 0 then if trace_italics then report_italics("inserting %p between %s italic %C and whatever",previtalic,"glyph",prevchar) end - insert_node_after(prevhead,prev,correction_kern(previtalic,current)) + insertnodeafter(prevhead,prev,correction_kern(previtalic,current)) previnserted = nil previtalic = 0 replaceinserted = nil @@ -535,7 +535,7 @@ local function texthandler(head) if trace_italics then report_italics("inserting %p between %s italic %C and whatever",replaceitalic,"replace",replacechar) end - insert_node_after(replacehead,replace,correction_kern(replaceitalic,current)) + insertnodeafter(replacehead,replace,correction_kern(replaceitalic,current)) previnserted = nil previtalic = 0 replaceinserted = nil @@ -547,7 +547,7 @@ local function texthandler(head) if trace_italics then report_italics("inserting %p between %s italic %C and whatever",postitalic,"post",postchar) end - insert_node_after(posthead,post,correction_kern(postitalic,current)) + insertnodeafter(posthead,post,correction_kern(postitalic,current)) previnserted = nil previtalic = 0 replaceinserted = nil @@ -564,19 +564,19 @@ local function texthandler(head) if trace_italics then report_italics("inserting %p between %s italic %C and end of list",previtalic,"glyph",prevchar) end - insert_node_after(prevhead,prev,correction_kern(previtalic,current)) + insertnodeafter(prevhead,prev,correction_kern(previtalic,current)) else if replaceitalic ~= 0 then if trace_italics then report_italics("inserting %p between %s italic %C and end of list",replaceitalic,"replace",replacechar) end - insert_node_after(replacehead,replace,correction_kern(replaceitalic,current)) + insertnodeafter(replacehead,replace,correction_kern(replaceitalic,current)) end if postitalic ~= 0 then if trace_italics then report_italics("inserting %p between %s italic %C and end of list",postitalic,"post",postchar) end - insert_node_after(posthead,post,correction_kern(postitalic,current)) + insertnodeafter(posthead,post,correction_kern(postitalic,current)) end end end diff --git a/tex/context/base/mkxl/typo-krn.lmt b/tex/context/base/mkxl/typo-krn.lmt index a8ccedccf..450194767 100644 --- a/tex/context/base/mkxl/typo-krn.lmt +++ b/tex/context/base/mkxl/typo-krn.lmt @@ -24,13 +24,12 @@ local nodepool = nuts.pool -- check what is used local find_node_tail = nuts.tail -local flush_node = nuts.flush_node -local insert_node_before = nuts.insert_before -local insert_node_after = nuts.insert_after -local end_of_math = nuts.end_of_math +local insertnodebefore = nuts.insertbefore +local insertnodeafter = nuts.insertafter +local endofmath = nuts.endofmath local copy_node = nuts.copy -local find_attribute = nuts.find_attribute -local unset_attributes = nuts.unset_attributes +local findattribute = nuts.findattribute +local unsetattributes = nuts.unsetattributes local getnext = nuts.getnext local getprev = nuts.getprev @@ -130,7 +129,7 @@ local factors = kerns.factors -- make sure it runs after all others -- there will be a width adaptor field in nodes so this will change -- todo: interchar kerns / disc nodes / can be made faster --- todo: use insert_before etc +-- todo: use insertbefore etc local gluefactor = 4 -- assumes quad = .5 enspace @@ -332,7 +331,7 @@ local function process_list(head,keeptogether,krn,font,okay) -- if kerns then -- print("it happens indeed, basemode kerns not yet injected") -- end - insert_node_before(head,start,new_kern((kerns and kerns[char] or 0) + kern)) + insertnodebefore(head,start,new_kern((kerns and kerns[char] or 0) + kern)) okay = true end end @@ -366,7 +365,7 @@ local function closest_bound(b,get) end function kerns.handler(head) - local _, start = find_attribute(head, a_kerns) + local _, start = findattribute(head, a_kerns) if start then local lastfont = nil local keepligature = kerns.keepligature @@ -415,7 +414,7 @@ function kerns.handler(head) setattr(n,a_kerns,attr) -- we took away the attr end setchar(n,unicode[i]) - insert_node_after(head,s,n) + insertnodeafter(head,s,n) s = n end end @@ -447,10 +446,10 @@ function kerns.handler(head) local data = chardata[font][prevchar] local kerns = data and data.kerns local kern = (kerns and kerns[char] or 0) + quaddata[font]*krn - insert_node_before(head,start,kern_injector(fillup,kern)) + insertnodebefore(head,start,kern_injector(fillup,kern)) end else - insert_node_before(head,start,kern_injector(fillup,quaddata[font]*krn)) + insertnodebefore(head,start,kern_injector(fillup,quaddata[font]*krn)) end end prev = start @@ -560,16 +559,16 @@ function kerns.handler(head) -- special case local b, f = closest_bound(start,getprev) if b then - insert_node_before(head,start,kern_injector(fillup,quaddata[f]*krn)) + insertnodebefore(head,start,kern_injector(fillup,quaddata[f]*krn)) end local b, f = closest_bound(start,getnext) if b then - insert_node_after(head,start,kern_injector(fillup,quaddata[f]*krn)) + insertnodeafter(head,start,kern_injector(fillup,quaddata[f]*krn)) end end bound = false elseif id == math_code then - start = end_of_math(start) + start = endofmath(start) bound = false end if start then @@ -590,7 +589,7 @@ function kerns.handler(head) end end if done then - -- unset_attributes(a_kerns, head) + -- unsetattributes(a_kerns, head) end end return head diff --git a/tex/context/base/mkxl/typo-lin.lmt b/tex/context/base/mkxl/typo-lin.lmt index 86365c3ba..783faeabf 100644 --- a/tex/context/base/mkxl/typo-lin.lmt +++ b/tex/context/base/mkxl/typo-lin.lmt @@ -68,8 +68,8 @@ local tonut = nodes.tonut local tonode = nodes.tonode local nexthlist = nuts.traversers.hlist -local insert_before = nuts.insert_before -local insert_after = nuts.insert_after +local insertbefore = nuts.insertbefore +local insertafter = nuts.insertafter local getlist = nuts.getlist local setlist = nuts.setlist @@ -89,7 +89,7 @@ local getnormalizedline = nuts.getnormalizedline local setprop = nuts.setprop local getprop = nuts.rawprop -- getprop -local effectiveglue = nuts.effective_glue +local effectiveglue = nuts.effectiveglue local nodepool = nuts.pool local new_kern = nodepool.kern @@ -127,9 +127,9 @@ local function finalize(prop,key) -- delayed calculations end local kern1 = new_kern(delta) local kern2 = new_kern(-delta) - head = insert_before(head,head,kern1) -- setlink - head = insert_before(head,head,pack) - head = insert_before(head,head,kern2) + head = insertbefore(head,head,kern1) -- setlink + head = insertbefore(head,head,pack) + head = insertbefore(head,head,kern2) setlist(line,head) local where = { pack = pack, @@ -193,10 +193,10 @@ local function addtoline(n,list,option) if trace_anchors and not line.traced then line.traced = true local rule = new_rule(2*65536,2*65536,1*65536) - local list = insert_before(rule,rule,new_kern(-1*65536)) + local list = insertbefore(rule,rule,new_kern(-1*65536)) addtoline(n,list) local rule = new_rule(2*65536,6*65536,-3*65536) - local list = insert_before(rule,rule,new_kern(-1*65536)) + local list = insertbefore(rule,rule,new_kern(-1*65536)) addtoline(n,list,"internal") else line.traced = true @@ -219,14 +219,14 @@ local function addtoline(n,list,option) -- optimize now .. we can also decide to put each blob in a hlist local kern = new_kern(delta) if tail then - head, tail = insert_after(head,tail,kern) + head, tail = insertafter(head,tail,kern) else head, tail = kern, kern setlist(where.pack,head) end - head, tail = insert_after(head,tail,blob) + head, tail = insertafter(head,tail,blob) local kern = new_kern(-delta) - head, tail = insert_after(head,tail,kern) + head, tail = insertafter(head,tail,kern) -- where.head = head where.tail = tail @@ -256,7 +256,7 @@ local function addanchortoline(n,anchor) end if where.tail then local head = where.head - insert_before(head,head,anchor) + insertbefore(head,head,anchor) else where.tail = anchor end diff --git a/tex/context/base/mkxl/typo-mar.lmt b/tex/context/base/mkxl/typo-mar.lmt index 7e69162a9..f8c135fa7 100644 --- a/tex/context/base/mkxl/typo-mar.lmt +++ b/tex/context/base/mkxl/typo-mar.lmt @@ -61,9 +61,9 @@ local v_line = variables.line local nuts = nodes.nuts local tonode = nuts.tonode -local hpack_nodes = nuts.hpack -local traverse_id = nuts.traverse_id -local flush_node_list = nuts.flush_list +local hpacknodes = nuts.hpack +local traverseid = nuts.traverseid +local flushnodelist = nuts.flushlist local getnext = nuts.getnext local getprev = nuts.getprev @@ -251,7 +251,7 @@ function margins.save(t) local si = store[i] if si.name == name then local s = remove(store,i) - flush_node_list(s.box) + flushnodelist(s.box) end end else @@ -259,7 +259,7 @@ function margins.save(t) local si = store[i] if si.name == name then local s = remove(store,i) - flush_node_list(s.box) + flushnodelist(s.box) end end end @@ -492,9 +492,9 @@ local function markovershoot(current) -- todo: alleen als offset > line v_anchors = v_anchors + 1 cache[v_anchors] = fastcopy(stacked) local anchor = setanchor(v_anchors) - -- local list = hpack_nodes(setlink(anchor,getlist(current))) -- not ok, we need to retain width + -- local list = hpacknodes(setlink(anchor,getlist(current))) -- not ok, we need to retain width -- local list = setlink(anchor,getlist(current)) -- why not this ... better play safe - local list = hpack_nodes(setlink(anchor,getlist(current)),getwidth(current),"exactly")-- + local list = hpacknodes(setlink(anchor,getlist(current)),getwidth(current),"exactly")-- if trace_marginstack then report_margindata("marking anchor %a",v_anchors) end @@ -790,7 +790,7 @@ local function flushed(scope,parent) -- current is hlist if done then local a = getattr(head,a_linenumber) -- hack .. we need a more decent critical attribute inheritance mechanism if false then - local l = hpack_nodes(head,getwidth(parent),"exactly") + local l = hpacknodes(head,getwidth(parent),"exactly") setlist(parent,l) if a then setattr(l,a_linenumber,a) @@ -905,7 +905,7 @@ end local function finalhandler(head) if nofdelayed > 0 then local current = head - while current and nofdelayed > 0 do -- traverse_list + while current and nofdelayed > 0 do local id = getid(current) if id == hlist_code then -- only lines? local a = getprop(current,"margindata") diff --git a/tex/context/base/mkxl/typo-pag.lmt b/tex/context/base/mkxl/typo-pag.lmt index 9f8a3a1f4..d9b910e86 100644 --- a/tex/context/base/mkxl/typo-pag.lmt +++ b/tex/context/base/mkxl/typo-pag.lmt @@ -39,7 +39,7 @@ local setpenalty = nuts.setpenalty local getwidth = nuts.getwidth local getdepth = nuts.getdepth -local insert_node_after = nuts.insert_after +local insertnodeafter = nuts.insertafter local new_penalty = nuts.pool.penalty local trace_keeptogether = false @@ -129,7 +129,7 @@ local function keeptogether(start,a,specification) if getid(previous) == penalty_code then setpenalty(previous,10000) else - insert_node_after(head,previous,new_penalty(10000)) + insertnodeafter(head,previous,new_penalty(10000)) end else break @@ -144,7 +144,7 @@ local function keeptogether(start,a,specification) if getid(previous) == penalty_code then setpenalty(previous,10000) else - insert_node_after(head,previous,new_penalty(10000)) + insertnodeafter(head,previous,new_penalty(10000)) end else break @@ -158,7 +158,7 @@ local function keeptogether(start,a,specification) if getid(previous) == penalty_code then setpenalty(previous,10000) else - insert_node_after(head,previous,new_penalty(10000)) + insertnodeafter(head,previous,new_penalty(10000)) end else break diff --git a/tex/context/base/mkxl/typo-rub.lmt b/tex/context/base/mkxl/typo-rub.lmt index 82aa3c269..eff522e02 100644 --- a/tex/context/base/mkxl/typo-rub.lmt +++ b/tex/context/base/mkxl/typo-rub.lmt @@ -49,7 +49,6 @@ local getwidth = nuts.getwidth local setwidth = nuts.setwidth local hpack = nuts.hpack -local insert_after = nuts.insert_after local takebox = nuts.takebox local nextlist = nuts.traversers.list diff --git a/tex/context/base/mkxl/typo-shp.lmt b/tex/context/base/mkxl/typo-shp.lmt index 30719c40e..139468a19 100644 --- a/tex/context/base/mkxl/typo-shp.lmt +++ b/tex/context/base/mkxl/typo-shp.lmt @@ -14,7 +14,7 @@ local texset = tex.set local texgetcount = tex.getcount local texgetglue = tex.getglue -local expandmacro = token.expand_macro +local expandmacro = token.expandmacro or token.expand_macro -- todo local implement = interfaces.implement @@ -217,6 +217,8 @@ do a = l + r goto AGAIN end + elseif key == "inspect" then + inspect(t) else logs.report("system","bad key %a in paragraphshape",key) break diff --git a/tex/context/base/mkxl/typo-shp.mkxl b/tex/context/base/mkxl/typo-shp.mkxl index b74003068..6201012fe 100644 --- a/tex/context/base/mkxl/typo-shp.mkxl +++ b/tex/context/base/mkxl/typo-shp.mkxl @@ -45,6 +45,19 @@ %D But we wrap this in a more abstract interface: \installcorenamespace {parshapes} +\installcorenamespace {shapedparagraph} + +\installbasicnativeautosetuphandler \??shapedparagraph {shapedparagraph} + +\setupshapedparagraph + [\c!method=, + \c!list=, + \c!lines=\zerocount, + \c!mp=, + \c!repeat=, + \c!hoffset=\zeropoint, + \c!voffset=\zeropoint, + \c!distance=\zeropoint] \aliased\let\stopparagraphshape\relax @@ -62,20 +75,103 @@ \def\spac_shapes_calculate#1% called locally in \LUA {\startMPcalculation \includeMPgraphic{#1} \stopMPcalculation} -\permanent\protected\tolerant\def\startshapedparagraph[#1]% no grouping - {\begingroup - \getdummyparameters[\c!method=,\c!list=,\c!mp=,\c!repeat=,#1]% - \edef\p_mp {\dummyparameter\c!mp}% - \edef\p_repeat{\dummyparameter\c!repeat}% - \setlocalhsize +% \permanent\protected\tolerant\def\startshapedparagraph[#1]% no grouping +% {\begingroup +% \let\currentshapedparagraph\empty +% \setupshapedparagraph[#1]% +% \edef\p_mp {\shapedparagraphparameter\c!mp}% +% \edef\p_repeat{\shapedparagraphparameter\c!repeat}% +% \setlocalhsize +% \normalexpanded +% {\endgroup +% \ifempty\p_mp +% \setparagraphshape[\shapedparagraphparameter\c!list]% +% \else +% \setparagraphmetashape[\shapedparagraphparameter\c!mp][\ifx\p_repeat\v!yes repeat\fi]% +% \fi +% \pushparagraphtweak{\shapedparagraphparameter\c!method}\relax}} + +\newbox\b_spac_shapes + +\def\spac_shapes_list + {\edef\p_mp {\shapedparagraphparameter\c!mp}% + \edef\p_repeat{\shapedparagraphparameter\c!repeat}% \normalexpanded {\endgroup \ifempty\p_mp - \setparagraphshape[\dummyparameter\c!list]% + \setparagraphshape[\shapedparagraphparameter\c!list]% \else - \setparagraphmetashape[\dummyparameter\c!mp][\ifx\p_repeat\v!yes repeat\fi]% + \setparagraphmetashape[\p_mp][\ifx\p_repeat\v!yes repeat\fi]% \fi - \pushparagraphtweak{\dummyparameter\c!method}\relax}} + \pushparagraphtweak{\shapedparagraphparameter\c!method}\relax}} + +\def\spac_shapes_text + {\getnoflines{\dimexpr\htdp\b_spac_shapes+\shapedparagraphparameter\c!voffset}% + \normalexpanded + {\endgroup + \clf_setparagraphshape + left \the\dimexpr + \wd\b_spac_shapes+\shapedparagraphparameter\c!distance + +\shapedparagraphparameter\c!hoffset + \relax + right \zeropoint + copy \the\numexpr + \noflines + +\shapedparagraphparameter\c!lines + \relax + left \zeropoint + right \zeropoint + % inspect + done + \relax + \pushparagraphtweak{shift}% + \dontleavehmode + \vtop + xoffset \the\dimexpr + -\shapedparagraphparameter\c!distance + -\wd\b_spac_shapes + \relax + yoffset \the\dimexpr + \shapedparagraphparameter\c!voffset + +\strutht + \relax + {\smashbox\b_spac_shapes + \box\b_spac_shapes}}} + +\def\spac_shapes_lines + {\normalexpanded + {\endgroup + \clf_setparagraphshape + left \shapedparagraphparameter\c!width + right \zeropoint + copy \shapedparagraphparameter\c!lines + left \zeropoint + right \zeropoint + % inspect + done + \relax + \pushparagraphtweak{shift}}} + +\permanent\protected\tolerant\def\startshapedparagraph[#1]% no grouping + {\begingroup + \let\currentshapedparagraph\empty + \setupshapedparagraph[#1]% + \setlocalhsize + \doifsomething{\shapedparagraphparameter\c!text} + {\global\setbox\b_spac_shapes\vpack\bgroup + \forgetall + \shapedparagraphparameter\c!text + \egroup}% + \ifvoid\b_spac_shapes + \ifnum\shapedparagraphparameter\c!lines>\zerocount + \spac_shapes_lines + \else + \spac_shapes_list + \fi + \else + \spac_shapes_text + \fi + \ignorespaces} \permanent\protected\def\stopshapedparagraph {\popparagraphtweak} diff --git a/tex/context/base/mkxl/typo-spa.lmt b/tex/context/base/mkxl/typo-spa.lmt index f453814fb..88ade876e 100644 --- a/tex/context/base/mkxl/typo-spa.lmt +++ b/tex/context/base/mkxl/typo-spa.lmt @@ -29,12 +29,12 @@ local getprev = nuts.getprev local getattr = nuts.getattr local isglyph = nuts.isglyph -local insert_node_before = nuts.insert_before -local insert_node_after = nuts.insert_after +local insertnodebefore = nuts.insertbefore +local insertnodeafter = nuts.insertafter local remove_node = nuts.remove -local end_of_math = nuts.end_of_math -local unset_attributes = nuts.unset_attributes -local find_attribute = nuts.find_attribute +local endofmath = nuts.endofmath +local unsetattributes = nuts.unsetattributes +local findattribute = nuts.findattribute local nodepool = nuts.pool local new_penalty = nodepool.penalty @@ -72,7 +72,7 @@ end -- todo cache lastattr function spacings.handler(head) - local _, start = find_attribute(head, a_spacings) + local _, start = findattribute(head, a_spacings) if start then local done = false -- head is always begin of par (whatsit), so we have at least two prev nodes @@ -118,8 +118,8 @@ function spacings.handler(head) if trace_spacing then report_spacing("inserting penalty and space before %C (left)",char) end - insert_node_before(head,start,new_penalty(10000)) - insert_node_before(head,start,new_glue(left*quad)) + insertnodebefore(head,start,new_penalty(10000)) + insertnodebefore(head,start,new_glue(left*quad)) end end local next = getnext(start) @@ -149,8 +149,8 @@ function spacings.handler(head) if trace_spacing then report_spacing("inserting penalty and space after %C (right)",char) end - insert_node_after(head,start,new_glue(right*quad)) - insert_node_after(head,start,new_penalty(10000)) + insertnodeafter(head,start,new_glue(right*quad)) + insertnodeafter(head,start,new_penalty(10000)) end end end @@ -158,14 +158,14 @@ function spacings.handler(head) done = true end elseif id == math_code then - start = end_of_math(start) -- weird, can return nil .. no math end? + start = endofmath(start) -- weird, can return nil .. no math end? end if start then start = getnext(start) end end if done then - -- unset_attributes(a_spacings,head) + -- unsetattributes(a_spacings,head) end end return head diff --git a/tex/context/base/mkxl/typo-sus.lmt b/tex/context/base/mkxl/typo-sus.lmt index 2c6d9ea69..b8d0d1cd9 100644 --- a/tex/context/base/mkxl/typo-sus.lmt +++ b/tex/context/base/mkxl/typo-sus.lmt @@ -59,9 +59,9 @@ local setattr = nuts.setattr local setlist = nuts.setlist local setcolor = nodes.tracers.colors.set -local insert_before = nuts.insert_before -local insert_after = nuts.insert_after -local end_of_math = nuts.end_of_math +local insertbefore = nuts.insertbefore +local insertafter = nuts.insertafter +local endofmath = nuts.endofmath local nodepool = nuts.pool @@ -127,22 +127,22 @@ local function mark(head,current,id,color) local width = getwidth(current) local rule = new_rule(width) local kern = new_kern(-width) - head = insert_before(head,current,rule) - head = insert_before(head,current,kern) + head = insertbefore(head,current,rule) + head = insertbefore(head,current,kern) setcolor(rule,color) -- elseif id == kern_code then -- local width = getkern(current) -- local rule = new_rule(width) -- local kern = new_kern(-width) - -- head = insert_before(head,current,rule) - -- head = insert_before(head,current,kern) + -- head = insertbefore(head,current,rule) + -- head = insertbefore(head,current,kern) -- setcolor(rule,color) else local width, height, depth = getwhd(current) local extra = fonts.hashes.xheights[getfont(current)] / 2 local rule = new_rule(width,height+extra,depth+extra) local hlist = new_hlist(rule) - head = insert_before(head,current,hlist) + head = insertbefore(head,current,hlist) setcolor(rule,color) setcolor(current,"white") end @@ -230,7 +230,7 @@ function typesetters.marksuspects(head) end current = getnext(current) elseif id == math_code then - current = getnext(end_of_math(current)) + current = getnext(endofmath(current)) elseif id == glue_code then local a = getattr(current,a_characters) if a then @@ -273,7 +273,7 @@ local function showsuspects(head) head, current = mark(head,current,id,colors[a]) end elseif id == math_code then - current = end_of_math(current) + current = endofmath(current) elseif id == hlist_code or id == vlist_code then local list = getlist(current) if list then diff --git a/tex/context/base/mkxl/typo-tal.lmt b/tex/context/base/mkxl/typo-tal.lmt index 5c32e9ef9..e5431cffc 100644 --- a/tex/context/base/mkxl/typo-tal.lmt +++ b/tex/context/base/mkxl/typo-tal.lmt @@ -47,8 +47,8 @@ local isglyph = nuts.isglyph local setattr = nuts.setattr local setchar = nuts.setchar -local insert_node_before = nuts.insert_before -local insert_node_after = nuts.insert_after +local insertnodebefore = nuts.insertbefore +local insertnodeafter = nuts.insertafter local nextglyph = nuts.traversers.glyph local getdimensions = nuts.dimensions @@ -393,46 +393,46 @@ function characteralign.handler(head,where) local new_kern = trace_split and traced_kern or new_kern if b_start then if before < maxbefore then - head = insert_node_before(head,b_start,new_kern(maxbefore-before)) + head = insertnodebefore(head,b_start,new_kern(maxbefore-before)) end if not c then -- print("[before]") if dataset.hasseparator then local width = fontcharacters[getfont(b_start)][separator].width - insert_node_after(head,b_stop,new_kern(maxafter+width)) + insertnodeafter(head,b_stop,new_kern(maxafter+width)) end elseif a_start then -- print("[before] [separator] [after]") if after < maxafter then - insert_node_after(head,a_stop,new_kern(maxafter-after)) + insertnodeafter(head,a_stop,new_kern(maxafter-after)) end else -- print("[before] [separator]") if maxafter > 0 then - insert_node_after(head,c,new_kern(maxafter)) + insertnodeafter(head,c,new_kern(maxafter)) end end elseif a_start then if c then -- print("[separator] [after]") if maxbefore > 0 then - head = insert_node_before(head,c,new_kern(maxbefore)) + head = insertnodebefore(head,c,new_kern(maxbefore)) end else -- print("[after]") local width = fontcharacters[getfont(b_stop)][separator].width - head = insert_node_before(head,a_start,new_kern(maxbefore+width)) + head = insertnodebefore(head,a_start,new_kern(maxbefore+width)) end if after < maxafter then - insert_node_after(head,a_stop,new_kern(maxafter-after)) + insertnodeafter(head,a_stop,new_kern(maxafter-after)) end elseif c then -- print("[separator]") if maxbefore > 0 then - head = insert_node_before(head,c,new_kern(maxbefore)) + head = insertnodebefore(head,c,new_kern(maxbefore)) end if maxafter > 0 then - insert_node_after(head,c,new_kern(maxafter)) + insertnodeafter(head,c,new_kern(maxafter)) end end return head diff --git a/tex/context/base/mkxl/typo-wrp.mkxl b/tex/context/base/mkxl/typo-wrp.mkxl index b552c151a..92af2058e 100644 --- a/tex/context/base/mkxl/typo-wrp.mkxl +++ b/tex/context/base/mkxl/typo-wrp.mkxl @@ -34,7 +34,7 @@ \ignorespaces} \protected\def\spac_crlf_placeholder - {\strut} + {\wordboundary\strut} % or \endstrut \protected\def\spac_crlf_placeholder_show {\wordboundary |