Move eachEditor and getEditors to Workspace

This commit is contained in:
probablycorey
2014-02-12 17:19:25 -08:00
parent ee09eee374
commit 41761ffbcf
2 changed files with 14 additions and 9 deletions

View File

@@ -128,11 +128,6 @@ class Project extends Model
filePath = @resolve(filePath)
@buildEditorForBuffer(@bufferForPathSync(filePath), options)
# Public: Retrieves all {Editor}s for all open files.
#
# Returns an {Array} of {Editor}s.
getEditors: ->
new Array(@editors...)
# Public: Add the given {Editor}.
addEditor: (editor) ->
@@ -305,10 +300,6 @@ class Project extends Model
@addEditor(editor)
editor
eachEditor: (callback) ->
callback(editor) for editor in @getEditors()
@on 'editor-created', (editor) -> callback(editor)
eachBuffer: (args...) ->
subscriber = args.shift() if args.length > 1
callback = args.shift()
@@ -322,3 +313,5 @@ class Project extends Model
# Deprecated delegates
registerOpener: -> atom.workspaceView.model.registerOpener(arguments)
unregisterOpener: -> atom.workspaceView.model.unregisterOpener(arguments)
eachEditor: -> atom.workspaceView.model.eachEditor(arguments)
getEditors: -> atom.workspaceView.model.getEditors(arguments)

View File

@@ -49,6 +49,18 @@ class Workspace extends Model
paneContainer: @paneContainer.serialize()
fullScreen: atom.isFullScreen()
# Public: Calls callback for every existing {Editor} and for all new {Editors}
# that are created.
#
# callback - A {Function} with an {Editor} as its only argument
eachEditor: (callback) ->
callback(editor) for editor in @getEditors()
@on 'editor-created', (editor) -> callback(editor)
# Public: Returns an {Array} of all open {Editor}s.
getEditors: ->
new Array(atom.project.editors...)
# Public: Asynchronously opens a given a filepath in Atom.
#
# uri - A {String} uri.