def highlight_curr_element(self): """Highlights opening and closing tags of the current element.""" v.clear_hl('BreezeHl') node = self.parser.get_current_node() if not node: return line, scol = node.start[0], node.start[1] + 1 ecol = scol + len(node.tag) + 1 patt = "\\%{0}l\\%>{1}c\%<{2}c".format(line, scol, ecol) v.highlight("BreezeHl", patt) if node.tag not in misc.empty_tags: line, scol = node.end[0], node.end[1] + 1 ecol = scol + len(node.tag) + 2 patt = "\\%{0}l\\%>{1}c\%<{2}c".format(line, scol, ecol) v.highlight("BreezeHl", patt)
def highlight_curr_element(self): """Highlights opening and closing tags of the current element.""" v.clear_hl('BreezeHl') node = self.parser.get_current_node() if not node: return line, scol = node.start[0], node.start[1]+1 ecol = scol + len(node.tag) + 1 patt = "\\%{0}l\\%>{1}c\%<{2}c".format(line, scol, ecol) v.highlight("BreezeHl", patt) if node.tag not in misc.empty_tags: line, scol = node.end[0], node.end[1]+1 ecol = scol + len(node.tag) + 2 patt = "\\%{0}l\\%>{1}c\%<{2}c".format(line, scol, ecol) v.highlight("BreezeHl", patt)
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
def _highlight_jump_mark(self, pos, special=False): """To highligt the jump mark at the given position.""" v.highlight("BreezeJumpMark", "\\%{0}l\\%{1}c".format(*pos))