Skip to main content

ComponentHost

Trait ComponentHost 

Source
pub trait ComponentHost: Send + Sync {
    // Required methods
    fn render(&self, handle: u32, width: u16) -> BoxFuture<'static, Vec<String>>;
    fn input(&self, handle: u32, data: &str);
    fn mouse(&self, handle: u32, event: &Value) -> BoxFuture<'static, bool>;
    fn editor_op(&self, handle: u32, op: &Value);
    fn terminal_input(
        &self,
        keys: Vec<String>,
    ) -> BoxFuture<'static, Vec<String>>;
    fn suggestions(&self, request: Value) -> BoxFuture<'static, Value>;
}
Expand description

The extension runtime side of components: renders them and delivers input to them.

Required Methods§

Source

fn render(&self, handle: u32, width: u16) -> BoxFuture<'static, Vec<String>>

The lines of component handle at width columns: text with escape sequences, and pi-tui’s cursor marker where a focused component wants the cursor. Empty once the component is gone.

Source

fn input(&self, handle: u32, data: &str)

Delivers raw terminal input to component handle.

Source

fn mouse(&self, handle: u32, event: &Value) -> BoxFuture<'static, bool>

Delivers pi-tui’s TuiMouseEvent event to component handle, after the input delivered before it. Resolves to whether the component took it, as pi-tui’s dispatchMouseEvent decides.

Source

fn editor_op(&self, handle: u32, op: &Value)

Sends op to editor component handle, after the input delivered before it: {"op": "setText", "text"}, {"op": "addToHistory", "text"}, {"op": "insertTextAtCursor", "text", "apart"}, or {"op": "configure", "border", "paddingX", "autocompleteMaxVisible", "focused", "rows"}. apart sets the text apart from the words around the cursor, and border is a thinking level or bashMode.

Source

fn terminal_input(&self, keys: Vec<String>) -> BoxFuture<'static, Vec<String>>

Runs the runtime’s onTerminalInput listeners over raw input keys, in order. Answers the keys left to handle, as the listeners transformed them, without those they consumed or emptied.

Source

fn suggestions(&self, request: Value) -> BoxFuture<'static, Value>

The suggestions of the runtime’s autocomplete providers for pi’s provider arguments request, as for ExtensionUi::suggestions, with what applying each item gives: {"prefix", "items", "applied": [{"lines", "cursorLine", "cursorCol"}]}, or Null.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§