Hans Hagen wrote:
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 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.
next time post with less typos -)
Sorry, next time I try to choose better time then 3 o'clock at night.
anyway, here is a working solution:
\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 \let\dodoubleempty\empty \def\doframed[##1]{\gdef\globalredefinedframed{\dodoubleempty\doframed[##1,#2]}}% \getvalue{#1}% \egroup \letvalue{#1}\globalredefinedframed}
\protect
Clever.
keep in mind that some 100 setups of the same instance may lead to rather big definitions
Yes, but no problem, I need only one (or two) resetuping after definition.
\setupcolors[state=start]
\starttext \setupframed[framecolor=yellow] \framed{A} \defineframed[myframed][framecolor=blue] \myframed{B} \setupframed[myframed][framecolor=red] \myframed{C} \stoptext
i need to think about adding this, since it may break other things (i will run it for a while)
All right.
you can add such patches to cont-loc.tex which is not distributed but read at runtime
I see, I did not know about this file. Fine. Thanks Hans, Vit