示例#1
0
    def _highlight_tags(self, tags, curr_line):
        """To highlight search results."""
        vk_colors = settings.get("visual_kinds_colors")
        vk_shape = settings.get("visual_kinds_shape")
        indicator = settings.get("current_line_indicator")

        for i, tag in enumerate(tags):

            if i == curr_line:
                offset = len(indicator.encode(v.encoding()))
            else:
                offset = len(indicator)

            if settings.get("visual_kinds", bool):
                offset += len(vk_shape.encode(v.encoding()))
                kind = tag["exts"].get("kind")
                if kind in vk_colors:
                    patt = u"\c\%{}l{}".format(i+1, vk_shape.replace(u"u",u"%u"))
                    v.highlight("SurferVisualKind_" + kind, patt)

            patt = u"\c\%{}l\%{}c.*".format(i+1, offset+len(tag["name"])+1)
            v.highlight("SurferShade", patt)

            for pos in misc.as_byte_indexes(tag["match_positions"], tag["name"]):

                patt = u"\c\%{}l\%{}c.".format(i+1, offset+pos+1)
                v.highlight("SurferMatches", patt)
示例#2
0
 def _highlight_err(self):
     """To highlight the content of the Surfer window as error."""
     v.highlight("SurferError", ".*")