Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This module allows you to add colors to another style for Hable configuration.
To add a single color to the whole table, it's the most simple to use
colored8Config
.
If you'd like to color vertical lines independently from horizontal lines, use
colored8Charset
and don't forget to compose Colored8
to the hLineStyle
and vLineStyle
properties of your config appropriately.
If you'd like to decide yourself how to act at the points of the table where
vertical and horizontal lines are cutting across, use genColored8charset
.
- data Color8
- data Colored8 style = Colored8 {
- foreground :: Maybe Color8
- background :: Maybe Color8
- colored8Style :: style
- colored8Config :: Maybe Color8 -> Maybe Color8 -> Config style -> Config (Colored8 style)
- colored8Charset :: (BoxChar style -> String) -> BoxChar (Colored8 style) -> String
- genColored8Charset :: (HAxis -> Colored8 style -> VAxis -> Colored8 style -> (Maybe Color8, Maybe Color8)) -> (BoxChar style -> String) -> BoxChar (Colored8 style) -> String
- color8String :: Maybe Color8 -> Maybe Color8 -> String -> String
Documentation
Represents the eight colors supported by most terminal emulators through ANSI escape codes.
A wrapper for any other style, adding an option of a fore- as well as a
background color to it. For the color fields, Nothing
represents an
unchanged/unmodified/unset color.
Colored8 | |
|
colored8Charset :: (BoxChar style -> String) -> BoxChar (Colored8 style) -> String Source #
Given a charset
, returns another new one which supports colors through a
Colored8
style.
An example which circles the colors of the horizontal lines using mod
>>> putStr (hable defaultConfig { charset = colored8Charset (charset defaultConfig), vLineStyle = _ _ -> Nothing, hLineStyle = m n -> fmap (Colored8 (Just (toEnum (fromInteger ((n mod
6) + 1)))) Nothing) $ vLineStyle defaultConfig m n } exampleTable)
Unfortunately, you wouldn't see the colors here, so there's a picture:
genColored8Charset :: (HAxis -> Colored8 style -> VAxis -> Colored8 style -> (Maybe Color8, Maybe Color8)) -> (BoxChar style -> String) -> BoxChar (Colored8 style) -> String Source #
A generalization of colored8Charset
. Instead of simply using choosing the
vertical color components for Angled
box characters, you can pass your own
function to decide which color to choose in this case. E.g. you could write a
function which uses a completely different color.
All in all, the first argument of genColored8charset
is a function. Its
arguments are the same as the arguments of the Angled
constructor.