ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Syntax highlighting for C-code
@ 2012-01-13 11:00 Richard Weickelt
  2012-01-14 15:40 ` [***SPAM***] " Peter Münster
  2012-01-15 11:06 ` Wolfgang Schuster
  0 siblings, 2 replies; 4+ messages in thread
From: Richard Weickelt @ 2012-01-13 11:00 UTC (permalink / raw)
  To: ntg-context

Hi,

I've tried to include some C-code into my document, but failed to enable 
syntax highlighting.

Tested on: linux-64, context-2011.05.18 (same with the beta) stand-alone mkIV

1) \starttyping[option=C] just prints verbatim text. There seems to be no 
formatter for C out of the box.

2) t-vim did not work. It failed somewhere (unknown command sequence 
\installspacehandler) on loading (\usemodule[vim])

3) http://wiki.contextgarden.net/Verbatim_text
I tried to download pret-c and put it into the modules folder, but writing 
\installprettytype[C][C] failed, because it's not known (in mkIV).

4) mkII does not complain to exec \installprettytype[C][C], but this does 
not change anything either. \starttyping[option=C] seems to call a (maybe 
builtin?) formatter, but I could not get colors to work.

I'm also lost in the documentation, because there are many places talking 
about syntax-highlighting. Does this thing work for anybody or is ist just 
my installation?

Thanks
Richard
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [***SPAM***] Re:  Syntax highlighting for C-code
  2012-01-13 11:00 Syntax highlighting for C-code Richard Weickelt
@ 2012-01-14 15:40 ` Peter Münster
  2012-01-14 18:03   ` Aditya Mahajan
  2012-01-15 11:06 ` Wolfgang Schuster
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Münster @ 2012-01-14 15:40 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Fri, Jan 13 2012, Richard Weickelt wrote:

> 2) t-vim did not work. It failed somewhere (unknown command sequence
> \installspacehandler) on loading (\usemodule[vim])

Usually, t-vim works quite well. Perhaps it's just broken with your
particular context version.


> 3) http://wiki.contextgarden.net/Verbatim_text
> I tried to download pret-c and put it into the modules folder, but writing
> \installprettytype[C][C] failed, because it's not known (in mkIV).

Should work with an old context version (end of 2010).

You can also try
http://tlcontrib.metatex.org/cgi-bin/package.cgi/action=view/id=367

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [***SPAM***] Re: Syntax highlighting for C-code
  2012-01-14 15:40 ` [***SPAM***] " Peter Münster
@ 2012-01-14 18:03   ` Aditya Mahajan
  0 siblings, 0 replies; 4+ messages in thread
From: Aditya Mahajan @ 2012-01-14 18:03 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 824 bytes --]

On Sat, 14 Jan 2012, Peter Münster wrote:

> On Fri, Jan 13 2012, Richard Weickelt wrote:
>
>> 2) t-vim did not work. It failed somewhere (unknown command sequence
>> \installspacehandler) on loading (\usemodule[vim])
>
> Usually, t-vim works quite well. Perhaps it's just broken with your
> particular context version.

In the current beta, \installspacehandler has been renamed to 
\installspacemethod. So, saying

\let\installspacehandler\installspacemethod

before loading vim module should fix this bug (untested).

However, since buffers are also broken in the current beta (see other 
messages), t-vim (and t-filter) will not work with the current beta. 
I'll check and upload a new version of the module, but you'll have to wait 
until Hans uploads a new beta to get everything working.

Aditya

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Syntax highlighting for C-code
  2012-01-13 11:00 Syntax highlighting for C-code Richard Weickelt
  2012-01-14 15:40 ` [***SPAM***] " Peter Münster
@ 2012-01-15 11:06 ` Wolfgang Schuster
  1 sibling, 0 replies; 4+ messages in thread
From: Wolfgang Schuster @ 2012-01-15 11:06 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 13.01.2012 um 12:00 schrieb Richard Weickelt:

> Hi,
> 
> I've tried to include some C-code into my document, but failed to enable syntax highlighting.
> 
> Tested on: linux-64, context-2011.05.18 (same with the beta) stand-alone mkIV
> 
> 1) \starttyping[option=C] just prints verbatim text. There seems to be no formatter for C out of the box.

There is no formatter for C code in MkIV but when you write one send the file to Hans and he can include it in the distribution.

> 2) t-vim did not work. It failed somewhere (unknown command sequence \installspacehandler) on loading (\usemodule[vim])
> 
> 3) http://wiki.contextgarden.net/Verbatim_text
> I tried to download pret-c and put it into the modules folder, but writing \installprettytype[C][C] failed, because it's not known (in mkIV).

MkII and MkIV have different implementation to format source code.

> 4) mkII does not complain to exec \installprettytype[C][C], but this does not change anything either. \starttyping[option=C] seems to call a (maybe builtin?) formatter, but I could not get colors to work.


The following is MkII only. There are two ways to have formatted C code, the first is to define a C environment with \definetype[C][option=C] and then you can put the code between \startC and \stopC, the second is to use the normal typing environment and pass “option=C” as argument. To get colors in your code you have to enable them first with \setupcolors[state=start].

% engine=pdftex

\setupcolors[state=start]

\definetyping[C][option=C]

\starttext

\startC
#include<stdio.h>
 
int main()
{
   printf("Hello World\n");
   return 0;
}
\stopC

\blank[2*line]

\starttyping[option=C]
#include<stdio.h>
 
int main()
{
   printf("Hello World\n");
   return 0;
}
\stoptyping

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-15 11:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-13 11:00 Syntax highlighting for C-code Richard Weickelt
2012-01-14 15:40 ` [***SPAM***] " Peter Münster
2012-01-14 18:03   ` Aditya Mahajan
2012-01-15 11:06 ` Wolfgang Schuster

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).