mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -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,
|
dzenPP, xmobarPP, sjanssenPP, byorgeyPP,
|
||||||
|
|
||||||
-- * Formatting utilities
|
-- * Formatting utilities
|
||||||
wrap, pad, trim, shorten,
|
wrap, pad, trim, shorten, shortenLeft,
|
||||||
xmobarColor, xmobarAction, xmobarBorder,
|
xmobarColor, xmobarAction, xmobarBorder,
|
||||||
xmobarRaw, xmobarStrip, xmobarStripTags,
|
xmobarRaw, xmobarStrip, xmobarStripTags,
|
||||||
dzenColor, dzenEscape, dzenStrip,
|
dzenColor, dzenEscape, dzenStrip,
|
||||||
@ -391,6 +391,14 @@ shorten n xs | length xs < n = xs
|
|||||||
where
|
where
|
||||||
end = "..."
|
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
|
-- | Output a list of strings, ignoring empty ones and separating the
|
||||||
-- rest with the given separator.
|
-- rest with the given separator.
|
||||||
sepBy :: String -- ^ separator
|
sepBy :: String -- ^ separator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user