[][src]Struct minus::Pager

pub struct Pager {
    pub lines: String,
    pub prompt: String,
    // some fields omitted
}

A struct containing basic configurations for the pager. This is used by all initializing functions

Example

You can use any async runtime, but we are taking the example of tokio

 #[tokio::main]
 async fn main() -> Result<(), Box<dyn std::error::Error>> {
     use minus::{Pager, LineNumbers, tokio_updating};
     let pager = Pager::new()
                        .set_line_numbers(LineNumbers::AlwaysOn)
                        .set_prompt("A complex configuration")
                        .finish();

     // Normally, you would use `futures::join` to join the pager and the text
     // updating function. We are doing this here to make the example simple
     tokio_updating(pager).await?;
     Ok(())
 }

For static output

 fn main() -> Result<(), Box<dyn std::error::Error>> {
      let pager = minus::Pager::new().set_text("Hello").set_prompt("Example");
      minus::page_all(pager)?;
      Ok(())
 }

Fields

lines: String

The output that is displayed

prompt: String

The prompt displayed at the bottom

Implementations

impl Pager[src]

#[must_use]pub fn new() -> Self[src]

Initialize a new pager configuration

Example

let pager = minus::Pager::new();

pub fn set_text(mut self: Self, t: impl Into<String>) -> Self[src]

Set the output text to this t Example

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

#[must_use]pub fn set_line_numbers(mut self: Self, l: LineNumbers) -> Self[src]

Set line number to this setting

Example

use minus::{Pager, LineNumbers};

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

pub fn set_prompt(mut self: Self, t: impl Into<String>) -> Self[src]

Set the prompt displayed at the prompt to t

Example

use minus::Pager;

let pager = Pager::new().set_prompt("my awesome program");

#[must_use]pub fn set_searchable(mut self: Self, s: bool) -> Self[src]

Sets whether searching is possible inside the pager. Default s set to true

Example

use minus::Pager;

let pager = Pager::new().set_searchable(false);

This is a candidate for deprecation. If you want to enable search, enable the search feature. This is because this dosen't really give any major benifits since regex and all related functions are already compiled

#[must_use]pub fn finish(self) -> Arc<PagerMutex>[src]

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

Example

use minus::Pager;

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

#[must_use]pub fn set_exit_strategy(mut self: Self, strategy: ExitStrategy) -> Self[src]

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

Trait Implementations

impl Clone for Pager[src]

impl Default for Pager[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.