box

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ASCII = NewBox(
		"+--+\n"+
			"| ||\n"+
			"|-+|\n"+
			"| ||\n"+
			"|-+|\n"+
			"|-+|\n"+
			"| ||\n"+
			"+--+\n",
		true,
	)

	ASCII2 = NewBox(
		"+-++\n"+
			"| ||\n"+
			"+-++\n"+
			"| ||\n"+
			"+-++\n"+
			"+-++\n"+
			"| ||\n"+
			"+-++\n",
		true,
	)

	ASCII_DOUBLE_HEAD = NewBox(
		"+-++\n"+
			"| ||\n"+
			"+=++\n"+
			"| ||\n"+
			"+-++\n"+
			"+-++\n"+
			"| ||\n"+
			"+-++\n",
		true,
	)

	SQUARE = NewBox(
		"┌─┬┐\n"+
			"│ ││\n"+
			"├─┼┤\n"+
			"│ ││\n"+
			"├─┼┤\n"+
			"├─┼┤\n"+
			"│ ││\n"+
			"└─┴┘\n",
		false,
	)

	SQUARE_DOUBLE_HEAD = NewBox(
		"┌─┬┐\n"+
			"│ ││\n"+
			"╞═╪╡\n"+
			"│ ││\n"+
			"├─┼┤\n"+
			"├─┼┤\n"+
			"│ ││\n"+
			"└─┴┘\n",
		false,
	)

	MINIMAL = NewBox(
		"  ╷ \n"+
			"  │ \n"+
			"╶─┼╴\n"+
			"  │ \n"+
			"╶─┼╴\n"+
			"╶─┼╴\n"+
			"  │ \n"+
			"  ╵ \n",
		false,
	)

	MINIMAL_HEAVY_HEAD = NewBox(
		"  ╷ \n"+
			"  │ \n"+
			"╺━┿╸\n"+
			"  │ \n"+
			"╶─┼╴\n"+
			"╶─┼╴\n"+
			"  │ \n"+
			"  ╵ \n",
		false,
	)

	MINIMAL_DOUBLE_HEAD = NewBox(
		"  ╷ \n"+
			"  │ \n"+
			" ═╪ \n"+
			"  │ \n"+
			" ─┼ \n"+
			" ─┼ \n"+
			"  │ \n"+
			"  ╵ \n",
		false,
	)

	SIMPLE = NewBox(
		"    \n"+
			"    \n"+
			" ── \n"+
			"    \n"+
			"    \n"+
			" ── \n"+
			"    \n"+
			"    \n",
		false,
	)

	SIMPLE_HEAD = NewBox(
		"    \n"+
			"    \n"+
			" ── \n"+
			"    \n"+
			"    \n"+
			"    \n"+
			"    \n"+
			"    \n",
		false,
	)

	SIMPLE_HEAVY = NewBox(
		"    \n"+
			"    \n"+
			" ━━ \n"+
			"    \n"+
			"    \n"+
			" ━━ \n"+
			"    \n"+
			"    \n",
		false,
	)

	HORIZONTALS = NewBox(
		" ── \n"+
			"    \n"+
			" ── \n"+
			"    \n"+
			" ── \n"+
			" ── \n"+
			"    \n"+
			" ── \n",
		false,
	)

	ROUNDED = NewBox(
		"╭─┬╮\n"+
			"│ ││\n"+
			"├─┼┤\n"+
			"│ ││\n"+
			"├─┼┤\n"+
			"├─┼┤\n"+
			"│ ││\n"+
			"╰─┴╯\n",
		false,
	)

	HEAVY = NewBox(
		"┏━┳┓\n"+
			"┃ ┃┃\n"+
			"┣━╋┫\n"+
			"┃ ┃┃\n"+
			"┣━╋┫\n"+
			"┣━╋┫\n"+
			"┃ ┃┃\n"+
			"┗━┻┛\n",
		false,
	)

	HEAVY_EDGE = NewBox(
		"┏━┯┓\n"+
			"┃ │┃\n"+
			"┠─┼┨\n"+
			"┃ │┃\n"+
			"┠─┼┨\n"+
			"┠─┼┨\n"+
			"┃ │┃\n"+
			"┗━┷┛\n",
		false,
	)

	HEAVY_HEAD = NewBox(
		"┏━┳┓\n"+
			"┃ ┃┃\n"+
			"┡━╇┩\n"+
			"│ ││\n"+
			"├─┼┤\n"+
			"├─┼┤\n"+
			"│ ││\n"+
			"└─┴┘\n",
		false,
	)

	DOUBLE = NewBox(
		"╔═╦╗\n"+
			"║ ║║\n"+
			"╠═╬╣\n"+
			"║ ║║\n"+
			"╠═╬╣\n"+
			"╠═╬╣\n"+
			"║ ║║\n"+
			"╚═╩╝\n",
		false,
	)

	DOUBLE_EDGE = NewBox(
		"╔═╤╗\n"+
			"║ │║\n"+
			"╟─┼╢\n"+
			"║ │║\n"+
			"╟─┼╢\n"+
			"╟─┼╢\n"+
			"║ │║\n"+
			"╚═╧╝\n",
		false,
	)

	MARKDOWN = NewBox(
		"    \n"+
			"| ||\n"+
			"|-||\n"+
			"| ||\n"+
			"|-||\n"+
			"|-||\n"+
			"| ||\n"+
			"    \n",
		true,
	)
)

Functions

This section is empty.

Types

type Box

type Box struct {
	// contains filtered or unexported fields
}

Box defines characters for drawing table borders.

The layout uses 8 lines of 4 characters each:

┌─┬┐  top
│ ││  head
├─┼┤  head_row
│ ││  mid
├─┼┤  row
├─┼┤  foot_row
│ ││  foot
└─┴┘  bottom

func NewBox

func NewBox(raw string, ascii bool) *Box

NewBox creates a Box from an 8-line string of box characters.

func (*Box) FootLeft

func (b *Box) FootLeft() rune

FootLeft returns the left edge character for the footer row.

func (*Box) FootRight

func (b *Box) FootRight() rune

FootRight returns the right edge character for the footer row.

func (*Box) FootVertical

func (b *Box) FootVertical() rune

FootVertical returns the vertical divider character for the footer row.

func (*Box) GetBottom

func (b *Box) GetBottom(widths []int) string

GetBottom builds the bottom border line string for the given column widths.

func (*Box) GetPlainHeadedBox

func (b *Box) GetPlainHeadedBox() *Box

GetPlainHeadedBox returns an equivalent box without special header characters.

func (*Box) GetRow

func (b *Box) GetRow(widths []int, level string) string

GetRow builds a horizontal divider line for the given column widths. level must be one of "head", "row", "foot", or "mid".

func (*Box) GetTop

func (b *Box) GetTop(widths []int) string

GetTop builds the top border line string for the given column widths.

func (*Box) HeadLeft

func (b *Box) HeadLeft() rune

HeadLeft returns the left edge character for the header row.

func (*Box) HeadRight

func (b *Box) HeadRight() rune

HeadRight returns the right edge character for the header row.

func (*Box) HeadRowCross

func (b *Box) HeadRowCross() rune

HeadRowCross returns the cross character for a head row divider.

func (*Box) HeadRowH

func (b *Box) HeadRowH() rune

HeadRowH returns the horizontal character for a head row divider.

func (*Box) HeadRowLeft

func (b *Box) HeadRowLeft() rune

HeadRowLeft returns the left edge character for a head row divider.

func (*Box) HeadRowRight

func (b *Box) HeadRowRight() rune

HeadRowRight returns the right edge character for a head row divider.

func (*Box) HeadVertical

func (b *Box) HeadVertical() rune

HeadVertical returns the vertical divider character for the header row.

func (*Box) MidLeft

func (b *Box) MidLeft() rune

MidLeft returns the left edge character for a mid (data) row.

func (*Box) MidRight

func (b *Box) MidRight() rune

MidRight returns the right edge character for a mid (data) row.

func (*Box) MidVertical

func (b *Box) MidVertical() rune

MidVertical returns the vertical divider character for mid (data) rows.

func (*Box) NoEdge

func (b *Box) NoEdge() *Box

NoEdge returns a Box with outer edges replaced by spaces.

func (*Box) String

func (b *Box) String() string

String returns the raw box definition.

func (*Box) Substitute

func (b *Box) Substitute(opts console.Options) *Box

Substitute returns a different Box if platform constraints prevent this one from rendering. Currently only checks for ASCII-only terminals.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL