def _apply_soft_wrapping(
        self, lines: Iterable[StyleAndTextTuples]
    ) -> Iterable[StyleAndTextTuples]:
        """
        Apply soft wrapping to the given lines. Wrap according to the terminal
        width. Insert whitespace in front of each wrapped line to align it with
        the output prompt.
        """
        line_length = self.output.get_size().columns

        # Iterate over hard wrapped lines.
        for lineno, line in enumerate(lines):
            columns_in_buffer = 0
            current_line: list[OneStyleAndTextTuple] = []

            for style, text, *_ in line:
                for c in text:
                    width = get_cwidth(c)

                    # (Soft) wrap line if it doesn't fit.
                    if columns_in_buffer + width > line_length:
                        yield current_line
                        columns_in_buffer = 0
                        current_line = []

                    columns_in_buffer += width
                    current_line.append((style, c))

            yield current_line

        Apply soft wrapping to the given lines. Wrap according to the terminal
        width. Insert whitespace in front of each wrapped line to align it with
        the output prompt.
        
src/ptpython/printer.py