From 63a408339190a6cb9ba31d8aef4bd9a1ff45f6e4 Mon Sep 17 00:00:00 2001 From: Jonathan Daugherty Date: Sun, 10 Jul 2022 13:59:27 -0700 Subject: [PATCH] EventTrigger: Static -> ByKey --- src/Brick/Keybindings/KeyHandlerMap.hs | 8 ++++---- src/Brick/Keybindings/Pretty.hs | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Brick/Keybindings/KeyHandlerMap.hs b/src/Brick/Keybindings/KeyHandlerMap.hs index dbffa54..9df0c5e 100644 --- a/src/Brick/Keybindings/KeyHandlerMap.hs +++ b/src/Brick/Keybindings/KeyHandlerMap.hs @@ -110,8 +110,8 @@ keyHandlersFromConfig kc eh = | Just Unbound <- lookupKeyConfigBindings kc ev = [] | otherwise = allDefaultBindings kc ev bindings = case kehEventTrigger eh of - Static binding -> [binding] - ByEvent ev -> allBindingsFor ev + ByKey binding -> [binding] + ByEvent ev -> allBindingsFor ev in [ KH { khHandler = eh, khKey = b } | b <- bindings ] mkHandler :: T.Text -> m () -> Handler m @@ -144,12 +144,12 @@ onKey :: (ToBinding a) -> KeyEventHandler e m onKey b msg action = KEH { kehHandler = mkHandler msg action - , kehEventTrigger = Static $ toBinding b + , kehEventTrigger = ByKey $ toBinding b } -- | A trigger for an event handler. data EventTrigger e = - Static Binding + ByKey Binding -- ^ The key event is always triggered by a specific key. | ByEvent e -- ^ The trigger is an abstract key event. diff --git a/src/Brick/Keybindings/Pretty.hs b/src/Brick/Keybindings/Pretty.hs index 91041e4..95ba3cb 100644 --- a/src/Brick/Keybindings/Pretty.hs +++ b/src/Brick/Keybindings/Pretty.hs @@ -88,7 +88,8 @@ mkKeybindEventHelp kc h = let trig = kehEventTrigger h unbound = [Comment "(unbound)"] (label, evText) = case trig of - Static binding -> (Comment "(non-customizable key)", [Verbatim $ ppBinding binding]) + ByKey binding -> + (Comment "(non-customizable key)", [Verbatim $ ppBinding binding]) ByEvent ev -> let name = fromJust $ keyEventName (keyConfigEvents kc) ev in case lookupKeyConfigBindings kc ev of