update example modes
Some checks failed
/ build (push) Has been cancelled

This commit is contained in:
facile pop culture reference 2026-07-30 22:07:42 +03:00
parent 859b173a1e
commit 94c26f06cc
5 changed files with 347 additions and 250 deletions

View file

@ -1,3 +1,37 @@
//! Mode 0: Direct draw
use ::{std::sync::{Arc, RwLock}, ratatui::style::Color, tengri::*};
fn main () {}
//! Mode 00: Direct draw, direct control
use ::std::sync::{Arc, RwLock};
use ::crossterm::event::{Event::*, KeyEvent, KeyCode::*};
use ::ratatui::style::Color;
use ::tengri::{*, lang::*};
tui_app!(State {
/** User-controllable value. */
cursor: usize,
});
tui_view!(self: State {
thunk(|to: &mut Tui|{
let cursor = format!("Cursor: {}", self.cursor);
let _ = "DEMO [MODE 00]".align_sw().draw(to);
let _ = ShowSize.align_se().draw(to);
let _ = format!("Cursor: {}", self.cursor).align_c().draw(to);
Ok(Some(to.area()))
})
});
tui_keys!(self: State, input {
Ok(if let Key(KeyEvent { code, .. }) = input.0 {
match code {
Up | Right => {
self.cursor = (self.cursor + 1) % 10;
()
},
Down | Left => {
self.cursor = if self.cursor > 0 { self.cursor - 1 } else { 10 - 1 };
()
},
_ => {}
}
})
});