Skip to main content

EditSession

Struct EditSession 

Source
pub struct EditSession { /* private fields */ }
Expand description

One active edit-mode session bound to a single text field.

Owns the engine Editor generic over BuffrHost. The host (clipboard / time / intent fan-out) lives inside the editor as of hjkl 0.1.0 — Editor<hjkl_buffer::Buffer, BuffrHost>. Pull-model: per render frame the host calls EditSession::take_content_change and forwards any new content to the DOM.

Implementations§

Source§

impl EditSession

Source

pub fn new(initial: &str) -> Self

Boot the session with the field’s current value.

Source

pub fn handle_key(&mut self, key: KeyEvent) -> bool

Feed one keystroke. Returns true when the keystroke was consumed by the engine; false means the caller should let the page see it (<Esc> in normal mode, etc.).

Source

pub fn feed_planned(&mut self, input: PlannedInput) -> bool

Feed a hjkl_engine::PlannedInput directly. Bypasses the crossterm conversion layer — used by the winit event path which constructs PlannedInput from winit’s KeyEvent directly so the two crates never need a shared crossterm version.

Source

pub fn type_char(&mut self, ch: char) -> bool

Convenience: type a literal character with no modifiers. Used by tests and by the JS bridge when forwarding plain printable keys.

Source

pub fn press(&mut self, code: KeyCode) -> bool

Convenience: send a special key (Esc, Enter, etc.) with no modifiers.

Source

pub fn type_str(&mut self, s: &str)

Type a string in insert mode. Caller must already have entered insert mode (type_char('i')); panics if asked to type while not in insert.

Source

pub fn take_content_change(&mut self) -> Option<Arc<String>>

Pull-model change drain. Returns the new content if anything changed since the last call; None if nothing did. Host forwards Some to the DOM.

Source

pub fn content(&self) -> String

Current full content. Useful for first-frame rendering.

Source

pub fn vim_mode(&self) -> VimMode

Mode for the status-line summary.

Source

pub fn drain_clipboard_outbox(&mut self) -> Vec<String>

Drain queued clipboard writes the engine has accumulated. Host’s tick loop dispatches each to CEF.

Source

pub fn drain_intents(&mut self) -> Vec<BuffrEditIntent>

Drain queued intents (RequestAutocomplete, SwitchBuffer, etc.). Host fans each out to its CEF / browser-action layer.

Source

pub fn host_mut(&mut self) -> &mut BuffrHost

Mutable access to the host. Production callers reach for this to refresh the clipboard cache on focus events / OSC52 reply.

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.