From 8afb450eb104e5335f4b1b976512842f7059142c Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 21 Aug 2011 19:09:15 +0200 Subject: Show invalid input in case of parsing error in template As a side-effect, parts without substitution vars will be displayed as-is, fixing a bug reported by RC in the mailing list. --- NEWS | 1 + src/Parsers.hs | 2 +- src/Xmobar.hs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 1e15772..9b398f2 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ _New features_ _Bug fixes_ - [issue 50]: `MPD` monitor now works with libmpd 0.6. + - Template sections without fields are now correctly displayed. [issue 50]: http://code.google.com/p/xmobar/issues/detail?id=14 diff --git a/src/Parsers.hs b/src/Parsers.hs index 1450a0e..baaa287 100644 --- a/src/Parsers.hs +++ b/src/Parsers.hs @@ -87,7 +87,7 @@ templateParser = many . templateStringParser parseTemplate :: Config -> String -> IO [(Runnable,String,String)] parseTemplate c s = do str <- case parse (templateParser c) "" s of - Left _ -> return [("","","")] + Left _ -> return [("", s, "")] Right x -> return x let cl = map alias (commands c) m = Map.fromList $ zip cl (commands c) diff --git a/src/Xmobar.hs b/src/Xmobar.hs index cf912b7..eb7a1dd 100644 --- a/src/Xmobar.hs +++ b/src/Xmobar.hs @@ -120,7 +120,7 @@ eventLoop xc@(XConf d _ w fs c) vs = block $ do startCommand :: (Runnable,String,String) -> IO (Maybe ThreadId, TVar String) startCommand (com,s,ss) | alias com == "" = do var <- atomically $ newTVar is - atomically $ writeTVar var "Could not parse the template" + atomically $ writeTVar var (s ++ ss) return (Nothing,var) | otherwise = do var <- atomically $ newTVar is let cb str = atomically $ writeTVar var (s ++ str ++ ss) -- cgit v1.2.3