diff options
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 |