From: Aditya Mahajan <adityam@umich.edu>
To: ntg-context@ntg.nl
Subject: Re: listings.sty
Date: Thu, 10 Jul 2008 18:02:28 -0400 [thread overview]
Message-ID: <20080710180228.18001tw3gupfxtlw@web.mail.umich.edu> (raw)
In-Reply-To: <loom.20080710T203021-133@post.gmane.org>
Quoting Mohamed Bana <abbg770@city.ac.uk>:
> nico <nicolas.marsgui <at> libertysurf.fr> writes:
>
>>
>> I don't see the point. The native ConTeXt verbatim support seems to cover
>> all what listings can do.
>>
>> The wiki page gives some examples:
>> http://wiki.contextgarden.net/Verbatim_text
>>
>> Regards,
>> BG
>>
>
>
> Hi,
>
> take a look at
> http://vega.soi.city.ac.uk/~abbg770/listing-sample.pdf, note you
> can customize the style of the font numbering, you can place a caption and my
> favourite is the colouring; if you use Eclipse you'll notice that
> it's the same
> colour the editor uses.
This can be done easily with current ConTeXt, for example:
\setupcolors[state=start]
\starttext
\setuplinenumbering[location=intext]
\setuptyping[option=color]
\startJV
/**
* The HelloWorldApp class implements an application that
* simply prints "Hello World!" to standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}
\stopJV
See the wiki page for adding line numbering and frames (or ask here if
the wiki page is confusing). It is possible to change the color scheme
and the wiki page gives an example. To make sure that the frames break
around pages, you will need to use backgroundtext rather than
framedtext.
The only advantage of listings is that it provides support for a *lot*
of languages out of the box. Writing a syntax highlighter is not easy.
I mean, you need to define all kinds of keywords, write regex or
parser for identifying comments, strings, escape sequences etc. No
matter what language is used to write a syntax highlighter, writing a
good syntax highlighter takes time. And hence the advantage of
listing. In terms of features, I think it is not difficult to add the
required display features in ConTeXt. Line numbering every n lines[1],
using proportional fonts, fancy frames, etc are pretty
straight-forward things.
One option for the long term could be to write a module for mkiv, that
can parse the syntax highlighting files of some editor and use them
directly. Since most decent editors have syntax highlighting files for
lot of languages, we will not have to do the hard work. (well, in case
you don't like any available syntax highlighting, and want to roll
your own, then it is a different matter).
There is a module that uses vim to generate syntax highlighting. Mojca
started the module, and I extended it when I needed syntax
highlighting for a project. After that, I have not really updated it.
It works by using vim to generate a tex file which is then read by
context. The only drawback is the starting and stopping times of vim
are fairly large (few secs for each file to be transformed).
Aditya
[1] Actually, line numbering every n lines is already supported.
___________________________________________________________________________________
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
___________________________________________________________________________________
next prev parent reply other threads:[~2008-07-10 22:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-27 17:23 listings.sty Peter Münster
2004-06-28 7:38 ` listings.sty Patrick Gundlach
2004-06-28 8:03 ` listings.sty Hans Hagen
2004-06-28 8:18 ` Morten Høgholm
2004-06-28 8:39 ` Holger Schöner
2004-06-28 9:26 ` Peter Münster
2004-06-28 14:39 ` Hans Hagen
2004-06-28 17:46 ` Peter Münster
2004-06-28 21:51 ` Nikolai Weibull
2004-07-10 9:44 ` Peter Münster
2008-07-10 0:27 ` listings.sty Mohamed Bana
2008-07-10 12:29 ` listings.sty Aditya Mahajan
2008-07-10 18:26 ` listings.sty nico
2008-07-10 20:34 ` listings.sty Mohamed Bana
2008-07-10 22:02 ` Aditya Mahajan [this message]
2008-07-10 21:31 ` listings.sty Hans Hagen
2008-07-11 21:51 ` listings.sty Mohamed Bana
2008-07-11 22:53 ` listings.sty Hans Hagen
2008-07-11 22:54 ` listings.sty Aditya Mahajan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080710180228.18001tw3gupfxtlw@web.mail.umich.edu \
--to=adityam@umich.edu \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).