diff --git a/wezterm-gui/src/commands.rs b/wezterm-gui/src/commands.rs index 9f5062f1a..3cbc35c4c 100644 --- a/wezterm-gui/src/commands.rs +++ b/wezterm-gui/src/commands.rs @@ -64,6 +64,7 @@ pub struct CommandDef { pub args: &'static [ArgType], /// Where to place the command in a menubar pub menubar: &'static [&'static str], + pub icon: Option<&'static str>, } #[derive(Debug, Clone)] @@ -73,6 +74,7 @@ pub struct ExpandedCommand { pub action: KeyAssignment, pub keys: Vec<(Modifiers, KeyCode)>, pub menubar: &'static [&'static str], + pub icon: Option<&'static str>, } impl std::fmt::Debug for CommandDef { @@ -175,6 +177,7 @@ impl CommandDef { keys, action, menubar: def.menubar, + icon: def.icon, }) } } @@ -211,6 +214,7 @@ impl CommandDef { keys: vec![], action: KeyAssignment::SpawnCommandInNewTab(cmd.clone()), menubar: &["Shell"], + icon: Some("mdi_tab_plus"), }); } @@ -245,6 +249,7 @@ impl CommandDef { ..SpawnCommand::default() }), menubar: &["Shell"], + icon: Some("mdi_tab_plus"), }); } else { result.push(ExpandedCommand { @@ -253,6 +258,7 @@ impl CommandDef { keys: vec![], action: KeyAssignment::AttachDomain(name.to_string()), menubar: &["Shell", "Attach"], + icon: Some("mdi_pipe"), }); } } @@ -274,6 +280,7 @@ impl CommandDef { name.to_string(), )), menubar: &["Shell", "Detach"], + icon: Some("mdi_pipe_disconnected"), }); } } @@ -290,6 +297,7 @@ impl CommandDef { spawn: None, }, menubar: &["Window", "Workspace"], + icon: None, }); } } @@ -302,6 +310,7 @@ impl CommandDef { spawn: None, }, menubar: &["Window", "Workspace"], + icon: None, }); } @@ -322,6 +331,7 @@ impl CommandDef { keys: vec![], action: entry.action.clone(), menubar: cmd.menubar, + icon: cmd.icon, }); } } @@ -341,6 +351,7 @@ impl CommandDef { keys: vec![], action: entry.action.clone(), menubar: cmd.menubar, + icon: cmd.icon, }); } } @@ -582,6 +593,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Copy to primary selection".into(), @@ -589,6 +601,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Copy to clipboard".into(), @@ -599,6 +612,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Copy to clipboard and primary selection".into(), @@ -606,6 +620,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Paste from clipboard".into(), @@ -616,6 +631,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Toggle full screen mode".into(), @@ -623,6 +639,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Hide/Minimize Window".into(), @@ -630,6 +647,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Show/Restore Window".into(), @@ -637,6 +655,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Hide Application".into(), @@ -646,6 +665,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "New Window".into(), @@ -653,6 +673,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Clear scrollback".into(), @@ -662,6 +683,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Clear the scrollback and viewport".into(), @@ -669,6 +691,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Search pane output".into(), @@ -676,6 +699,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Search pane output".into(), @@ -683,6 +707,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Show debug overlay".into(), @@ -690,6 +715,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Enter QuickSelect mode".into(), @@ -697,6 +723,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Enter QuickSelect mode".into(), @@ -704,6 +731,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Enter Emoji / Character selection mode".into(), @@ -711,6 +739,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Enter Pane selection mode".into(), @@ -718,6 +747,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Decrease font size".into(), @@ -728,6 +758,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Increase font size".into(), @@ -738,6 +769,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Reset font size".into(), @@ -748,6 +780,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Reset the window and font size".into(), @@ -755,6 +788,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "New Tab".into(), @@ -762,6 +796,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "New Tab (Default Domain)".into(), @@ -769,6 +804,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("New Tab (`{name}` Domain)").into(), @@ -776,6 +812,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("New Tab (Domain with id {id})").into(), @@ -783,6 +820,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Spawn a new Tab with {cmd:?}").into(), @@ -790,6 +828,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Spawn a new Window with {cmd:?}").into(), @@ -797,6 +836,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Activate right-most tab".into(), @@ -804,6 +844,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option { let n = *n; @@ -819,6 +860,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option { @@ -830,6 +872,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { @@ -842,6 +885,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Un-Zooms the current Pane").into(), @@ -849,6 +893,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Emit event `{name}`").into(), @@ -860,6 +905,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Close current Tab".into(), @@ -869,6 +915,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Close current Tab".into(), @@ -878,6 +925,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Close current Pane".into(), @@ -887,6 +935,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Close current Pane".into(), @@ -896,6 +945,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Activate the tab to the left".into(), @@ -909,6 +959,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Activate the tab to the right".into(), @@ -922,6 +973,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option { let (direction, amount) = if *n < 0 { ("left", -n) } else { ("right", *n) }; @@ -936,6 +988,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { @@ -944,6 +997,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Activate the tab to the right (no wrapping)".into(), @@ -951,6 +1005,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option { let (direction, amount) = if *n < 0 { ("left", -n) } else { ("right", *n) }; @@ -961,6 +1016,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { @@ -969,6 +1025,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Quit WezTerm".into(), @@ -976,6 +1033,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Move tab one place to the left".into(), @@ -985,6 +1043,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Move tab one place to the right".into(), @@ -994,12 +1053,13 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option { - let (direction, amount) = if *n < 0 { - ("left", (-n).to_string()) + let (direction, amount, icon) = if *n < 0 { + ("left", (-n).to_string(), "mdi_chevron_double_left") } else { - ("right", n.to_string()) + ("right", n.to_string(), "mdi_chevron_double_right") }; CommandDef { @@ -1012,6 +1072,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option { @@ -1026,6 +1087,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option { @@ -1037,6 +1099,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option Option Option Option Option { @@ -1096,6 +1163,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { @@ -1108,6 +1176,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Scroll to the bottom".into(), @@ -1115,6 +1184,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Scroll to the top".into(), @@ -1122,6 +1192,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Activate Copy Mode".into(), @@ -1131,6 +1202,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option Option Option CommandDef { brief: "Split Horizontally (Left/Right)".into(), @@ -1174,6 +1248,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Split Vertically (Top/Bottom)".into(), @@ -1183,6 +1258,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Resize Pane {amount} cells to the Left").into(), @@ -1195,6 +1271,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Resize Pane {amount} cells to the Right").into(), @@ -1207,6 +1284,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Resize Pane {amount} cells Upwards").into(), @@ -1219,6 +1297,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Resize Pane {amount} cells Downwards").into(), @@ -1231,6 +1310,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option return None, ActivatePaneDirection(PaneDirection::Next | PaneDirection::Prev) => return None, @@ -1240,6 +1320,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Activate Pane Right".into(), @@ -1247,6 +1328,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Activate Pane Up".into(), @@ -1254,6 +1336,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Activate Pane Down".into(), @@ -1261,6 +1344,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Toggle Pane Zoom".into(), @@ -1268,6 +1352,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Activate the last active tab".into(), @@ -1275,6 +1360,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Clear the key table stack".into(), @@ -1282,6 +1368,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Open link at mouse cursor".into(), @@ -1289,6 +1376,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Show the launcher".into(), @@ -1296,6 +1384,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Navigate tabs".into(), @@ -1303,6 +1392,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Detach the domain of the active pane".into(), @@ -1310,6 +1400,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Detach the default domain".into(), @@ -1317,6 +1408,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Detach the `{name}` domain").into(), @@ -1324,6 +1416,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Detach the domain with id {id}").into(), @@ -1331,6 +1424,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option match uri.as_ref() { "https://wezfurlong.org/wezterm/" => CommandDef { @@ -1339,6 +1433,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Discuss on GitHub".into(), @@ -1346,6 +1441,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Search or report issue on GitHub".into(), @@ -1353,6 +1449,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Open {uri} in your browser").into(), @@ -1360,6 +1457,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { @@ -1376,6 +1474,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!( @@ -1391,6 +1490,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Does nothing".into(), @@ -1398,6 +1498,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option return None, SelectTextAtMouseCursor(mode) => CommandDef { @@ -1414,6 +1515,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!( @@ -1429,6 +1531,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Clears the selection in the current pane".into(), @@ -1436,6 +1539,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Completes selection, and copy {destination:?}").into(), @@ -1447,6 +1551,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!( @@ -1462,6 +1567,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Requests a window drag operation from \ @@ -1473,6 +1579,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option { let mut brief = String::new(); @@ -1495,6 +1602,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option Option Option Option Option { let (direction, amount) = if *n < 0 { @@ -1578,6 +1690,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { @@ -1586,6 +1699,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Pop the current key table".into(), @@ -1593,6 +1707,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Attach domain `{name}`").into(), @@ -1600,6 +1715,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("{copy_mode:?}").into(), @@ -1607,6 +1723,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: format!("Rotate panes {direction:?}").into(), @@ -1614,6 +1731,10 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option "mdi_rotate_right", + RotationDirection::CounterClockwise => "mdi_rotate_left", + }), }, SplitPane(split) => { let direction = split.direction; @@ -1623,6 +1744,11 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option Some("cod_split_vertical"), + PaneDirection::Left | PaneDirection::Right => Some("cod_split_horizontal"), + PaneDirection::Next | PaneDirection::Prev => None, + }, } } ResetTerminal => CommandDef { @@ -1631,6 +1757,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option CommandDef { brief: "Activate Command Palette".into(), @@ -1638,6 +1765,7 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option NERD_FONTS.get(nf).unwrap_or_else(|| { + log::error!("nerdfont {nf} not found in NERD_FONTS"); + &'?' + }), + None => &' ', + }; + let (bg, text) = if display_idx == selected_row { ( term_window @@ -255,19 +264,26 @@ impl CommandPalette { }; elements.push( - Element::new(&font, ElementContent::Text(label)) - .colors(ElementColors { - border: BorderColor::default(), - bg, - text, - }) - .padding(BoxDimension { - left: Dimension::Cells(0.25), - right: Dimension::Cells(0.25), - top: Dimension::Cells(0.), - bottom: Dimension::Cells(0.), - }) - .display(DisplayType::Block), + Element::new( + &font, + ElementContent::Children(vec![ + Element::new(&font, ElementContent::Text(icon.to_string())) + .min_width(Some(Dimension::Cells(2.))), + Element::new(&font, ElementContent::Text(label)), + ]), + ) + .colors(ElementColors { + border: BorderColor::default(), + bg, + text, + }) + .padding(BoxDimension { + left: Dimension::Cells(0.25), + right: Dimension::Cells(0.25), + top: Dimension::Cells(0.), + bottom: Dimension::Cells(0.), + }) + .display(DisplayType::Block), ); } @@ -331,7 +347,7 @@ impl CommandPalette { let size = term_window.terminal_size; // Avoid covering the entire width - let desired_width = (size.cols / 3).max(80).min(size.cols); + let desired_width = (size.cols / 3).max(75).min(size.cols); // Center it let avail_pixel_width =