ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \setupframed[...][...=...]
@ 2006-04-12  0:25 Vit Zyka
  2006-04-12  8:56 ` \setupframed[...][...=...] Hans Hagen
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Vit Zyka @ 2006-04-12  0:25 UTC (permalink / raw)


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.

Vit

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: \setupframed[...][...=...]
  2006-04-12  0:25 \setupframed[...][...=...] Vit Zyka
@ 2006-04-12  8:56 ` Hans Hagen
  2006-04-12  9:11 ` \setupframed[...][...=...] Hans Hagen
  2006-04-12  9:14 ` \setupframed[...][...=...] Hans Hagen
  2 siblings, 0 replies; 8+ messages in thread
From: Hans Hagen @ 2006-04-12  8:56 UTC (permalink / raw)


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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: \setupframed[...][...=...]
  2006-04-12  0:25 \setupframed[...][...=...] Vit Zyka
  2006-04-12  8:56 ` \setupframed[...][...=...] Hans Hagen
@ 2006-04-12  9:11 ` Hans Hagen
  2006-04-12  9:39   ` \setupframed[...][...=...] Vit Zyka
  2006-04-12  9:14 ` \setupframed[...][...=...] Hans Hagen
  2 siblings, 1 reply; 8+ messages in thread
From: Hans Hagen @ 2006-04-12  9:11 UTC (permalink / raw)


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 -) 

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

keep in mind that some 100 setups of the same instance may lead to rather big definitions 

\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) 

you can add such patches to cont-loc.tex which is not distributed but read at runtime 

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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: \setupframed[...][...=...]
  2006-04-12  0:25 \setupframed[...][...=...] Vit Zyka
  2006-04-12  8:56 ` \setupframed[...][...=...] Hans Hagen
  2006-04-12  9:11 ` \setupframed[...][...=...] Hans Hagen
@ 2006-04-12  9:14 ` Hans Hagen
  2006-04-12 13:29   ` \setupframed[...][...=...] Vit Zyka
  2 siblings, 1 reply; 8+ messages in thread
From: Hans Hagen @ 2006-04-12  9:14 UTC (permalink / raw)


Vit Zyka wrote:
> Is there some simple solution? Or it has to be rewritten in a way like 
> other \definesomething[...] (storing every parameter/definition-instance 
>   
btw, there is (beware: use some unique name):

\presetlocalframed[myframed]
\setuplocalframed[myframed][width=4cm,height=2cm]
\localframed[myframed][framecolor=green]{oeps}
 

-----------------------------------------------------------------
                                          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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: \setupframed[...][...=...]
  2006-04-12  9:11 ` \setupframed[...][...=...] Hans Hagen
@ 2006-04-12  9:39   ` Vit Zyka
  0 siblings, 0 replies; 8+ messages in thread
From: Vit Zyka @ 2006-04-12  9:39 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: \setupframed[...][...=...]
  2006-04-12  9:14 ` \setupframed[...][...=...] Hans Hagen
@ 2006-04-12 13:29   ` Vit Zyka
  2006-04-12 14:26     ` \setupframed[...][...=...] Hans Hagen
  0 siblings, 1 reply; 8+ messages in thread
From: Vit Zyka @ 2006-04-12 13:29 UTC (permalink / raw)


Hans Hagen wrote:
> Vit Zyka wrote:
> 
>>Is there some simple solution? Or it has to be rewritten in a way like 
>>other \definesomething[...] (storing every parameter/definition-instance 
>>  
> 
> btw, there is (beware: use some unique name):
> 
> \presetlocalframed[myframed]
> \setuplocalframed[myframed][width=4cm,height=2cm]
> \localframed[myframed][framecolor=green]{oeps}

localframed was a mysterious stuff for me.

It seems do exactly what I wanted. In this perspective the 
\setupframed[...][...=...] is not needed (only for not being suprised 
since its absence is a bit against context filosofy).

I just wanted to fill texshow web, but it is missing this stuff. So I 
added \*localframed note in missing texshow items on wiki.

Vit

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: \setupframed[...][...=...]
  2006-04-12 13:29   ` \setupframed[...][...=...] Vit Zyka
@ 2006-04-12 14:26     ` Hans Hagen
  2006-04-12 16:04       ` \setupframed[...][...=...] Vit Zyka
  0 siblings, 1 reply; 8+ messages in thread
From: Hans Hagen @ 2006-04-12 14:26 UTC (permalink / raw)


Vit Zyka wrote:
> Hans Hagen wrote:
>   
>> Vit Zyka wrote:
>>
>>     
>>> Is there some simple solution? Or it has to be rewritten in a way like 
>>> other \definesomething[...] (storing every parameter/definition-instance 
>>>  
>>>       
>> btw, there is (beware: use some unique name):
>>
>> \presetlocalframed[myframed]
>> \setuplocalframed[myframed][width=4cm,height=2cm]
>> \localframed[myframed][framecolor=green]{oeps}
>>     
>
> localframed was a mysterious stuff for me.
>
> It seems do exactly what I wanted. In this perspective the 
> \setupframed[...][...=...] is not needed (only for not being suprised 
> since its absence is a bit against context filosofy).
>
> I just wanted to fill texshow web, but it is missing this stuff. So I 
> added \*localframed note in missing texshow items on wiki.
>   
it actually is a low level command, also, there is \defineframedtext which is (1) configurable and (2) provided \myframed as well

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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: \setupframed[...][...=...]
  2006-04-12 14:26     ` \setupframed[...][...=...] Hans Hagen
@ 2006-04-12 16:04       ` Vit Zyka
  0 siblings, 0 replies; 8+ messages in thread
From: Vit Zyka @ 2006-04-12 16:04 UTC (permalink / raw)


Hans Hagen wrote:
> Vit Zyka wrote:
> 
>>Hans Hagen wrote:
>>  
>>
>>>Vit Zyka wrote:
>>>
>>>    
>>>
>>>>Is there some simple solution? Or it has to be rewritten in a way like 
>>>>other \definesomething[...] (storing every parameter/definition-instance 
>>>> 
>>>>      
>>>
>>>btw, there is (beware: use some unique name):
>>>
>>>\presetlocalframed[myframed]
>>>\setuplocalframed[myframed][width=4cm,height=2cm]
>>>\localframed[myframed][framecolor=green]{oeps}
>>>    
>>
>>localframed was a mysterious stuff for me.
>>
>>It seems do exactly what I wanted. In this perspective the 
>>\setupframed[...][...=...] is not needed (only for not being suprised 
>>since its absence is a bit against context filosofy).
>>
>>I just wanted to fill texshow web, but it is missing this stuff. So I 
>>added \*localframed note in missing texshow items on wiki.
>>  
> 
> it actually is a low level command, also, there is \defineframedtext which is (1) configurable and (2) provided \myframed as well
> 
> Hans 

And the content of \framed and \framedtext is formated the same way?

Hmm I am a bit confused with \framed v. \localframed v. \framedtext. If 
the difference is only in an interface or even in functionality. I will 
have to study the code but not time for that now.

Thanks for this note.
Vit

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-04-12 16:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-12  0:25 \setupframed[...][...=...] Vit Zyka
2006-04-12  8:56 ` \setupframed[...][...=...] Hans Hagen
2006-04-12  9:11 ` \setupframed[...][...=...] Hans Hagen
2006-04-12  9:39   ` \setupframed[...][...=...] Vit Zyka
2006-04-12  9:14 ` \setupframed[...][...=...] Hans Hagen
2006-04-12 13:29   ` \setupframed[...][...=...] Vit Zyka
2006-04-12 14:26     ` \setupframed[...][...=...] Hans Hagen
2006-04-12 16:04       ` \setupframed[...][...=...] Vit Zyka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).