[−][src]Struct cursormatrix::Term
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: Cursor
matrix: Matrix
terminfo: TermInfo
xlimit: Option<usize>
fg: Vec<(u8, u8, u8)>
bg: Vec<(u8, u8, u8)>
Implementations
impl Term
[src]
pub fn from_cjk(cjk: bool) -> Result<Self, Error>
[src]
pub fn with_input(cjk: bool) -> Result<(Self, Receiver<Event>), Error>
[src]
pub fn clear(&mut self) -> Result<(), Error>
[src]
pub fn width_char(&self, c: char) -> usize
[src]
pub fn width_str(&self, s: &str) -> usize
[src]
pub fn print(&mut self, s: &str) -> Result<(), Error>
[src]
pub fn push_colors(&mut self, fg: (u8, u8, u8), bg: (u8, u8, u8))
[src]
pub fn pop_colors(
&mut self,
fg: bool,
bg: bool
) -> (Option<(u8, u8, u8)>, Option<(u8, u8, u8)>)
[src]
&mut self,
fg: bool,
bg: bool
) -> (Option<(u8, u8, u8)>, Option<(u8, u8, u8)>)
pub fn cprint(
&mut self,
s: &str,
fg: Option<(u8, u8, u8)>,
bg: Option<(u8, u8, u8)>
) -> Result<(), Error>
[src]
&mut self,
s: &str,
fg: Option<(u8, u8, u8)>,
bg: Option<(u8, u8, u8)>
) -> Result<(), Error>
pub fn move_to(&mut self, x: usize, y: usize) -> Result<(), Error>
[src]
pub fn move_up(&mut self) -> Result<(), Error>
[src]
pub fn move_down(&mut self) -> Result<(), Error>
[src]
pub fn move_left(&mut self) -> Result<(), Error>
[src]
pub fn move_right(&mut self) -> Result<(), Error>
[src]
pub fn move_home(&mut self) -> Result<(), Error>
[src]
pub fn move_end(&mut self) -> Result<(), Error>
[src]
pub fn move_top(&mut self) -> Result<(), Error>
[src]
pub fn move_bottom(&mut self) -> Result<(), Error>
[src]
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Term
[src]
impl Send for Term
[src]
impl Sync for Term
[src]
impl Unpin for Term
[src]
impl UnwindSafe for Term
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,