Csharp.st
From HasnoWiki
[edit]
description
The following file is needed to provide syntax highlighting using enscript for c# (csharp).
[edit]
usage
Paste the contents into a file called csharp.st and place it in /usr/share/enscript/hl if your trying to add c# highlighting to trac, your going to need to edit mimeview/enscript.py and add
'text/x-csharp': 'csharp',
to the list of mappings. your also going to need to edit mimeview/api.py and add
'cs':'text/x-csharp',
[edit]
the file contents
/*
* States definitions file for C#.
* Author: Carl Lobo (carl@cynapse.com)
*/
state csharp extends HighlightEntry
{
/* Comments. */
/\/\*/ {
comment_face (true);
language_print ($0);
call (c_comment);
comment_face (false);
}
/\/\/\// {
comment_face(true);
bold(true);
language_print($0);
call(eat_one_line);
bold(false);
comment_face(false);
}
/\/\// {
comment_face (true);
language_print ($0);
call (eat_one_line);
comment_face (false);
}
/\#/ {
italic(true);
function_name_face(true);
language_print($0);
call(eat_one_line);
function_name_face(false);
italic(false);
}
/* Escaped strings */
/\@\"[^"]+\"/ {
string_face(true);
language_print($0);
string_face(false);
}
/* String constants. */
/\"/ {
string_face (true);
language_print ($0);
call (c_string);
string_face (false);
}
/* Character constants. */
/'.'|'\\\\.'/ {
string_face (true);
language_print ($0);
string_face (false);
}
/* Keywords.
Some of these keywords may also be followed by "({"
Complete list is in msdn : ms-
help://MS.VSCC.2003/MS.MSDNQTR.2003JUL.1033/csref/html/
vclrfcsharpkeywords_pg.htm
*/
/\b(a(bstract|s)|b(ool|reak|yte|ase)|c(((a(se|tch))|h
(ar|ecked)|lass)|on(st|tinue))\
|d(e(cimal|fault|legate)|o(|uble))|e(lse|num|vent|x
(plicit|tern))|f(alse|i(nal(|ly)|xed)|loat|or(|each))|g(oto|et)\
|i((n(|t(|(ernal|erface)))|mplicit)|f|s)|lo(ng|ck)|o
(verride|bject|perator|ut)|params|n
(ew|ull|amespace|ocheck)\
|p(r(ivate|otected)|ublic)|re(turn|adonly|f)\
|s(hort|t(atic|ring|ackalloc|ruct)|witch|e(t|aled)|byte|izeof)
|t(h(is|row)|r(ue|y)|ypeof)\
|u(int|long|n(checked|safe)|s(ing|hort))|v(o(id|latile)|irtual)
|while)\b/ {
keyword_face (true);
language_print ($0);
keyword_face (false);
}
}
/*
Local variables:
mode: c
End:
*/
