From ed1042f0a214883d0b060fd9b461083fa31306f5 Mon Sep 17 00:00:00 2001 From: Jack Garner Date: Thu, 2 Apr 2020 13:58:20 -0600 Subject: [PATCH] Remove smart zoom because it was dumb The zooms that tried to skil around were added back when there were more Tilers. There are fewer now so it isn't needed. --- config/actions.dhall | 3 +-- config/tilers.dhall | 1 - src/Actions/ActionTypes.hs | 2 -- src/Actions/Actions.hs | 51 +++----------------------------------- src/Lib.hs | 2 -- 5 files changed, 5 insertions(+), 54 deletions(-) delete mode 100644 config/tilers.dhall diff --git a/config/actions.dhall b/config/actions.dhall index 1fb3a1f..9e31861 100644 --- a/config/actions.dhall +++ b/config/actions.dhall @@ -1,5 +1,4 @@ -let Tilers = ./tilers.dhall let Mode = { modeName : Text, hasButtons : Bool, hasBorders : Bool } let Direction = -let Actions = < Insert | RunCommand : Text | ChangeModeTo : Mode | ShowWindow : Text | HideWindow : Text | ZoomInInput | ZoomInMonitor | ZoomOutInput | ZoomOutMonitor | PopTiler | PushTiler | ChangeNamed : Text | Move : Direction | KillActive | ExitNow | ToggleLogging | ZoomMonitorToInput | ZoomInInputSkip | ZoomOutInputSkip | ZoomInputToMonitor | MoveToFront | MakeEmpty | ChangeToFloating | ChangeToHorizontal | SetFull | SetRotate | SetNoMod | ChangeToTwoCols > +let Actions = < Insert | RunCommand : Text | ChangeModeTo : Mode | ShowWindow : Text | HideWindow : Text | ZoomInInput | ZoomInMonitor | ZoomOutInput | ZoomOutMonitor | PopTiler | PushTiler | ChangeNamed : Text | Move : Direction | KillActive | ExitNow | ToggleLogging | ZoomMonitorToInput | ZoomInputToMonitor | MoveToFront | MakeEmpty | ChangeToFloating | ChangeToHorizontal | SetFull | SetRotate | SetNoMod | ChangeToTwoCols > in {Actions = Actions, Mode = Mode, Direction = Direction} diff --git a/config/tilers.dhall b/config/tilers.dhall deleted file mode 100644 index ed4e968..0000000 --- a/config/tilers.dhall +++ /dev/null @@ -1 +0,0 @@ -< Horizontal | Hovering | Rotate | FullScreen > diff --git a/src/Actions/ActionTypes.hs b/src/Actions/ActionTypes.hs index 5c7ae97..01e43e1 100644 --- a/src/Actions/ActionTypes.hs +++ b/src/Actions/ActionTypes.hs @@ -16,9 +16,7 @@ data Action | ShowWindow String | HideWindow String | ZoomInInput - | ZoomInInputSkip | ZoomOutInput - | ZoomOutInputSkip | ZoomInMonitor | ZoomOutMonitor | ZoomMonitorToInput diff --git a/src/Actions/Actions.hs b/src/Actions/Actions.hs index 5ecd439..c4a2ba2 100644 --- a/src/Actions/Actions.hs +++ b/src/Actions/Actions.hs @@ -34,45 +34,6 @@ import Actions.ActionTypes -- put this in the zoomDirInputSkip where block... type DeferedPath = DeferedListF Tiler Tiler --- | This "smart" zoom function skips past the useless Tilers that would only slow you down. --- Instead of zooming in or out one layer at a time, this function skips over the Tilers you probably --- don't want to stop at. Note the use of probably. You should still bind the non smart versions as backup --- in case you really do want to zoom into something boring. -zoomDirInputSkip - :: Members (States '[Tiler]) r - => (forall a . DeferedList a -> [a]) -- ^ Generally used to decide which side of the deffered list we're interested in - -> Sem r () -- ^ The action to perform for every interesting Tiler in our path - -> Sem r () -zoomDirInputSkip trans action = do - root <- get @Tiler - - replicateM_ - ( numToSkip -- Turns a list of Tilers into a number of things to skip - . trans -- transforms our deffered list into a real one - $ getPath root) -- Creates a deffered list based on the current focussed path - - action -- The second parameter to replicateM_ - - where - -- Turns a tree into a path of focused elements. - -- The InputController marks where the path might want to be split - getPath - :: Tiler - -> DeferedList Tiler - getPath = apo $ \case - InputController t -> - DActiveF $ maybe (Left DNil) (Right . unfix) t - mt@(Monitor t) -> maybe DNilF (DConsF mt . Right . unfix) t - Wrap _ -> DNilF - t -> DConsF t . Right . unfix $ getFocused t - - -- The number of jumps to make. - numToSkip = cata $ \case - Nil -> 1 - Cons (Many _ _) _ -> 1 - Cons (Monitor _) i -> i + 1 - Cons _ i -> i + 1 - -- | Zooms inwards, AKA away from the root. This function operates on -- the Input Controller, not the Monitor. This means that although the layout -- usually won't change, you will change the Tiler that will receive actions @@ -88,8 +49,7 @@ zoomInInput = t -> Fix t --- |Nearly identical to zooming in the input controller. The only --- differene is the Monitor needs to stay behind the input controller. +-- |Nearly identical to zooming in the input controller. zoomInMonitor :: Member (State Tiler) r => Sem r () @@ -101,7 +61,6 @@ zoomInMonitor = -- |Move the input controller towards the root --- This is complicated if the monitor is right behind it zoomOutInput :: Member (State Tiler) r => Sem r () @@ -117,8 +76,6 @@ zoomOutInput = else reduce $ fmap snd t) where - -- Is something the controller? Instead of returning a boolean, we return - -- a function used to construct a controller. isController (Fix (InputController _)) = True isController _ = False @@ -133,7 +90,7 @@ zoomMonitorToInput = Monitor childT -> join childT t -> coerce $ reduce t) --- |A smart zoomer which moves the monitor to wherever the input controller is. +-- |A smart zoomer which moves the input contrell to wherever the monitor is. zoomInputToMonitor :: Member (State Tiler) r => Sem r () @@ -144,7 +101,7 @@ zoomInputToMonitor = InputController childT -> join childT t -> coerce $ reduce t) --- |Very similar to zoomOutInput but less confusing to implement. +-- |Very similar to zoomOutInput. zoomOutMonitor :: Member (State Tiler) r => Sem r () @@ -162,7 +119,7 @@ zoomOutMonitor = where isMonitor (Fix (Monitor _)) = True isMonitor _ = False --- |changes a mode. For example, I have the windows key configured to change +-- |changes a mode. For example, I usually configure the windows key to change -- from Insert mode to Normal mode. changeModeTo :: Members '[State Mode, EventFlags, State KeyStatus] r => Mode -> Sem r () changeModeTo newM = do diff --git a/src/Lib.hs b/src/Lib.hs index 705ed78..5b272a6 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -254,9 +254,7 @@ mainLoop = do ShowWindow wName -> getWindowByClass wName >>= mapM_ restore HideWindow wName -> getWindowByClass wName >>= mapM_ minimize ZoomInInput -> zoomInInput - ZoomInInputSkip -> zoomDirInputSkip undefer zoomInInput ZoomOutInput -> zoomOutInput - ZoomOutInputSkip -> zoomDirInputSkip (fromMaybe [] . tailMay . deferred) zoomOutInput ZoomInMonitor -> zoomInMonitor ZoomOutMonitor -> zoomOutMonitor ZoomMonitorToInput -> zoomMonitorToInput