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