diff --git a/crates/keymap/README.md b/crates/keymap/README.md index 81b55ec95..1f2d1b752 100644 --- a/crates/keymap/README.md +++ b/crates/keymap/README.md @@ -13,6 +13,9 @@ its file-format readers and its UI. kept or reported (`Keymap::problems`, the import report). - Hostile input is capped: commands, bindings per command, text lengths, import entries, keys, path segments and fuzzy suggestions (the `MAX_*` constants). What is cut is counted. +- Reserved chords are opt-in. A keymap reserves no chord unless the app passes a list to + `Keymap::with_reserved`, e.g. `reserved::system(platform)` for the operating system's window + switching and closing chords. A reserved chord cannot be assigned or bound. - Dependencies: `serde` and `serde_json`; `egui` with the `egui` feature. ## A catalogue and dispatch diff --git a/crates/keymap/src/keymap.rs b/crates/keymap/src/keymap.rs index d2a81ae98..4ceb76d16 100644 --- a/crates/keymap/src/keymap.rs +++ b/crates/keymap/src/keymap.rs @@ -434,7 +434,8 @@ impl Keymap { self } - /// Chords that cannot be assigned, e.g. [`reserved::system`](crate::reserved::system). + /// Chords that cannot be assigned or bound, e.g. [`reserved::system`](crate::reserved::system). + /// Without this call the keymap reserves no chord. pub fn with_reserved(mut self, chords: Vec) -> Keymap { self.reserved = chords; self.reload(); diff --git a/crates/keymap/src/lib.rs b/crates/keymap/src/lib.rs index f669e6d7b..e673848c7 100644 --- a/crates/keymap/src/lib.rs +++ b/crates/keymap/src/lib.rs @@ -6,8 +6,10 @@ //! protocols store, display text per platform, and a reader for other applications' key text. //! [`command`] names what a binding runs, [`scope`] where it works, and [`keymap`] holds an app's //! catalogue with default bindings, the user's [`Overrides`], dispatch ([`Keymap::lookup`]), -//! editing and conflicts. [`reserved`] lists the chords each operating system takes. [`import`] -//! brings in other applications' shortcut sets. With the `egui` feature, the `egui` module +//! editing and conflicts. [`reserved`] lists the chords each operating system takes; a keymap +//! reserves no chord unless the app opts in with [`Keymap::with_reserved`], e.g. +//! `with_reserved(reserved::system(platform))`. [`import`] brings in other applications' shortcut +//! sets. With the `egui` feature, the `egui` module //! converts to and from egui keys, matches key presses against bindings and dispatches a frame's //! key events. //! diff --git a/crates/keymap/src/reserved.rs b/crates/keymap/src/reserved.rs index 7dbf847bf..4d64d36ac 100644 --- a/crates/keymap/src/reserved.rs +++ b/crates/keymap/src/reserved.rs @@ -1,4 +1,7 @@ //! Chords the operating system takes before the app sees them. +//! +//! A keymap reserves these only when the app passes them to +//! [`Keymap::with_reserved`](crate::Keymap::with_reserved). use crate::chord::{Chord, Platform}; @@ -25,7 +28,8 @@ const LINUX: &[&str] = &[ "Cmd+Alt+F12", ]; -/// The window switching, closing and session chords of `platform`. +/// The window switching, closing and session chords of `platform`, for +/// [`Keymap::with_reserved`](crate::Keymap::with_reserved). pub fn system(platform: Platform) -> Vec { let list = match platform { Platform::Mac => MAC,