15 |
15 |
16 class LexerPOV(Lexer, QsciLexerPOV): |
16 class LexerPOV(Lexer, QsciLexerPOV): |
17 """ |
17 """ |
18 Subclass to implement some additional lexer dependant methods. |
18 Subclass to implement some additional lexer dependant methods. |
19 """ |
19 """ |
|
20 |
20 def __init__(self, parent=None): |
21 def __init__(self, parent=None): |
21 """ |
22 """ |
22 Constructor |
23 Constructor |
23 |
24 |
24 @param parent parent widget of this lexer |
25 @param parent parent widget of this lexer |
25 """ |
26 """ |
26 QsciLexerPOV.__init__(self, parent) |
27 QsciLexerPOV.__init__(self, parent) |
27 Lexer.__init__(self) |
28 Lexer.__init__(self) |
28 |
29 |
29 self.commentString = "//" |
30 self.commentString = "//" |
30 self.streamCommentString = { |
31 self.streamCommentString = {"start": "/* ", "end": " */"} |
31 'start': '/* ', |
32 self.boxCommentString = {"start": "/* ", "middle": " * ", "end": " */"} |
32 'end': ' */' |
33 |
33 } |
|
34 self.boxCommentString = { |
|
35 'start': '/* ', |
|
36 'middle': ' * ', |
|
37 'end': ' */' |
|
38 } |
|
39 |
|
40 self.keywordSetDescriptions = [ |
34 self.keywordSetDescriptions = [ |
41 self.tr("Language directives"), |
35 self.tr("Language directives"), |
42 self.tr("Objects & CSG & Appearance"), |
36 self.tr("Objects & CSG & Appearance"), |
43 self.tr("Types & Modifiers & Items"), |
37 self.tr("Types & Modifiers & Items"), |
44 self.tr("Predefined Identifiers"), |
38 self.tr("Predefined Identifiers"), |
45 self.tr("Predefined Functions"), |
39 self.tr("Predefined Functions"), |
46 self.tr("User defined 1"), |
40 self.tr("User defined 1"), |
47 self.tr("User defined 2"), |
41 self.tr("User defined 2"), |
48 self.tr("User defined 3"), |
42 self.tr("User defined 3"), |
49 ] |
43 ] |
50 |
44 |
51 def initProperties(self): |
45 def initProperties(self): |
52 """ |
46 """ |
53 Public slot to initialize the properties. |
47 Public slot to initialize the properties. |
54 """ |
48 """ |
55 self.setFoldComments(Preferences.getEditor("PovFoldComment")) |
49 self.setFoldComments(Preferences.getEditor("PovFoldComment")) |
56 self.setFoldDirectives(Preferences.getEditor("PovFoldDirectives")) |
50 self.setFoldDirectives(Preferences.getEditor("PovFoldDirectives")) |
57 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) |
51 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) |
58 |
52 |
59 def isCommentStyle(self, style): |
53 def isCommentStyle(self, style): |
60 """ |
54 """ |
61 Public method to check, if a style is a comment style. |
55 Public method to check, if a style is a comment style. |
62 |
56 |
63 @param style style to check (integer) |
57 @param style style to check (integer) |
64 @return flag indicating a comment style (boolean) |
58 @return flag indicating a comment style (boolean) |
65 """ |
59 """ |
66 return style in [QsciLexerPOV.Comment, |
60 return style in [QsciLexerPOV.Comment, QsciLexerPOV.CommentLine] |
67 QsciLexerPOV.CommentLine] |
61 |
68 |
|
69 def isStringStyle(self, style): |
62 def isStringStyle(self, style): |
70 """ |
63 """ |
71 Public method to check, if a style is a string style. |
64 Public method to check, if a style is a string style. |
72 |
65 |
73 @param style style to check (integer) |
66 @param style style to check (integer) |
74 @return flag indicating a string style (boolean) |
67 @return flag indicating a string style (boolean) |
75 """ |
68 """ |
76 return style in [QsciLexerPOV.String, |
69 return style in [QsciLexerPOV.String, QsciLexerPOV.UnclosedString] |
77 QsciLexerPOV.UnclosedString] |
70 |
78 |
|
79 def defaultKeywords(self, kwSet): |
71 def defaultKeywords(self, kwSet): |
80 """ |
72 """ |
81 Public method to get the default keywords. |
73 Public method to get the default keywords. |
82 |
74 |
83 @param kwSet number of the keyword set (integer) |
75 @param kwSet number of the keyword set (integer) |
84 @return string giving the keywords (string) or None |
76 @return string giving the keywords (string) or None |
85 """ |
77 """ |
86 return QsciLexerPOV.keywords(self, kwSet) |
78 return QsciLexerPOV.keywords(self, kwSet) |