rasa-0.1.9: A modular text editor

Safe HaskellNone
LanguageHaskell2010

Rasa.Internal.Listeners

Synopsis

Documentation

data Listener Source #

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

type Listeners = Map TypeRep [Listener] Source #

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

onEveryTrigger :: forall a b. Typeable a => (a -> Action b) -> Action ListenerId Source #

This registers an event listener, as long as the listener is well-typed similar to this:

MyEventType -> Action () then it will be triggered on all dispatched events of type MyEventType. It returns an ID which may be used with removeListener to cancel the listener

onEveryTrigger_ :: forall a b. Typeable a => (a -> Action b) -> Action () Source #

onNextEvent :: forall a b. Typeable a => (a -> Action b) -> Action () Source #

This acts as onEveryTrigger but listens only for the first event of a given type.

onInit :: forall a. Action a -> Action () Source #

Registers an action to be performed during the Initialization phase.

This phase occurs exactly ONCE when the editor starts up. Though arbitrary actions may be performed in the configuration block; it's recommended to embed such actions in the onInit event listener so that all event listeners are registered before anything Actions occur.

beforeEveryEvent :: forall a. Action a -> Action ListenerId Source #

Registers an action to be performed BEFORE each event phase.

beforeEveryEvent_ :: forall a. Action a -> Action () Source #

beforeNextEvent :: forall a. Action a -> Action () Source #

Registers an action to be performed ONCE before only the NEXT event phase.

beforeEveryRender :: forall a. Action a -> Action ListenerId Source #

Registers an action to be performed BEFORE each render phase.

This is a good spot to add information useful to the renderer since all actions have been performed. Only cosmetic changes should occur during this phase.

beforeEveryRender_ :: forall a. Action a -> Action () Source #

beforeNextRender :: forall a. Action a -> Action () Source #

Registers an action to be performed ONCE before only the NEXT render phase.

onEveryRender :: forall a. Action a -> Action ListenerId Source #

Registers an action to be performed during each render phase.

This phase should only be used by extensions which actually render something.

onEveryRender_ :: forall a. Action a -> Action () Source #

onNextRender :: forall a. Action a -> Action () Source #

Registers an action to be performed ONCE before only the NEXT render phase.

This phase should only be used by extensions which actually render something.

afterEveryRender :: forall a. Action a -> Action ListenerId Source #

Registers an action to be performed AFTER each render phase.

This is useful for cleaning up extension state that was registered for the renderer, but needs to be cleared before the next iteration.

afterEveryRender_ :: forall a. Action a -> Action () Source #

afterNextRender :: forall a. Action a -> Action () Source #

Registers an action to be performed after the NEXT render phase.

dispatchEvent :: Typeable a => a -> Action () Source #

Use this to dispatch an event of any type, any listeners which are listening for this event will be triggered with the provided event. Use this within an Action.

onExit :: forall a. Action a -> Action () Source #

Registers an action to be performed during the exit phase.

This is only triggered exactly once when the editor is shutting down. It allows an opportunity to do clean-up, kill any processes you've started, or save any data before the editor terminates.

removeListener :: ListenerId -> Action () Source #

This removes a listener and prevents it from responding to any more events.

matchingListeners :: forall a. Typeable a => Listeners -> [a -> Action ()] Source #

This extracts all event listeners from a map of listeners which match the type of the provided event.

onBufAdded :: forall a. (BufRef -> Action a) -> Action ListenerId Source #

Registers an action to be performed after a new buffer is added.

The supplied function will be called with a BufRef to the new buffer, and the resulting Action will be run.

onBufTextChanged :: forall a. (CrdRange -> YiString -> Action a) -> Action ListenerId Source #

This is fired every time text in a buffer changes.

The range of text which was altered and the new value of that text are provided inside a BufTextChanged event.