Re: [NTG-context] t-vim: inline typing?

2009-07-21 Thread Peter Münster
On Mon, 20 Jul 2009, Aditya Mahajan wrote:

 On Mon, 20 Jul 2009, Peter Münster wrote:
 
 Attached is an ugly solution. I haven't tested it too much.

Thank you! (perhaps ugly, but working!)


 It should be possible to also define \typeC{...}, but then I will need to read
 up how to read code in verbatim and write it to a file.

Not really necessary for me.

Thanks, Peter

-- 
Contact information: http://pmrb.free.fr/contact/


___
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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] t-vim: inline typing?

2009-07-20 Thread Peter Münster
Hello,

Is it possible somehow, to get inline syntax highlighting (as with
\type{...})?

Cheers, Peter

-- 
Contact information: http://pmrb.free.fr/contact/


___
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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] t-vim: inline typing?

2009-07-20 Thread Aditya Mahajan

On Mon, 20 Jul 2009, Peter Münster wrote:


Hello,

Is it possible somehow, to get inline syntax highlighting (as with
\type{...})?


Attached is an ugly solution. I haven't tested it too much.

Usage example

\usemodule[vim]
\setupwhitespace[big]
\setupcolors[state=start]
\definevimtyping[C][syntax=c]

\starttext
We can always type code in display mode
\startC
#include stdio.h
\stopC

But more interestingly, we can now type code in inline mode
also. For example to print something we use \startinlineC
printf(%d, num); \stopinlineC and we can continue typing.
\stoptext

It should be possible to also define \typeC{...}, but then I will need to 
read up how to read code in verbatim and write it to a file.



Aditya%M \logo [VIM] {VIM} % Needed for the title

%D \module
%D   [  file=t-vim,
%Dversion=2008.07.15,
%D  title=\VIM\ to \CONTEXT,
%D   subtitle=Use \VIM\ to generate code listing,
%D author=Mojca Miklavec \ Aditya Mahajan,
%D  email=adityam at umich dot edu,
%D   date=\currentdate,
%D  copyright=Public Domain]

%M
%M \usemodule [vim]
%M \usemodule[int-load]
%M \loadsetups[t-vim.xml]
%M \usetypescript[modern-base][texnansi] \setupbodyfont[modern]
%M \setuptyping[option=color]
%M \setupcolors[state=start]

%D \section   {User Manual}
%D
%D \CONTEXT\ has an excellent pretty printing capabilities for many languages.
%D The code for pretty printing is written in \TEX, and due to catcode
%D jugglery verbatim typesetting is perhaps the trickiest part of \TEX. This
%D makes it difficult for a \quotation{normal} user to define syntax
%D highlighting rules for a new language. This module, takes the onus of
%D defining syntax highlighting rules away from the user and uses \VIM\ editor
%D to generate the syntax highlighting.  There is a helper
%D \filename{2context.vim} script to do the syntax parsing in \VIM. This is a
%D stop|-|gap method, and hopefully with \LUATEX, things will be much easier. 
%D
%D The main macro of this module is \type{\definevimtyping}. The best way to
%D explain it is by using an example. Suppose you want to pretty print ruby
%D code in \CONTEXT. So you can do
%D \starttyping
%D \definevimtyping [RUBY]  [syntax=ruby]
%D \stoptyping
%D after which you can get ruby highlighting by
%D \starttyping
%D \startRUBY
%D 
%D \stopRUBY
%D \stoptyping
%D
%D For example
%D \startbuffer
%D \definevimtyping [RUBY] [syntax=ruby]
%D
%D \startRUBY
%D #! /usr/bin/ruby
%D # This is my first ruby program
%D puts Hello World
%D \stopRUBY
%D \stopbuffer
%D {\getbuffer}
%D This was typed as \typebuffer
%D
%D The typing can be setup using \type{\setupvimtyping}.
%D
%D \showsetup{setupvimtyping}
%D
%D Here \type{syntax} is the syntax file in \VIM\ for the language
%D highlighting that you want. See \type{:he syntax.txt} inside \VIM\ for
%D details. \type{colorscheme} provides the syntax highlighting for various
%D regions. Right now, two colorschemes are defined. The \type{default}
%D colorscheme is based on on \filename{ps_color.vim} colorscheme in \VIM, and
%D the \type{blackandwhite} colorscheme is based on \filename{print_bw.vim}.
%D If there is a particular colorscheme that you will like, you can convert it
%D into \CONTEXT. \type{space=(yes|on|no)} makes the space significant,
%D visible, and insignificant respectively. \type{tab} specifies the number of
%D spaces a tab is equivalent to. It's default value is 8. \type{start} and
%D \type{stop} specify which lines to read from a file. These options only
%D make sense for highlighting files and should not to be set by
%D \type{\setupvimtyping}.  \type{numbering} enables line numbering, and
%D \type{step} specifies which lines are numbered. \type{numberstyle} and
%D \type{numbercolor} specify the style and color of line numbers. By
%D default the numbers are placed on the left. The location of the numbers can
%D be configured using \type{numbercommand} option.
%D
%D A new typing region can be define using \type{\definevimtyping}.
%D
%D \showsetup{definevimtyping}
%D
%D Minor changes in syntax highlighting can be made easily. For example, Mojca
%D likes \quote{void} to be bold in C programs. This can be done as follows
%D
%D \startbuffer
%D \definevimtyping [C] [syntax=c,numbering=on]
%D 
%D \startvimcolorscheme[default]
%D 
%D \definevimsyntax
%D   [Type]
%D   [style=boldmono]
%D
%D \definevimsyntax
%D   [PreProc]
%D   [style=slantedmono]
%D 
%D \stopvimcolorscheme
%D 
%D \startC
%D #include stdio.h
%D #include stdlib.h
%D 
%D void main() 
%D {
%Dprintf(Hello World\n) ;
%Dreturn;
%D }
%D \stopC
%D \stopbuffer 
%D \typebuffer which gives {\getbuffer}
%D
%D The second command provided by this module is \type{\definetypevimfile} for
%D typesetting files.  The syntax of this command is
%D
%D \showsetup{definetypevimfile}
%D
%D For example, to pretty print a ruby file you can do
%D \starttyping
%D \definetypevimfile[typeRUBY] [syntax=ruby]
%D \stoptyping
%D after which one can use
%D \starttyping
%D