1pub mod command;
2pub mod insert;
3pub mod normal;
4pub mod prompt;
5pub mod view;
6
7use indigo_key::Keymap;
8use std::sync::Arc;
9
10#[derive(Clone, Default)]
11pub enum Mode {
12 #[default]
13 Normal,
14 Insert,
15 Prompt(prompt::State),
16 View(view::State),
17}
18
19impl Mode {
20 #[must_use]
21 pub fn kind(&self) -> ModeKind {
22 match self {
23 Self::Normal => ModeKind::Normal,
24 Self::Insert => ModeKind::Insert,
25 Self::Prompt(_) => ModeKind::Prompt,
26 Self::View(_) => ModeKind::View,
27 }
28 }
29}
30
31#[derive(Clone, Copy)]
32pub enum ModeKind {
33 Normal,
34 Insert,
35 Prompt,
36 View,
37 }
39
40#[derive(Clone)]
41pub struct Keymaps {
42 pub normal: Arc<Keymap<Vec<normal::Action>>>,
43 pub insert: Arc<Keymap<Vec<insert::Action>>>,
44 pub prompt: Arc<Keymap<Vec<prompt::Action>>>,
45 pub view: Arc<Keymap<Vec<view::Action>>>,
46}
47
48impl Default for Keymaps {
49 fn default() -> Self {
50 Self {
51 normal: Arc::new(normal::keymap()),
52 insert: Arc::new(insert::keymap()),
53 prompt: Arc::new(prompt::keymap()),
54 view: Arc::new(view::keymap()),
55 }
56 }
57}