brick-1.4: A declarative terminal user interface library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Brick.Keybindings.Parse

Description

This module provides key binding string parsing functions for use in e.g. reading key bindings from configuration files.

Synopsis

Documentation

parseBinding :: Text -> Either String Binding Source #

Parse a key binding string. Key binding strings specify zero or more modifier keys and a base key, separated by hyphens.

(modifier "-")* key

e.g. c-down, backspace, ctrl-shift-f1.

where each modifier is parsed case-insensitively as follows:

and key is parsed case-insensitively as follows:

parseBindingList :: Text -> Either String BindingState Source #

Parse a key binding list into a BindingState.

A key binding list either the string "unbound" or is a comma-separated list of Bindings parsed with parseBinding.

keybindingsFromIni Source #

Arguments

:: KeyEvents k

The key event name mapping to use to parse the configuration data.

-> Text

The name of the INI configuration section to read.

-> Text

The text of the INI document to read.

-> Either String (Maybe [(k, BindingState)]) 

Parse custom key bindings from the specified INI file using the provided event name mapping.

Each line in the specified section can take the form

<event-name> = <"unbound"|[binding,...]>

where the event name must be a valid event name in the specified KeyEvents and each binding is valid as parsed by parseBinding.

Returns Nothing if the named section was not found; otherwise returns a (possibly empty) list of binding states for each event in evs.

keybindingsFromFile Source #

Arguments

:: KeyEvents k

The key event name mapping to use to parse the configuration data.

-> Text

The name of the INI configuration section to read.

-> FilePath

The path to the INI file to read.

-> IO (Either String (Maybe [(k, BindingState)])) 

Parse custom key bindings from the specified INI file path. This does not catch or convert any exceptions resulting from I/O errors. See keybindingsFromIni for details.

keybindingIniParser :: KeyEvents k -> Text -> IniParser (Maybe [(k, BindingState)]) Source #

The low-level INI parser for custom key bindings used by this module, exported for applications that use the config-ini package.