From 23b495f46b4d2e9264d54095f43774ef47d3a656 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 14 Jul 2017 21:22:10 +0200 Subject: 2017-07-14 19:41:00 --- tex/context/base/mkiv/node-nut.lua | 79 ++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 11 deletions(-) (limited to 'tex/context/base/mkiv/node-nut.lua') diff --git a/tex/context/base/mkiv/node-nut.lua b/tex/context/base/mkiv/node-nut.lua index 787afd888..87df5d5b2 100644 --- a/tex/context/base/mkiv/node-nut.lua +++ b/tex/context/base/mkiv/node-nut.lua @@ -283,8 +283,9 @@ nuts.has_attribute = direct.has_attribute nuts.set_attribute = direct.set_attribute nuts.unset_attribute = direct.unset_attribute -nuts.protect_glyphs = direct.protect_glyphs nuts.protect_glyph = direct.protect_glyph +nuts.protect_glyphs = direct.protect_glyphs +nuts.unprotect_glyph = direct.unprotect_glyph nuts.unprotect_glyphs = direct.unprotect_glyphs nuts.ligaturing = direct.ligaturing nuts.kerning = direct.kerning @@ -409,18 +410,32 @@ local d_setlink = direct.setlink local d_setboth = direct.setboth local d_getboth = direct.getboth +-- local function remove(head,current,free_too) +-- local t = current +-- head, current = d_remove_node(head,current) +-- if not t then +-- -- forget about it +-- elseif free_too then +-- d_flush_node(t) +-- t = nil +-- else +-- d_setboth(t) -- (t,nil,nil) +-- end +-- return head, current, t +-- end + local function remove(head,current,free_too) - local t = current - head, current = d_remove_node(head,current) - if not t then - -- forget about it - elseif free_too then - d_flush_node(t) - t = nil - else - d_setboth(t) -- (t,nil,nil) + if current then + local h, c = d_remove_node(head,current) + if free_too then + d_flush_node(current) + return h, c + else + d_setboth(current) + return h, c, current + end end - return head, current, t + return head, current end -- alias @@ -902,3 +917,45 @@ if not nuts.uses_font then end +-- for the moment (pre 6380) + +if not nuts.unprotect_glyph then + + local protect_glyph = nuts.protect_glyph + local protect_glyphs = nuts.protect_glyphs + local unprotect_glyph = nuts.unprotect_glyph + local unprotect_glyphs = nuts.unprotect_glyphs + + local getnext = nuts.getnext + local setnext = nuts.setnext + + function nuts.protectglyphs(first,last) + if first == last then + return protect_glyph(first) + elseif last then + local nxt = getnext(last) + setnext(last) + local f, b = protect_glyphs(first) + setnext(last,nxt) + return f, b + else + return protect_glyphs(first) + end + end + + function nuts.unprotectglyphs(first,last) + if first == last then + return unprotect_glyph(first) + elseif last then + local nxt = getnext(last) + setnext(last) + local f, b = unprotect_glyphs(first) + setnext(last,nxt) + return f, b + else + return unprotect_glyphs(first) + end + end + +end + -- cgit v1.2.3