Add command defs to default launcher menu view

This commit is contained in:
Wez Furlong committed 2022-04-10 06:52:12 -07:00
1 parent b83c3272f6
commit 2e8b5f5e7b
3 files changed
+22 -14

No files matched your search

+1 -1
View File
@@ -146,7 +146,7 @@ impl CommandDef {
}
}
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct ExpandedCommand {
pub brief: Cow<'static, str>,
pub doc: Cow<'static, str>,
+19 -12
View File
@@ -295,7 +295,24 @@ impl LauncherState {
});
}
// Grab interestig key assignments and show those as a kind of command palette
if args.flags.contains(LauncherFlags::COMMANDS) {
let commands = crate::commands::CommandDef::expanded_commands(&config);
for cmd in commands {
if matches!(
&cmd.action,
KeyAssignment::ActivateTabRelative(_) | KeyAssignment::ActivateTab(_)
) {
// Filter out some noisy, repetitive entries
continue;
}
self.entries.push(Entry {
label: format!("{}. {}", cmd.brief, cmd.doc),
kind: EntryKind::KeyAssignment(cmd.action),
});
}
}
// Grab interesting key assignments and show those as a kind of command palette
if args.flags.contains(LauncherFlags::KEY_ASSIGNMENTS) {
let input_map = InputMap::new(&config);
let mut key_entries: Vec<Entry> = vec![];
@@ -325,7 +342,7 @@ impl LauncherState {
"{:?} ({} {})",
entry.action,
mods.to_string(),
keycode.to_string()
keycode.to_string().escape_debug()
),
kind: EntryKind::KeyAssignment(entry.action),
});
@@ -333,16 +350,6 @@ impl LauncherState {
key_entries.sort_by(|a, b| a.label.cmp(&b.label));
self.entries.append(&mut key_entries);
}
if args.flags.contains(LauncherFlags::COMMANDS) {
let commands = crate::commands::CommandDef::expanded_commands(&config);
for cmd in commands {
self.entries.push(Entry {
label: format!("{}. {}", cmd.brief, cmd.doc),
kind: EntryKind::KeyAssignment(cmd.action),
});
}
}
}
fn render(&mut self, term: &mut TermWizTerminal) -> termwiz::Result<()> {
+2 -1
View File
@@ -1828,7 +1828,8 @@ impl TermWindow {
LauncherFlags::LAUNCH_MENU_ITEMS
| LauncherFlags::WORKSPACES
| LauncherFlags::DOMAINS
| LauncherFlags::KEY_ASSIGNMENTS,
| LauncherFlags::KEY_ASSIGNMENTS
| LauncherFlags::COMMANDS,
);
}