diff options
author | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-10-12 21:39:44 +0200 |
---|---|---|
committer | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-10-12 21:39:44 +0200 |
commit | 51f43202735c51ca93e9552f4f7508aa565e8f4e (patch) | |
tree | e35505c71fddd57d016a898ec3489cda79a86e78 | |
parent | e93f691527f4d92ba4acf875454df92af6404852 (diff) | |
download | xmobar-51f43202735c51ca93e9552f4f7508aa565e8f4e.tar.gz xmobar-51f43202735c51ca93e9552f4f7508aa565e8f4e.tar.bz2 |
Allow setting the foreground color
Now it is possible dynamically set the foreground color of strings to
be displayed with the <fc
darcs-hash:20071012193944-d6583-14ce9e84b1d5223b790e771f0b82cf354d58d744.gz
-rw-r--r-- | Xmobar.hs | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -183,10 +183,17 @@ printStrings dr gc fontst offs sl@((s,c,l):xs) = do "right" -> remWidth - 1 "left" -> offs _ -> offs - fgcolor <- io $ initColor d c - bgcolor <- io $ initColor d (bgColor conf) - io $ setForeground d gc fgcolor - io $ setBackground d gc bgcolor + (fc,bc) <- case (break (==',') c) of + (f,',':b) -> do + fgc <- io $ initColor d f + bgc <- io $ initColor d b + return (fgc,bgc) + (f,_) -> do + fgc <- io $ initColor d f + bgc <- io $ initColor d (bgColor conf) + return (fgc,bgc) + io $ setForeground d gc fc + io $ setBackground d gc bc io $ drawImageString d dr gc offset valign s printStrings dr gc fontst (offs + l) xs @@ -223,7 +230,7 @@ Utilities -- given the black pixel will be returned. initColor :: Display -> String -> IO Pixel initColor dpy c = - catch (initColor' dpy c) (const $ return $ blackPixel dpy (defaultScreen dpy)) + catch (initColor' dpy c) (const . return . blackPixel dpy $ (defaultScreen dpy)) initColor' :: Display -> String -> IO Pixel initColor' dpy c = (color_pixel . fst) `liftM` allocNamedColor dpy colormap c |