class tessera: def __init__(self, directory="."): self._tesserae = os.path.relpath(os.path.join(directory, ".tesserae")) config = TesseraConfig(os.path.join(self._tesserae, "config")) try: self.te = GitTessera(config) except NotGitRepository: self.te = None self.t = None def list(self): if not self.te: return self.files = self.te.ls() self.index = 0 vim.command(":e " + vim.eval("tempname()")) _display(self.files) vim.command(":nmap <Enter> :py tessera.open()<Enter>") def next(self): if not self.te: return vim.command(":e %s" % self.files[self.index]) self.index += 1 def open(self): if not self.te: return (row, col) = vim.current.window.cursor vim.command(":e %s" % self.files[row - (len(_headline) + 1)].filename) vim.command(":au BufDelete <buffer> :py tessera.check()") def check(self): if vim.current.buffer.options["modified"] == "modified": vim.command(":confirm q") def create(self, title): if not self.te: return Tessera._tesserae = self._tesserae self.t = self.te.create() if title is "" else self.te.create(title) vim.command(":e " + self.t.filename) def commit(self): if not self.te: return if self.t is None: return vim.command(":w") self.te.commit(self.t)
def __init__(self, directory="."): self._tesserae = os.path.relpath(os.path.join(directory, ".tesserae")) config = TesseraConfig(os.path.join(self._tesserae, "config")) try: self.te = GitTessera(config) except NotGitRepository: self.te = None self.t = None