summaryrefslogtreecommitdiffhomepage
path: root/Monitors
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@ing.unitn.it>2007-07-08 12:01:48 +0200
committerAndrea Rossato <andrea.rossato@ing.unitn.it>2007-07-08 12:01:48 +0200
commit562bf90aa4d9d2987c6bb132dbb99184e7e93b1e (patch)
tree87523b2fccfdef24a2c84f0214eff60fe2bea4f5 /Monitors
parent6d2519cb84ebd56a7b270bc58b4e352b291624f6 (diff)
downloadxmobar-562bf90aa4d9d2987c6bb132dbb99184e7e93b1e.tar.gz
xmobar-562bf90aa4d9d2987c6bb132dbb99184e7e93b1e.tar.bz2
better error handling when parsing weather information
darcs-hash:20070708100148-d6583-a9f7983de441caeccc341c15a7029102e20eaa7b.gz
Diffstat (limited to 'Monitors')
-rw-r--r--Monitors/Common.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Monitors/Common.hs b/Monitors/Common.hs
index e4c1562..8a51159 100644
--- a/Monitors/Common.hs
+++ b/Monitors/Common.hs
@@ -30,6 +30,8 @@ module Monitors.Common (
, getNumbers
, getNumbersAsString
, getAllBut
+ , getAfterString
+ , skipTillString
, parseTemplate
-- ** String Manipulation
-- $strings
@@ -207,6 +209,16 @@ skipRestOfLine =
do many $ noneOf "\n\r"
newline
+getAfterString :: String -> Parser String
+getAfterString s =
+ do { try $ manyTill skipRestOfLine $ string s
+ ; v <- manyTill anyChar $ newline
+ ; return v
+ } <|> return ("<" ++ s ++ " not found!>")
+
+skipTillString :: String -> Parser String
+skipTillString s =
+ manyTill skipRestOfLine $ string s
-- | Parses the output template string
templateStringParser :: Parser (String,String,String)