7 Module implementing an editor for simple editing tasks. |
7 Module implementing an editor for simple editing tasks. |
8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 import re |
11 import re |
|
12 import contextlib |
12 |
13 |
13 from PyQt5.QtCore import ( |
14 from PyQt5.QtCore import ( |
14 pyqtSignal, Qt, QSignalMapper, QPoint, QTimer, QFileInfo, QSize, |
15 pyqtSignal, Qt, QSignalMapper, QPoint, QTimer, QFileInfo, QSize, |
15 QCoreApplication |
16 QCoreApplication |
16 ) |
17 ) |
149 |
150 |
150 @param event the event object |
151 @param event the event object |
151 @type QFocusEvent |
152 @type QFocusEvent |
152 """ |
153 """ |
153 self.mw.editorActGrp.setEnabled(True) |
154 self.mw.editorActGrp.setEnabled(True) |
154 try: |
155 with contextlib.suppress(AttributeError): |
155 self.setCaretWidth(self.mw.caretWidth) |
156 self.setCaretWidth(self.mw.caretWidth) |
156 except AttributeError: |
|
157 pass |
|
158 |
157 |
159 self.setCursorFlashTime(QApplication.cursorFlashTime()) |
158 self.setCursorFlashTime(QApplication.cursorFlashTime()) |
160 |
159 |
161 super().focusInEvent(event) |
160 super().focusInEvent(event) |
162 |
161 |
2859 |
2858 |
2860 # set margin 2 settings |
2859 # set margin 2 settings |
2861 self.__textEdit.setMarginWidth(2, 16) |
2860 self.__textEdit.setMarginWidth(2, 16) |
2862 if Preferences.getEditor("FoldingMargin"): |
2861 if Preferences.getEditor("FoldingMargin"): |
2863 folding = Preferences.getEditor("FoldingStyle") |
2862 folding = Preferences.getEditor("FoldingStyle") |
2864 try: |
2863 with contextlib.suppress(AttributeError): |
2865 folding = QsciScintilla.FoldStyle(folding) |
2864 folding = QsciScintilla.FoldStyle(folding) |
2866 except AttributeError: |
|
2867 pass |
|
2868 self.__textEdit.setFolding(folding) |
2865 self.__textEdit.setFolding(folding) |
2869 self.__textEdit.setFoldMarginColors( |
2866 self.__textEdit.setFoldMarginColors( |
2870 Preferences.getEditorColour("FoldmarginBackground"), |
2867 Preferences.getEditorColour("FoldmarginBackground"), |
2871 Preferences.getEditorColour("FoldmarginBackground")) |
2868 Preferences.getEditorColour("FoldmarginBackground")) |
2872 self.__textEdit.setFoldMarkersColors( |
2869 self.__textEdit.setFoldMarkersColors( |