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

@@ -288,13 +288,15 @@ async fn main() -> Result<(), String> {
}
} else {
let parsed = command::parse(cmd_without_prefix);
if let Some(parsed) = parsed {
if let Some(commands) = parsed {
if let Some(data) = s.user_data::<UserData>().cloned() {
data.cmd.handle(s, parsed)
for cmd in commands {
data.cmd.handle(s, cmd);
}
}
} else {
let mut main = s.find_name::<ui::layout::Layout>("main").unwrap();
let err_msg = format!("Unknown command: \"{}\"", cmd_without_prefix);
let err_msg = format!("Failed to parse command(s): \"{}\"", cmd_without_prefix);
main.set_result(Err(err_msg));
}
}