char-boxdrawing-1: Combinators for unicode or ASCII box drawing characters
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Char.BoxDrawing

Synopsis

Box border type

data Drawing Source #

A box border which can be rendered to a terminal given a BoxDrawingStyle

Use the Monoid and Semigroup instances to combine box borders.

The internal representation is just a Word8; the least-significant four bits specify the base directions of the box drawing (up, down, left, or right), and the most-significant four bits specify the style (see rounded, dashed2, etc) which has its own special logic for how styles can be combined.

Instances

Instances details
Monoid Drawing Source # 
Instance details

Defined in Data.Char.BoxDrawing

Semigroup Drawing Source # 
Instance details

Defined in Data.Char.BoxDrawing

Eq Drawing Source # 
Instance details

Defined in Data.Char.BoxDrawing

Methods

(==) :: Drawing -> Drawing -> Bool #

(/=) :: Drawing -> Drawing -> Bool #

Ord Drawing Source # 
Instance details

Defined in Data.Char.BoxDrawing

render :: BoxDrawingStyle -> Drawing -> Char Source #

Render a Drawing given the style

lookup :: BoxDrawingStyle -> Char -> Maybe Drawing Source #

Lookup a character given the style

read :: BoxDrawingStyle -> Char -> Drawing Source #

Given a box drawing style and a character, determine what Drawing the character is. On error, returns an empty Drawing

overlay :: BoxDrawingStyle -> Drawing -> Char -> Char Source #

Get the character that best represents visually overlaying the given box drawing and a character.

Box drawing styles

data BoxDrawingStyle Source #

A border style such as ASCII or unicode. Describes how to turn a Drawing into an actual character for rendering, or to lookup a character from a buffer into a Drawing for combining different border characters

ascii :: BoxDrawingStyle Source #

A basic box-drawing style that uses |, +, and -

unicode :: BoxDrawingStyle Source #

An advanced box-drawing style that supports all the drawing primitives provided in this module

Drawings

Base primitives

Use the Semigroup instance to combine box Drawing.

Combinations

These are pre-made combinations of up, down, left, and right.

Box drawing modifiers

Combine these using the Semigroup instance with another Drawing to set its style, such as heavy, dashed, etc. - only relevant for the style unicode and has no effect for the style ascii.