QScintilla/QsciScintillaCompat.py

branch
Py2 comp.
changeset 3080
6c0a430b19df
parent 3060
5883ce99ee12
parent 3078
b9422535d0fe
child 3145
a9de05d4a22f
--- a/QScintilla/QsciScintillaCompat.py	Wed Nov 13 23:30:59 2013 +0100
+++ b/QScintilla/QsciScintillaCompat.py	Sat Nov 16 10:06:28 2013 +0100
@@ -11,9 +11,8 @@
 
 from PyQt4.QtCore import pyqtSignal, Qt
 from PyQt4.QtGui import QPalette, QColor, QApplication
-from PyQt4.Qsci import QsciScintilla, \
-    QSCINTILLA_VERSION as QSCIQSCINTILLA_VERSION, QSCINTILLA_VERSION_STR, \
-    QsciScintillaBase
+from PyQt4.Qsci import QsciScintillaBase, QsciScintilla, \
+    QSCINTILLA_VERSION as QSCIQSCINTILLA_VERSION
 
 ###############################################################################
 
@@ -22,15 +21,9 @@
     """
     Module function to return the QScintilla version.
     
-    If the installed QScintilla is a snapshot version, then assume it is
-    of the latest release and return a version number of 0x99999.
-    
     @return QScintilla version (integer)
     """
-    if '-snapshot-' in QSCINTILLA_VERSION_STR:
-        return 0x99999
-    else:
-        return QSCIQSCINTILLA_VERSION
+    return QSCIQSCINTILLA_VERSION
     
 ###############################################################################
 
@@ -52,6 +45,15 @@
     
     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
+    else:
+        IndicatorStyleMax = QsciScintilla.INDIC_COMPOSITIONTHICK
+    
     def __init__(self, parent=None):
         """
         Constructor
@@ -671,6 +673,33 @@
         """
         self.SendScintilla(QsciScintilla.SCI_SETCARETPERIOD, time // 2)
     
+    def getCaretLineAlwaysVisible(self):
+        """
+        Public method to determine, if the caret line is visible even if
+        the editor doesn't have the focus.
+        
+        @return flag indicating an always visible caret line (boolean)
+        """
+        try:
+            return self.SendScintilla(
+                QsciScintilla.SCI_GETCARETLINEVISIBLEALWAYS)
+        except AttributeError:
+            return False
+    
+    def setCaretLineAlwaysVisible(self, alwaysVisible):
+        """
+        Public method to set the caret line visible even if the editor doesn't
+        have the focus.
+        
+        @param alwaysVisible flag indicating that the caret line shall be
+            visible even if the editor doesn't have the focus (boolean)
+        """
+        try:
+            self.SendScintilla(
+                QsciScintilla.SCI_SETCARETLINEVISIBLEALWAYS, alwaysVisible)
+        except AttributeError:
+            pass
+    
     ###########################################################################
     # methods to perform searches in target range
     ###########################################################################
@@ -861,7 +890,12 @@
             (QsciScintilla.INDIC_PLAIN, QsciScintilla.INDIC_SQUIGGLE,
             QsciScintilla.INDIC_TT, QsciScintilla.INDIC_DIAGONAL,
             QsciScintilla.INDIC_STRIKE, QsciScintilla.INDIC_HIDDEN,
-            QsciScintilla.INDIC_BOX, QsciScintilla.INDIC_ROUNDBOX)
+            QsciScintilla.INDIC_BOX, QsciScintilla.INDIC_ROUNDBOX,
+            QsciScintilla.INDIC_STRAIGHTBOX, QsciScintilla.INDIC_DASH,
+            QsciScintilla.INDIC_DOTS, QsciScintilla.INDIC_SQUIGGLELOW,
+            QsciScintilla.INDIC_DOTBOX, QsciScintilla.INDIC_SQUIGGLEPIXMAP,
+            QsciScintilla.INDIC_COMPOSITIONTHICK depending upon QScintilla
+            version)
         @param color color to be used by the indicator (QColor)
         @exception ValueError the indicator or style are not valid
         """
@@ -870,7 +904,7 @@
             raise ValueError("indicator number out of range")
         
         if style < QsciScintilla.INDIC_PLAIN or \
-           style > QsciScintilla.INDIC_ROUNDBOX:
+           style > self.IndicatorStyleMax:
             raise ValueError("style out of range")
         
         self.SendScintilla(QsciScintilla.SCI_INDICSETSTYLE, indicator, style)
@@ -971,6 +1005,42 @@
                                  indicator, pos)
         return res
     
+    def showFindIndicator(self, sline, sindex, eline, eindex):
+        """
+        Public method to show the find indicator for the given range.
+        
+        @param sline line number of the indicator start (integer)
+        @param sindex index of the indicator start (integer)
+        @param eline line number of the indicator end (integer)
+        @param eindex index of the indicator end (integer)
+        """
+        if hasattr(QsciScintilla, "SCI_FINDINDICATORSHOW"):
+            spos = self.positionFromLineIndex(sline, sindex)
+            epos = self.positionFromLineIndex(eline, eindex)
+            self.SendScintilla(QsciScintilla.SCI_FINDINDICATORSHOW, spos, epos)
+    
+    def flashFindIndicator(self, sline, sindex, eline, eindex):
+        """
+        Public method to flash the find indicator for the given range.
+        
+        @param sline line number of the indicator start (integer)
+        @param sindex index of the indicator start (integer)
+        @param eline line number of the indicator end (integer)
+        @param eindex index of the indicator end (integer)
+        """
+        if hasattr(QsciScintilla, "SCI_FINDINDICATORFLASH"):
+            spos = self.positionFromLineIndex(sline, sindex)
+            epos = self.positionFromLineIndex(eline, eindex)
+            self.SendScintilla(QsciScintilla.SCI_FINDINDICATORFLASH,
+                               spos, epos)
+    
+    def hideFindIndicator(self):
+        """
+        Public method to hide the find indicator.
+        """
+        if hasattr(QsciScintilla, "SCI_FINDINDICATORHIDE"):
+            self.SendScintilla(QsciScintilla.SCI_FINDINDICATORHIDE)
+    
     ###########################################################################
     # methods to perform folding related stuff
     ###########################################################################

eric ide

mercurial