Adding a Scintilla based control to Xojo

In the last years we saw a lot of need for various edit controls in Xojo. The built-in TextArea is fine for a lot of people, but some need more. A couple of people extended the built-in control with various extensions, but those are always limited by what the platform can do. MacOS is quite good with NSTextView used as implementation and you see a lot of stuff via our NSTextViewMBS class to e.g. insert a picture. On Windows the RichEdit control is a bit limited, but we still got a few TextArea extensions in our plugins:

Next a few people started to write Canvas based control on their own. Like the Formatted Text Control for Xojo, which is now open source and can be used as an editor for styled text. Then recently we got notice of the Better Code Editor (BCE) Control from Garry Pettet. This may also help a few people and have it as source code in their projects and modify it.

But I looked for more and thanks to a little tip from Norman on my visit in September, I got pointed to the Scintilla project. That is am open source C++ library defining an editing component, which we can host in a plugin based Xojo control: ScintillaControlMBS
The description from their website shows what we may get in Xojo:

As well as features found in standard text editing components, Scintilla includes features especially useful when editing and debugging source code. These include support for syntax styling, error indicators, code completion and call tips. The selection margin can contain markers like those used in debuggers to indicate breakpoints and the current line. Styling choices are more open than with many editors, allowing the use of proportional fonts, bold and italics, multiple foreground and background colours and multiple fonts.

We may not get all things right into the control for the first release, but since the control seems to work fine for macOS and Windows already, I am confident we can ship this as a 1.0 with our next plugin release in January. There is still a long todo list, but we like to give interested developers a preview. Please try it in next pre-release.

Things we may do later, if possible include support for Linux. Maybe we can provide the library within the plugin instead of an external library. And we may improve the API to be more Xojo like, add printing functions, marker pictures or async loading.

This control should provide a great editor for XojoScript code in various projects. Also editing other things like SQL statements, JavaScript, JSON or HTML in your project. It has a great performance and should handle huge texts better than all the other choices.

Please try it in the next days and let us know what you think!


you can get pr2 here: MBS Xojo Plugins, version 21.6pr2

@Christian_Schmitz , I started playing with scintilla, Do you expose any methods to send basic messages directly to scintilla, mainly:

sptr_t ScintillaCocoa::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam)
Editor::StyleSetMessage(Message iMessage, uptr_t wParam, sptr_t lParam)

Also to allow multiple buffers/documents (tabs) we would need access to a whole lot more stuff and primitives.

(PS: back in the days somebody had ported Scintilla to RealBasic, I’m going to dig in my old hard drives, besides this one for windows there was one for mac.)

1 Like

While I could expose the direct function, it’s much too easy to cause crashes with passing invalid parameters.

So please let us know what functionality you need and we may add function for that.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.