Hello!
I would like to set framed boxes, measure their dimensions and proceed based on the measurement. It is a combination of TeX and Lua ends.
- Boxes are set on the TeX side. Stacking boxes (hbox, framed, vbox) in Lua looked too complex.
- The content of the inner box is set on the Lua side (some computations).
On TeX side boxes and their dimensions are accessible, but not at Lua side, until
luacode is finished (iterations over boxes happen here). I would say Hans already named the problem in the list:
that is always tricky as what happens is postponing till the group ends.
Do you have an idea how to expand the box sooner or would you use a different approach?
Sorry for longer MWE (attached
also).
Thank you,
Jano
\def\StartBox{\setbox0=\hbox\bgroup% open hbox
\framed[frame=on]\bgroup% open framed
\vbox\bgroup% open vbox (\par needed)
}
\def\StopBox{\egroup\egroup\egroup% close vbox, framed, hbox
\setvariable{Test}{Height}{\the\ht0}%
}%
\startluacode
ctx = context
function TestBox()
ctx("TeX Box: ") ctx.copy(false,0)ctx.par()
ctx("TeX Getvar: ") ctx.getvariable("Test", "Height")ctx.par()
var = tokens.getters.macro(tokens.getters.macro("??variables") .. "Test:Height")
ctx("Lua Type: ") ctx(type(var))ctx.par()
ctx("Lua Value: ") ctx(var)ctx.par()
end
\stopluacode
\starttext
\startluacode
ctx.bold("First luacode (more boxes)")ctx.par()
ctx.StartBox()
ctx("AAA")ctx.par()
ctx("BBB")ctx.par()
ctx.StopBox()
TestBox()
ctx.StartBox()
ctx("CCC")ctx.par()
ctx.StopBox()
TestBox()
\stopluacode
\blank[4*big]
\startluacode
ctx.bold("Second luacode (last content of box0)")ctx.par()
TestBox()
\stopluacode
\stoptext