tall corners

This commit is contained in:
🪞👃🪞 2024-09-15 19:08:26 +03:00
parent 2733b6b947
commit 2073bb541d
3 changed files with 144 additions and 182 deletions

View file

@ -447,7 +447,7 @@ pub struct Border<S: BorderStyle>(pub S);
impl<S: BorderStyle> Widget for Border<S> {
type Engine = Tui;
fn layout (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
Outset::XY(1, 1, "").layout(to)
Ok(Some([0, 0]))
}
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
let area = to.area();
@ -577,7 +577,7 @@ pub trait BorderStyle: Send + Sync {
}
macro_rules! border {
($($T:ty {
($($T:ident {
$nw:literal $n:literal $ne:literal $w:literal $e:literal $sw:literal $s:literal $se:literal
$($x:tt)*
}),+) => {$(
@ -592,10 +592,11 @@ macro_rules! border {
const SE: &'static str = $se;
$($x)*
}
pub struct $T(pub Style);
impl Widget for $T {
type Engine = Tui;
fn layout (&self, area: [u16;2]) -> Perhaps<[u16;2]> {
Ok(Some(area))
fn layout (&self, _: [u16;2]) -> Perhaps<[u16;2]> {
Ok(Some([0,0]))
}
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
self.draw(to)
@ -604,97 +605,72 @@ macro_rules! border {
)+}
}
pub struct Square(pub Style);
pub struct SquareBold(pub Style);
pub struct Tab(pub Style);
pub struct Lozenge(pub Style);
pub struct Brace(pub Style);
pub struct LozengeDotted(pub Style);
pub struct Quarter(pub Style);
pub struct QuarterV(pub Style);
pub struct Chamfer(pub Style);
pub struct Corners(pub Style);
border! {
Square {
"┌" "─" "┐"
"│" "│"
"└" "─" "┘"
fn style (&self) -> Option<Style> {
Some(self.0)
}
fn style (&self) -> Option<Style> { Some(self.0) }
},
SquareBold {
"┏" "━" "┓"
"┃" "┃"
"┗" "━" "┛"
fn style (&self) -> Option<Style> {
Some(self.0)
}
fn style (&self) -> Option<Style> { Some(self.0) }
},
Tab {
"╭" "─" "╮"
"│" "│"
"│" " " "│"
fn style (&self) -> Option<Style> {
Some(self.0)
}
fn style (&self) -> Option<Style> { Some(self.0) }
},
Lozenge {
"╭" "─" "╮"
"│" "│"
"╰" "─" "╯"
fn style (&self) -> Option<Style> {
Some(self.0)
}
fn style (&self) -> Option<Style> { Some(self.0) }
},
Brace {
"╭" "" "╮"
"│" "│"
"╰" "" "╯"
fn style (&self) -> Option<Style> {
Some(self.0)
}
fn style (&self) -> Option<Style> { Some(self.0) }
},
LozengeDotted {
"╭" "┅" "╮"
"┇" "┇"
"╰" "┅" "╯"
fn style (&self) -> Option<Style> {
Some(self.0)
}
fn style (&self) -> Option<Style> { Some(self.0) }
},
Quarter {
"▎" "▔" "🮇"
"▎" "🮇"
"▎" "▁" "🮇"
fn style (&self) -> Option<Style> {
Some(self.0)
}
fn style (&self) -> Option<Style> { Some(self.0) }
},
QuarterV {
"▎" "" "🮇"
"▎" "🮇"
"▎" "" "🮇"
fn style (&self) -> Option<Style> {
Some(self.0)
}
fn style (&self) -> Option<Style> { Some(self.0) }
},
Chamfer {
"🭂" "▔" "🭍"
"▎" "🮇"
"🭓" "▁" "🭞"
fn style (&self) -> Option<Style> {
Some(self.0)
}
fn style (&self) -> Option<Style> { Some(self.0) }
},
Corners {
"🬆" "" "🬊" // 🬴 🬸
"" ""
"🬱" "" "🬵"
fn style (&self) -> Option<Style> {
Some(self.0)
}
fn style (&self) -> Option<Style> { Some(self.0) }
},
CornersTall {
"🭽" "" "🭾"
"" ""
"🭼" "" "🭿"
fn style (&self) -> Option<Style> { Some(self.0) }
}
}