Notepad++

Sergey Gromov snake.scaly at gmail.com
Wed Aug 12 19:29:06 PDT 2009


Thu, 13 Aug 2009 01:40:47 +0100, Stewart Gordon wrote:

> Sergey Gromov wrote:
>> Wed, 12 Aug 2009 18:12:41 +0100, Stewart Gordon wrote:
> <snip>
>> Scintilla uses plugins to highlight source.  These plugins are written
>> in C++ and have almost full access to the buffer so the highlighter code
>> may be arbitrarily complex.  I actually wrote such a plugin to highlight
>> D a while back:
>> 
>> http://dsource.org/projects/scrapple/browser/trunk/scilexer
> 
> "1.  If you have SciTE 1.76 for Windows installed simply replace
> SciLexer.dll and d.properties with the supplied files.
> 
> 2.  If you wish to build Scintilla from source:"
> 
> Can it be used in Scintilla-based editors besides SciTE short of 
> acquiring the whole Scintilla source and rebuilding it?

There are two problems at least:

1.  SciLexer.dll contains *all* of the built-in lexer modules.
Replacing your DLL with another version will remove any extra lexers
which 3rd party put there, like an XML-configurable lexer in case of
Notepad++.

2.  Lexers are written in C++ and interface with the rest of Scintilla
via C++ classes.  Therefore if a field is added or removed anywhere, or
if you use a different compiler to build your DLL than that used to
build Scintilla, you'll get GPF, or worse.

Good news is that Notepad++ is on SourceForge so that the "from source"
way is at least possible.

> For the record, there's a SciLexer.dll in my Notepad++ dir, but no 
> d.properties to be found.  The SciLexer.dll reports itself as file 
> version 1.7.8.0, product version 1.78.  So maybe the question is of what 
> effect replacing it with a fork of version 1.76 would have.  (Do SciTE 
> versions correspond directly to Scintilla versions?)

Yes, SciTE versions seem to be in sync with Scintilla versions.

>> It seems like Notepad++ developers added their own highlighter plugin
>> which takes userDefineLang.xml as its configuration.  Such a
>> configurable plugin is presumably much less flexible than pure C++
>> implementation for a particular language.  It's very likely that PHP
>> highlighter is written in C++ and comes bundled with Scintilla.
> 
> 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 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.

---

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.  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.



More information about the Digitalmars-d mailing list