diff options
author | tom barrett <spalf0@gmail.com> | 2018-06-05 02:16:25 -0500 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2018-06-05 02:16:25 -0500 |
commit | 46f9c0f0c5bfc113bea04c295d9d01114d920cd2 (patch) | |
tree | 9678ce7ec55cefcd5ac63cc7bd7f57e3a625e6e8 /src | |
parent | 430b4ee12c72364e6901436951d66e4e6c43990d (diff) |
-termion output for the dashboard
Diffstat (limited to 'src')
-rw-r--r-- | src/client/dashboard.rs | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/client/dashboard.rs b/src/client/dashboard.rs index b9f0a08..cbc55ba 100644 --- a/src/client/dashboard.rs +++ b/src/client/dashboard.rs @@ -1,16 +1,37 @@ +extern crate termion; extern crate serde_json; -use std::io::BufRead; -use std::io::BufReader; use std::net::TcpStream; +use std::io::{BufRead, BufReader, stdout, Write, Read}; +use self::termion::raw::IntoRawMode; +use self::termion::async_stdin; use mass::Mass; pub fn client_dashboard(mut buff_r : BufReader<TcpStream>) { + let stdout = stdout(); + let mut stdout = stdout.lock().into_raw_mode().unwrap(); + let mut stdin = async_stdin().bytes(); + loop { let mut recv = String::new(); buff_r.read_line(&mut recv).unwrap(); let ship : Mass = serde_json::from_str(&recv).unwrap(); - println!("{:?}", ship); + + write!(stdout, "{}{}{:?}", + termion::clear::All, + termion::cursor::Goto(1,1), + ship).unwrap(); + + match stdin.next() { + Some(c) => { + let c = c.unwrap() as char; + if c == 'q' { + break; + } + } + None => (), + } + stdout.flush().unwrap(); } } |