QScintilla/QsciScintillaCompat.py

branch
5_4_x
changeset 3379
dcf9f81f2ae5
parent 3258
a2bec950a859
child 3391
30c8ac760fed
--- a/QScintilla/QsciScintillaCompat.py	Sat Mar 15 17:24:02 2014 +0100
+++ b/QScintilla/QsciScintillaCompat.py	Sat Mar 15 19:01:43 2014 +0100
@@ -1333,6 +1333,18 @@
             
             return pos
     
+    elif QSCINTILLA_VERSION() >= 0x020800:
+        def positionFromLineIndex(self, line, index):
+            """
+            Public method to convert line and index to an absolute position.
+            
+            @param line line number (integer)
+            @param index index number (integer)
+            @return absolute position in the editor (integer)
+            """
+            pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMLINE, line)
+            return pos + index
+    
     if "lineIndexFromPosition" not in QsciScintilla.__dict__:
         def lineIndexFromPosition(self, pos):
             """
@@ -1361,6 +1373,19 @@
             
             return lin, indx
     
+    elif QSCINTILLA_VERSION() >= 0x020800:
+        def lineIndexFromPosition(self, pos):
+            """
+            Public method to convert an absolute position to line and index.
+            
+            @param pos absolute position in the editor (integer)
+            @return tuple of line number (integer) and index number (integer)
+            """
+            lin = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION, pos)
+            linpos = self.SendScintilla(
+                QsciScintilla.SCI_POSITIONFROMLINE, lin)
+            return lin, pos - linpos
+    
     if "contractedFolds" not in QsciScintilla.__dict__:
         def contractedFolds(self):
             """

eric ide

mercurial