nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding csharp syntax highlighting to nano. Thankyou.


From: Benno Schulenberg
Subject: Re: Adding csharp syntax highlighting to nano. Thankyou.
Date: Sun, 4 Sep 2022 09:33:45 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

Op 31-08-2022 om 20:30 schreef collins muturi:
> +## Syntax highlighting for Csharp.
> +
> +syntax cs "\.cs$"

CSharp files are not normally found on a GNU/Linux system:

$ locate -r '\.cs$'
/usr/share/aptitude/README.cs
/usr/share/aptitude/aptitude-defaults.cs
/usr/share/emacs/25.2/etc/tutorials/TUTORIAL.cs
/usr/share/geany/filedefs/filetypes.cs
/usr/share/groff/1.22.3/tmac/hyphen.cs
/usr/share/groff/1.22.3/tmac/hyphenex.cs
/usr/share/mc/hints/mc.hint.cs
/usr/share/vim/vim80/tutor/tutor.cs

None of those files are CSharp files, and would get colored wrong
if your syntax were included with nano.

If you wish your syntax to be on https://nano-editor.org/more-syntaxes/,
then please add an author line and a license line.

> +magic "Csharp "
> +comment "//"
> +
> +color italic,green 
> "\<(bool|byte|char|double|float|int|long|new|short|string|this|transient|uint|void)\>"
> +color bold,red 
> "\<(break|case|catch|continue|default|do|else|finally|for|foreach|if|return|switch|throw|try|while)\>"
> +color cyan "\<(abstract|class|as|enum|final|is|interface|struct|using)\>"

It would be good to add a comment before each regex to explain what is being
colored by it -- like is done in most syntaxes included with nano.

> +color bold,white 
> "\<(namespace|private|protected|public|static|throws|volatile|virtual)\>"

Using 'white' assumes that the terminal has a dark background, which is not
a good idea for a generally useful syntax.

> +color orange ""[^"]*""

What if a string contains an escaped double quote (\")?

> +color bold,orange "\<(true|false|null)\>"
> +color italic,yellow "//.*"
> +color italic,yellow start="/\*" end="\*/"
> +color brightgreen start="/\*\*" end="\*/"

Benno

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]