Edgewall Software

How to add syntax-highlighting to SilverCity that exists in Scintilla

First download the SilverCity package and the latest Scintilla package.

root = where you unpacked SilverCity

lang = the language you want to add

  • Download the latest scintilla. So that you have all the latest lexers. in the SilverCity directory do:

    • tar -xvzf scintillaXXX.tgz
    • python setup.py build
    • cd root/PySilverCity/Src
    • python write_scintilla.py ../../scintilla/include ../../scintilla/include/Scintilla.iface tmp.py
    • rm ../SilverCity/ScintillaConstants.py
    • mv tmp.py ../SilverCity/ScintillaConstants.py
  • Now you change to the root/PySilverCity/SilverCity and you have to create a module for your lang

    • We are using the YAML.py as template so do 'cp YAML.py lang.py'

    • in lang.py replace every occurance of Yaml with lang

    • replace "from ScintillaConstants import SCLEX_YAML" to use your language lexer.

    • replace occurance of SCE_YAML with the equivalant for your language lexer

    • To find the equivalent constant for lang look into ScintillaConstants.py

    • change the language info at the end of file.

      • Change suffixes to what the new lang has. So that one can deduce from filename what lexer to use.
    • Open root/scintilla/src/Lex'lang' to find out how many WordList arguments are needed.

      • Search for "LexerModule" the last argument in this function is an array. See how many entries this array has. That is the number of WordList the lexer requires. For example in LexYAML the array is yamlWordListDesc and this array is the size of 1.
      • In lang.py add so many WordList in self._keywords in the langLexer.__init__ function
      • Check the CPP.py as example for a lexer for more than one WordList.
    • Add the keywords for the language in the Keywords module

    • Add the lang in the do_registration function in the module LanguageInfo

  • Fix css. So that you get colours when you view the html page.

    • Open root/PySilverCity/SilverCity/ScintillaConstants.py
      • Figure out what the language you added has for lexer keyword. The keyword is in the form SCE_xx_something. For example python has SCE_P_something.
    • Add the keywords in root/Scripts/generate_css.py see the other languages as example.
    • cd root/Scripts
    • python generate_css.py >! code.css
  • Add the lang in the root/setup.py script

    • Open root/setup.py
    • Search for py_modules variable and add Scintilla.lang to it
  • Install SilverCity with the new lang.

    • cd root
    • python setup.py install
  • Mail the changes back to the SilverCity maintainer.

In Trac

Trac 0.9

For the syntax-highlighting to take effect you have to add directives for colouring in code.css that normally located in in /usr/share/trac/htdocs/css/code.css. You also have to add the language in the …/trac/mimeviewer/silvercity.py. But see the patch in ticket #606.

Trac 0.10

See r3345.

Also, is there something that would be missing w.r.t. code.css?

Last modified 8 years ago Last modified on Jun 21, 2006 10:31:15 AM