EventTrigger: Static -> ByKey

This commit is contained in:
Jonathan Daugherty 2022-07-10 13:59:27 -07:00
parent 456da00fa9
commit 63a4083391
2 changed files with 6 additions and 5 deletions

View File

@ -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.

View File

@ -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