Skip to content
Snippets Groups Projects
Commit cd5daf9e authored by Jens Nolte's avatar Jens Nolte
Browse files

Move BlockText to BlockOutput.hs

parent 9c22ec4f
No related branches found
No related tags found
No related merge requests found
module BlockOutput where
import qualified Data.Text.Lazy as T
newtype BlockText = BlockText [BlockTextSegment]
instance Semigroup BlockText where
(BlockText a) <> (BlockText b) = BlockText (a <> b)
instance Monoid BlockText where
mempty = BlockText []
data BlockTextSegment = BlockTextSegment {
active :: Bool,
importance :: Importance,
text :: T.Text
}
| PangoTextSegment T.Text
type Importance = Float
mkText :: Bool -> Importance -> T.Text -> BlockText
mkText active importance text = BlockText [BlockTextSegment { text, active, importance }]
activeImportantText :: Importance -> T.Text -> BlockText
activeImportantText = mkText True
importantText :: Importance -> T.Text -> BlockText
importantText = mkText False
activeText :: T.Text -> BlockText
activeText = mkText True 0
normalText :: T.Text -> BlockText
normalText = mkText False 0
pangoText :: T.Text -> BlockText
pangoText pango = BlockText [PangoTextSegment pango]
surroundWith :: (T.Text -> BlockText) -> T.Text -> T.Text -> BlockText -> BlockText
surroundWith format left right middle = (format left) <> middle <> (format right)
...@@ -85,38 +85,6 @@ data Bar = Bar { ...@@ -85,38 +85,6 @@ data Bar = Bar {
data BarUpdateChannel = BarUpdateChannel (IO ()) data BarUpdateChannel = BarUpdateChannel (IO ())
type BarUpdateEvent = Event.Event type BarUpdateEvent = Event.Event
newtype BlockText = BlockText [BlockTextSegment]
instance Semigroup BlockText where
(BlockText a) <> (BlockText b) = BlockText (a <> b)
instance Monoid BlockText where
mempty = BlockText []
data BlockTextSegment = BlockTextSegment {
active :: Bool,
importance :: Importance,
text :: T.Text
}
| PangoTextSegment T.Text
type Importance = Float
mkText :: Bool -> Importance -> T.Text -> BlockText
mkText active importance text = BlockText [BlockTextSegment { text, active, importance }]
activeImportantText :: Importance -> T.Text -> BlockText
activeImportantText = mkText True
importantText :: Importance -> T.Text -> BlockText
importantText = mkText False
activeText :: T.Text -> BlockText
activeText = mkText True 0
normalText :: T.Text -> BlockText
normalText = mkText False 0
pangoText :: T.Text -> BlockText
pangoText pango = BlockText [PangoTextSegment pango]
defaultColor :: T.Text defaultColor :: T.Text
defaultColor = "#969896" defaultColor = "#969896"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment