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§
Sourcefn render(&self, handle: u32, width: u16) -> BoxFuture<'static, Vec<String>>
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.
Sourcefn mouse(&self, handle: u32, event: &Value) -> BoxFuture<'static, bool>
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.
Sourcefn editor_op(&self, handle: u32, op: &Value)
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.
Sourcefn terminal_input(&self, keys: Vec<String>) -> BoxFuture<'static, Vec<String>>
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.
Sourcefn suggestions(&self, request: Value) -> BoxFuture<'static, Value>
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".