Notepad++
Stewart Gordon
smjg_1998 at yahoo.com
Thu Aug 13 14:57:24 PDT 2009
Sergey Gromov wrote:
> Thu, 13 Aug 2009 01:40:47 +0100, Stewart Gordon wrote:
<snip>
>> It puzzles me that they didn't make this plugin powerful enough to
>> highlight the language it (and indeed the whole of Notepad++) is written
>> in. Even more so considering the sheer number of C-like languages out
>> there, which people are likely to want to use N++ to write.
>
> Well I think it's hard to create a regular expression engine flexible
> enough to allow arbitrary highlighting.
I can't see how it can be at all complicated to find the beginning and
end of a C string or character literal.
This (Posix?) regexp
"(\\.|[^\\"])*"
works as I try (though not in the tiny subset of Posix regexps that N++
understands). But that's an aside - you don't need regexps at all to
get it working at this basic level, only a rudimentary concept of escape
sequences.
> I think the best such engine
> I've seen was Colorer by Igor Russkih, and even there I wasn't able to
> express D's WYSIWYG or delimited strings. You need a real programming
> language for that.
For WYSIWYG strings, all that's needed is a generic highlighter that
supports:
- the aforementioned string escapes
- multiple types of string literals distinguished by whether they
support string escapes, and not just delimiters
TextPad's syntax highlighting engine manages 2/3 of this without any
regexps (or anything to that effect). That said, I've just found that
it can do a little bit of what remains: I can make it do `...` but not
r"..." at the expense of distinguishing string and character literals.
But token-delimited strings are indeed more complex to deal with. (How
many people do we have putting them to practical use at the moment, for
that matter?)
> ---
>
> I've just had a look at Notepad++ sources. The Scintilla they use
> contains Scintilla's built-in D lexer. I think it's just not
> configured.
Sounds as though N++'s developers overlooked to keep the configuration
files up to date as new languages have been added to Scintilla.
> SciTE uses *.properties files to configure stuff.
> Notepad++ uses XML files for the same purpose. I think it's all in
> langs.model.xml. My current idea is to take d.properties from the
> corresponding release of SciTE and try to translate it into the
> langs.model.xml format. I'll probably try it later when I have time.
>
> Of course it would be nice to replace the original D lexer with mine.
> Or, even better, to ask Scintilla developers to include my lexer into
> the official bundle. May be worth a try.
You have two good plans there.
Scintilla's definition of a plugin is confusing - normally plugins are
things that can be dynamically loaded at runtime, rather than having to
compile them in. If only....
Stewart.
More information about the Digitalmars-d
mailing list