From 2e351da39947485ee750b1106f54ba1d72ab3a18 Mon Sep 17 00:00:00 2001 From: thepenguin Date: Wed, 18 Oct 2023 14:50:45 +0200 Subject: [PATCH] No recalc of length of list --- app/Main.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Main.hs b/app/Main.hs index c651578..a0a0383 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -72,6 +72,7 @@ data AppS = AppS , appCursor :: Int , appFocus :: Maybe FilePath , appSubFiles :: [(FilePath, Integer)] + , appLenSub :: Int , appMemo :: IORef (IOHashMap FilePath [(FilePath, Integer)]) , appRoot :: FilePath } @@ -133,6 +134,7 @@ sizeDir s = do appCursor = 0 , appFocus = map fst subFiles !? 0 , appSubFiles = subFiles + , appLenSub = length subFiles } changeDir :: AppS -> IO AppS @@ -162,6 +164,7 @@ overDir s = do , appCursor = 0 , appFocus = pure a , appSubFiles = [] + , appLenSub = 0 } scroll :: ScrollDirection -> AppS -> AppS @@ -174,7 +177,7 @@ scroll d s = s { case d of SUp -> (-1) SDown -> 1 - newCursor = clamp 0 (subtract 1 . length $ appSubFiles s) cursor + newCursor = clamp 0 (subtract 1 $ appLenSub s) cursor maybeNewPath = fst <$> appSubFiles s !? newCursor eventHandler :: BrickEvent () e -> EventM () AppS () @@ -213,6 +216,7 @@ initialState f i = , appSubFiles = [] , appMemo = i , appRoot = f + , appLenSub = 0 } main :: IO ()