wild-bind-0.1.1.1: Dynamic key binding framework

MaintainerToshio Ito <debug.ito@gmail.com>
Safe HaskellNone
LanguageHaskell2010

WildBind.Seq

Contents

Description

This module defines convenient functions to build Bindings that bind actions to key sequences.

For example, see WildBind.Task.X11.Seq.Example in wild-bind-task-x11 package.

Since: 0.1.1.0

Synopsis

Simple API

prefix Source #

Arguments

:: Ord i 
=> [i]

The cancel keys (input symbols for canceling the current key sequence.)

-> [i]

list of prefix input symbols

-> Binding fs i

the original binding.

-> Binding fs i

the result binding.

Prepend prefix keys to a Binding. In the result Binding, the original Binding is enabled only after you input the prefix input symbols in the same order.

During typing prefix keys, you can cancel and reset the key sequence by typing the "cancel keys". This is analogous to C-g in Emacs. The binding of cancel keys are weak, that is, they are overridden by the original binding and prefix keys.

Note that this function creates an independent implicit state to memorize prefix keys input so far. This means,

(prefix [] [key1, key2] b) /= (prefix [] [key1] $ prefix [] [key2] b)

If you want a more composable way of building a sequence binding, try SeqBinding.

Advanced API

data SeqBinding fs i Source #

Intermediate type of building a Binding for key sequences.

Instances

Ord i => Monoid (SeqBinding fs i) Source #

Follows the same rule as Binding.

Methods

mempty :: SeqBinding fs i #

mappend :: SeqBinding fs i -> SeqBinding fs i -> SeqBinding fs i #

mconcat :: [SeqBinding fs i] -> SeqBinding fs i #

toSeq :: Eq i => Binding fs i -> SeqBinding fs i Source #

Create a SeqBinding from Binding. The result SeqBinding has no prefixes yet.

fromSeq :: SeqBinding fs i -> Binding fs i Source #

Resolve SeqBinding to build a Binding for key sequences.

withPrefix Source #

Arguments

:: Ord i 
=> [i]

prefix keys

-> SeqBinding fs i 
-> SeqBinding fs i 

Prepend prefix keys to the SeqBinding.

SeqBinding is composable in terms of prefixes, that is,

(withPrefix [key1, key2] seq_b) == (withPrefix [key1] $ withPrefix [key2] seq_b)

withCancel Source #

Arguments

:: Ord i 
=> [i]

cancel keys

-> SeqBinding fs i 
-> SeqBinding fs i 

Add cancel keys to the SeqBinding.

reviseSeq Source #

Arguments

:: (forall a. [i] -> fs -> i -> Action IO a -> Maybe (Action IO a))

Revising function. [i] is the prefix keys input so far.

-> SeqBinding fs i 
-> SeqBinding fs i 

Revise actions in SeqBinding. See revise.