eric6/QScintilla/Lexers/LexerCPP.py

changeset 8243
cc717c2ae956
parent 7923
91e843545d9a
equal deleted inserted replaced
8242:aa713ac50c0d 8243:cc717c2ae956
4 # 4 #
5 5
6 """ 6 """
7 Module implementing a CPP lexer with some additional methods. 7 Module implementing a CPP lexer with some additional methods.
8 """ 8 """
9
10 import contextlib
9 11
10 from PyQt5.Qsci import QsciLexerCPP, QsciScintilla 12 from PyQt5.Qsci import QsciLexerCPP, QsciScintilla
11 13
12 from .SubstyledLexer import SubstyledLexer 14 from .SubstyledLexer import SubstyledLexer
13 import Preferences 15 import Preferences
110 indentStyle |= QsciScintilla.AiOpening 112 indentStyle |= QsciScintilla.AiOpening
111 if Preferences.getEditor("CppIndentClosingBrace"): 113 if Preferences.getEditor("CppIndentClosingBrace"):
112 indentStyle |= QsciScintilla.AiClosing 114 indentStyle |= QsciScintilla.AiClosing
113 self.setAutoIndentStyle(indentStyle) 115 self.setAutoIndentStyle(indentStyle)
114 self.setFoldCompact(Preferences.getEditor("AllFoldCompact")) 116 self.setFoldCompact(Preferences.getEditor("AllFoldCompact"))
115 try: 117 with contextlib.suppress(AttributeError):
116 self.setDollarsAllowed(Preferences.getEditor("CppDollarsAllowed")) 118 self.setDollarsAllowed(Preferences.getEditor("CppDollarsAllowed"))
117 except AttributeError: 119 with contextlib.suppress(AttributeError):
118 pass
119 try:
120 self.setStylePreprocessor( 120 self.setStylePreprocessor(
121 Preferences.getEditor("CppStylePreprocessor")) 121 Preferences.getEditor("CppStylePreprocessor"))
122 except AttributeError: 122 with contextlib.suppress(AttributeError):
123 pass
124 try:
125 self.setHighlightTripleQuotedStrings( 123 self.setHighlightTripleQuotedStrings(
126 Preferences.getEditor("CppHighlightTripleQuotedStrings")) 124 Preferences.getEditor("CppHighlightTripleQuotedStrings"))
127 except AttributeError: 125 with contextlib.suppress(AttributeError):
128 pass
129 try:
130 self.setHighlightHashQuotedStrings( 126 self.setHighlightHashQuotedStrings(
131 Preferences.getEditor("CppHighlightHashQuotedStrings")) 127 Preferences.getEditor("CppHighlightHashQuotedStrings"))
132 except AttributeError: 128 with contextlib.suppress(AttributeError):
133 pass
134 try:
135 self.setHighlightBackQuotedStrings( 129 self.setHighlightBackQuotedStrings(
136 Preferences.getEditor("CppHighlightBackQuotedStrings")) 130 Preferences.getEditor("CppHighlightBackQuotedStrings"))
137 except AttributeError: 131 with contextlib.suppress(AttributeError):
138 pass
139 try:
140 self.setHighlightEscapeSequences( 132 self.setHighlightEscapeSequences(
141 Preferences.getEditor("CppHighlightEscapeSequences")) 133 Preferences.getEditor("CppHighlightEscapeSequences"))
142 except AttributeError: 134 with contextlib.suppress(AttributeError):
143 pass
144 try:
145 self.setVerbatimStringEscapeSequencesAllowed( 135 self.setVerbatimStringEscapeSequencesAllowed(
146 Preferences.getEditor( 136 Preferences.getEditor(
147 "CppVerbatimStringEscapeSequencesAllowed")) 137 "CppVerbatimStringEscapeSequencesAllowed"))
148 except AttributeError:
149 pass
150 138
151 def autoCompletionWordSeparators(self): 139 def autoCompletionWordSeparators(self):
152 """ 140 """
153 Public method to return the list of separators for autocompletion. 141 Public method to return the list of separators for autocompletion.
154 142

eric ide

mercurial