Expand description
Output text through a pager.
It uses less
by default, or any pager set by the PAGER
environment variable.
The points of interest are the Pager
struct, and the
OutputPaged
trait.
§Examples
Manually:
use lessify::Pager;
// If pager fails, fall back to printing text.
Pager::page_or_print("very long text");
Or with the trait (blanket implementation for T: Display
):
use lessify::OutputPaged;
// Same as `page_or_print()`.
"very long text".output_paged();
§Windows Notes
The default pager on Windows is set to more.com
. Unfortunately,
at the time of writing more
is legacy software which does not
understand multi-byte characters. This leads to mojibake.
Therefore, when using this crate on Windows, it is advisable to restrict what you print to the ASCII character set.
Possible alternative solutions include:
- Reading the active console codepage and converting the output.
- Setting the console codepage, if this is appropriate.
Structs§
- Pager
- Output text through a pager.
Statics§
- PAGER
- Pager to use, lazily determined.