diff options
Diffstat (limited to 'src/Xmobar/X11/Parsers.hs')
-rw-r--r-- | src/Xmobar/X11/Parsers.hs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/Xmobar/X11/Parsers.hs b/src/Xmobar/X11/Parsers.hs index d35cfa0..513f63b 100644 --- a/src/Xmobar/X11/Parsers.hs +++ b/src/Xmobar/X11/Parsers.hs @@ -28,11 +28,11 @@ import Text.Read (readMaybe) import Graphics.X11.Types (Button) import Foreign.C.Types (CInt) -data Widget = Icon String | Text String +data Widget = Icon String | Text String | Hspace Int32 deriving Show -data BoxOffset = BoxOffset Align Int32 deriving Eq +data BoxOffset = BoxOffset Align Int32 deriving (Eq, Show) -- margins: Top, Right, Bottom, Left -data BoxMargins = BoxMargins Int32 Int32 Int32 Int32 deriving Eq +data BoxMargins = BoxMargins Int32 Int32 Int32 Int32 deriving (Eq, Show) data BoxBorder = BBTop | BBBottom | BBVBoth @@ -40,14 +40,14 @@ data BoxBorder = BBTop | BBRight | BBHBoth | BBFull - deriving ( Read, Eq ) -data Box = Box BoxBorder BoxOffset CInt String BoxMargins deriving Eq + deriving ( Read, Eq, Show ) +data Box = Box BoxBorder BoxOffset CInt String BoxMargins deriving (Eq, Show) data TextRenderInfo = TextRenderInfo { tColorsString :: String , tBgTopOffset :: Int32 , tBgBottomOffset :: Int32 , tBoxes :: [Box] - } + } deriving Show type FontIndex = Int -- | Runs the string parser @@ -68,6 +68,7 @@ allParsers :: TextRenderInfo -> Parser [(Widget, TextRenderInfo, FontIndex, Maybe [Action])] allParsers c f a = textParser c f a <|> try (iconParser c f a) + <|> try (hspaceParser c f a) <|> try (rawParser c f a) <|> try (actionParser c f a) <|> try (fontParser c a) @@ -91,6 +92,7 @@ textParser c f a = do s <- many1 $ try (string "action=") <|> try (string "/action>") <|> try (string "icon=") <|> + try (string "hspace=") <|> try (string "raw=") <|> try (string "/fn>") <|> try (string "/box>") <|> @@ -133,6 +135,13 @@ iconParser c f a = do i <- manyTill (noneOf ">") (try (string "/>")) return [(Icon i, c, f, a)] +hspaceParser :: TextRenderInfo -> FontIndex -> Maybe [Action] + -> Parser [(Widget, TextRenderInfo, FontIndex, Maybe [Action])] +hspaceParser c f a = do + string "<hspace=" + pVal <- manyTill digit (try (string "/>")) + return [(Hspace (fromMaybe 0 $ readMaybe pVal), c, f, a)] + actionParser :: TextRenderInfo -> FontIndex -> Maybe [Action] -> Parser [(Widget, TextRenderInfo, FontIndex, Maybe [Action])] actionParser c f act = do |