Update root-view

This commit is contained in:
Garen Torikian
2013-05-01 16:40:33 -07:00
parent 6c5f310cba
commit 5c21d71461

View File

@@ -98,11 +98,11 @@ class RootView extends View
### Public ###
# Public: Shows a dialog asking if the pane was _really_ meant to be closed.
# Shows a dialog asking if the pane was _really_ meant to be closed.
confirmClose: ->
@panes.confirmClose()
# Public: Given a filepath, this opens it in Atom.
# Given a filepath, this opens it in Atom.
#
# Returns the `EditSession` for the file URI.
open: (path, options = {}) ->
@@ -119,7 +119,7 @@ class RootView extends View
activePane.focus() if changeFocus
editSession
# Public: Updates the application's title, based on whichever file is open.
# Updates the application's title, based on whichever file is open.
updateTitle: ->
if projectPath = project.getPath()
if item = @getActivePaneItem()
@@ -129,19 +129,19 @@ class RootView extends View
else
@setTitle('untitled')
# Public: Sets the application's title.
# Sets the application's title.
#
# Returns a {String}.
setTitle: (title) ->
document.title = title
# Public: Retrieves all of the application's {Editor}s.
# Retrieves all of the application's {Editor}s.
#
# Returns an {Array} of {Editor}s.
getEditors: ->
@panes.find('.pane > .item-views > .editor').map(-> $(this).view()).toArray()
# Public: Retrieves all of the modified buffers that are open and unsaved.
# Retrieves all of the modified buffers that are open and unsaved.
#
# Returns an {Array} of {Buffer}s.
getModifiedBuffers: ->
@@ -151,13 +151,13 @@ class RootView extends View
modifiedBuffers.push item.buffer if item.buffer.isModified()
modifiedBuffers
# Public: Retrieves all of the paths to open files.
# Retrieves all of the paths to open files.
#
# Returns an {Array} of {String}s.
getOpenBufferPaths: ->
_.uniq(_.flatten(@getEditors().map (editor) -> editor.getOpenBufferPaths()))
# Public: Retrieves the pane that's currently open.
# Retrieves the pane that's currently open.
#
# Returns an {Pane}.
getActivePane: ->
@@ -173,29 +173,23 @@ class RootView extends View
focusNextPane: -> @panes.focusNextPane()
getFocusedPane: -> @panes.getFocusedPane()
# Internal: Destroys everything.
remove: ->
editor.remove() for editor in @getEditors()
project.destroy()
super
# Public: Saves all of the open buffers.
# Saves all of the open buffers.
saveAll: ->
@panes.saveAll()
# Public: Fires a callback on each open {Pane}.
# Fires a callback on each open {Pane}.
#
# callback - A {Function} to call
eachPane: (callback) ->
@panes.eachPane(callback)
# Public: Retrieves all of the open {Pane}s.
# Retrieves all of the open {Pane}s.
#
# Returns an {Array} of {Pane}.
getPanes: ->
@panes.getPanes()
# Public: Given a {Pane}, this fetches its ID.
# Given a {Pane}, this fetches its ID.
#
# pane - An open {Pane}
#
@@ -203,21 +197,30 @@ class RootView extends View
indexOfPane: (pane) ->
@panes.indexOfPane(pane)
# Public: Fires a callback on each open {Editor}.
# Fires a callback on each open {Editor}.
#
# callback - A {Function} to call
eachEditor: (callback) ->
callback(editor) for editor in @getEditors()
@on 'editor:attached', (e, editor) -> callback(editor)
# Public: Fires a callback on each open {EditSession}.
# Fires a callback on each open {EditSession}.
#
# callback - A {Function} to call
eachEditSession: (callback) ->
project.eachEditSession(callback)
# Public: Fires a callback on each open {Buffer}.
# Fires a callback on each open {Buffer}.
#
# callback - A {Function} to call
eachBuffer: (callback) ->
project.eachBuffer(callback)
### Internal ###
# Destroys everything.
remove: ->
editor.remove() for editor in @getEditors()
project.destroy()
super