plugin/threesomelib/util/bufferlib.py @ 02506b7b8b92

I has a loupe!
author Steve Losh <steve@stevelosh.com>
date Sun, 12 Jun 2011 23:33:31 -0400
parents plugin/threesomelib/util/buffers.py@adb7e3942b34
children bb3247356f22
import vim


class Buffer(object):
    def __init__(self, i):
        self.number = i + 1
        self._buffer = vim.buffers[i]
        self.name = self._buffer.name

    def open(self):
        vim.command('%dbuffer' % self.number)

    def set_lines(self, lines):
        self._buffer[:] = lines

    @property
    def lines(self):
        for line in self._buffer:
            yield line


class _BufferList(object):
    @property
    def original(self):
        return Buffer(0)

    @property
    def one(self):
        return Buffer(1)

    @property
    def two(self):
        return Buffer(2)

    @property
    def result(self):
        return Buffer(3)

buffers = _BufferList()