From 51f43202735c51ca93e9552f4f7508aa565e8f4e Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Fri, 12 Oct 2007 21:39:44 +0200 Subject: Allow setting the foreground color Now it is possible dynamically set the foreground color of strings to be displayed with the 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 -- cgit v1.2.3