nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] regarding color syntax


From: David Benbennick
Subject: Re: [Nano-devel] regarding color syntax
Date: Thu, 19 Sep 2002 11:05:15 -0400
User-agent: Mutt/1.2.5.1i

On Wed, Sep 18, 2002 at 07:50:35AM -0500, Jeff DeFouw wrote:
> For example, if you were writing a code generator you might do this:
> 
> printf("#define THIS \"is a string\" /* comment the C program prints\n");
> /* real comment */

The color code tests color regexps in the order they appear in the .nanorc
file.  So you could make that example color correctly by putting the line
for /* comments */ above the line for "strings".  Of course, then the line

/* This is a comment, "not a C string." */

will color incorrectly.  To fix this problem, you have to drastically
change the coloring code.  You must start at the top of the file, and find
the first regexp that applies, and how far it goes.  Then you advance to
the end of the match, and repeat.

Perhaps you can make this job more efficient by having Nano keep
information about what bits of the file are colored.  Then you have to
update the structure as the file changes.

Anyway, it's more important that coloring be fast than that it be perfect. 
If smooth scrolling becomes jerky when you enable color, then color isn't
usable.


On Wed, Sep 18, 2002 at 10:09:24AM -0700, David Lawrence Ramsey wrote:
> ... there are problems with two other examples.  Start with a file
> containing the following string (and use the c-file syntax when opening
> it):
> 
> \"quote\" "test"

Assuming you redo the coloring code so Jeff's examples work, you can fix
this example by saying something like

color black "\\".*\\""

Of course, this is not important since it cannot appear in a valid C file
anyway.

> For the second case, start with the following two lines:
> 
> "this is a \
> test"

You can fix this example with

color yellow start=""(\\.|[^\"])*\\( |  )*$" end="^(\\.|[^\"])*""

> (and I haven't been able to successfully make it multi-line; 'start="""
> end="""' colors a lot more than it should, for some reason).

Multi-line colors only work when the start and end expressions don't match
the same thing.  With this declaration, everything will be colored between
the first " of the file, and the last.

Attachment: pgpXzGxyfllLt.pgp
Description: PGP signature


reply via email to

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