mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
separate Input and Output impls
This commit is contained in:
parent
a6efde40f8
commit
0e821e098f
77 changed files with 465 additions and 454 deletions
|
|
@ -1,14 +1,14 @@
|
|||
use crate::*;
|
||||
|
||||
pub struct Bordered<S: BorderStyle, W: Content<Tui>>(pub S, pub W);
|
||||
pub struct Bordered<S: BorderStyle, W: Content<TuiOut>>(pub S, pub W);
|
||||
|
||||
render!(Tui: (self: Bordered<S: BorderStyle, W: Content<Tui>>) => {
|
||||
render!(TuiOut: (self: Bordered<S: BorderStyle, W: Content<TuiOut>>) => {
|
||||
Fill::xy(lay!(Border(self.0), Padding::xy(1, 1, &self.1)))
|
||||
});
|
||||
|
||||
pub struct Border<S: BorderStyle>(pub S);
|
||||
|
||||
render!(Tui: |self: Border<S: BorderStyle>, to| {
|
||||
render!(TuiOut: |self: Border<S: BorderStyle>, to| {
|
||||
let area = to.area();
|
||||
if area.w() > 0 && area.y() > 0 {
|
||||
to.blit(&self.0.nw(), area.x(), area.y(), self.0.style());
|
||||
|
|
@ -27,13 +27,13 @@ render!(Tui: |self: Border<S: BorderStyle>, to| {
|
|||
});
|
||||
|
||||
pub trait BorderStyle: Send + Sync + Copy {
|
||||
fn wrap <W: Content<Tui>> (self, w: W) -> Bordered<Self, W> {
|
||||
fn wrap <W: Content<TuiOut>> (self, w: W) -> Bordered<Self, W> {
|
||||
Bordered(self, w)
|
||||
}
|
||||
fn enclose <W: Content<Tui>> (self, w: W) -> impl Content<Tui> {
|
||||
fn enclose <W: Content<TuiOut>> (self, w: W) -> impl Content<TuiOut> {
|
||||
lay!(Fill::xy(Border(self)), w)
|
||||
}
|
||||
fn enclose_bg <W: Content<Tui>> (self, w: W) -> impl Content<Tui> {
|
||||
fn enclose_bg <W: Content<TuiOut>> (self, w: W) -> impl Content<TuiOut> {
|
||||
Tui::bg(self.style().unwrap().bg.unwrap_or(Color::Reset), lay!(
|
||||
Fill::xy(Border(self)),
|
||||
w
|
||||
|
|
@ -137,7 +137,7 @@ macro_rules! border {
|
|||
}
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct $T(pub Style);
|
||||
impl Content<Tui> for $T {
|
||||
impl Content<TuiOut> for $T {
|
||||
fn render (&self, to: &mut TuiOut) { self.draw(to); }
|
||||
}
|
||||
)+}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue