[][src]Struct term_basics_linux::InputHistory

pub struct InputHistory { /* fields omitted */ }

A struct that holds information about a history of typed input's but the user.

Methods

impl InputHistory[src]

pub fn new(maxlen: usize) -> Self[src]

Make a new InputHistory with a certain maximum capacity.

Example

use term_basic_linux as tbl;
let mut his = tbl::InputHistory::new(10);
let x = tbl::input_field_scrollable(&mut his);

pub fn add(&mut self, string: &String)[src]

Adds an element to the history. It will delete items if it's length would grow past the max length. the oldest items will be removed.

Example

use term_basics_linux as tbl;
let mut his = tbl::InputHistory::new(2);
his.add(&"0".to_string());
his.add(&"1".to_string());
his.add(&"2".to_string());
//only "1" and "2" will remain, as 0 is removed.
let _ = tbl::input_field_scrollable(&mut his);

pub fn get_index(&self, index: i32) -> Option<&String>[src]

Returns the an Option of String, the element at the given index. The index wraps and you can query for negative indices as well as indices above the maximum length.

Example

use term_basics_linux as tbl;
let mut his = tbl::InputHistory::new(3);
his.add(&"0".to_string());
his.add(&"1".to_string());
his.add(&"2".to_string());
println!("at -2: {:?}", his.get_index(-2)); // "1"
println!("at -1: {:?}", his.get_index(-1)); // "2"
println!("at  0: {:?}", his.get_index(0));  // "0"
println!("at  1: {:?}", his.get_index(1));  // "1"
println!("at  2: {:?}", his.get_index(2));  // "2"
println!("at  3: {:?}", his.get_index(3));  // "0"
println!("at  4: {:?}", his.get_index(4));  // "1"

Auto Trait Implementations

Blanket Implementations

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

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

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.

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

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

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