pub struct InputStream<'a> { /* private fields */ }
Implementations§
Source§impl<'a> InputStream<'a>
impl<'a> InputStream<'a>
Sourcepub unsafe fn init_with_ncurses(
data: StdinLock<'a>,
screen: WINDOW,
) -> InputStream<'a>
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}
Sourcepub fn next_event(&mut self) -> Result<Event, ()>
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}
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more