ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Vit Zyka <vit.zyka@seznam.cz>
Subject: Re: \setupframed[...][...=...]
Date: Wed, 12 Apr 2006 11:39:31 +0200	[thread overview]
Message-ID: <443CCAD3.8010504@seznam.cz> (raw)
In-Reply-To: <443CC437.3020500@wxs.nl>

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

  reply	other threads:[~2006-04-12  9:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Vit Zyka [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=443CCAD3.8010504@seznam.cz \
    --to=vit.zyka@seznam.cz \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).