Replace the currently selected string with the new one.

        The method return **False** if another match to the right
        of the cursor exists, and **True** if not (ie. when the
        end of the document was reached).

def replaceSelected(self):
        """
        Replace the currently selected string with the new one.

        The method return **False** if another match to the right
        of the cursor exists, and **True** if not (ie. when the
        end of the document was reached).
        """
        SCI = self.qteWidget

        # Restore the original styling.
        self.qteWidget.SCISetStylingEx(0, 0, self.styleOrig)

        # Select the region spanned by the string to replace.
        start, stop = self.matchList[self.selMatchIdx]
        line1, col1 = SCI.lineIndexFromPosition(start)
        line2, col2 = SCI.lineIndexFromPosition(stop)
        SCI.setSelection(line1, col1, line2, col2)

        text = SCI.selectedText()
        text = re.sub(self.toReplace, self.toReplaceWith, text)

        # Replace that region with the new string and move the cursor
        # to the end of that string.
        SCI.replaceSelectedText(text)
        line, col = SCI.lineIndexFromPosition(start + len(text))
        SCI.setCursorPosition(line, col)

        # Backup the new document style bits.
        line, col = SCI.getNumLinesAndColumns()
        text, style = self.qteWidget.SCIGetStyledText((0, 0, line, col))
        self.styleOrig = style

        # Determine if this was the last entry in the match list.
        if len(self.matchList) == self.selMatchIdx + 1:
            return False
        else:
            self.highlightAllMatches()
            return True