mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-09-11 23:57:22 +03:00
reverseKeyMappings -> keyEventMappings
This commit is contained in:
parent
7b25cd1311
commit
9cc2d5eafb
@ -202,7 +202,7 @@ main = do
|
||||
-- 'dialog-box-okay' and 'dialog-box-cancel' that were intended to
|
||||
-- be handled in the same mode, we might want to check that those
|
||||
-- two events did not have the same binding.
|
||||
forM_ (K.reverseKeyMappings kc) $ \(b, evs) -> do
|
||||
forM_ (K.keyEventMappings kc) $ \(b, evs) -> do
|
||||
when (S.size evs > 1) $ do
|
||||
Text.putStrLn $ "Error: key '" <> K.ppBinding b <> "' is bound to multiple events:"
|
||||
forM_ evs $ \e ->
|
||||
|
@ -9,7 +9,7 @@
|
||||
-- is the application author's responsibility to check for collisions
|
||||
-- since the nature of the collisions will depend on how the application
|
||||
-- is implemented. To check for collisions, use the result of
|
||||
-- 'reverseKeyMappings'.
|
||||
-- 'keyEventMappings'.
|
||||
module Brick.Keybindings.KeyConfig
|
||||
( KeyConfig
|
||||
, newKeyConfig
|
||||
@ -29,7 +29,7 @@ module Brick.Keybindings.KeyConfig
|
||||
, firstActiveBinding
|
||||
, allDefaultBindings
|
||||
, allActiveBindings
|
||||
, reverseKeyMappings
|
||||
, keyEventMappings
|
||||
|
||||
-- * Misc
|
||||
, keyConfigEvents
|
||||
@ -139,14 +139,14 @@ newKeyConfig evs defaults bindings =
|
||||
, keyConfigDefaultBindings = M.fromList defaults
|
||||
}
|
||||
|
||||
-- | Return a list of reverse mappings including each key bound to any
|
||||
-- event combined with the list of events to which it is bound. This is
|
||||
-- useful for identifying problematic key binding collisions. Since key
|
||||
-- binding collisions cannot be determined in general, we leave it up to
|
||||
-- the application author to determine which key-to-event bindings are
|
||||
-- | Return a list of mappings including each key bound to any event
|
||||
-- combined with the list of events to which it is bound. This is useful
|
||||
-- for identifying problematic key binding collisions. Since key binding
|
||||
-- collisions cannot be determined in general, we leave it up to the
|
||||
-- application author to determine which key-to-event bindings are
|
||||
-- problematic.
|
||||
reverseKeyMappings :: (Ord k, Eq k) => KeyConfig k -> [(Binding, S.Set k)]
|
||||
reverseKeyMappings kc = M.toList resultMap
|
||||
keyEventMappings :: (Ord k, Eq k) => KeyConfig k -> [(Binding, S.Set k)]
|
||||
keyEventMappings kc = M.toList resultMap
|
||||
where
|
||||
-- Get all default bindings
|
||||
defaultBindings = M.toList $ keyConfigDefaultBindings kc
|
||||
|
@ -16,7 +16,7 @@
|
||||
-- within the program or load them from an INI file with routines like
|
||||
-- 'Brick.Keybindings.Parse.keybindingsFromFile'.
|
||||
-- * Optionally check for keybinding collisions with
|
||||
-- 'Brick.Keybindings.KeyConfig.reverseKeyMappings'.
|
||||
-- 'Brick.Keybindings.KeyConfig.keyEventMappings'.
|
||||
-- * Implement application event handlers that will be run in response
|
||||
-- to either specific hard-coded keys or events @k@, both in some
|
||||
-- monad @m@ of your choosing, using constructors 'onKey' and
|
||||
|
Loading…
Reference in New Issue
Block a user