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
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.
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
Writes a string slice into this writer, returning whether the write succeeded. Read more