eric6/QScintilla/QsciScintillaCompat.py

branch
without_py2_and_pyqt4
changeset 7202
d2f2a1fe0129
parent 6948
c6e580fd9bb1
child 7229
53054eb5b15a
equal deleted inserted replaced
7201:6b42677d7043 7202:d2f2a1fe0129
44 ArrowFoldStyle = QsciScintilla.BoxedTreeFoldStyle + 1 44 ArrowFoldStyle = QsciScintilla.BoxedTreeFoldStyle + 1
45 ArrowTreeFoldStyle = ArrowFoldStyle + 1 45 ArrowTreeFoldStyle = ArrowFoldStyle + 1
46 46
47 UserSeparator = '\x04' 47 UserSeparator = '\x04'
48 48
49 if QSCINTILLA_VERSION() < 0x020600: 49 if QSCINTILLA_VERSION() < 0x020A00:
50 IndicatorStyleMax = QsciScintilla.INDIC_ROUNDBOX
51 elif QSCINTILLA_VERSION() < 0x020700:
52 IndicatorStyleMax = QsciScintilla.INDIC_DOTBOX
53 elif QSCINTILLA_VERSION() < 0x020800:
54 IndicatorStyleMax = QsciScintilla.INDIC_SQUIGGLEPIXMAP
55 elif QSCINTILLA_VERSION() < 0x020900:
56 IndicatorStyleMax = QsciScintilla.INDIC_COMPOSITIONTHICK
57 elif QSCINTILLA_VERSION() < 0x020A00:
58 IndicatorStyleMax = QsciScintilla.INDIC_TEXTFORE 50 IndicatorStyleMax = QsciScintilla.INDIC_TEXTFORE
59 elif QSCINTILLA_VERSION() < 0x020B00: 51 elif QSCINTILLA_VERSION() < 0x020B00:
60 IndicatorStyleMax = QsciScintilla.INDIC_POINTCHARACTER 52 IndicatorStyleMax = QsciScintilla.INDIC_POINTCHARACTER
61 else: 53 else:
62 IndicatorStyleMax = QsciScintilla.INDIC_GRADIENTCENTRE 54 IndicatorStyleMax = QsciScintilla.INDIC_GRADIENTCENTRE
903 self.__targetSearchFlags |= QsciScintilla.SCFIND_POSIX 895 self.__targetSearchFlags |= QsciScintilla.SCFIND_POSIX
904 try: 896 try:
905 if cxx11: 897 if cxx11:
906 self.__targetSearchFlags |= QsciScintilla.SCFIND_CXX11REGEX 898 self.__targetSearchFlags |= QsciScintilla.SCFIND_CXX11REGEX
907 except AttributeError: 899 except AttributeError:
908 # defined for PyQt >= 2.11.0 900 # defined for QScintilla >= 2.11.0
909 pass 901 pass
910 902
911 if begline < 0 or begindex < 0: 903 if begline < 0 or begindex < 0:
912 self.__targetSearchStart = self.SendScintilla( 904 self.__targetSearchStart = self.SendScintilla(
913 QsciScintilla.SCI_GETCURRENTPOS) 905 QsciScintilla.SCI_GETCURRENTPOS)
1449 1441
1450 @param evt event object to handle (QEvent) 1442 @param evt event object to handle (QEvent)
1451 @return result of the event handling (boolean) 1443 @return result of the event handling (boolean)
1452 """ 1444 """
1453 return QsciScintillaBase.event(self, evt) 1445 return QsciScintillaBase.event(self, evt)
1454
1455 if "inputMethodEvent" in QsciScintillaBase.__dict__ and \
1456 QSCINTILLA_VERSION() < 0x020801:
1457 def inputMethodEvent(self, evt):
1458 """
1459 Protected method to cope with a glitch in some Qscintilla versions
1460 handling input events.
1461
1462 Note: This simply disables the Qscintilla behavior.
1463
1464 @param evt reference to the input method event object
1465 (QInputMethodEvent)
1466 """
1467 pass
1468
1469 def inputMethodQuery(self, query):
1470 """
1471 Public method to cope with a glitch in some Qscintilla versions
1472 handling input events.
1473
1474 Note: This simply disables the Qscintilla behavior.
1475
1476 @param query reference to the input method query object
1477 (Qt.InputMethodQuery)
1478 @return object containing the requested information
1479 """
1480 return None # __IGNORE_WARNING_M831__
1481 1446
1482 ########################################################################### 1447 ###########################################################################
1483 ## interface methods to the mini editor 1448 ## interface methods to the mini editor
1484 ########################################################################### 1449 ###########################################################################
1485 1450
1671 @type str 1636 @type str
1672 """ 1637 """
1673 line, col = self.getCursorPosition() 1638 line, col = self.getCursorPosition()
1674 self.insertAt(txt, line, col) 1639 self.insertAt(txt, line, col)
1675 1640
1641 def positionFromLineIndex(self, line, index):
1642 """
1643 Public method to convert line and index to an absolute position.
1644
1645 @param line line number (integer)
1646 @param index index number (integer)
1647 @return absolute position in the editor (integer)
1648 """
1649 pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMLINE, line)
1650 return pos + index
1651
1652 def lineIndexFromPosition(self, pos):
1653 """
1654 Public method to convert an absolute position to line and index.
1655
1656 @param pos absolute position in the editor (integer)
1657 @return tuple of line number (integer) and index number (integer)
1658 """
1659 lin = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, pos)
1660 linpos = self.SendScintilla(
1661 QsciScintilla.SCI_POSITIONFROMLINE, lin)
1662 return lin, pos - linpos
1663
1676 ########################################################################### 1664 ###########################################################################
1677 ## methods below have been added to QScintilla starting with version 2.5 1665 ## methods below have been added to QScintilla starting with version 2.5
1678 ########################################################################### 1666 ###########################################################################
1679
1680 if "positionFromLineIndex" not in QsciScintilla.__dict__:
1681 def positionFromLineIndex(self, line, index):
1682 """
1683 Public method to convert line and index to an absolute position.
1684
1685 @param line line number (integer)
1686 @param index index number (integer)
1687 @return absolute position in the editor (integer)
1688 """
1689 pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMLINE, line)
1690
1691 # Allow for multi-byte characters
1692 for _ in range(index):
1693 pos = self.positionAfter(pos)
1694
1695 return pos
1696
1697 elif QSCINTILLA_VERSION() >= 0x020700:
1698 def positionFromLineIndex(self, line, index):
1699 """
1700 Public method to convert line and index to an absolute position.
1701
1702 @param line line number (integer)
1703 @param index index number (integer)
1704 @return absolute position in the editor (integer)
1705 """
1706 pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMLINE, line)
1707 return pos + index
1708
1709 if "lineIndexFromPosition" not in QsciScintilla.__dict__:
1710 def lineIndexFromPosition(self, pos):
1711 """
1712 Public method to convert an absolute position to line and index.
1713
1714 @param pos absolute position in the editor (integer)
1715 @return tuple of line number (integer) and index number (integer)
1716 """
1717 lin = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, pos)
1718 linpos = self.SendScintilla(
1719 QsciScintilla.SCI_POSITIONFROMLINE, lin)
1720 indx = 0
1721
1722 # Allow for multi-byte characters.
1723 while linpos < pos:
1724 new_linpos = self.positionAfter(linpos)
1725
1726 # If the position hasn't moved then we must be at the end of
1727 # the text (which implies that the position passed was beyond
1728 # the end of the text).
1729 if new_linpos == linpos:
1730 break
1731
1732 linpos = new_linpos
1733 indx += 1
1734
1735 return lin, indx
1736
1737 elif QSCINTILLA_VERSION() >= 0x020700:
1738 def lineIndexFromPosition(self, pos):
1739 """
1740 Public method to convert an absolute position to line and index.
1741
1742 @param pos absolute position in the editor (integer)
1743 @return tuple of line number (integer) and index number (integer)
1744 """
1745 lin = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, pos)
1746 linpos = self.SendScintilla(
1747 QsciScintilla.SCI_POSITIONFROMLINE, lin)
1748 return lin, pos - linpos
1749 1667
1750 if "contractedFolds" not in QsciScintilla.__dict__: 1668 if "contractedFolds" not in QsciScintilla.__dict__:
1751 def contractedFolds(self): 1669 def contractedFolds(self):
1752 """ 1670 """
1753 Public method to get a list of line numbers of collapsed folds. 1671 Public method to get a list of line numbers of collapsed folds.

eric ide

mercurial