Struct cursormatrix::Term

source ·
pub struct Term {
    pub cursor: Cursor,
    pub matrix: Matrix,
    pub terminfo: TermInfo,
    pub xlimit: Option<usize>,
    pub fg: Vec<(u8, u8, u8)>,
    pub bg: Vec<(u8, u8, u8)>,
    /* private fields */
}
Expand description

The main struct of cursormatrix crate

Example usage:

use cursormatrix::{Direction, Event, Input, Term};

fn handle_event(ev: &Event, term: &mut Term) -> bool {
    match ev {
        &Event::Ctrl(Input::Chars(ref s)) => match s.as_str() {
            "C" => return false,
            _ => (),
        },
        &Event::Raw(Input::Arrow(Direction::Up)) => term.move_up().unwrap(),
        &Event::Raw(Input::Arrow(Direction::Down)) => term.move_down().unwrap(),
        &Event::Raw(Input::BackSpace) => term.cursor.backspace().unwrap(),
        &Event::Raw(Input::Chars(ref s)) => term.print(&s).unwrap(),
        &Event::TermSize(w, h) => term.matrix.refresh(w, h),
        _ => (),
    }
    true
}

fn main() {
    let (mut term, erx) = Term::with_input(true).expect("term");

    term.print("edit").unwrap();
    loop {
        if match erx.recv() {
            Ok(ev) => !handle_event(&ev, &mut term),
            Err(_) => false,
        } {
            break;
        }
    }
}

Fields

cursor: Cursormatrix: Matrixterminfo: TermInfoxlimit: Option<usize>fg: Vec<(u8, u8, u8)>bg: Vec<(u8, u8, u8)>

Implementations

Trait Implementations

Executes the destructor for this type. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.