summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/typo-dub.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/typo-dub.lua')
-rw-r--r--tex/context/base/mkiv/typo-dub.lua76
1 files changed, 44 insertions, 32 deletions
diff --git a/tex/context/base/mkiv/typo-dub.lua b/tex/context/base/mkiv/typo-dub.lua
index 206cfd9ae..e08d96e88 100644
--- a/tex/context/base/mkiv/typo-dub.lua
+++ b/tex/context/base/mkiv/typo-dub.lua
@@ -63,11 +63,11 @@ local getlist = nuts.getlist
local getchar = nuts.getchar
local getattr = nuts.getattr
local getprop = nuts.getprop
-local getdir = nuts.getdir
+local getdir ection = nuts.getdirection
local setprop = nuts.setprop
local setchar = nuts.setchar
-local setdir = nuts.setdir
+local setdirection = nuts.setdirection
local setattrlist = nuts.setattrlist
local remove_node = nuts.remove
@@ -75,10 +75,10 @@ local insert_node_after = nuts.insert_after
local insert_node_before = nuts.insert_before
local nodepool = nuts.pool
-local new_textdir = nodepool.textdir
+local new_direction = nodepool.direction
local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
+local gluecodes = nodes.gluecodes
local glyph_code = nodecodes.glyph
local glue_code = nodecodes.glue
@@ -87,7 +87,12 @@ local vlist_code = nodecodes.vlist
local math_code = nodecodes.math
local dir_code = nodecodes.dir
local localpar_code = nodecodes.localpar
-local parfillskip_code = skipcodes.parfillskip
+
+local parfillskip_code = gluecodes.parfillskip
+
+local dirvalues = nodes.dirvalues
+local lefttoright_code = dirvalues.lefttoright
+local righttoleft_code = dirvalues.righttoleft
local maximum_stack = 0xFF -- unicode: 60, will be jumped to 125, we don't care too much
@@ -280,13 +285,19 @@ local function build_list(head) -- todo: store node pointer ... saves loop
list[size] = { char = 0x0020, direction = "ws", original = "ws", level = 0 }
current = getnext(current)
elseif id == dir_code then
- local dir = getdir(current)
- if dir == "+TLT" then
- list[size] = { char = 0x202A, direction = "lre", original = "lre", level = 0 }
- elseif dir == "+TRT" then
- list[size] = { char = 0x202B, direction = "rle", original = "rle", level = 0 }
- elseif dir == "-TLT" or dir == "-TRT" then
- list[size] = { char = 0x202C, direction = "pdf", original = "pdf", level = 0 }
+ local direction, pop = getdirection(current)
+ if direction == lefttoright_code then
+ if pop then
+ list[size] = { char = 0x202C, direction = "pdf", original = "pdf", level = 0 }
+ else
+ list[size] = { char = 0x202A, direction = "lre", original = "lre", level = 0 }
+ end
+ elseif direction == righttoleft_code then
+ if pop then
+ list[size] = { char = 0x202C, direction = "pdf", original = "pdf", level = 0 }
+ else
+ list[size] = { char = 0x202B, direction = "rle", original = "rle", level = 0 }
+ end
else
list[size] = { char = 0xFFFC, direction = "on", original = "on", level = 0, id = id } -- object replacement character
end
@@ -395,10 +406,11 @@ end
local function get_baselevel(head,list,size) -- todo: skip if first is object (or pass head and test for localpar)
local id = getid(head)
if id == localpar_code then
- if getdir(head) == "TRT" then
- return 1, "TRT", true
+ local direction = getdirection(head)
+ if direction == righttoleft_code or direction == "TRT" then -- for old times sake we we handle strings too
+ return 1, righttoleft_code, true
else
- return 0, "TLT", true
+ return 0, lefttoright_code, true
end
else
-- P2, P3
@@ -406,12 +418,12 @@ local function get_baselevel(head,list,size) -- todo: skip if first is object (o
local entry = list[i]
local direction = entry.direction
if direction == "r" or direction == "al" then -- and an ?
- return 1, "TRT", true
+ return 1, righttoleft_code, true
elseif direction == "l" then
- return 0, "TLT", true
+ return 0, lefttoright_code, true
end
end
- return 0, "TLT", false
+ return 0, lefttoright_code, false
end
end
@@ -828,11 +840,11 @@ end
-- local begindir = nil
-- local enddir = nil
-- if level % 2 == 1 then
--- begindir = "+TRT"
--- enddir = "-TRT"
+-- begindir = righttoleft_code
+-- enddir = righttoleft_code
-- else
--- begindir = "+TLT"
--- enddir = "-TLT"
+-- begindir = lefttoright_code
+-- enddir = lefttoright_code
-- end
-- for i=1,size do
-- local entry = list[i]
@@ -875,12 +887,12 @@ local function insert_dir_points(list,size)
local enddir -- = nil
local prev -- = nil
if toggle then
- begindir = "+TLT"
- enddir = "-TLT"
+ begindir = righttoleft_code
+ enddir = righttoleft_code
toggle = false
else
- begindir = "+TRT"
- enddir = "-TRT"
+ begindir = righttoleft_code
+ enddir = righttoleft_code
toggle = true
end
for i=1,size do
@@ -920,7 +932,7 @@ local function insert_dir_points(list,size)
if trace_list and n > 1 then
report_directions("unbalanced list")
end
- last.enddir = s[n] == "+TRT" and "-TRT" or "-TLT"
+ last.enddir = s[n] == righttoleft_code or lefttoright_code
end
end
end
@@ -961,11 +973,11 @@ local function apply_to_list(list,size,head,pardir)
setcolor(current,direction,false,mirror)
end
elseif id == hlist_code or id == vlist_code then
- setdir(current,pardir) -- is this really needed?
+ setdirection(current,pardir) -- is this really needed?
elseif id == glue_code then
if enddir and getsubtype(current) == parfillskip_code then
-- insert the last enddir before \parfillskip glue
- local d = new_textdir(enddir)
+ local d = new_direction(enddir,true)
setprop(d,"directions",true)
-- setattrlist(d,current)
head = insert_node_before(head,current,d)
@@ -974,7 +986,7 @@ local function apply_to_list(list,size,head,pardir)
elseif begindir then
if id == localpar_code then
-- localpar should always be the 1st node
- local d = new_textdir(begindir)
+ local d = new_direction(begindir)
setprop(d,"directions",true)
-- setattrlist(d,current)
head, current = insert_node_after(head,current,d)
@@ -982,7 +994,7 @@ local function apply_to_list(list,size,head,pardir)
end
end
if begindir then
- local d = new_textdir(begindir)
+ local d = new_direction(begindir)
setprop(d,"directions",true)
-- setattrlist(d,current)
head = insert_node_before(head,current,d)
@@ -995,7 +1007,7 @@ local function apply_to_list(list,size,head,pardir)
end
end
if enddir then
- local d = new_textdir(enddir)
+ local d = new_direction(enddir,true)
setprop(d,"directions",true)
-- setattrlist(d,current)
head, current = insert_node_after(head,current,d)