pub struct EditorActorHandle { /* private fields */ }Expand description
Renderer-side handle to the editor actor.
Holds:
cmd_tx— unbounded; the renderer sends commands without blocking. Backpressure is the actor’s per-command processing cost; today every command processes in microseconds so the queue stays effectively empty.signal_rx— unbounded; the renderer drains signals once per frame viaSelf::poll_signal. The actor pushes signals as it processes commands.render_state— a clone of the editor’sArc<ArcSwap<RenderState>>. The renderer loads viahandle.render_state.load()(wait-free); the editor’spublish_render_statecalls are observable through this shared Arc.
Not Clone: the signal_rx is uniquely owned. Renderers
that need to send commands from multiple places can clone
the underlying mpsc::UnboundedSender via
Self::cmd_sender, which is freely Clone.
Implementations§
Source§impl EditorActorHandle
impl EditorActorHandle
Sourcepub fn send(&self, cmd: EditorCommand) -> Result<(), SendError<EditorCommand>>
pub fn send(&self, cmd: EditorCommand) -> Result<(), SendError<EditorCommand>>
Send a command to the editor actor. Returns Err only
when the actor has already shut down (channel closed).
In production this should never happen during normal
operation; in tests the failure mode is “test forgot to
keep the handle alive.”
Sourcepub fn send_action(
&self,
action: Action,
) -> Result<(), SendError<EditorCommand>>
pub fn send_action( &self, action: Action, ) -> Result<(), SendError<EditorCommand>>
Convenience: send an Apply(action) command. Fire-and-
forget — does not wait for completion. The renderer
keystroke handler uses this so the input loop returns
immediately; the dispatched action runs on the actor
thread and publishes RenderState when done (the existing
paint_request Notify wakes the GPUI peer’s next paint).
Sourcepub fn apply_blocking(&self, action: Action) -> Result<(), ActorGone>
pub fn apply_blocking(&self, action: Action) -> Result<(), ActorGone>
Synchronous dispatch — blocks until the actor finishes
processing this action (and any cascade). Used by
App::apply so existing call sites that read editor-
derived state on the next line keep working. Returns
Err only if the actor died mid-await.
Safe to call from inside or outside a tokio runtime:
safe_blocking_recv selects the right wait path based on
the current runtime flavor (see its docstring).
Sourcepub fn mutate_blocking(
&self,
closure: Box<dyn FnOnce(&mut Editor) + Send>,
) -> Result<(), ActorGone>
pub fn mutate_blocking( &self, closure: Box<dyn FnOnce(&mut Editor) + Send>, ) -> Result<(), ActorGone>
Closure escape hatch — synchronous: send the closure +
block until the actor runs it and publishes RS. Used by
App-side helpers during the slice-E sweep when the
helper’s body mutates editor state directly. Each helper
wraps its body in one closure; the caller’s read-back of
editor-derived state via app.ad() etc. sees the post-
mutation snapshot.
Sourcepub fn mutate_async(
&self,
closure: Box<dyn FnOnce(&mut Editor) + Send>,
) -> Result<(), ActorGone>
pub fn mutate_async( &self, closure: Box<dyn FnOnce(&mut Editor) + Send>, ) -> Result<(), ActorGone>
Closure escape hatch — fire-and-forget. For tokio task callers that can’t block (e.g., LSP response handlers).
Sourcepub fn with_editor<R, F>(&self, f: F) -> R
pub fn with_editor<R, F>(&self, f: F) -> R
Read-side RPC (3c.final.E.swap): synchronously run a
closure against &Editor on the actor thread and return
the result. Used by every &self-receiver helper on
App / GpuiApp that needs to read editor state.
Internally uses Box<dyn Any> erasure to keep the
actor’s command enum non-generic.
Sourcepub fn mutate_blocking_with<R, F>(&self, f: F) -> R
pub fn mutate_blocking_with<R, F>(&self, f: F) -> R
Sync mutate RPC with return value (3c.final.E.swap).
Used by mutate_editor_with post-swap: the closure
returns R; the actor publishes RS at its tail.
Sourcepub fn set_cursor(
&self,
cursor: Position,
) -> Result<(), SendError<EditorCommand>>
pub fn set_cursor( &self, cursor: Position, ) -> Result<(), SendError<EditorCommand>>
Replace the editor’s cursor and republish.
Sourcepub fn set_cursor_line(&self, line: u32) -> Result<(), SendError<EditorCommand>>
pub fn set_cursor_line(&self, line: u32) -> Result<(), SendError<EditorCommand>>
Replace cursor.line and republish.
Sourcepub fn set_cursor_byte(&self, byte: u32) -> Result<(), SendError<EditorCommand>>
pub fn set_cursor_byte(&self, byte: u32) -> Result<(), SendError<EditorCommand>>
Replace cursor.byte and republish.
Sourcepub fn set_scroll(&self, scroll: u32) -> Result<(), SendError<EditorCommand>>
pub fn set_scroll(&self, scroll: u32) -> Result<(), SendError<EditorCommand>>
Replace scroll and republish.
Sourcepub fn set_modal(
&self,
modal: ModalState,
) -> Result<(), SendError<EditorCommand>>
pub fn set_modal( &self, modal: ModalState, ) -> Result<(), SendError<EditorCommand>>
Replace modal and republish.
Sourcepub fn set_viewport_height(
&self,
height: u32,
) -> Result<(), SendError<EditorCommand>>
pub fn set_viewport_height( &self, height: u32, ) -> Result<(), SendError<EditorCommand>>
Resize the active pane’s viewport. Runs the same body as
the App-side wrapper: clamp to >= 1, run
ensure_cursor_visible, publish.
Sourcepub fn set_pane_viewport(
&self,
idx: usize,
height: u32,
width: u32,
) -> Result<(), SendError<EditorCommand>>
pub fn set_pane_viewport( &self, idx: usize, height: u32, width: u32, ) -> Result<(), SendError<EditorCommand>>
Issue #25 (2026-05-22): per-pane geometry setter. The
renderer’s per-frame layout pass walks the pane tree and
fires one of these per leaf. The active leaf’s height is
auto-mirrored into Editor::viewport_height for cursor
clamp + highlights worker.
Sourcepub fn poll_signal(&mut self) -> Option<RendererSignal>
pub fn poll_signal(&mut self) -> Option<RendererSignal>
Drain a single pending signal from the editor’s
signal stream. Returns None when the queue is empty
(steady-state on most frames). Called per-frame by the
renderer; the typical drain pattern is
while let Some(sig) = handle.poll_signal() { ... }.
Sourcepub fn cmd_sender(&self) -> UnboundedSender<EditorCommand>
pub fn cmd_sender(&self) -> UnboundedSender<EditorCommand>
Cheap clone of the command-send side. Use this when
multiple call sites in the renderer need to send
commands without sharing a &self to the full handle.
Sourcepub fn render_state(&self) -> Arc<RenderState> ⓘ
pub fn render_state(&self) -> Arc<RenderState> ⓘ
Wait-free read of the current RenderState snapshot.
Returns an Arc<RenderState> the renderer holds across
the frame.
Sourcepub fn render_state_arc(&self) -> Arc<ArcSwap<RenderState>> ⓘ
pub fn render_state_arc(&self) -> Arc<ArcSwap<RenderState>> ⓘ
Shared ArcSwap reference for callers that need to
store it alongside other Arc-shared state (e.g., a
renderer that wants to clone the cell into a paint
closure).
Sourcepub fn paint_request(&self) -> Arc<Notify> ⓘ
pub fn paint_request(&self) -> Arc<Notify> ⓘ
Shared paint_request Notify the actor’s workers fire after an
async republish (syntax recolour, LSP decoration, cells/virtual-rows).
The TUI event loop (I.3) awaits this to repaint promptly; the GPUI peer
uses the same notify natively.
Sourcepub fn shutdown_and_join(&mut self) -> Result<()>
pub fn shutdown_and_join(&mut self) -> Result<()>
Send Shutdown and join the editor thread. Idempotent
in the sense that subsequent calls return Ok(())
without re-joining. Returns Err only if the thread
panicked.
Trait Implementations§
Source§impl Drop for EditorActorHandle
impl Drop for EditorActorHandle
Auto Trait Implementations§
impl !RefUnwindSafe for EditorActorHandle
impl !UnwindSafe for EditorActorHandle
impl Freeze for EditorActorHandle
impl Send for EditorActorHandle
impl Sync for EditorActorHandle
impl Unpin for EditorActorHandle
impl UnsafeUnpin for EditorActorHandle
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 more