nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] aggressive C color highlighting


From: David Lawrence Ramsey
Subject: Re: [Nano-devel] aggressive C color highlighting
Date: Wed, 02 Aug 2006 13:38:37 -0400
User-agent: Thunderbird 1.5.0.5 (X11/20060719)

Mike Frysinger wrote:
> On Tuesday 01 August 2006 10:46, David Lawrence Ramsey wrote:
>> How about this?
>>
>> color brightblue "//.*"
>> color brightblue start="(/){1}\*" end="\*(/){1}"
>
> seems to work :)

Oh good.  I've applied it then.  Note that it's not perfect.  I've just
found out that if you create a C file with the following lines, they'll
all be highlighted when some of them shouldn't (it should be obvious
which):

//* This should be highlighted.

This should not be highlighted.

/*
This should be highlighted.
*/

If you delete the last "*/", or change the multiline comment to a
sequence of single-line comments, the highlighting works properly.  (The
old version of the comment highlighting regex does this too, so it's not
a regression.)  The only way I can think of to fix this properly is to
keep a count of matches and only highlight based on them, but (a) you
can't count using regular expressions, and (b) changing the syntax
highlighting system to use something that you can use to count is a
change more suitable for nano 3.0 :(

> the multiline string has a similar issue ... but dont know if a
> similar fix will work ... consider this:
> #define foo(x) \
>     x("hi \"mister"); \
>     x("booga");
>
> the problem being
> color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
> doesnt take into consideration \" ...

You're right that if the \" is deleted, it's colored properly, but it's
also colored properly if the \[newline] is deleted.  As far as I can
tell, the latter seems to be the real cause of the problem.  The quote
just after "mister" is treated as both the end of the "mister" string
and the beginning of a string containing an escaped character (in this
case, the backslash followed by a newline).  Unfortunately, I can't
think of a way to fix this properly that doesn't involve counting,
either...





reply via email to

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