Commits

Yuya Nishihara committed 910c680

qscilib: move rest of compatibility patches to ScintillaCompat

Comments (0)

Files changed (1)

tortoisehg/hgqt/qscilib.py

             a.setShortcuts(QKeySequence.SelectAll)
             return menu
 
+    # compability mode with QScintilla from Ubuntu 10.04
+    if not hasattr(QsciScintilla, 'HiddenIndicator'):
+        HiddenIndicator = QsciScintilla.INDIC_HIDDEN
+    if not hasattr(QsciScintilla, 'PlainIndicator'):
+        PlainIndicator = QsciScintilla.INDIC_PLAIN
+    if not hasattr(QsciScintilla, 'StrikeIndicator'):
+        StrikeIndicator = QsciScintilla.INDIC_STRIKE
+
+    if not hasattr(QsciScintilla, 'indicatorDefine'):
+        def indicatorDefine(self, style, indicatorNumber=-1):
+            # compatibility layer allows only one indicator to be defined
+            if indicatorNumber == -1:
+                indicatorNumber = 1
+            self.SendScintilla(self.SCI_INDICSETSTYLE, indicatorNumber, style)
+            return indicatorNumber
+
+    if not hasattr(QsciScintilla, 'setIndicatorDrawUnder'):
+        def setIndicatorDrawUnder(self, under, indicatorNumber):
+            self.SendScintilla(self.SCI_INDICSETUNDER, indicatorNumber, under)
+
+    if not hasattr(QsciScintilla, 'setIndicatorForegroundColor'):
+        def setIndicatorForegroundColor(self, color, indicatorNumber):
+            self.SendScintilla(self.SCI_INDICSETFORE, indicatorNumber, color)
+            self.SendScintilla(self.SCI_INDICSETALPHA, indicatorNumber,
+                               color.alpha())
+
+    if not hasattr(QsciScintilla, 'clearIndicatorRange'):
+        def clearIndicatorRange(self, lineFrom, indexFrom, lineTo, indexTo,
+                                indicatorNumber):
+            start = self.positionFromLineIndex(lineFrom, indexFrom)
+            finish = self.positionFromLineIndex(lineTo, indexTo)
+
+            self.SendScintilla(self.SCI_SETINDICATORCURRENT, indicatorNumber)
+            self.SendScintilla(self.SCI_INDICATORCLEARRANGE,
+                               start, finish - start)
+
+    if not hasattr(QsciScintilla, 'fillIndicatorRange'):
+        def fillIndicatorRange(self, lineFrom, indexFrom, lineTo, indexTo,
+                               indicatorNumber):
+            start = self.positionFromLineIndex(lineFrom, indexFrom)
+            finish = self.positionFromLineIndex(lineTo, indexTo)
+
+            self.SendScintilla(self.SCI_SETINDICATORCURRENT, indicatorNumber)
+            self.SendScintilla(self.SCI_INDICATORFILLRANGE,
+                               start, finish - start)
+
 
 class Scintilla(ScintillaCompat):
     """Scintilla widget for rich file view or editor"""
                                    max(point.x(), 0), point.y())
         return self.SendScintilla(self.SCI_LINEFROMPOSITION, chpos)
 
-    # compability mode with QScintilla from Ubuntu 10.04
-    if not hasattr(QsciScintilla, 'HiddenIndicator'):
-        HiddenIndicator = QsciScintilla.INDIC_HIDDEN
-    if not hasattr(QsciScintilla, 'PlainIndicator'):
-        PlainIndicator = QsciScintilla.INDIC_PLAIN
-    if not hasattr(QsciScintilla, 'StrikeIndicator'):
-        StrikeIndicator = QsciScintilla.INDIC_STRIKE
-
-    if not hasattr(QsciScintilla, 'indicatorDefine'):
-        def indicatorDefine(self, style, indicatorNumber=-1):
-            # compatibility layer allows only one indicator to be defined
-            if indicatorNumber == -1:
-                indicatorNumber = 1
-            self.SendScintilla(self.SCI_INDICSETSTYLE, indicatorNumber, style)
-            return indicatorNumber
-
-    if not hasattr(QsciScintilla, 'setIndicatorDrawUnder'):
-        def setIndicatorDrawUnder(self, under, indicatorNumber):
-            self.SendScintilla(self.SCI_INDICSETUNDER, indicatorNumber, under)
-
-    if not hasattr(QsciScintilla, 'setIndicatorForegroundColor'):
-        def setIndicatorForegroundColor(self, color, indicatorNumber):
-            self.SendScintilla(self.SCI_INDICSETFORE, indicatorNumber, color)
-            self.SendScintilla(self.SCI_INDICSETALPHA, indicatorNumber,
-                               color.alpha())
-
-    if not hasattr(QsciScintilla, 'clearIndicatorRange'):
-        def clearIndicatorRange(self, lineFrom, indexFrom, lineTo, indexTo,
-                                indicatorNumber):
-            start = self.positionFromLineIndex(lineFrom, indexFrom)
-            finish = self.positionFromLineIndex(lineTo, indexTo)
-
-            self.SendScintilla(self.SCI_SETINDICATORCURRENT, indicatorNumber)
-            self.SendScintilla(self.SCI_INDICATORCLEARRANGE,
-                               start, finish - start)
-
-    if not hasattr(QsciScintilla, 'fillIndicatorRange'):
-        def fillIndicatorRange(self, lineFrom, indexFrom, lineTo, indexTo,
-                               indicatorNumber):
-            start = self.positionFromLineIndex(lineFrom, indexFrom)
-            finish = self.positionFromLineIndex(lineTo, indexTo)
-
-            self.SendScintilla(self.SCI_SETINDICATORCURRENT, indicatorNumber)
-            self.SendScintilla(self.SCI_INDICATORFILLRANGE,
-                               start, finish - start)
-
 
 class SearchToolBar(QToolBar):
     conditionChanged = pyqtSignal(unicode, bool, bool)