keymap-editor
Builds KeymapEditor


The code that drew it
A still frame holds a repeating animation at its first frame and a one-shot at its last, because a still of a moving thing is not reproducible. Run the gallery to review motion.
fn keymap_editor(window: &mut Window, cx: &mut App) -> AnyElement {
if !cx.has_global::<SceneKeymapEditor>() {
let editor = cx.new(|cx| {
KeymapEditor::new("scene.keymap-editor", window, cx).commands([
KeymapCommand::new("workspace.open", "Open workspace")
.context("Workspace")
.defaults(["cmd-o"])
.bindings([
KeymapBinding::new("user", "cmd-shift-o")
.conflict("Already opens recent workspaces")
.provenance("User keymap"),
KeymapBinding::new("workspace", "ctrl-o").provenance("Workspace keymap"),
])
.searchable("Open a folder or project", ["folder", "project"]),
KeymapCommand::new("terminal.toggle", "Toggle terminal")
.context("Terminal")
.defaults(["ctrl-`"])
.bindings([KeymapBinding::new("default", "ctrl-`")])
.searchable("Show the integrated terminal", ["panel", "console"]),
KeymapCommand::new("policy.locked", "Managed shortcut")
.context("Workspace")
.defaults(["cmd-l"])
.bindings([KeymapBinding::new("managed", "cmd-l").provenance("Host policy")])
.refused("This binding is managed by the host."),
])
});
cx.set_global(SceneKeymapEditor(editor));
}
let editor = cx.global::<SceneKeymapEditor>().0.clone();
let theme = cx.theme().clone();
stack(&theme)
.w(px(760.0))
.child(editor)
.child(caption(
&theme,
"Bindings remain caller-owned; add, remove, and reset are intents.",
))
.into_any_element()
}