Skip to main content

HookContext

Struct HookContext 

Source
pub struct HookContext<'a> {
    pub buffer: &'a mut EditorBuffer,
    pub selection: &'a mut Option<Selection>,
    pub cursor_style: &'a mut CursorStyle,
    pub prompt: &'a mut PromptState,
    pub effects: &'a mut Vec<HookEffect>,
}
Expand description

The mutable editing context passed to editor hooks during events.

prompt is the shared headless input box (bottom bar / command palette): any hook can open it, read submitted input, and fill item rows, with no frontend code. effects collects app-level requests (save/load/quit) that the host drains after each event.

Fields§

§buffer: &'a mut EditorBuffer

Mutable access to the underlying text buffer.

§selection: &'a mut Option<Selection>

Mutable access to the active selection range, if any.

§cursor_style: &'a mut CursorStyle

Mutable access to the cursor visual style.

§prompt: &'a mut PromptState

Shared headless prompt / input-box state.

§effects: &'a mut Vec<HookEffect>

App-level requests for the host to drain after the event.

Implementations§

Source§

impl<'a> HookContext<'a>

Source

pub fn new( buffer: &'a mut EditorBuffer, selection: &'a mut Option<Selection>, cursor_style: &'a mut CursorStyle, prompt: &'a mut PromptState, effects: &'a mut Vec<HookEffect>, ) -> Self

Creates a new hook context.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for HookContext<'a>

§

impl<'a> Freeze for HookContext<'a>

§

impl<'a> RefUnwindSafe for HookContext<'a>

§

impl<'a> Send for HookContext<'a>

§

impl<'a> Sync for HookContext<'a>

§

impl<'a> Unpin for HookContext<'a>

§

impl<'a> UnsafeUnpin for HookContext<'a>

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