rmptuiba154a3
fix appending songs
+20 −10
1 file changed
- M src/handler.rs +20 −10
| @@ -4,7 +4,7 @@ use crate::{ | |||
| 4 | 4 | app::{App, AppResult, SelectedTab}, | |
| 5 | 5 | ui::InputMode, | |
| 6 | 6 | }; | |
| 7 | − | use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; | |
| 7 | + | use crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyEventState, KeyModifiers}; | |
| 8 | 8 | use rust_fuzzy_search::{self, fuzzy_search_sorted}; | |
| 9 | 9 | use simple_dmenu::dmenu; | |
| 10 | 10 | ||
| @@ -79,6 +79,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { | |||
| 79 | 79 | } else { | |
| 80 | 80 | app.conn.conn.clear()?; | |
| 81 | 81 | app.conn.update_status(); | |
| 82 | + | app.queue_list.list.clear(); | |
| 82 | 83 | } | |
| 83 | 84 | } | |
| 84 | 85 | ||
| @@ -154,21 +155,28 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { | |||
| 154 | 155 | ||
| 155 | 156 | // add to queue | |
| 156 | 157 | KeyCode::Char('a') => { | |
| 157 | − | // let song = app.conn.get_song_with_only_filename( | |
| 158 | − | // app.conn.songs_filenames.get(app.song_list.index).unwrap(), | |
| 159 | − | // ); | |
| 160 | − | ||
| 161 | 158 | let list = app | |
| 162 | 159 | .conn | |
| 163 | 160 | .songs_filenames | |
| 164 | 161 | .iter() | |
| 165 | 162 | .map(|f| f.as_str()) | |
| 166 | 163 | .collect::<Vec<&str>>(); | |
| 167 | − | let (filename, _) = | |
| 168 | − | rust_fuzzy_search::fuzzy_search_sorted(&app.browser.path, &list) | |
| 169 | − | .get(0) | |
| 170 | − | .unwrap() | |
| 171 | − | .clone(); | |
| 164 | + | ||
| 165 | + | let files: Vec<String> = app | |
| 166 | + | .browser | |
| 167 | + | .filetree | |
| 168 | + | .clone() | |
| 169 | + | .into_iter() | |
| 170 | + | .map(|(_, f)| f) | |
| 171 | + | .collect(); | |
| 172 | + | ||
| 173 | + | let (filename, _) = rust_fuzzy_search::fuzzy_search_sorted( | |
| 174 | + | &files.get(app.browser.selected).unwrap(), | |
| 175 | + | &list, | |
| 176 | + | ) | |
| 177 | + | .get(0) | |
| 178 | + | .unwrap() | |
| 179 | + | .clone(); | |
| 172 | 180 | ||
| 173 | 181 | let song = app.conn.get_song_with_only_filename(filename); | |
| 174 | 182 | ||
| @@ -180,6 +188,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { | |||
| 180 | 188 | .push_playlist(app.pl_list.list.get(app.pl_list.index).unwrap())?; | |
| 181 | 189 | } | |
| 182 | 190 | ||
| 191 | + | // Fast forward | |
| 183 | 192 | KeyCode::Char('f') => { | |
| 184 | 193 | let place = app.conn.conn.status().unwrap().song.unwrap().pos; | |
| 185 | 194 | let (pos, _) = app.conn.conn.status().unwrap().time.unwrap(); | |
| @@ -187,6 +196,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { | |||
| 187 | 196 | app.conn.conn.seek(place, pos)?; | |
| 188 | 197 | } | |
| 189 | 198 | ||
| 199 | + | // backward | |
| 190 | 200 | KeyCode::Char('b') => { | |
| 191 | 201 | let place = app.conn.conn.status().unwrap().song.unwrap().pos; | |
| 192 | 202 | let (pos, _) = app.conn.conn.status().unwrap().time.unwrap(); | |