summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/blob-ini.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/blob-ini.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/blob-ini.lua112
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