Work on menus
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
module Dodge.SelectionList where
|
||||
|
||||
import Dodge.Data.SelectionList
|
||||
import LensHelp
|
||||
|
||||
setShownSelectionItems :: SelectionList -> SelectionList
|
||||
setShownSelectionItems sl = case sl ^? slSizeRestriction of
|
||||
Just (SelectionSizeRestriction maxlines topit botit _)
|
||||
| length allitems <= maxlines -> sl & slShownItems .~ allitems
|
||||
| otherwise -> if offset > 0
|
||||
then sl & slShownItems .~ ((topit,ScrollUpSelectionItem) : take (maxlines - 2) (drop offset allitems))
|
||||
else sl & slShownItems .~ (take (maxlines - 2) allitems ++ [(botit,ScrollDownSelectionItem)])
|
||||
_ -> sl & slShownItems .~ allitems
|
||||
where
|
||||
offset = sl ^. slOffset
|
||||
allitems = zipWith (\x y -> (x,ListedSelectionItem y)) (sl ^. slItems) [0..]
|
||||
Reference in New Issue
Block a user