diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2011-01-22 03:33:08 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2011-01-22 03:33:08 +0100 |
commit | e909c3b8c6887b2fcee1debf34499794e5accac1 (patch) | |
tree | 4fd055de9b8c2ad13bb13b99c1d2248f6000079e /src/Main.hs | |
parent | afc503e0697046029a5fcbdfe313cbba302b8421 (diff) | |
download | xmobar-e909c3b8c6887b2fcee1debf34499794e5accac1.tar.gz xmobar-e909c3b8c6887b2fcee1debf34499794e5accac1.tar.bz2 |
Bug fix: don't get confused by align separators in input (issue 14)
This solves the common case of a template separator character (such as
{) popping up in xmobar's input (e.g., inside a window title) and
confusing the parser.
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/Main.hs b/src/Main.hs index aad87e7..c069b8e 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -60,11 +60,26 @@ main = do doOpts civ o conf <- readIORef civ fs <- initFont d (font conf) - cl <- parseTemplate conf (template conf) - vars <- mapM startCommand cl + cls <- mapM (parseTemplate conf) (splitTemplate conf) + vars <- mapM (mapM startCommand) cls (r,w) <- createWin d fs conf eventLoop (XConf d r w fs conf) vars +-- | Splits the template in its parts +splitTemplate :: Config -> [String] +splitTemplate conf = + case break (==l) t of + (le,_:re) -> case break (==r) re of + (ce,_:ri) -> [le, ce, ri] + _ -> def + _ -> def + where [l, r] = if length (alignSep conf) == 2 + then alignSep conf + else alignSep defaultConfig + t = template conf + def = [t, "", ""] + + -- | Reads the configuration files or quits with an error readConfig :: FilePath -> IO (Config,[String]) readConfig f = do |