summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/node-nut.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-07-14 21:22:10 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-07-14 21:22:10 +0200
commit23b495f46b4d2e9264d54095f43774ef47d3a656 (patch)
tree1b0131b93d92d4aa7e15b55c50ad1dfa3573a7e1 /tex/context/base/mkiv/node-nut.lua
parent6ae40572e7643edcc29f8d5b071221dd1e04bdf3 (diff)
downloadcontext-23b495f46b4d2e9264d54095f43774ef47d3a656.tar.gz
2017-07-14 19:41:00
Diffstat (limited to 'tex/context/base/mkiv/node-nut.lua')
-rw-r--r--tex/context/base/mkiv/node-nut.lua79
1 files changed, 68 insertions, 11 deletions
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
+