From 787222d067b8b246cd7827c53a3fcf582abe1490 Mon Sep 17 00:00:00 2001 From: pingu Date: Tue, 17 Oct 2023 14:09:29 +0200 Subject: [PATCH] A bit more clean --- app/Main.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 4f4de4d..c651578 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -80,7 +80,7 @@ app :: App AppS e () app = App { appDraw = pure . browse , appHandleEvent = eventHandler - , appStartEvent = pure () + , appStartEvent = put =<< liftIO . changeDir =<< get , appAttrMap = attributeMap , appChooseCursor = showFirstCursor } @@ -174,7 +174,7 @@ scroll d s = s { case d of SUp -> (-1) SDown -> 1 - newCursor = max 0 (min (subtract 1 . length $ appSubFiles s) cursor) + newCursor = clamp 0 (subtract 1 . length $ appSubFiles s) cursor maybeNewPath = fst <$> appSubFiles s !? newCursor eventHandler :: BrickEvent () e -> EventM () AppS () @@ -219,6 +219,5 @@ main :: IO () main = do a <- getWorkingDirectory b <- newIORef =<< empty - c <- changeDir $ initialState a b - _ <- defaultMain app c + _ <- defaultMain app $ initialState a b return ()