unhardcoded keybinds
This commit is contained in:
parent
4d9bc589d4
commit
110b17bfcf
34
src/main.rs
34
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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue