diff options
| author | Josh Rahm <rahm@google.com> | 2022-04-08 14:41:34 -0600 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2022-10-09 12:19:46 -0600 |
| commit | 401b293fe6a726d24cf944e626c301262d726aad (patch) | |
| tree | 6c459c551fea6b2d3c813a2d66126b0478717736 /src/Internal/LayoutZipper.hs | |
| parent | a1736a26f48c95574a682c260a311ef379e96352 (diff) | |
| download | rde-401b293fe6a726d24cf944e626c301262d726aad.tar.gz rde-401b293fe6a726d24cf944e626c301262d726aad.tar.bz2 rde-401b293fe6a726d24cf944e626c301262d726aad.zip | |
Cleanup and more documentation.
Diffstat (limited to 'src/Internal/LayoutZipper.hs')
| -rw-r--r-- | src/Internal/LayoutZipper.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Internal/LayoutZipper.hs b/src/Internal/LayoutZipper.hs index d31360b..787fe4f 100644 --- a/src/Internal/LayoutZipper.hs +++ b/src/Internal/LayoutZipper.hs @@ -29,7 +29,11 @@ layoutZipper = LayoutZipper 0 nil :: LNil a nil = LNil -data NavigateLayout = ToNextLayout | ToPreviousLayout deriving (Typeable, Show) +data NavigateLayout = + ToNextLayout | + ToPreviousLayout | + SetLayout Int + deriving (Typeable, Show) instance Message NavigateLayout where class LayoutSelect l a where @@ -85,6 +89,9 @@ instance (Show (l a), Typeable l, LayoutSelect l a) => LayoutClass (LayoutZipper if idx > 0 then return $ Just (LayoutZipper (idx - 1) l) else return $ Just (LayoutZipper (nLayouts l - 1) l) + handleMessage (LayoutZipper _ l) (fromMessage -> Just (SetLayout i)) = + return $ Just $ LayoutZipper (max 0 $ min (nLayouts l - 1) $ i) l + handleMessage (LayoutZipper idx l) m = do r <- update idx l $ \layout -> ((),) <$> handleMessage layout m return $ LayoutZipper idx . snd <$> r |