prompt-toolkit / pypager

A $PAGER in pure Python, similar to "less".
BSD 3-Clause "New" or "Revised" License
85 stars 19 forks source link

Feature request: Automatic paging for long text #30

Open sekika opened 3 months ago

sekika commented 3 months ago

I have created a script that automatically decides whether to print long text directly to the console or to use pypager for paginated display based on the length of the text and the terminal size.

Description

This script wraps the text to fit the terminal width and calculates the number of pages needed to display the text. If the text fits within a single page, it prints the text directly. If it spans multiple pages, it uses pypager to provide an easy-to-navigate paginated display.

Script

You can find the script in this Gist.

Example Usage

  1. Ensure you have pypager installed:

    pip install pypager
  2. Use the function with your text:

    from your_script import print_long
    long_text = "Your long text here..."
    print_long(long_text)

I believe this functionality could be a valuable addition to pypager. Would you consider integrating this feature into pypager?

Thank you for your consideration!