buffr_modal/lib.rs
1//! Vim-style modal keybinding engine for buffr.
2//!
3//! Two-layer modal model:
4//!
5//! - **Page mode** ([`PageMode`]) — scroll, tab switch, omnibar, hint mode,
6//! command line. Owned by this crate.
7//! - **Insert mode** — typing in `<textarea>` / `contenteditable` / form
8//! fields. Delegates to [`hjkl_engine::Editor`] against a mirrored
9//! [`hjkl_buffer::Buffer`] synced to the DOM via CEF.
10//!
11//! See `PLAN.md` "Edit-mode integration with `hjkl-*`" for the full
12//! data flow.
13//!
14//! # Layout
15//!
16//! - [`actions`] — [`PageAction`] / [`PageMode`] / [`Mode`]
17//! - [`key`] — vim-notation parser → [`KeyChord`] / [`Modifiers`]
18//! - [`keymap`] — mode-scoped trie + ambiguity resolution
19//! - [`edit_mode`] — [`EditSession`] wrapping `hjkl_engine::Editor`
20//! - [`host`] — [`BuffrHost`] adapter implementing
21//! `hjkl_engine::Host`
22
23pub mod actions;
24pub mod edit_mode;
25pub mod engine;
26pub mod host;
27pub mod key;
28pub mod keymap;
29
30/// winit `KeyEvent` → [`KeyChord`] adapter. Gated behind the `winit`
31/// Cargo feature; the engine itself stays winit-agnostic.
32#[cfg(feature = "winit")]
33pub mod winit_adapter;
34
35pub use actions::{Mode, PageAction, PageMode};
36pub use edit_mode::EditSession;
37pub use engine::{DEFAULT_TIMEOUT, EditModeStep, Engine, Step};
38pub use host::{BuffrEditIntent, BuffrHost};
39pub use key::{Key, KeyChord, Modifiers, NamedKey, ParseError, parse_key, parse_keys};
40pub use keymap::{BindError, Keymap, Lookup};
41
42// Re-export hjkl_engine types needed by the winit key-routing path in
43// `apps/buffr/src/main.rs`. `buffr-modal` owns the hjkl_engine dep so
44// the app binary doesn't need its own direct dependency.
45pub use hjkl_engine::{Modifiers as EngineModifiers, PlannedInput, SpecialKey, VimMode};
46
47#[cfg(feature = "winit")]
48pub use winit_adapter::{key_event_to_chord, key_event_to_chord_with_repeat};