revi_core/mode.rs
1use revi_ui::CursorShape::{Block, Line};
2use std::fmt;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum Mode {
6 Normal,
7 Command,
8 Insert,
9}
10impl Mode {
11 #[must_use]
12 pub fn shape(self) -> revi_ui::CursorShape {
13 match self {
14 Self::Normal | Self::Command => Block,
15 Self::Insert => Line,
16 }
17 }
18}
19
20impl fmt::Display for Mode {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 let mode = match self {
23 Self::Normal => "Normal",
24 Self::Command => "Command",
25 Self::Insert => "Insert",
26 };
27 write!(f, "{}", mode)
28 }
29}
30
31// trait Scroll {
32// fn scroll_up(&mut self);
33// fn scroll_down(&mut self);
34// fn scroll_left(&mut self);
35// fn scroll_right(&mut self);
36// }
37//
38// trait Movement {
39// fn move_cursor_up(&mut self);
40// fn move_cursor_down(&mut self);
41// fn move_cursor_left(&mut self);
42// fn move_cursor_right(&mut self);
43// }
44//
45//
46// /// Inserting text into buffer and basic movement.
47// trait Insert: Movement {
48// fn insert_char(&mut self);
49// fn backspace(&mut self);
50// fn delete(&mut self);
51// fn new_line(&mut self);
52// }
53// /// This is all of your Movement commands
54// trait Normal: Movement + Scroll {
55// }
56//
57// /// Command Bar behavior
58// trait Comand: Insert {}
59// trait ModalComand: Insert + Normal {}
60//
61// /// Fuzzy File
62// trait Fuzzy: Normal + Insert {}