Adding a new lexer to scintilla/scite (...and eventually wxPython StyledTextCtrl)

4k views Asked by At

Has anyone of you successfully added a lexer to scintilla?

I have been following the short instructions at http://www.scintilla.org/SciTELexer.html - and even discovered the secret extra instructions at http://www.scintilla.org/ScintillaDoc.html#BuildingScintilla (Changing Set of Lexers)

Everything compiles, and I can add the lexer to SciTE just fine, but my ColouriseMapfileDoc method just does not get called (a printf does not produce output). If I add the same code to e.g. the ColouriseLuaDoc lexer, everything is fine (a printf does produce output).

Specifically I have

  1. In scintilla/include/Scintilla.iface, added val SCLEX_MAPFILE=99
  2. And any lexical class IDs
  3. In the scintilla/include directory run HFacer.py and confirmed that the SciLexer.h file has changed.
  4. Created LexMapfile.cxx with a ColouriseMapfileDoc function
  5. At the end of the file associated the lexer ID and name with the function:

    LexerModule lmMapfile(SCLEX_MAPFILE, ColouriseMapfileDoc, "mapfile");

  6. Run LexGen.py to generate all the makefiles (as per the secret instructions)

  7. Created a new SciTE properties file by cloning scite/src/others.properties
  8. Set up some styles
  9. In scite/src/SciTEGlobal.properties added $(filter.conf) to the definition of open.filter.
  10. Added this language to the Language menu of SciTE,
  11. Built both Scintilla and SciTE.
  12. Grumbled and cursed.

What am I doing wrong, except maybe step 12?

3

There are 3 answers

0
relet On BEST ANSWER

In case someone reads this question in the future - you will also have to add a line import yourformat in SciTEGlobal.properties. That's the undocumented step 9b.

0
user1144598 On

In case someone reads this question in the future - you will also have to add a line import yourformat in SciTEGlobal.properties. That's the undocumented step 9b.

This step is no longer required. I compiled 3.2.2 and this was done with import *. The rest of the steps are still complete and relevant though.

0
tsingakbar On

I'm wring one lexer directly in scintilla/lexer/LexOthers.cxx as described in http://www.scintilla.org/SciTELexer.html. For scite 3.2.3 the lacking step 5b is that you need to add LINK_LEXER(lmYouLexerMod); in scintilla/src/Catalogue.cxx.