Skip to main content

hjkl_vim/
cmd.rs

1/// Controller commands the host engine implements. hjkl-vim never mutates
2/// the editor directly — it emits a command and the host (apps/hjkl) calls
3/// the corresponding `Editor` method.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum EngineCmd {
6    ReplaceChar {
7        ch: char,
8        count: usize,
9    },
10    /// Emitted by `PendingState::Find` when the user completes `f<x>` / `F<x>`
11    /// / `t<x>` / `T<x>`. The host calls `Editor::find_char`.
12    FindChar {
13        ch: char,
14        forward: bool,
15        till: bool,
16        count: usize,
17    },
18    /// Emitted by `PendingState::AfterG` when the user completes `g<x>`. The
19    /// host calls `Editor::after_g(ch, count)`.
20    AfterGChord {
21        ch: char,
22        count: usize,
23    },
24    /// Emitted by `PendingState::AfterZ` when the user completes `z<x>`. The
25    /// host calls `Editor::after_z(ch, count)`.
26    AfterZChord {
27        ch: char,
28        count: usize,
29    },
30    /// `d<motion>` / `y<motion>` / `c<motion>` / `><motion>` / `<<motion>` —
31    /// apply operator over a single-key motion. `motion_key` is the raw key
32    /// char (e.g. `'w'`, `'$'`, `'G'`). Engine parses via `parse_motion` and
33    /// applies. `total_count = count1 * inner_count`.
34    ApplyOpMotion {
35        op: crate::operator::OperatorKind,
36        motion_key: char,
37        total_count: usize,
38    },
39    /// `dd` / `yy` / `cc` / `>>` / `<<` — doubled-letter line op.
40    ApplyOpDouble {
41        op: crate::operator::OperatorKind,
42        total_count: usize,
43    },
44    /// `di` / `da` — operator-pending text object entry. Engine sets
45    /// `Pending::OpTextObj` for the next bracket key. Sub-state lifts in 2c-iii.
46    EnterOpTextObj {
47        op: crate::operator::OperatorKind,
48        count1: usize,
49        inner: bool,
50    },
51    /// `dg` — operator-pending g-chord entry. Engine sets `Pending::OpG`.
52    /// Sub-state lifts in 2c-iv.
53    EnterOpG {
54        op: crate::operator::OperatorKind,
55        count1: usize,
56    },
57    /// `df` / `dF` / `dt` / `dT` — operator-pending find entry. Engine sets
58    /// `Pending::OpFind`. Sub-state lifts in 2c-ii.
59    EnterOpFind {
60        op: crate::operator::OperatorKind,
61        count1: usize,
62        forward: bool,
63        till: bool,
64    },
65    // Future variants land in chunks 2c–2e: GotoMark, etc.
66}