mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
X.H.DynamicLog: Add shortenLeft
This can be sometimes useful, e.g. when showing a directory.
This commit is contained in:
parent
d5b64c1e5d
commit
0996e71c7e
@ -43,7 +43,7 @@ module XMonad.Hooks.DynamicLog (
|
||||
dzenPP, xmobarPP, sjanssenPP, byorgeyPP,
|
||||
|
||||
-- * Formatting utilities
|
||||
wrap, pad, trim, shorten,
|
||||
wrap, pad, trim, shorten, shortenLeft,
|
||||
xmobarColor, xmobarAction, xmobarBorder,
|
||||
xmobarRaw, xmobarStrip, xmobarStripTags,
|
||||
dzenColor, dzenEscape, dzenStrip,
|
||||
@ -391,6 +391,14 @@ shorten n xs | length xs < n = xs
|
||||
where
|
||||
end = "..."
|
||||
|
||||
-- | Like 'shorten', but truncate from the left instead of right.
|
||||
shortenLeft :: Int -> String -> String
|
||||
shortenLeft n xs | l < n = xs
|
||||
| otherwise = end ++ (drop (l - n + length end) xs)
|
||||
where
|
||||
end = "..."
|
||||
l = length xs
|
||||
|
||||
-- | Output a list of strings, ignoring empty ones and separating the
|
||||
-- rest with the given separator.
|
||||
sepBy :: String -- ^ separator
|
||||
|
Loading…
x
Reference in New Issue
Block a user