Пример #1
0
    def run(self, text, count=None):
        """Parse a command from a line of text and run it.

        Args:
            text: The text to parse.
            count: The count to pass to the command.
        """
        for result in self.parse_all(text):
            mode_manager = objreg.get('mode-manager', scope='window',
                                      window=self._win_id)
            cur_mode = mode_manager.mode

            if result.cmd.no_replace_variables:
                args = result.args
            else:
                args = replace_variables(self._win_id, result.args)
            if count is not None:
                if result.count is not None:
                    raise cmdexc.CommandMetaError("Got count via command and "
                                                  "prefix!")
                result.cmd.run(self._win_id, args, count=count)
            elif result.count is not None:
                result.cmd.run(self._win_id, args, count=result.count)
            else:
                result.cmd.run(self._win_id, args)

            if result.cmdline[0] != 'repeat-command':
                last_command[cur_mode] = (
                    self._parse_count(text)[1],
                    count if count is not None else result.count)
Пример #2
0
    def run(self, text, count=None):
        """Parse a command from a line of text and run it.

        Args:
            text: The text to parse.
            count: The count to pass to the command.
        """
        for result in self.parse_all(text):
            args = replace_variables(self._win_id, result.args)
            if count is not None:
                if result.count is not None:
                    raise cmdexc.CommandMetaError("Got count via command and "
                                                  "prefix!")
                result.cmd.run(self._win_id, args, count=count)
            elif result.count is not None:
                result.cmd.run(self._win_id, args, count=result.count)
            else:
                result.cmd.run(self._win_id, args)