Moving event handling out of editor into window

This commit is contained in:
Corey Johnson
2011-09-26 11:10:27 -07:00
parent 46d68cd934
commit 226fb9e26e
5 changed files with 15 additions and 18 deletions

View File

@@ -66,7 +66,7 @@ class Editor extends Pane
File.write @filename, @code()
@sessions[@filename] = @ace.getSession()
@window.setDirty false
@ace._emit 'save', { @filename }
@window._emit 'save', { @filename }
open: (path) ->
path = Chrome.openPanel() if not path
@@ -87,11 +87,11 @@ class Editor extends Pane
@ace.setSession @sessions[@filename]
@window.setDirty false
@ace._emit 'open', { @filename }
@window._emit 'open', { @filename }
close: (path) ->
@deleteSession path
@ace._emit 'close', { filename : path }
@window._emit 'close', { filename : path }
saveAs: ->
if file = Chrome.savePanel()

View File

@@ -4,6 +4,8 @@ File = require 'fs'
Chrome = require 'chrome'
{bindKey} = require 'keybinder'
oop = require "pilot/oop"
{EventEmitter} = require "pilot/event_emitter"
module.exports =
class Window
@@ -20,6 +22,8 @@ class Window
'Command-Ctrl-M' : @reload
constructor: (options={}) ->
oop.implement @, EventEmitter
for option, value of options
@[option] = value
@@ -28,7 +32,7 @@ class Window
@nswindow = @controller?.window
@loadPlugins()
@document.ace._emit "loaded"
@._emit "loaded"
loadPlugins: ->
Editor = require 'editor'
@@ -38,7 +42,7 @@ class Window
@plugins = []
App = require 'app'
for pluginPath in File.list(App.root + "/plugins")
for pluginPath in File.list(App.root + "/plugins")
if File.isDirectory pluginPath
try
plugin = require pluginPath