From 110b17bfcf59a1eb2d305c577e13923de4d9bb36 Mon Sep 17 00:00:00 2001 From: Alie Date: Sun, 9 Jul 2023 20:44:52 +0200 Subject: [PATCH] unhardcoded keybinds --- src/main.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main.rs b/src/main.rs index 979e951..cf82245 100644 --- a/src/main.rs +++ b/src/main.rs @@ -166,34 +166,34 @@ fn push() { } fn input_parse(storage: &Storage, keybinds: &Keybinds, image_uri: &str) -> bool { - let key = std::io::stdin() - .lock() - .lines() - .next() - .unwrap() - .unwrap() - .chars() - .next() - .unwrap_or('_'); - match key { - 'b' | 'a' => { + loop { + let key = std::io::stdin() + .lock() + .lines() + .next() + .unwrap() + .unwrap() + .chars() + .next() + .unwrap_or('_'); + if &key == &keybinds.quit { + return true; + } else if &key == &keybinds.accept { let mut file = std::fs::OpenOptions::new() .write(true) .append(true) // This is needed to append to file .open(&storage.verified) .unwrap(); write!(file, "{}\n", image_uri).unwrap(); - } - 'q' => return true, - 'd' => { + return false; + } else if &key == &keybinds.delete { let mut file = std::fs::OpenOptions::new() .write(true) .append(true) // This is needed to append to file .open(&storage.rejected) .unwrap(); write!(file, "{}\n", image_uri).unwrap(); + return false; } - _ => return input_parse(storage, keybinds, image_uri), - }; - false + } }