diff options
| author | krolxon <krolyxon@tutanota.com> | 2024-05-01 12:08:56 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2024-05-01 12:08:56 +0530 |
| commit | 955532893fc6db5a78f88ef2a2700dec56cd3012 (patch) | |
| tree | 452e05bd0c8aa959c824ba49655ecc7c37c1b327 | |
| parent | b29846fb72326dc04bc13fe11d07965879787533 (diff) | |
remove queue struct, and use generics of ContentList
| -rwxr-xr-x | src/app.rs | 11 | ||||
| -rwxr-xr-x | src/lib.rs | 3 | ||||
| -rwxr-xr-x | src/queue.rs | 41 | ||||
| -rwxr-xr-x | src/ui.rs | 6 |
4 files changed, 8 insertions, 53 deletions
@@ -3,7 +3,6 @@ use std::time::Duration; use crate::browser::FileBrowser; use crate::connection::Connection; use crate::list::ContentList; -use crate::queue::Queue; use crate::ui::InputMode; use mpd::{Client, Song}; @@ -16,10 +15,10 @@ pub struct App { /// check if app is running pub running: bool, pub conn: Connection, - pub browser: FileBrowser, // Directory browser - pub queue_list: Queue, // Stores the current playing queue - pub pl_list: ContentList<String>, // Stores list of playlists - pub selected_tab: SelectedTab, // Used to switch between tabs + pub browser: FileBrowser, // Directory browser + pub queue_list: ContentList<Song>, // Stores the current playing queue + pub pl_list: ContentList<String>, // Stores list of playlists + pub selected_tab: SelectedTab, // Used to switch between tabs // Search pub inputmode: InputMode, // Defines input mode, Normal or Search @@ -44,7 +43,7 @@ pub enum SelectedTab { impl App { pub fn builder(addrs: &str) -> AppResult<Self> { let mut conn = Connection::new(addrs).unwrap(); - let mut queue_list = Queue::new(); + let mut queue_list = ContentList::new(); let mut pl_list = ContentList::new(); pl_list.list = Self::get_playlist(&mut conn.conn)?; @@ -24,6 +24,3 @@ pub mod handler; /// Application pub mod app; - -/// The Queue structure -pub mod queue; diff --git a/src/queue.rs b/src/queue.rs deleted file mode 100755 index 712bc2f..0000000 --- a/src/queue.rs +++ /dev/null @@ -1,41 +0,0 @@ -use mpd::Song; - -#[derive(Debug)] -pub struct Queue { - pub list: Vec<Song>, - pub index: usize, -} - -impl Queue { - pub fn new() -> Self { - Queue { - list: Vec::new(), - index: 0, - } - } - - // Go to next item in list - pub fn next(&mut self) { - let len = self.list.len(); - if len != 0 && self.index < len - 1 { - self.index += 1; - } - } - - /// Go to previous item in list - pub fn prev(&mut self) { - if self.index != 0 { - self.index -= 1; - } - } - - pub fn reset_index(&mut self) { - self.index = 0; - } -} - -impl Default for Queue { - fn default() -> Self { - Self::new() - } -} @@ -362,9 +362,9 @@ fn draw_playlist_viewer(frame: &mut Frame, app: &mut App, area: Rect) { let table = Table::new( rows, vec![ - Constraint::Min(40), - Constraint::Percentage(40), - Constraint::Percentage(20), + Constraint::Min(48), + Constraint::Percentage(48), + Constraint::Percentage(4), ], ) .block(title) |
