Re: [NTG-context] Listings (was: Experience on writing a thesis with MKIV)

2008-10-02 Thread Chen Shen
Hi all,

Here is a simplistic C syntax highlighter. I hope I've extracted
comments/strings/numerics (more or less) correctly.

shenchen


On Wed, Oct 1, 2008 at 11:44 AM, Chen Shen <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Thanks for the pointers. It seems that the syntax-highlighter only
> need supply "function buffers.visualizers.mp.flush_line_()", which
> returns a buffer containing the typesetting commands. Will try playing
> with it.
>
> At the moment, I am looking for the feature with
> \setuptyping[option=commands]. I saw "\mksetupcommandsintype" defined,
> and "buffers.visualizers.enableescape = true" set in core-ver.mkiv,
> but it isn't handled in the default visualizer.
>
> ---
> \starttext
> \setuptyping[option=commands]
> \starttyping
> abc <> <> /BTEX{\sl abc}/ETEX
> \stoptyping
> \stoptext
> ---
>
> regards,
> shenchen
>
> On Wed, Oct 1, 2008 at 1:15 AM, Wolfgang Schuster
> <[EMAIL PROTECTED]> wrote:
>>
>> Am 30.09.2008 um 18:37 schrieb Chen Shen:
>>
>>> Hi Wolfgang,
>>>
>>> I guess you are referring to mkii features. It seems that formatting
>>> in verbatim doesn't work in mkiv yet, or did I miss out something?
>>> None of the wiki verbatim examples worked for me.
>>
>> Syntax hyghlighting is implemented in different ways for MkII
>> and MkIV, MkII use TeX code while MkIV use Lua code to show
>> the keywords etc.
>>
>> Hans added only files for TeX, MetaPost and Lua in MkIV but
>> you could write files for more languages, you find the rules in
>> the verb-*.lua files.
>>
>> Regards,
>> 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  : https://foundry.supelec.fr/projects/contextrev/
>> wiki : http://contextgarden.net
>> ___
>>
>


verb-cpp.lua
Description: Binary data


t1.tex
Description: TeX document
___
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] Listings (was: Experience on writing a thesis with MKIV)

2008-09-30 Thread Chen Shen
Hi,

Thanks for the pointers. It seems that the syntax-highlighter only
need supply "function buffers.visualizers.mp.flush_line_()", which
returns a buffer containing the typesetting commands. Will try playing
with it.

At the moment, I am looking for the feature with
\setuptyping[option=commands]. I saw "\mksetupcommandsintype" defined,
and "buffers.visualizers.enableescape = true" set in core-ver.mkiv,
but it isn't handled in the default visualizer.

---
\starttext
\setuptyping[option=commands]
\starttyping
abc <> <> /BTEX{\sl abc}/ETEX
\stoptyping
\stoptext
---

regards,
shenchen

On Wed, Oct 1, 2008 at 1:15 AM, Wolfgang Schuster
<[EMAIL PROTECTED]> wrote:
>
> Am 30.09.2008 um 18:37 schrieb Chen Shen:
>
>> Hi Wolfgang,
>>
>> I guess you are referring to mkii features. It seems that formatting
>> in verbatim doesn't work in mkiv yet, or did I miss out something?
>> None of the wiki verbatim examples worked for me.
>
> Syntax hyghlighting is implemented in different ways for MkII
> and MkIV, MkII use TeX code while MkIV use Lua code to show
> the keywords etc.
>
> Hans added only files for TeX, MetaPost and Lua in MkIV but
> you could write files for more languages, you find the rules in
> the verb-*.lua files.
>
> Regards,
> 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  : https://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ___
>
___
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] Listings (was: Experience on writing a thesis with MKIV)

2008-09-30 Thread Wolfgang Schuster

Am 30.09.2008 um 18:37 schrieb Chen Shen:

> Hi Wolfgang,
>
> I guess you are referring to mkii features. It seems that formatting
> in verbatim doesn't work in mkiv yet, or did I miss out something?
> None of the wiki verbatim examples worked for me.

Syntax hyghlighting is implemented in different ways for MkII
and MkIV, MkII use TeX code while MkIV use Lua code to show
the keywords etc.

Hans added only files for TeX, MetaPost and Lua in MkIV but
you could write files for more languages, you find the rules in
the verb-*.lua files.

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


Re: [NTG-context] Listings (was: Experience on writing a thesis with MKIV)

2008-09-30 Thread Chen Shen
Hi Wolfgang,

I guess you are referring to mkii features. It seems that formatting
in verbatim doesn't work in mkiv yet, or did I miss out something?
None of the wiki verbatim examples worked for me.

regards,
shenchen

On Mon, Sep 29, 2008 at 2:16 AM, Wolfgang Schuster
<[EMAIL PROTECTED]> wrote:
>
> \setupcolors[state=start]
>
> \definetyping[JAVA][option=JV]
>
> \setuptyping
>   [JAVA]
>   [numbering=line]
>
> \starttext
>
> \startJAVA
> ...
> \stopJAVA
>
> \stoptext
>
> or
>
> same preamble as above plus
>
> \definefloat[listing][listings]
>
> \starttext
>
> \placelisting
>[split]
>[lst:freeformlogfile]
>{Log File}
>{\startJAVA
> ...
> \stopJAVA}
>
> \stoptext
>
> 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  : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] Listings (was: Experience on writing a thesis with MKIV)

2008-09-28 Thread Wolfgang Schuster

Am 28.09.2008 um 19:34 schrieb Mohamed Bana:

> Aditya Mahajan wrote:
>> Hi everyone,
>>
>> I finished my thesis, writing both my thesis and my presentation  
>> using
>> ConTeXt.
>>
>> Aditya
>
> :).  But there's a still something missing that I need before I even
> thinking of typesetting an msc thesis in ConTeXt.   I'd like to have
> something equivelant to the *listings.sty* package;
> http://thread.gmane.org/gmane.comp.tex.context/15591/focus=15592 or
> http://vega.soi.city.ac.uk/~abbg770/listing-sample.pdf.
>
>
> I setup listing first;
>
> \lstset{breaklines=true,
> showlines=true,   % showing line numbers
> numbers=left, % where to show line numbers
> numberstyle=\tiny\color{gray},
> numbersep=10pt,   %
> stepnumber=1, % how often to show the line number on the left
> language=Java,% specifiy the language
> basicstyle=\ttfamily\small,  % print whole listing small
> keywordstyle=\color{eclipsekeyword}\ttfamily\underbar, % underlined  
> bold
> black keywords
> identifierstyle=,   % nothing happens
> commentstyle=\color{eclipsecomment}, % white comments, if you use
> commentstyle=\color{white},
> stringstyle=\ttfamily,  % typewriter type for strings
> showstringspaces=false,   % no special string spaces
> frame=single,
> backgroundcolor=\color{white},
> tabsize=4,
> showspaces=false,
> showstringspaces=false}   
>
> \lstset{morecomment=[s][\color{eclipsejavadoc}]{/**}{*/}}
>
>
> Includes a file, look at Listing B.2 on the pdf I posted.  This should
> be self explanatory;
>
> \lstinputlisting[
> caption={SpreadsheetParser.java},
> label=lst:SpreadsheetParser.java]
> {source/SpreadsheetParser.java}
>
>
>
> I can also list inline using the same settings defined in \lstset -  
> but
> it doesn't break across lines.  The choice of charater is arbitrary
> i.e., I could have chosen to use | instead of !;
>
> \lstinline!matcher(CharSequence input)!
>
>
>
> Similar to preceeding, with line breaking.  Also I can refer to it
> using; \ref{lst:freeformlogfile}
>
> \begin{lstlisting}[frame=,label={lst:freeformlogfile},caption={Log  
> File}]
> import java.util.Arrays;
>
> public class ArrayReallocationDemo {
>
>   public static void main(String[] args) {
> int[] data1 = new int[] { 1, 3, 5, 7, 9 };
>
> printArray(data1);
> int[] data2 = Arrays.copyOf(data1, 6);
> data2[5] = 11;
> printArray(data2);
>
> int[] data3 = Arrays.copyOfRange(data1, 2, 10);
> printArray(data3);
>   }
>
>   // print array elements
>   private static void printArray(int[] data) {
> StringBuilder stringBuilder = new StringBuilder("[");
> for (int i = 0; i < data.length; i++) {
>   stringBuilder.append(data[i]);
>   if (i < data.length - 1)
> stringBuilder.append(", ");
> }
> stringBuilder.append("]");
> System.out.println(stringBuilder);
>   }
> }
> \end{lstlisting}

\setupcolors[state=start]

\definetyping[JAVA][option=JV]

\setuptyping
   [JAVA]
   [numbering=line]

\starttext

\startJAVA
...
\stopJAVA

\stoptext

or

same preamble as above plus

\definefloat[listing][listings]

\starttext

\placelisting
[split]
[lst:freeformlogfile]
{Log File}
{\startJAVA
 ...
 \stopJAVA}

\stoptext

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