Merge branch 'master' of github.com:github/atom

Conflicts:
	static/command-panel.css
This commit is contained in:
Nathan Sobo
2012-05-08 15:11:27 -06:00
13 changed files with 76 additions and 46 deletions

View File

@@ -6,7 +6,6 @@ Directory = require 'directory'
module.exports =
class Project
path: null
rootDirectory: null
buffers: null
@@ -15,16 +14,15 @@ class Project
@buffers = []
getPath: ->
@path
@rootDirectory?.path
setPath: (path) ->
@rootDirectory.off() if @rootDirectory
@rootDirectory?.off()
if path?
@path = if fs.isDirectory(path) then path else fs.directory(path)
@rootDirectory = new Directory(@path)
directory = if fs.isDirectory(path) then path else fs.directory(path)
@rootDirectory = new Directory(directory)
else
@path = null
@rootDirectory = null
@trigger "path-change"
@@ -33,8 +31,7 @@ class Project
@rootDirectory
getFilePaths: ->
projectPath = @path
fs.async.listTree(@path).pipe (paths) =>
fs.async.listTree(@getPath()).pipe (paths) =>
@relativize(path) for path in paths when fs.isFile(path)
open: (filePath) ->
@@ -51,11 +48,11 @@ class Project
buffer
resolve: (filePath) ->
filePath = fs.join(@path, filePath) unless filePath[0] == '/'
filePath = fs.join(@getPath(), filePath) unless filePath[0] == '/'
fs.absolute filePath
relativize: (fullPath) ->
fullPath.replace(@path, "").replace(/^\//, '')
fullPath.replace(@getPath(), "").replace(/^\//, '')
bufferWithId: (id) ->
return buffer for buffer in @buffers when buffer.id == id

View File

@@ -8,7 +8,6 @@ Buffer = require 'buffer'
Editor = require 'editor'
Project = require 'project'
VimMode = require 'vim-mode'
CommandPanel = require 'command-panel'
Pane = require 'pane'
PaneColumn = require 'pane-column'
PaneRow = require 'pane-row'
@@ -31,19 +30,16 @@ class RootView extends View
extensionStates: null
initialize: ({ pathToOpen }) ->
@handleEvents()
@extensions = {}
@extensionStates = {}
@commandPanel = new CommandPanel({rootView: this})
@setTitle()
@project = new Project(pathToOpen)
if pathToOpen? and fs.isFile(pathToOpen)
@open(pathToOpen)
@handleEvents()
@setTitle()
@open(pathToOpen) if fs.isFile(pathToOpen)
serialize: ->
projectPath: @project?.path
projectPath: @project?.getPath()
panesViewState: @panes.children().view()?.serialize()
extensionStates: @serializeExtensions()
@@ -57,7 +53,7 @@ class RootView extends View
@setTitle(@project?.getPath())
@on 'active-editor-path-change', (e, path) =>
@project.setPath(path) unless @project.getPath()
@project.setPath(path) unless @project.getRootDirectory()
@setTitle(path)
afterAttach: (onDom) ->

View File

@@ -5,6 +5,22 @@ Editor = require 'editor'
module.exports =
class CommandPanel extends View
@activate: (rootView, state) ->
requireStylesheet 'command-panel.css'
if state?
@instance = CommandPanel.deserialize(state, rootView)
else
@instance = new CommandPanel(rootView)
@serialize: ->
text: @instance.editor.getText()
visible: @instance.hasParent()
@deserialize: (state, rootView) ->
commandPanel = new CommandPanel(rootView)
commandPanel.show(state.text) if state.visible
commandPanel
@content: ->
@div class: 'command-panel', =>
@div ':', class: 'prompt', outlet: 'prompt'
@@ -14,9 +30,7 @@ class CommandPanel extends View
history: null
historyIndex: 0
initialize: ({@rootView})->
requireStylesheet 'command-panel.css'
initialize: (@rootView)->
@commandInterpreter = new CommandInterpreter()
@history = []

View File

@@ -33,7 +33,7 @@ class FileFinder extends View
if @hasParent()
@detach()
else
@attach() if @rootView.project.path?
@attach() if @rootView.project.getPath()?
attach: ->
@rootView.project.getFilePaths().done (@paths) => @populatePathList()

View File

@@ -14,14 +14,14 @@ class TreeView extends View
requireStylesheet 'tree-view.css'
if state
@treeView = TreeView.deserialize(state, rootView)
@instance = TreeView.deserialize(state, rootView)
else
@treeView = new TreeView(rootView)
@instance = new TreeView(rootView)
rootView.horizontal.prepend(@treeView)
rootView.horizontal.prepend(@instance)
@serialize: ->
@treeView.serialize()
@instance.serialize()
@content: (rootView) ->
@div class: 'tree-view', tabindex: -1, =>

View File

@@ -51,7 +51,7 @@ module.exports =
# Returns true if the file specified by path exists and is a
# regular file.
isFile: (path) ->
not $native.isDirectory path
$native.isFile path
# Returns an array with all the names of files contained
# in the directory path.