mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-09-18 05:16:44 +02:00
Compare commits
3 commits
b7f4d55e1d
...
95ace83756
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95ace83756 | ||
|
|
3ee25879cd | ||
|
|
1f54140759 |
5 changed files with 32 additions and 10 deletions
2
dizzle
2
dizzle
|
|
@ -1 +1 @@
|
|||
Subproject commit 5426dc44f231531758a7e8575117357b55b1a9f5
|
||||
Subproject commit ab177b0d0d1ccdff0c69f915847be9a23a364663
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
22
src/term.rs
22
src/term.rs
|
|
@ -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)
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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()? {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue