The GoScintilla wrapper...
Scintilla is a freely available open-source code editing component (not a COM component) created by Neil Hodgson and is used by many editors including the Purebasic IDE (and JaPBe).
Scintilla exposes a 'flat' c-style API which is not particularly easy to use when wishing to make use of some of the more advanced facilities on offer. For example, using syntax styling requires that we create our own 'lexer' (or make use of an existing one) which can be quite tricky and involved. Code-folding is also best handled within a dedicated lexer.
GoScintilla is a small Purebasic source-code utility which wraps a lot of the
Scintilla API in order to make it easier to use the Scintilla control within our
applications to give our programs source code editing facilities. It comes with a powerful little lexer which is easily configured
to give us syntax styling and/or code folding as appropriate for some
programming/scripting language or other. With a few lines
of Purebasic code we can have a fully configured Scintilla control up and
running in no time and without the need to code our own lexer.
Main features of GoScintilla:
- Fully open source and fully cross-platform (not sure how much of this will work on MacOSX ?)
- Works with or without the Purebasic Unicode compiler switch set.
- Functions for working with the basic content of Scintilla controls; adding lines of text, changing lines of text, altering colors and so on.
- A fully configurable styling lexer which allows us to quickly add syntax styling and/or code folding to our controls. (See below for more details.)
Main features of the GoScintilla lexer :
- Set up to 31 individual styles (fonts + colors).
- Specify lists of keywords along with the style to use (one of the aforementioned 31 possible styles).
- Specify a list of 'separators' which the lexer uses to split the text into separate 'entities'.
- Specify different types of delimiter (a special class of separator). These offer a simple means of extending the lexer to 'shortcut' the identification of more complex lexical forms.
- Specify keywords which create (or terminate) fold points. Use multiple open and/or close fold points on a single line.
- Supplement GoScintilla's line-styling function (part of the lexer) with one of your own in order to apply styles to lexical entities which the default lexer will not recognise.
The download includes all of the GoScintilla source-code, a fully detailed .chm user manual and a
couple of
demo programs.
GoScintilla 2
For Purebasic 4.5 onwards there is now GoScintilla 2 which represents a major upgrade to the original GoScintilla library.
Enhanced features offered by GoScintilla 2 :
- Automatic code-completion.
- Automatic nested call-tips (code-tips).
- Bookmarks.
- Auto-indentation.
- Ability to copy the styling lexer from one control to another.
- Numerous minor improvements.
Quite an improvement!
The down-side is that GoScintilla 2 will break some existing code
designed to work with the original GoScintilla library. Nothing
major mind!
Enjoy!