pub struct WidgetRegistry { /* private fields */ }Expand description
Global registry of mounted widget panels.
Implementations§
Source§impl WidgetRegistry
impl WidgetRegistry
pub fn new() -> Self
Sourcepub fn mount(
&mut self,
panel_id: PanelId,
buffer_id: BufferId,
spec: WidgetSpec,
hits: Vec<HitArea>,
instance_states: HashMap<String, WidgetInstanceState>,
focus_key: String,
tabbable: Vec<String>,
) -> Option<WidgetPanelState>
pub fn mount( &mut self, panel_id: PanelId, buffer_id: BufferId, spec: WidgetSpec, hits: Vec<HitArea>, instance_states: HashMap<String, WidgetInstanceState>, focus_key: String, tabbable: Vec<String>, ) -> Option<WidgetPanelState>
Mount or replace a panel. Returns the previous state if the panel was already mounted (the dispatcher may use this to detect re-mounts on the same id).
The wide parameter list is the price of WidgetPanelState
being public — every field is plainly named at the call
site rather than buried inside an opaque builder. The
dispatcher always populates them all from one RenderOutput,
so the apparent verbosity stays at the boundary.
Sourcepub fn update(
&mut self,
panel_id: PanelId,
spec: WidgetSpec,
hits: Vec<HitArea>,
instance_states: HashMap<String, WidgetInstanceState>,
focus_key: String,
tabbable: Vec<String>,
) -> Result<BufferId, ()>
pub fn update( &mut self, panel_id: PanelId, spec: WidgetSpec, hits: Vec<HitArea>, instance_states: HashMap<String, WidgetInstanceState>, focus_key: String, tabbable: Vec<String>, ) -> Result<BufferId, ()>
Replace the spec and rendered metadata on an already-mounted
panel. Returns Ok(buffer_id) to render into, or Err(())
if no panel exists for that id (caller should drop the
update — the plugin re-emitted after unmount). The unit
error is sufficient: there’s exactly one failure mode and
no payload to attach.
Sourcepub fn instance_states(
&self,
panel_id: PanelId,
) -> Option<&HashMap<String, WidgetInstanceState>>
pub fn instance_states( &self, panel_id: PanelId, ) -> Option<&HashMap<String, WidgetInstanceState>>
Read-only access to the instance state for a panel — used by the dispatcher to thread previous scroll offsets / cursor positions into the next render so they persist.
Sourcepub fn focus_key(&self, panel_id: PanelId) -> Option<&str>
pub fn focus_key(&self, panel_id: PanelId) -> Option<&str>
Read-only access to the previous render’s focus key.
Sourcepub fn set_focus_key(&mut self, panel_id: PanelId, key: String)
pub fn set_focus_key(&mut self, panel_id: PanelId, key: String)
Set the focus key directly (used by widget_focus_advance
and click-driven focus moves). Updates the in-place state;
the next render reads it via focus_key().
Sourcepub fn set_list_scroll(
&mut self,
panel_id: PanelId,
list_key: &str,
scroll_offset: u32,
visible: u32,
) -> Option<i32>
pub fn set_list_scroll( &mut self, panel_id: PanelId, list_key: &str, scroll_offset: u32, visible: u32, ) -> Option<i32>
Host-driven scroll of a List widget (e.g. a scrollbar drag).
Sets the list’s scroll_offset and, when the list has a live
selection, clamps selected_index into the new visible window
[scroll, scroll + visible) so the next render’s
ensure-selected-visible doesn’t snap the thumb back.
Returns the post-clamp selected_index when the list has a
selection that moved (so the caller can notify the plugin to
keep its own selection mirror + preview in sync), else None.
Sourcepub fn update_side_effects(
&mut self,
panel_id: PanelId,
hits: Vec<HitArea>,
instance_states: HashMap<String, WidgetInstanceState>,
focus_key: String,
tabbable: Vec<String>,
) -> Result<BufferId, ()>
pub fn update_side_effects( &mut self, panel_id: PanelId, hits: Vec<HitArea>, instance_states: HashMap<String, WidgetInstanceState>, focus_key: String, tabbable: Vec<String>, ) -> Result<BufferId, ()>
Update side-effects (hits, instance_states, focus_key, tabbable)
without taking ownership of the spec. Used by rerender_widget_panel
after an in-place spec mutation: the spec in the registry is already
current (mutation helpers like append_tree_nodes_in_spec mutate it
in place), so cloning it back through update() just to write the
same value would waste a 5 000-node deep clone for every IPC.
Sourcepub fn buffer_and_spec_ref(
&self,
panel_id: PanelId,
) -> Option<(BufferId, &WidgetSpec)>
pub fn buffer_and_spec_ref( &self, panel_id: PanelId, ) -> Option<(BufferId, &WidgetSpec)>
Borrow the current spec + return the buffer id. Companion to
update_side_effects — render with the borrow and then write
back only the side-effects, avoiding the deep clone of the spec
that buffer_and_spec() does.
Sourcepub fn buffer_and_spec(
&self,
panel_id: PanelId,
) -> Option<(BufferId, WidgetSpec)>
pub fn buffer_and_spec( &self, panel_id: PanelId, ) -> Option<(BufferId, WidgetSpec)>
Find the buffer and current spec for a panel — used by the dispatcher to re-render after a focus advance / activate command without the plugin needing to send an UpdateWidgetPanel.
Sourcepub fn unmount(&mut self, panel_id: PanelId) -> Option<BufferId>
pub fn unmount(&mut self, panel_id: PanelId) -> Option<BufferId>
Tear down a panel. Returns the buffer_id the panel was rendering into, so the caller can clear the buffer if it owns it.
Sourcepub fn get(&self, panel_id: PanelId) -> Option<&WidgetPanelState>
pub fn get(&self, panel_id: PanelId) -> Option<&WidgetPanelState>
Read-only access to a panel’s current state.
Sourcepub fn get_mut(&mut self, panel_id: PanelId) -> Option<&mut WidgetPanelState>
pub fn get_mut(&mut self, panel_id: PanelId) -> Option<&mut WidgetPanelState>
Mutable access — used by WidgetCommand handlers that
update widget instance state (e.g. TextInput value/cursor)
directly without round-tripping through the plugin.
Sourcepub fn panel_ids(&self) -> Vec<PanelId> ⓘ
pub fn panel_ids(&self) -> Vec<PanelId> ⓘ
All currently-mounted panel ids — useful for theme-change re-render passes (every panel re-renders against the new theme without plugin involvement).
Sourcepub fn panels_for_buffer(&self, buffer_id: BufferId) -> Vec<PanelId> ⓘ
pub fn panels_for_buffer(&self, buffer_id: BufferId) -> Vec<PanelId> ⓘ
Panels rendering into buffer_id. Used by mouse-wheel
routing to find which widget panel sits under the pointer.
Sourcepub fn hit_test(
&self,
buffer_id: BufferId,
row: u32,
col_byte: u32,
) -> Option<(PanelId, HitArea)>
pub fn hit_test( &self, buffer_id: BufferId, row: u32, col_byte: u32, ) -> Option<(PanelId, HitArea)>
Hit-test the given buffer-local position against every
currently-mounted panel rendering into buffer_id. Returns
the matching panel id and a clone of the hit area on a hit,
None otherwise.
Linear scan: panel count is typically 1 per buffer; per-panel hit count is small (one per interactive widget). A spatial index would be over-engineering at this scale.
Trait Implementations§
Source§impl Debug for WidgetRegistry
impl Debug for WidgetRegistry
Source§impl Default for WidgetRegistry
impl Default for WidgetRegistry
Source§fn default() -> WidgetRegistry
fn default() -> WidgetRegistry
Auto Trait Implementations§
impl Freeze for WidgetRegistry
impl RefUnwindSafe for WidgetRegistry
impl Send for WidgetRegistry
impl Sync for WidgetRegistry
impl Unpin for WidgetRegistry
impl UnsafeUnpin for WidgetRegistry
impl UnwindSafe for WidgetRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more