diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2022-04-17 23:15:55 -0600 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2022-10-09 12:19:46 -0600 |
| commit | 3a26f3eb4f02052fdb97dcdd884f408d52b383a9 (patch) | |
| tree | 592287a0d97ac6e6fef9c24846f7575873bf9a0c /src/Rahm/Desktop/History.hs | |
| parent | 1ad36bd0e332bfe4354c9966191603f116196ecd (diff) | |
| download | rde-3a26f3eb4f02052fdb97dcdd884f408d52b383a9.tar.gz rde-3a26f3eb4f02052fdb97dcdd884f408d52b383a9.tar.bz2 rde-3a26f3eb4f02052fdb97dcdd884f408d52b383a9.zip | |
Starting to implement window management language
Diffstat (limited to 'src/Rahm/Desktop/History.hs')
| -rw-r--r-- | src/Rahm/Desktop/History.hs | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/Rahm/Desktop/History.hs b/src/Rahm/Desktop/History.hs index 5e15fe6..9195a92 100644 --- a/src/Rahm/Desktop/History.hs +++ b/src/Rahm/Desktop/History.hs @@ -9,10 +9,9 @@ import Data.Default import qualified XMonad.Util.ExtensibleState as XS import Data.Foldable (toList) -import Rahm.Desktop.Workspaces (gotoWorkspace) import Rahm.Desktop.Hooks.WindowChange +import Rahm.Desktop.Common import Rahm.Desktop.Logger -import Rahm.Desktop.Marking import Data.Sequence (Seq(..)) import qualified Data.Sequence as Seq @@ -60,6 +59,20 @@ instance ExtensionClass History where initialValue = def -- extensionType = PersistentExtension +pastHistory :: Int -> X (Maybe Location) +pastHistory i = do + History (BoundedSeqZipper _ _ t) <- XS.get + return $ t Seq.!? i + +getMostRecentLocationInHistory :: X (Maybe Location) +getMostRecentLocationInHistory = do + History z <- XS.get + case z of + (BoundedSeqZipper _ (_ :|> h) _) -> return $ Just h + (BoundedSeqZipper _ _ (t :<| _)) -> return $ Just t + _ -> return Nothing + + historyBack :: X () historyBack = do History z <- XS.get @@ -74,19 +87,19 @@ historyForward = do mapM_ focusLocation (getZipper z') XS.put (History z') -lastWindow :: X (Maybe Location) -lastWindow = getZipper . zipperBack . currentZipper <$> XS.get +lastLocation :: X (Maybe Location) +lastLocation = getZipper . zipperBack . currentZipper <$> XS.get -jumpToLastLocation :: X () -jumpToLastLocation = mapM_ focusLocation =<< lastWindow +nextLocation :: X (Maybe Location) +nextLocation = getZipper . zipperForward . currentZipper <$> XS.get +jumpToLastLocation :: X () +jumpToLastLocation = mapM_ focusLocation =<< lastLocation -historyHook :: Location -> Location -> X () -historyHook (Location ws _) l@(Location ws' _) | ws /= ws' = do +historyHook :: Maybe Location -> Location -> X () +historyHook Nothing loc = + XS.modify $ \(History z) -> History (pushZipper loc z) +historyHook (Just (Location ws _)) l@(Location ws' _) | ws /= ws' = do XS.modify $ \(History z) -> History (pushZipper l z) historyHook _ _ = return () - -focusLocation :: Location -> X () -focusLocation (Location ws Nothing) = gotoWorkspace ws -focusLocation (Location _ (Just win)) = windows $ W.focusWindow win |