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 /// `diw` etc. — apply operator over text-object range. The reducer owns the
45 /// `i`/`a` key via `PendingState::OpTextObj`; on the next char it emits this
46 /// command. Host calls `Editor::apply_op_text_obj`.
47 ApplyOpTextObj {
48 op: crate::operator::OperatorKind,
49 ch: char,
50 inner: bool,
51 total_count: usize,
52 },
53 /// `dgg` etc. — apply operator over g-chord motion or case-op linewise form.
54 /// The reducer owns the `g` key via `PendingState::OpG`; on the next char it
55 /// emits this command. Host calls `Editor::apply_op_g`.
56 ApplyOpG {
57 op: crate::operator::OperatorKind,
58 ch: char,
59 total_count: usize,
60 },
61 /// `df<x>` / `dF<x>` / `dt<x>` / `dT<x>` — apply operator over find
62 /// motion. Engine builds `Motion::Find { ch, forward, till }` and applies
63 /// it. `total_count` is `count1 * inner_count` folded at transition time.
64 ///
65 /// Replaces `EnterOpFind` (removed in 0.7.0). The reducer no longer sets
66 /// engine `Pending::OpFind`; instead it transitions to
67 /// `PendingState::OpFind` and emits this command on the next char.
68 ApplyOpFind {
69 op: crate::operator::OperatorKind,
70 ch: char,
71 forward: bool,
72 till: bool,
73 total_count: usize,
74 },
75 /// `"<reg>` chord completion. Engine validates `reg` against
76 /// `[a-zA-Z0-9"+*_]` and sets `vim.pending_register` if valid. Invalid
77 /// chars are silently ignored (no-op), matching the engine FSM behaviour.
78 SetPendingRegister {
79 reg: char,
80 },
81 // Future variants land in chunks 2c–2e: GotoMark, etc.
82}