Tweak combine filtering

This commit is contained in:
2023-01-16 00:57:55 +00:00
parent bb72ec9baa
commit 43e3c1fe4c
6 changed files with 35 additions and 12 deletions
+11 -4
View File
@@ -24,6 +24,11 @@ setShownIntMap sm = case sm ^. smRegex of
, _siOffX = 0
}
initialSelPos :: SelectionIntMap a -> SelectionIntMap a
initialSelPos sm = sm & smSelPos .~ mi
where
mi = fst <$> ifind (const _siIsSelectable) (sm ^. smShownItems)
-- assumes that at least one item is selectable!
-- also assumes that the integer is 1 or -1
moveSelectionMapStep :: Int -> SelectionIntMap a -> SelectionIntMap a
@@ -36,10 +41,12 @@ moveSelectionMapStep x sm = fromMaybe sm $ do
_ -> Just $ moveSelectionMapStep x (sm & smSelPos ?~ j)
moveSelectionMapSelection :: Int -> SelectionIntMap a -> SelectionIntMap a
moveSelectionMapSelection i sm = foldl'
(&)
sm
(replicate (abs i) (moveSelectionMapStep (signum i)))
moveSelectionMapSelection i sm
| any _siIsSelectable (sm ^. smShownItems) = foldl'
(&)
sm
(replicate (abs i) (moveSelectionMapStep (signum i)))
| otherwise = sm & smSelPos .~ Nothing
getIthPos :: Int -> IM.IntMap (SelectionItem a) -> Int
getIthPos i sm = sum . fmap _siHeight . fst $ IM.split i sm