def parse_formatting()

in src/pathpicker/formatted_text.py [0:0]


    def parse_formatting(cls, formatting: str) -> Tuple[int, int, int]:
        """Parse ANSI formatting; the formatting passed in should be
        stripped of the control characters and ending character"""
        fg_color = -1  # -1 default means "use default", not "use white/black"
        bg_color = -1
        other = 0
        int_values = [int(value) for value in formatting.split(";") if value]
        for code in int_values:
            if cls.FOREGROUND_RANGE.bottom <= code <= cls.FOREGROUND_RANGE.top:
                fg_color = code - cls.FOREGROUND_RANGE.bottom
            elif cls.BACKGROUND_RANGE.bottom <= code <= cls.BACKGROUND_RANGE.top:
                bg_color = code - cls.BACKGROUND_RANGE.bottom
            elif code == cls.BOLD_ATTRIBUTE:
                other = other | curses.A_BOLD
            elif code == cls.UNDERLINE_ATTRIBUTE:
                other = other | curses.A_UNDERLINE

        return fg_color, bg_color, other