Add KeyBindings to CommandPalette
This commit is contained in:
parent
b918c27cf9
commit
25bc898807
7 changed files with 116 additions and 273 deletions
|
@ -11,7 +11,7 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
use theme::ActiveTheme;
|
||||
use ui::{v_stack, HighlightedLabel, StyledExt};
|
||||
use ui::{h_stack, v_stack, HighlightedLabel, KeyBinding, StyledExt};
|
||||
use util::{
|
||||
channel::{parse_zed_link, ReleaseChannel, RELEASE_CHANNEL},
|
||||
ResultExt,
|
||||
|
@ -318,66 +318,16 @@ impl PickerDelegate for CommandPaletteDelegate {
|
|||
.rounded_md()
|
||||
.when(selected, |this| this.bg(colors.ghost_element_selected))
|
||||
.hover(|this| this.bg(colors.ghost_element_hover))
|
||||
.child(HighlightedLabel::new(
|
||||
command.name.clone(),
|
||||
r#match.positions.clone(),
|
||||
))
|
||||
.child(
|
||||
h_stack()
|
||||
.justify_between()
|
||||
.child(HighlightedLabel::new(
|
||||
command.name.clone(),
|
||||
r#match.positions.clone(),
|
||||
))
|
||||
.children(KeyBinding::for_action(&*command.action, cx)),
|
||||
)
|
||||
}
|
||||
|
||||
// fn render_match(
|
||||
// &self,
|
||||
// ix: usize,
|
||||
// mouse_state: &mut MouseState,
|
||||
// selected: bool,
|
||||
// cx: &gpui::AppContext,
|
||||
// ) -> AnyElement<Picker<Self>> {
|
||||
// let mat = &self.matches[ix];
|
||||
// let command = &self.actions[mat.candidate_id];
|
||||
// let theme = theme::current(cx);
|
||||
// let style = theme.picker.item.in_state(selected).style_for(mouse_state);
|
||||
// let key_style = &theme.command_palette.key.in_state(selected);
|
||||
// let keystroke_spacing = theme.command_palette.keystroke_spacing;
|
||||
|
||||
// Flex::row()
|
||||
// .with_child(
|
||||
// Label::new(mat.string.clone(), style.label.clone())
|
||||
// .with_highlights(mat.positions.clone()),
|
||||
// )
|
||||
// .with_children(command.keystrokes.iter().map(|keystroke| {
|
||||
// Flex::row()
|
||||
// .with_children(
|
||||
// [
|
||||
// (keystroke.ctrl, "^"),
|
||||
// (keystroke.alt, "⌥"),
|
||||
// (keystroke.cmd, "⌘"),
|
||||
// (keystroke.shift, "⇧"),
|
||||
// ]
|
||||
// .into_iter()
|
||||
// .filter_map(|(modifier, label)| {
|
||||
// if modifier {
|
||||
// Some(
|
||||
// Label::new(label, key_style.label.clone())
|
||||
// .contained()
|
||||
// .with_style(key_style.container),
|
||||
// )
|
||||
// } else {
|
||||
// None
|
||||
// }
|
||||
// }),
|
||||
// )
|
||||
// .with_child(
|
||||
// Label::new(keystroke.key.clone(), key_style.label.clone())
|
||||
// .contained()
|
||||
// .with_style(key_style.container),
|
||||
// )
|
||||
// .contained()
|
||||
// .with_margin_left(keystroke_spacing)
|
||||
// .flex_float()
|
||||
// }))
|
||||
// .contained()
|
||||
// .with_style(style.container)
|
||||
// .into_any()
|
||||
// }
|
||||
}
|
||||
|
||||
fn humanize_action_name(name: &str) -> String {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue