mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 17:46:42 +01:00
tabula rasa
This commit is contained in:
commit
2b855f43d7
9 changed files with 1601 additions and 0 deletions
66
src/keys.rs
Normal file
66
src/keys.rs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
use crate::*;
|
||||
|
||||
impl Handle<TuiIn> for Taggart {
|
||||
fn handle (&mut self, input: &TuiIn) -> Perhaps<bool> {
|
||||
Ok(match &*input.event() {
|
||||
Event::Key(KeyEvent {
|
||||
code: KeyCode::Up,
|
||||
kind: KeyEventKind::Press,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
state: KeyEventState::NONE
|
||||
}) => {
|
||||
self.cursor = self.cursor.saturating_sub(1);
|
||||
None
|
||||
},
|
||||
Event::Key(KeyEvent {
|
||||
code: KeyCode::Down,
|
||||
kind: KeyEventKind::Press,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
state: KeyEventState::NONE
|
||||
}) => {
|
||||
self.cursor = self.cursor + 1;
|
||||
None
|
||||
},
|
||||
Event::Key(KeyEvent {
|
||||
code: KeyCode::PageUp,
|
||||
kind: KeyEventKind::Press,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
state: KeyEventState::NONE
|
||||
}) => {
|
||||
self.offset = self.offset.saturating_sub(5);
|
||||
None
|
||||
},
|
||||
Event::Key(KeyEvent {
|
||||
code: KeyCode::PageDown,
|
||||
kind: KeyEventKind::Press,
|
||||
modifiers: KeyModifiers::NONE,
|
||||
state: KeyEventState::NONE
|
||||
}) => {
|
||||
self.offset += 5;
|
||||
None
|
||||
},
|
||||
_ => None
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[moku::state_machine]
|
||||
mod taggart {
|
||||
use moku::*;
|
||||
#[machine_module] mod machine {}
|
||||
use self::machine::{TaggartState, TopSuperstates};
|
||||
struct Top;
|
||||
impl TopState<TaggartState> for Top {}
|
||||
struct Tree(usize);
|
||||
#[superstate(Top)] impl State<TaggartState> for Tree {
|
||||
fn enter (_: &mut TopSuperstates<'_>) -> StateEntry<Self, TaggartState> {
|
||||
StateEntry::State(Self(0))
|
||||
}
|
||||
}
|
||||
struct File(usize);
|
||||
#[superstate(Top)] impl State<TaggartState> for File {
|
||||
fn enter (_: &mut TopSuperstates<'_>) -> StateEntry<Self, TaggartState> {
|
||||
StateEntry::State(Self(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue