eric6/Preferences/ConfigurationPages/EditorPropertiesPage.py

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

eric ide

mercurial