Skip to main content

Crate hjkl_engine

Crate hjkl_engine 

Source
Expand description

Vim-mode editor engine built on top of hjkl_buffer.

Exposes an Editor that is fully toolkit-agnostic. Covers the bulk of vim’s normal / insert / visual / visual-line / visual-block modes, text-object operators, dot-repeat, and ex-command handling (:s/foo/bar/g, :w, :q, :noh, …). Rendering goes through hjkl_buffer::BufferView; selection / gutter highlights are painted in the same single-pass as text. TUI/crossterm adapters live in the hjkl-engine-tui companion crate.

Imported wholesale from sqeel-vim with full git history. The trait extraction (Selection / SelectionSet / Buffer + Host sub-traits) lands progressively under crate::types. Pre-1.0 churn — the public surface may change in patch bumps. See docs.rs for the canonical API reference.

The legacy public surface is intentionally narrow:

  • Editor — the editor widget.
  • KeybindingMode / VimMode — mode enums used by host apps.
  • [ex::run] / [ex::ExEffect] — drive ex-mode commands.

Re-exports§

pub use keymap_motion::MotionKind;
pub use substitute::SubstError;
pub use substitute::SubstFlags;
pub use substitute::SubstituteCmd;
pub use substitute::SubstituteMatch;
pub use substitute::SubstituteOutcome;
pub use substitute::apply_collected_matches;
pub use substitute::apply_substitute;
pub use substitute::collect_substitute_matches;
pub use substitute::parse_substitute;
pub use types::Attrs;
pub use types::Buffer;
pub use types::BufferEdit;
pub use types::BufferId;
pub use types::Color;
pub use types::ContentEdit;
pub use types::Cursor;
pub use types::CursorShape;
pub use types::DefaultHost;
pub use types::Edit;
pub use types::EditorSnapshot;
pub use types::EngineError;
pub use types::FoldOp;
pub use types::FoldProvider;
pub use types::Highlight;
pub use types::HighlightKind;
pub use types::Host;
pub use types::Input as PlannedInput;
pub use types::Mode;
pub use types::Modifiers;
pub use types::MouseEvent;
pub use types::MouseKind;
pub use types::NoopFoldProvider;
pub use types::OptionValue;
pub use types::Options;
pub use types::Pos;
pub use types::Query;
pub use types::RenderFrame;
pub use types::Search;
pub use types::Selection;
pub use types::SelectionKind;
pub use types::SelectionSet;
pub use types::SnapshotMode;
pub use types::SpecialKey;
pub use types::Style;
pub use types::WrapMode;
pub use vim::InsertDir;
pub use vim::InsertEntry;
pub use vim::InsertReason;
pub use vim::InsertSession;
pub use vim::LastChange;
pub use vim::LastVisual;
pub use vim::Motion;
pub use vim::Operator;
pub use vim::Pending;
pub use vim::RangeKind;
pub use vim::ScrollDir;
pub use vim::SearchPrompt;
pub use vim::op_is_change;
pub use vim::parse_motion;
pub use vim::Mode as FsmMode;

Modules§

keymap_motion
motions
Vim-shaped cursor motions, computed over the SPEC trait surface.
search
Engine-owned search state + execution helpers.
substitute
Public substitute command parser and applicator.
types
Core types for the engine trait surface.
vim
Vim-mode engine.

Structs§

BufferFoldProvider
FoldProvider adapter wrapping a &hjkl_buffer::Buffer. Lets engine call sites ask the buffer’s fold storage about visible rows without reaching into Buffer::next_visible_row &c. directly.
BufferFoldProviderMut
Mutable FoldProvider adapter wrapping a &mut hjkl_buffer::Buffer. Engine call sites that need to dispatch a FoldOp (vim’s z… keystrokes, the :fold* Ex commands, edit-pipeline invalidation) construct this on the fly from &mut self.buffer and call FoldProvider::apply / FoldProvider::invalidate_range on it.
Editor
Input
A key press with modifier flags. The vim engine reads modifiers directly off this struct (e.g. input.ctrl && input.key == Key::Char('d')).
Registers
Slot
StepBookkeeping
State carried between Editor::begin_step and Editor::end_step.
Viewport
Visible region of a buffer — the runtime viewport state the host owns and mutates per render frame.

Enums§

Key
A key code, mirroring the subset of [crossterm::event::KeyCode] the vim engine actually consumes. Null is the conventional sentinel for “no input” (matching the previous tui_textarea::Key shape) so call sites can early-return on unsupported keys.
KeybindingMode
Which keyboard discipline the editor uses. Currently vim-only, but kept as an enum so future emacs / plain bindings can slot in without touching the public signature.
LspIntent
Host-observable LSP requests triggered by editor bindings. The hjkl-engine crate doesn’t talk to an LSP itself — it just raises an intent that the TUI layer picks up and routes to sqls.
MarkJump
Return value from the engine’s try_goto_mark_* methods. Tells the caller (app layer) whether a cross-buffer switch is required.
ViewMode
A read-only view layered over the real input VimMode. Unlike a vim mode (which decides how keystrokes are interpreted), a ViewMode only changes what the buffer presents — input is still interpreted as Normal.
VimMode
Coarse vim-mode a host app can display in its status line.

Functions§

decode_macro
Reverse of [encode_macro] — parse the textual form back into Input events for replay. Unknown <…> tags are dropped silently so the caller can roundtrip text the user pasted into a register without erroring out on partial matches.
decode_planned_input
Decode a crate::types::Input (alias: crate::PlannedInput) to the engine-internal Input type.