pub fn watch_input(tx_keyboard_input: Sender<Message>) -> JoinHandle<()> {
    let join_handle = thread::spawn(move || {
        loop {

            use std::io::{stdin};
            let mut buffer = String::new();
            stdin().read_line(&mut buffer).expect("Did not enter a correct string");

            let forward = buffer.to_lowercase().trim().to_string();

            if forward != "" {
                if forward == Message::Quit.as_str() {
                    let _send_result = tx_keyboard_input.send(Message::Quit);
                    break;
                } else if forward == Message::StopAlarm.as_str() {
                    let _send_result = tx_keyboard_input.send(Message::StopAlarm);
                } else if forward == Message::Show.as_str() {
                    let _send_result = tx_keyboard_input.send(Message::Show);
                } else if forward == Message::Help.as_str() {
                    println!("\n
'{}' shows this message
'{}' shows the loaded configuration
'{}' stops the running alarm
'{}' stops the application\n",
                        Message::Help.as_str(),
                        Message::Show.as_str(),
                        Message::StopAlarm.as_str(),
                        Message::Quit.as_str()
                    )
                }
            }
        }
    });

    join_handle
}
/// Thread to watch user keyboard inputs
Thread to watch user keyboard inputs
Thread to watch user keyboard inputs
pub fn watch_input(tx_keyboard_input: Sender<Message>) -> JoinHandle<()> {
    let join_handle = thread::spawn(move || {
        loop {
            use std::io::{stdin};
            let mut buffer = String::new();
            stdin().read_line(&mut buffer).expect("Did not enter a correct string");
            let forward = buffer.to_lowercase().trim().to_string();
            if forward != "" {
                if forward == Message::Quit.as_str() {
                    let _send_result = tx_keyboard_input.send(Message::Quit);
                    break;
                } else if forward == Message::StopAlarm.as_str() {
                    let _send_result = tx_keyboard_input.send(Message::StopAlarm);
                } else if forward == Message::Show.as_str() {
                    let _send_result = tx_keyboard_input.send(Message::Show);
                } else if forward == Message::Help.as_str() {
                    println!("\n
'{}' shows this message
'{}' shows the loaded configuration
'{}' stops the running alarm
'{}' stops the application\n",
                        Message::Help.as_str(),
                        Message::Show.as_str(),
                        Message::StopAlarm.as_str(),
                        Message::Quit.as_str()
                    )
                }
            }
        }
    });
    join_handle
}
pub fn watch_input ( tx_keyboard_input : Sender < Message > ) -> JoinHandle < ( ) > { let join_handle = thread :: spawn ( move | | { loop { use std :: io :: { stdin } ; let mut buffer = String :: new ( ) ; stdin ( ) . read_line ( & mut buffer ) . expect ( " " ) ; let forward = buffer . to_lowercase ( ) . trim ( ) . to_string ( ) ; if forward != " " { if forward == Message :: Quit . as_str ( ) { let _send_result = tx_keyboard_input . send ( Message :: Quit ) ; break ; } else if forward == Message :: StopAlarm . as_str ( ) { let _send_result = tx_keyboard_input . send ( Message :: StopAlarm ) ; } else if forward == Message :: Show . as_str ( ) { let _send_result = tx_keyboard_input . send ( Message :: Show ) ; } else if forward == Message :: Help . as_str ( ) { println ! ( " \n \n " Message Help as_str ( ) Message Show as_str ( ) Message StopAlarm as_str ( ) Message Quit as_str ( ) ) } } } } ) ; join_handle }
Thread to watch user keyboard inputs
Thread to watch user keyboard inputs
tx_keyboard_input
Sender<Message>
tx_keyboard_input
Sender<Message>