* Vim module - different settings for inline and block code
@ 2013-01-16 14:51 Marco Patzer
2013-01-16 15:02 ` Wolfgang Schuster
0 siblings, 1 reply; 5+ messages in thread
From: Marco Patzer @ 2013-01-16 14:51 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 714 bytes --]
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?
Marco
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Vim module - different settings for inline and block code
2013-01-16 14:51 Vim module - different settings for inline and block code Marco Patzer
@ 2013-01-16 15:02 ` Wolfgang Schuster
2013-01-16 15:39 ` Marco Patzer
2013-01-16 15:51 ` Aditya Mahajan
0 siblings, 2 replies; 5+ messages in thread
From: Wolfgang Schuster @ 2013-01-16 15:02 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 16.01.2013 um 15:51 schrieb Marco Patzer <homerow@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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Vim module - different settings for inline and block code
2013-01-16 15:02 ` Wolfgang Schuster
@ 2013-01-16 15:39 ` Marco Patzer
2013-01-16 15:58 ` Wolfgang Schuster
2013-01-16 15:51 ` Aditya Mahajan
1 sibling, 1 reply; 5+ messages in thread
From: Marco Patzer @ 2013-01-16 15:39 UTC (permalink / raw)
To: ntg-context
[-- Attachment #1.1: Type: text/plain, Size: 520 bytes --]
On 2013–01–16 Wolfgang Schuster wrote:
> \definevimytping
> [C]
> […,
> before={\ifhmode\startInlineBackground\else\startDisplayBackground\fi},
> after={\ifhmode\stopInlineBackground\else\stopDisplayBackground\fi},
> …]
That's a good idea and it seems to work.
> You could also ask Aditya to use different keys for display (e.g. before/aftter)
> and inline (e.g. left/right) code blocks.
That's not necessary. I think your solution is clean enough.
Thanks Wolfgang.
Marco
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Vim module - different settings for inline and block code
2013-01-16 15:39 ` Marco Patzer
@ 2013-01-16 15:58 ` Wolfgang Schuster
0 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Schuster @ 2013-01-16 15:58 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 16.01.2013 um 16:39 schrieb Marco Patzer <homerow@lavabit.com>:
> On 2013–01–16 Wolfgang Schuster wrote:
>
>> \definevimytping
>> [C]
>> […,
>> before={\ifhmode\startInlineBackground\else\startDisplayBackground\fi},
>> after={\ifhmode\stopInlineBackground\else\stopDisplayBackground\fi},
>> …]
>
> That's a good idea and it seems to work.
>
>> You could also ask Aditya to use different keys for display (e.g. before/aftter)
>> and inline (e.g. left/right) code blocks.
>
> That's not necessary. I think your solution is clean enough.
The test doesn’t work when you use \inlineC at the beginning of a paragraph because
TeX it at this moment still in vertical mode and you have to add a \dontleavehmode
to force horizontal mode.
<example>
\def\TestMode
{\ifhmode
\bold{Horizontal Mode}%
\else
\bold{Vertical Mode}%
\fi}
\starttext
\TestMode\ Inline \TestMode
\dontleavehmode\TestMode\ Inline \TestMode
\stoptext
</example>
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Vim module - different settings for inline and block code
2013-01-16 15:02 ` Wolfgang Schuster
2013-01-16 15:39 ` Marco Patzer
@ 2013-01-16 15:51 ` Aditya Mahajan
1 sibling, 0 replies; 5+ messages in thread
From: Aditya Mahajan @ 2013-01-16 15:51 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Wed, 16 Jan 2013, Wolfgang Schuster wrote:
> You could also ask Aditya to use different keys for display (e.g. before/aftter)
> and inline (e.g. left/right) code blocks.
That's a nice suggestion. I have implemented it in the dev version of the
filter module: https://github.com/adityam/filter/tree/dev but haven't
tested it beyond a simple test case:
https://github.com/adityam/filter/blob/dev/tests/25-before-left.tex
I'll do more thorough tests and a proper release later.
Aditya
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-01-16 15:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-16 14:51 Vim module - different settings for inline and block code Marco Patzer
2013-01-16 15:02 ` Wolfgang Schuster
2013-01-16 15:39 ` Marco Patzer
2013-01-16 15:58 ` Wolfgang Schuster
2013-01-16 15:51 ` Aditya Mahajan
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).