def scroll_output (data,
                   rows=(WINDOW_ROWS-1),
                   cols=WINDOW_COLS,
                   prompt='\t--- more --- [enter to continue] ',
                   wrap_data=True,
                   choice_fn=None):
    """Print the data to the screen, pausing when the number of lines
    meets the total size of the screen in rows. If choice_fn is defined,
    it is invoked with the user reply to the prompt as input."""

    if wrap_data:
        margin = u' ' * (cols/4)
        lines = []
        for line in wrap(data, cols/2):
            lines.append( margin + line )
    else:
        lines = data.splitlines()

    for i, line in enumerate(lines):
        if i > 0 and i % rows == 0:
            user_choice = prompt_user(prompt)
            if choice_fn is not None:
                if choice_fn(user_choice):
                    break
        print line
dataset/ETHPy150Open dpapathanasiou/cmdline-news/cmdlinenews.py/scroll_output/original