mirror of
https://github.com/atom/atom.git
synced 2026-02-12 15:45:23 -05:00
Move eachEditor and getEditors to Workspace
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user