This commit is contained in:
2023-01-16 00:16:12 +00:00
parent 048135c370
commit bb72ec9baa
6 changed files with 45 additions and 60 deletions
+10 -2
View File
@@ -30,7 +30,7 @@ moveSelectionMapStep :: Int -> SelectionIntMap a -> SelectionIntMap a
moveSelectionMapStep x sm = fromMaybe sm $ do
i <- _smSelPos sm
(n,_) <- IM.lookupMax (sm ^. smShownItems)
let j = (i + x) `mod` (n + 1)
let j = (i - x) `mod` (n + 1)
case sm ^? smShownItems . ix j . siIsSelectable of
Just True -> Just $ sm & smSelPos ?~ j
_ -> Just $ moveSelectionMapStep x (sm & smSelPos ?~ j)
@@ -38,6 +38,14 @@ moveSelectionMapStep x sm = fromMaybe sm $ do
moveSelectionMapSelection :: Int -> SelectionIntMap a -> SelectionIntMap a
moveSelectionMapSelection i sm = foldl'
(&)
sm
sm
(replicate (abs i) (moveSelectionMapStep (signum i)))
getIthPos :: Int -> IM.IntMap (SelectionItem a) -> Int
getIthPos i sm = sum . fmap _siHeight . fst $ IM.split i sm
getIthYOffset :: Float -> Float -> SelectionIntMap a -> Int -> Float
getIthYOffset ygap scale sm i = (scale * 10 + ygap) * (fromIntegral yint + 1)
where
yint = getIthPos i (sm ^. smShownItems)