aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2024-04-26 21:12:41 +0530
committerkrolxon <krolyxon@tutanota.com>2024-04-26 21:12:41 +0530
commit8269766147962df1fce10c6617baf7d5d9300f40 (patch)
tree3fd136279e484a5023549a25c571edc579fa73b0 /src
parentba154a307e5b28e8131d1c3d98847c5710b4ecc8 (diff)
delete this random (L) function, add comments
Diffstat (limited to 'src')
-rwxr-xr-xsrc/handler.rs31
-rwxr-xr-xsrc/ui.rs6
2 files changed, 17 insertions, 20 deletions
diff --git a/src/handler.rs b/src/handler.rs
index 679512d..cb7c292 100755
--- a/src/handler.rs
+++ b/src/handler.rs
@@ -4,7 +4,7 @@ use crate::{
app::{App, AppResult, SelectedTab},
ui::InputMode,
};
-use crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyEventState, KeyModifiers};
+use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
use rust_fuzzy_search::{self, fuzzy_search_sorted};
use simple_dmenu::dmenu;
@@ -72,6 +72,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
}
} else {
match key_event.code {
+ // Quit
KeyCode::Char('q') | KeyCode::Esc => app.quit(),
KeyCode::Char('c') | KeyCode::Char('C') => {
if key_event.modifiers == KeyModifiers::CONTROL {
@@ -83,18 +84,21 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
}
}
+ // Go Up
KeyCode::Char('j') | KeyCode::Down => match app.selected_tab {
SelectedTab::DirectoryBrowser => app.browser.next(),
SelectedTab::Queue => app.queue_list.next(),
SelectedTab::Playlists => app.pl_list.next(),
},
+ // Go down
KeyCode::Char('k') | KeyCode::Up => match app.selected_tab {
SelectedTab::DirectoryBrowser => app.browser.prev(),
SelectedTab::Queue => app.queue_list.prev(),
SelectedTab::Playlists => app.pl_list.prev(),
},
+ // Next directory
KeyCode::Enter | KeyCode::Char('l') => {
// app.update_queue();
@@ -117,6 +121,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
app.conn.update_status();
}
+ // head back to previous directory
KeyCode::Char('h') => match app.selected_tab {
SelectedTab::DirectoryBrowser => {
app.browser.handle_go_back(&mut app.conn)?;
@@ -204,26 +209,32 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
app.conn.conn.seek(place, pos)?;
}
+ // Cycle through tabs
KeyCode::Tab => {
app.cycle_tabls();
}
+ // Directory browser tab
KeyCode::Char('1') => {
app.selected_tab = SelectedTab::DirectoryBrowser;
}
+ // Playing queue tab
KeyCode::Char('2') => {
app.selected_tab = SelectedTab::Queue;
}
+ // Playlists tab
KeyCode::Char('3') => {
app.selected_tab = SelectedTab::Playlists;
}
+ // Play next song
KeyCode::Char('>') => {
app.conn.conn.next()?;
}
+ // Play previous song
KeyCode::Char('<') => {
app.conn.conn.prev()?;
}
@@ -251,27 +262,11 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
app.update_queue();
}
+ // Update MPD database
KeyCode::Char('U') => {
app.conn.conn.update()?;
}
- KeyCode::Char('L') => {
- let str = dmenu!(prompt "Search: ");
- let list = app
- .conn
- .songs_filenames
- .iter()
- .map(|f| f.as_str())
- .collect::<Vec<&str>>();
- let (filename, _) = rust_fuzzy_search::fuzzy_search_sorted(&str, &list)
- .get(0)
- .unwrap()
- .clone();
-
- let song = app.conn.get_song_with_only_filename(filename);
- app.conn.push(&song)?;
- }
-
// Search for songs
KeyCode::Char('/') => {
app.inputmode = InputMode::toggle_editing_states(&app.inputmode);
diff --git a/src/ui.rs b/src/ui.rs
index 76a39ee..2010362 100755
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -78,6 +78,7 @@ fn draw_directory_browser(frame: &mut Frame, app: &mut App, size: Rect) {
Style::new()
.fg(Color::Cyan)
.bg(Color::Black)
+ .add_modifier(Modifier::BOLD)
.add_modifier(Modifier::REVERSED),
)
.highlight_symbol(">>")
@@ -103,10 +104,10 @@ fn draw_queue(frame: &mut Frame, app: &mut App, size: Rect) {
Style::new()
.fg(Color::Cyan)
.bg(Color::Black)
+ .add_modifier(Modifier::BOLD)
.add_modifier(Modifier::REVERSED),
)
- .highlight_symbol(">>")
- .repeat_highlight_symbol(true);
+ .highlight_symbol(">>");
queue_state.select(Some(app.queue_list.index));
frame.render_stateful_widget(list, size, &mut queue_state);
@@ -129,6 +130,7 @@ fn draw_playlists(frame: &mut Frame, app: &mut App, size: Rect) {
Style::new()
.fg(Color::Cyan)
.bg(Color::Black)
+ .add_modifier(Modifier::BOLD)
.add_modifier(Modifier::REVERSED),
)
.highlight_symbol(">>")