Outputs lines to a terminal. It uses
        `shutil.get_terminal_size` to determine the height of the terminal.
        It expects an iterator that returns a line at a time and those lines
        should be terminated by a valid newline sequence.

        Behaviour is controlled by a number of external class properties.

        `paginate` : Is on by default and triggers pagination. Without `paginate`
        all output is written straight to the screen.

        `output_file` : By assigning a name to this property we can ensure that
        all output is sent to the corresponding file. Prompts are not output.

        `pretty_print` : If this is set (default is on) then all output is
        pretty printed with `pprint`. If it is off then the output is just
        written to the screen.

        `overlap` : The number of lines to overlap between one page and the
        next.

        :param lines:
        :return: paginated output

def pager(self, lines):
        """
        Outputs lines to a terminal. It uses
        `shutil.get_terminal_size` to determine the height of the terminal.
        It expects an iterator that returns a line at a time and those lines
        should be terminated by a valid newline sequence.

        Behaviour is controlled by a number of external class properties.

        `paginate` : Is on by default and triggers pagination. Without `paginate`
        all output is written straight to the screen.

        `output_file` : By assigning a name to this property we can ensure that
        all output is sent to the corresponding file. Prompts are not output.

        `pretty_print` : If this is set (default is on) then all output is
        pretty printed with `pprint`. If it is off then the output is just
        written to the screen.

        `overlap` : The number of lines to overlap between one page and the
        next.

        :param lines:
        :return: paginated output
        """
        try:

            line_count = 0

            if self._output_filename:
                print(f"Output is also going to '{self.output_file}'")
                self._output_file = open(self._output_filename, "a+")

            terminal_columns, terminal_lines = shutil.get_terminal_size(fallback=(80, 24))
            lines_left = terminal_lines
            for i, l in enumerate(lines, 1):

                line_residue = 0
                if self.line_numbers:
                    output_line = f"{i:<4} {l}"
                else:
                    output_line = l

                line_overflow = int(len(output_line) / terminal_columns)
                if line_overflow:
                    line_residue = len(output_line) % terminal_columns

                if line_overflow >= 1:
                    lines_left = lines_left - line_overflow
                else:
                    lines_left = lines_left - 1

                if line_residue > 1:
                    lines_left = lines_left - 1

                # line_count = line_count + 1

                print(output_line)

                if self._output_file:
                    self._output_file.write(f"{l}\n")
                    self._output_file.flush()

                #print(lines_left)
                if (lines_left - self.overlap - 1) <= 0:  # -1 to leave room for prompt

                    if self.paginate:
                        print("Hit Return to continue (q or quit to exit)", end="")

                        user_input = input()
                        if user_input.lower().strip() in ["q", "quit", "exit"]:
                            break

                        terminal_columns, terminal_lines = shutil.get_terminal_size(fallback=(80, 24))
                        lines_left = terminal_lines
            # end for

            if self._output_file:
                self._output_file.close()
        except KeyboardInterrupt:
            print("ctrl-C...")
            if self._output_file:
                self._output_file.close()