Exemplo n.º 1
0
    def motion(self, name):
        if self.action in INCOMPLETE_ACTIONS:
            # The .action should handle this.
            self.action = name
            return

        # HACK: Translate vi_enter to \n if we're expecting user input.
        # This enables r\n, for instance.
        # XXX: I don't understand why the enter key is captured as a motion in this case, though;
        # the catch-all key binding for user input should have intercepted it.
        if self.expecting_user_input and name == 'vi_enter':
            self.view.run_command('collect_user_input', {'character': '\n'})
            return

        # Check for digraphs like gg in dgg.
        stored_motion = self.motion
        if stored_motion and name:
            name, type_ = digraphs.get((stored_motion, name), (None, None))
            if type_ != DIGRAPH_MOTION:
                # We know there's an action because we only check for digraphs  when there is one.
                self.cancel_action = True
                return

        motion_name = MOTION_TRANSLATION_TABLE.get((self.action, name), name)

        input_type, input_parser = INPUT_FOR_MOTIONS.get(motion_name, (None, None))
        if input_type == INPUT_IMMEDIATE:
            self.expecting_user_input = True
            self.user_input_parsers.append(input_parser)

        if not input_type and self.user_input_parsers:
            self.expecting_user_input = True

        self.settings.vi['motion'] = motion_name
        self.display_partial_command()
Exemplo n.º 2
0
    def motion(self, name):
        if self.action in INCOMPLETE_ACTIONS:
            # The .action should handle this.
            self.action = name
            return

        # HACK: Translate vi_enter to \n if we're expecting user input.
        # This enables r\n, for instance.
        # XXX: I don't understand why the enter key is captured as a motion in this case, though;
        # the catch-all key binding for user input should have intercepted it.
        if self.expecting_user_input and name == 'vi_enter':
            self.view.run_command('collect_user_input', {'character': '\n'})
            return

        # Check for digraphs like gg in dgg.
        stored_motion = self.motion
        if stored_motion and name:
            name, type_ = digraphs.get((stored_motion, name), (None, None))
            if type_ != DIGRAPH_MOTION:
                # We know there's an action because we only check for digraphs  when there is one.
                self.cancel_action = True
                return

        motion_name = MOTION_TRANSLATION_TABLE.get((self.action, name), name)

        input_type, input_parser = INPUT_FOR_MOTIONS.get(
            motion_name, (None, None))
        if input_type == INPUT_IMMEDIATE:
            self.expecting_user_input = True
            self.user_input_parsers.append(input_parser)

        if not input_type and self.user_input_parsers:
            self.expecting_user_input = True

        self.settings.vi['motion'] = motion_name
        self.display_partial_command()
Exemplo n.º 3
0
 def motion(self, name):
     self.settings.vi['motion'] = MOTION_TRANSLATION_TABLE.get(
         (self.action, name), name)
Exemplo n.º 4
0
 def motion(self, name):
     self.settings.vi["motion"] = MOTION_TRANSLATION_TABLE.get((self.action, name), name)