def conserve(self): """Save the last visual selection and the mode it was made in.""" sl, sbyte = map(int, (vim_helper.eval("""line("'<")"""), vim_helper.eval("""col("'<")"""))) el, ebyte = map(int, (vim_helper.eval("""line("'>")"""), vim_helper.eval("""col("'>")"""))) sc = byte2col(sl, sbyte - 1) ec = byte2col(el, ebyte - 1) self._mode = vim_helper.eval("visualmode()") # When 'selection' is 'exclusive', the > mark is one column behind the # actual content being copied, but never before the < mark. if vim_helper.eval("&selection") == "exclusive": if not (sl == el and sbyte == ebyte): ec -= 1 _vim_line_with_eol = lambda ln: vim_helper.buf[ln] + "\n" if sl == el: text = _vim_line_with_eol(sl - 1)[sc:ec + 1] else: text = _vim_line_with_eol(sl - 1)[sc:] for cl in range(sl, el - 1): text += _vim_line_with_eol(cl) text += _vim_line_with_eol(el - 1)[:ec + 1] self._text = text
def conserve(self): """Save the last visual selection and the mode it was made in.""" sl, sbyte = map( int, (_vim.eval("""line("'<")"""), _vim.eval("""col("'<")"""))) el, ebyte = map( int, (_vim.eval("""line("'>")"""), _vim.eval("""col("'>")"""))) sc = byte2col(sl, sbyte - 1) ec = byte2col(el, ebyte - 1) self._mode = _vim.eval('visualmode()') _vim_line_with_eol = lambda ln: _vim.buf[ln] + '\n' # Remove last character for windows if platform.system() == 'Windows': add = 0 else: add = 1 if sl == el: text = _vim_line_with_eol(sl - 1)[sc:ec + add] else: text = _vim_line_with_eol(sl - 1)[sc:] for cl in range(sl, el - 1): text += _vim_line_with_eol(cl) text += _vim_line_with_eol(el - 1)[:ec + add] self._text = text
def conserve(self): """Save the last visual selection and the mode it was made in.""" sl, sbyte = map(int, (_vim.eval("""line("'<")"""), _vim.eval("""col("'<")"""))) el, ebyte = map(int, (_vim.eval("""line("'>")"""), _vim.eval("""col("'>")"""))) sc = byte2col(sl, sbyte - 1) ec = byte2col(el, ebyte - 1) self._mode = _vim.eval('visualmode()') # When 'selection' is 'exclusive', the > mark is one column behind the # actual content being copied, but never before the < mark. if _vim.eval('&selection') == 'exclusive': if not (sl == el and sbyte == ebyte): ec -= 1 _vim_line_with_eol = lambda ln: _vim.buf[ln] + '\n' if sl == el: text = _vim_line_with_eol(sl - 1)[sc:ec + 1] else: text = _vim_line_with_eol(sl - 1)[sc:] for cl in range(sl, el - 1): text += _vim_line_with_eol(cl) text += _vim_line_with_eol(el - 1)[:ec + 1] self._text = text
def cursor(self): # pylint:disable=no-self-use """ The current windows cursor. Note that this is 0 based in col and 0 based in line which is different from Vim's cursor. """ line, nbyte = vim.current.window.cursor col = byte2col(line, nbyte) return Position(line - 1, col)
def conserve(self): """Save the last visual selection ond the mode it was made in.""" sl, sbyte = map(int, (_vim.eval("""line("'<")"""), _vim.eval("""col("'<")"""))) el, ebyte = map(int, (_vim.eval("""line("'>")"""), _vim.eval("""col("'>")"""))) sc = byte2col(sl, sbyte - 1) ec = byte2col(el, ebyte - 1) self._mode = _vim.eval("visualmode()") _vim_line_with_eol = lambda ln: _vim.buf[ln] + "\n" if sl == el: text = _vim_line_with_eol(sl - 1)[sc : ec + 1] else: text = _vim_line_with_eol(sl - 1)[sc:] for cl in range(sl, el - 1): text += _vim_line_with_eol(cl) text += _vim_line_with_eol(el - 1)[: ec + 1] self._text = text
def conserve(self): sl, sbyte = map(int, (_vim.eval("""line("'<")"""), _vim.eval("""col("'<")"""))) el, ebyte = map(int, (_vim.eval("""line("'>")"""), _vim.eval("""col("'>")"""))) sc = byte2col(sl, sbyte - 1) ec = byte2col(el, ebyte - 1) self._mode = _vim.eval("visualmode()") def _vim_line_with_eol(ln): return _vim.buf[ln] + '\n' if sl == el: text = _vim_line_with_eol(sl-1)[sc:ec+1] else: text = _vim_line_with_eol(sl-1)[sc:] for cl in range(sl,el-1): text += _vim_line_with_eol(cl) text += _vim_line_with_eol(el-1)[:ec+1] self._text = text
def conserve(self): """Save the last visual selection ond the mode it was made in.""" sl, sbyte = map(int, (_vim.eval("""line("'<")"""), _vim.eval("""col("'<")"""))) el, ebyte = map(int, (_vim.eval("""line("'>")"""), _vim.eval("""col("'>")"""))) sc = byte2col(sl, sbyte - 1) ec = byte2col(el, ebyte - 1) self._mode = _vim.eval("visualmode()") _vim_line_with_eol = lambda ln: _vim.buf[ln] + '\n' if sl == el: text = _vim_line_with_eol(sl-1)[sc:ec+1] else: text = _vim_line_with_eol(sl-1)[sc:] for cl in range(sl, el-1): text += _vim_line_with_eol(cl) text += _vim_line_with_eol(el-1)[:ec+1] self._text = text
def fget(self): line, nbyte = vim.current.window.cursor col = byte2col(line, nbyte) return Position(line - 1, col)