summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKrzysztof Kosciuszkiewicz <k.kosciuszkiewicz@gmail.com>2007-07-06 03:01:24 +0200
committerKrzysztof Kosciuszkiewicz <k.kosciuszkiewicz@gmail.com>2007-07-06 03:01:24 +0200
commit9192f3664b07b161a1c4120e889e37100824b16a (patch)
treeb0850681735f143f480d5a7a9f1e161757d7ab01
parent0b11566a389e54b4c5d891def5641a1dad7098a5 (diff)
downloadxmobar-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.hs15
1 files changed, 12 insertions, 3 deletions
diff --git a/Parsers.hs b/Parsers.hs
index 6ca318c..6feea97 100644
--- a/Parsers.hs
+++ b/Parsers.hs
@@ -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 =