From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/42345 Path: news.gmane.org!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: listings.sty Date: Thu, 10 Jul 2008 18:02:28 -0400 Message-ID: <20080710180228.18001tw3gupfxtlw@web.mail.umich.edu> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1215727440 14638 80.91.229.12 (10 Jul 2008 22:04:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 10 Jul 2008 22:04:00 +0000 (UTC) To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Fri Jul 11 00:04:46 2008 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1KH4Fq-0000KX-Bv for gctc-ntg-context-518@m.gmane.org; Fri, 11 Jul 2008 00:04:46 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id DBCDA1FD62; Fri, 11 Jul 2008 00:03:52 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 25237-04-2; Fri, 11 Jul 2008 00:03:05 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id DB01E1FCE3; Fri, 11 Jul 2008 00:03:04 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 73FBC1FCCA for ; Fri, 11 Jul 2008 00:03:03 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 29001-03-2 for ; Fri, 11 Jul 2008 00:02:29 +0200 (CEST) Original-Received: from captainamerica.web.itd.umich.edu (captainamerica.web.itd.umich.edu [141.211.13.152]) by ronja.ntg.nl (Postfix) with ESMTP id 5F1EE1FD60 for ; Fri, 11 Jul 2008 00:02:29 +0200 (CEST) Original-Received: (from www@localhost) by captainamerica.web.itd.umich.edu () id m6AM2SB0008770 for ntg-context@ntg.nl; Thu, 10 Jul 2008 18:02:28 -0400 Original-Received: from eecs4440p09.engin.umich.edu (eecs4440p09.engin.umich.edu [141.213.51.209]) by web.mail.umich.edu (Horde Framework) with HTTP; Thu, 10 Jul 2008 18:02:28 -0400 In-Reply-To: Content-Disposition: inline User-Agent: Internet Messaging Program (IMP) H3 (4.2) X-Remote-Browser: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3 X-IMP-Server: 141.211.13.217 (captainamerica) X-Originating-IP: 141.213.51.209 X-Originating-User: adityam X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:42345 Archived-At: Quoting Mohamed Bana : > nico 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 ___________________________________________________________________________________