diff options
Diffstat (limited to 'src/Erebos/TextFormat.hs')
| -rw-r--r-- | src/Erebos/TextFormat.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Erebos/TextFormat.hs b/src/Erebos/TextFormat.hs index 20973d9..88fe0c2 100644 --- a/src/Erebos/TextFormat.hs +++ b/src/Erebos/TextFormat.hs @@ -2,6 +2,12 @@ module Erebos.TextFormat ( FormattedText, plainText, + TextStyle, + withStyle, noStyle, + + Color(..), + setForegroundColor, setBackgroundColor, + renderPlainText, formattedTextLength, ) where @@ -16,6 +22,19 @@ plainText :: Text -> FormattedText plainText = PlainText +withStyle :: TextStyle -> FormattedText -> FormattedText +withStyle = FormattedText + +noStyle :: TextStyle +noStyle = CustomTextColor Nothing Nothing + +setForegroundColor :: Color -> TextStyle -> TextStyle +setForegroundColor color (CustomTextColor _ bg) = CustomTextColor (Just color) bg + +setBackgroundColor :: Color -> TextStyle -> TextStyle +setBackgroundColor color (CustomTextColor fg _) = CustomTextColor fg (Just color) + + renderPlainText :: FormattedText -> Text renderPlainText = \case PlainText text -> text |