def METHOD_NAME(self, edit, ev):
    """Return None, False or True.
    None when no horizontal arrow key was pressed,
    True when the event was handled,
    False when the event was not handled and should be handled normally.
    """
    cursor = edit.textCursor()
    pos = cursor.position()
    if ev.matches(QKeySequence.MoveToPreviousLine) or ev.matches(QKeySequence.MoveToPreviousPage):
        cursor.movePosition(QTextCursor.Up)
        if cursor.position() == pos:    # no move
            cursor.movePosition(QTextCursor.Start)
            edit.setTextCursor(cursor)
            return True
        return False
    elif ev.matches(QKeySequence.SelectPreviousLine) or ev.matches(QKeySequence.SelectPreviousPage):
        cursor.movePosition(QTextCursor.Up, QTextCursor.KeepAnchor)
        if cursor.position() == pos:    # no move
            cursor.movePosition(QTextCursor.Start, QTextCursor.KeepAnchor)
            edit.setTextCursor(cursor)
            return True
        return False
    elif ev.matches(QKeySequence.MoveToNextLine) or ev.matches(QKeySequence.MoveToNextPage):
        cursor.movePosition(QTextCursor.Down)
        if cursor.position() == pos:    # no move
            cursor.movePosition(QTextCursor.End)
            edit.setTextCursor(cursor)
            return True
        return False
    elif ev.matches(QKeySequence.SelectNextLine) or ev.matches(QKeySequence.SelectNextPage):
        cursor.movePosition(QTextCursor.Down, QTextCursor.KeepAnchor)
        if cursor.position() == pos:    # no move
            cursor.movePosition(QTextCursor.End, QTextCursor.KeepAnchor)
            edit.setTextCursor(cursor)
            return True
        return False