mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 00:34:25 +00:00
fwb2-fix: commands::bindings reads the runtime keymap's keys for a command
This commit is contained in:
@@ -613,6 +613,11 @@ pub(crate) fn edit_chords(ctx: &Context) -> Arc<[(EditCommand, Chord)]> {
|
||||
with(ctx, |board| board.keymap.as_ref().map(|cache| Arc::clone(&cache.edit_chords)).unwrap_or_default())
|
||||
}
|
||||
|
||||
/// The bindings the window's keymap gives `command`; none before the first frame builds one.
|
||||
pub(crate) fn bindings(ctx: &Context, command: &CommandRef) -> Vec<craft_keymap::Binding> {
|
||||
with(ctx, |board| board.keymap.as_ref().map(|cache| cache.keymap.bindings(command)).unwrap_or_default())
|
||||
}
|
||||
|
||||
/// The chords bound to the window's keys, which the input hook takes before any component.
|
||||
pub(crate) fn window_shortcuts(ctx: &Context) -> Arc<[(WindowShortcut, Chord)]> {
|
||||
with(ctx, |board| board.keymap.as_ref().map(|cache| Arc::clone(&cache.window_shortcuts)).unwrap_or_default())
|
||||
|
||||
@@ -442,6 +442,12 @@ pub fn resolve(ctx: &Context, command: impl Into<CommandRef>) -> ResolvedCommand
|
||||
board::resolve_global(ctx, &command.into())
|
||||
}
|
||||
|
||||
/// The keys `command` has in the runtime's keymap: its defaults under the user's overrides (`CommandInput`), on the
|
||||
/// window's platform, double presses included. Empty before the first frame.
|
||||
pub fn bindings(ctx: &Context, command: &CommandRef) -> Vec<Binding> {
|
||||
board::bindings(ctx, command)
|
||||
}
|
||||
|
||||
/// `command` as [`resolve`] shows it, from the window under the modal layer whose body is running, as that window is
|
||||
/// once the layer closes: for a surface that closes before its command runs (the command palette), whose own layer
|
||||
/// does not block the command. Outside a modal layer it is [`resolve`].
|
||||
|
||||
Reference in New Issue
Block a user