mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-07-31 04:01:51 -07:00
X.H.DynamicLog: Add shorten' and shortenLeft' (customizable end)
This commit is contained in:
@@ -176,6 +176,9 @@
|
||||
- Added `shortenLeft` function, like existing `shorten` but shortens by
|
||||
truncating from left instead of right. Useful for showing directories.
|
||||
|
||||
- Added `shorten'` and `shortenLeft'` functions with customizable overflow
|
||||
markers.
|
||||
|
||||
- Added `filterOutWsPP` for filtering out certain workspaces from being
|
||||
displayed.
|
||||
|
||||
@@ -309,7 +312,7 @@
|
||||
|
||||
* `XMonad.Util.DebugWindow`
|
||||
Fixed a bottom in `debugWindow` when used on windows with UTF8 encoded titles.
|
||||
|
||||
|
||||
* `XMonad.Config.Xfce`
|
||||
Set `terminal` to `xfce4-terminal`.
|
||||
|
||||
|
@@ -43,7 +43,7 @@ module XMonad.Hooks.DynamicLog (
|
||||
dzenPP, xmobarPP, sjanssenPP, byorgeyPP,
|
||||
|
||||
-- * Formatting utilities
|
||||
wrap, pad, trim, shorten, shortenLeft,
|
||||
wrap, pad, trim, shorten, shorten', shortenLeft, shortenLeft',
|
||||
xmobarColor, xmobarAction, xmobarBorder,
|
||||
xmobarRaw, xmobarStrip, xmobarStripTags,
|
||||
dzenColor, dzenEscape, dzenStrip, filterOutWsPP,
|
||||
@@ -386,18 +386,22 @@ trim = f . f
|
||||
|
||||
-- | Limit a string to a certain length, adding "..." if truncated.
|
||||
shorten :: Int -> String -> String
|
||||
shorten n xs | length xs < n = xs
|
||||
| otherwise = take (n - length end) xs ++ end
|
||||
where
|
||||
end = "..."
|
||||
shorten = shorten' "..."
|
||||
|
||||
-- | Limit a string to a certain length, adding @end@ if truncated.
|
||||
shorten' :: String -> Int -> String -> String
|
||||
shorten' end n xs | length xs < n = xs
|
||||
| otherwise = take (n - length end) xs ++ 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
|
||||
shortenLeft = shortenLeft' "..."
|
||||
|
||||
-- | Like 'shorten'', but truncate from the left instead of right.
|
||||
shortenLeft' :: String -> Int -> String -> String
|
||||
shortenLeft' end n xs | l < n = xs
|
||||
| otherwise = end ++ (drop (l - n + length end) xs)
|
||||
where l = length xs
|
||||
|
||||
-- | Output a list of strings, ignoring empty ones and separating the
|
||||
-- rest with the given separator.
|
||||
|
Reference in New Issue
Block a user