From a78bbe6684239e2a0816a8bb7264e39ad6ddabf5 Mon Sep 17 00:00:00 2001 From: Henrik Friedrichsen Date: Fri, 1 Oct 2021 18:43:45 +0200 Subject: [PATCH] Add `redraw` command and bind to CTRL+L solves #609 --- src/command.rs | 3 +++ src/commands.rs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/command.rs b/src/command.rs index 584bda8..47f7b4c 100644 --- a/src/command.rs +++ b/src/command.rs @@ -135,6 +135,7 @@ pub enum Command { Sort(SortKey, SortDirection), Logout, ShowRecommendations(TargetMode), + Redraw, } impl fmt::Display for Command { @@ -195,6 +196,7 @@ impl fmt::Display for Command { Command::Sort(key, direction) => format!("sort {} {}", key, direction), Command::Logout => "logout".to_string(), Command::ShowRecommendations(mode) => format!("similar {}", mode), + Command::Redraw => "redraw".to_string(), }; // escape the command separator let repr = repr.replace(";", ";;"); @@ -462,6 +464,7 @@ pub fn parse(input: &str) -> Option> { }) .map(Command::ShowRecommendations), "noop" => Some(Command::Noop), + "redraw" => Some(Command::Redraw), _ => None, }; commands.push(command?); diff --git a/src/commands.rs b/src/commands.rs index 90fb425..eac01a2 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -119,6 +119,11 @@ impl CommandManager { s.quit(); Ok(None) } + Command::Redraw => { + info!("Redrawing screen"); + s.clear(); + Ok(None) + } Command::Stop => { self.queue.stop(); Ok(None) @@ -346,6 +351,7 @@ impl CommandManager { let mut kb = HashMap::new(); kb.insert("q".into(), vec![Command::Quit]); + kb.insert("Ctrl+l".into(), vec![Command::Redraw]); kb.insert("Shift+p".into(), vec![Command::TogglePlay]); kb.insert("Shift+u".into(), vec![Command::UpdateLibrary]); kb.insert("Shift+s".into(), vec![Command::Stop]);