From eb122585d63c0c97ef88fb85f174da30f8a5d69f Mon Sep 17 00:00:00 2001 From: unspeaker Date: Fri, 6 Sep 2024 00:57:21 +0300 Subject: [PATCH] wip: a little broken rendering (as a treat) --- crates/tek_core/src/component/split.rs | 6 +- crates/tek_core/src/tui.rs | 454 +----------------- crates/tek_core/src/tui/tui_border.rs | 169 +++++++ crates/tek_core/src/tui/tui_buffer.rs | 37 ++ crates/tek_core/src/tui/tui_colors.rs | 159 ++++++ crates/tek_core/src/tui/tui_layout.rs | 81 ++++ crates/tek_sequencer/src/lib.rs | 3 +- crates/tek_sequencer/src/transport_focus.rs | 22 - ...{transport_render.rs => transport_view.rs} | 0 9 files changed, 457 insertions(+), 474 deletions(-) create mode 100644 crates/tek_core/src/tui/tui_border.rs create mode 100644 crates/tek_core/src/tui/tui_buffer.rs create mode 100644 crates/tek_core/src/tui/tui_colors.rs create mode 100644 crates/tek_core/src/tui/tui_layout.rs delete mode 100644 crates/tek_sequencer/src/transport_focus.rs rename crates/tek_sequencer/src/{transport_render.rs => transport_view.rs} (100%) diff --git a/crates/tek_core/src/component/split.rs b/crates/tek_core/src/component/split.rs index 8cf2f667..2f7df30d 100644 --- a/crates/tek_core/src/component/split.rs +++ b/crates/tek_core/src/component/split.rs @@ -13,9 +13,9 @@ impl Direction { } pub struct Split<'a, E: Engine> { - items: Collection<'a, E>, - direction: Direction, - focus: Option + pub items: Collection<'a, E>, + pub direction: Direction, + pub focus: Option } impl<'a, E: Engine> Split<'a, E> { diff --git a/crates/tek_core/src/tui.rs b/crates/tek_core/src/tui.rs index e3b7e57f..f384fbca 100644 --- a/crates/tek_core/src/tui.rs +++ b/crates/tek_core/src/tui.rs @@ -10,6 +10,12 @@ use crossterm::terminal::{ EnterAlternateScreen, LeaveAlternateScreen, enable_raw_mode, disable_raw_mode }; +submod! { + tui_border + tui_buffer + tui_colors + tui_layout +} pub struct Tui { exited: Arc, buffer: usize, @@ -98,7 +104,7 @@ impl Tui { if engine.exited() { break } - engine.render(&*state).expect("render failed"); + state.render(&mut engine).expect("render failed"); engine.flip(); } std::thread::sleep(sleep); @@ -219,449 +225,3 @@ pub fn half_block (lower: bool, upper: bool) -> Option { _ => None } } - -pub struct FillBg(pub Color); - -impl Render for FillBg { - fn render (&self, to: &mut Tui) -> Perhaps { - to.fill_bg(to.area, self.0); - Ok(Some(to.area)) - } -} - -pub trait BorderStyle { - const NW: &'static str = ""; - const N: &'static str = ""; - const NE: &'static str = ""; - const E: &'static str = ""; - const SE: &'static str = ""; - const S: &'static str = ""; - const SW: &'static str = ""; - const W: &'static str = ""; - - #[inline] - fn draw <'a> (&self, to: &mut Tui) -> Perhaps { - self.draw_horizontal(to, None)?; - self.draw_vertical(to, None)?; - self.draw_corners(to, None)?; - Ok(Some(to.area)) - } - - #[inline] - fn draw_horizontal (&self, to: &mut Tui, style: Option