Cleanup
This commit is contained in:
@@ -3,7 +3,7 @@ module Dodge.SelectionSections (
|
||||
ssLookupDown,
|
||||
ssLookupGT,
|
||||
ssSetCursor,
|
||||
-- setFirstPosSelectionSections,
|
||||
-- setFirstPosSelectionSections,
|
||||
selSecYint,
|
||||
selSecSelSize,
|
||||
inverseSelSecYint,
|
||||
@@ -23,13 +23,17 @@ import Dodge.Data.Config
|
||||
import Dodge.Data.SelectionList
|
||||
import Dodge.ScreenPos
|
||||
import Geometry.Data
|
||||
import Data.Foldable
|
||||
|
||||
scrollSelectionSections :: Int -> SelectionSections a -> Maybe (Int,Int)
|
||||
-> Maybe (Int,Int)
|
||||
scrollSelectionSections ::
|
||||
Int ->
|
||||
SelectionSections a ->
|
||||
Maybe (Int, Int) ->
|
||||
Maybe (Int, Int)
|
||||
scrollSelectionSections yi sss msel
|
||||
| yi == 0 = msel
|
||||
| yi > 0 = foldr ($) msel $ replicate yi (ssScrollUsing ssLookupUp sss)
|
||||
| otherwise = foldr ($) msel $ replicate (negate yi) (ssScrollUsing ssLookupDown sss)
|
||||
| yi > 0 = foldl' (&) msel $ replicate yi (ssScrollUsing ssLookupUp sss)
|
||||
| otherwise = foldl' (&) msel $ replicate (negate yi) (ssScrollUsing ssLookupDown sss)
|
||||
|
||||
--setFirstPosSelectionSections :: SelectionSections a -> SelectionSections a
|
||||
--setFirstPosSelectionSections sss = fromMaybe sss $ do
|
||||
@@ -39,21 +43,15 @@ scrollSelectionSections yi sss msel
|
||||
ssScrollUsing ::
|
||||
(Int -> Int -> SelectionSections a -> Maybe (Int, Int, SelectionItem a)) ->
|
||||
SelectionSections a ->
|
||||
Maybe (Int,Int) ->
|
||||
Maybe (Int,Int)
|
||||
ssScrollUsing g sss msel =
|
||||
( ssScrollMinOnFail
|
||||
g
|
||||
(sss & sssSections %~ fmap (ssItems %~ IM.filter _siIsSelectable))
|
||||
msel
|
||||
)
|
||||
Maybe (Int, Int) ->
|
||||
Maybe (Int, Int)
|
||||
ssScrollUsing g =
|
||||
ssScrollMinOnFail
|
||||
g
|
||||
. (sssSections %~ fmap (ssItems %~ IM.filter _siIsSelectable))
|
||||
|
||||
ssScrollMinOnFail ::
|
||||
( Int ->
|
||||
Int ->
|
||||
SelectionSections a ->
|
||||
Maybe (Int, Int, SelectionItem a)
|
||||
) ->
|
||||
(Int -> Int -> SelectionSections a -> Maybe (Int, Int, SelectionItem a)) ->
|
||||
SelectionSections a ->
|
||||
Maybe (Int, Int) ->
|
||||
Maybe (Int, Int)
|
||||
@@ -66,8 +64,8 @@ ssScrollMinOnFail f sss msel = fmap (\(i, j, _) -> (i, j)) $ l <|> ssLookupMin s
|
||||
ssSetCursor ::
|
||||
(SelectionSections a -> Maybe (Int, Int, SelectionItem a)) ->
|
||||
SelectionSections a ->
|
||||
Maybe (Int,Int) ->
|
||||
Maybe (Int,Int)
|
||||
Maybe (Int, Int) ->
|
||||
Maybe (Int, Int)
|
||||
ssSetCursor f sss msel = fromMaybe msel $ do
|
||||
(i, j, _) <- f sss
|
||||
return $ Just (i, j)
|
||||
@@ -205,7 +203,7 @@ inverseSelBoundaryUp cfig ldp sss (V2 _ y) = do
|
||||
let mselup = inverseSelSecYint (posSelSecYint cfig ldp y - 1) sss
|
||||
if Just sel == mselup
|
||||
then return $ sel & _2 +~ 1
|
||||
else return $ sel
|
||||
else return sel
|
||||
|
||||
inverseSelBoundaryDown ::
|
||||
Configuration ->
|
||||
|
||||
Reference in New Issue
Block a user