pub trait ZonePlugin: Send + Sync {
// Required methods
fn id(&self) -> &str;
fn render(
&self,
zone_id: ZoneId,
ctx: &RenderContext,
area: Rect,
buf: &mut Buffer,
) -> bool;
// Provided methods
fn zones(&self) -> Vec<ZoneRequest> { ... }
fn on_register(&self, _zone_id: ZoneId) { ... }
fn on_event(&self, _zone_id: ZoneId, _event: &ZoneEvent) -> bool { ... }
}Expand description
A plugin that owns one or more zones in the TUI.
Implement this trait to contribute UI to a ratatui application. The host calls methods in this order:
id()+zones()— once at registrationon_register(zone_id)— once per granted zonerender(zone_id, ctx, area, buf)— every frame per visible zoneon_event(zone_id, event)— when a relevant event occurs
§Theme Agnosticism
The RenderContext.base_style carries the host’s theme as a plain
ratatui::style::Style. This works with any styling system:
- ratatui-themekit: host sets
base_style = theme.style_base() - Raw styles: host sets
base_style = Style::default().bg(Color::Rgb(...)) - Custom: any
Stylevalue
Plugins that want to use themekit directly can depend on it themselves — zonekit does not require or prevent this.
Required Methods§
Sourcefn render(
&self,
zone_id: ZoneId,
ctx: &RenderContext,
area: Rect,
buf: &mut Buffer,
) -> bool
fn render( &self, zone_id: ZoneId, ctx: &RenderContext, area: Rect, buf: &mut Buffer, ) -> bool
Renders the plugin’s content into the granted zone.
area is the allocated Rect — plugin MUST NOT write outside it.
buf is the buffer slice for this area.
ctx carries theme style, focus state, and terminal dimensions.
Return false if the zone has nothing to show (host may hide it).
Provided Methods§
Sourcefn zones(&self) -> Vec<ZoneRequest>
fn zones(&self) -> Vec<ZoneRequest>
Zone requests — what zones this plugin wants to own.
Called once during registration. Each request is evaluated by the host, which may grant or deny based on available space.
Sourcefn on_register(&self, _zone_id: ZoneId)
fn on_register(&self, _zone_id: ZoneId)
Called when the host grants a zone to this plugin.
Uses &self — plugins that need to store the zone ID should
use interior mutability (e.g., Cell, Mutex).