wip: refactor pt.12, separate tek_snd

This commit is contained in:
🪞👃🪞 2024-11-10 22:24:58 +01:00
parent 47c9cd2fe8
commit 2be7aee002
28 changed files with 955 additions and 766 deletions

View file

@ -1,5 +1,34 @@
use crate::*;
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum FocusCommand {
Next,
Prev,
Up,
Down,
Left,
Right,
Enter,
Exit
}
impl<F: FocusGrid> Command<F> for FocusCommand {
fn execute (self, state: &mut F) -> Perhaps<FocusCommand> {
use FocusCommand::*;
match self {
Next => { state.focus_next(); },
Prev => { state.focus_prev(); },
Up => { state.focus_up(); },
Down => { state.focus_down(); },
Left => { state.focus_left(); },
Right => { state.focus_right(); },
Enter => { state.focus_enter(); },
Exit => { state.focus_exit(); },
}
Ok(None)
}
}
pub trait FocusGrid {
type Item: Copy + PartialEq;
fn layout (&self) -> &[&[Self::Item]];
@ -85,32 +114,3 @@ pub trait FocusGrid {
self.update_focus();
}
}
#[derive(Copy, Clone, PartialEq)]
pub enum FocusCommand {
Next,
Prev,
Up,
Down,
Left,
Right,
Enter,
Exit
}
impl<F: FocusGrid> Command<F> for FocusCommand {
fn execute (self, state: &mut F) -> Perhaps<FocusCommand> {
use FocusCommand::*;
match self {
Next => { state.focus_next(); },
Prev => { state.focus_prev(); },
Up => { state.focus_up(); },
Down => { state.focus_down(); },
Left => { state.focus_left(); },
Right => { state.focus_right(); },
Enter => { state.focus_enter(); },
Exit => { state.focus_exit(); },
}
Ok(None)
}
}