Safe Haskell | None |
---|---|
Language | Haskell2010 |
A mini-DSL for ASCII drawing of structures.
From some structures there is also Graphviz and/or diagrams
(http://projects.haskell.org/diagrams) visualization support
(the latter in the separate libray combinat-diagrams
).
- data ASCII = ASCII {
- asciiSize :: (Int, Int)
- asciiLines :: [String]
- emptyRect :: ASCII
- asciiXSize :: ASCII -> Int
- asciiYSize :: ASCII -> Int
- asciiString :: ASCII -> String
- printASCII :: ASCII -> IO ()
- asciiFromLines :: [String] -> ASCII
- asciiFromString :: String -> ASCII
- data HAlign
- data VAlign
- data Alignment = Align HAlign VAlign
- hExtendTo :: HAlign -> Int -> ASCII -> ASCII
- vExtendTo :: VAlign -> Int -> ASCII -> ASCII
- hExtendWith :: HAlign -> Int -> ASCII -> ASCII
- vExtendWith :: VAlign -> Int -> ASCII -> ASCII
- hIndent :: Int -> ASCII -> ASCII
- vIndent :: Int -> ASCII -> ASCII
- data HSep
- hSepSize :: HSep -> Int
- hSepString :: HSep -> String
- data VSep
- = VSepEmpty
- | VSepSpaces Int
- | VSepString [Char]
- vSepSize :: VSep -> Int
- vSepString :: VSep -> [Char]
- hPad :: Int -> ASCII -> ASCII
- vPad :: Int -> ASCII -> ASCII
- pad :: ASCII -> ASCII
- hCatWith :: VAlign -> HSep -> [ASCII] -> ASCII
- vCatWith :: HAlign -> VSep -> [ASCII] -> ASCII
- tabulate :: (HAlign, VAlign) -> (HSep, VSep) -> [[ASCII]] -> ASCII
- data MatrixOrder
- autoTabulate :: MatrixOrder -> Either Int Int -> [ASCII] -> ASCII
- caption :: String -> ASCII -> ASCII
- caption' :: Bool -> HAlign -> String -> ASCII -> ASCII
- asciiBox :: (Int, Int) -> ASCII
- roundedAsciiBox :: (Int, Int) -> ASCII
- asciiNumber :: Int -> ASCII
- asciiShow :: Show a => a -> ASCII
The basic type
The type of a (rectangular) ASCII figure. Internally it is a list of lines of the same length plus the size.
Note: The Show instance is pretty-printing, so that it's convenient in ghci.
asciiXSize :: ASCII -> Int Source
asciiYSize :: ASCII -> Int Source
asciiString :: ASCII -> String Source
printASCII :: ASCII -> IO () Source
asciiFromLines :: [String] -> ASCII Source
asciiFromString :: String -> ASCII Source
Alignment
Extension
hExtendTo :: HAlign -> Int -> ASCII -> ASCII Source
Extends an ASCII figure with spaces horizontally to the given width
vExtendTo :: VAlign -> Int -> ASCII -> ASCII Source
Extends an ASCII figure with spaces vertically to the given height
hExtendWith :: HAlign -> Int -> ASCII -> ASCII Source
Extend horizontally with the given number of spaces
vExtendWith :: VAlign -> Int -> ASCII -> ASCII Source
Extend vertically with the given number of empty lines
Separators
Horizontal separator
HSepEmpty | empty separator |
HSepSpaces Int |
|
HSepString String | some custom string, eg. |
hSepString :: HSep -> String Source
Vertical separator
VSepEmpty | empty separator |
VSepSpaces Int |
|
VSepString [Char] | some custom list of characters, eg. |
vSepString :: VSep -> [Char] Source
Padding
hPad :: Int -> ASCII -> ASCII Source
Horizontally pads with the given number of spaces, on both sides
vPad :: Int -> ASCII -> ASCII Source
Vertically pads with the given number of empty lines, on both sides
Concatenation
Tabulate
data MatrixOrder Source
Order of elements in a matrix
:: MatrixOrder | whether to use row-major or column-major ordering of the elements |
-> Either Int Int |
|
-> [ASCII] | list of ASCII rectangles |
-> ASCII |
Automatically tabulates ASCII rectangles.
Captions
caption' :: Bool -> HAlign -> String -> ASCII -> ASCII Source
Adds a caption to the bottom. The Bool
flag specifies whether to add an empty between
the caption and the figure
Testing / miscellanea
roundedAsciiBox :: (Int, Int) -> ASCII Source
An "rounded" ASCII box of the given size
asciiNumber :: Int -> ASCII Source