summaryrefslogtreecommitdiff
path: root/tex/context/base/lang-wrd.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2014-05-03 13:55:34 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2014-05-03 13:55:34 +0200
commit624cbb5da392e9403984dd1cf368c0d408b1c2a8 (patch)
tree489c049ac849bb5bbce7d32e4df477872c58373d /tex/context/base/lang-wrd.lua
parent088de88944c1f2254250bb448c7371a87ff7ee39 (diff)
downloadcontext-624cbb5da392e9403984dd1cf368c0d408b1c2a8.tar.gz
2014-01-03 00:42:00
Diffstat (limited to 'tex/context/base/lang-wrd.lua')
-rw-r--r--tex/context/base/lang-wrd.lua37
1 files changed, 12 insertions, 25 deletions
diff --git a/tex/context/base/lang-wrd.lua b/tex/context/base/lang-wrd.lua
index 5fc23757e..bf066fc09 100644
--- a/tex/context/base/lang-wrd.lua
+++ b/tex/context/base/lang-wrd.lua
@@ -26,18 +26,7 @@ words.threshold = 4
local numbers = languages.numbers
local registered = languages.registered
-local nuts = nodes.nuts
-local tonut = nuts.tonut
-
-local getfield = nuts.getfield
-local getnext = nuts.getnext
-local getid = nuts.getid
-local getsubtype = nuts.getsubtype
-local getchar = nuts.getchar
-local setattr = nuts.setattr
-
-local traverse_nodes = nuts.traverse
-
+local traverse_nodes = node.traverse
local wordsdata = words.data
local chardata = characters.data
local tasks = nodes.tasks
@@ -107,7 +96,7 @@ end
-- there is an n=1 problem somewhere in nested boxes
local function mark_words(head,whenfound) -- can be optimized and shared
- local current, language, done = tonut(head), nil, nil, 0, false
+ local current, language, done = head, nil, nil, 0, false
local str, s, nds, n = { }, 0, { }, 0 -- n could also be a table, saves calls
local function action()
if s > 0 then
@@ -123,9 +112,9 @@ local function mark_words(head,whenfound) -- can be optimized and shared
n, s = 0, 0
end
while current do
- local id = getid(current)
+ local id = current.id
if id == glyph_code then
- local a = getfield(current,"lang")
+ local a = current.lang
if a then
if a ~= language then
if s > 0 then
@@ -137,16 +126,16 @@ local function mark_words(head,whenfound) -- can be optimized and shared
action()
language = a
end
- local components = getfield(current,"components")
+ local components = current.components
if components then
n = n + 1
nds[n] = current
for g in traverse_nodes(components) do
s = s + 1
- str[s] = utfchar(getchar(g))
+ str[s] = utfchar(g.char)
end
else
- local code = getchar(current)
+ local code = current.char
local data = chardata[code]
if is_letter[data.category] then
n = n + 1
@@ -162,12 +151,12 @@ local function mark_words(head,whenfound) -- can be optimized and shared
n = n + 1
nds[n] = current
end
- elseif id == kern_code and getsubtype(current) == kerning_code and s > 0 then
+ elseif id == kern_code and current.subtype == kerning_code and s > 0 then
-- ok
elseif s > 0 then
action()
end
- current = getnext(current)
+ current = current.next
end
if s > 0 then
action()
@@ -187,8 +176,6 @@ local enabled = false
function words.check(head)
if enabled then
return methods[wordmethod](head)
- elseif not head then
- return head, false
else
return head, false
end
@@ -220,7 +207,7 @@ table.setmetatableindex(cache, function(t,k) -- k == language, numbers[k] == tag
else
c = colist["word:" .. (numbers[k] or "unset")] or colist["word:unknown"]
end
- local v = c and function(n) setattr(n,a_color,c) end or false
+ local v = c and function(n) n[a_color] = c end or false
t[k] = v
return v
end)
@@ -239,7 +226,7 @@ end
methods[1] = function(head)
for n in traverse_nodes(head) do
- setattr(n,a_color,unsetvalue) -- hm, not that selective (reset color)
+ n[a_color] = unsetvalue -- hm, not that selective (reset color)
end
return mark_words(head,sweep)
end
@@ -340,7 +327,7 @@ end
methods[3] = function(head)
for n in traverse_nodes(head) do
- setattr(n,a_color,unsetvalue)
+ n[a_color] = unsetvalue
end
return mark_words(head,sweep)
end