fix signatures of iter_ helpers

This commit is contained in:
i do not exist 2026-04-17 04:07:14 +03:00
parent 6c382e2627
commit c9b9ff1519
3 changed files with 56 additions and 47 deletions

View file

@ -6,13 +6,6 @@ use ::{
tui_main!(State { cursor: 10, ..Default::default() });
//namespace!(State: bool {});
//namespace!(State: u16 {});
//namespace!(State: Color {});
//handle!(TuiIn: |self: State, input|Action::from(input).eval(self).map(|_|None));
//view!(State: Tui: [ evaluate_output_expression, evaluate_output_expression_tui ]);
//draw!(State: Tui: [ draw_example ]);
impl Apply<TuiEvent, Usually<Self>> for State {
fn apply (&mut self, input: &TuiEvent) -> Usually<Self> {
todo!()
@ -53,19 +46,27 @@ fn draw_example (state: &State, to: &mut Tui) {
}
impl Action {
const BINDS: &'static str = stringify! { (@left prev) (@right next) };
const BINDS: &'static str = stringify! {
(@left prev)
(@right next)
};
fn eval (&self, state: &mut State) -> Perhaps<Self> {
use Action::*;
match self { Next => Self::next(state), Prev => Self::prev(state), }
}
fn next (state: &mut State) -> Perhaps<Self> {
state.cursor = (state.cursor + 1) % VIEWS.len();
Ok(Some(Self::Prev))
}
fn prev (state: &mut State) -> Perhaps<Self> {
state.cursor = if state.cursor > 0 { state.cursor - 1 } else { VIEWS.len() - 1 };
Ok(Some(Self::Next))
}
}
const VIEWS: &'static [&'static str] = &[
@ -148,3 +149,10 @@ const VIEWS: &'static [&'static str] = &[
},
];
//namespace!(State: bool {});
//namespace!(State: u16 {});
//namespace!(State: Color {});
//handle!(TuiIn: |self: State, input|Action::from(input).eval(self).map(|_|None));
//view!(State: Tui: [ evaluate_output_expression, evaluate_output_expression_tui ]);
//draw!(State: Tui: [ draw_example ]);