Merge pull request #503 from oogeek/X.L.Rename-KeepWordsLR

add KeepWordsLeft and KeepWordsRight for X.L.Renamed
This commit is contained in:
Yecine Megdiche 2021-04-05 18:46:02 +01:00 committed by GitHub
commit a668b0f13a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -529,6 +529,11 @@
ability to postpone magnifying until there are a certain number of
windows on the workspace.
* `XMonad.Layout.Renamed`
- Added `KeepWordsLeft` and `KeepWordsRight` for keeping certain number of
words in left or right direction in layout description.
## 0.16
### Breaking Changes

View File

@ -46,6 +46,8 @@ data Rename a = CutLeft Int -- ^ Remove a number of characters from the left
| Prepend String -- ^ Add a string on the left
| CutWordsLeft Int -- ^ Remove a number of words from the left
| CutWordsRight Int -- ^ Remove a number of words from the right
| KeepWordsLeft Int -- ^ Keep a number of words from the left
| KeepWordsRight Int -- ^ Keep a number of words from the right
| AppendWords String -- ^ Add a string to the right, prepending a space to it
-- if necessary
| PrependWords String -- ^ Add a string to the left, appending a space to it if
@ -59,7 +61,10 @@ apply (CutLeft i) s = drop i s
apply (CutRight i) s = take (length s - i) s
apply (CutWordsLeft i) s = unwords $ drop i $ words s
apply (CutWordsRight i) s = let ws = words s
in unwords $ take (length ws - i) ws
in unwords $ take (length ws - i) ws
apply (KeepWordsLeft i) s = unwords $ take i $ words s
apply (KeepWordsRight i) s = let ws = words s
in unwords $ drop (length ws - i) ws
apply (Replace s) _ = s
apply (Append s') s = s ++ s'
apply (Prepend s') s = s' ++ s