summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar.hs
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2011-01-22 03:33:08 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2011-01-22 03:33:08 +0100
commite909c3b8c6887b2fcee1debf34499794e5accac1 (patch)
tree4fd055de9b8c2ad13bb13b99c1d2248f6000079e /src/Xmobar.hs
parentafc503e0697046029a5fcbdfe313cbba302b8421 (diff)
downloadxmobar-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/Xmobar.hs')
-rw-r--r--src/Xmobar.hs26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/Xmobar.hs b/src/Xmobar.hs
index f3e0907..566f8e8 100644
--- a/src/Xmobar.hs
+++ b/src/Xmobar.hs
@@ -73,23 +73,27 @@ data WakeUp = WakeUp deriving (Show,Typeable)
instance Exception WakeUp
-- | The event loop
-eventLoop :: XConf -> [(Maybe ThreadId, TVar String)] -> IO ()
+eventLoop :: XConf -> [[(Maybe ThreadId, TVar String)]] -> IO ()
eventLoop xc@(XConf d _ w fs c) v = block $ do
tv <- atomically $ newTVar []
t <- myThreadId
- ct <- forkIO (checker t tv "" `catch` \(SomeException _) -> return ())
+ ct <- forkIO (checker t tv [] `catch` \(SomeException _) -> return ())
go tv ct
where
-- interrupt the drawing thread every time a var is updated
checker t tvar ov = do
nval <- atomically $ do
- nv <- fmap concat $ mapM (readTVar . snd) v
+ nv <- mapM concatV v
guard (nv /= ov)
writeTVar tvar nv
return nv
throwTo t WakeUp
checker t tvar nval
+ concatV xs = do
+ s <- mapM (readTVar . snd) xs
+ return $ concat s
+
-- Continuously wait for a timer interrupt or an expose event
go tv ct = do
catch (unblock $ allocaXEvent $ \e ->
@@ -217,21 +221,13 @@ getStaticStrutValues (Static cx cy cw ch) rwh
xe = xs + cw
getStaticStrutValues _ _ = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
-updateWin :: TVar String -> X ()
+updateWin :: TVar [String] -> X ()
updateWin v = do
xc <- ask
+ s <- io $ atomically $ readTVar v
let (conf,rec) = (config &&& rect) xc
- [lc,rc] = if length (alignSep conf) == 2
- then alignSep conf
- else alignSep defaultConfig
- i <- io $ atomically $ readTVar v
- let def = [i,[],[]]
- [l,c,r] = case break (==lc) i of
- (le,_:re) -> case break (==rc) re of
- (ce,_:ri) -> [le,ce,ri]
- _ -> def
- _ -> def
- ps <- io $ mapM (parseString conf) [l,c,r]
+ l:c:r:_ = s ++ repeat ""
+ ps <- io $ mapM (parseString conf) [l, c, r]
drawInWin rec ps
-- $print