| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Brick.Keybindings.KeyConfig
Description
This module provides KeyConfig and associated functions. A
KeyConfig is the basis for the custom keybinding system in this
library.
To get started, see newKeyConfig. Once a KeyConfig has been
constructed, see keyDispatcher.
Synopsis
- data KeyConfig k
- newKeyConfig :: Ord k => KeyEvents k -> [(k, [Binding])] -> [(k, BindingState)] -> KeyConfig k
- data BindingState
- = BindingList [Binding]
- | Unbound
- data Binding = Binding {}
- class ToBinding a where
- binding :: Key -> [Modifier] -> Binding
- fn :: Int -> Binding
- meta :: ToBinding a => a -> Binding
- ctrl :: ToBinding a => a -> Binding
- shift :: ToBinding a => a -> Binding
- firstDefaultBinding :: (Show k, Ord k) => KeyConfig k -> k -> Maybe Binding
- firstActiveBinding :: (Show k, Ord k) => KeyConfig k -> k -> Maybe Binding
- allDefaultBindings :: Ord k => KeyConfig k -> k -> [Binding]
- allActiveBindings :: (Show k, Ord k) => KeyConfig k -> k -> [Binding]
- keyConfigEvents :: KeyConfig k -> KeyEvents k
- lookupKeyConfigBindings :: Ord k => KeyConfig k -> k -> Maybe BindingState
Documentation
A configuration of custom key bindings. A KeyConfig
stores everything needed to resolve a key event into one or
more key bindings. Make a KeyConfig with newKeyConfig,
then use it to dispatch to KeyEventHandlers with
keyDispatcher.
Make a new KeyConfig with newKeyConfig.
A KeyConfig stores:
- A collection of named key events, mapping the event type
ktoTextlabels. - For each event
k, optionally store a list of default key bindings for that event. - An optional customized binding list for each event, setting the
event to either
Unboundor providing explicit overridden bindings withBindingList.
Arguments
| :: Ord k | |
| => KeyEvents k | The base mapping of key events and names to use. |
| -> [(k, [Binding])] | Default bindings by key event, such as from a configuration file or embedded code. Optional on a per-event basis. |
| -> [(k, BindingState)] | Custom bindings by key event, such as from a
configuration file. Explicitly setting an event to
|
| -> KeyConfig k |
data BindingState Source #
An explicit configuration of key bindings for a key event.
Constructors
| BindingList [Binding] | Bind the event to the specified list of bindings. |
| Unbound | Disable all bindings for the event, including default bindings. |
Instances
| Eq BindingState Source # | |
Defined in Brick.Keybindings.KeyConfig | |
| Ord BindingState Source # | |
Defined in Brick.Keybindings.KeyConfig Methods compare :: BindingState -> BindingState -> Ordering # (<) :: BindingState -> BindingState -> Bool # (<=) :: BindingState -> BindingState -> Bool # (>) :: BindingState -> BindingState -> Bool # (>=) :: BindingState -> BindingState -> Bool # max :: BindingState -> BindingState -> BindingState # min :: BindingState -> BindingState -> BindingState # | |
| Show BindingState Source # | |
Defined in Brick.Keybindings.KeyConfig Methods showsPrec :: Int -> BindingState -> ShowS # show :: BindingState -> String # showList :: [BindingState] -> ShowS # | |
Specifying bindings
A key binding.
The easiest way to express Bindings is to use the helper functions
in this module that work with instances of ToBinding, e.g.
let ctrlB =ctrl'b' shiftX =shift'x' ctrlMetaK =ctrl$meta'k' -- Or with Vty keys directly: ctrlDown =ctrlKDown
class ToBinding a where Source #
The class of types that can form the basis of Bindings.
This is provided to make it easy to write and modify bindings in less verbose ways.
Querying KeyConfigs
firstDefaultBinding :: (Show k, Ord k) => KeyConfig k -> k -> Maybe Binding Source #
A convenience function to return the first result of
allDefaultBindings, if any.
firstActiveBinding :: (Show k, Ord k) => KeyConfig k -> k -> Maybe Binding Source #
A convenience function to return the first result of
allActiveBindings, if any.
allDefaultBindings :: Ord k => KeyConfig k -> k -> [Binding] Source #
Returns the list of default bindings for the specified event,
irrespective of whether the event has been explicitly configured with
other bindings or set to Unbound.
Misc
keyConfigEvents :: KeyConfig k -> KeyEvents k Source #
The base mapping of events and their names that is used in this configuration.
lookupKeyConfigBindings :: Ord k => KeyConfig k -> k -> Maybe BindingState Source #
Look up the binding state for the specified event. This returns
Nothing when the event has no explicitly configured custom
BindingState.