'Searches a text in a text document.
:param text_cursor: Current text cursor
:param search_txt: Text to search
:param search_flags: QTextDocument.FindFlags
:returns: the list of occurrences, the current occurrence index
:rtype: tuple([], int)'

def search_text(self, text_cursor, search_txt, search_flags):

    def compare_cursors(cursor_a, cursor_b):
        '\n                                                Compares    two    QTextCursor.\n\n                                                :param    cursor_a:    cursor    a\n                                                :param    cursor_b:    cursor    b\n\n                                                :returns;    True    if    both    cursor    are    identical    (same    position,    same\n                                                                selection)\n                                                '
        return ((cursor_b.selectionStart() >= cursor_a.selectionStart()) and (cursor_b.selectionEnd() <= cursor_a.selectionEnd()))
    text_document = self._editor.document()
    occurrences = []
    index = (-1)
    cursor = text_document.find(search_txt, 0, search_flags)
    original_cursor = text_cursor
    while (not cursor.isNull()):
        if compare_cursors(cursor, original_cursor):
            index = len(occurrences)
        occurrences.append((cursor.selectionStart(), cursor.selectionEnd()))
        cursor.setPosition((cursor.position() + 1))
        cursor = text_document.find(search_txt, cursor, search_flags)
    return (occurrences, index)
