Separate selection list items from display parameters
This commit is contained in:
@@ -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..]
|
||||
|
||||
Reference in New Issue
Block a user