Version 3 (modified by 20 years ago) ( diff ) | ,
---|
How to add syntax-highlightning to SilverCity that exists in Scintilla
First download the !SilverCity package and the latest Scintialla 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 have to create a module lang.py
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 langue info at the.
- 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' see how many WordList arguments are to the function.
- In lang.py add so many WordList in self._keywords in the langLexer.__init__ function
- Check the CPP.py as example.
Add the keywords for the language in the Keywords module
Add the lang in 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 keywords, that start with SCE_xx. 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
- Open root/PySilverCity/SilverCity/ScintillaConstants.py
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
In Trac
For the syntax-highlightning 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 se the patch in ticket #606