make menu input case insensitive
This commit is contained in:
parent
0798786d36
commit
79f8df50a0
|
@ -30,6 +30,7 @@ module Mtlstats.Menu (
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.Trans.State (modify)
|
import Control.Monad.Trans.State (modify)
|
||||||
|
import Data.Char (toUpper)
|
||||||
import Lens.Micro ((^.), (.~), (?~))
|
import Lens.Micro ((^.), (.~), (?~))
|
||||||
import qualified UI.NCurses as C
|
import qualified UI.NCurses as C
|
||||||
|
|
||||||
|
@ -46,10 +47,10 @@ drawMenu m = do
|
||||||
-- | The event handler for a 'Menu'
|
-- | The event handler for a 'Menu'
|
||||||
menuHandler :: Menu a -> C.Event -> Action a
|
menuHandler :: Menu a -> C.Event -> Action a
|
||||||
menuHandler m (C.EventCharacter c) =
|
menuHandler m (C.EventCharacter c) =
|
||||||
case filter (\i -> i ^. miKey == c) $ m ^. menuItems of
|
case filter (\i -> i^.miKey == toUpper c) $ m^.menuItems of
|
||||||
i:_ -> i ^. miAction
|
i:_ -> i^.miAction
|
||||||
[] -> return $ m ^. menuDefault
|
[] -> return $ m^.menuDefault
|
||||||
menuHandler m _ = return $ m ^. menuDefault
|
menuHandler m _ = return $ m^.menuDefault
|
||||||
|
|
||||||
-- | The main menu
|
-- | The main menu
|
||||||
mainMenu :: Menu Bool
|
mainMenu :: Menu Bool
|
||||||
|
|
Loading…
Reference in New Issue
Block a user