141 EndEditToken = "END_EDIT" |
143 EndEditToken = "END_EDIT" |
142 CancelEditToken = "CANCEL_EDIT" |
144 CancelEditToken = "CANCEL_EDIT" |
143 RequestSyncToken = "REQUEST_SYNC" |
145 RequestSyncToken = "REQUEST_SYNC" |
144 SyncToken = "SYNC" |
146 SyncToken = "SYNC" |
145 |
147 |
|
148 VcsConflictMarkerLineRegExpList = ( |
|
149 r"""^<<<<<<< .*?$""", |
|
150 r"""^\|\|\|\|\|\|\| .*?$""", |
|
151 r"""^=======.*?$""", |
|
152 r"""^>>>>>>> .*?$""", |
|
153 ) |
|
154 |
146 def __init__(self, dbs, fn="", vm=None, |
155 def __init__(self, dbs, fn="", vm=None, |
147 filetype="", editor=None, tv=None): |
156 filetype="", editor=None, tv=None): |
148 """ |
157 """ |
149 Constructor |
158 Constructor |
150 |
159 |
190 # key: marker handle |
199 # key: marker handle |
191 # value: list of (warning message, warning type) |
200 # value: list of (warning message, warning type) |
192 self.notcoveredMarkers = [] # just a list of marker handles |
201 self.notcoveredMarkers = [] # just a list of marker handles |
193 self.showingNotcoveredMarkers = False |
202 self.showingNotcoveredMarkers = False |
194 |
203 |
|
204 self.lexer_ = None |
|
205 |
|
206 self.__loadEditorConfig() |
|
207 |
195 self.condHistory = [] |
208 self.condHistory = [] |
196 self.lexer_ = None |
|
197 self.__lexerReset = False |
209 self.__lexerReset = False |
198 self.completer = None |
210 self.completer = None |
199 self.encoding = Preferences.getEditor("DefaultEncoding") |
211 self.encoding = self.__getEditorConfig("DefaultEncoding") |
200 self.apiLanguage = '' |
212 self.apiLanguage = '' |
201 self.lastModified = 0 |
213 self.lastModified = 0 |
202 self.line = -1 |
214 self.line = -1 |
203 self.inReopenPrompt = False |
215 self.inReopenPrompt = False |
204 # true if the prompt to reload a changed source is present |
216 # true if the prompt to reload a changed source is present |
258 |
270 |
259 # connect signals before loading the text |
271 # connect signals before loading the text |
260 self.modificationChanged.connect(self.__modificationChanged) |
272 self.modificationChanged.connect(self.__modificationChanged) |
261 self.cursorPositionChanged.connect(self.__cursorPositionChanged) |
273 self.cursorPositionChanged.connect(self.__cursorPositionChanged) |
262 self.modificationAttempted.connect(self.__modificationReadOnly) |
274 self.modificationAttempted.connect(self.__modificationReadOnly) |
263 self.userListActivated.connect(self.__completionListSelected) |
|
264 self.SCN_CHARADDED.connect(self.__charAddedPermanent) |
|
265 |
275 |
266 # margins layout |
276 # margins layout |
267 if QSCINTILLA_VERSION() >= 0x020301: |
277 if QSCINTILLA_VERSION() >= 0x020301: |
268 self.__unifiedMargins = Preferences.getEditor("UnifiedMargins") |
278 self.__unifiedMargins = Preferences.getEditor("UnifiedMargins") |
269 else: |
279 else: |
402 self.__acWatchdog = QTimer(self) |
412 self.__acWatchdog = QTimer(self) |
403 self.__acWatchdog.setSingleShot(True) |
413 self.__acWatchdog.setSingleShot(True) |
404 self.__acWatchdog.setInterval( |
414 self.__acWatchdog.setInterval( |
405 Preferences.getEditor("AutoCompletionWatchdogTime")) |
415 Preferences.getEditor("AutoCompletionWatchdogTime")) |
406 self.__acWatchdog.timeout.connect(self.autoCompleteQScintilla) |
416 self.__acWatchdog.timeout.connect(self.autoCompleteQScintilla) |
|
417 |
|
418 self.userListActivated.connect(self.__completionListSelected) |
|
419 self.SCN_CHARADDED.connect(self.__charAddedPermanent) |
407 |
420 |
408 self.__completionListHookFunctions = {} |
421 self.__completionListHookFunctions = {} |
409 self.__completionListAsyncHookFunctions = {} |
422 self.__completionListAsyncHookFunctions = {} |
410 self.__setAutoCompletion() |
423 self.__setAutoCompletion() |
411 |
424 |
1154 self.marginMenuActs["PreviousBookmark"] = self.bmMarginMenu.addAction( |
1167 self.marginMenuActs["PreviousBookmark"] = self.bmMarginMenu.addAction( |
1155 self.tr('Previous bookmark'), self.previousBookmark) |
1168 self.tr('Previous bookmark'), self.previousBookmark) |
1156 self.marginMenuActs["ClearBookmark"] = self.bmMarginMenu.addAction( |
1169 self.marginMenuActs["ClearBookmark"] = self.bmMarginMenu.addAction( |
1157 self.tr('Clear all bookmarks'), self.clearBookmarks) |
1170 self.tr('Clear all bookmarks'), self.clearBookmarks) |
1158 |
1171 |
1159 self.bmMarginMenu.aboutToShow.connect(self.__showContextMenuMargin) |
1172 self.bmMarginMenu.aboutToShow.connect( |
|
1173 lambda: self.__showContextMenuMargin(self.bmMarginMenu)) |
1160 |
1174 |
1161 # breakpoint margin |
1175 # breakpoint margin |
1162 self.bpMarginMenu = QMenu() |
1176 self.bpMarginMenu = QMenu() |
1163 |
1177 |
1164 self.marginMenuActs["Breakpoint"] = self.bpMarginMenu.addAction( |
1178 self.marginMenuActs["Breakpoint"] = self.bpMarginMenu.addAction( |
1178 self.tr('Previous breakpoint'), |
1192 self.tr('Previous breakpoint'), |
1179 self.menuPreviousBreakpoint) |
1193 self.menuPreviousBreakpoint) |
1180 self.marginMenuActs["ClearBreakpoint"] = self.bpMarginMenu.addAction( |
1194 self.marginMenuActs["ClearBreakpoint"] = self.bpMarginMenu.addAction( |
1181 self.tr('Clear all breakpoints'), self.__menuClearBreakpoints) |
1195 self.tr('Clear all breakpoints'), self.__menuClearBreakpoints) |
1182 |
1196 |
1183 self.bpMarginMenu.aboutToShow.connect(self.__showContextMenuMargin) |
1197 self.bpMarginMenu.aboutToShow.connect( |
|
1198 lambda: self.__showContextMenuMargin(self.bpMarginMenu)) |
1184 |
1199 |
1185 # indicator margin |
1200 # indicator margin |
1186 self.indicMarginMenu = QMenu() |
1201 self.indicMarginMenu = QMenu() |
1187 |
1202 |
1188 self.marginMenuActs["GotoSyntaxError"] = \ |
1203 self.marginMenuActs["GotoSyntaxError"] = \ |
1231 self.tr('Previous change'), self.previousChange) |
1246 self.tr('Previous change'), self.previousChange) |
1232 self.marginMenuActs["ClearChangeMarkers"] = \ |
1247 self.marginMenuActs["ClearChangeMarkers"] = \ |
1233 self.indicMarginMenu.addAction( |
1248 self.indicMarginMenu.addAction( |
1234 self.tr('Clear changes'), self.__reinitOnlineChangeTrace) |
1249 self.tr('Clear changes'), self.__reinitOnlineChangeTrace) |
1235 |
1250 |
1236 self.indicMarginMenu.aboutToShow.connect(self.__showContextMenuMargin) |
1251 self.indicMarginMenu.aboutToShow.connect( |
|
1252 lambda: self.__showContextMenuMargin(self.indicMarginMenu)) |
1237 |
1253 |
1238 def __initContextMenuUnifiedMargins(self): |
1254 def __initContextMenuUnifiedMargins(self): |
1239 """ |
1255 """ |
1240 Private method used to setup the context menu for the unified margins. |
1256 Private method used to setup the context menu for the unified margins. |
1241 """ |
1257 """ |
1311 self.marginMenuActs["LMBbreakpoints"] = self.marginMenu.addAction( |
1327 self.marginMenuActs["LMBbreakpoints"] = self.marginMenu.addAction( |
1312 self.tr('LMB toggles breakpoints'), self.__lmBbreakpoints) |
1328 self.tr('LMB toggles breakpoints'), self.__lmBbreakpoints) |
1313 self.marginMenuActs["LMBbreakpoints"].setCheckable(True) |
1329 self.marginMenuActs["LMBbreakpoints"].setCheckable(True) |
1314 self.marginMenuActs["LMBbreakpoints"].setChecked(True) |
1330 self.marginMenuActs["LMBbreakpoints"].setChecked(True) |
1315 |
1331 |
1316 self.marginMenu.aboutToShow.connect(self.__showContextMenuMargin) |
1332 self.marginMenu.aboutToShow.connect( |
|
1333 lambda: self.__showContextMenuMargin(self.marginMenu)) |
1317 |
1334 |
1318 def __exportMenuTriggered(self, act): |
1335 def __exportMenuTriggered(self, act): |
1319 """ |
1336 """ |
1320 Private method to handle the selection of an export format. |
1337 Private method to handle the selection of an export format. |
1321 |
1338 |
2954 @keyparam encoding encoding to be used to read the file (string) |
2971 @keyparam encoding encoding to be used to read the file (string) |
2955 (Note: this parameter overrides encoding detection) |
2972 (Note: this parameter overrides encoding detection) |
2956 """ |
2973 """ |
2957 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
2974 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
2958 |
2975 |
|
2976 self.__loadEditorConfig(fileName=fn) |
|
2977 |
2959 try: |
2978 try: |
2960 if createIt and not os.path.exists(fn): |
2979 if createIt and not os.path.exists(fn): |
2961 f = open(fn, "w") |
2980 f = open(fn, "w") |
2962 f.close() |
2981 f.close() |
|
2982 if encoding == "": |
|
2983 encoding = self.__getEditorConfig("DefaultEncoding", |
|
2984 nodefault=True) |
2963 if encoding: |
2985 if encoding: |
2964 txt, self.encoding = Utilities.readEncodedFileWithEncoding( |
2986 txt, self.encoding = Utilities.readEncodedFileWithEncoding( |
2965 fn, encoding) |
2987 fn, encoding) |
2966 else: |
2988 else: |
2967 txt, self.encoding = Utilities.readEncodedFile(fn) |
2989 txt, self.encoding = Utilities.readEncodedFile(fn) |
2973 self.tr('<p>The file <b>{0}</b> could not be opened.</p>' |
2995 self.tr('<p>The file <b>{0}</b> could not be opened.</p>' |
2974 '<p>Reason: {1}</p>') |
2996 '<p>Reason: {1}</p>') |
2975 .format(fn, str(why))) |
2997 .format(fn, str(why))) |
2976 QApplication.restoreOverrideCursor() |
2998 QApplication.restoreOverrideCursor() |
2977 raise |
2999 raise |
2978 fileEol = self.detectEolString(txt) |
|
2979 |
3000 |
2980 modified = False |
3001 modified = False |
2981 if (not Preferences.getEditor("TabForIndentation")) and \ |
3002 |
|
3003 if (not self.__getEditorConfig("TabForIndentation")) and \ |
2982 Preferences.getEditor("ConvertTabsOnLoad") and \ |
3004 Preferences.getEditor("ConvertTabsOnLoad") and \ |
2983 not (self.lexer_ and |
3005 not (self.lexer_ and |
2984 self.lexer_.alwaysKeepTabs()): |
3006 self.lexer_.alwaysKeepTabs()): |
2985 txtExpanded = txt.expandtabs(Preferences.getEditor("TabWidth")) |
3007 txtExpanded = txt.expandtabs(self.__getEditorConfig("TabWidth")) |
2986 if txtExpanded != txt: |
3008 if txtExpanded != txt: |
2987 modified = True |
3009 modified = True |
2988 txt = txtExpanded |
3010 txt = txtExpanded |
2989 del txtExpanded |
|
2990 |
3011 |
2991 self.setText(txt) |
3012 self.setText(txt) |
2992 |
3013 |
2993 # get eric specific flags |
3014 # get eric specific flags |
2994 self.__processFlags() |
3015 self.__processFlags() |
2995 |
3016 |
2996 # perform automatic eol conversion |
3017 # perform automatic EOL conversion |
2997 if Preferences.getEditor("AutomaticEOLConversion"): |
3018 if self.__getEditorConfig("EOLMode", nodefault=True) or \ |
|
3019 Preferences.getEditor("AutomaticEOLConversion"): |
2998 self.convertEols(self.eolMode()) |
3020 self.convertEols(self.eolMode()) |
2999 else: |
3021 else: |
|
3022 fileEol = self.detectEolString(txt) |
3000 self.setEolModeByEolString(fileEol) |
3023 self.setEolModeByEolString(fileEol) |
3001 |
3024 |
3002 self.extractTasks() |
3025 self.extractTasks() |
3003 |
3026 |
3004 QApplication.restoreOverrideCursor() |
3027 QApplication.restoreOverrideCursor() |
3025 |
3048 |
3026 @param fn filename to write to (string) |
3049 @param fn filename to write to (string) |
3027 @param backup flag indicating to save a backup (boolean) |
3050 @param backup flag indicating to save a backup (boolean) |
3028 @return flag indicating success (boolean) |
3051 @return flag indicating success (boolean) |
3029 """ |
3052 """ |
3030 if Preferences.getEditor("StripTrailingWhitespace"): |
3053 config = self.__loadEditorConfigObject(fn) |
|
3054 |
|
3055 eol = self.__getEditorConfig("EOLMode", nodefault=True, config=config) |
|
3056 if eol is not None: |
|
3057 self.convertEols(eol) |
|
3058 |
|
3059 if self.__getEditorConfig("StripTrailingWhitespace", config=config): |
3031 self.__removeTrailingWhitespace() |
3060 self.__removeTrailingWhitespace() |
3032 |
3061 |
3033 txt = self.text() |
3062 txt = self.text() |
3034 # work around glitch in scintilla: always make sure, |
3063 |
3035 # that the last line is terminated properly |
3064 if self.__getEditorConfig("InsertFinalNewline", config=config): |
3036 eol = self.getLineSeparator() |
3065 eol = self.getLineSeparator() |
3037 if eol: |
3066 if eol: |
3038 if len(txt) >= len(eol): |
3067 if len(txt) >= len(eol): |
3039 if txt[-len(eol):] != eol: |
3068 if txt[-len(eol):] != eol: |
|
3069 txt += eol |
|
3070 else: |
3040 txt += eol |
3071 txt += eol |
3041 else: |
|
3042 txt += eol |
|
3043 |
3072 |
3044 # create a backup file, if the option is set |
3073 # create a backup file, if the option is set |
3045 createBackup = backup and Preferences.getEditor("CreateBackupFile") |
3074 createBackup = backup and Preferences.getEditor("CreateBackupFile") |
3046 if createBackup: |
3075 if createBackup: |
3047 if os.path.islink(fn): |
3076 if os.path.islink(fn): |
3064 # if there was an error, ignore it |
3093 # if there was an error, ignore it |
3065 pass |
3094 pass |
3066 |
3095 |
3067 # now write text to the file fn |
3096 # now write text to the file fn |
3068 try: |
3097 try: |
3069 self.encoding = Utilities.writeEncodedFile(fn, txt, self.encoding) |
3098 editorConfigEncoding = self.__getEditorConfig( |
|
3099 "DefaultEncoding", nodefault=True, config=config) |
|
3100 self.encoding = Utilities.writeEncodedFile( |
|
3101 fn, txt, self.encoding, forcedEncoding=editorConfigEncoding) |
3070 if createBackup and perms_valid: |
3102 if createBackup and perms_valid: |
3071 os.chmod(fn, permissions) |
3103 os.chmod(fn, permissions) |
3072 return True |
3104 return True |
3073 except (IOError, Utilities.CodingError, UnicodeError) as why: |
3105 except (IOError, Utilities.CodingError, UnicodeError) as why: |
3074 E5MessageBox.critical( |
3106 E5MessageBox.critical( |
3184 newName = fn |
3216 newName = fn |
3185 |
3217 |
3186 # save to project, if a project is loaded |
3218 # save to project, if a project is loaded |
3187 if self.project.isOpen() and \ |
3219 if self.project.isOpen() and \ |
3188 self.project.startswithProjectPath(fn): |
3220 self.project.startswithProjectPath(fn): |
3189 self.setEolModeByEolString(self.project.getEolString()) |
3221 editorConfigEol = self.__getEditorConfig( |
|
3222 "EOLMode", nodefault=True, |
|
3223 config=self.__loadEditorConfigObject(fn)) |
|
3224 if editorConfigEol is not None: |
|
3225 self.setEolMode(editorConfigEol) |
|
3226 else: |
|
3227 self.setEolModeByEolString(self.project.getEolString()) |
3190 self.convertEols(self.eolMode()) |
3228 self.convertEols(self.eolMode()) |
3191 else: |
3229 else: |
3192 fn = self.fileName |
3230 fn = self.fileName |
3193 |
3231 |
|
3232 self.__loadEditorConfig(fn) |
3194 self.editorAboutToBeSaved.emit(self.fileName) |
3233 self.editorAboutToBeSaved.emit(self.fileName) |
3195 if self.writeFile(fn): |
3234 if self.writeFile(fn): |
3196 if saveas: |
3235 if saveas: |
3197 self.__clearBreakpoints(self.fileName) |
3236 self.__clearBreakpoints(self.fileName) |
3198 self.fileName = fn |
3237 self.fileName = fn |
4311 linenoMargin = Preferences.getEditor("LinenoMargin") |
4352 linenoMargin = Preferences.getEditor("LinenoMargin") |
4312 if linenoMargin: |
4353 if linenoMargin: |
4313 self.setMarginWidth( |
4354 self.setMarginWidth( |
4314 self.__linenoMargin, '8' * (len(str(self.lines())) + 1)) |
4355 self.__linenoMargin, '8' * (len(str(self.lines())) + 1)) |
4315 |
4356 |
4316 def __setTextDisplay(self): |
4357 def __setTabAndIndent(self): |
4317 """ |
4358 """ |
4318 Private method to configure the text display. |
4359 Private method to set indentation size and style and tab width. |
4319 """ |
4360 """ |
4320 self.setTabWidth(Preferences.getEditor("TabWidth")) |
4361 self.setTabWidth(self.__getEditorConfig("TabWidth")) |
4321 self.setIndentationWidth(Preferences.getEditor("IndentWidth")) |
4362 self.setIndentationWidth(self.__getEditorConfig("IndentWidth")) |
4322 if self.lexer_ and self.lexer_.alwaysKeepTabs(): |
4363 if self.lexer_ and self.lexer_.alwaysKeepTabs(): |
4323 self.setIndentationsUseTabs(True) |
4364 self.setIndentationsUseTabs(True) |
4324 else: |
4365 else: |
4325 self.setIndentationsUseTabs( |
4366 self.setIndentationsUseTabs( |
4326 Preferences.getEditor("TabForIndentation")) |
4367 self.__getEditorConfig("TabForIndentation")) |
|
4368 |
|
4369 def __setTextDisplay(self): |
|
4370 """ |
|
4371 Private method to configure the text display. |
|
4372 """ |
|
4373 self.__setTabAndIndent() |
|
4374 |
4327 self.setTabIndents(Preferences.getEditor("TabIndents")) |
4375 self.setTabIndents(Preferences.getEditor("TabIndents")) |
4328 self.setBackspaceUnindents(Preferences.getEditor("TabIndents")) |
4376 self.setBackspaceUnindents(Preferences.getEditor("TabIndents")) |
4329 self.setIndentationGuides(Preferences.getEditor("IndentationGuides")) |
4377 self.setIndentationGuides(Preferences.getEditor("IndentationGuides")) |
4330 self.setIndentationGuidesBackgroundColor( |
4378 self.setIndentationGuidesBackgroundColor( |
4331 Preferences.getEditorColour("IndentationGuidesBackground")) |
4379 Preferences.getEditorColour("IndentationGuidesBackground")) |
4438 Private method to configure the eol mode of the editor. |
4486 Private method to configure the eol mode of the editor. |
4439 """ |
4487 """ |
4440 if self.fileName and \ |
4488 if self.fileName and \ |
4441 self.project.isOpen() and \ |
4489 self.project.isOpen() and \ |
4442 self.project.isProjectFile(self.fileName): |
4490 self.project.isProjectFile(self.fileName): |
4443 self.setEolModeByEolString(self.project.getEolString()) |
4491 eolMode = self.__getEditorConfig("EOLMode", nodefault=True) |
4444 else: |
4492 if eolMode is None: |
4445 eolMode = Preferences.getEditor("EOLMode") |
4493 eolStr = self.project.getEolString() |
|
4494 self.setEolModeByEolString(eolStr) |
|
4495 else: |
|
4496 self.setEolMode(eolMode) |
|
4497 else: |
|
4498 eolMode = self.__getEditorConfig("EOLMode") |
4446 eolMode = QsciScintilla.EolMode(eolMode) |
4499 eolMode = QsciScintilla.EolMode(eolMode) |
4447 self.setEolMode(eolMode) |
4500 self.setEolMode(eolMode) |
4448 self.__eolChanged() |
4501 self.__eolChanged() |
4449 |
4502 |
4450 def __setAutoCompletion(self): |
4503 def __setAutoCompletion(self): |
5323 else: |
5376 else: |
5324 self.applicationDiagramMenuAct.setEnabled(False) |
5377 self.applicationDiagramMenuAct.setEnabled(False) |
5325 |
5378 |
5326 self.showMenu.emit("Graphics", self.graphicsMenu, self) |
5379 self.showMenu.emit("Graphics", self.graphicsMenu, self) |
5327 |
5380 |
5328 def __showContextMenuMargin(self): |
5381 def __showContextMenuMargin(self, menu): |
5329 """ |
5382 """ |
5330 Private slot handling the aboutToShow signal of the margins context |
5383 Private slot handling the aboutToShow signal of the margins context |
5331 menu. |
5384 menu. |
|
5385 |
|
5386 @param menu reference to the menu to be shown |
|
5387 @type QMenu |
5332 """ |
5388 """ |
5333 if self.fileName and self.isPyFile(): |
5389 if self.fileName and self.isPyFile(): |
5334 self.marginMenuActs["Breakpoint"].setEnabled(True) |
5390 self.marginMenuActs["Breakpoint"].setEnabled(True) |
5335 self.marginMenuActs["TempBreakpoint"].setEnabled(True) |
5391 self.marginMenuActs["TempBreakpoint"].setEnabled(True) |
5336 if self.markersAtLine(self.line) & self.breakpointMask: |
5392 if self.markersAtLine(self.line) & self.breakpointMask: |
5419 else: |
5475 else: |
5420 self.marginMenuActs["PreviousChangeMarker"].setEnabled(False) |
5476 self.marginMenuActs["PreviousChangeMarker"].setEnabled(False) |
5421 self.marginMenuActs["NextChangeMarker"].setEnabled(False) |
5477 self.marginMenuActs["NextChangeMarker"].setEnabled(False) |
5422 self.marginMenuActs["ClearChangeMarkers"].setEnabled(False) |
5478 self.marginMenuActs["ClearChangeMarkers"].setEnabled(False) |
5423 |
5479 |
5424 self.showMenu.emit("Margin", self.sender(), self) |
5480 self.showMenu.emit("Margin", menu, self) |
5425 |
5481 |
5426 def __showContextMenuChecks(self): |
5482 def __showContextMenuChecks(self): |
5427 """ |
5483 """ |
5428 Private slot handling the aboutToShow signal of the checks context |
5484 Private slot handling the aboutToShow signal of the checks context |
5429 menu. |
5485 menu. |
6060 else: |
6116 else: |
6061 E5MessageBox.critical( |
6117 E5MessageBox.critical( |
6062 self, |
6118 self, |
6063 self.tr("Syntax Error"), |
6119 self.tr("Syntax Error"), |
6064 self.tr("No syntax error message available.")) |
6120 self.tr("No syntax error message available.")) |
|
6121 |
|
6122 ########################################################################### |
|
6123 ## VCS conflict marker handling methods below |
|
6124 ########################################################################### |
|
6125 |
|
6126 def getVcsConflictMarkerLines(self): |
|
6127 """ |
|
6128 Public method to determine the lines containing a VCS conflict marker. |
|
6129 |
|
6130 @return list of line numbers containg a VCS conflict marker |
|
6131 @rtype list of int |
|
6132 """ |
|
6133 conflictMarkerLines = [] |
|
6134 |
|
6135 for searchRe in Editor.VcsConflictMarkerLineRegExpList: |
|
6136 ok = self.findFirstTarget(searchRe, True, False, False, 0, 0) |
|
6137 while ok: |
|
6138 spos = self.getFoundTarget()[0] |
|
6139 line = self.lineIndexFromPosition(spos)[0] |
|
6140 conflictMarkerLines.append(line) |
|
6141 |
|
6142 ok = self.findNextTarget() |
|
6143 |
|
6144 return conflictMarkerLines |
6065 |
6145 |
6066 ########################################################################### |
6146 ########################################################################### |
6067 ## Warning handling methods below |
6147 ## Warning handling methods below |
6068 ########################################################################### |
6148 ########################################################################### |
6069 |
6149 |
7247 if self.spell: |
7327 if self.spell: |
7248 pwl, pel = self.project.getProjectDictionaries() |
7328 pwl, pel = self.project.getProjectDictionaries() |
7249 self.__setSpellingLanguage(self.project.getProjectSpellLanguage(), |
7329 self.__setSpellingLanguage(self.project.getProjectSpellLanguage(), |
7250 pwl=pwl, pel=pel) |
7330 pwl=pwl, pel=pel) |
7251 |
7331 |
7252 self.setEolModeByEolString(self.project.getEolString()) |
7332 editorConfigEol = self.__getEditorConfig("EOLMode", nodefault=True) |
|
7333 if editorConfigEol is not None: |
|
7334 self.setEolMode(editorConfigEol) |
|
7335 else: |
|
7336 self.setEolModeByEolString(self.project.getEolString()) |
7253 self.convertEols(self.eolMode()) |
7337 self.convertEols(self.eolMode()) |
7254 |
7338 |
7255 def addedToProject(self): |
7339 def addedToProject(self): |
7256 """ |
7340 """ |
7257 Public method to signal, that this editor has been added to a project. |
7341 Public method to signal, that this editor has been added to a project. |
7283 self.__projectPropertiesChanged) |
7367 self.__projectPropertiesChanged) |
7284 except TypeError: |
7368 except TypeError: |
7285 pass |
7369 pass |
7286 |
7370 |
7287 ####################################################################### |
7371 ####################################################################### |
7288 ## Spellchecking related methods |
7372 ## Spell checking related methods |
7289 ####################################################################### |
7373 ####################################################################### |
7290 |
7374 |
7291 def __setSpellingLanguage(self, language, pwl="", pel=""): |
7375 def __setSpellingLanguage(self, language, pwl="", pel=""): |
7292 """ |
7376 """ |
7293 Private slot to set the spell checking language. |
7377 Private slot to set the spell checking language. |
8014 """ |
8098 """ |
8015 Private slot to execute the selected text in the shell window. |
8099 Private slot to execute the selected text in the shell window. |
8016 """ |
8100 """ |
8017 txt = self.selectedText() |
8101 txt = self.selectedText() |
8018 e5App().getObject("Shell").executeLines(txt) |
8102 e5App().getObject("Shell").executeLines(txt) |
|
8103 |
|
8104 ####################################################################### |
|
8105 ## Methods implementing the interface to EditorConfig |
|
8106 ####################################################################### |
|
8107 |
|
8108 def __loadEditorConfig(self, fileName=""): |
|
8109 """ |
|
8110 Private method to load the EditorConfig properties. |
|
8111 |
|
8112 @param fileName name of the file |
|
8113 @type str |
|
8114 """ |
|
8115 if not fileName: |
|
8116 fileName = self.fileName |
|
8117 |
|
8118 self.__editorConfig = self.__loadEditorConfigObject(fileName) |
|
8119 |
|
8120 if fileName: |
|
8121 self.__setTabAndIndent() |
|
8122 |
|
8123 def __loadEditorConfigObject(self, fileName): |
|
8124 """ |
|
8125 Private method to load the EditorConfig properties for the given |
|
8126 file name. |
|
8127 |
|
8128 @param fileName name of the file |
|
8129 @type str |
|
8130 @return EditorConfig dictionary |
|
8131 @rtype dict |
|
8132 """ |
|
8133 editorConfig = {} |
|
8134 |
|
8135 if fileName: |
|
8136 try: |
|
8137 editorConfig = editorconfig.get_properties(fileName) |
|
8138 except editorconfig.EditorConfigError: |
|
8139 E5MessageBox.warning( |
|
8140 self, |
|
8141 self.tr("EditorConfig Properties"), |
|
8142 self.tr("""<p>The EditorConfig properties for file""" |
|
8143 """ <b>{0}</b> could not be loaded.</p>""") |
|
8144 .format(fileName)) |
|
8145 |
|
8146 return editorConfig |
|
8147 |
|
8148 def __getEditorConfig(self, option, nodefault=False, config=None): |
|
8149 """ |
|
8150 Private method to get the requested option via EditorConfig. |
|
8151 |
|
8152 If there is no EditorConfig defined, the equivalent built-in option |
|
8153 will be used (Preferences.getEditor(). The option must be given as the |
|
8154 Preferences option key. The mapping to the EditorConfig option name |
|
8155 will be done within this method. |
|
8156 |
|
8157 @param option Preferences option key |
|
8158 @type str |
|
8159 @param nodefault flag indicating to not get the default value from |
|
8160 Preferences but return None instead |
|
8161 @type bool |
|
8162 @param config reference to an EditorConfig object or None |
|
8163 @type dict |
|
8164 @return value of requested setting or None if nothing was found and |
|
8165 nodefault parameter was True |
|
8166 @rtype any |
|
8167 """ |
|
8168 if config is None: |
|
8169 config = self.__editorConfig |
|
8170 |
|
8171 if not config: |
|
8172 if nodefault: |
|
8173 return None |
|
8174 else: |
|
8175 return Preferences.getEditor(option) |
|
8176 |
|
8177 try: |
|
8178 if option == "EOLMode": |
|
8179 value = config["end_of_line"] |
|
8180 if value == "lf": |
|
8181 value = QsciScintilla.EolUnix |
|
8182 elif value == "crlf": |
|
8183 value = QsciScintilla.EolWindows |
|
8184 elif value == "cr": |
|
8185 value = QsciScintilla.EolMac |
|
8186 else: |
|
8187 value = None |
|
8188 elif option == "DefaultEncoding": |
|
8189 value = config["charset"] |
|
8190 elif option == "InsertFinalNewline": |
|
8191 value = Utilities.toBool(config["insert_final_newline"]) |
|
8192 elif option == "StripTrailingWhitespace": |
|
8193 value = Utilities.toBool(config["trim_trailing_whitespace"]) |
|
8194 elif option == "TabWidth": |
|
8195 value = int(config["tab_width"]) |
|
8196 elif option == "IndentWidth": |
|
8197 value = config["indent_size"] |
|
8198 if value == "tab": |
|
8199 value = self.__getEditorConfig("TabWidth", config=config) |
|
8200 else: |
|
8201 value = int(value) |
|
8202 elif option == "TabForIndentation": |
|
8203 value = config["indent_style"] == "tab" |
|
8204 except KeyError: |
|
8205 value = None |
|
8206 |
|
8207 if value is None and not nodefault: |
|
8208 # use Preferences in case of error |
|
8209 value = Preferences.getEditor(option) |
|
8210 |
|
8211 return value |
|
8212 |
|
8213 def getEditorConfig(self, option): |
|
8214 """ |
|
8215 Public method to get the requested option via EditorConfig. |
|
8216 |
|
8217 @param option Preferences option key |
|
8218 @type str |
|
8219 @return value of requested setting |
|
8220 @rtype any |
|
8221 """ |
|
8222 return self.__getEditorConfig(option) |