yi-core-0.19.4: Yi editor core library

License | GPL-2
Maintainer | yi-devel@googlegroups.com
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Extensions

- OverloadedStrings
- FlexibleContexts

Yi.Keymap.Keys

Description

Combinators for building keymaps.

Synopsis

- module Yi.Event
- data I ev w a
- choice :: (MonadInteract m w e, MonadFail m) => [m a] -> m a
- option :: MonadInteract m w e => a -> m a -> m a
- data P event w
  - = End
  - | (Show mid, Eq mid) => Chain (P event mid) (P mid w)
- oneOf :: (Ord event, MonadInteract m w event, MonadFail m) => [event] -> m event
- accepted :: Show ev => Int -> P ev w -> [[Text]]
- mkAutomaton :: Eq w => I ev w a -> P ev w
- event :: (Ord event, MonadInteract m w event) => event -> m event
- data InteractState event w
  - = Ambiguous [(Int, w, P event w)]
  - | Waiting
  - | Dead
  - | Running w (P event w)
- class (Eq w, Monad m, Alternative m, Applicative m, MonadPlus m) => MonadInteract (m :: Type -> Type) w e | m -> w e where
  - eventBounds :: Maybe e -> Maybe e -> m e
  - adjustPriority :: Int -> m ()
- deprioritize :: MonadInteract f w e => f ()
- important :: MonadInteract f w e => f a -> f a -> f a
- (<||) :: MonadInteract f w e => f a -> f a -> f a
- (||>) :: MonadInteract f w e => f a -> f a -> f a
- processOneEvent :: Eq w => P event w -> event -> ([w], P event w)
- computeState :: Eq w => P event w -> InteractState event w
- events :: (Ord event, MonadInteract m w event) => [event] -> m [event]
- idAutomaton :: (Ord a, Eq a) => P a a
- runWrite :: Eq w => P event w -> [event] -> [w]
- anyEvent :: (Ord event, MonadInteract m w event) => m event
- eventBetween :: (Ord e, MonadInteract m w e) => e -> e -> m e
- printableChar :: (MonadFail m, MonadInteract m w Event) => m Char
- textChar :: KeymapM Char
- charOf :: (MonadFail m, MonadInteract m w Event) => (Event -> Event) -> Char -> Char -> m Char
- shift :: Event -> Event
- meta :: Event -> Event
- ctrl :: Event -> Event
- super :: Event -> Event
- hyper :: Event -> Event
- spec :: Key -> Event
- char :: Char -> Event
- (>>!) :: (MonadInteract m Action Event, YiAction a x, Show x) => m b -> a -> m ()
- (>>=!) :: (MonadInteract m Action Event, YiAction a x, Show x) => m b -> (b -> a) -> m ()
- (?>>) :: MonadInteract m action Event => Event -> m a -> m a
- (?>>!) :: (MonadInteract m Action Event, YiAction a x, Show x) => Event -> a -> m ()
- (?*>>) :: MonadInteract m action Event => [Event] -> m a -> m a
- (?*>>!) :: (MonadInteract m Action Event, YiAction a x, Show x) => [Event] -> a -> m ()
- ctrlCh :: Char -> Event
- metaCh :: Char -> Event
- hyperCh :: Char -> Event
- optMod :: (MonadFail m, MonadInteract m w Event) => (Event -> Event) -> Event -> m Event
- pString :: MonadInteract m w Event => String -> m [Event]

# Documentation

module Yi.Event

data I ev w a Source #

Interactive process description

#### Instances

Instances details

Alternative (I ev w) Source # |
Instance details Defined in Yi.Interact Methods empty :: I ev w a Source # (<|>) :: I ev w a -> I ev w a -> I ev w a Source # some :: I ev w a -> I ev w [a] Source # many :: I ev w a -> I ev w [a] Source #
Applicative (I ev w) Source # |
Instance details Defined in Yi.Interact Methods pure :: a -> I ev w a Source # (<*>) :: I ev w (a -> b) -> I ev w a -> I ev w b Source # liftA2 :: (a -> b -> c) -> I ev w a -> I ev w b -> I ev w c Source # (*>) :: I ev w a -> I ev w b -> I ev w b Source # (<*) :: I ev w a -> I ev w b -> I ev w a Source #
Functor (I event w) Source # |
Instance details Defined in Yi.Interact Methods fmap :: (a -> b) -> I event w a -> I event w b Source # (<$) :: a -> I event w b -> I event w a Source #
Monad (I event w) Source # |
Instance details Defined in Yi.Interact Methods (>>=) :: I event w a -> (a -> I event w b) -> I event w b Source # (>>) :: I event w a -> I event w b -> I event w b Source # return :: a -> I event w a Source #
Eq w => MonadPlus (I event w) Source # |
Instance details Defined in Yi.Interact Methods mzero :: I event w a Source # mplus :: I event w a -> I event w a -> I event w a Source #
MonadFail (I event w) Source # |
Instance details Defined in Yi.Interact Methods fail :: String -> I event w a Source #
Eq w => MonadInteract (I event w) w event Source # |
Instance details Defined in Yi.Interact Methods write :: w -> I event w () Source # eventBounds :: Maybe event -> Maybe event -> I event w event Source # adjustPriority :: Int -> I event w () Source #

choice :: (MonadInteract m w e, MonadFail m) => [m a] -> m a Source #

Combines all parsers in the specified list.

option :: MonadInteract m w e => a -> m a -> m a Source #

`option x p` will either parse `p` or return `x` without consuming any input.

data P event w Source #

Operational representation of a process

Constructors

End |
(Show mid, Eq mid) => Chain (P event mid) (P mid w) |

#### Instances

Instances details

(Show w, Show ev) => Show (P ev w) Source # |
Instance details Defined in Yi.Interact Methods showsPrec :: Int -> P ev w -> ShowS Source # show :: P ev w -> String Source # showList :: [P ev w] -> ShowS Source #

oneOf :: (Ord event, MonadInteract m w event, MonadFail m) => [event] -> m event Source #

accepted :: Show ev => Int -> P ev w -> [[Text]] Source #

mkAutomaton :: Eq w => I ev w a -> P ev w Source #

event :: (Ord event, MonadInteract m w event) => event -> m event Source #

Parses and returns the specified character.

data InteractState event w Source #

Abstraction of the automaton state.

Constructors

Ambiguous [(Int, w, P event w)] |
Waiting |
Dead |
Running w (P event w) |

#### Instances

Instances details

Monoid (InteractState event w) Source # |
Instance details Defined in Yi.Interact Methods mempty :: InteractState event w Source # mappend :: InteractState event w -> InteractState event w -> InteractState event w Source # mconcat :: [InteractState event w] -> InteractState event w Source #
Semigroup (InteractState event w) Source # |
Instance details Defined in Yi.Interact Methods (<>) :: InteractState event w -> InteractState event w -> InteractState event w Source # sconcat :: NonEmpty (InteractState event w) -> InteractState event w Source # stimes :: Integral b => b -> InteractState event w -> InteractState event w Source #

class (Eq w, Monad m, Alternative m, Applicative m, MonadPlus m) => MonadInteract (m :: Type -> Type) w e | m -> w e where Source #

Abstraction of monadic interactive processes

Minimal complete definition

write, eventBounds, adjustPriority

Methods

eventBounds :: Maybe e -> Maybe e -> m e Source #

Consumes and returns the next character. Fails if there is no input left, or outside the given bounds.

adjustPriority :: Int -> m () Source #

#### Instances

Instances details

MonadInteract m w e => MonadInteract (StateT s m) w e Source # |
Instance details Defined in Yi.Interact Methods write :: w -> StateT s m () Source # eventBounds :: Maybe e -> Maybe e -> StateT s m e Source # adjustPriority :: Int -> StateT s m () Source #
Eq w => MonadInteract (I event w) w event Source # |
Instance details Defined in Yi.Interact Methods write :: w -> I event w () Source # eventBounds :: Maybe event -> Maybe event -> I event w event Source # adjustPriority :: Int -> I event w () Source #

deprioritize :: MonadInteract f w e => f () Source #

important :: MonadInteract f w e => f a -> f a -> f a Source #

Just like `(<||)` but in prefix form. It `deprioritize`s the second argument.

(<||) :: MonadInteract f w e => f a -> f a -> f a infixl 3 Source #

(||>) :: MonadInteract f w e => f a -> f a -> f a Source #

processOneEvent :: Eq w => P event w -> event -> ([w], P event w) Source #

computeState :: Eq w => P event w -> InteractState event w Source #

events :: (Ord event, MonadInteract m w event) => [event] -> m [event] Source #

Parses and returns the specified list of events (lazily).

idAutomaton :: (Ord a, Eq a) => P a a Source #

runWrite :: Eq w => P event w -> [event] -> [w] Source #

anyEvent :: (Ord event, MonadInteract m w event) => m event Source #

eventBetween :: (Ord e, MonadInteract m w e) => e -> e -> m e Source #

printableChar :: (MonadFail m, MonadInteract m w Event) => m Char Source #

textChar :: KeymapM Char Source #

Parse any character that can be inserted in the text.

charOf :: (MonadFail m, MonadInteract m w Event) => (Event -> Event) -> Char -> Char -> m Char Source #

shift :: Event -> Event Source #

meta :: Event -> Event Source #

ctrl :: Event -> Event Source #

super :: Event -> Event Source #

hyper :: Event -> Event Source #

spec :: Key -> Event Source #

Convert a special key into an event

char :: Char -> Event Source #

(>>!) :: (MonadInteract m Action Event, YiAction a x, Show x) => m b -> a -> m () infixl 1 Source #

    p >>! act = p >> 'write' act

(>>=!) :: (MonadInteract m Action Event, YiAction a x, Show x) => m b -> (b -> a) -> m () infixl 1 Source #

    p >>=! act = p >>= 'write' . act

(?>>) :: MonadInteract m action Event => Event -> m a -> m a infixr 0 Source #

     ev ?>> proc = event ev >> proc

(?>>!) :: (MonadInteract m Action Event, YiAction a x, Show x) => Event -> a -> m () infixr 0 Source #

     ev ?>>! act = event ev >> write act

(?*>>) :: MonadInteract m action Event => [Event] -> m a -> m a infixr 0 Source #

     ev ?*>> proc = events ev >> proc

(?*>>!) :: (MonadInteract m Action Event, YiAction a x, Show x) => [Event] -> a -> m () infixr 0 Source #

     ev ?*>>! act = events ev >> write act

ctrlCh :: Char -> Event Source #

metaCh :: Char -> Event Source #

hyperCh :: Char -> Event Source #

optMod :: (MonadFail m, MonadInteract m w Event) => (Event -> Event) -> Event -> m Event Source #

`optMod f ev` produces a `MonadInteract` that consumes `ev` or `f ev`

pString :: MonadInteract m w Event => String -> m [Event] Source #