Improve mouse menu controls, tweak charmap

This commit is contained in:
2022-12-21 11:33:11 +00:00
parent 860d63df45
commit 03c945d189
12 changed files with 68 additions and 50 deletions
+7 -4
View File
@@ -1,16 +1,19 @@
module Dodge.SelectionList where
--import Color
import Dodge.Data.SelectionList
import LensHelp
setShownSelectionItems :: SelectionList -> SelectionList
setShownSelectionItems sl = case sl ^? slSizeRestriction of
Just (SelectionSizeRestriction maxlines topit botit _)
Just (SelectionSizeRestriction maxlines _ 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)])
-- | offset > length allitems + 3 - maxlines -> sl
| otherwise ->
sl & slShownItems .~ take (maxlines - 2) (drop offset allitems) -- ++ repeat dummyitem))
++ [(botit,ScrollDownSelectionItem)]
_ -> sl & slShownItems .~ allitems
where
-- dummyitem = (SelectionItem [] 1 False 0 white 0, DummySelectionItem)
offset = sl ^. slOffset
allitems = zipWith (\x y -> (x,ListedSelectionItem y)) (sl ^. slItems) [0..]