[NTG-context] \setupframed[...][...=...]

Hans Hagen pragma at wxs.nl
Wed Apr 12 10:56:31 CEST 2006


Vit Zyka wrote:
> Hi,
>
> I tied to extend \setupframed[...=...] to also \setupframed[...][...=...]:
>
> ---------------------------------
> \unprotect
> \def\setupframed{\dodoubleempty\dosetupframed}
> \def\dosetupframed{%
>    \ifsecondargument
>      \@EA\dodoublesetupframed
>    \else
>      \@EA\dosinglesetupframed
>    \fi
> }
> \def\dosinglesetupframed[#1][#2]{\getparameters[\??oi][#1]}
> \def\dodoublesetupframed[#1][#2]{%
>    \bgroup
>      \def\dodoubleempty{}%
>      \def\doframed[##1]{##1}%
>      \xdef\tmp{\getvalue{#1}}%
>    \egroup
>  
> \@EA\setvalue\@EA{\@EA#1\@EA}\@EA{\@EA\dodoubleempty\@EA\doframed\@EA[\tmp,#2]}%
> }
> \protect
>
> \starttext
> \setupframed[framecolor=yellow]          \framed{A}
> \defineframed[myframed][framecolor=blue] \myframed{B}
> \setupframe[myframe][framecolor=red]     \myframed{C}
> \stoptext
> -------------------------------------
>
> it works but with fully expansion of options. So it works a bit 
> differently in a cases
> 1)
> \def\ONorOFF{off}
> \defineframed[myframed][frame=\ONorOFF]
> \def\ONorOFF{on}\myframed{A}
>
> 2)
> \def\ONorOFF{off}
> \defineframed[myframed][frame=\ONorOFF]
> \setupframed[myframe][framecolor=red]
> \def\ONorOFF{on}\myframed{A}
>
> Is there some simple solution? Or it has to be rewritten in a way like 
>   
sure, later (fields do something similar)
> other \definesomething[...] (storing every parameter/definition-instance 
> in a macro)? If sometimes this code would be reviewed I vote for doing 
> \setupframed in this 'standard' ConTeXt way.
>   
the reason for not doing it that way is that it takes less memory; framed preallocates quite some hash entries 

Hans 

-----------------------------------------------------------------
                                          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 ntg-context mailing list