Edgewall Software

Ticket #636: CSharp.py

File CSharp.py, 1.6 KB (added by cheald45@…, 8 years ago)

CSharp.py file for SilverCity syntax coloring of C# files.

Line 
1import HTMLGenerator
2import Keywords
3import Lexer
4from DispatchHandler import DispatchHandler
5from _SilverCity import find_lexer_module_by_id, PropertySet, WordList
6from ScintillaConstants import SCLEX_CPP
7import LanguageInfo
8
9class CSharpLexer(Lexer.Lexer):
10    def __init__(self, properties = PropertySet()):
11        self._properties = properties
12        self._lexer = find_lexer_module_by_id(SCLEX_CPP)
13        self._keyword_lists = [
14            WordList(Keywords.csharp_keywords),
15            WordList(), # User defined (important functions, constants, etc.)
16            WordList(Keywords.doxygen_keywords),
17            WordList(), # "Fold header keywords" - whatever that is
18            WordList(), # Global classes and typedefs
19                               ]
20           
21class CSharpHandler(DispatchHandler):
22    def __init__(self):
23        DispatchHandler.__init__(self, 'SCE_C')
24
25class CSharpHTMLGenerator(HTMLGenerator.SimpleHTMLGenerator, CSharpHandler):
26    name = 'csharp'
27    description = 'C#'
28
29    def __init__(self):
30        CSharpHandler.__init__(self)
31        HTMLGenerator.SimpleHTMLGenerator.__init__(self, 'SCE_C')
32           
33    def generate_html(self, file, buffer, lexer = CSharpLexer()):
34        self._file = file
35       
36        lexer.tokenize_by_style(buffer, self.event_handler)
37
38
39csharp_language_info = LanguageInfo.LanguageInfo(
40                'C#',
41                 ['cs'],
42                 [],
43                 [CSharpHTMLGenerator]
44            ) 
45
46LanguageInfo.register_language(csharp_language_info)