eric6/QScintilla/QsciScintillaCompat.py

changeset 8243
cc717c2ae956
parent 8218
7c09585bd960
child 8260
2161475d9639
equal deleted inserted replaced
8242:aa713ac50c0d 8243:cc717c2ae956
4 # 4 #
5 5
6 """ 6 """
7 Module implementing a compatability interface class to QsciScintilla. 7 Module implementing a compatability interface class to QsciScintilla.
8 """ 8 """
9
10 import contextlib
9 11
10 from PyQt5.QtCore import pyqtSignal, Qt, QPoint 12 from PyQt5.QtCore import pyqtSignal, Qt, QPoint
11 from PyQt5.QtGui import QPalette, QColor, QFontMetrics 13 from PyQt5.QtGui import QPalette, QColor, QFontMetrics
12 from PyQt5.QtWidgets import QApplication, QListWidget 14 from PyQt5.QtWidgets import QApplication, QListWidget
13 from PyQt5.Qsci import ( 15 from PyQt5.Qsci import (
757 have the focus. 759 have the focus.
758 760
759 @param alwaysVisible flag indicating that the caret line shall be 761 @param alwaysVisible flag indicating that the caret line shall be
760 visible even if the editor doesn't have the focus (boolean) 762 visible even if the editor doesn't have the focus (boolean)
761 """ 763 """
762 try: 764 with contextlib.suppress(AttributeError):
763 self.SendScintilla( 765 self.SendScintilla(
764 QsciScintilla.SCI_SETCARETLINEVISIBLEALWAYS, alwaysVisible) 766 QsciScintilla.SCI_SETCARETLINEVISIBLEALWAYS, alwaysVisible)
765 except AttributeError:
766 pass
767 767
768 def canPaste(self): 768 def canPaste(self):
769 """ 769 """
770 Public method to test, if the paste action is available (i.e. if the 770 Public method to test, if the paste action is available (i.e. if the
771 clipboard contains some text). 771 clipboard contains some text).
908 self.__targetSearchFlags |= QsciScintilla.SCFIND_WHOLEWORD 908 self.__targetSearchFlags |= QsciScintilla.SCFIND_WHOLEWORD
909 if ws_: 909 if ws_:
910 self.__targetSearchFlags |= QsciScintilla.SCFIND_WORDSTART 910 self.__targetSearchFlags |= QsciScintilla.SCFIND_WORDSTART
911 if posix: 911 if posix:
912 self.__targetSearchFlags |= QsciScintilla.SCFIND_POSIX 912 self.__targetSearchFlags |= QsciScintilla.SCFIND_POSIX
913 try: 913 with contextlib.suppress(AttributeError):
914 if cxx11: 914 if cxx11:
915 self.__targetSearchFlags |= QsciScintilla.SCFIND_CXX11REGEX 915 self.__targetSearchFlags |= QsciScintilla.SCFIND_CXX11REGEX
916 except AttributeError:
917 # defined for QScintilla >= 2.11.0 916 # defined for QScintilla >= 2.11.0
918 pass
919 917
920 if begline < 0 or begindex < 0: 918 if begline < 0 or begindex < 0:
921 self.__targetSearchStart = self.SendScintilla( 919 self.__targetSearchStart = self.SendScintilla(
922 QsciScintilla.SCI_GETCURRENTPOS) 920 QsciScintilla.SCI_GETCURRENTPOS)
923 else: 921 else:
1010 ): 1008 ):
1011 raise ValueError("style out of range") 1009 raise ValueError("style out of range")
1012 1010
1013 self.SendScintilla(QsciScintilla.SCI_INDICSETSTYLE, indicator, style) 1011 self.SendScintilla(QsciScintilla.SCI_INDICSETSTYLE, indicator, style)
1014 self.SendScintilla(QsciScintilla.SCI_INDICSETFORE, indicator, color) 1012 self.SendScintilla(QsciScintilla.SCI_INDICSETFORE, indicator, color)
1015 try: 1013 with contextlib.suppress(AttributeError):
1016 self.SendScintilla(QsciScintilla.SCI_INDICSETALPHA, indicator, 1014 self.SendScintilla(QsciScintilla.SCI_INDICSETALPHA, indicator,
1017 color.alpha()) 1015 color.alpha())
1018 if style in ( 1016 if style in (
1019 QsciScintilla.INDIC_ROUNDBOX, QsciScintilla.INDIC_STRAIGHTBOX, 1017 QsciScintilla.INDIC_ROUNDBOX, QsciScintilla.INDIC_STRAIGHTBOX,
1020 QsciScintilla.INDIC_DOTBOX, QsciScintilla.INDIC_FULLBOX, 1018 QsciScintilla.INDIC_DOTBOX, QsciScintilla.INDIC_FULLBOX,
1021 ): 1019 ):
1022 # set outline alpha less transparent 1020 # set outline alpha less transparent
1023 self.SendScintilla(QsciScintilla.SCI_INDICSETOUTLINEALPHA, 1021 self.SendScintilla(QsciScintilla.SCI_INDICSETOUTLINEALPHA,
1024 indicator, color.alpha() + 20) 1022 indicator, color.alpha() + 20)
1025 except AttributeError:
1026 pass
1027 1023
1028 def setCurrentIndicator(self, indicator): 1024 def setCurrentIndicator(self, indicator):
1029 """ 1025 """
1030 Public method to set the current indicator. 1026 Public method to set the current indicator.
1031 1027

eric ide

mercurial