Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module provides key binding string parsing functions for use in e.g. reading key bindings from configuration files.
Synopsis
- parseBinding :: Text -> Either String Binding
- parseBindingList :: Text -> Either String BindingState
- keybindingsFromIni :: KeyEvents k -> Text -> Text -> Either String (Maybe [(k, BindingState)])
- keybindingsFromFile :: KeyEvents k -> Text -> FilePath -> IO (Either String (Maybe [(k, BindingState)]))
- keybindingIniParser :: KeyEvents k -> Text -> IniParser (Maybe [(k, BindingState)])
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:
- "f1", "f2", ...:
KFun
- "esc":
KEsc
- "backspace":
KBS
- "enter":
KEnter
- "left":
KLeft
- "right":
KRight
- "up":
KUp
- "down":
KDown
- "upleft":
KUpLeft
- "upright":
KUpRight
- "downleft":
KDownLeft
- "downright":
KDownRight
- "center":
KCenter
- "backtab":
KBackTab
- "printscreen":
KPrtScr
- "pause":
KPause
- "insert":
KIns
- "home":
KHome
- "pgup":
KPageUp
- "del":
KDel
- "end":
KEnd
- "pgdown":
KPageDown
- "begin":
KBegin
- "menu":
KMenu
- "space":
' '
- "tab":
'\t'
- Otherwise,
KChar
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 Binding
s parsed with parseBinding
.
:: 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
.
:: 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.