summaryrefslogtreecommitdiffhomepage
path: root/Plugins
diff options
context:
space:
mode:
authornzeh <nzeh@cs.dal.ca>2009-03-18 23:51:52 +0100
committernzeh <nzeh@cs.dal.ca>2009-03-18 23:51:52 +0100
commit691f97181129642b5a1bd4d2e347afb182db90a5 (patch)
tree7996ccf87e8cc519330411da506a600dce6d6daa /Plugins
parent0001a568f9210a141db63113ad04386598bdba4b (diff)
downloadxmobar-691f97181129642b5a1bd4d2e347afb182db90a5.tar.gz
xmobar-691f97181129642b5a1bd4d2e347afb182db90a5.tar.bz2
Allow color markup in monitor output templates
With this patch, colors can be included in the output template of a monitor. E.g., ["-t", "TX <fc darcs-hash:20090318225152-c6b6b-54a807a7f88612b89fdbf7e0ba5ecc0336a5cfa1.gz
Diffstat (limited to 'Plugins')
-rw-r--r--Plugins/Monitors/Common.hs25
1 files changed, 18 insertions, 7 deletions
diff --git a/Plugins/Monitors/Common.hs b/Plugins/Monitors/Common.hs
index 03b40d8..1b5cb60 100644
--- a/Plugins/Monitors/Common.hs
+++ b/Plugins/Monitors/Common.hs
@@ -196,19 +196,30 @@ skipTillString s =
-- | Parses the output template string
templateStringParser :: Parser (String,String,String)
templateStringParser =
- do{ s <- many $ noneOf "<"
- ; (_,com,_) <- templateCommandParser
- ; ss <- many $ noneOf "<"
- ; return (s, com, ss)
- }
+ do { s <- nonPlaceHolder
+ ; com <- templateCommandParser
+ ; ss <- nonPlaceHolder
+ ; return (s, com, ss)
+ }
+ where
+ nonPlaceHolder = liftM concat . many $
+ (many1 $ noneOf "<") <|> colorSpec
+
+-- | Recognizes color specification and returns it unchanged
+colorSpec :: Parser String
+colorSpec = (try $ string "</fc>") <|> try (
+ do string "<fc="
+ s <- many1 (alphaNum <|> char ',' <|> char '#')
+ char '>'
+ return $ "<fc=" ++ s ++ ">")
-- | Parses the command part of the template string
-templateCommandParser :: Parser (String,String,String)
+templateCommandParser :: Parser String
templateCommandParser =
do { char '<'
; com <- many $ noneOf ">"
; char '>'
- ; return $ ("",com,"")
+ ; return com
}
-- | Combines the template parsers