pub struct KeybindingResolver { /* private fields */ }Expand description
Resolves key events to actions based on configuration
Implementations§
Source§impl KeybindingResolver
impl KeybindingResolver
Sourcepub fn load_plugin_default(
&mut self,
context: KeyContext,
key_code: KeyCode,
modifiers: KeyModifiers,
action: Action,
)
pub fn load_plugin_default( &mut self, context: KeyContext, key_code: KeyCode, modifiers: KeyModifiers, action: Action, )
Load a plugin default binding (for mode bindings registered via defineMode)
Sourcepub fn load_plugin_chord_default(
&mut self,
context: KeyContext,
sequence: Vec<(KeyCode, KeyModifiers)>,
action: Action,
)
pub fn load_plugin_chord_default( &mut self, context: KeyContext, sequence: Vec<(KeyCode, KeyModifiers)>, action: Action, )
Load a plugin default chord binding (for mode chord bindings from defineMode)
Sourcepub fn clear_plugin_defaults_for_mode(&mut self, mode_name: &str)
pub fn clear_plugin_defaults_for_mode(&mut self, mode_name: &str)
Clear all plugin default bindings (single-key and chord) for a specific mode
Sourcepub fn set_mode_inherits_normal_bindings(
&mut self,
mode_name: &str,
inherit: bool,
)
pub fn set_mode_inherits_normal_bindings( &mut self, mode_name: &str, inherit: bool, )
Mark (or unmark) a plugin mode as inheriting Normal-context bindings for keys it doesn’t bind itself.
Sourcepub fn get_plugin_defaults(
&self,
) -> &HashMap<KeyContext, HashMap<(KeyCode, KeyModifiers), Action>>
pub fn get_plugin_defaults( &self, ) -> &HashMap<KeyContext, HashMap<(KeyCode, KeyModifiers), Action>>
Get all plugin default bindings (for keybinding editor display)
Sourcepub fn is_terminal_ui_action(action: &Action) -> bool
pub fn is_terminal_ui_action(action: &Action) -> bool
Check if an action is a UI action that should work in terminal mode (without keyboard capture). These are general navigation and UI actions that don’t involve text editing.
Sourcepub fn resolve_chord(
&self,
chord_state: &[(KeyCode, KeyModifiers)],
event: &KeyEvent,
context: KeyContext,
) -> ChordResolution
pub fn resolve_chord( &self, chord_state: &[(KeyCode, KeyModifiers)], event: &KeyEvent, context: KeyContext, ) -> ChordResolution
Resolve a key event with chord state to check for multi-key sequences Returns:
- Complete(action): The sequence is complete, execute the action
- Partial: The sequence is partial (prefix of a chord), wait for more keys
- NoMatch: The sequence doesn’t match any chord binding
Sourcepub fn resolve(&self, event: &KeyEvent, context: KeyContext) -> Action
pub fn resolve(&self, event: &KeyEvent, context: KeyContext) -> Action
Resolve a key event to an action in the given context
Sourcepub fn resolve_in_context_only(
&self,
event: &KeyEvent,
context: KeyContext,
) -> Option<Action>
pub fn resolve_in_context_only( &self, event: &KeyEvent, context: KeyContext, ) -> Option<Action>
Resolve a key event looking only in the specified context (no Global fallback). This is used when a modal context (like Prompt) needs to check if it has a specific binding without being overridden by Global bindings. Returns None if no binding found in the specified context.
Sourcepub fn has_explicit_binding(
&self,
event: &KeyEvent,
context: &KeyContext,
) -> bool
pub fn has_explicit_binding( &self, event: &KeyEvent, context: &KeyContext, ) -> bool
true iff this context has its own binding for event —
either user-customised, built-in default, or plugin-default
(from defineMode). Unlike [resolve], this does not
fall back to Global or Normal-context bindings; it’s the
“did someone explicitly claim this key for this mode”
check used by dispatch_floating_widget_key to decide
whether to let mode dispatch override its smart-key defaults.
Sourcepub fn resolve_terminal_ui_action(&self, event: &KeyEvent) -> Action
pub fn resolve_terminal_ui_action(&self, event: &KeyEvent) -> Action
Resolve a key event to a UI action for terminal mode. Only returns actions that are classified as UI actions (is_terminal_ui_action). Returns Action::None if the key doesn’t map to a UI action.
Sourcepub fn bound_plugin_action_names(&self) -> HashSet<String>
pub fn bound_plugin_action_names(&self) -> HashSet<String>
Find the primary keybinding for a given action (for display in menus)
Returns a formatted string like “Ctrl+S” or “F12”
Names of every PluginAction bound in any context (custom or
default). Used to populate getKeybindingLabel for plugin actions,
which aren’t in Action::all_action_names().
pub fn find_keybinding_for_action( &self, action_name: &str, context: KeyContext, ) -> Option<String>
Find the mnemonic character for a menu (based on Alt+letter keybindings) Returns the character that should be underlined in the menu label
Sourcepub fn get_all_bindings(&self) -> Vec<(String, String)>
pub fn get_all_bindings(&self) -> Vec<(String, String)>
Create default keybindings organized by context Get all keybindings (for help display) Returns a Vec of (key_description, action_description)
Sourcepub fn format_action(action: &Action) -> String
pub fn format_action(action: &Action) -> String
Format an action as a readable description
Sourcepub fn parse_key_public(key: &str) -> Option<KeyCode>
pub fn parse_key_public(key: &str) -> Option<KeyCode>
Public wrapper for parse_key (for keybinding editor)
Sourcepub fn parse_modifiers_public(modifiers: &[String]) -> KeyModifiers
pub fn parse_modifiers_public(modifiers: &[String]) -> KeyModifiers
Public wrapper for parse_modifiers (for keybinding editor)
Sourcepub fn format_action_from_str(action_name: &str) -> String
pub fn format_action_from_str(action_name: &str) -> String
Format an action name string as a human-readable description. Used by the keybinding editor to display action names without needing a full Action enum parse.
Sourcepub fn format_action_from_str_with_args(
action_name: &str,
args: &HashMap<String, Value>,
) -> String
pub fn format_action_from_str_with_args( action_name: &str, args: &HashMap<String, Value>, ) -> String
Like format_action_from_str but uses the provided args so parameterised
actions (e.g. menu_open with {"name": "File"}) produce distinct,
informative descriptions instead of a generic fallback.
Sourcepub fn all_action_names() -> Vec<String>
pub fn all_action_names() -> Vec<String>
Return a sorted list of all valid action name strings.
Delegates to Action::all_action_names() which is generated by the
define_action_str_mapping! macro (same source of truth as Action::from_str).
Sourcepub fn get_keybinding_for_action(
&self,
action: &Action,
context: KeyContext,
) -> Option<String>
pub fn get_keybinding_for_action( &self, action: &Action, context: KeyContext, ) -> Option<String>
Get the keybinding string for an action in a specific context Returns the first keybinding found (prioritizing custom bindings over defaults) When multiple keybindings exist for the same action, prefers canonical keys over terminal equivalents (e.g., “Space” over “@”) Returns None if no binding is found
Sourcepub fn get_keybinding_event_for_action(
&self,
action: &Action,
context: KeyContext,
) -> Option<(KeyCode, KeyModifiers)>
pub fn get_keybinding_event_for_action( &self, action: &Action, context: KeyContext, ) -> Option<(KeyCode, KeyModifiers)>
Raw-event counterpart to get_keybinding_for_action: returns the
(KeyCode, KeyModifiers) pair bound to action in context — or
falls through to the same Normal-context chain the string version
does — so callers (notably tests simulating user input) can feed
the bound key through the editor’s key dispatcher without
hardcoding a default that a rebind would invalidate.
Trait Implementations§
Source§impl Clone for KeybindingResolver
impl Clone for KeybindingResolver
Source§fn clone(&self) -> KeybindingResolver
fn clone(&self) -> KeybindingResolver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for KeybindingResolver
impl RefUnwindSafe for KeybindingResolver
impl Send for KeybindingResolver
impl Sync for KeybindingResolver
impl Unpin for KeybindingResolver
impl UnsafeUnpin for KeybindingResolver
impl UnwindSafe for KeybindingResolver
Blanket Implementations§
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more