Exemplo n.º 1
0
 def conv(obj):
     if isinstance(obj, list):
         rv = as_unicode("[" + ",".join(conv(o) for o in obj) + "]")
     elif isinstance(obj, dict):
         rv = as_unicode(
             "{" + ",".join(["%s:%s" % (conv(key), conv(value)) for key, value in obj.iteritems()]) + "}"
         )
     else:
         rv = as_unicode('"%s"') % as_unicode(obj).replace('"', '\\"')
     return rv
Exemplo n.º 2
0
 def conv(obj):
     if isinstance(obj, list):
         rv = as_unicode('[' + ','.join(conv(o) for o in obj) + ']')
     elif isinstance(obj, dict):
         rv = as_unicode('{' + ','.join([
             "%s:%s" % (conv(key), conv(value))
             for key, value in obj.iteritems()]) + '}')
     else:
         rv = as_unicode('"%s"') % as_unicode(obj).replace('"', '\\"')
     return rv
Exemplo n.º 3
0
 def conv(obj):
     if isinstance(obj, list):
         rv = as_unicode('[' + ','.join(conv(o) for o in obj) + ']')
     elif isinstance(obj, dict):
         rv = as_unicode('{' + ','.join([
             "%s:%s" % (conv(key), conv(value))
             for key, value in obj.iteritems()
         ]) + '}')
     else:
         rv = as_unicode('"%s"') % as_unicode(obj).replace('"', '\\"')
     return rv
Exemplo n.º 4
0
    def _do_update(self):
        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),
            'fn': fn,
            'path': path,
            'cur': ct,
            'res': ct,
            'snip': self._snip,
        })

        self._code = self._code.replace("\r\n", "\n")
        compatible_exec(self._code, self._globals, local_d)

        if self._snip._rv_changed:
            self.current_text = self._snip.rv
        else:
            self.current_text = as_unicode(local_d["res"])
Exemplo n.º 5
0
    def _do_update(self):
        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),
            'fn': fn,
            'path': path,
            'cur': ct,
            'res': ct,
            'snip' : self._snip,
        })

        self._code = self._code.replace("\r\n", "\n")
        compatible_exec(self._code, self._globals, local_d)

        if self._snip._rv_changed:
            self.current_text = self._snip.rv
        else:
            self.current_text = as_unicode(local_d["res"])
Exemplo n.º 6
0
    def translate(self, s):
        langmap = as_unicode(vim.eval("&langmap").strip())
        if langmap == "":
            return s

        if langmap not in self._maps:
            self._create_translation(langmap)

        for f,t in zip(*self._maps[langmap]):
            s = s.replace(f,t)
        return s
Exemplo n.º 7
0
def debug(s):
    s = as_unicode(s)
    f = open("/tmp/file.txt","ba")
    f.write((s + '\n').encode("utf-8"))
    f.close()
Exemplo n.º 8
0
 def __getitem__(self, a):
     if isinstance(a, slice):
         return [as_unicode(k) for k in vim.current.buffer[a]]
     return as_unicode(vim.current.buffer[a])
Exemplo n.º 9
0
 def __init__(self, textblock):
     # We do not use splitlines() here because it handles cases like 'text\n'
     # differently than we want it here
     self._lines = [
         as_unicode(l) for l in textblock.replace('\r', '').split('\n')
     ]
Exemplo n.º 10
0
def debug(s):
    s = as_unicode(s)
    f = open("/tmp/file.txt", "ba")
    f.write((s + '\n').encode("utf-8"))
    f.close()
Exemplo n.º 11
0
 def _do_update(self):
     self.current_text = as_unicode(vim.eval(self._code))
Exemplo n.º 12
0
 def fget(self):
     return as_unicode(self._current_text)
Exemplo n.º 13
0
 def __getitem__(self, a):
     if isinstance(a, slice):
         return [ as_unicode(k) for k in vim.current.buffer[a] ]
     return as_unicode(vim.current.buffer[a])
Exemplo n.º 14
0
 def __init__(self, textblock):
     # We do not use splitlines() here because it handles cases like 'text\n'
     # differently than we want it here
     self._lines = [ as_unicode(l) for l in textblock.replace('\r','').split('\n') ]
Exemplo n.º 15
0
 def _do_update(self):
     self.current_text = as_unicode(vim.eval(self._code))
Exemplo n.º 16
0
 def fget(self):
     return as_unicode(self._current_text)