Scintilla version 5 moves the lexing code out of Scintilla into the separate Lexilla module. This can be linked as a static or a dynamic library. I chose to use a dynamic library.
My initial state was that I have a Visual Studio 2019 Windows application that used Scintilla in a DLL to edit various text files with a couple of proprietary LexerModule lexers. I had modified the Scintilla 4 catalogue.cxx source file to exclude all the supplied lexers and added my two LexerModule lexers. I have Scintilla implemented as a Windows control with all the SCI_... messages converted to member functions.
The good news is that there are no changes to make to the LexerModule code. However, there is some reorganisation needed and minor changes to the code that sets up the lexer.
I migrated my code in two stages.
1) Add the Lexilla module to the existing Scintilla 4 code and use the lexers in
the Lexilla module to replace the ones in Scintilla 4.
2) Replace the Scintilla 4 code with Scintilla 5.
I did it this way as the replacement of Scintilla 4 with 5 felt a bit drastic for source control to do in one step and this let me add Lexilla while maintaining a working program.
Stage 1
=======
a) I added a new C++ DLL project to the application solution and added all the
files in the Lexilla src and lexlib folders, and set src\lexilla.def in the
Linker settings as the Module Definition File. I excluded all the supplied
Lexer files (but you would, of course, include any you needed). I added my
lexers to the project. I modified Lexilla.cxx to remove the supplied lexers
and add my lexers. This sufficed to generate a Lexilla.dll that included my
lexers.
b) I modified my application to include the LexillaAccess.cpp/h files from the
Lexilla\access folder.
c) I modified my Scintilla initialisation code to call:
Lexilla::Load("path to Lexilla.dll");
to generate the list of lexers. At this point I could build the application
and see the two lexers get added in Lexilla::Load().
d) I modified my application code that set the lexer for each Scintilla instance.
I implement Scintilla as a Windows Control, so my setup code changed from:
CSciCtrl rCtrl; // This is my Windows control that wraps Scintilla
...
rCtrl.SetLexerLanguage("abc"); // Version 4 set lexer for language "abc"
to:
auto* pLexer = Lexilla::MakeLexer("abc"); // Create an ILexer5 object
rCtrl.SetILexer(pLexer); // Pass ownership to the control
SetLexerLanguage() is a wrapper for SCI_SETLEXERLANGUAGE and SetILexer() is a
wrapper for SCI_SETILEXER.
Having done this, my code ran as before using Scintilla 4, but with the lexers
supplied by Lexilla, not Scintilla.
Stage 2
=======
I deleted all the files from the Scintilla 4 project and replaced them with the Scintilla 5 files.
Thats it. It was much easier than I expected. The only problem I hit was on my first attempt I did not add the Lexilla.def file to the project, which did not allow the DLL loading code to 'see' the functions exported from the Lexilla DLL.