Separate selection list items from display parameters

This commit is contained in:
2022-12-23 12:22:57 +00:00
parent 6ac4e5d669
commit b072dc9e9a
10 changed files with 141 additions and 132 deletions
+10 -8
View File
@@ -6,19 +6,21 @@ import Dodge.Data.Universe
import LensHelp
import Data.Maybe
setShownSelectionItems :: Configuration -> ScreenLayer -> ScreenLayer
setShownSelectionItems cfig sl = fromMaybe sl $ do
setShownSelectionItems :: ScreenLayer -> ScreenLayer
setShownSelectionItems sl = fromMaybe sl $ do
offset <- sl ^? scOffset
maxlines <- sl ^? scAvailableLines
return $ sl & scSelectionList %~ setShownSelectionItems' maxlines offset
return $ setShownSelectionItems' maxlines offset sl
setShownSelectionItems' :: Int -> Int -> SelectionList -> SelectionList
setShownSelectionItems' maxlines offset sl = case sl ^? slSizeRestriction of
setShownSelectionItems' :: Int -> Int -> ScreenLayer -> ScreenLayer
setShownSelectionItems' maxlines offset sl = case sl ^? scListDisplayParams . ldpSizeRestriction of
Just (SelectionSizeRestriction botit)
| length allitems > maxlines ->
sl & slShownItems .~ take (maxlines - 2) (drop offset allitems) -- ++ repeat dummyitem))
sl & scShownItems .~ take (maxlines - 2) (drop offset allitems) -- ++ repeat dummyitem))
++ [(botit,ScrollSelectionItem)]
_ -> sl & slShownItems .~ allitems
& scSelectionList . slItems .~ map fst ( take (maxlines - 2) (drop offset allitems) -- ++ repeat dummyitem))
++ [(botit,ScrollSelectionItem)])
_ -> sl & scShownItems .~ allitems
where
-- dummyitem = (SelectionItem [] 1 False 0 white 0, DummySelectionItem)
allitems = zipWith (\x y -> (x,ListedSelectionItem y)) (sl ^. slItems) [0..]
allitems = zipWith (\x y -> (x,ListedSelectionItem y)) (sl ^. scSelectionList . slItems) [0..]