unhardcoded keybinds

This commit is contained in:
Alie 2023-07-09 20:44:52 +02:00
parent 4d9bc589d4
commit 110b17bfcf
1 changed files with 17 additions and 17 deletions

View File

@ -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
}
}