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

- TemplateHaskell
- TemplateHaskellQuotes
- StandaloneDeriving
- DeriveDataTypeable
- TypeSynonymInstances
- FlexibleContexts
- FlexibleInstances
- ConstrainedClassMethods
- MultiParamTypeClasses
- FunctionalDependencies
- ExistentialQuantification
- GeneralizedNewtypeDeriving
- RankNTypes
- ExplicitForAll

Yi.Keymap

Contents

- Lenses

Description

`Keymap`, `YiM` and `Action`s.

Synopsis

- data Action
  - = Show a => YiA (YiM a)
  - | Show a => EditorA (EditorM a)
  - | Show a => BufferA (BufferM a)
- emptyAction :: Action
- type Interact ev a = I ev Action a
- type KeymapM a = Interact Event a
- type Keymap = KeymapM ()
- type KeymapEndo = Keymap -> Keymap
- type KeymapProcess = P Event Action
- data KeymapSet = KeymapSet {
  - topKeymap :: Keymap
  - insertKeymap :: Keymap
  }
- topKeymapA :: Lens' KeymapSet Keymap
- insertKeymapA :: Lens' KeymapSet Keymap
- extractTopKeymap :: KeymapSet -> Keymap
- modelessKeymapSet :: Keymap -> KeymapSet
- newtype YiM a = YiM {
  - runYiM :: ReaderT Yi IO a
  }
- withUI :: (UI Editor -> IO a) -> YiM a
- unsafeWithEditor :: Config -> MVar YiVar -> EditorM a -> IO a
- readEditor :: MonadEditor m => (Editor -> a) -> m a
- catchDynE :: Exception exception => YiM a -> (exception -> YiM a) -> YiM a
- catchJustE :: Exception e => (e -> Maybe b) -> YiM a -> (b -> YiM a) -> YiM a
- handleJustE :: Exception e => (e -> Maybe b) -> (b -> YiM a) -> YiM a -> YiM a
- class YiAction a x | a -> x where
  - makeAction :: a -> Action
- data Yi = Yi {
  - yiUi :: UI Editor
  - yiInput :: [Event] -> IO ()
  - yiOutput :: IsRefreshNeeded -> [Action] -> IO ()
  - yiConfig :: Config
  - yiVar :: MVar YiVar
  }
- data IsRefreshNeeded
  - = MustRefresh
  - | NoNeedToRefresh
- data YiVar = YiVar {
  - yiEditor :: !Editor
  - yiSubprocessIdSupply :: !SubprocessId
  - yiSubprocesses :: !(Map SubprocessId SubprocessInfo)
  }
- write :: (MonadInteract m Action ev, YiAction a x, Show x) => a -> m ()
- withModeY :: (forall syntax. Mode syntax -> YiM ()) -> YiM ()
- yiSubprocessesA :: Lens' YiVar (Map SubprocessId SubprocessInfo)
- yiEditorA :: Lens' YiVar Editor
- yiSubprocessIdSupplyA :: Lens' YiVar SubprocessId
- yiConfigA :: Lens' Yi Config
- yiInputA :: Lens' Yi ([Event] -> IO ())
- yiOutputA :: Lens' Yi (IsRefreshNeeded -> [Action] -> IO ())
- yiUiA :: Lens' Yi (UI Editor)
- yiVarA :: Lens' Yi (MVar YiVar)

# Documentation

data Action Source #

Constructors

Show a => YiA (YiM a) |
Show a => EditorA (EditorM a) |
Show a => BufferA (BufferM a) |

#### Instances

Instances details

Show Action Source # |
Instance details Defined in Yi.Types Methods showsPrec :: Int -> Action -> ShowS Source # show :: Action -> String Source # showList :: [Action] -> ShowS Source #
Eq Action Source # |
Instance details Defined in Yi.Types Methods (==) :: Action -> Action -> Bool Source # (/=) :: Action -> Action -> Bool Source #
YiAction Action () Source # |
Instance details Defined in Yi.Keymap Methods makeAction :: Action -> Action Source #

emptyAction :: Action Source #

type Interact ev a = I ev Action a Source #

type KeymapM a = Interact Event a Source #

type Keymap = KeymapM () Source #

type KeymapEndo = Keymap -> Keymap Source #

type KeymapProcess = P Event Action Source #

data KeymapSet Source #

Constructors

KeymapSet |

Fields

- topKeymap :: Keymap

  Content of the top-level loop.

- insertKeymap :: Keymap

  For insertion-only modes

topKeymapA :: Lens' KeymapSet Keymap Source #

insertKeymapA :: Lens' KeymapSet Keymap Source #

extractTopKeymap :: KeymapSet -> Keymap Source #

modelessKeymapSet :: Keymap -> KeymapSet Source #

newtype YiM a Source #

The type of user-bindable functions TODO: doc how these are actually user-bindable are they?

Constructors

YiM |

Fields

- runYiM :: ReaderT Yi IO a

#### Instances

Instances details

Applicative YiM Source # |
Instance details Defined in Yi.Types Methods pure :: a -> YiM a Source # (<*>) :: YiM (a -> b) -> YiM a -> YiM b Source # liftA2 :: (a -> b -> c) -> YiM a -> YiM b -> YiM c Source # (*>) :: YiM a -> YiM b -> YiM b Source # (<*) :: YiM a -> YiM b -> YiM a Source #
Functor YiM Source # |
Instance details Defined in Yi.Types Methods fmap :: (a -> b) -> YiM a -> YiM b Source # (<$) :: a -> YiM b -> YiM a Source #
Monad YiM Source # |
Instance details Defined in Yi.Types Methods (>>=) :: YiM a -> (a -> YiM b) -> YiM b Source # (>>) :: YiM a -> YiM b -> YiM b Source # return :: a -> YiM a Source #
MonadFail YiM Source # |
Instance details Defined in Yi.Types Methods fail :: String -> YiM a Source #
MonadEditor YiM Source # |
Instance details Defined in Yi.Types Methods askCfg :: YiM Config Source # withEditor :: EditorM a -> YiM a Source # withEditor_ :: EditorM a -> YiM () Source #
MonadReader Yi YiM Source # |
Instance details Defined in Yi.Types Methods ask :: YiM Yi Source # local :: (Yi -> Yi) -> YiM a -> YiM a Source # reader :: (Yi -> a) -> YiM a Source #
MonadState Editor YiM Source # |
Instance details Defined in Yi.Types Methods get :: YiM Editor Source # put :: Editor -> YiM () Source # state :: (Editor -> (a, Editor)) -> YiM a Source #
MonadBase IO YiM Source # |
Instance details Defined in Yi.Types Methods liftBase :: IO α -> YiM α Source #
HookType (YiM a) Source # |
Instance details Defined in Yi.Hooks Methods runHookImpl :: YiConfigVariable var => (var -> YiM a) -> YiM a
YiAction (YiM x) x Source # |
Instance details Defined in Yi.Keymap Methods makeAction :: YiM x -> Action Source #

withUI :: (UI Editor -> IO a) -> YiM a Source #

unsafeWithEditor :: Config -> MVar YiVar -> EditorM a -> IO a Source #

readEditor :: MonadEditor m => (Editor -> a) -> m a Source #

catchDynE :: Exception exception => YiM a -> (exception -> YiM a) -> YiM a Source #

catchJustE Source #

Arguments

:: Exception e |
=> (e -> Maybe b) | Predicate to select exceptions
-> YiM a | Computation to run
-> (b -> YiM a) | Handler
-> YiM a |

handleJustE :: Exception e => (e -> Maybe b) -> (b -> YiM a) -> YiM a -> YiM a Source #

class YiAction a x | a -> x where Source #

Methods

makeAction :: a -> Action Source #

#### Instances

Instances details

YiAction Action () Source # |
Instance details Defined in Yi.Keymap Methods makeAction :: Action -> Action Source #
YiAction (IO x) x Source # |
Instance details Defined in Yi.Keymap Methods makeAction :: IO x -> Action Source #
YiAction (BufferM x) x Source # |
Instance details Defined in Yi.Keymap Methods makeAction :: BufferM x -> Action Source #
YiAction (EditorM x) x Source # |
Instance details Defined in Yi.Keymap Methods makeAction :: EditorM x -> Action Source #
YiAction (YiM x) x Source # |
Instance details Defined in Yi.Keymap Methods makeAction :: YiM x -> Action Source #
(YiAction a x, Promptable r) => YiAction (r -> a) x Source # |
Instance details Defined in Yi.MiniBuffer Methods makeAction :: (r -> a) -> Action Source #

data Yi Source #

Constructors

Yi |

Fields

- yiUi :: UI Editor
- yiInput :: [Event] -> IO ()

  input stream

- yiOutput :: IsRefreshNeeded -> [Action] -> IO ()

  output stream

- yiConfig :: Config
- yiVar :: MVar YiVar

  The only mutable state in the program

#### Instances

Instances details

MonadReader Yi YiM Source # |
Instance details Defined in Yi.Types Methods ask :: YiM Yi Source # local :: (Yi -> Yi) -> YiM a -> YiM a Source # reader :: (Yi -> a) -> YiM a Source #

data IsRefreshNeeded Source #

Constructors

MustRefresh |
NoNeedToRefresh |

#### Instances

Instances details

Show IsRefreshNeeded Source # |
Instance details Defined in Yi.Types Methods showsPrec :: Int -> IsRefreshNeeded -> ShowS Source # show :: IsRefreshNeeded -> String Source # showList :: [IsRefreshNeeded] -> ShowS Source #
Eq IsRefreshNeeded Source # |
Instance details Defined in Yi.Types Methods (==) :: IsRefreshNeeded -> IsRefreshNeeded -> Bool Source # (/=) :: IsRefreshNeeded -> IsRefreshNeeded -> Bool Source #

data YiVar Source #

Constructors

YiVar |

Fields

- yiEditor :: !Editor
- yiSubprocessIdSupply :: !SubprocessId
- yiSubprocesses :: !(Map SubprocessId SubprocessInfo)

write :: (MonadInteract m Action ev, YiAction a x, Show x) => a -> m () Source #

`write a` returns a keymap that just outputs the action `a`.

withModeY :: (forall syntax. Mode syntax -> YiM ()) -> YiM () Source #

`withModeY f` runs `f` on the current buffer's mode. As this runs in the YiM monad, we're able to do more than with just `withModeB` such as prompt the user for something before running the action.

# Lenses

yiSubprocessesA :: Lens' YiVar (Map SubprocessId SubprocessInfo) Source #

yiEditorA :: Lens' YiVar Editor Source #

yiSubprocessIdSupplyA :: Lens' YiVar SubprocessId Source #

yiConfigA :: Lens' Yi Config Source #

yiInputA :: Lens' Yi ([Event] -> IO ()) Source #

yiOutputA :: Lens' Yi (IsRefreshNeeded -> [Action] -> IO ()) Source #

yiUiA :: Lens' Yi (UI Editor) Source #

yiVarA :: Lens' Yi (MVar YiVar) Source #