Example #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
Example #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
Example #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
Example #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"])
Example #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"])
Example #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
Example #7
0
def debug(s):
    s = as_unicode(s)
    f = open("/tmp/file.txt","ba")
    f.write((s + '\n').encode("utf-8"))
    f.close()
Example #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])
Example #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')
     ]
Example #10
0
def debug(s):
    s = as_unicode(s)
    f = open("/tmp/file.txt", "ba")
    f.write((s + '\n').encode("utf-8"))
    f.close()
Example #11
0
 def _do_update(self):
     self.current_text = as_unicode(vim.eval(self._code))
Example #12
0
 def fget(self):
     return as_unicode(self._current_text)
Example #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])
Example #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') ]
Example #15
0
 def _do_update(self):
     self.current_text = as_unicode(vim.eval(self._code))
Example #16
0
 def fget(self):
     return as_unicode(self._current_text)