Exemplo n.º 1
0
 def append(self, line, line_number=-1):
     """
     Same as vim.current.window.buffer.append(), but with tracking changes.
     """
     if line_number < 0:
         line_number = len(self)
     if not isinstance(line, list):
         line = [line]
     self[line_number:line_number] = [as_vimencoding(l) for l in line]
Exemplo n.º 2
0
 def append(self, line, line_number=-1):
     """
     Same as vim.current.window.buffer.append(), but with tracking changes.
     """
     if line_number < 0:
         line_number = len(self)
     if not isinstance(line, list):
         line = [line]
     self[line_number:line_number] = [as_vimencoding(l) for l in line]
Exemplo n.º 3
0
    def __setitem__(self, key, value):
        """
        Behaves as vim.current.window.buffer.__setitem__ except it tracks
        changes and applies them to the current snippet stack.
        """
        if isinstance(key, slice):
            value = [as_vimencoding(line) for line in value]
            changes = list(self._get_diff(key.start, key.stop, value))
            self._buffer[key.start : key.stop] = [line.strip("\n") for line in value]
        else:
            value = as_vimencoding(value)
            changes = list(self._get_line_diff(key, self._buffer[key], value))
            self._buffer[key] = value

        self._change_tick += 1

        if self._forward_edits:
            for change in changes:
                self._apply_change(change)
            if self._snippets_stack:
                self._vstate.remember_buffer(self._snippets_stack[0])
Exemplo n.º 4
0
    def __setitem__(self, key, value):
        """
        Behaves as vim.current.window.buffer.__setitem__ except it tracks
        changes and applies them to the current snippet stack.
        """
        if isinstance(key, slice):
            value = [as_vimencoding(line) for line in value]
            changes = list(self._get_diff(key.start, key.stop, value))
            self._buffer[key.start:key.stop] = [
                line.strip("\n") for line in value
            ]
        else:
            value = as_vimencoding(value)
            changes = list(self._get_line_diff(key, self._buffer[key], value))
            self._buffer[key] = value

        self._change_tick += 1

        if self._forward_edits:
            for change in changes:
                self._apply_change(change)
            if self._snippets_stack:
                self._vstate.remember_buffer(self._snippets_stack[0])
Exemplo n.º 5
0
 def __setslice__(self, i, j, text): # pylint:disable=no-self-use
     vim.current.buffer[i:j] = [as_vimencoding(l) for l in text]
Exemplo n.º 6
0
 def __setitem__(self, idx, text):
     if isinstance(idx, slice): # Py3
         return self.__setslice__(idx.start, idx.stop, text)
     vim.current.buffer[idx] = as_vimencoding(text)
Exemplo n.º 7
0
 def __setslice__(self, i, j, text):
     vim.current.buffer[i:j] = [as_vimencoding(l) for l in text]
Exemplo n.º 8
0
 def __setitem__(self, idx, text):
     if isinstance(idx, slice):  # Py3
         return self.__setslice__(idx.start, idx.stop, text)
     vim.current.buffer[idx] = as_vimencoding(text)
Exemplo n.º 9
0
def eval(s):
    rv = vim.eval(as_vimencoding(s))
    if not isinstance(rv, (dict, list)):
        return as_unicode(rv)
    return rv
Exemplo n.º 10
0
def command(s):
    return as_unicode(vim.command(as_vimencoding(s)))
Exemplo n.º 11
0
def command(cmd):
    """Wraps vim.command."""
    return as_unicode(vim.command(as_vimencoding(cmd)))
Exemplo n.º 12
0
 def __setslice__(self, i, j, text):  # pylint:disable=no-self-use
     vim.current.buffer[i:j] = [as_vimencoding(l) for l in text]
Exemplo n.º 13
0
 def __setslice__(self, i, j, text):
     vim.current.buffer[i:j] = [ as_vimencoding(l) for l in text ]
Exemplo n.º 14
0
def eval(s):
    rv = vim.eval(as_vimencoding(s))
    if not isinstance(rv, (dict, list)):
        return as_unicode(rv)
    return rv
Exemplo n.º 15
0
def command(s):
    return as_unicode(vim.command(as_vimencoding(s)))
Exemplo n.º 16
0
def command(cmd):
    """Wraps vim.command."""
    return as_unicode(vim.command(as_vimencoding(cmd)))
Exemplo n.º 17
0
def eval(text):
    """Wraps vim.eval."""
    rv = vim.eval(as_vimencoding(text))
    if not isinstance(rv, (dict, list)):
        return as_unicode(rv)
    return rv
Exemplo n.º 18
0
def eval(text):
    """Wraps vim.eval."""
    rv = vim.eval(as_vimencoding(text))
    if not isinstance(rv, (dict, list)):
        return as_unicode(rv)
    return rv