Inherits from NSObject
Declared in ViEventManager.h

Overview

The event manager is used to automatically run code when specific events occur. An event handler is defined as a Nu function, typically an anonymous function created with the Nu do operator. An event handler will receive zero or more arguments, depending on the event. Any return value is ignored.

The standard events are described below.

Constants

Standard event names

Document Controller events

didFinishLaunching

Emitted when Vico has finished launching.

arguments: none

willResignActive

Emitted when Vico resigns active state (ie, loses focus).

arguments: none

didBecomeActive

Emitted when Vico becomes active (ie, regains focus).

arguments: none

didAddDocument

Emitted when a new document is opened.

arguments: document

didRemoveDocument

Emitted when a document is closed.

arguments: document

Document events

willChangeURL

Emitted before a document changes it's URL.

arguments: document, url

didChangeURL

Emitted after a document changed it's URL.

arguments: document, url

willLoadDocument

Emitted before a document is loaded.

arguments: document, url

didLoadDocument

Emitted after a document was loaded.

arguments: document

willSaveDocument

Emitted before a document is being saved.

arguments: document

didSaveDocument

Emitted after a document was saved.

arguments: document

willSaveAsDocument

Emitted before a document is being saved at a new URL.

arguments: document, url

didSaveAsDocument

Emitted after a document was saved at a new URL.

arguments: document, url

willCloseDocument

Emitted before a document is closed.

arguments: document

didCloseDocument

Emitted after a document was closed.

arguments: document

didModifyDocument

Emitted after a document was modified.

arguments: document, range, delta

didMakeView

Emitted after a new document view was created.

arguments: document, view, text

willChangeSyntax

Emitted before a document changes language syntax.

arguments: document, language

didChangeSyntax

Emitted after a document changed language syntax.

arguments: document, language

Text events

caretDidMove

Emitted after the caret has changed in a text view.

arguments: text

Window events

willSelectDocument

Emitted before the selected document is changed in a window.

arguments: window, document

didSelectDocument

Emitted after the selected document was changed in a window.

arguments: window, document

willSelectView

Emitted before the selected view is changed in a window.

arguments: window, view

didSelectView

Emitted after the selected view was changed in a window.

arguments: window, view

willSelectTab

Emitted before the selected tab is changed in a window.

arguments: window, tab controller

didSelectTab

Emitted after the selected tab was changed in a window.

arguments: window, tab controller

Tab Controller events

didAddView

Emitted after a view was added to a tab.

arguments: view

didCloseView

Emitted after a view was removed from a tab.

arguments: view

Tasks

Other Methods

Emitting events

Registering event handlers

Removing event handlers

Class Methods

defaultManager

The default global event manager.

+ (ViEventManager *)defaultManager

Return Value

The default global event manager.

Declared In

ViEventManager.h

Instance Methods

clear

Remove all handlers for all events.

- (void)clear

Declared In

ViEventManager.h

clear:

Remove all handlers for an event.

- (void)clear:(NSString *)event

Parameters

event

The name of the event; cannot be nil.

Declared In

ViEventManager.h

clear:for:

Remove all events handlers for a specific object.

- (void)clear:(NSString *)event for:(id)owner

Parameters

event

The name of the event; cannot be nil.

owner

The object that is responsible for emitting the event.

Declared In

ViEventManager.h

clearFor:

Remove all handlers for an object.

- (void)clearFor:(id)owner

Parameters

owner

The object that is responsible for emitting the event.

Declared In

ViEventManager.h

emit:for:withArguments:

Emit an event immediately.

- (void)emit:(NSString *)event for:(id)owner withArguments:(id)arguments

Parameters

event

The name of the event; cannot be nil.

owner

The object that is responsible for emitting the event.

arguments

The arguments to the event handler. Can either be an NSArray or a Nu list.

Discussion

You should not manually emit any of the standard events.

Declared In

ViEventManager.h

emitDelayed:for:withArguments:

Emit an event in the next run loop iteration.

- (void)emitDelayed:(NSString *)event for:(id)owner withArguments:(id)arguments

Parameters

event

The name of the event; cannot be nil.

owner

The object that is responsible for emitting the event.

arguments

The arguments to the event handler. Can either be an NSArray or a Nu list.

Discussion

You should not manually emit any of the standard events.

Declared In

ViEventManager.h

on:by:do:

Register a handler for an event by a specific object.

- (NSInteger)on:(NSString *)event by:(id)owner do:(NuBlock *)expression

Parameters

event

The name of the event; cannot be nil.

owner

The object that emitted the event.

expression

A Nu anonymous function (do block). See the Nu documentation. The number of arguments to the function must match the number of arguments emitted.

Return Value

A unique event ID.

Discussion

This event handler is called whenever the event is emitted by the owner object.

See Also

Declared In

ViEventManager.h

on:do:

Register an event handler.

- (NSInteger)on:(NSString *)event do:(NuBlock *)expression

Parameters

event

The name of the event; cannot be nil.

expression

A Nu anonymous function (do block). See the Nu documentation. The number of arguments to the function must match the number of arguments emitted.

Return Value

A unique event ID.

Discussion

This event handler is called whenever the event is emitted, regardless of the emitting object.

Declared In

ViEventManager.h

remove:

Remove an event handler.

- (void)remove:(NSInteger)eventId

Parameters

eventId

An event ID as returned by on:by:do:.

Declared In

ViEventManager.h