This commit is contained in:
Corey Johnson
2011-11-02 10:27:25 -07:00
parent 9e21d8da04
commit c67917efa3
14 changed files with 83 additions and 76 deletions

View File

@@ -64,7 +64,9 @@ class Editor
@ace.getSession().setMode new mode
open: (path) ->
if not path or fs.isDirectory path
return if fs.isDirectory path
if not path
@activePath = null
@ace.setSession @newSession()
else
@@ -85,7 +87,7 @@ class Editor
# ICK, clean this up... too many assumptions being made
session = @sessions[path]
if not session or session.$atom_dirty
if session?.$atom_dirty or (not session and @code.length > 0)
detailedMessage = if @activePath
"#{@activePath} has changes."
else

View File

@@ -13,6 +13,7 @@ class Event
window.document.removeEventListener name, callback
@trigger: (name, data, bubbleToApp=true) ->
console.log name
if bubbleToApp and name.match /^app:/
OSX.NSApp.triggerGlobalEvent_data name, data
return

View File

@@ -1,18 +1,12 @@
KeyBinder = require 'key-binder'
App = require 'app'
fs = require 'fs'
module.exports =
class Extension
constructor: ->
console.log "#{@.constructor.name}: Loaded"
register @identifier(), @
console.log "#{@constructor.name}: Loaded"
# Unique key for the extension. Used in key bindings and settings.
identifier: ->
throw "#{@constructor.name}: You have to supply a unique identifier to extensions"
storageNamespace: -> "storage-#{@identifier()}"
storageNamespace: -> @constructor.name
startup: ->

View File

@@ -57,7 +57,11 @@ class KeyBinder
return false if not callbacks
# Only use the most recently added binding
_.last(callbacks)()
try
_.last(callbacks)()
catch e
console.warn "Failed to run binding #{binding}. #{e}"
true
@bindingParser: (binding) ->

View File

@@ -30,10 +30,16 @@ class Pane
else
throw "I DON'T KNOW HOW TO DEAL WITH #{@position}"
show: ->
@add this
@showing = true
hide: ->
@html.parent().detach()
@showing = false
toggle: ->
if @showing
@html.parent().detach()
@hide()
else
@add this
@showing = not @showing
@show()

View File

@@ -1,4 +1,5 @@
resourcePath = OSX.NSBundle.mainBundle.resourcePath
#resourcePath = OSX.NSBundle.mainBundle.resourcePath
resourcePath = "/Users/corey/code/mine/Atomicity"
paths = [
"#{resourcePath}/src"

View File

@@ -1,4 +1,5 @@
Editor = require 'editor'
Extension = require 'extension'
Event = require 'event'
KeyBinder = require 'key-binder'
Native = require 'native'
@@ -15,13 +16,13 @@ windowAdditions =
appRoot: OSX.NSBundle.mainBundle.resourcePath
startup: () ->
KeyBinder.register "window", window
if atomController.path
@setRecentPath atomController.path
else
atomController.path = @recentPath()
KeyBinder.register "window", window
@editor = if atomController.path and fs.isFile atomController.path
new Editor atomController.path
else
@@ -32,7 +33,6 @@ windowAdditions =
Event.on "editor:open", (e) =>
path = e.details
console.log path
basename = fs.base path
@setTitle basename
@@ -47,7 +47,7 @@ windowAdditions =
for extensionPath in extensionPaths when fs.isDirectory extensionPath
try
extension = require extensionPath
extensions.push new Extension()
extensions.push new extension()
catch error
console.warn "window: Loading Extension #{fs.base extensionPath} failed."
console.warn error
@@ -100,8 +100,6 @@ windowAdditions =
parent = atomController.path.replace(/([^\/])$/, "$1/")
child = path.replace(/([^\/])$/, "$1/")
console.log parent
console.log child
window.x = parent
window.y = child