add origin and align methods to Layout trait

This commit is contained in:
facile pop culture reference 2026-07-10 18:24:44 +03:00
parent 09463649c6
commit 13c886d9e0
18 changed files with 333 additions and 248 deletions

View file

@ -1,7 +1,7 @@
use ::{
std::{io::stdout, sync::{Arc, RwLock}},
tengri::{*, term::*, lang::*, keys::*, draw::*, space::*, lang::*},
ratatui::style::Color,
tengri::{*, lang::*},
};
tui_main!(State {
@ -18,10 +18,10 @@ tui_view!(|self: State| {
let wh = (self.size.w(), self.size.h());
let src = VIEWS.get(self.cursor).unwrap_or(&"");
let heading = format!("State {}/{} in {:?}", index, VIEWS.len(), &wh);
let title = bg(Color::Rgb(60, 10, 10), y_push(1, align_n(heading)));
let code = bg(Color::Rgb(10, 60, 10), y_push(2, align_n(format!("{}", src))));
let title = bg(Color::Rgb(60, 10, 10), heading.align_n().push_y(1));
let code = bg(Color::Rgb(10, 60, 10), format!("{}", src).align_n().push_y(2));
//let content = ;//();//bg(Color::Rgb(10, 10, 60), View(self, CstIter::new(src)));
let widget = thunk(move|to: &mut Tui|self.interpret(to, &src));
let widget = thunk(move|to: &mut Tui|self.interpret(to, &src).map(Some));
self.size.of(south(title, north(code, widget)))
});
@ -32,7 +32,7 @@ struct State {
/** User-controllable value. */
cursor: usize,
/** Rendered window size. */
size: crate::space::Size,
size: Sizer,
}
impl Interpret<Tui, XYWH<u16>> for State {