[Top][All Lists]

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

Re: [Help-nano] C language color syntax highlighting

From: Neil Brown
Subject: Re: [Help-nano] C language color syntax highlighting
Date: Tue, 06 Jan 2004 20:22:03 +0000

All of the 'color' statements work EXCEPT for the following (cut'n'paste from the nanorc.sample file):
color red "\<[A-Z_]{2,}\>"
color green "\<(float|char|int|void|static|const|struct)\>"
color brightyellow "\<(if|while|do|else|case|switch)\>"

I have switched around the colors to make sure that all the colors can be displayed on my terminal setup.

If I change the second and third line to:
color green "(float|char|int|void|static|const|struct)"
color brightyellow "(if|while|do|else|case|switch)"

It works somewhat, but if those character strings are present inside a larger word they will be highlighted, which is obviously not desired behavior.

Basically I need to fix the two regexp expression to find the C keywords, and I need a better expression to find operator symbols (+,-,=,&,%,!,|,~,.) etc.

The \< and \> around the word, as it originally was, make the word only match if there are non-word characters both sides. Removing them as you did make the regexes stop working. When you say they didnt work (before the changes), do you mean that they didnt change to the right colour or they matched wrongly or something else?

Operator symbols can be done as simple regexes as long as you are wary of which ones are special regular expression characters. The main ones that I can remember that will be relevant are + . * ^



reply via email to

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