--- a/eric7/QScintilla/QsciScintillaCompat.py Sat Oct 23 09:16:10 2021 +0200 +++ b/eric7/QScintilla/QsciScintillaCompat.py Sat Oct 23 12:19:47 2021 +0200 @@ -660,6 +660,31 @@ selections.append(self.getSelectionN(index)) return selections + def addCursor(self, line, index): + """ + Public method to add an additional cursor. + + @param line line number for the cursor + @type int + @param index index number for the cursor + @type int + """ + pos = self.positionFromLineIndex(line, index) + + if self.getSelectionCount() == 0: + self.SendScintilla(QsciScintilla.SCI_SETSELECTION, pos, pos) + else: + self.SendScintilla(QsciScintilla.SCI_ADDSELECTION, pos, pos) + + def enableMultiCursorSupport(self): + """ + Public method to enable support for multi cursor editing. + """ + # typing should insert in all selections at the same time + self.SendScintilla(QsciScintilla.SCI_SETMULTIPLESELECTION, True) + self.SendScintilla(QsciScintilla.SCI_SETADDITIONALSELECTIONTYPING, + True) + def setVirtualSpaceOptions(self, options): """ Public method to set the virtual space usage options. @@ -1623,33 +1648,6 @@ else: return string.encode("latin-1") - ########################################################################### - ## methods to implement workarounds for broken things - ########################################################################### - - 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 are missing from QScintilla. ######################################################################### @@ -1687,6 +1685,20 @@ """ self.SendScintilla(QsciScintilla.SCI_CALLTIPCANCEL) + if "lineIndexFromPoint" not in QsciScintilla.__dict__: + def lineIndexFromPoint(self, point): + """ + Public method to convert a point to line and index. + + @param point point to be converted + @type QPoin + @return tuple containing the line number and index number + @rtype tuple of (int, int) + """ + pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMPOINT, + point.x(), point.y()) + return self.lineIndexFromPosition(pos) + ## ######################################################################### ## ## Methods below have been added to QScintilla starting with version 2.x. ## #########################################################################