pub trait Host: Send {
type Intent;
// Required methods
fn write_clipboard(&mut self, text: String);
fn read_clipboard(&mut self) -> Option<String>;
fn now(&self) -> Duration;
fn prompt_search(&mut self) -> Option<String>;
fn emit_cursor_shape(&mut self, shape: CursorShape);
fn viewport(&self) -> &Viewport;
fn viewport_mut(&mut self) -> &mut Viewport;
fn emit_intent(&mut self, intent: Self::Intent);
// Provided methods
fn should_cancel(&self) -> bool { ... }
fn display_line_for(&self, pos: Pos) -> u32 { ... }
fn pos_for_display(&self, line: u32, col: u32) -> Pos { ... }
fn syntax_highlights(&self, range: Range<Pos>) -> Vec<Highlight> { ... }
}Expand description
Host adapter consumed by the engine. Lives behind the planned
Editor<B: Buffer, H: Host> generic; today it’s the contract that
buffr-modal::BuffrHost and the (future) sqeel-tui Host impl
align against.
Methods with default impls return safe no-ops so hosts that don’t need a feature (cancellation, wrap-aware motion, syntax highlights) can ignore them.
Required Associated Types§
Required Methods§
Sourcefn write_clipboard(&mut self, text: String)
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, …).
Sourcefn read_clipboard(&mut self) -> Option<String>
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.
Sourcefn now(&self) -> Duration
fn now(&self) -> Duration
Monotonic time. Multi-key timeout (timeoutlen) resolution
reads this; engine never reads Instant::now() directly so
macro replay stays deterministic.
Sourcefn prompt_search(&mut self) -> Option<String>
fn prompt_search(&mut self) -> Option<String>
Synchronously prompt the user for a search pattern. Returning
None aborts the search.
Sourcefn emit_cursor_shape(&mut self, shape: CursorShape)
fn emit_cursor_shape(&mut self, shape: CursorShape)
Engine emits this on every mode transition. Hosts repaint the cursor in the requested shape.
Sourcefn viewport(&self) -> &Viewport
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.
Sourcefn viewport_mut(&mut self) -> &mut Viewport
fn viewport_mut(&mut self) -> &mut Viewport
Mutable viewport access. Engine motion + scroll code routes
here when scrolloff math advances top_row.
Sourcefn emit_intent(&mut self, intent: Self::Intent)
fn emit_intent(&mut self, intent: Self::Intent)
Host-defined event the engine raises (LSP request, fold op, buffer switch, …).
Provided Methods§
Sourcefn should_cancel(&self) -> bool
fn should_cancel(&self) -> bool
Cooperative cancellation. Engine polls during long search /
regex / multi-cursor edit loops. Default returns false.
Sourcefn display_line_for(&self, pos: Pos) -> u32
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.
Sourcefn pos_for_display(&self, line: u32, col: u32) -> Pos
fn pos_for_display(&self, line: u32, col: u32) -> Pos
Inverse of [display_line_for]. Default identity.