pub struct KeyBindings { /* private fields */ }Expand description
Complete keybindings configuration.
Implementations§
Source§impl KeyBindings
impl KeyBindings
Sourcepub fn load(path: &Path) -> Result<Self, Error>
pub fn load(path: &Path) -> Result<Self, Error>
Load keybindings from a JSON file, merging with defaults.
Sourcepub fn user_config_path() -> PathBuf
pub fn user_config_path() -> PathBuf
Get the default user keybindings path: ~/.pi/agent/keybindings.json
Sourcepub fn load_from_user_config() -> KeyBindingsLoadResult
pub fn load_from_user_config() -> KeyBindingsLoadResult
Load keybindings from user config, returning defaults with diagnostics if loading fails.
This method never fails - it always returns valid keybindings (defaults at minimum).
Warnings are collected in KeyBindingsLoadResult for display to the user.
§User Config Format
The config file is a JSON object mapping action IDs (camelCase) to key bindings:
{
"cursorUp": ["up", "ctrl+p"],
"cursorDown": ["down", "ctrl+n"],
"deleteWordBackward": ["ctrl+w", "alt+backspace"]
}Sourcepub fn load_from_path_with_diagnostics(path: &Path) -> KeyBindingsLoadResult
pub fn load_from_path_with_diagnostics(path: &Path) -> KeyBindingsLoadResult
Load keybindings from a specific path with full diagnostics.
Returns defaults with warnings if:
- File doesn’t exist (no warning - this is normal)
- File is not valid JSON
- File contains unknown action IDs
- File contains invalid key strings
Sourcepub fn lookup(&self, binding: &KeyBinding) -> Option<AppAction>
pub fn lookup(&self, binding: &KeyBinding) -> Option<AppAction>
Look up the action for a key binding.
Sourcepub fn matching_actions(&self, binding: &KeyBinding) -> Vec<AppAction>
pub fn matching_actions(&self, binding: &KeyBinding) -> Vec<AppAction>
Return all actions bound to a key binding.
Many bindings are context-dependent (e.g. ctrl+d can mean “delete forward” in the editor
but “exit” when the editor is empty). Callers should resolve collisions based on UI state.
Sourcepub fn get_bindings(&self, action: AppAction) -> &[KeyBinding]
pub fn get_bindings(&self, action: AppAction) -> &[KeyBinding]
Get all key bindings for an action.
Sourcepub fn iter(&self) -> impl Iterator<Item = (AppAction, &[KeyBinding])>
pub fn iter(&self) -> impl Iterator<Item = (AppAction, &[KeyBinding])>
Iterate all actions with their bindings (for /hotkeys display).
Sourcepub fn iter_category(
&self,
category: ActionCategory,
) -> impl Iterator<Item = (AppAction, &[KeyBinding])>
pub fn iter_category( &self, category: ActionCategory, ) -> impl Iterator<Item = (AppAction, &[KeyBinding])>
Iterate actions in a category with their bindings.
Trait Implementations§
Source§impl Clone for KeyBindings
impl Clone for KeyBindings
Source§fn clone(&self) -> KeyBindings
fn clone(&self) -> KeyBindings
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KeyBindings
impl Debug for KeyBindings
Auto Trait Implementations§
impl Freeze for KeyBindings
impl RefUnwindSafe for KeyBindings
impl Send for KeyBindings
impl Sync for KeyBindings
impl Unpin for KeyBindings
impl UnsafeUnpin for KeyBindings
impl UnwindSafe for KeyBindings
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().