On 12/2/2012 4:31 PM, Wolfgang Schuster wrote:
Hi,
how can I write the following two lines with Lua, I saw in supp-box.lua a few
example how to loop through the characters but I don’t know how I can add glue
between them.
\starttext
\ruledhbox to 6cm{\processtokens{\hfil }{\hfil\hfil}{\hfil }{}{WORD}}
\ruledhbox to 6cm{\processtokens{\relax}{\hfil\hfil}{\relax}{}{WORD}}
\def\HFILLED#1{\hfil#1\hfil}
\ruledhbox to 6cm{\applytocharacters\HFILLED{WORD}}
\ruledhbox to 6cm{\hfilneg\applytocharacters\HFILLED{WORD}\hfilneg}
\stoptext
\startluacode
function commands.ws_hfilled(str)
context.hfil()
for c in string.utfcharacters(str) do
context(c)
context.hfil()
end
end
\stopluacode
\enabletrackers[context.trace]
\def\HFILLED#1{\ctxcommand{ws_hfilled("#1")}}
\ruledhbox to 6cm{\HFILLED{WORD}}
\ruledhbox to 6cm{\hfilneg\HFILLED{WORD}\hfilneg}
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
_______________________________________________
dev-context mailing list
dev-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/dev-context