mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-08-28 13:06:56 +02:00
parent
a9f2fa2cdd
commit
291ab63224
11 changed files with 98 additions and 96 deletions
|
|
@ -27,7 +27,7 @@ tui_keys!(self: State, input {
|
|||
});
|
||||
|
||||
tui_view!(self: State {
|
||||
let title = "Demo [Mode 01]";
|
||||
let title = "Demo [Mode 01";
|
||||
let items = self.history.iter().take(10).map(|x|format!("{x:?}")).join("\n");
|
||||
let history = format!("History: {}\n{items}", self.history.len());
|
||||
let cursor = format!("Counter: {}", self.cursor);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ tui_view!(self: State {
|
|||
let heading = format!("Demo [Mode 02]\nExample {}/{}\nSize {:?}", index, VIEWS.len(), &wh);
|
||||
let title = bg(Color::Rgb(60, 10, 10), heading);
|
||||
let code = bg(Color::Rgb(10, 60, 10), format!("Source:\n{}", src).max_h(10));
|
||||
let widget = draw(move|to: &mut Tui|self.interpret(to, &src)); // FIXME this forcefills
|
||||
let widget = draw(move|to: &mut Tui|self.interpret(to, src)); // FIXME this forcefills
|
||||
let sidebar = bg(Color::Rgb(20, 20, 20), north(code, title)).max_w(40);
|
||||
let content = bg(Color::Rgb(64, 64, 64), widget);
|
||||
east(sidebar, ShowSizeOf(content))
|
||||
|
|
@ -31,22 +31,8 @@ tui_view!(self: State {
|
|||
//self.size.of(bg(Color::Rgb(10, 10, 10), east(sidebar, content)).full_w())
|
||||
});
|
||||
|
||||
impl_keywords!(Tui, XYWH<u16>, State [
|
||||
kw_when,
|
||||
kw_either,
|
||||
kw_split,
|
||||
kw_align,
|
||||
kw_exact,
|
||||
kw_min,
|
||||
kw_max,
|
||||
kw_push,
|
||||
kw_tui_text,
|
||||
kw_tui_fg,
|
||||
kw_tui_bg
|
||||
]);
|
||||
|
||||
impl<'a> Interpret<'a, Tui, Option<XYWH<u16>>> for State {
|
||||
fn interpret_word <L: Language<'a> + ?Sized> (&'a self, to: &mut Tui, lang: &'a L)
|
||||
fn interpret_word <L: Language + ?Sized> (&'a self, to: &mut Tui, lang: &'a L)
|
||||
-> Drawn<'a, u16>
|
||||
{
|
||||
match lang.src()? {
|
||||
|
|
@ -56,13 +42,20 @@ impl<'a> Interpret<'a, Tui, Option<XYWH<u16>>> for State {
|
|||
src => todo!("src: {src:?}")
|
||||
}
|
||||
}
|
||||
fn interpret_expr <L: Language<'a> + ?Sized> (&self, to: &mut Tui, src: &'a L)
|
||||
fn interpret_expr <L: Language + ?Sized> (&'a self, to: &mut Tui, src: &'a L)
|
||||
-> Drawn<'a, u16>
|
||||
{
|
||||
if let Some(area) = self.keyword(to, src)? {
|
||||
Ok(Some(area))
|
||||
if let Some(src) = src.src()? {
|
||||
interpret_keyword!(self, to, src, [
|
||||
kw_when, kw_either,
|
||||
kw_split, kw_align,
|
||||
kw_exact, kw_min, kw_max,
|
||||
kw_push, kw_pull,
|
||||
kw_tui_text, kw_tui_fg, kw_tui_bg
|
||||
]);
|
||||
Err(format!("interpret_expr: unexpected: {src:?}").into())
|
||||
} else {
|
||||
Err(format!("App::interpret_expr: unexpected: {src:?}").into())
|
||||
Err(format!("interpret_expr: no keyword: {src:?}").into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue