mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-08-07 22:17:07 +02:00
This commit is contained in:
parent
859b173a1e
commit
94c26f06cc
5 changed files with 347 additions and 250 deletions
|
|
@ -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 };
|
||||
()
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue