mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Added updateName
and removeName
to X.A.DynamicWorkspaceOrder
This adds the possibility to maintain the ordering of workspaces after they are renamed and to remove them from sorting when they are deleted.
This commit is contained in:
parent
d3d0818e9b
commit
635a9dee4c
@ -282,6 +282,11 @@
|
||||
- Added optional `ppVisibleNoWindows` to differentiate between empty
|
||||
and non-empty visible workspaces in pretty printing.
|
||||
|
||||
* `XMonad.Actions.DynamicWorkspaceOrder`
|
||||
|
||||
- Added `updateName` and `removeName` to better control ordering when
|
||||
workspace names are changed or workspaces are removed.
|
||||
|
||||
## 0.13 (February 10, 2017)
|
||||
|
||||
### Breaking Changes
|
||||
|
@ -23,6 +23,8 @@ module XMonad.Actions.DynamicWorkspaceOrder
|
||||
getWsCompareByOrder
|
||||
, getSortByOrder
|
||||
, swapWith
|
||||
, updateName
|
||||
, removeName
|
||||
|
||||
, moveTo
|
||||
, moveToGreedy
|
||||
@ -152,6 +154,21 @@ swapOrder w1 w2 = do
|
||||
XS.modify (withWSO (M.insert w1 i2 . M.insert w2 i1))
|
||||
windows id -- force a status bar update
|
||||
|
||||
-- | Update the name of a workspace in the stored order.
|
||||
updateName :: WorkspaceId -> WorkspaceId -> X ()
|
||||
updateName oldId newId = XS.modify . withWSO $ changeKey oldId newId
|
||||
|
||||
-- | Remove a workspace from the stored order.
|
||||
removeName :: WorkspaceId -> X ()
|
||||
removeName = XS.modify . withWSO . M.delete
|
||||
|
||||
-- | Update a key in a Map.
|
||||
changeKey :: Ord k => k -> k -> M.Map k a -> M.Map k a
|
||||
changeKey oldKey newKey oldMap =
|
||||
case M.updateLookupWithKey (\_ _ -> Nothing) oldKey oldMap of
|
||||
(Nothing, _) -> oldMap
|
||||
(Just val, newMap) -> M.insert newKey val newMap
|
||||
|
||||
-- | View the next workspace of the given type in the given direction,
|
||||
-- where \"next\" is determined using the dynamic workspace order.
|
||||
moveTo :: Direction1D -> WSType -> X ()
|
||||
@ -175,4 +192,4 @@ withNthWorkspace job wnum = do
|
||||
ws <- gets (map W.tag . sort . W.workspaces . windowset)
|
||||
case drop wnum ws of
|
||||
(w:_) -> windows $ job w
|
||||
[] -> return ()
|
||||
[] -> return ()
|
||||
|
Loading…
x
Reference in New Issue
Block a user