feat: add insert command to paste spotify links (#277)
* feat: add insert command to paste spotify links - use Ctrl-v to paste from clipboard or use :insert without an argument * fix: handle paste on disabled clipboard feature * fix: handle wrong URIs Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
This commit is contained in:
@@ -114,6 +114,7 @@ pub enum Command {
|
||||
Help,
|
||||
ReloadConfig,
|
||||
Noop,
|
||||
Insert(Option<String>),
|
||||
}
|
||||
|
||||
impl fmt::Display for Command {
|
||||
@@ -169,6 +170,7 @@ impl fmt::Display for Command {
|
||||
Command::Jump(term) => format!("jump {}", term),
|
||||
Command::Help => "help".to_string(),
|
||||
Command::ReloadConfig => "reload".to_string(),
|
||||
Command::Insert(_) => "insert".to_string(),
|
||||
};
|
||||
write!(f, "{}", repr)
|
||||
}
|
||||
@@ -346,6 +348,14 @@ pub fn parse(input: &str) -> Option<Command> {
|
||||
"voldown" => Some(Command::VolumeDown),
|
||||
"help" => Some(Command::Help),
|
||||
"reload" => Some(Command::ReloadConfig),
|
||||
"insert" => {
|
||||
if args.is_empty() {
|
||||
Some(Command::Insert(None))
|
||||
} else {
|
||||
args.get(0)
|
||||
.map(|url| Command::Insert(Some((*url).to_string())))
|
||||
}
|
||||
}
|
||||
"noop" => Some(Command::Noop),
|
||||
_ => None,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user