No recalc of length of list
This commit is contained in:
parent
787222d067
commit
2e351da399
@ -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 ()
|
||||
|
Loading…
Reference in New Issue
Block a user