press spacebar to reset selection

This commit is contained in:
figsoda 2020-11-01 12:02:59 -05:00
parent 25e6644f30
commit d5cd92ae3a

View file

@ -47,6 +47,7 @@ enum Command {
UpdateStatus, UpdateStatus,
TogglePause, TogglePause,
Play, Play,
Reselect,
Down, Down,
Up, Up,
JumpDown, JumpDown,
@ -131,6 +132,9 @@ async fn run() -> Result<()> {
KeyCode::Enter => { KeyCode::Enter => {
tx.send(Command::Play).await.unwrap_or_else(die); tx.send(Command::Play).await.unwrap_or_else(die);
} }
KeyCode::Char(' ') => {
tx.send(Command::Reselect).await.unwrap_or_else(die);
}
KeyCode::Char('j') | KeyCode::Down => { KeyCode::Char('j') | KeyCode::Down => {
tx.send(Command::Down).await.unwrap_or_else(die); tx.send(Command::Down).await.unwrap_or_else(die);
} }
@ -196,6 +200,11 @@ async fn run() -> Result<()> {
} }
tx.send(Command::UpdateStatus).await?; tx.send(Command::UpdateStatus).await?;
} }
Command::Reselect => {
selected = status.song.map_or(0, |song| song.pos);
liststate.select(Some(selected));
tx.send(Command::UpdateFrame).await?;
}
Command::Down => { Command::Down => {
let len = queue.len(); let len = queue.len();
if selected >= len { if selected >= len {