eric6/QScintilla/Lexers/LexerPython.py

changeset 8243
cc717c2ae956
parent 7923
91e843545d9a
child 8255
2fc483702cd6
equal deleted inserted replaced
8242:aa713ac50c0d 8243:cc717c2ae956
6 """ 6 """
7 Module implementing a Python lexer with some additional methods. 7 Module implementing a Python lexer with some additional methods.
8 """ 8 """
9 9
10 import re 10 import re
11 import contextlib
11 12
12 from PyQt5.Qsci import QsciLexerPython, QsciScintilla 13 from PyQt5.Qsci import QsciLexerPython, QsciScintilla
13 14
14 from .SubstyledLexer import SubstyledLexer 15 from .SubstyledLexer import SubstyledLexer
15 import Preferences 16 import Preferences
128 Preferences.getEditor("PythonBadIndentation")) 129 Preferences.getEditor("PythonBadIndentation"))
129 self.setFoldComments(Preferences.getEditor("PythonFoldComment")) 130 self.setFoldComments(Preferences.getEditor("PythonFoldComment"))
130 self.setFoldQuotes(Preferences.getEditor("PythonFoldString")) 131 self.setFoldQuotes(Preferences.getEditor("PythonFoldString"))
131 if not Preferences.getEditor("PythonAutoIndent"): 132 if not Preferences.getEditor("PythonAutoIndent"):
132 self.setAutoIndentStyle(QsciScintilla.AiMaintain) 133 self.setAutoIndentStyle(QsciScintilla.AiMaintain)
133 try: 134 with contextlib.suppress(AttributeError):
134 self.setV2UnicodeAllowed( 135 self.setV2UnicodeAllowed(
135 Preferences.getEditor("PythonAllowV2Unicode")) 136 Preferences.getEditor("PythonAllowV2Unicode"))
136 self.setV3BinaryOctalAllowed( 137 self.setV3BinaryOctalAllowed(
137 Preferences.getEditor("PythonAllowV3Binary")) 138 Preferences.getEditor("PythonAllowV3Binary"))
138 self.setV3BytesAllowed(Preferences.getEditor("PythonAllowV3Bytes")) 139 self.setV3BytesAllowed(Preferences.getEditor("PythonAllowV3Bytes"))
139 except AttributeError: 140 with contextlib.suppress(AttributeError):
140 pass
141 try:
142 self.setFoldQuotes(Preferences.getEditor("PythonFoldQuotes")) 141 self.setFoldQuotes(Preferences.getEditor("PythonFoldQuotes"))
143 self.setStringsOverNewlineAllowed( 142 self.setStringsOverNewlineAllowed(
144 Preferences.getEditor("PythonStringsOverNewLineAllowed")) 143 Preferences.getEditor("PythonStringsOverNewLineAllowed"))
145 except AttributeError: 144 with contextlib.suppress(AttributeError):
146 pass
147 try:
148 self.setHighlightSubidentifiers( 145 self.setHighlightSubidentifiers(
149 Preferences.getEditor("PythonHighlightSubidentifier")) 146 Preferences.getEditor("PythonHighlightSubidentifier"))
150 except AttributeError: 147
151 pass
152
153 def getIndentationDifference(self, line, editor): 148 def getIndentationDifference(self, line, editor):
154 """ 149 """
155 Public method to determine the difference for the new indentation. 150 Public method to determine the difference for the new indentation.
156 151
157 @param line line to perform the calculation for (integer) 152 @param line line to perform the calculation for (integer)

eric ide

mercurial