Preferences/ConfigurationPages/EditorPropertiesPage.py

changeset 0
de9c2efb9d02
child 7
c679fb30c8f3
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2006 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Editor Properties configuration page.
8 """
9
10 from PyQt4.Qsci import QsciScintilla
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 class EditorPropertiesPage(ConfigurationPageBase, Ui_EditorPropertiesPage):
20 """
21 Class implementing the Editor Properties configuration page.
22 """
23 def __init__(self, lexers):
24 """
25 Constructor
26
27 @param lexers reference to the lexers dictionary
28 """
29 ConfigurationPageBase.__init__(self)
30 self.setupUi(self)
31 self.setObjectName("EditorPropertiesPage")
32
33 self.languages = sorted(lexers.keys()[:])
34
35 # set initial values
36 # All
37 self.allFoldCompactCheckBox.setChecked(\
38 Preferences.getEditor("AllFoldCompact"))
39
40 # Bash
41 self.foldBashCommentCheckBox.setChecked(\
42 Preferences.getEditor("BashFoldComment"))
43
44 # CMake
45 self.cmakeFoldAtElseCheckBox.setChecked(\
46 Preferences.getEditor("CMakeFoldAtElse"))
47
48 # C++
49 self.foldCppCommentCheckBox.setChecked(\
50 Preferences.getEditor("CppFoldComment"))
51 self.foldCppPreprocessorCheckBox.setChecked(\
52 Preferences.getEditor("CppFoldPreprocessor"))
53 self.foldCppAtElseCheckBox.setChecked(\
54 Preferences.getEditor("CppFoldAtElse"))
55 self.cppIndentOpeningBraceCheckBox.setChecked(\
56 Preferences.getEditor("CppIndentOpeningBrace"))
57 self.cppIndentClosingBraceCheckBox.setChecked(\
58 Preferences.getEditor("CppIndentClosingBrace"))
59 self.cppCaseInsensitiveCheckBox.setChecked(\
60 Preferences.getEditor("CppCaseInsensitiveKeywords"))
61 self.cppDollarAllowedCheckBox.setChecked(
62 Preferences.getEditor("CppDollarsAllowed"))
63
64 # CSS
65 self.foldCssCommentCheckBox.setChecked(\
66 Preferences.getEditor("CssFoldComment"))
67
68 # D
69 self.foldDCommentCheckBox.setChecked(\
70 Preferences.getEditor("DFoldComment"))
71 self.foldDAtElseCheckBox.setChecked(\
72 Preferences.getEditor("DFoldAtElse"))
73 self.dIndentOpeningBraceCheckBox.setChecked(\
74 Preferences.getEditor("DIndentOpeningBrace"))
75 self.dIndentClosingBraceCheckBox.setChecked(\
76 Preferences.getEditor("DIndentClosingBrace"))
77
78 # HTML
79 self.foldHtmlPreprocessorCheckBox.setChecked(\
80 Preferences.getEditor("HtmlFoldPreprocessor"))
81 self.htmlCaseSensitiveTagsCheckBox.setChecked(\
82 Preferences.getEditor("HtmlCaseSensitiveTags"))
83 self.foldHtmlScriptCommentsCheckBox.setChecked(
84 Preferences.getEditor("HtmlFoldScriptComments"))
85 self.foldHtmlScriptHereDocsCheckBox.setChecked(
86 Preferences.getEditor("HtmlFoldScriptHeredocs"))
87
88 # Pascal
89 if "Pascal" in self.languages:
90 self.pascalGroup.setEnabled(True)
91 self.foldPascalCommentCheckBox.setChecked(\
92 Preferences.getEditor("PascalFoldComment"))
93 self.foldPascalPreprocessorCheckBox.setChecked(\
94 Preferences.getEditor("PascalFoldPreprocessor"))
95 if QSCINTILLA_VERSION() >= 0x020400:
96 self.pascalSmartHighlightingCheckBox.setChecked(
97 Preferences.getEditor("PascalSmartHighlighting"))
98 else:
99 self.pascalSmartHighlightingCheckBox.setEnabled(False)
100 else:
101 self.pascalGroup.setEnabled(False)
102
103 # Perl
104 self.foldPerlCommentCheckBox.setChecked(\
105 Preferences.getEditor("PerlFoldComment"))
106 self.foldPerlPackagesCheckBox.setChecked(
107 Preferences.getEditor("PerlFoldPackages"))
108 self.foldPerlPODBlocksCheckBox.setChecked(
109 Preferences.getEditor("PerlFoldPODBlocks"))
110
111 # PostScript
112 if "PostScript" in self.languages:
113 self.postscriptGroup.setEnabled(True)
114 self.psFoldAtElseCheckBox.setChecked(\
115 Preferences.getEditor("PostScriptFoldAtElse"))
116 self.psMarkTokensCheckBox.setChecked(\
117 Preferences.getEditor("PostScriptTokenize"))
118 self.psLevelSpinBox.setValue(\
119 Preferences.getEditor("PostScriptLevel"))
120 else:
121 self.postscriptGroup.setEnabled(False)
122
123 # Povray
124 self.foldPovrayCommentCheckBox.setChecked(\
125 Preferences.getEditor("PovFoldComment"))
126 self.foldPovrayDirectivesCheckBox.setChecked(\
127 Preferences.getEditor("PovFoldDirectives"))
128
129 # Python
130 self.foldPythonCommentCheckBox.setChecked(\
131 Preferences.getEditor("PythonFoldComment"))
132 self.foldPythonStringCheckBox.setChecked(\
133 Preferences.getEditor("PythonFoldString"))
134 self.pythonBadIndentationCheckBox.setChecked(\
135 Preferences.getEditor("PythonBadIndentation"))
136 self.pythonAutoindentCheckBox.setChecked(\
137 Preferences.getEditor("PythonAutoIndent"))
138 self.pythonV2UnicodeAllowedCheckBox.setChecked(
139 Preferences.getEditor("PythonAllowV2Unicode"))
140 self.pythonV3BinaryAllowedCheckBox.setChecked(
141 Preferences.getEditor("PythonAllowV3Binary"))
142 self.pythonV3BytesAllowedCheckBox.setChecked(
143 Preferences.getEditor("PythonAllowV3Bytes"))
144
145 # SQL
146 self.foldSqlCommentCheckBox.setChecked(\
147 Preferences.getEditor("SqlFoldComment"))
148 self.sqlBackslashEscapesCheckBox.setChecked(\
149 Preferences.getEditor("SqlBackslashEscapes"))
150
151 # VHDL
152 self.vhdlFoldCommentCheckBox.setChecked(\
153 Preferences.getEditor("VHDLFoldComment"))
154 self.vhdlFoldAtElseCheckBox.setChecked(\
155 Preferences.getEditor("VHDLFoldAtElse"))
156 self.vhdlFoldAtBeginCheckBox.setChecked(\
157 Preferences.getEditor("VHDLFoldAtBegin"))
158 self.vhdlFoldAtParenthesisCheckBox.setChecked(\
159 Preferences.getEditor("VHDLFoldAtParenthesis"))
160
161 # XML
162 self.xmlSyleScriptsCheckBox.setChecked(
163 Preferences.getEditor("XMLStyleScripts"))
164
165 # YAML
166 if "YAML" in self.languages:
167 self.yamlGroup.setEnabled(True)
168 self.foldYamlCommentCheckBox.setChecked(\
169 Preferences.getEditor("YAMLFoldComment"))
170 else:
171 self.yamlGroup.setEnabled(False)
172
173 def save(self):
174 """
175 Public slot to save the Editor Properties (1) configuration.
176 """
177 # All
178 Preferences.setEditor("AllFoldCompact",
179 int(self.allFoldCompactCheckBox.isChecked()))
180
181 # Bash
182 Preferences.setEditor("BashFoldComment",
183 int(self.foldBashCommentCheckBox.isChecked()))
184
185 # CMake
186 Preferences.setEditor("CMakeFoldAtElse",
187 int(self.cmakeFoldAtElseCheckBox.isChecked()))
188
189 # C++
190 Preferences.setEditor("CppFoldComment",
191 int(self.foldCppCommentCheckBox.isChecked()))
192 Preferences.setEditor("CppFoldPreprocessor",
193 int(self.foldCppPreprocessorCheckBox.isChecked()))
194 Preferences.setEditor("CppFoldAtElse",
195 int(self.foldCppAtElseCheckBox.isChecked()))
196 Preferences.setEditor("CppIndentOpeningBrace",
197 int(self.cppIndentOpeningBraceCheckBox.isChecked()))
198 Preferences.setEditor("CppIndentClosingBrace",
199 int(self.cppIndentClosingBraceCheckBox.isChecked()))
200 Preferences.setEditor("CppCaseInsensitiveKeywords",
201 int(self.cppCaseInsensitiveCheckBox.isChecked()))
202 Preferences.setEditor("CppDollarsAllowed",
203 int(self.cppDollarAllowedCheckBox.isChecked()))
204
205 # CSS
206 Preferences.setEditor("CssFoldComment",
207 int(self.foldCssCommentCheckBox.isChecked()))
208
209 # D
210 Preferences.setEditor("DFoldComment",
211 int(self.foldDCommentCheckBox.isChecked()))
212 Preferences.setEditor("DFoldAtElse",
213 int(self.foldDAtElseCheckBox.isChecked()))
214 Preferences.setEditor("DIndentOpeningBrace",
215 int(self.dIndentOpeningBraceCheckBox.isChecked()))
216 Preferences.setEditor("DIndentClosingBrace",
217 int(self.dIndentClosingBraceCheckBox.isChecked()))
218
219 # HTML
220 Preferences.setEditor("HtmlFoldPreprocessor",
221 int(self.foldHtmlPreprocessorCheckBox.isChecked()))
222 Preferences.setEditor("HtmlCaseSensitiveTags",
223 int(self.htmlCaseSensitiveTagsCheckBox.isChecked()))
224 Preferences.setEditor("HtmlFoldScriptComments",
225 int(self.foldHtmlScriptCommentsCheckBox.isChecked()))
226 Preferences.setEditor("HtmlFoldScriptHeredocs",
227 int(self.foldHtmlScriptHereDocsCheckBox.isChecked()))
228
229 # Pascal
230 if "Pascal" in self.languages:
231 Preferences.setEditor("PascalFoldComment",
232 int(self.foldPascalCommentCheckBox.isChecked()))
233 Preferences.setEditor("PascalFoldPreprocessor",
234 int(self.foldPascalPreprocessorCheckBox.isChecked()))
235 Preferences.setEditor("PascalSmartHighlighting",
236 int(self.pascalSmartHighlightingCheckBox.isChecked()))
237
238 # Perl
239 Preferences.setEditor("PerlFoldComment",
240 int(self.foldPerlCommentCheckBox.isChecked()))
241 Preferences.setEditor("PerlFoldPackages",
242 int(self.foldPerlPackagesCheckBox.isChecked()))
243 Preferences.setEditor("PerlFoldPODBlocks",
244 int(self.foldPerlPODBlocksCheckBox.isChecked()))
245
246 # PostScript
247 if "PostScript" in self.languages:
248 Preferences.setEditor("PostScriptFoldAtElse",
249 int(self.psFoldAtElseCheckBox.isChecked()))
250 Preferences.setEditor("PostScriptTokenize",
251 int(self.psMarkTokensCheckBox.isChecked()))
252 Preferences.setEditor("PostScriptLevel",
253 self.psLevelSpinBox.value())
254
255 # Povray
256 Preferences.setEditor("PovFoldComment",
257 int(self.foldPovrayCommentCheckBox.isChecked()))
258 Preferences.setEditor("PovFoldDirectives",
259 int(self.foldPovrayDirectivesCheckBox.isChecked()))
260
261 # Python
262 Preferences.setEditor("PythonFoldComment",
263 int(self.foldPythonCommentCheckBox.isChecked()))
264 Preferences.setEditor("PythonFoldString",
265 int(self.foldPythonStringCheckBox.isChecked()))
266 Preferences.setEditor("PythonBadIndentation",
267 int(self.pythonBadIndentationCheckBox.isChecked()))
268 Preferences.setEditor("PythonAutoIndent",
269 int(self.pythonAutoindentCheckBox.isChecked()))
270 Preferences.setEditor("PythonAllowV2Unicode",
271 int(self.pythonV2UnicodeAllowedCheckBox.isChecked()))
272 Preferences.setEditor("PythonAllowV3Binary",
273 int(self.pythonV3BinaryAllowedCheckBox.isChecked()))
274 Preferences.setEditor("PythonAllowV3Bytes",
275 int(self.pythonV3BytesAllowedCheckBox.isChecked()))
276
277 # SQL
278 Preferences.setEditor("SqlFoldComment",
279 int(self.foldSqlCommentCheckBox.isChecked()))
280 Preferences.setEditor("SqlBackslashEscapes",
281 int(self.sqlBackslashEscapesCheckBox.isChecked()))
282
283 # VHDL
284 Preferences.setEditor("VHDLFoldComment",
285 int(self.vhdlFoldCommentCheckBox.isChecked()))
286 Preferences.setEditor("VHDLFoldAtElse",
287 int(self.vhdlFoldAtElseCheckBox.isChecked()))
288 Preferences.setEditor("VHDLFoldAtBegin",
289 int(self.vhdlFoldAtBeginCheckBox.isChecked()))
290 Preferences.setEditor("VHDLFoldAtParenthesis",
291 int(self.vhdlFoldAtParenthesisCheckBox.isChecked()))
292
293 # XML
294 Preferences.setEditor("XMLStyleScripts",
295 int(self.xmlSyleScriptsCheckBox.isChecked()))
296
297 # YAML
298 if "YAML" in self.languages:
299 Preferences.setEditor("YAMLFoldComment",
300 int(self.foldYamlCommentCheckBox.isChecked()))
301
302 def create(dlg):
303 """
304 Module function to create the configuration page.
305
306 @param dlg reference to the configuration dialog
307 """
308 page = EditorPropertiesPage(dlg.getLexers())
309 return page

eric ide

mercurial