diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2026-03-01 15:50:03 -0700 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2026-03-01 15:50:03 -0700 |
| commit | 9839efd016f43c892e935c7d4063e30c23b81e1f (patch) | |
| tree | 0431ff646b7a273f6a40e04ebe40931faafdcbd1 /src/Rahm/Desktop/Workspaces.hs | |
| parent | 2bcd8842dab3a8e62b5ad7cba6cbfbe3fc648f0d (diff) | |
| download | rde-9839efd016f43c892e935c7d4063e30c23b81e1f.tar.gz rde-9839efd016f43c892e935c7d4063e30c23b81e1f.tar.bz2 rde-9839efd016f43c892e935c7d4063e30c23b81e1f.zip | |
[feat] change <M-a> behaivor. Add {} motions.
<M-a> now iterates through the screens as they're ordered. (top-bottom,
left-right).
} - new workspace motion to go through visibly ordered workspaces
{ - reverse of }
Diffstat (limited to 'src/Rahm/Desktop/Workspaces.hs')
| -rw-r--r-- | src/Rahm/Desktop/Workspaces.hs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/Rahm/Desktop/Workspaces.hs b/src/Rahm/Desktop/Workspaces.hs index 50a04d2..96e4d99 100644 --- a/src/Rahm/Desktop/Workspaces.hs +++ b/src/Rahm/Desktop/Workspaces.hs @@ -18,6 +18,8 @@ module Rahm.Desktop.Workspaces getWorkspaceToTheLeft, getWorkspaceAbove, getWorkspaceBelow, + getNextWorkspaceInOrder, + getPrevWorkspaceInOrder, WorkspaceState (..), ) where @@ -142,6 +144,41 @@ adjacentWorkspace (Selector selector) from = let tags = sort $ W.tag . snd <$> getPopulatedWorkspaces ss in return $ fromMaybe from $ selector (== from) tags +getNextWorkspaceInOrder :: WorkspaceId -> X WorkspaceId +getNextWorkspaceInOrder from = + withWindowSet $ \ss -> + let screens = getOrderedScreens ss + tags = map (W.tag . W.workspace . snd) screens + tagsWithHidden = map (W.tag . snd) $ getPopulatedWorkspaces ss + orderedTags = filter (\t -> t `elem` tagsWithHidden) tags + getIndex [] _ = Nothing + getIndex (x : xs) target = + if x == target + then + if null xs + then Just $ head orderedTags -- wrap around + else Just $ head xs + else getIndex xs target + in return $ fromMaybe from $ getIndex orderedTags from + +getPrevWorkspaceInOrder :: WorkspaceId -> X WorkspaceId +getPrevWorkspaceInOrder from = + withWindowSet $ \ss -> + let screens = getOrderedScreens ss + tags = map (W.tag . W.workspace . snd) screens + tagsWithHidden = map (W.tag . snd) $ getPopulatedWorkspaces ss + orderedTags = filter (\t -> t `elem` tagsWithHidden) tags + reverseTags = reverse orderedTags + getIndex [] _ = Nothing + getIndex (x : xs) target = + if x == target + then + if null xs + then Just $ head reverseTags -- wrap around + else Just $ head xs + else getIndex xs target + in return $ fromMaybe from $ getIndex reverseTags from + viewAdjacent :: Selector -> X () viewAdjacent sel = gotoWorkspace =<< (adjacentWorkspaceNotVisible sel =<< getCurrentWorkspace) |