Exemple #1
0
    def _update(self, done, not_done):
        path = _vim.eval('expand("%")')
        if path is None:
            path = ""
        fn = os.path.basename(path)

        ct = self.current_text
        self._snip._reset(ct)
        local_d = self._locals

        local_d.update({
            't': _Tabs(self._parent),
            'fn': fn,
            'path': path,
            'cur': ct,
            'res': ct,
            'i': self._snip.i,
            'snip' : self._snip,
        })

        compatible_exec(self._code, self._globals, local_d)

        rv = as_unicode(self._snip.rv if self._snip._rv_changed
                else as_unicode(local_d['res']))

        if ct != rv:
            self.overwrite(rv)
            return False
        return True
Exemple #2
0
    def _update(self, done, not_done):
        path = _vim.eval('expand("%")')
        if path is None:
            path = ""
        fn = os.path.basename(path)

        ct = self.current_text
        self._snip._reset(ct)
        local_d = self._locals

        local_d.update({
            't': _Tabs(self._parent),
            'fn': fn,
            'path': path,
            'cur': ct,
            'res': ct,
            'snip': self._snip,
        })

        compatible_exec(self._code, self._globals, local_d)

        rv = as_unicode(self._snip.rv if self._snip.
                        _rv_changed else as_unicode(local_d['res']))

        if ct != rv:
            self.overwrite(rv)
            return False
        return True
Exemple #3
0
    def _update(self, done, not_done):
        path = _vim.eval('expand("%")')
        if path is None:
            path = ""
        fn = os.path.basename(path)

        ct = self.current_text
        self._snip._reset(ct)
        local_d = self._locals

        local_d.update({"t": _Tabs(self._parent), "fn": fn, "path": path, "cur": ct, "res": ct, "snip": self._snip})

        compatible_exec(self._code, self._globals, local_d)

        rv = as_unicode(self._snip.rv if self._snip._rv_changed else as_unicode(local_d["res"]))

        if ct != rv:
            self.overwrite(rv)
            return False
        return True
Exemple #4
0
    def __init__(self, parent, token):
        code = token.code.replace("\\`", "`")

        # Find our containing snippet for snippet local data
        snippet = parent
        while snippet:
            try:
                self._locals = snippet.locals
                break
            except AttributeError:
                snippet = snippet._parent
        self._snip = SnippetUtil(token.indent)

        self._globals = {}
        globals = snippet.globals.get("!p", [])
        compatible_exec("\n".join(globals).replace("\r\n", "\n"), self._globals)

        # Add Some convenience to the code
        self._code = "import re, os, vim, string, random\n" + code

        NoneditableTextObject.__init__(self, parent, token)
Exemple #5
0
    def __init__(self, parent, token):
        code = token.code.replace("\\`", "`")

        # Find our containing snippet for snippet local data
        snippet = parent
        while snippet:
            try:
                self._locals = snippet.locals
                t = snippet.visual_content.text
                m = snippet.visual_content.mode
                break
            except AttributeError:
                snippet = snippet._parent
        self._snip = SnippetUtil(token.indent, m, t)

        self._globals = {}
        globals = snippet.globals.get("!p", [])
        compatible_exec("\n".join(globals).replace("\r\n", "\n"), self._globals)

        # Add Some convenience to the code
        self._code = "import re, os, vim, string, random\n" + code

        NoneditableTextObject.__init__(self, parent, token)