def print_text(
        self, y_pos: int, x_pos: int, printer: ColorPrinter, max_len: int
    ) -> None:
        """Print out using ncurses. Note that if any formatting changes
        occur, the attribute set is changed and not restored"""
        printed_so_far = 0
        for index, val in enumerate(self.segments):
            if printed_so_far >= max_len:
                break
            if index % 2 == 1:
                # text
                to_print = val[0 : max_len - printed_so_far]
                printer.addstr(
                    y_pos, x_pos + printed_so_far, to_print, ColorPrinter.CURRENT_COLORS
                )
                printed_so_far += len(to_print)
            else:
                # formatting
                printer.set_attributes(*self.parse_formatting(val))
Print out using ncurses. Note that if any formatting changes
        occur, the attribute set is changed and not restored
src/pathpicker/formatted_text.py