mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
things got a little out of hand
This commit is contained in:
@@ -1,16 +1,51 @@
|
||||
Editor = require 'editor'
|
||||
Event = require 'event'
|
||||
KeyBinder = require 'key-binder'
|
||||
Native = require 'native'
|
||||
|
||||
fs = require 'fs'
|
||||
|
||||
# This file is a weirdo. We don't create a Window class, we just add stuff to
|
||||
# the DOM window.
|
||||
windowAdditions =
|
||||
editor: null
|
||||
|
||||
extensions: []
|
||||
|
||||
appRoot: OSX.NSBundle.mainBundle.resourcePath
|
||||
|
||||
path: localStorage.lastOpenedPath ? fs.workingDirectory()
|
||||
|
||||
startup: ->
|
||||
KeyBinder.register "window", window
|
||||
|
||||
@path = localStorage.lastOpenedPath ? File.workingDirectory()
|
||||
@appPath = OSX.NSBundle.mainBundle.resourcePath
|
||||
@editor = new Editor()
|
||||
|
||||
@loadExtensions()
|
||||
|
||||
KeyBinder.load "#{@appRoot}/static/key-bindings.coffee"
|
||||
KeyBinder.load "~/.atomicity/key-bindings.coffee"
|
||||
|
||||
loadExtensions: ->
|
||||
extension.shutdown() for extension in @extensions
|
||||
@extensions = []
|
||||
|
||||
extensionPaths = fs.list(@appRoot + "/extensions")
|
||||
for extensionPath in extensionPaths when fs.isDirectory extensionPath
|
||||
try
|
||||
extension = require extensionPath
|
||||
extensions.push new Extension()
|
||||
catch error
|
||||
console.warn "window: Loading Extension #{fs.base extensionPath} failed."
|
||||
console.warn error
|
||||
|
||||
# After all the extensions are created, start them up.
|
||||
for extension in @extensions
|
||||
try
|
||||
extension.startup()
|
||||
catch error
|
||||
console.warn "window: Extension #{extension.constructor.name} failed to startup."
|
||||
console.warn error
|
||||
|
||||
handleKeyEvent: ->
|
||||
KeyBinder.handleEvent.apply KeyBinder, arguments
|
||||
@@ -18,6 +53,10 @@ windowAdditions =
|
||||
showConsole: ->
|
||||
atomController.webView.inspector.showConsole true
|
||||
|
||||
open: (path) ->
|
||||
path = Native.openPanel() if not path
|
||||
Event.trigger 'window:open', path if path
|
||||
|
||||
for key, value of windowAdditions
|
||||
raise "DOMWindow already has a key named #{key}" if window[key]
|
||||
console.warn "DOMWindow already has a key named `#{key}`" if window[key]
|
||||
window[key] = value
|
||||
|
||||
Reference in New Issue
Block a user