def syntax_highlight_visible_lines(self):
        """Apply syntax highlighting to visible lines."""
        ### if the last_edition_frame isn't 0, it means
        ### there are changes yet to be taken into account,
        ### that is, the syntax highlighting data is
        ### outdated;
        ###
        ### in such case,  we abort the execution of
        ### the rest of this method by returning earlier
        if self.last_edition_frame:
            return

        ### otherwise we go on and apply the syntax
        ### highlighting to the visible lines

        ## reference the theme text settings and
        ## highlight data locally, for quicker and easier
        ## access

        theme_text_settings = self.theme_map["text_settings"]
        highlight_data = self.highlight_data

        ## iterate over the visible lines and their indices,
        ## highlighting their text according to the
        ## highlighting data present

        for line_index, line in enumerate(
            self.visible_lines, start=self.top_visible_line_index
        ):

            ## try popping out the interval data from the
            ## highlight data dict with the line index

            try:
                interval_data = highlight_data.pop(line_index)

            ## if there is no such data, skip iteration
            ## of this item
            except KeyError:
                continue

            ## otherwise, we take needed measures so the
            ## interval data is used to highlight the
            ## text of the line

            # iterate over the interval data, which consists
            # of interval/category name pairs, with the
            # intervals further decomposed into their
            # start and ending indices

            for (
                (including_start, excluding_end),
                category_name,
            ) in interval_data.items():

                # retrieve the text settings for the
                # category
                category_text_settings = theme_text_settings[category_name]

                # each index in the interval represents
                # the index of a character object;
                #
                # iterate over such indices, applying the
                # text settings corresponding to the syntax
                # category to the character in each index

                for char_index in range(including_start, excluding_end):

                    line[char_index].change_text_settings(category_text_settings)
Apply syntax highlighting to visible lines.
nodezator/textman/editor/cursor/syntaxhigh.py