Change selection set to work for multiple sections
This commit is contained in:
@@ -16,7 +16,6 @@ import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Foldable
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.IntSet as IS
|
||||
import Data.Maybe
|
||||
import Dodge.Data.CardinalPoint
|
||||
import Dodge.Data.Config
|
||||
@@ -28,13 +27,8 @@ import Geometry.Data
|
||||
scrollSelectionSections :: Int -> IMSS a -> Maybe Selection -> Maybe Selection
|
||||
scrollSelectionSections yi sss msel
|
||||
| yi == 0 = msel
|
||||
| yi > 0 = g $ foldl' (&) msel $ replicate yi (ssScrollUsing ssLookupUp sss)
|
||||
| otherwise = g $ foldl' (&) msel $ replicate (negate yi) (ssScrollUsing ssLookupDown sss)
|
||||
where
|
||||
g msel'
|
||||
| msel'^?_Just.slSec /= msel^?_Just.slSec
|
||||
= msel'&_Just.slSet.~IS.empty
|
||||
| otherwise = msel'
|
||||
| yi > 0 = foldl' (&) msel $ replicate yi (ssScrollUsing ssLookupUp sss)
|
||||
| otherwise = foldl' (&) msel $ replicate (negate yi) (ssScrollUsing ssLookupDown sss)
|
||||
|
||||
nextInSectionSS :: IMSS a -> Maybe Selection -> Maybe Selection
|
||||
nextInSectionSS = ssScrollUsing ssLookupNextMax
|
||||
@@ -52,11 +46,11 @@ ssScrollMinOnFail ::
|
||||
IMSS a ->
|
||||
Maybe Selection ->
|
||||
Maybe Selection
|
||||
ssScrollMinOnFail f sss msel = fmap (\(i, j, _) -> Sel i j q) $ l <|> ssLookupMin sss
|
||||
ssScrollMinOnFail f sss msel = fmap (\(i, j, _) -> Sel i j) $ l <|> ssLookupMin sss
|
||||
where
|
||||
q = fold (msel ^? _Just . slSet)
|
||||
-- q = fold (msel ^? _Just . slSet)
|
||||
l = do
|
||||
Sel i j _ <- msel
|
||||
Sel i j <- msel
|
||||
f i j sss
|
||||
|
||||
---- this version removes the selected set when scrolling outside it
|
||||
@@ -81,12 +75,15 @@ ssSetCursor ::
|
||||
Maybe Selection ->
|
||||
Maybe Selection
|
||||
ssSetCursor f sss msel = fromMaybe msel $ do
|
||||
(i, j, _) <- f sss
|
||||
let newxs = fromMaybe mempty $ do
|
||||
Sel k _ xs <- msel
|
||||
guard $ k == i && j `IS.member` xs
|
||||
return xs
|
||||
return $ Just (Sel i j newxs)
|
||||
(i,j,_) <- f sss
|
||||
return $ Just (Sel i j)
|
||||
-- = fromMaybe msel $ do
|
||||
-- (i, j, _) <- f sss
|
||||
-- let newxs = fromMaybe mempty $ do
|
||||
-- Sel k _ xs <- msel
|
||||
-- guard $ k == i && j `IS.member` xs
|
||||
-- return xs
|
||||
-- return $ Just (Sel i j newxs)
|
||||
|
||||
ssLookupMax :: IMSS a -> Maybe (Int, Int, SelectionItem a)
|
||||
ssLookupMax sss = do
|
||||
|
||||
Reference in New Issue
Block a user