1 extern crate starry_client; 2 extern crate starry_server; 3 extern crate starry_toolkit; 4 extern crate termios; 5 6 pub mod asset_manager; 7 8 use std::io; 9 use std::os::unix::io::AsRawFd; 10 use termios::{tcsetattr, Termios}; 11 12 // TODO 13 #[allow(dead_code)] 14 pub fn set_terminal() -> io::Result<()> { 15 let stdin = io::stdin().as_raw_fd(); 16 let stored_settings = Termios::from_fd(stdin)?; 17 18 let mut new_settings = stored_settings.clone(); 19 new_settings.c_lflag &= !(termios::ICANON) & !(termios::ECHO); 20 new_settings.c_cc[termios::VMIN] = 1; 21 new_settings.c_cc[termios::VTIME] = 0; 22 23 tcsetattr(stdin, termios::TCSANOW, &new_settings)?; 24 25 Ok(()) 26 } 27 28 // TODO 29 #[allow(dead_code)] 30 pub fn reset_terminal() -> io::Result<()> { 31 let stdin = io::stdin().as_raw_fd(); 32 let stored_settings = Termios::from_fd(stdin)?; 33 34 let mut new_settings = stored_settings.clone(); 35 new_settings.c_lflag &= (termios::ICANON) & (termios::ECHO); 36 37 tcsetattr(stdin, termios::TCSANOW, &new_settings)?; 38 39 Ok(()) 40 } 41