brick-2.9: A declarative terminal user interface library

Safe Haskell | Safe-Inferred
Language | Haskell2010

Brick.Keybindings.KeyEvents

Description

This module provides `KeyEvents`, a data type for mapping application-defined abstract events to user-facing names (e.g. for use in configuration files and documentation). This data structure gives you a place to define the correspondence between your application's key events and their names. A `KeyEvents` also effectively tells the key binding system about the collection of possible abstract events that can be handled.

A `KeyEvents` is used to construct a `KeyConfig` with `newKeyConfig`.

Synopsis

- data KeyEvents k
- keyEvents :: Ord k => [(Text, k)] -> KeyEvents k
- keyEventsList :: KeyEvents k -> [(Text, k)]
- lookupKeyEvent :: Ord k => KeyEvents k -> Text -> Maybe k
- keyEventName :: Ord k => KeyEvents k -> k -> Maybe Text

# Documentation

data KeyEvents k Source #

A bidirectional mapping between events `k` and their user-readable names.

#### Instances

Instances details

Show k => Show (KeyEvents k) Source # |
Instance details Defined in Brick.Keybindings.KeyEvents Methods showsPrec :: Int -> KeyEvents k -> ShowS Source # show :: KeyEvents k -> String Source # showList :: [KeyEvents k] -> ShowS Source #
Eq k => Eq (KeyEvents k) Source # |
Instance details Defined in Brick.Keybindings.KeyEvents Methods (==) :: KeyEvents k -> KeyEvents k -> Bool Source # (/=) :: KeyEvents k -> KeyEvents k -> Bool Source #

keyEvents :: Ord k => [(Text, k)] -> KeyEvents k Source #

Build a new `KeyEvents` map from the specified list of events and names. Key event names are stored in lowercase.

Calls `error` if any events have the same name (ignoring case) or if multiple names map to the same event.

keyEventsList :: KeyEvents k -> [(Text, k)] Source #

Convert the `KeyEvents` to a list.

lookupKeyEvent :: Ord k => KeyEvents k -> Text -> Maybe k Source #

Look up the specified event name to get its abstract event. The lookup ignores leading and trailing whitespace as well as case.

keyEventName :: Ord k => KeyEvents k -> k -> Maybe Text Source #

Given an abstract event, get its event name.