diff options
author | Marius <mariausol@gmail.com> | 2013-10-20 01:21:09 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2013-10-20 01:21:09 +0300 |
commit | b8ac6d7b7fdb16293c28034c349efd5b0b7b20b3 (patch) | |
tree | 0e9051dbe21b4e9cfc72fe594df5b0fe7bc511f3 /tex/context/base/node-ref.lua | |
parent | 965214d981e6129b782c67adcaf3a81aedcb0bac (diff) | |
download | context-b8ac6d7b7fdb16293c28034c349efd5b0b7b20b3.tar.gz |
beta 2013.10.20 07:09
Diffstat (limited to 'tex/context/base/node-ref.lua')
-rw-r--r-- | tex/context/base/node-ref.lua | 121 |
1 files changed, 61 insertions, 60 deletions
diff --git a/tex/context/base/node-ref.lua b/tex/context/base/node-ref.lua index 09e066434..aa864fb1c 100644 --- a/tex/context/base/node-ref.lua +++ b/tex/context/base/node-ref.lua @@ -16,61 +16,60 @@ if not modules then modules = { } end modules ['node-ref'] = { -- is grouplevel still used? -local format = string.format - -local allocate, mark = utilities.storage.allocate, utilities.storage.mark +local attributes, nodes, node = attributes, nodes, node -local cleanupreferences, cleanupdestinations = false, true +local allocate = utilities.storage.allocate, utilities.storage.mark +local mark = utilities.storage.allocate, utilities.storage.mark -local attributes, nodes, node = attributes, nodes, node -local nodeinjections = backends.nodeinjections -local codeinjections = backends.codeinjections +local nodeinjections = backends.nodeinjections +local codeinjections = backends.codeinjections -local transparencies = attributes.transparencies -local colors = attributes.colors -local references = structures.references -local tasks = nodes.tasks +local cleanupreferences = false +local cleanupdestinations = true -local hpack_list = node.hpack -local list_dimensions = node.dimensions +local transparencies = attributes.transparencies +local colors = attributes.colors +local references = structures.references +local tasks = nodes.tasks --- current.glue_set current.glue_sign +local hpack_list = node.hpack +local list_dimensions = node.dimensions -local trace_backend = false trackers.register("nodes.backend", function(v) trace_backend = v end) -local trace_references = false trackers.register("nodes.references", function(v) trace_references = v end) -local trace_destinations = false trackers.register("nodes.destinations", function(v) trace_destinations = v end) +local trace_backend = false trackers.register("nodes.backend", function(v) trace_backend = v end) +local trace_references = false trackers.register("nodes.references", function(v) trace_references = v end) +local trace_destinations = false trackers.register("nodes.destinations", function(v) trace_destinations = v end) -local report_reference = logs.reporter("backend","references") -local report_destination = logs.reporter("backend","destinations") -local report_area = logs.reporter("backend","areas") +local report_reference = logs.reporter("backend","references") +local report_destination = logs.reporter("backend","destinations") +local report_area = logs.reporter("backend","areas") -local nodecodes = nodes.nodecodes -local skipcodes = nodes.skipcodes -local whatcodes = nodes.whatcodes -local listcodes = nodes.listcodes +local nodecodes = nodes.nodecodes +local skipcodes = nodes.skipcodes +local whatcodes = nodes.whatcodes +local listcodes = nodes.listcodes -local hlist_code = nodecodes.hlist -local vlist_code = nodecodes.vlist -local glue_code = nodecodes.glue -local whatsit_code = nodecodes.whatsit +local hlist_code = nodecodes.hlist +local vlist_code = nodecodes.vlist +local glue_code = nodecodes.glue +local whatsit_code = nodecodes.whatsit -local leftskip_code = skipcodes.leftskip -local rightskip_code = skipcodes.rightskip -local parfillskip_code = skipcodes.parfillskip +local leftskip_code = skipcodes.leftskip +local rightskip_code = skipcodes.rightskip +local parfillskip_code = skipcodes.parfillskip -local localpar_code = whatcodes.localpar -local dir_code = whatcodes.dir +local localpar_code = whatcodes.localpar +local dir_code = whatcodes.dir -local line_code = listcodes.line +local line_code = listcodes.line -local nodepool = nodes.pool +local nodepool = nodes.pool -local new_kern = nodepool.kern +local new_kern = nodepool.kern -local traverse = node.traverse -local find_node_tail = node.tail or node.slide -local tosequence = nodes.tosequence +local traverse = node.traverse +local find_node_tail = node.tail or node.slide +local tosequence = nodes.tosequence -- local function dimensions(parent,start,stop) -- stop = stop and stop.next @@ -362,20 +361,19 @@ local function colorize(width,height,depth,n,reference,what) end end -local nodepool = nodes.pool - -local new_kern = nodepool.kern +-- references: -local texattribute = tex.attribute -local texcount = tex.count +local nodepool = nodes.pool +local new_kern = nodepool.kern --- references: +local texsetattribute = tex.setattribute +local texsetcount = tex.setcount -local stack = { } -local done = { } -local attribute = attributes.private('reference') -local nofreferences = 0 -local topofstack = 0 +local stack = { } +local done = { } +local attribute = attributes.private('reference') +local nofreferences = 0 +local topofstack = 0 nodes.references = { attribute = attribute, @@ -390,8 +388,8 @@ local function setreference(h,d,r) -- the preroll permits us to determine samepage (but delayed also has some advantages) -- so some part of the backend work is already done here stack[topofstack] = { r, h, d, codeinjections.prerollreference(r) } - -- texattribute[attribute] = topofstack -- todo -> at tex end - texcount.lastreferenceattribute = topofstack + -- texsetattribute(attribute,topofstack) -- todo -> at tex end + texsetcount("lastreferenceattribute",topofstack) end function references.get(n) -- not public so functionality can change @@ -500,13 +498,16 @@ local function makedestination(width,height,depth,reference) nofdestinations = nofdestinations + 1 for n=1,#name do local annot = nodeinjections.destination(width,height,depth,name[n],view) - if not result then - result = annot - else - current.next = annot - annot.prev = current + if annot then + -- probably duplicate + if not result then + result = annot + else + current.next = annot + annot.prev = current + end + current = find_node_tail(annot) end - current = find_node_tail(annot) end if result then -- some internal error @@ -540,7 +541,7 @@ function references.inject(prefix,reference,h,d,highlight,newwindow,layer) -- to -- unknown ref, just don't set it and issue an error else -- check - set.highlight, set.newwindow,set.layer = highlight, newwindow, layer + set.highlight, set.newwindow, set.layer = highlight, newwindow, layer setreference(h,d,set) -- sets attribute / todo: for set[*].error end end @@ -573,7 +574,7 @@ end statistics.register("interactive elements", function() if nofreferences > 0 or nofdestinations > 0 then - return format("%s references, %s destinations",nofreferences,nofdestinations) + return string.format("%s references, %s destinations",nofreferences,nofdestinations) else return nil end |