- data Text
- data FormattedText
- type Formatter = DisplayRegion -> Text -> Text
- setText :: MonadIO m => Widget FormattedText -> String -> m ()
- prepareText :: String -> Text
- plainText :: MonadIO m => String -> m (Widget FormattedText)
- textWidget :: MonadIO m => Formatter -> String -> m (Widget FormattedText)
- (&.&) :: Formatter -> Formatter -> Formatter
- highlight :: Regex -> Attr -> Formatter
- nullFormatter :: Formatter
- wrap :: Formatter
Documentation
type Formatter = DisplayRegion -> Text -> TextSource
A formatter makes changes to text at rendering time.
It'd be nice if formatters were just ::
, but
some formatting use cases involve knowing the size of the rendering
area, which is not known until render time (e.g., text wrapping).
Thus, a formatter takes a Text
-> Text
DisplayRegion
and runs at render time.
setText :: MonadIO m => Widget FormattedText -> String -> m ()Source
Set the text value of a FormattedText
widget.
prepareText :: String -> TextSource
Prepare a string for rendering.
Constructing Widgets
plainText :: MonadIO m => String -> m (Widget FormattedText)Source
Construct a Widget directly from a String. This is recommended if
you don't need to use a Formatter
.
textWidget :: MonadIO m => Formatter -> String -> m (Widget FormattedText)Source
Construct a text widget formatted with the specified formatters. the formatters will be applied in the order given here, so be aware of how the formatters will modify the text (and affect each other).
Formatting
(&.&) :: Formatter -> Formatter -> FormatterSource
Formatter composition: a &.& b
applies a
followed by b
.