Esempio n. 1
0
    def run_command(self, start, end, command, clear=False):
        """To Run the command as the given command"""
        self.last_command = command

        if command and settings.get('bufname_expansion', bool):
            command = misc.expand_chars(command, '%', vim.current.buffer.name)

        if command and settings.get('selection_expansion', bool):
            command = misc.expand_chars(
                command, '@', '\r'.join(vim.current.buffer[start - 1:end]))

        if command and settings.get('function_expansion', bool):
            try:
                command = misc.expand_functions(command)
            except NameError:  # the function does not exist
                v.echo('unknown function')
                return
            except ValueError:  # bad arguments
                v.echo('bad arguments')
                return

        if not command or settings.get('always_clear_screen', bool):
            clear = True

        self.run(command, clear=clear)
Esempio n. 2
0
    def run_command(self, start, end, command, clear=False):
        """To Run the command as the given command"""
        self.last_command = command

        if command and settings.get('bufname_expansion', bool):
            command = misc.expand_chars(command, '%', vim.current.buffer.name)

        if command and settings.get('selection_expansion', bool):
            command = misc.expand_chars(
                command, '@', '\r'.join(vim.current.buffer[start-1:end]))

        if command and settings.get('function_expansion', bool):
            try:
                command = misc.expand_functions(command)
            except NameError:  # the function does not exist
                v.echo('unknown function')
                return
            except ValueError:  # bad arguments
                v.echo('bad arguments')
                return

        if not command or settings.get('always_clear_screen', bool):
            clear = True

        self.run(command, clear=clear)
Esempio n. 3
0
 def run_alias(self, start, end, alias, clear=False):
     """Lookup a command given its alias and execute it."""
     command = settings.get('aliases').get(alias)
     if command:
         self.run_command(start, end, command, clear)
     else:
         v.echo("'{}' alias not found".format(alias))
Esempio n. 4
0
 def __init__(self):
     self.last_command = ''
     self.term = settings.get('terminal').lower()
     scpt_loc = os.path.dirname(
         vim.eval('globpath(&rtp, "autoload/tube.vim")')) + "/applescript/"
     self.BASE_CMD = "osascript " + scpt_loc + self.term + ".scpt"
     self.BASE_CMD_INLINE = "osascript -e"
Esempio n. 5
0
 def run_alias(self, start, end, alias, clear=False):
     """Lookup a command given its alias and execute it."""
     command = settings.get('aliases').get(alias)
     if command:
         self.run_command(start, end, command, clear)
     else:
         v.echo("'{}' alias not found".format(alias))
Esempio n. 6
0
 def show_aliases(self):
     """To show all defined aliases."""
     aliases = settings.get('aliases')
     if aliases:
         print('+ aliases')
         for i, alias in enumerate(aliases):
             conn = '└─ ' if i == len(aliases) - 1 else '├─ '
             print(conn + alias + ': ' + aliases[alias])
     else:
         v.echo('no aliases found')
Esempio n. 7
0
 def show_aliases(self):
     """To show all defined aliases."""
     aliases = settings.get('aliases')
     if aliases:
         print('+ aliases')
         for i, alias in enumerate(aliases):
             conn = '└─ ' if i == len(aliases)-1 else '├─ '
             print(conn + alias + ': ' + aliases[alias])
     else:
         v.echo('no aliases found')
Esempio n. 8
0
    def callf(match):
        """Call the matched function and inject its return value."""
        fun_name = match.group("fun")
        args = match.group("args")
        args_separator = settings.get("funargs_separator")

        if args:
            argv = [escape(a.strip()) for a in args.split(args_separator)]
        else:
            argv = []

        if fun_name:
            if "1" == vim.eval("exists('*{0}')".format(fun_name)):
                try:
                    raw = vim.eval("call('{0}',[{1}])".format(fun_name, ",".join(argv)))
                    return raw.replace("\\", "\\\\")

                except vim.error:
                    pass
            else:
                raise NameError  # unkwown function
Esempio n. 9
0
    def callf(match):
        """Call the matched function and inject its return value."""
        fun_name = match.group('fun')
        args = match.group('args')
        args_separator = settings.get('funargs_separator')

        if args:
            argv = [escape(a.strip()) for a in args.split(args_separator)]
        else:
            argv = []

        if fun_name:
            if '1' == vim.eval("exists('*{0}')".format(fun_name)):
                try:
                    raw = vim.eval("call('{0}',[{1}])".format(
                        fun_name, ','.join(argv)))
                    return raw.replace('\\', '\\\\')

                except vim.error:
                    pass
            else:
                raise NameError  # unkwown function
Esempio n. 10
0
 def __init__(self):
     self.last_command = ''
     self.term = settings.get('terminal').lower()
     scpt_loc = os.path.dirname(vim.eval('globpath(&rtp, "autoload/tube.vim")')) + "/applescript/"
     self.BASE_CMD = "osascript " + scpt_loc + self.term + ".scpt"
     self.BASE_CMD_INLINE = "osascript -e"