Added the alignment option 'AlignRightOffset'

This commit is contained in:
Jan Vornberger
2009-10-24 20:45:13 +00:00
parent 79e7a8210a
commit c38912b991
2 changed files with 3 additions and 2 deletions

View File

@@ -143,7 +143,7 @@ textExtentsXMF (Xft xftfont) _ = io $ do
#endif #endif
-- | String position -- | String position
data Align = AlignCenter | AlignRight | AlignLeft data Align = AlignCenter | AlignRight | AlignLeft | AlignRightOffset Int
-- | Return the string x and y 'Position' in a 'Rectangle', given a -- | Return the string x and y 'Position' in a 'Rectangle', given a
-- 'FontStruct' and the 'Align'ment -- 'FontStruct' and the 'Align'ment
@@ -156,6 +156,7 @@ stringPosition dpy fs (Rectangle _ _ w h) al s = do
AlignCenter -> fi (w `div` 2) - fi (width `div` 2) AlignCenter -> fi (w `div` 2) - fi (width `div` 2)
AlignLeft -> 1 AlignLeft -> 1
AlignRight -> fi (w - (fi width + 1)); AlignRight -> fi (w - (fi width + 1));
AlignRightOffset offset -> fi (w - (fi width + 1)) - fi offset;
return (x,y) return (x,y)
printStringXMF :: (Functor m, MonadIO m) => Display -> Drawable -> XMonadFont -> GC -> String -> String printStringXMF :: (Functor m, MonadIO m) => Display -> Drawable -> XMonadFont -> GC -> String -> String

View File

@@ -254,7 +254,7 @@ fixedWidthL a str n logger = do
case a of case a of
AlignCenter -> toL (take n $ padhalf l ++ l ++ cs) AlignCenter -> toL (take n $ padhalf l ++ l ++ cs)
AlignRight -> toL (reverse (take n $ reverse l ++ cs)) AlignRight -> toL (reverse (take n $ reverse l ++ cs))
AlignLeft -> toL (take n $ l ++ cs) _ -> toL (take n $ l ++ cs)
where where
toL = return . Just toL = return . Just
cs = cycle str cs = cycle str