示例#1
0
 def goto_first_sibling(self):
     """To move the cursor to the first sibling node."""
     node = self.parser.get_current_node()
     if node and node.parent:
         row, col = node.parent.children[0].start
         if not settings.get("jump_to_angle_bracket", bool):
             col += 1
         v.cursor((row, col))
示例#2
0
 def goto_last_child(self):
     """To move the cursor to the last child of the current node."""
     node = self.parser.get_current_node()
     if node and node.children:
         row, col = node.children[-1].start
         if not settings.get("jump_to_angle_bracket", bool):
             col += 1
         v.cursor((row, col))
示例#3
0
 def goto_last_child(self):
     """To move the cursor to the last child of the current node."""
     node = self.parser.get_current_node()
     if node and node.children:
         row, col = node.children[-1].start
         if not settings.get("jump_to_angle_bracket", bool):
             col += 1
         v.cursor((row, col))
示例#4
0
 def goto_first_sibling(self):
     """To move the cursor to the first sibling node."""
     node = self.parser.get_current_node()
     if node and node.parent:
         row, col = node.parent.children[0].start
         if not settings.get("jump_to_angle_bracket", bool):
             col += 1
         v.cursor((row, col))
示例#5
0
 def goto_parent(self):
     """To move the cursor to the parent of the current node."""
     node = self.parser.get_current_node()
     if node:
         if node.parent.tag != "root":
             row, col = node.parent.start
             if not settings.get("jump_to_angle_bracket", bool):
                 col += 1
             v.cursor((row, col))
         else:
             v.echom("no parent found")
示例#6
0
 def goto_prev_sibling(self):
     """To move the cursor to the previous sibling node."""
     node = self.parser.get_current_node()
     if node and node.parent:
         ch = node.parent.children
         for i, c in enumerate(ch):
             if c.start == node.start and c.end == node.end and i - 1 >= 0:
                 row, col = ch[i - 1].start
                 if not settings.get("jump_to_angle_bracket", bool):
                     col += 1
                 v.cursor((row, col))
示例#7
0
 def goto_parent(self):
     """To move the cursor to the parent of the current node."""
     node = self.parser.get_current_node()
     if node:
         if node.parent.tag != "root":
             row, col = node.parent.start
             if not settings.get("jump_to_angle_bracket", bool):
                 col += 1
             v.cursor((row, col))
         else:
             v.echom("no parent found")
示例#8
0
 def goto_prev_sibling(self):
     """To move the cursor to the previous sibling node."""
     node = self.parser.get_current_node()
     if node and node.parent:
         ch = node.parent.children
         for i, c in enumerate(ch):
             if c.start == node.start and c.end == node.end and i - 1 >= 0:
                 row, col = ch[i-1].start
                 if not settings.get("jump_to_angle_bracket", bool):
                     col += 1
                 v.cursor((row, col))
示例#9
0
    def jump(self, backward=False):
        """To display jump marks and move to the selected jump mark."""
        table = self._show_jump_marks(v.cursor(), backward)
        choice = None
        while choice not in table:
            choice = self._ask_target_key()
            if choice is None:
                break

        v.clear_hl('BreezeJumpMark', 'BreezeShade')
        self._clear_jump_marks(table)

        if choice:
            row, col = table[choice][0]
            if not settings.get("jump_to_angle_bracket", bool):
                col += 1
            v.cursor((row, col))
示例#10
0
    def match_tag(self):
        """Matches the current tag.

        If the cursor is on the first line of the tag the cursor is positioned
        at the closing tag, and vice-versa.  If the cursor isn't on the start
        line of the tag, the cursor is positioned at the opening tag.
        """
        node = self.parser.get_current_node()
        if node:
            row, col = v.cursor()
            if row != node.start[0]:
                target = node.start
            else:
                endcol = node.start[1] + len(node.starttag_text)
                if col < endcol:
                    target = node.end
                else:
                    target = node.start

            row, col = target
            if not settings.get("jump_to_angle_bracket", bool):
                col += 1
            v.cursor((row, col))
示例#11
0
    def match_tag(self):
        """Matches the current tag.

        If the cursor is on the first line of the tag the cursor is positioned
        at the closing tag, and vice-versa.  If the cursor isn't on the start
        line of the tag, the cursor is positioned at the opening tag.
        """
        node = self.parser.get_current_node()
        if node:
            row, col = v.cursor()
            if row != node.start[0]:
                target = node.start
            else:
                endcol = node.start[1] + len(node.starttag_text)
                if col < endcol:
                    target = node.end
                else:
                    target = node.start

            row, col = target
            if not settings.get("jump_to_angle_bracket", bool):
                col += 1
            v.cursor((row, col))
示例#12
0
 def get_current_node(self):
     """To return the current element (the one that enclose our cursor position)."""
     for c in self.tree.children:
         node, depth = self._closest_node(c, 0, None, -1, v.cursor())
         if node:
             return node