struct TermBuf::Border

Overview

A box drawn around something, with an optional title in its top edge.

It lives at the widget layer root rather than inside Field because anything else drawn in a box wants the same thing.

Defined in:

termbuf/widgets/border.cr

Constant Summary

ASCII = Glyphs.new('+', '-', '+', '|', '|', '+', '-', '+')

For a terminal whose font has no box drawing, and for a screen someone is going to copy out of.

DOUBLE = Glyphs.new('╔', '═', '╗', '║', '║', '╚', '═', '╝')
HEAVY = Glyphs.new('┏', '━', '┓', '┃', '┃', '┗', '━', '┛')
PADDING = 2

Rows and columns a border adds to whatever it surrounds.

PLAIN = Glyphs.new('┌', '─', '┐', '│', '│', '└', '─', '┘')
ROUNDED = Glyphs.new('╭', '─', '╮', '│', '│', '╰', '─', '╯')

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.ascii(style : Style = Style::DEFAULT, title : String | Nil = nil, title_style : Style = Style::DEFAULT) : Border #

A ascii border.


[View source]
def self.double(style : Style = Style::DEFAULT, title : String | Nil = nil, title_style : Style = Style::DEFAULT) : Border #

A double border.


[View source]
def self.heavy(style : Style = Style::DEFAULT, title : String | Nil = nil, title_style : Style = Style::DEFAULT) : Border #

A heavy border.


[View source]
def self.new(glyphs : Glyphs = PLAIN, style : Style = Style::DEFAULT, title : String | Nil = nil, title_style : Style = Style::DEFAULT) #

[View source]
def self.plain(style : Style = Style::DEFAULT, title : String | Nil = nil, title_style : Style = Style::DEFAULT) : Border #

A plain border.


[View source]
def self.rounded(style : Style = Style::DEFAULT, title : String | Nil = nil, title_style : Style = Style::DEFAULT) : Border #

A rounded border.


[View source]

Class Method Detail

def self.inset(rect : Rect) : Rect #

The area inside the box. Empty when rect has no room for one.


[View source]

Instance Method Detail

def draw(screen : Drawing, rect : Rect) : Nil #

Draws the box around the edge of rect.

The last cell written is the bottom right corner, which on a terminal that scrolls rather than holding the wrap would take the top edge with it. The painter turns wrapping off for the duration of a frame, so it does not.


[View source]
def glyphs : Glyphs #

Which characters the box is drawn with.


[View source]
def inset(rect : Rect) : Rect #

The area inside the box. Empty when rect has no room for one.


[View source]
def style : Style #

What the box itself is drawn in.


[View source]
def title : String | Nil #

Shown in the top edge, trimmed to fit. nil for none.


[View source]
def title_style : Style #

What the title is drawn in, which is often not what the box is.


[View source]
def with_title(title : String | Nil) : Border #

A copy carrying a different title.


[View source]