ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Subject: Re: \setupframed[...][...=...]
Date: Wed, 12 Apr 2006 11:11:19 +0200	[thread overview]
Message-ID: <443CC437.3020500@wxs.nl> (raw)
In-Reply-To: <443C48FF.40504@seznam.cz>

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

  parent reply	other threads:[~2006-04-12  9:11 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 ` Hans Hagen [this message]
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

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=443CC437.3020500@wxs.nl \
    --to=pragma@wxs.nl \
    --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).