strop_core/commands.rs
1//! Frontend command metadata shared by the TUI, native GUI and automation.
2//! Dispatch ownership stays in the engine; this data carries only stable
3//! identities, user-facing rows and whether the row is dispatchable today.
4//!
5//! The engine consumes this table as its single keymap source. Native
6//! frontends read the same rows for parity/help surfaces; neither builds a
7//! second command table from rendering code.
8
9/// The one-char absorber flavors.
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub enum AbsorbKind {
12 Replace,
13 MarkSet,
14 MarkJump,
15 Find,
16 /// q<a> — toggle macro recording into register a.
17 MacroRecord,
18 /// @<a> — replay register a's macro.
19 MacroPlay,
20}
21
22/// Dispatch-independent command category. Engine-specific leaf handlers
23/// remain in the engine's adapter over this data.
24#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25pub enum CommandKind {
26 /// A direct command or semantic action.
27 Leaf,
28 Alias(&'static str),
29 /// A grammar motion.
30 Motion,
31 /// A grammar operator.
32 Operator,
33 /// An object prefix.
34 ObjectPrefix,
35 /// A prefix: children follow; which-key renders them.
36 Prefix,
37 /// Free-text line: a modal text field, not a key sequence.
38 TextLine,
39 /// One-char absorbers.
40 AbsorbChar(AbsorbKind),
41 /// Register selection.
42 AbsorbRegister,
43 /// Implemented by a modal field or Ex host, not the document trie.
44 Contextual,
45 /// Planned slot: no dispatch yet.
46 Soon,
47}
48
49/// One binding row: stable identity, notation, description, sections,
50/// support state and dispatch category.
51#[derive(Debug, Clone, Copy, PartialEq, Eq)]
52pub struct Binding {
53 pub keys: &'static str,
54 pub desc: &'static str,
55 pub sections: &'static [&'static str],
56 pub live: bool,
57 pub id: &'static str,
58 pub kind: CommandKind,
59}
60
61pub const SECTIONS: &[&str] = &[
62 "normal", "visual", "insert", "leader", "git", "ex+panes", "terminal",
63];
64
65include!("commands/bindings.rs");