Ejemplo n.º 1
0
    def on_activate(self, input):
        """The user has pressed enter"""

        if input == '':
            execute_action('search')
Ejemplo n.º 2
0
def toggle_next_field(editor=None):
    """
    When in alias expansion, toggle to next field
    """

    if not editor:
        editor = EditorBuffer.get()

    try:
        reset_overlay(editor)

        editor.apply_overlay(editor.aliases_background_overlay_1,
                             editor.beginning_of_buffer(),
                             editor.end_of_buffer())

        editor.apply_overlay(
            editor.aliases_background_overlay,
            editor.alias_begin_mark.location().beginning_of_line(),
            editor.alias_end_mark.location())

        i = editor.current_alias_mark_index

        if i is None:
            return

        if i >= len(editor.alias_marks):
            if editor.last_alias_mark:
                editor.current_view().goto(editor.last_alias_mark.location())
                exit_alias_expand(editor)
                # ??? Doesn't work every time if executed only once
                execute_action("autoindent selection")
                execute_action("autoindent selection")
            else:
                exit_alias_expand(editor)
            return

        editor.alias_move_expected = True
        try:
            editor.remove_all_slave_cursors()
            marks = editor.alias_marks[i]

            # Delete the placeholder text
            for mark_start, mark_end in marks:
                lstart = mark_start.location()
                lend = mark_end.location().forward_char(-1)
                if lend >= lstart:
                    editor.delete(lstart, lend)

            editor.current_view().goto(marks[0][0].location())
            try:
                execute_action("autoindent selection")
            except Exception:
                pass

            reset_overlay(editor)

            # Add multi cursors for every other mark
            if len(marks) > 1:
                for mark_begin, mark_end in marks[1:]:
                    editor.add_cursor(mark_begin.location())

            editor.current_alias_mark_index += 1
        finally:
            editor.alias_move_expected = False

    except AttributeError:
        return