src/eric7/QScintilla/QsciScintillaCompat.py

branch
eric7
changeset 9977
a5acf678c367
parent 9845
50d1cd44b2cb
child 10069
435cc5875135
--- a/src/eric7/QScintilla/QsciScintillaCompat.py	Wed Apr 12 13:10:09 2023 +0200
+++ b/src/eric7/QScintilla/QsciScintillaCompat.py	Thu Apr 13 19:33:10 2023 +0200
@@ -1202,6 +1202,56 @@
         """
         return self.SendScintilla(QsciScintilla.SCI_INDICATOREND, indicator, pos)
 
+    def getIndicatorRange(self, indicator, pos=None):
+        """
+        Public method to get the range of the indicator at the given position.
+
+        If the position is given as 'None', the current cursor position is used.
+
+        @param indicator ID of the indicator
+        @type int
+        @param pos position within the indicator (defaults to None)
+        @type int (optional)
+        @return start position and length of the indicator
+        @rtype tuple of (int, int)
+        """
+        if pos is None:
+            pos = self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS)
+
+        isInIndicator = self.hasIndicator(indicator, pos)
+        if isInIndicator:
+            posStart = self.getIndicatorStartPos(indicator, pos)
+            posEnd = self.getIndicatorEndPos(indicator, pos)
+            return posStart, posEnd - posStart
+        else:
+            return 0, 0
+
+    def getIndicator(self, indicator, pos=None):
+        """
+        Public method to get the start and end of the indicator at the given position.
+
+        If the position is given as 'None', the current cursor position is used.
+
+        @param indicator ID of the indicator
+        @type int
+        @param pos position within the indicator (defaults to None)
+        @type int (optional)
+        @return tuple containing the start line and index and the end line and index
+        @rtype tuple of (int, int, int, int)
+        """
+        if pos is None:
+            pos = self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS)
+
+        isInIndicator = self.hasIndicator(indicator, pos)
+        if isInIndicator:
+            posStart = self.getIndicatorStartPos(indicator, pos)
+            sline, sindex = self.lineIndexFromPosition(posStart)
+            posEnd = self.getIndicatorEndPos(indicator, pos)
+            eline, eindex = self.lineIndexFromPosition(posEnd)
+            return sline, sindex, eline, eindex
+        else:
+            return 0, 0, 0, 0
+
     def gotoPreviousIndicator(self, indicator, wrap):
         """
         Public method to move the cursor to the previous position of an

eric ide

mercurial