diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
commit | d7ccb42582f85acf30568913610ccf4d602023fb (patch) | |
tree | 7292e3545a420676878e7451b68892d360c62cb6 /Master/texmf-dist/tex/context/base/blob-ini.lua | |
parent | 2d62a6fe9b80def59c392268022f1f9a2d6e358f (diff) |
commit context 2011.05.18
git-svn-id: svn://tug.org/texlive/trunk@22719 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/blob-ini.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/blob-ini.lua | 112 |
1 files changed, 53 insertions, 59 deletions
diff --git a/Master/texmf-dist/tex/context/base/blob-ini.lua b/Master/texmf-dist/tex/context/base/blob-ini.lua index 0f7ccee26c5..48cf4e39314 100644 --- a/Master/texmf-dist/tex/context/base/blob-ini.lua +++ b/Master/texmf-dist/tex/context/base/blob-ini.lua @@ -6,8 +6,11 @@ if not modules then modules = { } end modules ['blob-ini'] = { license = "see context related readme files" } --- later we will consider an OO variant. - +-- Experimental ... names and functionality will change ... just a +-- place to collect code, so: +-- +-- DON'T USE THESE FUNCTIONS AS THEY WILL CHANGE! +-- -- This module is just a playground. Occasionally we need to typeset -- at the lua and and this is one method. In principle we can construct -- pages this way too which sometimes makes sense in dumb cases. Actually, @@ -20,17 +23,22 @@ if not modules then modules = { } end modules ['blob-ini'] = { -- collapse or new pars -- interline spacing etc --- DON'T USE THESE FUNCTIONS AS THEY WILL CHANGE! +-- blob.char +-- blob.line +-- blob.paragraph +-- blob.page local type = type - -local utfvalues = string.utfvalues local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns -local fontdata = fonts.identifiers +local report_blobs = logs.reporter("blobs") + +local fontdata = fonts.hashes.identifiers + +local nodepool = nodes.pool -local new_glyph_node = nodes.glyph -local new_glue_node = nodes.glyph +local new_glyph = nodepool.glyph +local new_glue = nodepool.glue local copy_node = node.copy local copy_node_list = node.copy_list @@ -57,70 +65,34 @@ local ctxtextcapture = lpeg.Ct ( ( ) )^0) -local function tonodes(str,fnt,attr) -- (str,template_glyph) - if not str or str == "" then - return - end - local head, tail, space, fnt, template = nil, nil, nil, nil, nil - if not fnt then - fnt = current_font() - elseif type(fnt) ~= "number" and fnt.id == "glyph" then - fnt, template = nil, fnt - -- else - -- already a number - end - for s in utfvalues(str) do - local n - if s == 32 then - if not space then - local parameters = fontdata[fnt].parameters - space = new_glue_node(parameters.space,parameters.space_stretch,parameters.space_shrink) - n = space - else - n = copy_node(space) - end - elseif template then - n = copy_node(template) - n.char = s - else - n = new_glyph_node(fnt,s) - end - if attr then -- normall false when template - n.attr = copy_node_list(attr) - end - if head then - insert_node_after(head,tail,n) - else - head = n - end - tail = n - end - return head, tail -end - -blobs.tonodes = tonodes - function blobs.new() return { list = { }, } end -function blobs.append(t,str) - local kind = type(str) +function blobs.append(t,str) -- will be link nodes.link + local typ = type(str) local dummy = nil - if kind == "string" then + if typ == "number" then + str = tostring(str) + typ = "string" + end + local list = t.list + if typ == "string" then local pars = lpegmatch(ctxtextcapture,str) - local list = t.list + local noflist = #list for p=1,#pars do local str = pars[p] if #str == 0 then - list[#list+1 ] = { head = nil, tail = nil } + noflist = noflist + 1 + list[noflist] = { head = nil, tail = nil } else - local l = list[#list] + local l = list[noflist] if not l then l = { head = nil, tail = nil } - list[#list+1 ] = l + noflist = noflist + 1 + list[noflist] = l end local head, tail = tonodes(str,nil,nil) if head then @@ -147,7 +119,7 @@ function blobs.pack(t,how) if how == "vertical" then -- we need to prepend a local par node -- list[i].pack = node.vpack(list[i].head,"exactly") - logs.report("blobs","vpack not yet supported") + report_blobs("vpack not yet supported") else list[i].pack = hpack_node_list(list[i].head,"exactly") end @@ -163,3 +135,25 @@ function blobs.write(t) end end end + + +-- blob.char +-- blob.line: head, tail +-- blob.paragraph +-- blob.page + +--~ local lineblob = { +--~ type = "line", +--~ head = false, +--~ tail = false, +--~ pack = false, +--~ properties = { }, +--~ end + +--~ local parblob = { +--~ type = "line", +--~ head = false, +--~ tail = false, +--~ pack = false, +--~ properties = { }, +--~ end |