Skip to main content

DefaultHost

Struct DefaultHost 

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

Default no-op Host implementation. Suitable for tests, headless embedding, or any host that doesn’t yet need clipboard / cursor-shape / cancellation plumbing.

Behaviour:

  • write_clipboard stores the most recent payload in an in-memory slot; read_clipboard returns it. Round-trip-only — no OS-level clipboard touched.
  • now returns wall-clock duration since construction.
  • prompt_search returns None (search is aborted).
  • emit_cursor_shape records the most recent shape; readable via DefaultHost::last_cursor_shape.
  • emit_intent discards intents (intent type is ()).

Implementations§

Source§

impl DefaultHost

Source

pub const DEFAULT_VIEWPORT: Viewport

Default viewport size for headless / test hosts: 80x24, no soft-wrap. Matches the conventional terminal default.

Source

pub fn new() -> Self

Source

pub fn with_viewport(viewport: Viewport) -> Self

Construct a DefaultHost with a custom initial viewport. Useful for tests that want to exercise scrolloff math at a specific window size.

Source

pub fn last_cursor_shape(&self) -> CursorShape

Most recent cursor shape requested by the engine.

Trait Implementations§

Source§

impl Debug for DefaultHost

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DefaultHost

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Host for DefaultHost

Source§

type Intent = ()

Custom intent type. Hosts that don’t fan out actions back to themselves can use the unit type via the default impl approach (set associated type explicitly).
Source§

fn write_clipboard(&mut self, text: String)

Fire-and-forget clipboard write. Engine never blocks; the host queues internally and flushes on its own task (OSC52, wl-copy, pbcopy, …).
Source§

fn read_clipboard(&mut self) -> Option<String>

Returns the last-known cached clipboard value. May be stale — matches the OSC52/wl-paste model neovim and helix both ship.
Source§

fn now(&self) -> Duration

Monotonic time. Multi-key timeout (timeoutlen) resolution reads this; engine never reads Instant::now() directly so macro replay stays deterministic.
Synchronously prompt the user for a search pattern. Returning None aborts the search.
Source§

fn emit_cursor_shape(&mut self, shape: CursorShape)

Engine emits this on every mode transition. Hosts repaint the cursor in the requested shape.
Source§

fn viewport(&self) -> &Viewport

Borrow the host’s viewport. The host writes width/height/ text_width/wrap per render frame; the engine reads/writes top_row / top_col to scroll. 0.0.34 (Patch C-δ.1) moved this off hjkl_buffer::Buffer onto Host.
Source§

fn viewport_mut(&mut self) -> &mut Viewport

Mutable viewport access. Engine motion + scroll code routes here when scrolloff math advances top_row.
Source§

fn emit_intent(&mut self, _intent: Self::Intent)

Host-defined event the engine raises (LSP request, fold op, buffer switch, …).
Source§

fn should_cancel(&self) -> bool

Cooperative cancellation. Engine polls during long search / regex / multi-cursor edit loops. Default returns false.
Source§

fn display_line_for(&self, pos: Pos) -> u32

Map a logical position to its display line for gj/gk. Hosts without wrapping may use the default identity impl.
Source§

fn pos_for_display(&self, line: u32, col: u32) -> Pos

Inverse of [display_line_for]. Default identity.
Source§

fn syntax_highlights(&self, range: Range<Pos>) -> Vec<Highlight>

Host-supplied syntax highlights for range. Empty by default; hosts wire tree-sitter or LSP semantic tokens here.

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.