[Dev-luatex] How to insert at start of hlist/vlist?
Hans Hagen
pragma at wxs.nl
Sat Dec 8 00:31:59 CET 2007
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
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
> Example (complete example file after PS):
>
> \setbox0=\hbox{XY}
> \directlua0{
> 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"
> local head = hlist.list
> % local current = hlist.list.next % works
> local current = hlist.list % fails
> hlist.list = node.insert_before(head, current, pdf_literal)
> end
> }
>
> ! LuaTeX error Attempt to node.insert_before() a non-existing node.
>
> Have I misunderstood node.insert_before()?
>
> Yours sincerely
> Heiko <oberdiek at uni-freiburg.de>
>
> PS: Complete example file that can be used with
> iniTeX, plain-TeX and LaTeX:
>
> \ifnum\catcode`\{=1
> \else
> \catcode`\{=1
> \catcode`\}=2
> \hsize=6.5in
> \vsize=8.9in
> \parfillskip=0pt plus 1fil
> \fi
> \font\f=cmr10
> \f
> \pdfoutput=1
>
> \setbox0=\hbox{XY}
> \directlua0{
> 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"
> local head = hlist.list
> % local current = hlist.list.next % works
> local current = hlist.list % fails
> hlist.list = node.insert_before(head, current, pdf_literal)
> end
> }
> \shipout\hbox{[\box0]}
>
> \csname @@end\endcsname
> \end
> _______________________________________________
> dev-luatex mailing list
> dev-luatex at ntg.nl
> http://www.ntg.nl/mailman/listinfo/dev-luatex
--
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
More information about the dev-luatex
mailing list