diff options
author | Kierán Meinhardt <kieran.meinhardt@gmail.com> | 2020-09-22 23:37:06 +0200 |
---|---|---|
committer | Kierán Meinhardt <kieran.meinhardt@gmail.com> | 2020-09-22 23:37:06 +0200 |
commit | 121d703bcd3ecbaba031499070907251b5eae1a9 (patch) | |
tree | 40ad272443c65ac68c0e3ddd38d23c543ef6c78c | |
parent | c7fc18648a6fe295d14284cb491b9ea2d1a28cac (diff) |
Action: add openFold and closeFold
-rw-r--r-- | Action.hs | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -134,18 +134,26 @@ moveCursorDownToNextUnread = moveCursorToUnread findNext botOverrun moveTreeUp -toggleFold :: State -> IO State -toggleFold q@State{..} = - getNewSubForest >>= return . \case +openFold :: State -> IO State +openFold q@State{..} = + handle <$> loadSubForest (Z.label cursor) + where + handle = \case Left err -> q { flashMessage = SGR [31] $ Plain err } Right sf -> q { cursor = Z.modifyTree (setSubForest sf) cursor } - where - getNewSubForest = - if hasUnloadedSubForest (Z.tree cursor) - then loadSubForest (Z.label cursor) - else return $ Right $ unloadSubForest (Z.tree cursor) + +closeFold :: State -> IO State +closeFold q@State{..} = + let sf = unloadSubForest (Z.tree cursor) + in return q { cursor = Z.modifyTree (setSubForest sf) cursor } + +toggleFold :: State -> IO State +toggleFold q@State{..} = + if hasUnloadedSubForest (Z.tree cursor) + then openFold q + else closeFold q toggleTagAtCursor :: Tag -> State -> IO State |