Exemple #1
0
 def setup_colors(self):
     """To setup Breeze highlight groups."""
     postfix = "" if vim.eval("&bg") == "light" else "_darkbg"
     colors = {
         "BreezeShade": settings.get("shade_color{0}".format(postfix)),
         "BreezeJumpMark": settings.get("jumpmark_color{0}".format(postfix)),
         "BreezeHl": settings.get("hl_color{0}".format(postfix))
     }
     for group, color in colors.items():
         link = "" if "=" in color else "link"
         vim.command("hi {0} {1} {2}".format(link, group, color))
Exemple #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))
Exemple #3
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))
Exemple #4
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))
Exemple #5
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))
Exemple #6
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")
Exemple #7
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))
Exemple #8
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")
Exemple #9
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))
Exemple #10
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))
Exemple #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))
Exemple #12
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))