src/eric7/Preferences/ConfigurationPages/EditorPropertiesPage.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2006 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Editor Properties configuration page.
8 """
9
10 from PyQt6.Qsci import QsciLexerPython
11
12 from .ConfigurationPageBase import ConfigurationPageBase
13 from .Ui_EditorPropertiesPage import Ui_EditorPropertiesPage
14
15 import Preferences
16
17
18 class EditorPropertiesPage(ConfigurationPageBase, Ui_EditorPropertiesPage):
19 """
20 Class implementing the Editor Properties configuration page.
21 """
22 def __init__(self, lexers):
23 """
24 Constructor
25
26 @param lexers reference to the lexers dictionary
27 """
28 super().__init__()
29 self.setupUi(self)
30 self.setObjectName("EditorPropertiesPage")
31
32 self.languages = sorted(list(lexers.keys())[:])
33
34 # set initial values
35 # All
36 self.allFoldCompactCheckBox.setChecked(
37 Preferences.getEditor("AllFoldCompact"))
38
39 # Bash
40 self.foldBashCommentCheckBox.setChecked(
41 Preferences.getEditor("BashFoldComment"))
42
43 # C++
44 self.foldCppCommentCheckBox.setChecked(
45 Preferences.getEditor("CppFoldComment"))
46 self.foldCppPreprocessorCheckBox.setChecked(
47 Preferences.getEditor("CppFoldPreprocessor"))
48 self.foldCppAtElseCheckBox.setChecked(
49 Preferences.getEditor("CppFoldAtElse"))
50 self.cppIndentOpeningBraceCheckBox.setChecked(
51 Preferences.getEditor("CppIndentOpeningBrace"))
52 self.cppIndentClosingBraceCheckBox.setChecked(
53 Preferences.getEditor("CppIndentClosingBrace"))
54 self.cppCaseInsensitiveCheckBox.setChecked(
55 Preferences.getEditor("CppCaseInsensitiveKeywords"))
56 self.cppDollarAllowedCheckBox.setChecked(
57 Preferences.getEditor("CppDollarsAllowed"))
58 self.cppStylePreprocessorCheckBox.setChecked(
59 Preferences.getEditor("CppStylePreprocessor"))
60 self.cppHighlightTripleQuotedCheckBox.setChecked(
61 Preferences.getEditor("CppHighlightTripleQuotedStrings"))
62 self.cppHighlightHashQuotedCheckBox.setChecked(
63 Preferences.getEditor("CppHighlightHashQuotedStrings"))
64 self.cppHighlightBackQuotedCheckBox.setChecked(
65 Preferences.getEditor("CppHighlightBackQuotedStrings"))
66 self.cppHighlightEsacepSequencesCheckBox.setChecked(
67 Preferences.getEditor("CppHighlightEscapeSequences"))
68 self.cppVerbatimStringEscapeAllowedCheckBox.setChecked(
69 Preferences.getEditor(
70 "CppVerbatimStringEscapeSequencesAllowed"))
71
72 # CMake
73 self.cmakeFoldAtElseCheckBox.setChecked(
74 Preferences.getEditor("CMakeFoldAtElse"))
75
76 # CoffeeScript
77 if "CoffeeScript" in self.languages:
78 self.foldCoffeeScriptCommentCheckBox.setChecked(
79 Preferences.getEditor("CoffeScriptFoldComment"))
80 self.coffeeScriptDollarAllowedCheckBox.setChecked(
81 Preferences.getEditor("CoffeeScriptDollarsAllowed"))
82 self.coffeeScriptStylePreprocessorCheckBox.setChecked(
83 Preferences.getEditor("CoffeeScriptStylePreprocessor"))
84 else:
85 self.coffeeScriptGroup.setEnabled(False)
86
87 # CSS
88 self.foldCssCommentCheckBox.setChecked(
89 Preferences.getEditor("CssFoldComment"))
90 self.cssHssCheckBox.setChecked(
91 Preferences.getEditor("CssHssSupport"))
92 self.cssLessCheckBox.setChecked(
93 Preferences.getEditor("CssLessSupport"))
94 self.cssSassyCheckBox.setChecked(
95 Preferences.getEditor("CssSassySupport"))
96
97 # D
98 self.foldDCommentCheckBox.setChecked(
99 Preferences.getEditor("DFoldComment"))
100 self.foldDAtElseCheckBox.setChecked(
101 Preferences.getEditor("DFoldAtElse"))
102 self.dIndentOpeningBraceCheckBox.setChecked(
103 Preferences.getEditor("DIndentOpeningBrace"))
104 self.dIndentClosingBraceCheckBox.setChecked(
105 Preferences.getEditor("DIndentClosingBrace"))
106
107 # Gettext
108 if "Gettext" in self.languages:
109 self.foldPoCommentCheckBox.setChecked(
110 Preferences.getEditor("PoFoldComment"))
111 else:
112 self.gettextGroup.setEnabled(False)
113
114 # HTML
115 self.foldHtmlPreprocessorCheckBox.setChecked(
116 Preferences.getEditor("HtmlFoldPreprocessor"))
117 self.htmlCaseSensitiveTagsCheckBox.setChecked(
118 Preferences.getEditor("HtmlCaseSensitiveTags"))
119 self.foldHtmlScriptCommentsCheckBox.setChecked(
120 Preferences.getEditor("HtmlFoldScriptComments"))
121 self.foldHtmlScriptHereDocsCheckBox.setChecked(
122 Preferences.getEditor("HtmlFoldScriptHeredocs"))
123 self.htmlDjangoCheckBox.setChecked(
124 Preferences.getEditor("HtmlDjangoTemplates"))
125 self.htmlMakoCheckBox.setChecked(
126 Preferences.getEditor("HtmlMakoTemplates"))
127
128 # JSON
129 if "JSON" in self.languages:
130 self.jsonHighlightCommentsCheckBox.setChecked(
131 Preferences.getEditor("JSONHightlightComments"))
132 self.jsonHighlightEscapeCheckBox.setChecked(
133 Preferences.getEditor("JSONHighlightEscapeSequences"))
134 else:
135 self.jsonGroup.setEnabled(False)
136
137 # Pascal
138 self.pascalGroup.setEnabled(True)
139 self.foldPascalCommentCheckBox.setChecked(
140 Preferences.getEditor("PascalFoldComment"))
141 self.foldPascalPreprocessorCheckBox.setChecked(
142 Preferences.getEditor("PascalFoldPreprocessor"))
143 self.pascalSmartHighlightingCheckBox.setChecked(
144 Preferences.getEditor("PascalSmartHighlighting"))
145
146 # Perl
147 self.foldPerlCommentCheckBox.setChecked(
148 Preferences.getEditor("PerlFoldComment"))
149 self.foldPerlPackagesCheckBox.setChecked(
150 Preferences.getEditor("PerlFoldPackages"))
151 self.foldPerlPODBlocksCheckBox.setChecked(
152 Preferences.getEditor("PerlFoldPODBlocks"))
153 self.foldPerlAtElseCheckBox.setChecked(
154 Preferences.getEditor("PerlFoldAtElse"))
155
156 # PostScript
157 self.postscriptGroup.setEnabled(True)
158 self.psFoldAtElseCheckBox.setChecked(
159 Preferences.getEditor("PostScriptFoldAtElse"))
160 self.psMarkTokensCheckBox.setChecked(
161 Preferences.getEditor("PostScriptTokenize"))
162 self.psLevelSpinBox.setValue(
163 Preferences.getEditor("PostScriptLevel"))
164
165 # Povray
166 self.foldPovrayCommentCheckBox.setChecked(
167 Preferences.getEditor("PovFoldComment"))
168 self.foldPovrayDirectivesCheckBox.setChecked(
169 Preferences.getEditor("PovFoldDirectives"))
170
171 # Properties
172 self.propertiesInitialSpacesCheckBox.setChecked(
173 Preferences.getEditor("PropertiesInitialSpaces"))
174
175 # Python
176 self.pythonBadIndentationComboBox.addItems([
177 self.tr("No Warning"),
178 self.tr("Inconsistent"),
179 self.tr("Tabs after Spaces"),
180 self.tr("Spaces"),
181 self.tr("Tabs"),
182 ])
183 self.pythonBadIndentationComboBox.setCurrentIndex(
184 Preferences.getEditor("PythonBadIndentation").value)
185 self.foldPythonCommentCheckBox.setChecked(
186 Preferences.getEditor("PythonFoldComment"))
187 self.foldPythonStringCheckBox.setChecked(
188 Preferences.getEditor("PythonFoldString"))
189 self.pythonAutoindentCheckBox.setChecked(
190 Preferences.getEditor("PythonAutoIndent"))
191 self.pythonV2UnicodeAllowedCheckBox.setChecked(
192 Preferences.getEditor("PythonAllowV2Unicode"))
193 self.pythonV3BinaryAllowedCheckBox.setChecked(
194 Preferences.getEditor("PythonAllowV3Binary"))
195 self.pythonV3BytesAllowedCheckBox.setChecked(
196 Preferences.getEditor("PythonAllowV3Bytes"))
197 self.foldPythonQuotesCheckBox.setChecked(
198 Preferences.getEditor("PythonFoldQuotes"))
199 self.pythonStringsOverNewlineCheckBox.setChecked(
200 Preferences.getEditor("PythonStringsOverNewLineAllowed"))
201 self.pythonHighlightSubidentifierCheckBox.setChecked(
202 Preferences.getEditor("PythonHighlightSubidentifier"))
203
204 # Ruby
205 self.foldRubyCommentCheckBox.setChecked(
206 Preferences.getEditor("RubyFoldComment"))
207
208 # SQL
209 self.foldSqlCommentCheckBox.setChecked(
210 Preferences.getEditor("SqlFoldComment"))
211 self.sqlBackslashEscapesCheckBox.setChecked(
212 Preferences.getEditor("SqlBackslashEscapes"))
213 self.sqlFoldAtElseCheckBox.setChecked(
214 Preferences.getEditor("SqlFoldAtElse"))
215 self.sqlFoldOnlyBeginCheckBox.setChecked(
216 Preferences.getEditor("SqlFoldOnlyBegin"))
217 self.sqlDottedWordsCheckBox.setChecked(
218 Preferences.getEditor("SqlDottedWords"))
219 self.sqlHashCommentsCheckBox.setChecked(
220 Preferences.getEditor("SqlHashComments"))
221 self.sqlQuotedIdentifiersCheckBox.setChecked(
222 Preferences.getEditor("SqlQuotedIdentifiers"))
223
224 # TCL
225 self.foldTclCommentCheckBox.setChecked(
226 Preferences.getEditor("TclFoldComment"))
227
228 # TeX
229 self.foldTexCommentCheckBox.setChecked(
230 Preferences.getEditor("TexFoldComment"))
231 self.texProcessCommentsCheckBox.setChecked(
232 Preferences.getEditor("TexProcessComments"))
233 self.texProcessIfCheckBox.setChecked(
234 Preferences.getEditor("TexProcessIf"))
235
236 # VHDL
237 self.vhdlFoldCommentCheckBox.setChecked(
238 Preferences.getEditor("VHDLFoldComment"))
239 self.vhdlFoldAtElseCheckBox.setChecked(
240 Preferences.getEditor("VHDLFoldAtElse"))
241 self.vhdlFoldAtBeginCheckBox.setChecked(
242 Preferences.getEditor("VHDLFoldAtBegin"))
243 self.vhdlFoldAtParenthesisCheckBox.setChecked(
244 Preferences.getEditor("VHDLFoldAtParenthesis"))
245
246 # XML
247 self.xmlSyleScriptsCheckBox.setChecked(
248 Preferences.getEditor("XMLStyleScripts"))
249
250 # YAML
251 self.yamlGroup.setEnabled(True)
252 self.foldYamlCommentCheckBox.setChecked(
253 Preferences.getEditor("YAMLFoldComment"))
254
255 def save(self):
256 """
257 Public slot to save the Editor Properties (1) configuration.
258 """
259 # All
260 Preferences.setEditor(
261 "AllFoldCompact",
262 self.allFoldCompactCheckBox.isChecked())
263
264 # Bash
265 Preferences.setEditor(
266 "BashFoldComment",
267 self.foldBashCommentCheckBox.isChecked())
268
269 # CMake
270 Preferences.setEditor(
271 "CMakeFoldAtElse",
272 self.cmakeFoldAtElseCheckBox.isChecked())
273
274 # C++
275 Preferences.setEditor(
276 "CppFoldComment",
277 self.foldCppCommentCheckBox.isChecked())
278 Preferences.setEditor(
279 "CppFoldPreprocessor",
280 self.foldCppPreprocessorCheckBox.isChecked())
281 Preferences.setEditor(
282 "CppFoldAtElse",
283 self.foldCppAtElseCheckBox.isChecked())
284 Preferences.setEditor(
285 "CppIndentOpeningBrace",
286 self.cppIndentOpeningBraceCheckBox.isChecked())
287 Preferences.setEditor(
288 "CppIndentClosingBrace",
289 self.cppIndentClosingBraceCheckBox.isChecked())
290 Preferences.setEditor(
291 "CppCaseInsensitiveKeywords",
292 self.cppCaseInsensitiveCheckBox.isChecked())
293 Preferences.setEditor(
294 "CppDollarsAllowed",
295 self.cppDollarAllowedCheckBox.isChecked())
296 Preferences.setEditor(
297 "CppStylePreprocessor",
298 self.cppStylePreprocessorCheckBox.isChecked())
299 Preferences.setEditor(
300 "CppHighlightTripleQuotedStrings",
301 self.cppHighlightTripleQuotedCheckBox.isChecked())
302 Preferences.setEditor(
303 "CppHighlightHashQuotedStrings",
304 self.cppHighlightHashQuotedCheckBox.isChecked())
305 Preferences.setEditor(
306 "CppHighlightBackQuotedStrings",
307 self.cppHighlightBackQuotedCheckBox.isChecked())
308 Preferences.setEditor(
309 "CppHighlightEscapeSequences",
310 self.cppHighlightEsacepSequencesCheckBox.isChecked())
311 Preferences.setEditor(
312 "CppVerbatimStringEscapeSequencesAllowed",
313 self.cppVerbatimStringEscapeAllowedCheckBox.isChecked())
314
315 # CMake
316 Preferences.setEditor(
317 "CMakeFoldAtElse",
318 self.cmakeFoldAtElseCheckBox.isChecked())
319
320 # CoffeeScript
321 if "CoffeeScript" in self.languages:
322 Preferences.setEditor(
323 "CoffeScriptFoldComment",
324 self.foldCoffeeScriptCommentCheckBox.isChecked())
325 Preferences.setEditor(
326 "CoffeeScriptDollarsAllowed",
327 self.coffeeScriptDollarAllowedCheckBox.isChecked())
328 Preferences.setEditor(
329 "CoffeeScriptStylePreprocessor",
330 self.coffeeScriptStylePreprocessorCheckBox.isChecked())
331
332 # CSS
333 Preferences.setEditor(
334 "CssFoldComment",
335 self.foldCssCommentCheckBox.isChecked())
336 Preferences.setEditor(
337 "CssHssSupport",
338 self.cssHssCheckBox.isChecked())
339 Preferences.setEditor(
340 "CssLessSupport",
341 self.cssLessCheckBox.isChecked())
342 Preferences.setEditor(
343 "CssSassySupport",
344 self.cssSassyCheckBox.isChecked())
345
346 # D
347 Preferences.setEditor(
348 "DFoldComment",
349 self.foldDCommentCheckBox.isChecked())
350 Preferences.setEditor(
351 "DFoldAtElse",
352 self.foldDAtElseCheckBox.isChecked())
353 Preferences.setEditor(
354 "DIndentOpeningBrace",
355 self.dIndentOpeningBraceCheckBox.isChecked())
356 Preferences.setEditor(
357 "DIndentClosingBrace",
358 self.dIndentClosingBraceCheckBox.isChecked())
359
360 # Gettext
361 if "Gettext" in self.languages:
362 Preferences.setEditor(
363 "PoFoldComment",
364 self.foldPoCommentCheckBox.isChecked())
365
366 # HTML
367 Preferences.setEditor(
368 "HtmlFoldPreprocessor",
369 self.foldHtmlPreprocessorCheckBox.isChecked())
370 Preferences.setEditor(
371 "HtmlCaseSensitiveTags",
372 self.htmlCaseSensitiveTagsCheckBox.isChecked())
373 Preferences.setEditor(
374 "HtmlFoldScriptComments",
375 self.foldHtmlScriptCommentsCheckBox.isChecked())
376 Preferences.setEditor(
377 "HtmlFoldScriptHeredocs",
378 self.foldHtmlScriptHereDocsCheckBox.isChecked())
379 Preferences.setEditor(
380 "HtmlDjangoTemplates",
381 self.htmlDjangoCheckBox.isChecked())
382 Preferences.setEditor(
383 "HtmlMakoTemplates",
384 self.htmlMakoCheckBox.isChecked())
385
386 # JSON
387 if "JSON" in self.languages:
388 Preferences.setEditor(
389 "JSONHightlightComments",
390 self.jsonHighlightCommentsCheckBox.isChecked())
391 Preferences.setEditor(
392 "JSONHighlightEscapeSequences",
393 self.jsonHighlightEscapeCheckBox.isChecked())
394
395 # Pascal
396 Preferences.setEditor(
397 "PascalFoldComment",
398 self.foldPascalCommentCheckBox.isChecked())
399 Preferences.setEditor(
400 "PascalFoldPreprocessor",
401 self.foldPascalPreprocessorCheckBox.isChecked())
402 Preferences.setEditor(
403 "PascalSmartHighlighting",
404 self.pascalSmartHighlightingCheckBox.isChecked())
405
406 # Perl
407 Preferences.setEditor(
408 "PerlFoldComment",
409 self.foldPerlCommentCheckBox.isChecked())
410 Preferences.setEditor(
411 "PerlFoldPackages",
412 self.foldPerlPackagesCheckBox.isChecked())
413 Preferences.setEditor(
414 "PerlFoldPODBlocks",
415 self.foldPerlPODBlocksCheckBox.isChecked())
416 Preferences.setEditor(
417 "PerlFoldAtElse",
418 self.foldPerlAtElseCheckBox.isChecked())
419
420 # PostScript
421 Preferences.setEditor(
422 "PostScriptFoldAtElse",
423 self.psFoldAtElseCheckBox.isChecked())
424 Preferences.setEditor(
425 "PostScriptTokenize",
426 self.psMarkTokensCheckBox.isChecked())
427 Preferences.setEditor(
428 "PostScriptLevel",
429 self.psLevelSpinBox.value())
430
431 # Povray
432 Preferences.setEditor(
433 "PovFoldComment",
434 self.foldPovrayCommentCheckBox.isChecked())
435 Preferences.setEditor(
436 "PovFoldDirectives",
437 self.foldPovrayDirectivesCheckBox.isChecked())
438
439 # Properties
440 Preferences.setEditor(
441 "PropertiesInitialSpaces",
442 self.propertiesInitialSpacesCheckBox.isChecked())
443
444 # Python
445 Preferences.setEditor(
446 "PythonFoldComment",
447 self.foldPythonCommentCheckBox.isChecked())
448 Preferences.setEditor(
449 "PythonFoldString",
450 self.foldPythonStringCheckBox.isChecked())
451 Preferences.setEditor(
452 "PythonBadIndentation",
453 QsciLexerPython.IndentationWarning(
454 self.pythonBadIndentationComboBox.currentIndex()))
455 Preferences.setEditor(
456 "PythonAutoIndent",
457 self.pythonAutoindentCheckBox.isChecked())
458 Preferences.setEditor(
459 "PythonAllowV2Unicode",
460 self.pythonV2UnicodeAllowedCheckBox.isChecked())
461 Preferences.setEditor(
462 "PythonAllowV3Binary",
463 self.pythonV3BinaryAllowedCheckBox.isChecked())
464 Preferences.setEditor(
465 "PythonAllowV3Bytes",
466 self.pythonV3BytesAllowedCheckBox.isChecked())
467 Preferences.setEditor(
468 "PythonFoldQuotes",
469 self.foldPythonQuotesCheckBox.isChecked())
470 Preferences.setEditor(
471 "PythonStringsOverNewLineAllowed",
472 self.pythonStringsOverNewlineCheckBox.isChecked())
473 Preferences.setEditor(
474 "PythonHighlightSubidentifier",
475 self.pythonHighlightSubidentifierCheckBox.isChecked())
476
477 # Ruby
478 Preferences.setEditor(
479 "RubyFoldComment",
480 self.foldRubyCommentCheckBox.isChecked())
481
482 # SQL
483 Preferences.setEditor(
484 "SqlFoldComment",
485 self.foldSqlCommentCheckBox.isChecked())
486 Preferences.setEditor(
487 "SqlBackslashEscapes",
488 self.sqlBackslashEscapesCheckBox.isChecked())
489 Preferences.setEditor(
490 "SqlFoldAtElse",
491 self.sqlFoldAtElseCheckBox.isChecked())
492 Preferences.setEditor(
493 "SqlFoldOnlyBegin",
494 self.sqlFoldOnlyBeginCheckBox.isChecked())
495 Preferences.setEditor(
496 "SqlDottedWords",
497 self.sqlDottedWordsCheckBox.isChecked())
498 Preferences.setEditor(
499 "SqlHashComments",
500 self.sqlHashCommentsCheckBox.isChecked())
501 Preferences.setEditor(
502 "SqlQuotedIdentifiers",
503 self.sqlQuotedIdentifiersCheckBox.isChecked())
504
505 # TCL
506 Preferences.setEditor(
507 "TclFoldComment",
508 self.foldTclCommentCheckBox.isChecked())
509
510 # TeX
511 Preferences.setEditor(
512 "TexFoldComment",
513 self.foldTexCommentCheckBox.isChecked())
514 Preferences.setEditor(
515 "TexProcessComments",
516 self.texProcessCommentsCheckBox.isChecked())
517 Preferences.setEditor(
518 "TexProcessIf",
519 self.texProcessIfCheckBox.isChecked())
520
521 # VHDL
522 Preferences.setEditor(
523 "VHDLFoldComment",
524 self.vhdlFoldCommentCheckBox.isChecked())
525 Preferences.setEditor(
526 "VHDLFoldAtElse",
527 self.vhdlFoldAtElseCheckBox.isChecked())
528 Preferences.setEditor(
529 "VHDLFoldAtBegin",
530 self.vhdlFoldAtBeginCheckBox.isChecked())
531 Preferences.setEditor(
532 "VHDLFoldAtParenthesis",
533 self.vhdlFoldAtParenthesisCheckBox.isChecked())
534
535 # XML
536 Preferences.setEditor(
537 "XMLStyleScripts",
538 self.xmlSyleScriptsCheckBox.isChecked())
539
540 # YAML
541 Preferences.setEditor(
542 "YAMLFoldComment",
543 self.foldYamlCommentCheckBox.isChecked())
544
545
546 def create(dlg):
547 """
548 Module function to create the configuration page.
549
550 @param dlg reference to the configuration dialog
551 @return reference to the instantiated page (ConfigurationPageBase)
552 """
553 page = EditorPropertiesPage(dlg.getLexers())
554 return page

eric ide

mercurial