diff options
author | Krzysztof Kosciuszkiewicz <k.kosciuszkiewicz@gmail.com> | 2007-07-06 03:01:24 +0200 |
---|---|---|
committer | Krzysztof Kosciuszkiewicz <k.kosciuszkiewicz@gmail.com> | 2007-07-06 03:01:24 +0200 |
commit | 9192f3664b07b161a1c4120e889e37100824b16a (patch) | |
tree | b0850681735f143f480d5a7a9f1e161757d7ab01 | |
parent | 0b11566a389e54b4c5d891def5641a1dad7098a5 (diff) | |
download | xmobar-9192f3664b07b161a1c4120e889e37100824b16a.tar.gz xmobar-9192f3664b07b161a1c4120e889e37100824b16a.tar.bz2 |
Add support for named colors.
If bad color name is specified then exception is thrown by Xlib.
This should be probably handled in a more elegant way.
darcs-hash:20070706010124-ba08c-86d9d978d9f86348f552a1e2ebbdec18b21ff271.gz
-rw-r--r-- | Parsers.hs | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -59,15 +59,24 @@ defaultColors config = -- | Parses a string with a color set colorsAndText :: Config -> Parser (String, String) colorsAndText config = - do { string "<fc=#" - ; n <- count 6 hexDigit + do { string "<fc=" + ; c <- colorSpec ; string ">" ; s <- many $ noneOf "<" ; string "</fc>" - ; return (s,"#"++n) + ; return (s,c) } <|> defaultColors config +-- | Parses a color specification (hex or named) +colorSpec :: Parser String +colorSpec = + do { c <- char '#' + ; s <- count 6 hexDigit + ; return $ c:s + } + <|> many1 alphaNum + -- | Parses the output template string templateStringParser :: Config -> Parser (String,String,String) templateStringParser c = |