def _print_paginated_formatted_text(
        self, lines: Iterable[StyleAndTextTuples]
    ) -> None:
        """
        Print formatted text, using --MORE-- style pagination.
        (Avoid filling up the terminal's scrollback buffer.)
        """
        lines = self._apply_soft_wrapping(lines)
        pager_prompt = create_pager_prompt(
            self.style, self.title, output=self.output, input=self.input
        )

        abort = False
        print_all = False

        # Max number of lines allowed in the buffer before painting.
        size = self.output.get_size()
        max_rows = size.rows - 1

        # Page buffer.
        page: StyleAndTextTuples = []

        def show_pager() -> None:
            nonlocal abort, max_rows, print_all

            # Run pager prompt in another thread.
            # Same as for the input. This prevents issues with nested event
            # loops.
            pager_result = pager_prompt.prompt(in_thread=True)

            if pager_result == PagerResult.ABORT:
                print("...")
                abort = True

            elif pager_result == PagerResult.NEXT_LINE:
                max_rows = 1

            elif pager_result == PagerResult.NEXT_PAGE:
                max_rows = size.rows - 1

            elif pager_result == PagerResult.PRINT_ALL:
                print_all = True

        # Loop over lines. Show --MORE-- prompt when page is filled.
        rows = 0

        for lineno, line in enumerate(lines):
            page.extend(line)
            page.append(("", "\n"))
            rows += 1

            if rows >= max_rows:
                self._print_formatted_text(page, end="")
                page = []
                rows = 0

                if not print_all:
                    show_pager()
                    if abort:
                        return

        self._print_formatted_text(page)

        Print formatted text, using --MORE-- style pagination.
        (Avoid filling up the terminal's scrollback buffer.)
        
src/ptpython/printer.py