Re: Adding csharp syntax highlighting to nano. Thankyou.

Benno Schulenberg <[email protected]>
Newsgroups gmane.editors.nano.devel
Message-ID <[email protected]>
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
OpenPGP_signature (application/pgp-signature, 840 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.