Enable binding multiple commands to a key.

This enables useful combinations of commands like `Space -> queue; move
down 1` using ';' as command separator. ';' can be escaped using ';;'.
This commit is contained in:
HMH
2021-09-06 12:17:36 +02:00
committed by Henrik Friedrichsen
parent d17c66f8ad
commit 102acd803e
4 changed files with 335 additions and 264 deletions

View File

@@ -17,7 +17,7 @@ pub struct HelpView {
}
impl HelpView {
pub fn new(bindings: HashMap<String, Command>) -> HelpView {
pub fn new(bindings: HashMap<String, Vec<Command>>) -> HelpView {
let mut text = StyledString::styled("Keybindings\n\n", Effect::Bold);
let note = format!(
@@ -30,8 +30,16 @@ impl HelpView {
keys.sort();
for key in keys {
let command = &bindings[key];
let binding = format!("{} -> {}\n", key, command);
let commands = &bindings[key];
let binding = format!(
"{} -> {}\n",
key,
commands
.iter()
.map(|c| c.to_string())
.collect::<Vec<_>>()
.join("; ")
);
text.append(binding);
}