Struct InputStream

Source
pub struct InputStream<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> InputStream<'a>

Source

pub unsafe fn init_with_ncurses( data: StdinLock<'a>, screen: WINDOW, ) -> InputStream<'a>

Examples found in repository?
examples/event_viewer.rs (line 20)
16fn main() {
17    let screen = Screen(ncurses::initscr());
18    ncurses::scrollok(screen.0, true);
19    let stdin = std::io::stdin();
20    let mut input_stream = unsafe { InputStream::init_with_ncurses(stdin.lock(), screen.0) };
21
22    let mut out_file = None;
23    if let Some(arg) = std::env::args_os().nth(1) {
24        out_file = Some(std::fs::File::create(arg).unwrap());
25    }
26
27    loop {
28        let event = input_stream.next_event();
29        if let Some(ref mut file) = out_file {
30            write!(file, "{:?}\n", event).unwrap();
31        }
32        ncurses::wprintw(screen.0, &format!("{:?}\n", event));
33        ncurses::wrefresh(screen.0);
34
35        if let Ok(Event::KeyPress { modifiers: Modifiers::CTRL, key: KeyInput::Codepoint('c'), .. })
36             | Ok(Event::KeyPress { modifiers: Modifiers::CTRL, key: KeyInput::Codepoint('q'), .. }) = event {
37            return;         
38        }
39    }
40}
Source

pub fn next_event(&mut self) -> Result<Event, ()>

Examples found in repository?
examples/event_viewer.rs (line 28)
16fn main() {
17    let screen = Screen(ncurses::initscr());
18    ncurses::scrollok(screen.0, true);
19    let stdin = std::io::stdin();
20    let mut input_stream = unsafe { InputStream::init_with_ncurses(stdin.lock(), screen.0) };
21
22    let mut out_file = None;
23    if let Some(arg) = std::env::args_os().nth(1) {
24        out_file = Some(std::fs::File::create(arg).unwrap());
25    }
26
27    loop {
28        let event = input_stream.next_event();
29        if let Some(ref mut file) = out_file {
30            write!(file, "{:?}\n", event).unwrap();
31        }
32        ncurses::wprintw(screen.0, &format!("{:?}\n", event));
33        ncurses::wrefresh(screen.0);
34
35        if let Ok(Event::KeyPress { modifiers: Modifiers::CTRL, key: KeyInput::Codepoint('c'), .. })
36             | Ok(Event::KeyPress { modifiers: Modifiers::CTRL, key: KeyInput::Codepoint('q'), .. }) = event {
37            return;         
38        }
39    }
40}
Source

pub fn set_escdelay(&mut self, escdelay: Duration)

Auto Trait Implementations§

§

impl<'a> Freeze for InputStream<'a>

§

impl<'a> RefUnwindSafe for InputStream<'a>

§

impl<'a> !Send for InputStream<'a>

§

impl<'a> !Sync for InputStream<'a>

§

impl<'a> Unpin for InputStream<'a>

§

impl<'a> UnwindSafe for InputStream<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.