QScintilla/QsciScintillaCompat.py

changeset 3378
b88e7fd6c009
parent 3257
a2b4a45e14de
child 3390
7f46edbfcbc0
--- a/QScintilla/QsciScintillaCompat.py	Sat Mar 15 17:35:04 2014 +0100
+++ b/QScintilla/QsciScintillaCompat.py	Sat Mar 15 19:01:43 2014 +0100
@@ -1336,6 +1336,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):
             """
@@ -1364,6 +1376,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