extensibility via services
This commit is contained in:
parent
d2bf0c5502
commit
4f2e9d6fd7
5 changed files with 30 additions and 2 deletions
|
|
@ -13,7 +13,7 @@ class Command
|
|||
return unless input.characters.length > 0
|
||||
[command, args...] = input.characters.split(" ")
|
||||
|
||||
func = (new Ex)[command]
|
||||
func = Ex.singleton()[command]
|
||||
if func?
|
||||
func(args...)
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
GlobalExState = require './global-ex-state'
|
||||
ExState = require './ex-state'
|
||||
Ex = require './ex'
|
||||
{Disposable, CompositeDisposable} = require 'event-kit'
|
||||
|
||||
module.exports = ExMode =
|
||||
|
|
@ -26,3 +27,6 @@ module.exports = ExMode =
|
|||
|
||||
deactivate: ->
|
||||
@disposables.dispose()
|
||||
|
||||
provideEx: ->
|
||||
registerCommand: Ex.registerCommand.bind(Ex)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
path = require 'path'
|
||||
|
||||
class Ex
|
||||
@singleton: =>
|
||||
@ex ||= new Ex
|
||||
|
||||
@registerCommand: (name, func) =>
|
||||
@singleton()[name] = func
|
||||
|
||||
quit: ->
|
||||
atom.workspace.getActivePane().destroyActiveItem()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue