mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: and sweeps right through the codebase
This commit is contained in:
parent
d37bd3e0c5
commit
c9b09b7dea
16 changed files with 370 additions and 625 deletions
|
|
@ -89,7 +89,7 @@ impl Tui {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait TuiRun<R: Layout<Tui> + Handle<Tui> + Sized + 'static> {
|
||||
pub trait TuiRun<R: Content<Tui> + Handle<Tui> + Sized + 'static> {
|
||||
/// Run an app in the main loop.
|
||||
fn run (&self, state: &Arc<RwLock<R>>) -> Usually<()>;
|
||||
/// Spawn the input thread.
|
||||
|
|
@ -98,7 +98,7 @@ pub trait TuiRun<R: Layout<Tui> + Handle<Tui> + Sized + 'static> {
|
|||
fn run_output (&self, state: &Arc<RwLock<R>>, sleep: Duration) -> JoinHandle<()>;
|
||||
}
|
||||
|
||||
impl<T: Layout<Tui> + Handle<Tui> + Sized + 'static> TuiRun<T> for Arc<RwLock<Tui>> {
|
||||
impl<T: Content<Tui> + Handle<Tui> + Sized + 'static> TuiRun<T> for Arc<RwLock<Tui>> {
|
||||
fn run (&self, state: &Arc<RwLock<T>>) -> Usually<()> {
|
||||
let _input_thread = self.run_input(state, Duration::from_millis(100));
|
||||
self.write().unwrap().setup()?;
|
||||
|
|
@ -254,12 +254,11 @@ pub struct TuiOutput {
|
|||
impl Output<Tui> for TuiOutput {
|
||||
#[inline] fn area (&self) -> [u16;4] { self.area }
|
||||
#[inline] fn area_mut (&mut self) -> &mut [u16;4] { &mut self.area }
|
||||
#[inline] fn render_in (&mut self, area: [u16;4], widget: &impl Render<Tui>) -> Usually<()> {
|
||||
#[inline] fn place (&mut self, area: [u16;4], content: &impl Content<Tui>) {
|
||||
let last = self.area();
|
||||
*self.area_mut() = area;
|
||||
widget.render(self);
|
||||
content.render(self);
|
||||
*self.area_mut() = last;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -330,13 +329,13 @@ pub fn half_block (lower: bool, upper: bool) -> Option<char> {
|
|||
|
||||
//impl<T: Content<Tui>> Render<Tui> for T {}
|
||||
|
||||
impl Render<Tui> for &str {
|
||||
impl Content<Tui> for &str {
|
||||
fn render (&self, to: &mut TuiOutput) {
|
||||
to.blit(self, to.area.x(), to.area.y(), None)
|
||||
}
|
||||
}
|
||||
|
||||
impl Render<Tui> for String {
|
||||
impl Content<Tui> for String {
|
||||
fn render (&self, to: &mut TuiOutput) {
|
||||
to.blit(self, to.area.x(), to.area.y(), None)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue