diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-03-04 18:10:49 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-03-04 18:10:49 -0500 |
commit | e1bfb9bc59a6a97594cb5c2c51cc4ca8ee813a23 (patch) | |
tree | a7b9f6982b76e0e56c3cbc2c2909f6e9e04a8582 /src/shell/inputs/stdin.rs | |
parent | b1c5f2f31874fc019b67ae981f66e0492b22c867 (diff) | |
download | nbsh-e1bfb9bc59a6a97594cb5c2c51cc4ca8ee813a23.tar.gz nbsh-e1bfb9bc59a6a97594cb5c2c51cc4ca8ee813a23.zip |
refactor inputs
Diffstat (limited to 'src/shell/inputs/stdin.rs')
-rw-r--r-- | src/shell/inputs/stdin.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/shell/inputs/stdin.rs b/src/shell/inputs/stdin.rs new file mode 100644 index 0000000..b966307 --- /dev/null +++ b/src/shell/inputs/stdin.rs @@ -0,0 +1,17 @@ +use crate::shell::prelude::*; + +pub struct Handler; + +impl Handler { + pub fn new( + mut input: textmode::blocking::Input, + event_w: crate::shell::event::Writer, + ) -> Self { + std::thread::spawn(move || { + while let Some(key) = input.read_key().unwrap() { + event_w.send(Event::Key(key)); + } + }); + Self + } +} |