--- a/QScintilla/Editor.py Sun Apr 07 19:55:21 2019 +0200 +++ b/QScintilla/Editor.py Mon Apr 08 19:08:44 2019 +0200 @@ -18,7 +18,7 @@ import difflib from PyQt5.QtCore import QDir, QTimer, QModelIndex, QFileInfo, pyqtSignal, \ - pyqtSlot, QCryptographicHash, QEvent, QDateTime, QRegExp, Qt + pyqtSlot, QCryptographicHash, QEvent, QDateTime, QRegExp, Qt, QPoint from PyQt5.QtGui import QCursor, QPalette, QFont, QPixmap, QPainter from PyQt5.QtWidgets import QLineEdit, QActionGroup, QDialog, QInputDialog, \ QApplication, QMenu @@ -90,6 +90,8 @@ @signal refreshed() emitted to signal a refresh of the editor contents @signal settingsRead() emitted to signal, that the settings have been read and set + @signal mouseDoubleClick(position, buttons) emitted to signal a mouse + double click somewhere in the editor area """ modificationStatusChanged = pyqtSignal(bool, QsciScintillaCompat) undoAvailable = pyqtSignal(bool) @@ -114,6 +116,7 @@ lastEditPositionAvailable = pyqtSignal() refreshed = pyqtSignal() settingsRead = pyqtSignal() + mouseDoubleClick = pyqtSignal(QPoint, int) WarningCode = 1 WarningStyle = 2 @@ -3536,6 +3539,48 @@ self.__markerMap.update() ########################################################################### + ## Highlightinh marker handling methods below + ########################################################################### + + def setHighlight(self, startLine, startIndex, endLine, endIndex): + """ + Public method to set a text highlight. + + @param startLine line of the highlight start + @type int + @param startIndex index of the highlight start + @type int + @param endLine line of the highlight end + @type int + @param endIndex index of the highlight end + @type int + """ + self.setIndicator(self.highlightIndicator, startLine, startIndex, + endLine, endIndex) + + def clearAllHighlights(self): + """ + Public method to clear all highlights. + """ + self.clearAllIndicators(self.highlightIndicator) + + def clearHighlight(self, startLine, startIndex, endLine, endIndex): + """ + Public method to clear a text highlight. + + @param startLine line of the highlight start + @type int + @param startIndex index of the highlight start + @type int + @param endLine line of the highlight end + @type int + @param endIndex index of the highlight end + @type int + """ + self.clearIndicator(self.highlightIndicator, startLine, startIndex, + endLine, endIndex) + + ########################################################################### ## Comment handling methods below ########################################################################### @@ -4385,7 +4430,10 @@ Preferences.getEditorColour("SpellingMarkers")) self.__setSpelling() - # TODO: add support for a highlight indicator (if not possible via multiple selections) + self.highlightIndicator = QsciScintilla.INDIC_CONTAINER + 2 + self.indicatorDefine( + self.highlightIndicator, QsciScintilla.INDIC_FULLBOX, + Preferences.getEditorColour("HighlightMarker")) self.setCursorFlashTime(QApplication.cursorFlashTime()) @@ -8182,3 +8230,14 @@ @rtype any """ return self.__getEditorConfig(option) + + def mouseDoubleClickEvent(self, evt): + """ + Protected method to handle mouse double click events. + + @param evt reference to the mouse event + @type QMouseEvent + """ + super(Editor, self).mouseDoubleClickEvent(evt) + + self.mouseDoubleClick.emit(evt.pos(), evt.buttons())