Struct minus::Pager[][src]

pub struct Pager { /* fields omitted */ }
Expand description

A struct containing all configurations for the pager.

This is used by all initializing functions

Implementations

Initialize a new pager configuration

Errors

This function will return an error if it cannot determine the terminal size

Example
let pager = minus::Pager::new().unwrap();

Set the output text to this t

Note that unlike Pager::push_str, this replaces the original text. If you want to append text, use the Pager::push_str function

Example

let mut pager = minus::Pager::new().unwrap();
pager.set_text("This is a line");

Set line number to this setting

Example

use minus::{Pager, LineNumbers};

let mut pager = Pager::new().unwrap();
pager.set_line_numbers(LineNumbers::Enabled);

Display a temporary message at the prompt area

Panics

This function panics if the given text contains newline characters. This is because, the pager reserves only one line for showing the prompt and a newline will cause it to span multiple lines, breaking the display

Example

use minus::Pager;

let mut pager = Pager::new().unwrap();
pager.send_message("An error occurred");

Set the prompt displayed at the prompt to t

Panics

This function panics if the given text contains newline characters. This is because, the pager reserves only one line for showing the prompt and a newline will cause it to span multiple lines, breaking the display

Example

use minus::Pager;

let mut pager = Pager::new().unwrap();
pager.set_prompt("my awesome program");
This is supported on crate features tokio_lib or async_std_lib only.

Return a PagerMutex from this Pager. This is gated on tokio_lib or async_std_lib feature

Example

use minus::Pager;

let mut pager = Pager::new().unwrap();
pager.set_text("This output is paged");
let _pager_mutex = pager.finish();

Set the default exit strategy.

This controls how the pager will behave when the user presses q or Ctrl+C. See ExitStrategy for available options

use minus::{Pager, ExitStrategy};

let mut pager = Pager::new().unwrap();
pager.set_exit_strategy(ExitStrategy::ProcessQuit);

Set whether to display pager if there’s less data than available screen height

By default this is set to false

use minus::Pager;

let mut pager = Pager::new().unwrap();
pager.set_run_no_overflow(true);

Appends text to the pager output

This function will automatically split the lines, if they overflow the number of terminal columns

let mut pager = minus::Pager::new().unwrap();
pager.push_str("This is some text");

Hints the running pager that no more data is coming

Example

use minus::Pager;

let mut pager = Pager::new().unwrap();
pager.set_text("Hello from minus!");
pager.end_data_stream();

Set custom input handler function

See example in InputHandler on using this function

Example

use minus::Pager;

fn hello() {
    println!("Hello");
}

let mut pager = Pager::new().unwrap();
pager.add_exit_callback(Box::new(hello));

Trait Implementations

Returns the “default value” for a type. Read more

Writes a string slice into this writer, returning whether the write succeeded. Read more

Writes a char into this writer, returning whether the write succeeded. Read more

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.