diff options
author | sean.escriva <sean.escriva@gmail.com> | 2009-04-09 18:35:13 +0200 |
---|---|---|
committer | sean.escriva <sean.escriva@gmail.com> | 2009-04-09 18:35:13 +0200 |
commit | 2c2e4ce205fcfe57a1228863bdecd7b486ea3787 (patch) | |
tree | 3b817de0d602fe4e328ad941ebf61ff951738633 | |
parent | 82dd844adfa563fe0e2d0a4b19c37e5786f54343 (diff) | |
download | XMonadContrib-2c2e4ce205fcfe57a1228863bdecd7b486ea3787.tar.gz XMonadContrib-2c2e4ce205fcfe57a1228863bdecd7b486ea3787.tar.xz XMonadContrib-2c2e4ce205fcfe57a1228863bdecd7b486ea3787.zip |
X.H.DynamicLog: provides trim, inverse of pad
Ignore-this: 9d92ff592f2bc4f041b85d1314058fdc
darcs-hash:20090409163513-29414-6e265fe7109d15b55b040514bca469d5c68f2bc4.gz
Diffstat (limited to '')
-rw-r--r-- | XMonad/Hooks/DynamicLog.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/XMonad/Hooks/DynamicLog.hs b/XMonad/Hooks/DynamicLog.hs index 51fb70b..3bc979b 100644 --- a/XMonad/Hooks/DynamicLog.hs +++ b/XMonad/Hooks/DynamicLog.hs @@ -38,7 +38,7 @@ module XMonad.Hooks.DynamicLog ( dzenPP, xmobarPP, sjanssenPP, byorgeyPP, -- * Formatting utilities - wrap, pad, shorten, + wrap, pad, trim, shorten, xmobarColor, xmobarStrip, dzenColor, dzenEscape, dzenStrip, @@ -56,6 +56,7 @@ module XMonad.Hooks.DynamicLog ( -- import XMonad import Control.Monad +import Data.Char ( isSpace ) import Data.Maybe ( isJust, catMaybes ) import Data.List import qualified Data.Map as M @@ -303,6 +304,11 @@ wrap l r m = l ++ m ++ r pad :: String -> String pad = wrap " " " " +-- | Trim leading and trailing whitespace from a string. +trim :: String -> String +trim = f . f + where f = reverse . dropWhile isSpace + -- | Limit a string to a certain length, adding "..." if truncated. shorten :: Int -> String -> String shorten n xs | length xs < n = xs |