List: add support for Home/End keys

This commit is contained in:
Jonathan Daugherty 2015-08-20 08:46:05 -07:00
parent 1950bc01de
commit 717186ef5e

View File

@ -54,6 +54,8 @@ import Brick.AttrMap
-- * Up/down arrow keys: move cursor of selected item
-- * Page up / page down keys: move cursor of selected item by one page
-- at a time (based on the number of items shown)
-- * Home/end keys: move cursor of selected item to beginning or end of
-- list
data List e =
List { listElements :: !(V.Vector e)
, listSelected :: !(Maybe Int)
@ -69,6 +71,8 @@ instance HandleEvent (List e) where
f = case e of
EvKey KUp [] -> return $ listMoveUp theList
EvKey KDown [] -> return $ listMoveDown theList
EvKey KHome [] -> return $ listMoveTo 0 theList
EvKey KEnd [] -> return $ listMoveTo (length $ listElements theList) theList
EvKey KPageDown [] -> do
v <- lookupViewport (theList^.listNameL)
case v of