Compare commits

..

3 commits

Author SHA1 Message Date
facile pop culture reference
95ace83756 implement Draw<Tui> for usize
Some checks failed
/ build (push) Has been cancelled
2026-08-13 07:43:42 +03:00
facile pop culture reference
3ee25879cd safe subtract in border 2026-08-13 07:43:25 +03:00
facile pop culture reference
1f54140759 remove generic from Namespace 2026-08-12 11:22:12 +03:00
5 changed files with 32 additions and 10 deletions

2
dizzle

@ -1 +1 @@
Subproject commit 5426dc44f231531758a7e8575117357b55b1a9f5
Subproject commit ab177b0d0d1ccdff0c69f915847be9a23a364663

View file

@ -163,9 +163,9 @@ impl Sizer {
$state: &S, $output: &mut O, $expr: &str
) -> Perhaps<XYWH<O::Unit>> where
S: Interpret<O, Option<XYWH<O::Unit>>>
+ for<'b> Namespace<'b, bool>
+ for<'b> Namespace<'b, O::Unit>
+ for<'b> Namespace<'b, Option<O::Unit>>
+ Namespace<bool>
+ Namespace<O::Unit>
+ Namespace<Option<O::Unit>>
$body
}
}
@ -177,10 +177,10 @@ impl Sizer {
$state: &S, $output: &mut Tui, $expr: &str
) -> Perhaps<XYWH<u16>> where
S: Interpret<Tui, Option<XYWH<u16>>>
+ for<'b> Namespace<'b, bool>
+ for<'b> Namespace<'b, u16>
+ for<'b> Namespace<'b, Option<u16>>
+ for<'b> Namespace<'b, Color>
+ Namespace<bool>
+ Namespace<u16>
+ Namespace<Option<u16>>
+ Namespace<Color>
$body
}
}

View file

@ -439,6 +439,28 @@ impl<T: Draw<Tui>> Draw<Tui> for ShowSizeOf<T> {
}
}
impl_draw!(|self: usize, to: Tui|{
let XYWH(x0, y0, w0, h0) = to.area();
let mut v = *self;
let w = (1 + if v > 0 { self.ilog10() } else { 0 }) as u16;
let h = 1u16;
Ok((w0 >= w && h0 >= h).then(||{
if let Tui::Draw(buffer, ..) = to {
let mut x = x0 + w - 1;
while x >= x0 {
if let Some(cell) = buffer.cell_mut(Position { x, y: y0 }) {
cell.set_char([
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
][(v % 10) as usize]);
}
x -= 1;
v = v / 10;
}
}
XYWH(x0, y0, w, h)
}))
});
impl_draw!(|self: String, to: Tui|{
self.as_str().draw(to)
});

View file

@ -194,7 +194,7 @@ pub trait BorderStyle: Draw<Tui> + Copy {
let area = to.area();
let style = style.or_else(||self.style_vertical());
let [x, x2, y, y2] = area.lrtb();
let h = y2 - y;
let h = y2.minus(y);
if h > 1 {
for y in y..y2.saturating_sub(1) {
to.blit(&Self::W, x, y, style);

View file

@ -30,7 +30,7 @@ fn_kw_layout_tui!(kw_tui_bg |state, output, expr| {
});
impl Tui {
pub fn eval_color_expr (state: &impl for<'a> Namespace<'a, u8>, src: impl Language)
pub fn eval_color_expr (state: &impl Namespace<u8>, src: impl Language)
-> Perhaps<Color>
{
if let Some(expr) = src.expr()? {