X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fltj-direction.lua;h=75517f03df2be3014044042eed9c7a903d6b2e6a;hb=db94e608b0fe848b08a050d4226f7fae8be1f87d;hp=08804aafe41b4041d52dca22d3199b89e429e1b5;hpb=bc314a49743c0238712afe698c3a25403e1d180d;p=luatex-ja%2Fluatexja.git diff --git a/src/ltj-direction.lua b/src/ltj-direction.lua index 08804aa..75517f0 100644 --- a/src/ltj-direction.lua +++ b/src/ltj-direction.lua @@ -59,7 +59,6 @@ local dir_node_manual = luatexja.dir_table.dir_node_manual local get_dir_count -- \tate, \yoko do - local abs = math.abs function get_dir_count() return tex_getcount('ltj@dir@count') end @@ -75,10 +74,11 @@ do node_set_attr(w, attr_dir, v) end else - local w = node_next(to_direct(lv.head)) - if to_node(w) then + local w = node_next(lv.head) + if w then + w = to_direct(w) if getid(w)==id_whatsit and getsubtype(w)==sid_user - and getfield(w, 'user_id')==DIR then + and getfield(w, 'user_id')==DIR then set_attr(w, attr_dir, v) else ltjb.package_error( @@ -102,6 +102,11 @@ do luatexja.direction.set_list_direction = set_list_direction end +function luatexja.direction.freeze_list_dir() + local w = to_direct(tex.nest[tex.nest.ptr].tail) + set_attr(w, attr_dir, -has_attr(w, attr_dir)) +end + -- ボックスに dir whatsit を追加 local function create_dir_whatsit(hd, gc, new_dir) local w = node_new(id_whatsit, sid_user) @@ -147,7 +152,7 @@ do end end if hd==wh[1] then - ltjs.list_dir = has_attr(hd,attr_dir) + ltjs.list_dir =has_attr(hd,attr_dir) local x = node_next(hd) if getid(x)==id_glue and getsubtype(x)==sid_parskip then node_remove(hd,x); node_free(x) @@ -175,8 +180,6 @@ do local function create_dir_whatsit_parbox(h, gc) stop_time_measure('tex_linebreak') - print('BEGIN POST_LINEBREAK', gc) - luatexja.ext_show_node_list(h, ' ', print) -- start 側は ltj-debug.lua に local new_dir, hd = ltjs.list_dir, to_direct(h) for line in traverse_id(id_hlist, hd) do @@ -336,7 +339,8 @@ end -- 2nd ret val はその DIR whatsit local function get_box_dir(b, default) local dir = has_attr(b, attr_dir) or 0 - local bh = getlist(b) + local bh = getfield(b,'head') + -- b は insert node となりうるので getlist() は使えない local c for i=1,2 do if bh and getid(bh)==id_whatsit @@ -353,6 +357,20 @@ local function get_box_dir(b, default) return (dir==0 and default or dir), c end +function luatexja.direction.check_dir(reg_num) + local list_dir = get_dir_count() + local b = tex.getbox(reg_num) + if b then + local box_dir = get_box_dir(to_direct(b), dir_yoko) + if box_dir%dir_node_auto ~= list_dir%dir_node_auto then + ltjb.package_error( + 'luatexja', + "Incompatible direction list can't be unboxed", + 'I refuse to unbox a box in differrent direction.') + end + end +end + -- dir_node に包まれている「本来の中身」を取り出し, -- dir_node を全部消去 local function unwrap_dir_node(b, head, box_dir) @@ -734,3 +752,21 @@ do end luatexja.direction.glyph_from_packed = glyph_from_packed end + +-- adjust and insertion +local id_adjust = node.id('adjust') +function luatexja.direction.check_adjust_direction() + local list_dir = tex_getcount('ltj@adjdir@count') + local a = tex.nest[tex.nest.ptr].tail + local ad = to_direct(a) + if a and getid(ad)==id_adjust then + local adj_dir = get_box_dir(ad) + if list_dir~=adj_dir then + ltjb.package_error( + 'luatexja', + 'Direction Incompatible', + "\\vadjust's argument and outer vlist must have same direction.") + Dnode.last_node() + end + end +end