16 import os |
16 import os |
17 import re |
17 import re |
18 import difflib |
18 import difflib |
19 |
19 |
20 from PyQt5.QtCore import QDir, QTimer, QModelIndex, QFileInfo, pyqtSignal, \ |
20 from PyQt5.QtCore import QDir, QTimer, QModelIndex, QFileInfo, pyqtSignal, \ |
21 pyqtSlot, QCryptographicHash, QEvent, QDateTime, QRegExp, Qt |
21 pyqtSlot, QCryptographicHash, QEvent, QDateTime, QRegExp, Qt, QPoint |
22 from PyQt5.QtGui import QCursor, QPalette, QFont, QPixmap, QPainter |
22 from PyQt5.QtGui import QCursor, QPalette, QFont, QPixmap, QPainter |
23 from PyQt5.QtWidgets import QLineEdit, QActionGroup, QDialog, QInputDialog, \ |
23 from PyQt5.QtWidgets import QLineEdit, QActionGroup, QDialog, QInputDialog, \ |
24 QApplication, QMenu |
24 QApplication, QMenu |
25 from PyQt5.QtPrintSupport import QPrinter, QPrintDialog, QAbstractPrintDialog |
25 from PyQt5.QtPrintSupport import QPrinter, QPrintDialog, QAbstractPrintDialog |
26 from PyQt5.Qsci import QsciScintilla, QsciMacro, QsciStyledText |
26 from PyQt5.Qsci import QsciScintilla, QsciMacro, QsciStyledText |
88 @signal lastEditPositionAvailable() emitted when a last edit position is |
88 @signal lastEditPositionAvailable() emitted when a last edit position is |
89 available |
89 available |
90 @signal refreshed() emitted to signal a refresh of the editor contents |
90 @signal refreshed() emitted to signal a refresh of the editor contents |
91 @signal settingsRead() emitted to signal, that the settings have been read |
91 @signal settingsRead() emitted to signal, that the settings have been read |
92 and set |
92 and set |
|
93 @signal mouseDoubleClick(position, buttons) emitted to signal a mouse |
|
94 double click somewhere in the editor area |
93 """ |
95 """ |
94 modificationStatusChanged = pyqtSignal(bool, QsciScintillaCompat) |
96 modificationStatusChanged = pyqtSignal(bool, QsciScintillaCompat) |
95 undoAvailable = pyqtSignal(bool) |
97 undoAvailable = pyqtSignal(bool) |
96 redoAvailable = pyqtSignal(bool) |
98 redoAvailable = pyqtSignal(bool) |
97 cursorChanged = pyqtSignal(str, int, int) |
99 cursorChanged = pyqtSignal(str, int, int) |
112 eolChanged = pyqtSignal(str) |
114 eolChanged = pyqtSignal(str) |
113 encodingChanged = pyqtSignal(str) |
115 encodingChanged = pyqtSignal(str) |
114 lastEditPositionAvailable = pyqtSignal() |
116 lastEditPositionAvailable = pyqtSignal() |
115 refreshed = pyqtSignal() |
117 refreshed = pyqtSignal() |
116 settingsRead = pyqtSignal() |
118 settingsRead = pyqtSignal() |
|
119 mouseDoubleClick = pyqtSignal(QPoint, int) |
117 |
120 |
118 WarningCode = 1 |
121 WarningCode = 1 |
119 WarningStyle = 2 |
122 WarningStyle = 2 |
120 |
123 |
121 # Autocompletion icon definitions |
124 # Autocompletion icon definitions |
3534 Public method to initiate an update of the marker map. |
3537 Public method to initiate an update of the marker map. |
3535 """ |
3538 """ |
3536 self.__markerMap.update() |
3539 self.__markerMap.update() |
3537 |
3540 |
3538 ########################################################################### |
3541 ########################################################################### |
|
3542 ## Highlightinh marker handling methods below |
|
3543 ########################################################################### |
|
3544 |
|
3545 def setHighlight(self, startLine, startIndex, endLine, endIndex): |
|
3546 """ |
|
3547 Public method to set a text highlight. |
|
3548 |
|
3549 @param startLine line of the highlight start |
|
3550 @type int |
|
3551 @param startIndex index of the highlight start |
|
3552 @type int |
|
3553 @param endLine line of the highlight end |
|
3554 @type int |
|
3555 @param endIndex index of the highlight end |
|
3556 @type int |
|
3557 """ |
|
3558 self.setIndicator(self.highlightIndicator, startLine, startIndex, |
|
3559 endLine, endIndex) |
|
3560 |
|
3561 def clearAllHighlights(self): |
|
3562 """ |
|
3563 Public method to clear all highlights. |
|
3564 """ |
|
3565 self.clearAllIndicators(self.highlightIndicator) |
|
3566 |
|
3567 def clearHighlight(self, startLine, startIndex, endLine, endIndex): |
|
3568 """ |
|
3569 Public method to clear a text highlight. |
|
3570 |
|
3571 @param startLine line of the highlight start |
|
3572 @type int |
|
3573 @param startIndex index of the highlight start |
|
3574 @type int |
|
3575 @param endLine line of the highlight end |
|
3576 @type int |
|
3577 @param endIndex index of the highlight end |
|
3578 @type int |
|
3579 """ |
|
3580 self.clearIndicator(self.highlightIndicator, startLine, startIndex, |
|
3581 endLine, endIndex) |
|
3582 |
|
3583 ########################################################################### |
3539 ## Comment handling methods below |
3584 ## Comment handling methods below |
3540 ########################################################################### |
3585 ########################################################################### |
3541 |
3586 |
3542 def __isCommentedLine(self, line, commentStr): |
3587 def __isCommentedLine(self, line, commentStr): |
3543 """ |
3588 """ |
4383 self.indicatorDefine( |
4428 self.indicatorDefine( |
4384 self.spellingIndicator, QsciScintilla.INDIC_SQUIGGLE, |
4429 self.spellingIndicator, QsciScintilla.INDIC_SQUIGGLE, |
4385 Preferences.getEditorColour("SpellingMarkers")) |
4430 Preferences.getEditorColour("SpellingMarkers")) |
4386 self.__setSpelling() |
4431 self.__setSpelling() |
4387 |
4432 |
4388 # TODO: add support for a highlight indicator (if not possible via multiple selections) |
4433 self.highlightIndicator = QsciScintilla.INDIC_CONTAINER + 2 |
|
4434 self.indicatorDefine( |
|
4435 self.highlightIndicator, QsciScintilla.INDIC_FULLBOX, |
|
4436 Preferences.getEditorColour("HighlightMarker")) |
4389 |
4437 |
4390 self.setCursorFlashTime(QApplication.cursorFlashTime()) |
4438 self.setCursorFlashTime(QApplication.cursorFlashTime()) |
4391 |
4439 |
4392 try: |
4440 try: |
4393 if Preferences.getEditor("AnnotationsEnabled"): |
4441 if Preferences.getEditor("AnnotationsEnabled"): |
8180 @type str |
8228 @type str |
8181 @return value of requested setting |
8229 @return value of requested setting |
8182 @rtype any |
8230 @rtype any |
8183 """ |
8231 """ |
8184 return self.__getEditorConfig(option) |
8232 return self.__getEditorConfig(option) |
|
8233 |
|
8234 def mouseDoubleClickEvent(self, evt): |
|
8235 """ |
|
8236 Protected method to handle mouse double click events. |
|
8237 |
|
8238 @param evt reference to the mouse event |
|
8239 @type QMouseEvent |
|
8240 """ |
|
8241 super(Editor, self).mouseDoubleClickEvent(evt) |
|
8242 |
|
8243 self.mouseDoubleClick.emit(evt.pos(), evt.buttons()) |