Sat, 09 May 2015 17:07:56 +0200
Added methods to QsciScintillaCompat to find the start and end of an indicator and to go to the previous or next occurrence of an indicator.
--- a/APIs/Python3/eric6.api Sat May 09 14:10:59 2015 +0200 +++ b/APIs/Python3/eric6.api Sat May 09 17:07:56 2015 +0200 @@ -7610,12 +7610,16 @@ eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.getEolIndicator?4() eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.getFileName?4() eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.getFoundTarget?4() +eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.getIndicatorEndPos?4(indicator, pos) +eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.getIndicatorStartPos?4(indicator, pos) eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.getLineSeparator?4() eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.getRectangularSelection?4() eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.getSelectionCount?4() eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.getSelectionN?4(index) eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.getSelections?4() eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.getZoom?4() +eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.gotoNextIndicator?4(indicator, wrap) +eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.gotoPreviousIndicator?4(indicator, wrap) eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.hasIndicator?4(indicator, pos) eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.hasSelectedText?4() eric6.QScintilla.QsciScintillaCompat.QsciScintillaCompat.hasSelection?4()
--- a/Documentation/Help/source.qhp Sat May 09 14:10:59 2015 +0200 +++ b/Documentation/Help/source.qhp Sat May 09 17:07:56 2015 +0200 @@ -9634,12 +9634,16 @@ <keyword name="QsciScintillaCompat.getEolIndicator" id="QsciScintillaCompat.getEolIndicator" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.getEolIndicator" /> <keyword name="QsciScintillaCompat.getFileName" id="QsciScintillaCompat.getFileName" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.getFileName" /> <keyword name="QsciScintillaCompat.getFoundTarget" id="QsciScintillaCompat.getFoundTarget" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.getFoundTarget" /> + <keyword name="QsciScintillaCompat.getIndicatorEndPos" id="QsciScintillaCompat.getIndicatorEndPos" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.getIndicatorEndPos" /> + <keyword name="QsciScintillaCompat.getIndicatorStartPos" id="QsciScintillaCompat.getIndicatorStartPos" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.getIndicatorStartPos" /> <keyword name="QsciScintillaCompat.getLineSeparator" id="QsciScintillaCompat.getLineSeparator" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.getLineSeparator" /> <keyword name="QsciScintillaCompat.getRectangularSelection" id="QsciScintillaCompat.getRectangularSelection" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.getRectangularSelection" /> <keyword name="QsciScintillaCompat.getSelectionCount" id="QsciScintillaCompat.getSelectionCount" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.getSelectionCount" /> <keyword name="QsciScintillaCompat.getSelectionN" id="QsciScintillaCompat.getSelectionN" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.getSelectionN" /> <keyword name="QsciScintillaCompat.getSelections" id="QsciScintillaCompat.getSelections" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.getSelections" /> <keyword name="QsciScintillaCompat.getZoom" id="QsciScintillaCompat.getZoom" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.getZoom" /> + <keyword name="QsciScintillaCompat.gotoNextIndicator" id="QsciScintillaCompat.gotoNextIndicator" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.gotoNextIndicator" /> + <keyword name="QsciScintillaCompat.gotoPreviousIndicator" id="QsciScintillaCompat.gotoPreviousIndicator" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.gotoPreviousIndicator" /> <keyword name="QsciScintillaCompat.hasIndicator" id="QsciScintillaCompat.hasIndicator" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.hasIndicator" /> <keyword name="QsciScintillaCompat.hasSelectedText" id="QsciScintillaCompat.hasSelectedText" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.hasSelectedText" /> <keyword name="QsciScintillaCompat.hasSelection" id="QsciScintillaCompat.hasSelection" ref="eric6.QScintilla.QsciScintillaCompat.html#QsciScintillaCompat.hasSelection" />
--- a/Documentation/Source/eric6.QScintilla.QsciScintillaCompat.html Sat May 09 14:10:59 2015 +0200 +++ b/Documentation/Source/eric6.QScintilla.QsciScintillaCompat.html Sat May 09 17:07:56 2015 +0200 @@ -208,6 +208,12 @@ <td><a href="#QsciScintillaCompat.getFoundTarget">getFoundTarget</a></td> <td>Public method to get the recently found target.</td> </tr><tr> +<td><a href="#QsciScintillaCompat.getIndicatorEndPos">getIndicatorEndPos</a></td> +<td>Public method to get the end position of an indicator at a position.</td> +</tr><tr> +<td><a href="#QsciScintillaCompat.getIndicatorStartPos">getIndicatorStartPos</a></td> +<td>Public method to get the start position of an indicator at a position.</td> +</tr><tr> <td><a href="#QsciScintillaCompat.getLineSeparator">getLineSeparator</a></td> <td>Public method to get the line separator for the current eol mode.</td> </tr><tr> @@ -226,6 +232,12 @@ <td><a href="#QsciScintillaCompat.getZoom">getZoom</a></td> <td>Public method used to retrieve the current zoom factor.</td> </tr><tr> +<td><a href="#QsciScintillaCompat.gotoNextIndicator">gotoNextIndicator</a></td> +<td>Public method to move the cursor to the next position of an indicator.</td> +</tr><tr> +<td><a href="#QsciScintillaCompat.gotoPreviousIndicator">gotoPreviousIndicator</a></td> +<td>Public method to move the cursor to the previous position of an indicator.</td> +</tr><tr> <td><a href="#QsciScintillaCompat.hasIndicator">hasIndicator</a></td> <td>Public method to test for the existence of an indicator.</td> </tr><tr> @@ -901,6 +913,42 @@ found target as a tuple of starting position and target length (integer, integer) </dd> +</dl><a NAME="QsciScintillaCompat.getIndicatorEndPos" ID="QsciScintillaCompat.getIndicatorEndPos"></a> +<h4>QsciScintillaCompat.getIndicatorEndPos</h4> +<b>getIndicatorEndPos</b>(<i>indicator, pos</i>) +<p> + Public method to get the end position of an indicator at a position. +</p><dl> +<dt><i>indicator</i></dt> +<dd> +ID of the indicator (integer) +</dd><dt><i>pos</i></dt> +<dd> +position within the indicator (integer) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +end position of the indicator (integer) +</dd> +</dl><a NAME="QsciScintillaCompat.getIndicatorStartPos" ID="QsciScintillaCompat.getIndicatorStartPos"></a> +<h4>QsciScintillaCompat.getIndicatorStartPos</h4> +<b>getIndicatorStartPos</b>(<i>indicator, pos</i>) +<p> + Public method to get the start position of an indicator at a position. +</p><dl> +<dt><i>indicator</i></dt> +<dd> +ID of the indicator (integer) +</dd><dt><i>pos</i></dt> +<dd> +position within the indicator (integer) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +start position of the indicator (integer) +</dd> </dl><a NAME="QsciScintillaCompat.getLineSeparator" ID="QsciScintillaCompat.getLineSeparator"></a> <h4>QsciScintillaCompat.getLineSeparator</h4> <b>getLineSeparator</b>(<i></i>) @@ -971,6 +1019,53 @@ <dd> zoom factor (integer) </dd> +</dl><a NAME="QsciScintillaCompat.gotoNextIndicator" ID="QsciScintillaCompat.gotoNextIndicator"></a> +<h4>QsciScintillaCompat.gotoNextIndicator</h4> +<b>gotoNextIndicator</b>(<i>indicator, wrap</i>) +<p> + Public method to move the cursor to the next position of an indicator. +</p><p> + This method ensures, that the position found is visible (i.e. unfolded + and inside the visible range). The text containing the indicator is + selected. +</p><dl> +<dt><i>indicator</i></dt> +<dd> +ID of the indicator to search (integer) +</dd><dt><i>wrap</i></dt> +<dd> +flag indicating to wrap around at the beginning of the + text (boolean) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +flag indicating if the indicator was found (boolean) +</dd> +</dl><a NAME="QsciScintillaCompat.gotoPreviousIndicator" ID="QsciScintillaCompat.gotoPreviousIndicator"></a> +<h4>QsciScintillaCompat.gotoPreviousIndicator</h4> +<b>gotoPreviousIndicator</b>(<i>indicator, wrap</i>) +<p> + Public method to move the cursor to the previous position of an + indicator. +</p><p> + This method ensures, that the position found is visible (i.e. unfolded + and inside the visible range). The text containing the indicator is + selected. +</p><dl> +<dt><i>indicator</i></dt> +<dd> +ID of the indicator to search (integer) +</dd><dt><i>wrap</i></dt> +<dd> +flag indicating to wrap around at the beginning of the + text (boolean) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +flag indicating if the indicator was found (boolean) +</dd> </dl><a NAME="QsciScintillaCompat.hasIndicator" ID="QsciScintillaCompat.hasIndicator"></a> <h4>QsciScintillaCompat.hasIndicator</h4> <b>hasIndicator</b>(<i>indicator, pos</i>)
--- a/QScintilla/QsciScintillaCompat.py Sat May 09 14:10:59 2015 +0200 +++ b/QScintilla/QsciScintillaCompat.py Sat May 09 17:07:56 2015 +0200 @@ -1093,6 +1093,135 @@ if hasattr(QsciScintilla, "SCI_FINDINDICATORHIDE"): self.SendScintilla(QsciScintilla.SCI_FINDINDICATORHIDE) + def getIndicatorStartPos(self, indicator, pos): + """ + Public method to get the start position of an indicator at a position. + + @param indicator ID of the indicator (integer) + @param pos position within the indicator (integer) + @return start position of the indicator (integer) + """ + return self.SendScintilla(QsciScintilla.SCI_INDICATORSTART, + indicator, pos) + + def getIndicatorEndPos(self, indicator, pos): + """ + Public method to get the end position of an indicator at a position. + + @param indicator ID of the indicator (integer) + @param pos position within the indicator (integer) + @return end position of the indicator (integer) + """ + return self.SendScintilla(QsciScintilla.SCI_INDICATOREND, + indicator, pos) + + def gotoPreviousIndicator(self, indicator, wrap): + """ + Public method to move the cursor to the previous position of an + indicator. + + This method ensures, that the position found is visible (i.e. unfolded + and inside the visible range). The text containing the indicator is + selected. + + @param indicator ID of the indicator to search (integer) + @param wrap flag indicating to wrap around at the beginning of the + text (boolean) + @return flag indicating if the indicator was found (boolean) + """ + pos = self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS) + docLen = self.SendScintilla(QsciScintilla.SCI_GETTEXTLENGTH) + isInIndicator = self.hasIndicator(indicator, pos) + posStart = self.getIndicatorStartPos(indicator, pos) + posEnd = self.getIndicatorEndPos(indicator, pos) + + if posStart == 0 and posEnd == docLen - 1: + # indicator does not exist + return False + + if posStart <= 0: + if not wrap: + return False + + isInIndicator = self.hasIndicator(indicator, docLen - 1) + posStart = self.getIndicatorStartPos(indicator, docLen - 1) + + if isInIndicator: + # get out of it + posStart = self.getIndicatorStartPos(indicator, posStart - 1) + if posStart <= 0: + if not wrap: + return False + + posStart = self.getIndicatorStartPos(indicator, docLen - 1) + + newPos = posStart - 1 + posStart = self.getIndicatorStartPos(indicator, newPos) + posEnd = self.getIndicatorEndPos(indicator, newPos) + + if self.hasIndicator(indicator, posStart): + # found it + line, index = self.lineIndexFromPosition(posEnd) + self.ensureLineVisible(line) + self.SendScintilla(QsciScintilla.SCI_SETSEL, posEnd, posStart) + self.SendScintilla(QsciScintilla.SCI_SCROLLCARET) + return True + + return False + + def gotoNextIndicator(self, indicator, wrap): + """ + Public method to move the cursor to the next position of an indicator. + + This method ensures, that the position found is visible (i.e. unfolded + and inside the visible range). The text containing the indicator is + selected. + + @param indicator ID of the indicator to search (integer) + @param wrap flag indicating to wrap around at the beginning of the + text (boolean) + @return flag indicating if the indicator was found (boolean) + """ + pos = self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS) + docLen = self.SendScintilla(QsciScintilla.SCI_GETTEXTLENGTH) + isInIndicator = self.hasIndicator(indicator, pos) + posStart = self.getIndicatorStartPos(indicator, pos) + posEnd = self.getIndicatorEndPos(indicator, pos) + + if posStart == 0 and posEnd == docLen - 1: + # indicator does not exist + return False + + if posEnd >= docLen: + if not wrap: + return False + + isInIndicator = self.hasIndicator(indicator, 0) + posEnd = self.getIndicatorEndPos(indicator, 0) + + if isInIndicator: + # get out of it + posEnd = self.getIndicatorEndPos(indicator, posEnd) + if posEnd >= docLen: + if not wrap: + return False + + posEnd = self.getIndicatorEndPos(indicator, 0) + + newPos = posEnd + 1 + posStart = self.getIndicatorStartPos(indicator, newPos) + posEnd = self.getIndicatorEndPos(indicator, newPos) + + if self.hasIndicator(indicator, posStart): + # found it + line, index = self.lineIndexFromPosition(posEnd) + self.ensureLineVisible(line) + self.SendScintilla(QsciScintilla.SCI_SETSEL, posStart, posEnd) + self.SendScintilla(QsciScintilla.SCI_SCROLLCARET) + return True + + return False + ########################################################################### ## methods to perform folding related stuff ###########################################################################