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<x>` / `dF<x>` / `dt<x>` / `dT<x>` — apply operator over find
58    /// motion. Engine builds `Motion::Find { ch, forward, till }` and applies
59    /// it. `total_count` is `count1 * inner_count` folded at transition time.
60    ///
61    /// Replaces `EnterOpFind` (removed in 0.7.0). The reducer no longer sets
62    /// engine `Pending::OpFind`; instead it transitions to
63    /// `PendingState::OpFind` and emits this command on the next char.
64    ApplyOpFind {
65        op: crate::operator::OperatorKind,
66        ch: char,
67        forward: bool,
68        till: bool,
69        total_count: usize,
70    },
71    // Future variants land in chunks 2c–2e: GotoMark, etc.
72}