Am 16.01.2013 um 15:51 schrieb Marco Patzer <home...@lavabit.com>:

> Hi,
> 
> I need different settings for code in inline and block mode. See the
> following example:
> 
> \usemodule [vim]
> \definetextbackground [C] [location=text]
> \definevimtyping [C]
>  [syntax=c,
>   before={\starttextbackground[C]},
>   after=\stoptextbackground,
>   margin=2em]
> 
> \starttext
> 
> This is C: \inlineC{int foo();}. \blank
> \startC
> int foo(){
>  return 0;
> }
> \stopC
> 
> \stoptext
> 
> Inline code needs “location=text”, block code on the other hand
> needs “location=paragraph” as text background setting. Sure, I can
> create two environments “Cinline” and “Cblock”, but that feels
> clumsy.
> 
> What's the proper way to set up different backgrounds for inline
> and block code?

You can try this (untested):

\definetextbackground[InlineBackground][location=text]
\definetextbackground[DisplayBackground][location=paragraph]

\definevimytping
  [C]
  […,
   before={\ifhmode\startInlineBackground\else\startDisplayBackground\fi},
   after={\ifhmode\stopInlineBackground\else\stopDisplayBackground\fi},
   …]

You could also ask Aditya to use different keys for display (e.g. before/aftter)
and inline (e.g. left/right) code blocks.

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to