paperos 0.2.0

A programmable editor built on the Runact actor runtime
Documentation
use runact::Runtime;
use std::any::Any;

#[allow(dead_code)]
pub trait Extension: Any + Send + Sync {
    fn name(&self) -> &str;

    fn init(&mut self, runtime: &mut Runtime) -> Result<(), Box<dyn std::error::Error>> {
        let _ = runtime;
        Ok(())
    }

    fn shutdown(&mut self, runtime: &mut Runtime) -> Result<(), Box<dyn std::error::Error>> {
        let _ = runtime;
        Ok(())
    }

    fn on_key(&mut self, ch: char) -> Result<(), Box<dyn std::error::Error>> {
        let _ = ch;
        Ok(())
    }

    fn on_render(&mut self, runtime: &Runtime) -> Result<(), Box<dyn std::error::Error>> {
        let _ = runtime;
        Ok(())
    }

    /// Register commands into the runtime's command registry.
    /// Called during startup so extensions are self-contained — they don't
    /// need main.rs to manually wire each command.
    fn register_commands(
        &mut self,
        _runtime: &mut crate::core::EditorRuntime,
    ) -> Result<(), Box<dyn std::error::Error>> {
        Ok(())
    }

    /// Return global keymap bindings as (key_spec, command_name) pairs.
    /// These are merged into the global layer (priority 15) alongside
    /// M-x. Extensions can add custom global bindings without touching
    /// main.rs.
    fn global_bindings(&self) -> Vec<(&'static str, &'static str)> {
        Vec::new()
    }

    fn as_any(&self) -> &dyn Any;
    fn as_any_mut(&mut self) -> &mut dyn Any;
}