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