1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-21 03:39:16 +03:00

launcher: prefer to use human description of key assignment

refs: https://github.com/wez/wezterm/issues/1485
This commit is contained in:
Wez Furlong 2022-12-21 13:31:05 -07:00
parent 98479d8530
commit 82da1b42f7
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387
2 changed files with 10 additions and 3 deletions

View File

@ -271,7 +271,7 @@ fn english_ordinal(n: isize) -> String {
/// of metadata that is useful in the command palette/menubar context.
/// This function will be called for the result of compute_default_actions(),
/// but can also be used to describe user-provided commands
fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option<CommandDef> {
pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option<CommandDef> {
Some(match action {
PasteFrom(ClipboardPasteSource::PrimarySelection) => CommandDef {
brief: "Paste primary selection".into(),

View File

@ -5,6 +5,7 @@
//! be rendered as a popup/context menu if the system supports it; at the
//! time of writing our window layer doesn't provide an API for context
//! menus.
use crate::commands::derive_command_from_key_assignment;
use crate::inputmap::InputMap;
use crate::termwindow::TermWindowNotif;
use config::configuration;
@ -320,13 +321,19 @@ impl LauncherState {
// Avoid duplicate entries
continue;
}
key_entries.push(Entry {
label: format!(
let label = match derive_command_from_key_assignment(&entry.action) {
Some(cmd) => format!("{}. {}", cmd.brief, cmd.doc),
None => format!(
"{:?} ({} {})",
entry.action,
mods.to_string(),
keycode.to_string().escape_debug()
),
};
key_entries.push(Entry {
label,
action: entry.action,
});
}