Re: [NTG-context] colors for pretty-printing

2010-12-10 Thread Renaud AUBIN
I need to not redefine.

Quoting Hans: maybe you should protect the color names as for instance
redefining darkred might not be the intention

In fact, I just need to find unique names for my colors to not overload
the existing ones…

Renaud

 I still don't understand. Where do you need to redefine darkred?
 Cheers, Peter

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


Re: [NTG-context] colors for pretty-printing

2010-12-10 Thread Peter Münster
On Wed, Dec 08 2010, Renaud AUBIN wrote:

 In fact, I just need to find unique names for my colors to not overload
 the existing ones…

\doifcolorelse{new funny color}
  {Error: funny color already exists!}
  {\definecolor[new funny color][...]}

With \setupcolor[ema] or \setupcolor[ema, x11, xwi] there are already a lot of
predefined colors, so I don't think that you need new color definitions in the
module.

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


Re: [NTG-context] colors for pretty-printing

2010-12-10 Thread Renaud AUBIN
Ok but then why did you define a specific color palet?

local function color_init()
color = 0
local def_colors = -- \setupcolor[ema] introduces new line...
\\definecolor [darkred]   [r=.545098] ..
\\definecolor [orchid][r=.854902,g=.439216,b=.839216] ..
\\definecolor [rosybrown] [r=.737255,g=.560784,b=.560784] ..
\\definecolor [forestgreen]   [r=.13,g=.545098,b=.13] ..
…

Renaud
 With \setupcolor[ema] or \setupcolor[ema, x11, xwi] there are already a lot of
 predefined colors, so I don't think that you need new color definitions in the
 module
___
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
___


Re: [NTG-context] colors for pretty-printing

2010-12-10 Thread Peter Münster
On Fri, Dec 10 2010, Renaud AUBIN wrote:

 Ok but then why did you define a specific color palet?
 
 local function color_init()
 color = 0
 local def_colors = -- \setupcolor[ema] introduces new line...

The comment says it: \setupcolor[ema] introduces new line and that's annoying
when you do inline typing: bla bla \typeC{int main(){}} bla bla

The \definecolor[] lines (dirty workaround) were just copied from
colo-ema.tex.

The problem with the pretty-c.lua was, that color_init() was called at every
\typeC{} or \startC.

In your t-pretty-c.mkiv you can use \setupcolor[ema] without problems.

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


Re: [NTG-context] colors for pretty-printing

2010-12-10 Thread Renaud AUBIN
Done and committed on
http://gitorious.org/c-pretty-printer-module-for-context-mark-iv
 In your t-pretty-c.mkiv you can use \setupcolor[ema] without problems.
___
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
___


Re: [NTG-context] colors for pretty-printing (was: Re: pret-c.lua - v-c.lua)

2010-12-07 Thread Aditya Mahajan

On Tue, 7 Dec 2010, Peter Münster wrote:


On Mon, Dec 06 2010, Renaud AUBIN wrote:


Concerning the color abstraction patch, one needs just to overload
Ccomment, Cpreproc, Cstring, Ctype, Ckeyword, Cname and Cfuncnbound to
use custom color scheme.


You don't need that. There is already a standard interface for color and style
configuration. Example:

\setupstartstop[CSnippetComment][color=blue]

So you can simplify t-pretty-c.mkiv:

\unprotect

\setupcolor[ema]

\definestartstop
   [CSnippetName]
   [\c!color=darkgoldenrod,
\c!style=]


I have not looked into the new verbatim code yet, but I have been thinking 
about a similar interface for a new module that uses external programs for 
syntax highlighting (sort of a superset of t-vim that will allow one to 
use other programs like pgyments, etc.).


Why are you using a C prefix for all environments? Isn't it better to use 
a syntax like this:


\startsetups[verbatim:C]
\definestartstop[SnippetName][color=...,style=...]
\definestartstop[string][color=...,style=...]

\stopsetups

and then pass setups=verbatim:C to an appropriate \setup... command. That 
will make it easy to share the same syntax highlighting between different 
languages.


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
___


Re: [NTG-context] colors for pretty-printing

2010-12-07 Thread Hans Hagen

On 7-12-2010 2:29, Aditya Mahajan wrote:

On Tue, 7 Dec 2010, Peter Münster wrote:


On Mon, Dec 06 2010, Renaud AUBIN wrote:


Concerning the color abstraction patch, one needs just to overload
Ccomment, Cpreproc, Cstring, Ctype, Ckeyword, Cname and Cfuncnbound to
use custom color scheme.


You don't need that. There is already a standard interface for color
and style
configuration. Example:

\setupstartstop[CSnippetComment][color=blue]

So you can simplify t-pretty-c.mkiv:

\unprotect

\setupcolor[ema]

\definestartstop
[CSnippetName]
[\c!color=darkgoldenrod,
\c!style=]


I have not looked into the new verbatim code yet, but I have been
thinking about a similar interface for a new module that uses external
programs for syntax highlighting (sort of a superset of t-vim that will
allow one to use other programs like pgyments, etc.).


it all boils down hooking in a parser then:

\startluacode
local function parser(s)
  local s = somexternalthing(s)
  -- feedback s
end

visualizers.register(myparser, { parser = parser })
\stopluacode

\starttyping[option=myparser]

\stoptyping


Why are you using a C prefix for all environments? Isn't it better to
use a syntax like this:

\startsetups[verbatim:C]
\definestartstop[SnippetName][color=...,style=...]
\definestartstop[string][color=...,style=...]

\stopsetups

and then pass setups=verbatim:C to an appropriate \setup... command.
That will make it easy to share the same syntax highlighting between
different languages.


it's hard to come up with common names for characteristics for all those 
languages but at some point we can have a set predefined as default


btw, startstop can inherit (now):

\definestartstop
[MetapostSnippet]
[DefaultSnippet]

etc so there is no need for setups

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
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
___


Re: [NTG-context] colors for pretty-printing

2010-12-07 Thread Aditya Mahajan

On Tue, 7 Dec 2010, Hans Hagen wrote:


On 7-12-2010 2:29, Aditya Mahajan wrote:

On Tue, 7 Dec 2010, Peter Münster wrote:


On Mon, Dec 06 2010, Renaud AUBIN wrote:


Concerning the color abstraction patch, one needs just to overload
Ccomment, Cpreproc, Cstring, Ctype, Ckeyword, Cname and Cfuncnbound to
use custom color scheme.


You don't need that. There is already a standard interface for color
and style
configuration. Example:

\setupstartstop[CSnippetComment][color=blue]

So you can simplify t-pretty-c.mkiv:

\unprotect

\setupcolor[ema]

\definestartstop
[CSnippetName]
[\c!color=darkgoldenrod,
\c!style=]


I have not looked into the new verbatim code yet, but I have been
thinking about a similar interface for a new module that uses external
programs for syntax highlighting (sort of a superset of t-vim that will
allow one to use other programs like pgyments, etc.).


it all boils down hooking in a parser then:

\startluacode
local function parser(s)
 local s = somexternalthing(s)
 -- feedback s
end

visualizers.register(myparser, { parser = parser })
\stopluacode

\starttyping[option=myparser]

\stoptyping


Thanks for the explanation. But, I am not too keen to write parsers on my 
own when I can easily borrow existing ones.



Why are you using a C prefix for all environments? Isn't it better to
use a syntax like this:

\startsetups[verbatim:C]
\definestartstop[SnippetName][color=...,style=...]
\definestartstop[string][color=...,style=...]

\stopsetups

and then pass setups=verbatim:C to an appropriate \setup... command.
That will make it easy to share the same syntax highlighting between
different languages.


it's hard to come up with common names for characteristics for all those 
languages


But it does allow you to choose a color scheme for pretty printing. This 
is similar to how most editors choose color schemes.



but at some point we can have a set predefined as default

btw, startstop can inherit (now):

\definestartstop
   [MetapostSnippet]
   [DefaultSnippet]

etc so there is no need for setups


Setups have an advantage that one does not pollute the cs names. After 
all, \DefaultSnippet is not useful outside the pretty printing region.


An alternative could be to use a namsespace in define in all definitions, 
e.g.,


\definestartstop[visualizer::Snippet]

On a related note, does it make sense to add foregroundcolor and 
foregroupdstyle keys to \definebar? (Then, bars will be an appropriate and 
versatile mechanism to define syntax highlighting regions).


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
___


Re: [NTG-context] colors for pretty-printing

2010-12-07 Thread Hans Hagen

On 7-12-2010 6:57, Aditya Mahajan wrote:


Thanks for the explanation. But, I am not too keen to write parsers on
my own when I can easily borrow existing ones.


sure, but a simple one can be:

function myparser(str)
  .. call your prog do do something with str and return the result
end


But it does allow you to choose a color scheme for pretty printing.
This is similar to how most editors choose color schemes.


sure, but my experience is that there are easily 10-15 different 
categories and naming them right is somewhat tricky



On a related note, does it make sense to add foregroundcolor and
foregroupdstyle keys to \definebar? (Then, bars will be an appropriate
and versatile mechanism to define syntax highlighting regions).


maybe

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
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
___


Re: [NTG-context] colors for pretty-printing

2010-12-07 Thread Renaud AUBIN

 You don't need that. There is already a standard interface for color and style
 configuration. Example:

 \setupstartstop[CSnippetComment][color=blue]

 So you can simplify t-pretty-c.mkiv:

 \unprotect

 \setupcolor[ema]

 \definestartstop
 [CSnippetName]
 [\c!color=darkgoldenrod,
  \c!style=]

 and so on...
   
OK, but anyway, I have to protect the color names (to prevent darkred
redefinition for example ;) )… So, I have made the choice to use
Csomething and it is not annoying as soon as the source color names are
kept…

Cheers

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


Re: [NTG-context] colors for pretty-printing

2010-12-07 Thread Peter Münster
On Tue, Dec 07 2010, Renaud AUBIN wrote:
 
  So you can simplify t-pretty-c.mkiv:
 
  \unprotect
 
  \setupcolor[ema]
 
  \definestartstop
  [CSnippetName]
  [\c!color=darkgoldenrod,
   \c!style=]
 
  and so on...

 OK, but anyway, I have to protect the color names (to prevent darkred
 redefinition for example ;) )

I still don't understand. Where do you need to redefine darkred?
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] colors for pretty-printing

2010-12-07 Thread Aditya Mahajan
On Tue, Dec 7, 2010 at 2:30 PM, Hans Hagen pra...@wxs.nl wrote:
 On 7-12-2010 6:57, Aditya Mahajan wrote:

 Thanks for the explanation. But, I am not too keen to write parsers on
 my own when I can easily borrow existing ones.

 sure, but a simple one can be:

 function myparser(str)
  .. call your prog do do something with str and return the result
 end

OK. This sounds much easier than writing my own wrappers. I will try
to port the t-vim module to use the new code.

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
___