Graphics.Vty.Widgets.Text
Description
- data FormattedText
- plainText :: String -> IO (Widget FormattedText)
- plainTextWithAttrs :: [(String, Attr)] -> IO (Widget FormattedText)
- textWidget :: Formatter -> String -> IO (Widget FormattedText)
- setText :: Widget FormattedText -> String -> IO ()
- setTextWithAttrs :: Widget FormattedText -> [(String, Attr)] -> IO ()
- setTextFormatter :: Widget FormattedText -> Formatter -> IO ()
- setTextAppearFocused :: Widget FormattedText -> Bool -> IO ()
- newtype Formatter = Formatter (DisplayRegion -> TextStream Attr -> IO (TextStream Attr))
- applyFormatter :: Formatter -> DisplayRegion -> TextStream Attr -> IO (TextStream Attr)
- getTextFormatter :: Widget FormattedText -> IO Formatter
- nullFormatter :: Formatter
- wrap :: Formatter
Documentation
data FormattedText Source
The type of formatted text widget state. Stores the text itself and the formatter used to apply attributes to the text.
Instances
Constructing Text Widgets
plainText :: String -> IO (Widget FormattedText)Source
Construct a Widget directly from a String. This is recommended if
you don't need to use a Formatter
.
plainTextWithAttrs :: [(String, Attr)] -> IO (Widget FormattedText)Source
Construct a Widget directly from a list of strings and their attributes.
textWidget :: Formatter -> String -> IO (Widget FormattedText)Source
Construct a text widget formatted with the specified formatters and initial content. The formatters will be applied in the order given here (and, depending on the formatter, order might matter).
Setting Widget Contents
setText :: Widget FormattedText -> String -> IO ()Source
Set the text value of a FormattedText
widget. The specified
string will be tokenize
d.
setTextWithAttrs :: Widget FormattedText -> [(String, Attr)] -> IO ()Source
Set the text value of a FormattedText
widget directly, in case
you have done formatting elsewhere and already have text with
attributes. The specified strings will each be tokenize
d, and
tokens resulting from each tokenize
operation will be given the
specified attribute in the tuple.
setTextFormatter :: Widget FormattedText -> Formatter -> IO ()Source
Set the formatter for the text.
setTextAppearFocused :: Widget FormattedText -> Bool -> IO ()Source
Set whether a text widget can appear focused by using the context-specific focus attribute when the widget has the focus. This setting defaults to False; some widgets which embed text widgets may need to turn this on.
Formatting
A formatter makes changes to text at rendering time. 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 DisplayRegion
which indicates the size
of screen area available for formatting.
Constructors
Formatter (DisplayRegion -> TextStream Attr -> IO (TextStream Attr)) |
applyFormatter :: Formatter -> DisplayRegion -> TextStream Attr -> IO (TextStream Attr)Source
getTextFormatter :: Widget FormattedText -> IO FormatterSource
Get the formatter for the text.
nullFormatter :: FormatterSource
The null formatter which has no effect on text streams.