[][src]Struct nixterm::term::Term

pub struct Term<I, O> where
    I: Read + AsRawFd,
    O: Write + AsRawFd
{ pub info: TermInfoBuf, // some fields omitted }

Fields

info: TermInfoBuf

Methods

impl Term<Stdin, Stdout>[src]

impl<I, O> Term<I, O> where
    I: Read + AsRawFd,
    O: Write + AsRawFd
[src]

Term represents the user's terminal. It has two channels, I (input), and O (output). Each terminal is accompanied by a "terminfo" file, (represented by the TermInfoBuf struct).

pub fn from_streams(tib: TermInfoBuf, stdin: I, stdout: O) -> Term<I, O>[src]

Important traits for TermWriter<'a, O>
pub fn writer<'a>(&'a self) -> TermWriter<'a, O>[src]

Write to the terminal's stdout, it returns the number of bytes written. write does not need a mutable reference to self, meaning it can be used while self is being borrowed, however write blocks if it's being called from another thread.

Examples

use nixterm::term::Term;

pub fn main() {
    let term = Term::new().unwrap();
    term.writer()
        .foreground("rgb(64, 64, 128)")
        .write(b" Look look look! I'm kinda blue now!\n")
        .flush()
        .err()
        .unwrap();
}

pub fn print<T: AsRef<str>>(&self, s: T) -> Result<usize>[src]

pub fn println<T: AsRef<str>>(&self, s: T) -> Result<usize>[src]

pub fn read(&self, buffer: &mut [u8]) -> usize[src]

Read from the terminal's standard input. Read into a fixed length buffer and return the number of characters read. Similar to Term::write, read does not need Term to be mutable, however only one thread may be reading at a time.

Examples

use nixterm::term::Term;

pub fn main() {
    let term = Term::new().unwrap();
    let mut buffer : [u8; 12] = [0; 12];
     
    // There's nothing to read! so read does nothing and returns 0.
    assert_eq!(term.read(&mut buffer), 0);
    assert_eq!(buffer, [0; 12]);
}

pub fn readline(&self) -> Result<String>[src]

pub fn err(&self) -> Result<()>[src]

pub fn settings(&self) -> Settings[src]

pub fn update(&self, settings: Settings) -> Result<()>[src]

pub fn flush(&self)[src]

Important traits for Keys<'a, I, O>
pub fn read_keys<'a>(&'a self) -> Keys<'a, I, O>[src]

pub fn clear_line_after_cursor(&self)[src]

pub fn save_cursor(&self)[src]

pub fn restore_cursor(&self)[src]

pub fn prompt<T: AsRef<str>>(&self, prompt: T) -> Result<String>[src]

pub fn colors(&self) -> usize[src]

Trait Implementations

impl<I, O> AsRawFd for Term<I, O> where
    I: Read + AsRawFd,
    O: Write + AsRawFd
[src]

Auto Trait Implementations

impl<I, O> Send for Term<I, O> where
    I: Send,
    O: Send

impl<I, O> Unpin for Term<I, O> where
    I: Unpin,
    O: Unpin

impl<I, O> !Sync for Term<I, O>

impl<I, O> !UnwindSafe for Term<I, O>

impl<I, O> !RefUnwindSafe for Term<I, O>

Blanket Implementations

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

impl<T, U> Into<U> for T where
    U: From<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> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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