March 13, 2003


This week I have been mostly working on:

User-defined syntax highlighting
This allows any user to define a simple language syntax without writing a scintilla lexer. The code basically implements a highly generic scintilla lexer in an external lexer dll. When this dll is loaded it looks for user syntax files and loads the settings from each into an instance of this generic lexer (note: this may be optimised in the future to only load on request for speed reasons).

The syntax for the languaged is defined using really simple XML, and therefore the same file can contain the elements required to make it a Scheme definition for PN2. One file defines both the syntax and the user-controllable elements such as colouring options and keywords.

Scintilla hotspot support
This allows certain styles in Scintilla to be marked as "hot spots". These spots are reactive - when the user moves the mouse over them the cursor changes to indicate that there is an associated action possible. When the user clicks (or double-clicks) a special "hot spot clicked" notification is sent to the container.

This will be used in Programmers Notepad 2 to allow clickable URLs and also in matching tools output such as compiler messages.

Header-switch for C++
When using the cpp scheme, my local copy of PN2 now allows you to switch from a header to an implementation file or vice versa using a key combination.
I haven't entirely decided yet if I've implemented it the correct way, different file types will require different special functionality and I don't want the code to get really messy.

Posted by Simon at March 13, 2003 02:07 PM

Cool stuff. Header switching would be very useful.

I don't know if the Scintilla engine or your lexers support this, but would it be possible to implement an auto-complete feature, like in MS or Borland compilers. It would require maintaining a list of all identifiers in the current document, and responding to some hotkey (e.g. Ctrl+space) to popup a list of words that begin with the already typed characters.


Posted by Patrick at Mar 14, 2003 11:53 AM

This will be implemented at some stage. It is not supported directly by scintilla, but SciTE - scintilla's demonstration editor - includes this feature.

Posted by Simon at Mar 17, 2003 6:35 PM

Will the header switching also work in case the header file is not yet open in the editor? Say I've openend file.cpp for editing, and hit the key combination; will PN2 open file.h for me?

Also, you say: "I haven't entirely decided yet if I've implemented it the correct way". Couldn't you just (let the user) define a list of extension pairs which can be switched between? Like (.h,.c), (.h,.cpp), (.h,.rc), (.pas,.dfm). Then if file.ext is open in the editor, you should look for a pair that contains .ext, and either or open activate the companion file.


Posted by Patrick at Mar 19, 2003 12:29 PM

Currently the code works with the following mappings:

.c* ->
.h or .hpp or .hh

.h* ->
.cxx or .c. or .cpp or .cc

and yes the code will open the file if it's not already open (as long as it is in the same filesystem location as the current file). In fact, in the current version of the code it always opens the other file - even if it's already open. This will be fixed with "already open" code.

I will think about allowing the user to define extensions to swap between - while this is good customisability it adds a significant amount of complexity to a very simple feature.

Posted by Simon at Mar 19, 2003 2:01 PM

Although there may not be an awful lot of languages that have file pairs, it would be very nice if PN2 would allow the user to customize them. For instance, for my PhD research I do a lot of programming in Ox (a C++ based matrix programming language), and there the pair is (.ox,.h): a rather uncommon combination that is unlikely to be hard-coded in PN2....


Posted by Patrick at Mar 19, 2003 9:09 PM

Do you have any C++ code that shows how to use the hotspots I cannot seem to get them to work in my code. I'm using the code below:

public void AddHotspot(int start,int end)
int li_EndStyle = EndStyled;

StartStyling(start, 31);
SetStyling((end - start ) + 1, 20);

StartStyling(li_EndStyle, 31);
SetStyling(0, 0);

Posted by Andreas Freeman at Sep 20, 2004 11:04 PM