Interactive pagination utilities for CLI output.
Provides functions for paginating long lists of items with keyboard navigation.
Summary
Functions
Prompts for a page number and returns the 0-indexed page.
Returns :stay if invalid input.
Handles navigation input and returns the next page number.
Returns :quit to exit pagination.
Maps a key to its navigation action.
Returns the navigation help message.
Gets the slice of items for a given page.
Reads a key from the user with a prompt.
Calculates the number of pages needed for a given total items and page size.
Functions
@spec goto_page(non_neg_integer()) :: non_neg_integer() | :stay
Prompts for a page number and returns the 0-indexed page.
Returns :stay if invalid input.
Maps a key to its navigation action.
@spec page_items([any()], non_neg_integer(), pos_integer()) :: [any()]
Gets the slice of items for a given page.
Reads a key from the user with a prompt.
@spec total_pages(non_neg_integer(), pos_integer()) :: non_neg_integer()
Calculates the number of pages needed for a given total items and page size.