eric7/QScintilla/QsciScintillaCompat.py

branch
eric7
changeset 8713
c2a124c2ecbb
parent 8581
a6c893c8b7af
child 8716
7bd161e50995
equal deleted inserted replaced
8712:ce5d777ecfef 8713:c2a124c2ecbb
657 """ 657 """
658 selections = [] 658 selections = []
659 for index in range(self.getSelectionCount()): 659 for index in range(self.getSelectionCount()):
660 selections.append(self.getSelectionN(index)) 660 selections.append(self.getSelectionN(index))
661 return selections 661 return selections
662
663 def addCursor(self, line, index):
664 """
665 Public method to add an additional cursor.
666
667 @param line line number for the cursor
668 @type int
669 @param index index number for the cursor
670 @type int
671 """
672 pos = self.positionFromLineIndex(line, index)
673
674 if self.getSelectionCount() == 0:
675 self.SendScintilla(QsciScintilla.SCI_SETSELECTION, pos, pos)
676 else:
677 self.SendScintilla(QsciScintilla.SCI_ADDSELECTION, pos, pos)
678
679 def enableMultiCursorSupport(self):
680 """
681 Public method to enable support for multi cursor editing.
682 """
683 # typing should insert in all selections at the same time
684 self.SendScintilla(QsciScintilla.SCI_SETMULTIPLESELECTION, True)
685 self.SendScintilla(QsciScintilla.SCI_SETADDITIONALSELECTIONTYPING,
686 True)
662 687
663 def setVirtualSpaceOptions(self, options): 688 def setVirtualSpaceOptions(self, options):
664 """ 689 """
665 Public method to set the virtual space usage options. 690 Public method to set the virtual space usage options.
666 691
1621 if self.isUtf8(): 1646 if self.isUtf8():
1622 return string.encode("utf-8") 1647 return string.encode("utf-8")
1623 else: 1648 else:
1624 return string.encode("latin-1") 1649 return string.encode("latin-1")
1625 1650
1626 ###########################################################################
1627 ## methods to implement workarounds for broken things
1628 ###########################################################################
1629
1630 def positionFromLineIndex(self, line, index):
1631 """
1632 Public method to convert line and index to an absolute position.
1633
1634 @param line line number (integer)
1635 @param index index number (integer)
1636 @return absolute position in the editor (integer)
1637 """
1638 pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMLINE, line)
1639 return pos + index
1640
1641 def lineIndexFromPosition(self, pos):
1642 """
1643 Public method to convert an absolute position to line and index.
1644
1645 @param pos absolute position in the editor (integer)
1646 @return tuple of line number (integer) and index number (integer)
1647 """
1648 lin = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, pos)
1649 linpos = self.SendScintilla(
1650 QsciScintilla.SCI_POSITIONFROMLINE, lin)
1651 return lin, pos - linpos
1652
1653 ######################################################################### 1651 #########################################################################
1654 ## Methods below are missing from QScintilla. 1652 ## Methods below are missing from QScintilla.
1655 ######################################################################### 1653 #########################################################################
1656 1654
1657 if "setWrapStartIndent" not in QsciScintilla.__dict__: 1655 if "setWrapStartIndent" not in QsciScintilla.__dict__:
1685 """ 1683 """
1686 Public method to cancel displayed call tips. 1684 Public method to cancel displayed call tips.
1687 """ 1685 """
1688 self.SendScintilla(QsciScintilla.SCI_CALLTIPCANCEL) 1686 self.SendScintilla(QsciScintilla.SCI_CALLTIPCANCEL)
1689 1687
1688 if "lineIndexFromPoint" not in QsciScintilla.__dict__:
1689 def lineIndexFromPoint(self, point):
1690 """
1691 Public method to convert a point to line and index.
1692
1693 @param point point to be converted
1694 @type QPoin
1695 @return tuple containing the line number and index number
1696 @rtype tuple of (int, int)
1697 """
1698 pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMPOINT,
1699 point.x(), point.y())
1700 return self.lineIndexFromPosition(pos)
1701
1690 ## ######################################################################### 1702 ## #########################################################################
1691 ## ## Methods below have been added to QScintilla starting with version 2.x. 1703 ## ## Methods below have been added to QScintilla starting with version 2.x.
1692 ## ######################################################################### 1704 ## #########################################################################
1693 ## 1705 ##
1694 ## if "newMethod" not in QsciScintilla.__dict__: 1706 ## if "newMethod" not in QsciScintilla.__dict__:

eric ide

mercurial