eric7/Preferences/ConfigurationPages/EditorPropertiesPage.py

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

eric ide

mercurial