--- a/eric6/QScintilla/QsciScintillaCompat.py Mon Sep 02 18:50:38 2019 +0200 +++ b/eric6/QScintilla/QsciScintillaCompat.py Mon Sep 02 18:51:38 2019 +0200 @@ -46,15 +46,7 @@ UserSeparator = '\x04' - if QSCINTILLA_VERSION() < 0x020600: - IndicatorStyleMax = QsciScintilla.INDIC_ROUNDBOX - elif QSCINTILLA_VERSION() < 0x020700: - IndicatorStyleMax = QsciScintilla.INDIC_DOTBOX - elif QSCINTILLA_VERSION() < 0x020800: - IndicatorStyleMax = QsciScintilla.INDIC_SQUIGGLEPIXMAP - elif QSCINTILLA_VERSION() < 0x020900: - IndicatorStyleMax = QsciScintilla.INDIC_COMPOSITIONTHICK - elif QSCINTILLA_VERSION() < 0x020A00: + if QSCINTILLA_VERSION() < 0x020A00: IndicatorStyleMax = QsciScintilla.INDIC_TEXTFORE elif QSCINTILLA_VERSION() < 0x020B00: IndicatorStyleMax = QsciScintilla.INDIC_POINTCHARACTER @@ -905,7 +897,7 @@ if cxx11: self.__targetSearchFlags |= QsciScintilla.SCFIND_CXX11REGEX except AttributeError: - # defined for PyQt >= 2.11.0 + # defined for QScintilla >= 2.11.0 pass if begline < 0 or begindex < 0: @@ -1451,33 +1443,6 @@ @return result of the event handling (boolean) """ return QsciScintillaBase.event(self, evt) - - if "inputMethodEvent" in QsciScintillaBase.__dict__ and \ - QSCINTILLA_VERSION() < 0x020801: - def inputMethodEvent(self, evt): - """ - Protected method to cope with a glitch in some Qscintilla versions - handling input events. - - Note: This simply disables the Qscintilla behavior. - - @param evt reference to the input method event object - (QInputMethodEvent) - """ - pass - - def inputMethodQuery(self, query): - """ - Public method to cope with a glitch in some Qscintilla versions - handling input events. - - Note: This simply disables the Qscintilla behavior. - - @param query reference to the input method query object - (Qt.InputMethodQuery) - @return object containing the requested information - """ - return None # __IGNORE_WARNING_M831__ ########################################################################### ## interface methods to the mini editor @@ -1673,80 +1638,33 @@ line, col = self.getCursorPosition() self.insertAt(txt, line, col) + def positionFromLineIndex(self, line, index): + """ + Public method to convert line and index to an absolute position. + + @param line line number (integer) + @param index index number (integer) + @return absolute position in the editor (integer) + """ + pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMLINE, line) + return pos + index + + def lineIndexFromPosition(self, pos): + """ + Public method to convert an absolute position to line and index. + + @param pos absolute position in the editor (integer) + @return tuple of line number (integer) and index number (integer) + """ + lin = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, pos) + linpos = self.SendScintilla( + QsciScintilla.SCI_POSITIONFROMLINE, lin) + return lin, pos - linpos + ########################################################################### ## methods below have been added to QScintilla starting with version 2.5 ########################################################################### - if "positionFromLineIndex" not in QsciScintilla.__dict__: - def positionFromLineIndex(self, line, index): - """ - Public method to convert line and index to an absolute position. - - @param line line number (integer) - @param index index number (integer) - @return absolute position in the editor (integer) - """ - pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMLINE, line) - - # Allow for multi-byte characters - for _ in range(index): - pos = self.positionAfter(pos) - - return pos - - elif QSCINTILLA_VERSION() >= 0x020700: - def positionFromLineIndex(self, line, index): - """ - Public method to convert line and index to an absolute position. - - @param line line number (integer) - @param index index number (integer) - @return absolute position in the editor (integer) - """ - pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMLINE, line) - return pos + index - - if "lineIndexFromPosition" not in QsciScintilla.__dict__: - def lineIndexFromPosition(self, pos): - """ - Public method to convert an absolute position to line and index. - - @param pos absolute position in the editor (integer) - @return tuple of line number (integer) and index number (integer) - """ - lin = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, pos) - linpos = self.SendScintilla( - QsciScintilla.SCI_POSITIONFROMLINE, lin) - indx = 0 - - # Allow for multi-byte characters. - while linpos < pos: - new_linpos = self.positionAfter(linpos) - - # If the position hasn't moved then we must be at the end of - # the text (which implies that the position passed was beyond - # the end of the text). - if new_linpos == linpos: - break - - linpos = new_linpos - indx += 1 - - return lin, indx - - elif QSCINTILLA_VERSION() >= 0x020700: - def lineIndexFromPosition(self, pos): - """ - Public method to convert an absolute position to line and index. - - @param pos absolute position in the editor (integer) - @return tuple of line number (integer) and index number (integer) - """ - lin = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, pos) - linpos = self.SendScintilla( - QsciScintilla.SCI_POSITIONFROMLINE, lin) - return lin, pos - linpos - if "contractedFolds" not in QsciScintilla.__dict__: def contractedFolds(self): """