Skip to main content

EditorState

Struct EditorState 

Source
pub struct EditorState {
Show 13 fields pub buffers: BufferSet, pub modal: ModalState, pub search: SearchState, pub keymap: Keymap, pub commands: CommandRegistry, pub layout: Layout, pub active: BufferId, pub quit_requested: bool, pub messages: Vec<String>, pub jumps: JumpList, pub options: HashMap<String, String>, pub pending_keys: Vec<Key>, pub plugin_host: PluginHost, /* private fields */
}
Expand description

Full editor state — the single Rust value the binary hands to the renderer each frame.

Fields§

§buffers: BufferSet§modal: ModalState§search: SearchState

Search session — the committed pattern, its matches, the live / prompt and history. Owns no buffer or cursor; it answers questions about text and this runtime applies the answers.

§keymap: Keymap§commands: CommandRegistry§layout: Layout§active: BufferId§quit_requested: bool§messages: Vec<String>

Messages surfaced to the user (status line / :messages) — the sink for the tatara-lisp (message …) effect and other feedback.

§jumps: JumpList

Where the cursor was before each far jump — <C-o> / <C-i>. Search commits, n/N and */# all record into it, which is what makes a search a place you can come back from.

§options: HashMap<String, String>

Generic editor option store (name → value). Written by the tatara-lisp (set-option …) effect and the declarative defoption apply path; typed accessors layer on top later.

§pending_keys: Vec<Key>

Keys accumulated for an in-progress multi-key sequence — e.g. holding [,, f] while waiting for the final key of <leader>ff. Empty when not mid-sequence. Lives on EditorState (not ModalState) so escriba-mode needn’t depend on escriba-keymap’s Key.

§plugin_host: PluginHost

Runtime lazy-activation host for USER plugin caixas (the bundled default catalog is applied eagerly at boot, not through here). A command / filetype-open / event fires the matching plugins’ entries through the escriba-lisp apply paths. See PluginHost.

Implementations§

Source§

impl EditorState

Source

pub fn new_with_buffer(initial: BufferSet, active: BufferId) -> Self

Build a fresh editor with one buffer (scratch or file-backed).

Source

pub fn edit_gen(&self) -> EditGen

The current refresh generation. A renderer caches its products against this; equality is the freshness test (an unchanged generation ⇒ the last frame is still valid, so skip the re-highlight + re-shape).

Source

pub fn damage(&self) -> Damage

The accumulated dirty region (read-only). See take_damage.

Source

pub fn take_damage(&mut self) -> Damage

Drain the accumulated dirty region, resetting to Damage::None. The renderer calls this once per frame to learn what to repaint, then the accumulator restarts — so damage never double-counts across frames.

Source

pub fn register_lazy_plugin( &mut self, name: impl Into<String>, triggers: Vec<LazyTrigger>, entry_src: impl Into<String>, )

Register a lazy USER plugin: its escriba entry is deferred until one of its triggers fires. Bundled defaults do NOT go through here — they are applied eagerly at boot. Empty triggers means the plugin never lazily activates (the binary applies eager plugins directly).

Source

pub fn activate_filetype_plugins(&mut self, filetype: &str) -> usize

Fire any lazy plugin gated on a FileType trigger for filetype. Returns the number of plugins activated. Call when a buffer of a known filetype is opened.

Source

pub fn activate_event_plugins(&mut self, event: &str) -> usize

Fire any lazy plugin gated on an Event trigger for event. Returns the number of plugins activated.

Source

pub fn tick(&mut self, event: &AppEvent)

Advance one frame’s worth of state given a raw madori event.

Key events pass through the KeyRepeatGate first (see Self::tick_at); everything else is handled directly.

Source

pub fn tick_at(&mut self, event: &AppEvent, now: Instant)

Self::tick with an explicit timestamp for the key-repeat gate — lets tests drive the debounce window without depending on the wall clock.

Source

pub fn on_key(&mut self, key: &Key)

Dispatch a single key through the keymap + apply the resulting action.

Source

pub fn cursor(&self) -> Position

The primary cursor position. The single read accessor — every renderer + motion path goes through it, so the underlying representation (today a single-cursor Cursors) can grow to multi-caret without changing read sites.

Source

pub fn status_model(&self) -> StatusModel<'_>

Move the cursor onto a match and report a wrap the way vim does. The status line as data — what every face draws.

One model, so the two faces can only disagree about styling. Before this existed the GPU face built its own line from a fixed format!() and drew neither the prompt nor any message, which made a fully working / look like a dead key on escriba’s default renderer.

Source

pub fn register(&self) -> Option<&str>

The text last yanked or deleted into the unnamed register, if any. The future p/P paste reads this.

Source

pub fn snapshot(&self) -> EditorSnapshot

Capture a read snapshot of the editor for the tatara-lisp host. Lisp reads (cursor-line, current-line, …) answer from this.

Source

pub fn run_lisp(&mut self, src: &str) -> Result<(), VmError>

Evaluate tatara-lisp src against this editor: capture a snapshot, run it in the embedded VM, then apply the typed effects the program emitted. This is the imperative programmability tier — live Lisp that reads state and drives the editor through the sandboxed effect boundary.

Snapshot semantics: the read snapshot is captured ONCE before eval, and effects are applied AFTER the program returns. So within a single run_lisp call a program cannot observe its own writes — (insert "x") (cursor-column) reads the pre-insert column. This snapshot-isolation is deliberate (it’s what makes the effect boundary a clean sandbox seam); a program that must read its own effects splits the work across calls. The VM is cached (Self::lisp_vm) so the stdlib is installed once and top-level defines persist across calls (REPL-like).

Source

pub fn apply_host_effects(&mut self, effects: Vec<HostEffect>)

Apply tatara-lisp HostEffects to live editor state. The single seam where Lisp-requested mutations land — extend here + in escriba-vm to add a capability.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more