def _clear_jump_marks(self, table): """To clear jump marks.""" vim.command("try|undojoin|catch|endtry") # restore characters for mark, tpl in table.items(): pos, old = tpl row, col = pos[0]-1, pos[1]+1 v.subst_char(v.buf(), old, row, col) vim.command("setl nomodified") v.redraw()
def wrapper(self, *args, **kwargs): if self.refresh_cache or vim.eval("&mod") == '1': self.parser.feed(v.buf()) if self.parser.success: self.cache = self.parser.tree self.refresh_cache = False else: v.clear_hl('BreezeJumpMark', 'BreezeShade') self.refresh_cache = True return else: self.parser.tree = self.cache return f(self, *args, **kwargs)
def _show_jump_marks(self, curr_pos, backward=False): """To display jump marks.""" top, bot = v.window_bundaries() v.highlight("BreezeShade", "\\%>{0}l\\%<{1}l".format(top-1, bot+1)) table = {} jump_marks = list(string.letters) vim.command("setl modifiable noreadonly") vim.command("try|undojoin|catch|endtry") nodes = filter(lambda n: top <= n.start[0] <= bot, self.plug.parser.all_nodes()) nodes = reversed(nodes) if backward else nodes for node in nodes: if not jump_marks: break # both trow and tcol are 1-indexed trow, tcol = node.start[0], node.start[1] crow, ccol = curr_pos[0], curr_pos[1]-1 if backward: if not (trow < crow or (trow == crow and tcol < ccol)): continue else: if not (trow > crow or (trow == crow and tcol > ccol)): continue old = v.subst_char(v.buf(), jump_marks[0], trow-1, tcol+1) self._highlight_jump_mark((trow, tcol+2)) table[jump_marks.pop(0)] = (node.start, old) vim.command("setl nomodified") v.redraw() return table