summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/typo-brk.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-02-17 10:31:56 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-02-17 10:31:56 +0100
commitb14f992ef5f4e868c9959b174278c86516d60dbc (patch)
tree28587bb46c025ea7b0d27ba93f09c93dcf53c73a /tex/context/base/mkiv/typo-brk.lua
parent95a1799032dc61dbca4a11e495be34b4397c8fec (diff)
downloadcontext-b14f992ef5f4e868c9959b174278c86516d60dbc.tar.gz
2017-02-17 10:23:00
Diffstat (limited to 'tex/context/base/mkiv/typo-brk.lua')
-rw-r--r--tex/context/base/mkiv/typo-brk.lua105
1 files changed, 49 insertions, 56 deletions
diff --git a/tex/context/base/mkiv/typo-brk.lua b/tex/context/base/mkiv/typo-brk.lua
index 749c25a33..84eff0654 100644
--- a/tex/context/base/mkiv/typo-brk.lua
+++ b/tex/context/base/mkiv/typo-brk.lua
@@ -32,11 +32,15 @@ local getsubtype = nuts.getsubtype
local getfont = nuts.getfont
local getid = nuts.getid
local getfield = nuts.getfield
-local getattr = nuts.getattr
+----- getattr = nuts.getattr
+local getattrlist = nuts.getattrlist
+local takeattr = nuts.takeattr
+local getlang = nuts.getlang
local isglyph = nuts.isglyph
local setfield = nuts.setfield
local setattr = nuts.setattr
+local setattrlist = nuts.setattrlist
local setlink = nuts.setlink
local setchar = nuts.setchar
local setdisc = nuts.setdisc
@@ -59,7 +63,7 @@ local texsetattribute = tex.setattribute
local unsetvalue = attributes.unsetvalue
local nodepool = nuts.pool
-local tasks = nodes.tasks
+local enableaction = nodes.tasks.enableaction
local v_reset = interfaces.variables.reset
local v_yes = interfaces.variables.yes
@@ -109,19 +113,21 @@ end
-- todo: use boundaries
-local function withattribute(n,a)
- setfield(n,"attr",a)
- return n
-end
-
local function insert_break(head,start,stop,before,after,kern)
- local a = getfield(start,"attr")
if not kern then
- insert_node_before(head,start,withattribute(new_penalty(before),a))
- insert_node_before(head,start,withattribute(new_glue(0),a))
+ local p = new_penalty(before)
+ local g = new_glue()
+ setattrlist(p,start)
+ setattrlist(g,start)
+ insert_node_before(head,start,p)
+ insert_node_before(head,start,g)
end
- insert_node_after(head,stop,withattribute(new_glue(0),a))
- insert_node_after(head,stop,withattribute(new_penalty(after),a))
+ 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)
end
methods[1] = function(head,start,stop,settings,kern)
@@ -142,14 +148,8 @@ methods[6] = function(head,start,stop,settings,kern)
local l = new_wordboundary()
local d = new_disc()
local r = new_wordboundary()
- local a = getfield(start,"attr")
- -- setfield(l,"attr",a)
- setfield(d,"attr",a) -- otherwise basemode is forces and we crash
- -- setfield(r,"attr",a)
- setlink(p,l)
- setlink(l,d)
- setlink(d,r)
- setlink(r,n)
+ setattrlist(d,start) -- otherwise basemode is forced and we crash
+ setlink(p,l,d,r,n)
if start == stop then
setboth(start)
setdisc(d,start,nil,copy_node(start))
@@ -167,16 +167,14 @@ end
methods[2] = function(head,start) -- ( => (-
local p, n = getboth(start)
if p and n then
- local tmp
- head, start, tmp = remove_node(head,start)
- head, start = insert_node_before(head,start,new_disc())
- setfield(start,"attr",getfield(tmp,"attr"))
- setfield(start,"replace",tmp)
- local tmp = copy_node(tmp)
- local hyphen = copy_node(tmp)
- setchar(hyphen,languages.prehyphenchar(getfield(tmp,"lang")))
- setlink(tmp,hyphen)
- setfield(start,"post",tmp)
+ local replace
+ head, start, replace = remove_node(head,start)
+ local post = copy_node(replace)
+ local hyphen = copy_node(post)
+ setchar(hyphen,languages.prehyphenchar(getlang(post)))
+ setlink(post,hyphen)
+ head, start = insert_node_before(head,start,new_disc(nil,post,replace))
+ setattrlist(start,replace)
insert_break(head,start,start,10000,10000)
end
return head, start
@@ -185,16 +183,14 @@ end
methods[3] = function(head,start) -- ) => -)
local p, n = getboth(start)
if p and n then
- local tmp
- head, start, tmp = remove_node(head,start)
- head, start = insert_node_before(head,start,new_disc())
- setfield(start,"attr",getfield(tmp,"attr"))
- setfield(start,"replace",tmp)
- local tmp = copy_node(tmp)
- local hyphen = copy_node(tmp)
- setchar(hyphen,languages.prehyphenchar(getfield(tmp,"lang")))
- setlink(hyphen,tmp)
- setfield(start,"pre",hyphen)
+ local replace
+ head, start, replace = remove_node(head,start)
+ local pre = copy_node(replace)
+ local hyphen = copy_node(pre)
+ setchar(hyphen,languages.prehyphenchar(getlang(pre)))
+ setlink(hyphen,pre)
+ head, start = insert_node_before(head,start,new_disc(hyphen,nil,replace)) -- so not pre !
+ setattrlist(start,tmp)
insert_break(head,start,start,10000,10000)
end
return head, start
@@ -206,7 +202,7 @@ methods[4] = function(head,start) -- - => - - -
local tmp
head, start, tmp = remove_node(head,start)
head, start = insert_node_before(head,start,new_disc())
- setfield(start,"attr",getfield(tmp,"attr"))
+ setattrlist(start,tmp)
setdisc(start,copy_node(tmp),copy_node(tmp),tmp)
insert_break(head,start,start,10000,10000)
end
@@ -218,11 +214,11 @@ 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())
- local attr = getfield(tmp,"attr")
- local font = getfont(tmp)
- local left = settings.left
- local right = settings.right
+ head, start = insert_node_before(head,start,new_disc())
+ local attr = getattrlist(tmp)
+ local font = getfont(tmp)
+ local left = settings.left
+ local right = settings.right
local middle = settings.middle
if left then
left = tonodes(tostring(left),font,attr)
@@ -234,7 +230,7 @@ methods[5] = function(head,start,stop,settings) -- x => p q r
middle = tonodes(tostring(middle),font,attr)
end
setdisc(start,left,right,middle)
- setfield(start,"attr",attr) -- todo: critical only -- just a copy will do
+ setattrlist(start,attr)
flush_node(tmp)
insert_break(head,start,start,10000,10000)
end
@@ -254,7 +250,8 @@ function breakpoints.handler(head)
while current do
local char, id = isglyph(current)
if char then
- local a = getattr(current,a_breakpoints)
+ -- local a = getattr(current,a_breakpoints)
+ local a = takeattr(current,a_breakpoints)
if a and a > 0 then
if a ~= attr then
local data = mapping[a]
@@ -268,10 +265,10 @@ function breakpoints.handler(head)
if map then
local cmap = map[char]
if cmap then
- setattr(current,a_breakpoints,unsetvalue) -- should not be needed
+ -- setattr(current,a_breakpoints,unsetvalue) -- should not be needed
-- for now we collect but when found ok we can move the handler here
-- although it saves nothing in terms of performance
- local lang = getfield(current,"lang")
+ local lang = getlang(current)
local smap = lang and lang >= 0 and lang < 0x7FFF and (cmap[numbers[lang]] or cmap[""])
if smap then
local skip = smap.skip
@@ -328,7 +325,7 @@ function breakpoints.handler(head)
local stop = data[2]
local cmap = data[3]
local smap = data[4]
--- local lang = getfield(start,"lang")
+-- local lang = getlang(start)
-- -- we do a sanity check for language
-- local smap = lang and lang >= 0 and lang < 0x7FFF and (cmap[numbers[lang]] or cmap[""])
-- if smap then
@@ -450,7 +447,7 @@ function breakpoints.set(n)
if trace_breakpoints then
report_breakpoints("enabling breakpoints handler")
end
- tasks.enableaction("processors","typesetters.breakpoints.handler")
+ enableaction("processors","typesetters.breakpoints.handler")
end
n = n.number
end
@@ -458,10 +455,6 @@ function breakpoints.set(n)
texsetattribute(a_breakpoints,n)
end
--- function breakpoints.enable()
--- tasks.enableaction("processors","typesetters.breakpoints.handler")
--- end
-
-- interface
implement {