pub struct PluginHost {
pub errors: Vec<String>,
/* private fields */
}Expand description
Loads Rhai plugins and runs their commands against the editor.
Fields§
§errors: Vec<String>Errors encountered while loading or running plugins.
Implementations§
Source§impl PluginHost
impl PluginHost
Sourcepub fn add_plugin(&mut self, name: &str, source: &str)
pub fn add_plugin(&mut self, name: &str, source: &str)
Adds (or replaces) a named plugin from source and rebuilds.
Sourcepub fn commands(&self) -> Vec<CommandInfo>
pub fn commands(&self) -> Vec<CommandInfo>
All registered commands, sorted by title.
pub fn command_titles(&self) -> Vec<String>
Sourcepub fn keybindings(&self) -> Vec<(KeySpec, String)>
pub fn keybindings(&self) -> Vec<(KeySpec, String)>
All registered keybindings.
Sourcepub fn lookup_key(&self, key: &KeySpec) -> Option<String>
pub fn lookup_key(&self, key: &KeySpec) -> Option<String>
Finds the command title bound to a key, if any.
Sourcepub fn run_command(
&mut self,
title: &str,
ctx: &EditorContext,
) -> Vec<EditorAction>
pub fn run_command( &mut self, title: &str, ctx: &EditorContext, ) -> Vec<EditorAction>
Runs a command by title, returning the actions it requested.
pub fn is_empty(&self) -> bool
Sourcepub fn has_hook(&self, name: &str) -> bool
pub fn has_hook(&self, name: &str) -> bool
True when a loaded plugin defines name as a function.
Sourcepub fn run_hook(&mut self, name: &str, ctx: &EditorContext) -> Vec<EditorAction>
pub fn run_hook(&mut self, name: &str, ctx: &EditorContext) -> Vec<EditorAction>
Runs a lifecycle hook such as on_buffer_open or on_buffer_save.
A missing hook is not an error; it simply produces no actions. Errors
inside a hook are collected in PluginHost::errors and returned as a
message action so the frontend can surface them without crashing.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PluginHost
impl !RefUnwindSafe for PluginHost
impl !Send for PluginHost
impl !Sync for PluginHost
impl !UnwindSafe for PluginHost
impl Forget for PluginHost
impl Move for PluginHost
impl Unpin for PluginHost
impl UnsafeUnpin for PluginHost
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
Mutably borrows from an owned value. Read more