예제 #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]
예제 #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]
예제 #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])
예제 #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])
예제 #5
0
파일: _vim.py 프로젝트: alex-env/dotfiles
 def __setslice__(self, i, j, text): # pylint:disable=no-self-use
     vim.current.buffer[i:j] = [as_vimencoding(l) for l in text]
예제 #6
0
파일: _vim.py 프로젝트: alex-env/dotfiles
 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)
예제 #7
0
 def __setslice__(self, i, j, text):
     vim.current.buffer[i:j] = [as_vimencoding(l) for l in text]
예제 #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)
예제 #9
0
def eval(s):
    rv = vim.eval(as_vimencoding(s))
    if not isinstance(rv, (dict, list)):
        return as_unicode(rv)
    return rv
예제 #10
0
def command(s):
    return as_unicode(vim.command(as_vimencoding(s)))
예제 #11
0
def command(cmd):
    """Wraps vim.command."""
    return as_unicode(vim.command(as_vimencoding(cmd)))
예제 #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]
예제 #13
0
파일: _vim.py 프로젝트: zhaocai/ultisnips
 def __setslice__(self, i, j, text):
     vim.current.buffer[i:j] = [ as_vimencoding(l) for l in text ]
예제 #14
0
파일: _vim.py 프로젝트: zhaocai/ultisnips
def eval(s):
    rv = vim.eval(as_vimencoding(s))
    if not isinstance(rv, (dict, list)):
        return as_unicode(rv)
    return rv
예제 #15
0
파일: _vim.py 프로젝트: zhaocai/ultisnips
def command(s):
    return as_unicode(vim.command(as_vimencoding(s)))
예제 #16
0
파일: _vim.py 프로젝트: alex-env/dotfiles
def command(cmd):
    """Wraps vim.command."""
    return as_unicode(vim.command(as_vimencoding(cmd)))
예제 #17
0
파일: _vim.py 프로젝트: alex-env/dotfiles
def eval(text):
    """Wraps vim.eval."""
    rv = vim.eval(as_vimencoding(text))
    if not isinstance(rv, (dict, list)):
        return as_unicode(rv)
    return rv
예제 #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