pub struct HostBindings {
pub limits: HostBindingLimits,
pub capabilities: PluginNavCapabilities,
/* private fields */
}Expand description
ECS-safe host bindings for Fusabi plugins
This struct provides the bridge between Fusabi scripts and Scarab’s ECS.
All operations are validated against capability flags, quotas, and rate limits
before being queued as RemoteCommands for the plugin host to process.
§Thread Safety
All methods are thread-safe and can be called from async Fusabi contexts.
§Example
let bindings = HostBindings::new(limits, capabilities);
// Register a focusable (checks quotas and validates)
bindings.register_focusable(&ctx, PluginFocusable {
x: 10, y: 5, width: 20, height: 1,
label: "GitHub".into(),
action: PluginFocusableAction::OpenUrl("https://github.com".into()),
})?;
// Enter hint mode (checks capability and rate limit)
bindings.enter_hint_mode(&ctx)?;Fields§
§limits: HostBindingLimitsConfiguration limits
capabilities: PluginNavCapabilitiesNavigation capabilities
Implementations§
Source§impl HostBindings
impl HostBindings
Sourcepub fn new(
limits: HostBindingLimits,
capabilities: PluginNavCapabilities,
) -> Self
pub fn new( limits: HostBindingLimits, capabilities: PluginNavCapabilities, ) -> Self
Create new host bindings with the specified limits and capabilities
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default limits and capabilities
Sourcepub fn enter_hint_mode(&self, ctx: &PluginContext) -> Result<()>
pub fn enter_hint_mode(&self, ctx: &PluginContext) -> Result<()>
Enter hint mode
Triggers the navigation hint mode UI, displaying labels for all focusable elements.
§Errors
Returns error if:
- Plugin doesn’t have
can_enter_hint_modecapability - Rate limit exceeded
Exit navigation mode
Exits hint mode and returns to normal input handling.
§Errors
Returns error if rate limit exceeded
Sourcepub fn register_focusable(
&self,
ctx: &PluginContext,
region: PluginFocusable,
) -> Result<u64>
pub fn register_focusable( &self, ctx: &PluginContext, region: PluginFocusable, ) -> Result<u64>
Register a focusable region
Registers a custom navigation target that will appear in hint mode. The region is validated for bounds and the action is checked for safety.
§Arguments
ctx- Plugin contextregion- Focusable region to register
§Returns
Unique ID for this focusable (can be used to unregister)
§Errors
Returns error if:
- Plugin doesn’t have
can_register_focusablescapability - Plugin has reached
max_focusablesquota - Region fails validation (coordinates, dimensions, URL safety)
- Rate limit exceeded
Sourcepub fn unregister_focusable(
&self,
ctx: &PluginContext,
focusable_id: u64,
) -> Result<()>
pub fn unregister_focusable( &self, ctx: &PluginContext, focusable_id: u64, ) -> Result<()>
Set navigation style
Configures the visual style of navigation hints (character set, appearance).
Get current navigation style
Set navigation keymap
Configures the keybindings for navigation mode.
Get current navigation keymap
Sourcepub fn resource_usage(&self) -> ResourceUsage
pub fn resource_usage(&self) -> ResourceUsage
Get current resource usage
Sourcepub fn reset_rate_limit(&self)
pub fn reset_rate_limit(&self)
Reset rate limiter (useful for testing)
Sourcepub fn spawn_overlay(
&self,
ctx: &PluginContext,
config: OverlayConfig,
) -> Result<u64>
pub fn spawn_overlay( &self, ctx: &PluginContext, config: OverlayConfig, ) -> Result<u64>
Spawn an overlay at the given position
Creates a floating overlay element at the specified terminal coordinates. Overlays are useful for tooltips, popups, and other transient UI elements.
§Arguments
ctx- Plugin contextconfig- Overlay configuration (position, content, style)
§Returns
Unique ID for this overlay (can be used to remove it later)
§Errors
Returns error if:
- Plugin has reached
max_overlaysquota - Rate limit exceeded
- Overlay position is out of bounds
Sourcepub fn remove_overlay(&self, ctx: &PluginContext, overlay_id: u64) -> Result<()>
pub fn remove_overlay(&self, ctx: &PluginContext, overlay_id: u64) -> Result<()>
Sourcepub fn add_status_item(
&self,
ctx: &PluginContext,
item: StatusBarItem,
) -> Result<u64>
pub fn add_status_item( &self, ctx: &PluginContext, item: StatusBarItem, ) -> Result<u64>
Add a status bar item
Adds an item to the terminal status bar. Status items are positioned based on their priority (higher priority = further right).
§Arguments
ctx- Plugin contextitem- Status bar item configuration
§Returns
Unique ID for this status item (can be used to remove it later)
§Errors
Returns error if:
- Plugin has reached
max_status_itemsquota - Rate limit exceeded
Sourcepub fn remove_status_item(
&self,
ctx: &PluginContext,
item_id: u64,
) -> Result<()>
pub fn remove_status_item( &self, ctx: &PluginContext, item_id: u64, ) -> Result<()>
Sourcepub fn prompt_jump(
&self,
ctx: &PluginContext,
direction: JumpDirection,
) -> Result<()>
pub fn prompt_jump( &self, ctx: &PluginContext, direction: JumpDirection, ) -> Result<()>
Trigger prompt jump navigation
Navigates the terminal viewport to the previous/next command prompt in the scrollback buffer. Useful for quickly navigating command history.
§Arguments
ctx- Plugin contextdirection- Direction to jump (Up, Down, First, Last)
§Errors
Returns error if rate limit exceeded
Sourcepub fn apply_theme(&self, ctx: &PluginContext, theme_name: &str) -> Result<()>
pub fn apply_theme(&self, ctx: &PluginContext, theme_name: &str) -> Result<()>
Apply a named theme
Dynamically applies a color theme to the terminal. The theme must be one of the built-in themes or a custom theme registered with the configuration system.
§Built-in Themes
slime- Vibrant green tones (default)dracula- Dark purple themenord- Arctic, north-bluish color palettemonokai- Classic dark theme with warm accentsgruvbox_dark- Retro groove color schemesolarized_dark- Precision colors for machinessolarized_light- Light variant of solarizedtokyo_night- A clean, dark theme from Tokyocatppuccin- Soothing pastel theme
§Arguments
ctx- Plugin contexttheme_name- Name of the theme to apply
§Errors
Returns error if rate limit exceeded
§Example
Host.applyTheme ctx "dracula"Sourcepub fn set_palette_color(
&self,
ctx: &PluginContext,
color_name: &str,
value: &str,
) -> Result<()>
pub fn set_palette_color( &self, ctx: &PluginContext, color_name: &str, value: &str, ) -> Result<()>
Set a specific palette color
Modifies a single color in the current palette. This allows fine-grained customization of terminal colors without changing the entire theme.
§Color Names
foreground,backgroundblack,red,green,yellow,blue,magenta,cyan,whitebright_black,bright_red,bright_green,bright_yellowbright_blue,bright_magenta,bright_cyan,bright_whitecursor,selection
§Color Values
Colors can be specified as:
- Hex:
#RRGGBBorRRGGBB - RGB:
rgb(255, 0, 128) - Named:
red,green,blue, etc.
§Arguments
ctx- Plugin contextcolor_name- Name of the color to setvalue- New color value (hex, rgb, or named)
§Errors
Returns error if rate limit exceeded
§Example
Host.setPaletteColor ctx "foreground" "#00FF00"
Host.setPaletteColor ctx "background" "rgb(30, 30, 30)"Sourcepub fn get_current_theme(&self, ctx: &PluginContext) -> Result<()>
pub fn get_current_theme(&self, ctx: &PluginContext) -> Result<()>
Request the current theme name
Queries the current active theme name. Since this is an async operation, the result will be delivered via a callback or event.
§Arguments
ctx- Plugin context
§Errors
Returns error if rate limit exceeded
§Note
The theme name is returned asynchronously. Plugins should listen for
the ThemeInfoResponse event to receive the result.