aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Util
diff options
context:
space:
mode:
authorJan Vornberger <jan.vornberger@informatik.uni-oldenburg.de>2009-10-24 22:51:11 +0200
committerJan Vornberger <jan.vornberger@informatik.uni-oldenburg.de>2009-10-24 22:51:11 +0200
commit4da4e91a5ab9361451bad2a51a565115bbc0d79e (patch)
tree06a7c740d845c790f64d4dd5e57b134ffd82db01 /XMonad/Util
parentc2926c7f7543f3e79d6ecd841c0c55ea2454606a (diff)
downloadXMonadContrib-4da4e91a5ab9361451bad2a51a565115bbc0d79e.tar.gz
XMonadContrib-4da4e91a5ab9361451bad2a51a565115bbc0d79e.tar.xz
XMonadContrib-4da4e91a5ab9361451bad2a51a565115bbc0d79e.zip
Extended paintAndWrite to allow for multiple strings to be written into the rectangle
Ignore-this: eb7d32284b7f98145038dcaa14f8075e darcs-hash:20091024205111-594c5-33318832d5ca7d71ece560ea79d45109001eadfb.gz
Diffstat (limited to 'XMonad/Util')
-rw-r--r--XMonad/Util/XUtils.hs27
1 files changed, 15 insertions, 12 deletions
diff --git a/XMonad/Util/XUtils.hs b/XMonad/Util/XUtils.hs
index b37d438..1995d31 100644
--- a/XMonad/Util/XUtils.hs
+++ b/XMonad/Util/XUtils.hs
@@ -103,7 +103,8 @@ paintWindow :: Window -- ^ The window where to draw
paintWindow w wh ht bw c bc =
paintWindow' w (Rectangle 0 0 wh ht) bw c bc Nothing
--- | Fill a window with a rectangle and a border, and write a string at given position
+-- | Fill a window with a rectangle and a border, and write
+-- | a number of strings to given positions
paintAndWrite :: Window -- ^ The window where to draw
-> XMonadFont -- ^ XMonad Font for drawing
-> Dimension -- ^ Window width
@@ -113,19 +114,20 @@ paintAndWrite :: Window -- ^ The window where to draw
-> String -- ^ Border color
-> String -- ^ String color
-> String -- ^ String background color
- -> Align -- ^ String 'Align'ment
- -> String -- ^ String to be printed
+ -> [Align] -- ^ String 'Align'ments
+ -> [String] -- ^ Strings to be printed
-> X ()
-paintAndWrite w fs wh ht bw bc borc ffc fbc al str = do
+paintAndWrite w fs wh ht bw bc borc ffc fbc als strs = do
d <- asks display
- (x,y) <- stringPosition d fs (Rectangle 0 0 wh ht) al str
- paintWindow' w (Rectangle x y wh ht) bw bc borc ms
- where ms = Just (fs,ffc,fbc,str)
+ strPositions <- forM (zip als strs) $ \(al, str) ->
+ stringPosition d fs (Rectangle 0 0 wh ht) al str
+ let ms = Just (fs,ffc,fbc, zip strs strPositions)
+ paintWindow' w (Rectangle 0 0 wh ht) bw bc borc ms
-- This stuff is not exported
-paintWindow' :: Window -> Rectangle -> Dimension -> String -> String -> Maybe (XMonadFont,String,String,String) -> X ()
-paintWindow' win (Rectangle x y wh ht) bw color b_color str = do
+paintWindow' :: Window -> Rectangle -> Dimension -> String -> String -> Maybe (XMonadFont,String,String,[(String, (Position, Position))]) -> X ()
+paintWindow' win (Rectangle _ _ wh ht) bw color b_color strStuff = do
d <- asks display
p <- io $ createPixmap d win wh ht (defaultDepthOfScreen $ defaultScreenOfDisplay d)
gc <- io $ createGC d p
@@ -138,9 +140,10 @@ paintWindow' win (Rectangle x y wh ht) bw color b_color str = do
-- and now again
io $ setForeground d gc color'
io $ fillRectangle d p gc (fi bw) (fi bw) (wh - (bw * 2)) (ht - (bw * 2))
- when (isJust str) $ do
- let (xmf,fc,bc,s) = fromJust str
- printStringXMF d p xmf gc fc bc x y s
+ when (isJust strStuff) $ do
+ let (xmf,fc,bc,strAndPos) = fromJust strStuff
+ forM_ strAndPos $ \(s, (x, y)) ->
+ printStringXMF d p xmf gc fc bc x y s
-- copy the pixmap over the window
io $ copyArea d p win gc 0 0 wh ht 0 0
-- free the pixmap and GC