QScintilla/Lexers/LexerPython.py

changeset 945
8cd4d08fa9f6
parent 826
2e3e2055e715
child 948
fe7b94ed01ec
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
12 from PyQt4.Qsci import QsciLexerPython, QsciScintilla 12 from PyQt4.Qsci import QsciLexerPython, QsciScintilla
13 13
14 from .Lexer import Lexer 14 from .Lexer import Lexer
15 import Preferences 15 import Preferences
16 16
17
17 class LexerPython(QsciLexerPython, Lexer): 18 class LexerPython(QsciLexerPython, Lexer):
18 """ 19 """
19 Subclass to implement some additional lexer dependant methods. 20 Subclass to implement some additional lexer dependant methods.
20 """ 21 """
21 def __init__(self, variant = "", parent = None): 22 def __init__(self, variant="", parent=None):
22 """ 23 """
23 Constructor 24 Constructor
24 25
25 @param variant name of the language variant (string) 26 @param variant name of the language variant (string)
26 @param parent parent widget of this lexer 27 @param parent parent widget of this lexer
84 last = previous_lead_spaces 85 last = previous_lead_spaces
85 if m: 86 if m:
86 last += indent_width 87 last += indent_width
87 else: 88 else:
88 # special cases, like pass (unindent) or return (also unindent) 89 # special cases, like pass (unindent) or return (also unindent)
89 m = re.search('(pass\s*(#.*)?$)|(^[^#]return)', 90 m = re.search('(pass\s*(#.*)?$)|(^[^#]return)',
90 editor.text(pline)) 91 editor.text(pline))
91 if m: 92 if m:
92 last -= indent_width 93 last -= indent_width
93 94
94 if lead_spaces % indent_width != 0 or lead_spaces == 0 \ 95 if lead_spaces % indent_width != 0 or lead_spaces == 0 \
111 """ 112 """
112 Public method to check, if a style is a comment style. 113 Public method to check, if a style is a comment style.
113 114
114 @return flag indicating a comment style (boolean) 115 @return flag indicating a comment style (boolean)
115 """ 116 """
116 return style in [QsciLexerPython.Comment, 117 return style in [QsciLexerPython.Comment,
117 QsciLexerPython.CommentBlock] 118 QsciLexerPython.CommentBlock]
118 119
119 def isStringStyle(self, style): 120 def isStringStyle(self, style):
120 """ 121 """
121 Public method to check, if a style is a string style. 122 Public method to check, if a style is a string style.
122 123
123 @return flag indicating a string style (boolean) 124 @return flag indicating a string style (boolean)
124 """ 125 """
125 return style in [QsciLexerPython.DoubleQuotedString, 126 return style in [QsciLexerPython.DoubleQuotedString,
126 QsciLexerPython.SingleQuotedString, 127 QsciLexerPython.SingleQuotedString,
127 QsciLexerPython.TripleDoubleQuotedString, 128 QsciLexerPython.TripleDoubleQuotedString,
128 QsciLexerPython.TripleSingleQuotedString, 129 QsciLexerPython.TripleSingleQuotedString,
129 QsciLexerPython.UnclosedString] 130 QsciLexerPython.UnclosedString]
130 131
131 def defaultKeywords(self, kwSet): 132 def defaultKeywords(self, kwSet):
132 """ 133 """
133 Public method to get the default keywords. 134 Public method to get the default keywords.

eric ide

mercurial