A simple CPU rendered GUI IDE experience.
Diffstat (limited to 'src/edi/st.rs')
-rw-r--r--src/edi/st.rs47
1 files changed, 38 insertions, 9 deletions
diff --git a/src/edi/st.rs b/src/edi/st.rs
index de25b1b..3186b05 100644
--- a/src/edi/st.rs
+++ b/src/edi/st.rs
@@ -36,7 +36,44 @@ rust_fsm::state_machine! {
pub(crate) State => #[derive(Debug)] pub(crate) Action => #[derive(Debug)] pub(crate) Do
Dead => K(Key => _) => Dead,
+Normal => {
+ K(Key::Character(x) if x == "i") => Insert,
+ K(Key::Character(x) if x == ":") => Command (Commands => default()),
+ K(Key::Character(x) if x == "/") => Procure((default(), InputRequest::Search)),
+ K(Key::Character(x) if x == "p") => _ [Paste],
+ K(Key::Character(x) if x == "u") => _ [Undo],
+ K(Key::Character(x) if x == "y") => _ [Redo],
+ K(Key::Named(Space)) => SpaceMode,
+ K(_) => _,
+ M(_) => _,
+ C(_) => _,
+},
+Insert => {
+ K(Key::Named(Escape)) => Normal,
+ K(k) => _ [Edit],
+ K(_) => _,
+ M(_) => _,
+ C(_) => _,
+},
+Command(_) => K(Key::Named(Escape)) => Normal,
+Command(t) => K(Key::Named(Enter)) => Normal [ProcessCommand(Commands => t)],
+Command(t) => K(Key::Named(Tab) if shift()) => _ [CommandPrev],
+Command(t) => K(Key::Named(Tab)) => _ [CommandNext],
+Command(mut t) => K(k) => Command({ handle2(&k, &mut t.tedit, None); t }),
+Command(t) => C(_) => _,
+Command(t) => M(_) => _,
+Command(t) => K(_) => _,
+
+SpaceMode => K(Key::Named(Escape)) => Normal,
+SpaceMode => K(Key::Character(x) if x == "f") => _ [Symbols],
+SpaceMode => K(Key::Character(x) if x == "a") => _ [CodeAction],
+SpaceMode => K(Key::Character(x) if x == "c") => _ [Comment(Self::SpaceMode)],
+SpaceMode => C(_) => _,
+SpaceMode => M(_) => _,
+SpaceMode => K(_) => _,
+
Default => {
+ K(Key::Character(x) if x == "n" && ctrl()) => Normal,
K(Key::Character(x) if x == "s" && ctrl()) => Save [Save],
K(Key::Character(x) if x == "q" && ctrl()) => Dead [Quit],
K(Key::Character(x) if x == "v" && ctrl()) => _ [Paste],
@@ -50,7 +87,6 @@ Default => {
K(Key::Character(x) if x == "0" && ctrl()) => _ [MatchingBrace],
K(Key::Character(x) if x == "`" && ctrl()) => _ [SpawnTerminal],
K(Key::Character(y) if y == "/" && ctrl()) => Default [Comment(State => State::Default)],
- K(Key::Character(x) if x == "p" && ctrl()) => Command(Commands => Commands::default()),
K(Key::Named(F1)) => Procure((default(), InputRequest::RenameSymbol)),
K(Key::Named(k @ (ArrowUp | ArrowDown)) if alt()) => _ [InsertCursor(Direction => {
if k == ArrowUp {Direction::Above} else { Direction::Below }
@@ -71,19 +107,12 @@ Default => {
K(_) => _ [Edit],
M(_) => _,
},
-Command(_) => K(Key::Named(Escape)) => Default,
-Command(t) => K(Key::Named(Enter)) => Default [ProcessCommand(Commands => t)],
-Command(mut t) => K(Key::Named(Tab) if shift()) => Command({ t.back();t }),
-Command(mut t) => K(Key::Named(Tab)) => Command({ t.next(); t }),
-Command(mut t) => K(k) => Command({ handle2(&k, &mut t.tedit, None); t }),
-Command(t) => C(_) => _,
-Command(t) => K(_) => _,
Symbols(Rq { result: Some(_x), request: _rq }) => {
K(Key::Named(Tab) if shift()) => _ [SymbolsSelectNext],
K(Key::Named(ArrowDown)) => _ [SymbolsSelectNext],
K(Key::Named(ArrowUp | Tab)) => _ [SymbolsSelectPrev],
K(Key::Named(Enter)) => _ [SymbolsSelect],
- K(Key::Named(Escape)) => Default,
+ K(Key::Named(Escape)) => Normal,
},
Symbols(Rq::<Symbols, Option<SymbolsList>, (), AQErr> => _rq) => {
K(Key::Character(x) if x == "d" && ctrl()) => _ [SwitchType], // crahs cond methinks