diff options
-rw-r--r-- | XMonad/Actions/GridSelect.hs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/XMonad/Actions/GridSelect.hs b/XMonad/Actions/GridSelect.hs index d9413e0..d0d14db 100644 --- a/XMonad/Actions/GridSelect.hs +++ b/XMonad/Actions/GridSelect.hs @@ -60,6 +60,7 @@ module XMonad.Actions.GridSelect ( -- * Navigation Components setPos, move, + moveNext, movePrev, select, cancel, transformSearchString @@ -404,6 +405,30 @@ move (dx,dy) = do newPos = (x+dx,y+dy) setPos newPos +moveNext :: TwoD a () +moveNext = do + position <- gets td_curpos + elems <- gets td_elementmap + let n = length elems + m = case findIndex (\p -> fst p == position) elems of + Nothing -> Nothing + Just k | k == n-1 -> Just 0 + | otherwise -> Just (k+1) + whenJust m $ \i -> + setPos (fst $ elems !! i) + +movePrev :: TwoD a () +movePrev = do + position <- gets td_curpos + elems <- gets td_elementmap + let n = length elems + m = case findIndex (\p -> fst p == position) elems of + Nothing -> Nothing + Just 0 -> Just (n-1) + Just k -> Just (k-1) + whenJust m $ \i -> + setPos (fst $ elems !! i) + -- | Apply a transformation function the current search string transformSearchString :: (String -> String) -> TwoD a () transformSearchString f = do @@ -661,4 +686,4 @@ gridselectWorkspace :: GSConfig WorkspaceId -> (WorkspaceId -> WindowSet -> WindowSet) -> X () gridselectWorkspace conf viewFunc = withWindowSet $ \ws -> do let wss = map W.tag $ W.hidden ws ++ map W.workspace (W.current ws : W.visible ws) - gridselect conf (zip wss wss) >>= flip whenJust (windows . viewFunc)
\ No newline at end of file + gridselect conf (zip wss wss) >>= flip whenJust (windows . viewFunc) |