def indentation_post_event_input_accelerators(editor, event):
    """
    Implements indentation post event input accelerators.

    :param editor: Document editor.
    :type editor: QWidget
    :param event: Event being handled.
    :type event: QEvent
    :return: Method success.
    :rtype: bool
    """

    if event.key() in (Qt.Key_Enter, Qt.Key_Return):
        cursor = editor.textCursor()
        block = cursor.block().previous()
        if block.isValid():
            indent = match = re.match(r"(\s*)", foundations.strings.to_string(block.text())).group(1)
            cursor.insertText(indent)

            indentation_symbols = get_editor_capability(editor, "indentation_symbols")
            if not indentation_symbols:
                return True

            if not block.text():
                return True

            if not foundations.strings.to_string(block.text())[-1] in indentation_symbols:
                return True

            symbols_pairs = get_editor_capability(editor, "symbols_pairs")
            if not symbols_pairs:
                return True

            cursor.insertText(editor.indent_marker)

            position = cursor.position()
            cursor.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor)
            cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.MoveAnchor)
            cursor.movePosition(QTextCursor.PreviousCharacter, QTextCursor.KeepAnchor)
            previous_character = foundations.strings.to_string(cursor.selectedText())
            cursor.setPosition(position)
            next_character = editor.get_next_character()
            if previous_character in symbols_pairs:
                if next_character in symbols_pairs.values():
                    cursor.insertBlock()
                    cursor.insertText(match)
                    cursor.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor)
                    cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.MoveAnchor)
                    editor.setTextCursor(cursor)
    return True
def indentation_post_event_input_accelerators ( editor , event ) : if event . key ( ) in ( Qt . Key_Enter , Qt . Key_Return ) : cursor = editor . textCursor ( ) block = cursor . block ( ) . previous ( ) if block . isValid ( ) : indent = match = re . match ( r"(\s*)" , foundations . strings . to_string ( block . text ( ) ) ) . group ( 1 ) cursor . insertText ( indent ) indentation_symbols = get_editor_capability ( editor , "indentation_symbols" ) if not indentation_symbols : return True if not block . text ( ) : return True if not foundations . strings . to_string ( block . text ( ) ) [ - 1 ] in indentation_symbols : return True symbols_pairs = get_editor_capability ( editor , "symbols_pairs" ) if not symbols_pairs : return True cursor . insertText ( editor . indent_marker ) position = cursor . position ( ) cursor . movePosition ( QTextCursor . PreviousBlock , QTextCursor . MoveAnchor ) cursor . movePosition ( QTextCursor . EndOfLine , QTextCursor . MoveAnchor ) cursor . movePosition ( QTextCursor . PreviousCharacter , QTextCursor . KeepAnchor ) previous_character = foundations . strings . to_string ( cursor . selectedText ( ) ) cursor . setPosition ( position ) next_character = editor . get_next_character ( ) if previous_character in symbols_pairs : if next_character in symbols_pairs . values ( ) : cursor . insertBlock ( ) cursor . insertText ( match ) cursor . movePosition ( QTextCursor . PreviousBlock , QTextCursor . MoveAnchor ) cursor . movePosition ( QTextCursor . EndOfLine , QTextCursor . MoveAnchor ) editor . setTextCursor ( cursor ) return True
Implements indentation post event input accelerators.

    :param editor: Document editor.
    :type editor: QWidget
    :param event: Event being handled.
    :type event: QEvent
    :return: Method success.
    :rtype: bool