-
Notifications
You must be signed in to change notification settings - Fork 127
Plugin
Cédric Néhémie edited this page May 17, 2014
·
6 revisions
A Minimap is basically just another Atom packages that will interact with the Minimap API, so you can just starts with the Generate Package command.
In addition of the initial Atom packages interface a Minimap plugin must implement the following methods:
-
activatePlugin- A function called to activate the plugin -
deactivatePlugin- A function called to deactivate the plugin -
isActive- A function returning a boolean that indicates the activation state of the plugin.
These methods enable plugins to be activated/deactivated by the Minimap package independently of their activation as a package.
All Minimap plugins are activated by default.
module.exports =
# The atom package activation method. It retrieves the minimap package and registers itself
# as a minimap plugin. That way, the plugin will be available in the minimap package settings.
activate: ->
minimapPackage = atom.packages.getLoadedPackage('minimap')
return @deactivate() unless minimapPackage?
@minimap = require minimapPackage.path
@minimap.registerPlugin 'my-plugin', this
# The atom package deactivation method.
deactivate: ->
@minimap.unregisterPlugin 'my-plugin'
@minimap = null
# Minimap Plugin Interface
active: false
isActive: -> @active
# Method called by the Minimap package when the plugin is activated through the minimap settings
activatePlugin: ->
return if @active
@active = true
# This is where the real plugin activation takes place
# Method called by the Minimap package when the plugin is deactivated through the minimap settings
deactivatePlugin: ->
return unless @active
@active = false
# This is where the real plugin deactivation takes place