allow for more config and cli args
This commit is contained in:
@@ -22,6 +22,7 @@ enum Action {
|
||||
MoveDown,
|
||||
MoveUp,
|
||||
Select,
|
||||
Exit,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@@ -59,7 +60,7 @@ fn get_input() -> Option<Action> {
|
||||
KeyCode::Char('j') => Action::MoveDown,
|
||||
KeyCode::Char('k') => Action::MoveUp,
|
||||
KeyCode::Enter => Action::Select,
|
||||
KeyCode::Char('q') => exit(),
|
||||
KeyCode::Char('q') => Action::Exit,
|
||||
_ => return None,
|
||||
}),
|
||||
Err(e) => {
|
||||
@@ -83,9 +84,6 @@ fn exit() -> ! {
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
// pub fn multi_select(entries: &[Entry]) -> Result<Vec<u16>, std::io::Error> {
|
||||
// }
|
||||
|
||||
pub fn select(entries: &[Entry]) -> Result<u16, std::io::Error> {
|
||||
let (width, height) = terminal::size()?;
|
||||
let mut stdout = io::stdout();
|
||||
@@ -125,6 +123,14 @@ pub fn select(entries: &[Entry]) -> Result<u16, std::io::Error> {
|
||||
.flush()?;
|
||||
return Ok(selected);
|
||||
}
|
||||
Action::Exit => {
|
||||
stdout
|
||||
.queue(MoveTo(0, 0))?
|
||||
.queue(Clear(ClearType::All))?
|
||||
.queue(Show)?
|
||||
.flush()?;
|
||||
exit();
|
||||
}
|
||||
}
|
||||
stdout.queue(MoveTo(0, selected))?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user