rasa-0.1.7: A modular text editor

Safe HaskellNone
LanguageHaskell2010

Rasa.Internal.Action

Synopsis

Documentation

data Hook Source #

A wrapper around event listeners so they can be stored in Hooks.

Constructors

Hook HookId (a -> Action ()) 

data HookId Source #

Constructors

HookId Int TypeRep 

Instances

Eq HookId Source # 

Methods

(==) :: HookId -> HookId -> Bool #

(/=) :: HookId -> HookId -> Bool #

type Hooks = Map TypeRep [Hook] Source #

A map of Event types to a list of listeners for that event

newtype Action a Source #

This is a monad-transformer stack for performing actions against the editor. You register Actions to be run in response to events using onEveryTrigger

Within an Action you can:

  • Use liftIO for IO
  • Access/edit extensions that are stored globally, see ext
  • Embed any Actions exported other extensions
  • Embed buffer actions using bufDo or buffersDo
  • Add/Edit/Focus buffers and a few other Editor-level things, see the Directive module.

Constructors

Action 

Instances

Monad Action Source # 

Methods

(>>=) :: Action a -> (a -> Action b) -> Action b #

(>>) :: Action a -> Action b -> Action b #

return :: a -> Action a #

fail :: String -> Action a #

Functor Action Source # 

Methods

fmap :: (a -> b) -> Action a -> Action b #

(<$) :: a -> Action b -> Action a #

Applicative Action Source # 

Methods

pure :: a -> Action a #

(<*>) :: Action (a -> b) -> Action a -> Action b #

(*>) :: Action a -> Action b -> Action b #

(<*) :: Action a -> Action b -> Action a #

MonadIO Action Source # 

Methods

liftIO :: IO a -> Action a #

MonadState ActionState Action Source # 

execAction :: ActionState -> Action () -> IO ActionState Source #

Execute an Action (returning the editor state)

evalAction :: ActionState -> Action a -> IO a Source #

Evaluate an Action (returning the value)

data ActionState Source #

This contains all data representing the editor's state. It acts as the state object for an 'Action

Constructors

ActionState 

class HasActionState a where Source #

Allows polymorphic lenses which need to access something in ActionState

Minimal complete definition

actionState

data BufActionState Source #

Contains all data about the editor; as well as a buffer which is in focus. We keep the full ActionState here too so that Actions may be lifted inside a BufAction

Constructors

BufActionState 

newtype BufAction a Source #

This is a monad-transformer stack for performing actions on a specific buffer. You run BufActions by embedding them in a Action via bufferDo or buffersDo

Within a BufAction you can:

  • Use liftAction to run an Action; It is your responsibility to ensure that any nested Actions don't edit the Buffer which the current BufAction is editing; behaviour is undefined if this occurs.
  • Use liftIO for IO
  • Access/Edit the buffer's text
  • Access/edit buffer extensions; see bufExt
  • Embed and sequence BufActions from other extensions

Constructors

BufAction 

liftBuf :: BufAction a -> BufRef -> Action (Maybe a) Source #

This lifts up a bufAction into an Action which performs the BufAction over the referenced buffer and returns the result (if the buffer existed)

liftAction :: Action a -> BufAction a Source #

This lifts up an Action to be run inside a BufAction

it is your responsibility to ensure that any nested Actions don't edit the Buffer which the current BufAction is editing; behaviour is undefined if this occurs.