License | MIT-style (see LICENSE) |
---|---|
Stability | provisional |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Parser and definition of the dzen2-inspired formatting language used by Sindre. A format string is a sequence of commands changing drawing option parameters, and things to draw.
Synopsis
- data Format
- type FormatString = [Format]
- textContents :: FormatString -> Text
- startBg :: FormatString -> Maybe String
- parseFormatString :: Text -> Either String FormatString
- unparseFormatString :: FormatString -> Text
Documentation
A formatting command is either a change to the drawing state, or a string to be printed at the current location.
Fg String | Draw text in the given colour. |
DefFg | Draw text in the default colour. |
Bg String | Draw the background in the given colour. |
DefBg | Draw the background in the default colour. |
Text Text | Draw the given string. |
type FormatString = [Format] Source #
A list of formatting commands, interpreted left-to-right.
textContents :: FormatString -> Text Source #
The human-readable part of a format string, with formatting directives stripped.
startBg :: FormatString -> Maybe String Source #
The first background colour preceding any default background colour or text entry specified in the format string, if any.
parseFormatString :: Text -> Either String FormatString Source #
Parse a format string, returning either an error message or the result of the parse.
unparseFormatString :: FormatString -> Text Source #
Prettyprint a FormatString
to a string that, when parsed by
parseFormatString
, results in the original FormatString