From 9ee8b6e19f5578a85faf965239f45fb4056fbe8d Mon Sep 17 00:00:00 2001 From: Victor/Alyx Bersy Date: Thu, 27 Oct 2022 21:02:57 +0200 Subject: [PATCH] feat: add `BlockBorder`, `OuterHalfBlockBorder`, and `InnerHalfBlockBorder` border styles (#120) --- borders.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ set.go | 5 +++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/borders.go b/borders.go index a3284ac..2337280 100644 --- a/borders.go +++ b/borders.go @@ -84,6 +84,39 @@ var ( BottomRight: "╯", } + blockBorder = Border{ + Top: "█", + Bottom: "█", + Left: "█", + Right: "█", + TopLeft: "█", + TopRight: "█", + BottomLeft: "█", + BottomRight: "█", + } + + outerHalfBlockBorder = Border{ + Top: "▀", + Bottom: "▄", + Left: "▌", + Right: "▐", + TopLeft: "▛", + TopRight: "▜", + BottomLeft: "▙", + BottomRight: "▟", + } + + innerHalfBlockBorder = Border{ + Top: "▄", + Bottom: "▀", + Left: "▐", + Right: "▌", + TopLeft: "▗", + TopRight: "▖", + BottomLeft: "▝", + BottomRight: "▘", + } + thickBorder = Border{ Top: "━", Bottom: "━", @@ -129,6 +162,21 @@ func RoundedBorder() Border { return roundedBorder } +// BlockBorder returns a border that takes the whole block. +func BlockBorder() Border { + return blockBorder +} + +// OuterHalfBlockBorder returns a half-block border that sits outside the frame. +func OuterHalfBlockBorder() Border { + return outerHalfBlockBorder +} + +// InnerHalfBlockBorder returns a half-block border that sits inside the frame. +func InnerHalfBlockBorder() Border { + return innerHalfBlockBorder +} + // ThickBorder returns a border that's thicker than the one returned by // NormalBorder. func ThickBorder() Border { diff --git a/set.go b/set.go index 4fa9c3b..21a9ce4 100644 --- a/set.go +++ b/set.go @@ -300,8 +300,9 @@ func (s Style) Border(b Border, sides ...bool) Style { // the border style, the border will be enabled for all sides during rendering. // // You can define border characters as you'd like, though several default -// styles are included: NormalBorder(), RoundedBorder(), ThickBorder(), and -// DoubleBorder(). +// styles are included: NormalBorder(), RoundedBorder(), BlockBorder(), +// OuterHalfBlockBorder(), InnerHalfBlockBorder(), ThickBorder(), +// and DoubleBorder(). // // Example: //