From 19b8c17ca1c0af54d194ebc1d1c39f5cfbe1d06a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 17 Jul 2015 22:42:21 +0000 Subject: luasseq (16jul15) git-svn-id: svn://tug.org/texlive/trunk@37877 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/lualatex/luasseq/README | 6 ++ Master/texmf-dist/doc/lualatex/luasseq/luasseq.pdf | Bin 138478 -> 224059 bytes Master/texmf-dist/scripts/luasseq/luasseq.lua | 100 +++++++++++++++++---- .../texmf-dist/source/lualatex/luasseq/luasseq.dtx | 2 +- Master/texmf-dist/tex/lualatex/luasseq/luasseq.sty | 2 +- 5 files changed, 90 insertions(+), 20 deletions(-) create mode 100644 Master/texmf-dist/doc/lualatex/luasseq/README (limited to 'Master') diff --git a/Master/texmf-dist/doc/lualatex/luasseq/README b/Master/texmf-dist/doc/lualatex/luasseq/README new file mode 100644 index 00000000000..b6cb5d92040 --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/luasseq/README @@ -0,0 +1,6 @@ +Version 2015-07-16 contains compatibility fixed for lualatex bundled with TeXLive 2014. + +Required for use: luasseq.lua and luasseq.sty + +To get luasseq.sty: lualatex luasseq.ins (requires luasseq.dtx) +To get the documentation luasseq.pdf: lualatex luasseq.dtx diff --git a/Master/texmf-dist/doc/lualatex/luasseq/luasseq.pdf b/Master/texmf-dist/doc/lualatex/luasseq/luasseq.pdf index 9b6894eaa9b..6e487fcde6a 100644 Binary files a/Master/texmf-dist/doc/lualatex/luasseq/luasseq.pdf and b/Master/texmf-dist/doc/lualatex/luasseq/luasseq.pdf differ diff --git a/Master/texmf-dist/scripts/luasseq/luasseq.lua b/Master/texmf-dist/scripts/luasseq/luasseq.lua index 80704fb5d5e..79082efce72 100755 --- a/Master/texmf-dist/scripts/luasseq/luasseq.lua +++ b/Master/texmf-dist/scripts/luasseq/luasseq.lua @@ -76,7 +76,7 @@ end function parselabelrange(s,defstart) local res = {} local mini,maxi,found - for rng in string.gfind(s.."," , "([^,]+)") do + for rng in string.gmatch(s.."," , "([^,]+)") do found,_,mini,maxi = string.find(rng,"([+-]?[0-9]+)%.%.%.([+-]?[0-9]+)") if not found then mini = defstart @@ -153,7 +153,7 @@ end function sseq_grid_chess(x,y,width,height) tex.print("\\pgfsetcolor{sslightgr}") - if math.mod(x+y, 2) == 1 then -- invert everything by first drawing a solid gray rectangle + if ((x+y) % 2) == 1 then -- invert everything by first drawing a solid gray rectangle -- and then draw the grid in white. This way, even bidegree -- is always white. tex.print("\\pgfpathrectangle{\\pgfpoint{0sp}{0sp}}{\\pgfpoint{" @@ -201,10 +201,10 @@ function sseq_parse_label_list(s) local chunk = 0 local index - for rng in string.gfind(s.."," , "([^,]*),") do + for rng in string.gmatch(s.."," , "([^,]*),") do res[chunk] = {} index = 0 - for label in string.gfind(rng..";", "([^;]*);") do + for label in string.gmatch(rng..";", "([^;]*);") do res[chunk][index] = label index = index+1 end @@ -238,7 +238,7 @@ end function sseq_draw_horizontal_labels(range) local k - if sseqxtep == 0 then return end -- old-fashioned way of disabling labels + if sseqxstep == 0 then return end -- old-fashioned way of disabling labels for c,rng in ipairs(range) do k=0 for i=rng.min,rng.max,sseqxstep do @@ -322,6 +322,7 @@ function sseq_drop_object(x,y,shape,pathusage,content,col) obj.color = col obj.nodetype = shape + sseq_conclude_connection() -- now do the optimizations such as \bullet -> drawn black circle etc if (pathusage == "fill") or (obj.code == "\\bullet ") then @@ -335,9 +336,14 @@ function sseq_drop_object(x,y,shape,pathusage,content,col) obj.wd,obj.ht = 262144,262144 obj.radius = 370727 end + elseif (obj.code == "\\circ ") then + obj.nodetype = "circle" + obj.cmd = "\\pgfsetstrokecolor{%s}\\pgfsetfillcolor{white}\\pgfsetdash{}{0pt}\\pgfpathqcircle{2pt}\\pgfusepathqfillstroke" + obj.radius = 131072 -- 2pt in sp + obj.wd,obj.ht = 262144,262144 -- 4pt in sp elseif(obj.code == "\\square ") then obj.nodetype="rectangle" - obj.cmd = "\\pgfsetstrokecolor{%s}\\pgfsys@rect{-2pt}{-2pt}{4pt}{4pt}\\pgfsys@stroke" + obj.cmd = "\\pgfsetstrokecolor{%s}\\pgfsetdash{}{0pt}\\pgfsys@rect{-2pt}{-2pt}{4pt}{4pt}\\pgfsys@stroke" obj.wd,obj.ht = 262144,262144 obj.radius = 370727 else @@ -374,9 +380,9 @@ end function sseq_register_size() local currobj = sseqobject[sseqcurrentindex[1]][sseqcurrentindex[2]][sseqcurrentindex[3]] - currobj.wd = tex.wd[sseqboxno] - currobj.ht = (tex.ht[sseqboxno]+tex.dp[sseqboxno]) - currobj.dp = tex.dp[sseqboxno] + currobj.wd = tex.box[sseqboxno].width + currobj.ht = (tex.box[sseqboxno].height+tex.box[sseqboxno].depth) + currobj.dp = tex.box[sseqboxno].depth currobj.radius = 0.5*math.sqrt(currobj.wd*currobj.wd+currobj.ht*currobj.ht) end @@ -415,10 +421,28 @@ function sseq_move(x,y) sseq_moveto(sseqposx+x,sseqposy+y) end +-- New prefix model: sseqprefix is a stack of lists +-- sseq_begin_prefix_context pushes an empty prefix onto that stack +-- sseq_end_prefix_context pops the last prefix off the stack +-- A prefix is an (unordered) list of names + +function uses_old_prefix_model(pref) + if #pref == 0 then return true end + if type(pref[1]) == "table" then return false end + return true +end + function stringtolist(pref,name) local res = {} - for i,p in ipairs(pref) do table.insert(res,p) end - for w in string.gfind(name,"%w+") do + -- check if we're using the old or the new model + if uses_old_prefix_model(pref) then + for i,p in ipairs(pref) do table.insert(res,p) end + else -- new prefix model + for i,l in ipairs(pref) do + for j,p in ipairs(l) do table.insert(res,p) end + end + end + for w in string.gmatch(name,"%w+") do table.insert(res,w) end table.sort(res) @@ -448,7 +472,7 @@ function sseq_global_goto(name) sseq_conclude_connection() sseq_finish_pos() if not sseqname[namestring] then - error("sseq: goto name does not exist: "..namestring) + error("sseq: goto name does not exist: '"..namestring.."'") else sseqcurrentindex = { sseqname[namestring][1],sseqname[namestring][2],sseqname[namestring][3] } sseqposx,sseqposy = sseqname[namestring][1], sseqname[namestring][2] @@ -460,11 +484,38 @@ function sseq_abs_goto(name) end function sseq_prefix(pref) - sseqprefix = stringtolist(sseqprefix,pref) + if uses_old_prefix_model(sseqprefix) then + sseqprefix = stringtolist(sseqprefix,pref) + else + sseqprefix[#sseqprefix] = stringtolist(sseqprefix[#sseqprefix],pref) + end +end + +function sseq_begin_prefix_context() + if (#sseqprefix > 0) and uses_old_prefix_model(sseqprefix) then + error("sseq: you cannot use stacked prefixes when there's a non-stacked active prefix") + else + table.insert(sseqprefix,{}) + end +end + + +function sseq_end_prefix_context() + if uses_old_prefix_model(sseqprefix) then + error("sseq: no prefix context to end") + else + table.remove(sseqprefix,#sseqprefix) + end end +-- sseq_reset_prefix is deprecated. It'll throw an error if we ever used +-- sseq_begin_prefix_context (because that would be incompatible) function sseq_reset_prefix() - sseqprefix = {} + if uses_old_prefix_model(sseqprefix) then + sseqprefix = {} + else + error("sseq: you cannot use \\ssresetprefix if you use stacked prefixes.") + end end function sseq_goto(name) @@ -684,6 +735,9 @@ function sseq_dump_connection(conn) -- if source or target is clipped, will make it a void line -- + + -- TODO: locations outside displayed range are incorrect + fromx,fromy = sseq_getcoords(conn.from[1],conn.from[2]) tox,toy = sseq_getcoords(conn.to[1],conn.to[2]) @@ -694,13 +748,13 @@ function sseq_dump_connection(conn) end if ((not fromx) or (not fromy)) then -- source clipped: we can be sure the target is regular - fromx,fromy = sseq_fix_clipped_connection(conn.from[1],conn.from[2],conn.to[1],conn.to[2],tox,toy) toobj = sseqobject[conn.to[1]][conn.to[2]][conn.to[3]] tox,toy = toobj.posx, toobj.posy + fromx,fromy = sseq_fix_clipped_connection(conn.from[1],conn.from[2],conn.to[1],conn.to[2],tox,toy) elseif ((not tox) or (not toy)) then -- target clipped: we can be sure the source is regular - tox,toy = sseq_fix_clipped_connection(conn.to[1],conn.to[2],conn.from[1],conn.from[2],fromx,fromy) fromobj = sseqobject[conn.from[1]][conn.from[2]][conn.from[3]] fromx,fromy = fromobj.posx, fromobj.posy + tox,toy = sseq_fix_clipped_connection(conn.to[1],conn.to[2],conn.from[1],conn.from[2],fromx,fromy) elseif conn.from[3] == 0 then -- source not clipped but void toobj = sseqobject[conn.to[1]][conn.to[2]][conn.to[3]] fromx = fromx+(toobj.posx-tox) @@ -742,8 +796,16 @@ function sseq_dump_connection(conn) else tex.print(string.format("\\pgfpathlineto{\\pgfpoint{%dsp}{%dsp}}",tox,toy)) end - if conn.arrowfrom then tex.print("\\pgfsetarrowsstart{"..conn.arrowfrom.."}")end - if conn.arrowto then tex.print("\\pgfsetarrowsend{"..conn.arrowto.."}") end + if conn.arrowfrom then + tex.print("\\pgfsetarrowsstart{"..conn.arrowfrom.."}") + else + tex.print("\\pgfsetarrowsstart{}") + end + if conn.arrowto then + tex.print("\\pgfsetarrowsend{"..conn.arrowto.."}") + else + tex.print("\\pgfsetarrowsend{}") + end tex.print("\\pgfusepath{stroke}") end end @@ -788,6 +850,8 @@ local labelpositionincirc = { U = {0,1,"bottom"}, function sseq_dump_label(label) local labelledobj = sseqobject[label.x][label.y][label.n] local posx,posy + + if (not labelledobj.posx) or (not labelledobj.posy) then return end tex.print("\\color{"..label.color.."}") if labelledobj.nodetype == "circle" then posx = labelledobj.posx+labelpositionincirc[label.pos][1]*labelledobj.radius diff --git a/Master/texmf-dist/source/lualatex/luasseq/luasseq.dtx b/Master/texmf-dist/source/lualatex/luasseq/luasseq.dtx index 9afbd95a161..349ee9f9dfa 100644 --- a/Master/texmf-dist/source/lualatex/luasseq/luasseq.dtx +++ b/Master/texmf-dist/source/lualatex/luasseq/luasseq.dtx @@ -204,7 +204,7 @@ % % -\directlua0{dofile(kpse.find_file("luasseq.lua"))} +\directlua0{dofile(kpse.find_file("luasseq.lua","lua"))} \definecolor{sseqgr}{gray}{0.65} diff --git a/Master/texmf-dist/tex/lualatex/luasseq/luasseq.sty b/Master/texmf-dist/tex/lualatex/luasseq/luasseq.sty index 17e4ca8179b..a7f3c625596 100644 --- a/Master/texmf-dist/tex/lualatex/luasseq/luasseq.sty +++ b/Master/texmf-dist/tex/lualatex/luasseq/luasseq.sty @@ -44,7 +44,7 @@ \ProcessOptions -\directlua0{dofile(kpse.find_file("luasseq.lua"))} +\directlua0{dofile(kpse.find_file("luasseq.lua","lua"))} \definecolor{sseqgr}{gray}{0.65} \definecolor{sslightgr}{gray}{0.9} -- cgit v1.2.3