mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
trying to get new Bsp to work; update docs
This commit is contained in:
parent
c9b81edb45
commit
62ce1776c0
11 changed files with 301 additions and 157 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use crate::*;
|
||||
use std::sync::{Arc, atomic::{AtomicUsize, Ordering::Relaxed}};
|
||||
use ratatui::prelude::{Style, Color};
|
||||
|
||||
// TODO: 🡘 🡙 ←🡙→ indicator to expand window when too small
|
||||
|
||||
|
|
@ -79,3 +80,43 @@ impl<E: Engine> Measure<E> {
|
|||
//}
|
||||
|
||||
//impl<E: Engine> ContentDebug<E> for E {}
|
||||
|
||||
impl Render<Tui> for Measure<Tui> {
|
||||
fn min_size (&self, _: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
Ok(Some([0u16.into(), 0u16.into()].into()))
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
self.set_w(to.area().w());
|
||||
self.set_h(to.area().h());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Measure<Tui> {
|
||||
pub fn debug (&self) -> ShowMeasure {
|
||||
ShowMeasure(&self)
|
||||
}
|
||||
}
|
||||
|
||||
render!(<Tui>|self: ShowMeasure<'a>|render(|to: &mut TuiOutput|Ok({
|
||||
let w = self.0.w();
|
||||
let h = self.0.h();
|
||||
to.blit(&format!(" {w} x {h} "), to.area.x(), to.area.y(), Some(
|
||||
Style::default().bold().italic().bg(Color::Rgb(255, 0, 255)).fg(Color::Rgb(0,0,0))
|
||||
))
|
||||
})));
|
||||
|
||||
pub struct ShowMeasure<'a>(&'a Measure<Tui>);
|
||||
|
||||
pub struct DebugOverlay<E: Engine, W: Render<E>>(PhantomData<E>, pub W);
|
||||
|
||||
impl<T: Render<Tui>> Render<Tui> for DebugOverlay<Tui, T> {
|
||||
fn min_size (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
self.1.min_size(to)
|
||||
}
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
let [x, y, w, h] = to.area();
|
||||
self.1.render(to)?;
|
||||
Ok(to.blit(&format!("{w}x{h}+{x}+{y}"), x, y, Some(Style::default().green())))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue