17 |
17 |
18 class LexerTeX(Lexer, QsciLexerTeX): |
18 class LexerTeX(Lexer, QsciLexerTeX): |
19 """ |
19 """ |
20 Subclass to implement some additional lexer dependant methods. |
20 Subclass to implement some additional lexer dependant methods. |
21 """ |
21 """ |
|
22 |
22 def __init__(self, parent=None): |
23 def __init__(self, parent=None): |
23 """ |
24 """ |
24 Constructor |
25 Constructor |
25 |
26 |
26 @param parent parent widget of this lexer |
27 @param parent parent widget of this lexer |
27 """ |
28 """ |
28 QsciLexerTeX.__init__(self, parent) |
29 QsciLexerTeX.__init__(self, parent) |
29 Lexer.__init__(self) |
30 Lexer.__init__(self) |
30 |
31 |
31 self.commentString = "%" |
32 self.commentString = "%" |
32 |
33 |
33 self.keywordSetDescriptions = [ |
34 self.keywordSetDescriptions = [ |
34 self.tr("TeX, eTeX, pdfTeX, Omega"), |
35 self.tr("TeX, eTeX, pdfTeX, Omega"), |
35 self.tr("ConTeXt Dutch"), |
36 self.tr("ConTeXt Dutch"), |
36 self.tr("ConTeXt English"), |
37 self.tr("ConTeXt English"), |
37 self.tr("ConTeXt German"), |
38 self.tr("ConTeXt German"), |
38 self.tr("ConTeXt Czech"), |
39 self.tr("ConTeXt Czech"), |
39 self.tr("ConTeXt Italian"), |
40 self.tr("ConTeXt Italian"), |
40 self.tr("ConTeXt Romanian"), |
41 self.tr("ConTeXt Romanian"), |
41 self.tr("LaTeX"), |
42 self.tr("LaTeX"), |
42 ] |
43 ] |
43 |
44 |
44 def initProperties(self): |
45 def initProperties(self): |
45 """ |
46 """ |
46 Public slot to initialize the properties. |
47 Public slot to initialize the properties. |
47 """ |
48 """ |
48 with contextlib.suppress(AttributeError): |
49 with contextlib.suppress(AttributeError): |
49 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) |
50 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) |
50 self.setFoldComments(Preferences.getEditor("TexFoldComment")) |
51 self.setFoldComments(Preferences.getEditor("TexFoldComment")) |
51 self.setProcessComments( |
52 self.setProcessComments(Preferences.getEditor("TexProcessComments")) |
52 Preferences.getEditor("TexProcessComments")) |
|
53 self.setProcessIf(Preferences.getEditor("TexProcessIf")) |
53 self.setProcessIf(Preferences.getEditor("TexProcessIf")) |
54 |
54 |
55 def isCommentStyle(self, style): |
55 def isCommentStyle(self, style): |
56 """ |
56 """ |
57 Public method to check, if a style is a comment style. |
57 Public method to check, if a style is a comment style. |
58 |
58 |
59 @param style style to check (integer) |
59 @param style style to check (integer) |
60 @return flag indicating a comment style (boolean) |
60 @return flag indicating a comment style (boolean) |
61 """ |
61 """ |
62 return False |
62 return False |
63 |
63 |
64 def isStringStyle(self, style): |
64 def isStringStyle(self, style): |
65 """ |
65 """ |
66 Public method to check, if a style is a string style. |
66 Public method to check, if a style is a string style. |
67 |
67 |
68 @param style style to check (integer) |
68 @param style style to check (integer) |
69 @return flag indicating a string style (boolean) |
69 @return flag indicating a string style (boolean) |
70 """ |
70 """ |
71 return style in [QsciLexerTeX.Text] |
71 return style in [QsciLexerTeX.Text] |
72 |
72 |
73 def defaultKeywords(self, kwSet): |
73 def defaultKeywords(self, kwSet): |
74 """ |
74 """ |
75 Public method to get the default keywords. |
75 Public method to get the default keywords. |
76 |
76 |
77 @param kwSet number of the keyword set (integer) |
77 @param kwSet number of the keyword set (integer) |
78 @return string giving the keywords (string) or None |
78 @return string giving the keywords (string) or None |
79 """ |
79 """ |
80 texKeywords = ( |
80 texKeywords = ( |
81 "above abovedisplayshortskip abovedisplayskip " |
81 "above abovedisplayshortskip abovedisplayskip " |