From 6466c4e99db2780853ca1504c12995e307de8ff9 Mon Sep 17 00:00:00 2001 From: Jonathan Daugherty Date: Sun, 10 Jul 2022 13:56:41 -0700 Subject: [PATCH] keyHandlersFromConfig: cleanup --- src/Brick/Keybindings/KeyHandlerMap.hs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Brick/Keybindings/KeyHandlerMap.hs b/src/Brick/Keybindings/KeyHandlerMap.hs index a2a9db2..c283156 100644 --- a/src/Brick/Keybindings/KeyHandlerMap.hs +++ b/src/Brick/Keybindings/KeyHandlerMap.hs @@ -106,14 +106,13 @@ keyHandlersFromConfig :: (Ord e) -> KeyEventHandler e m -> [KeyHandler e m] keyHandlersFromConfig kc eh = - case kehEventTrigger eh of - Static binding -> - [ KH eh binding ] - ByEvent ev -> - [ KH eh b | b <- allBindings ] - where allBindings | Just (BindingList ks) <- lookupKeyConfigBindings kc ev = ks - | Just Unbound <- lookupKeyConfigBindings kc ev = [] - | otherwise = allDefaultBindings kc ev + let allBindingsFor ev | Just (BindingList ks) <- lookupKeyConfigBindings kc ev = ks + | Just Unbound <- lookupKeyConfigBindings kc ev = [] + | otherwise = allDefaultBindings kc ev + bindings = case kehEventTrigger eh of + Static binding -> [binding] + ByEvent ev -> allBindingsFor ev + in [ KH eh b | b <- bindings ] mkHandler :: T.Text -> m () -> Handler m mkHandler msg action =