On Sat, Dec 08, 2007 at 12:31:59AM +0100, Hans Hagen wrote:
Heiko Oberdiek wrote:
Hello,
I have some trouble to insert something at the start of a list.
weird message indeed; this works
do local hlist = tex.box[0] local pdf_literal = node.new(8,8)% \pdfliteral pdf_literal.mode = 2 % direct pdf_literal.data = "1 0 0 rg 1 0 0 RG" pdf_literal.next = hlist.list hlist.list = pdf_literal end
Thanks. What about "prev"? * insert_before seems to set this entry, too. * I have seen, the head of the list (variable "hlist/tex.box[0]") has a node "prev" with id "temp" in the example (I have also seen "attribute_list", "if_stack" and the expected "nil"). Is this a bug not being "nil"? Or must the new head node inherit the prev entry from the old head node?
current assigning to a box (or operating on box related lists are somewhat tricky, internal invisible pointers and such; this interface will probably change a bit; it helps to copy the list, work on the copy and hpack the result
The there is the problem with freeing the old node list.
The internal invisible pointers remain invisible, thus it is unknown
whether it is safe to call node.free().
What about global/local box contents?
Or is the copy strategy more safe, if two box registers are used?
\begingroup
\setbox1=\box1
\endgroup
% box 1 is void and takes the result
\setbox0=\hbox{XY}
\directlua0{
do
local hlist = node.copy(tex.box[0])
% manipulating hlist
tex.box[1] = hlist
end
}%
\setbox0=\box1
But insert_before also don't work on the copied list.
And I would want to avoid copying the whole list, because
it would mean copying the whole document:
I am experimenting with color support based on an attribute.
At some time the shipout material needs transforming to add
pdf_literals with color setting. BTW, I haven't found a
direct callback function for this (page shipout/xform generation).
The way via a box register requires catching the shipout box
at TeX level (package atbegshi). But \pdfxform can't catched
in an easy and reliable way.
Yours sincerely
Heiko