From 502e52f37d2a1ec3b2cff8e5109e0d28882cb71c Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 28 Aug 2012 16:47:19 -0500 Subject: [PATCH] Implement `atom.open` using `atom.sendMessageToBrowserProcess` --- native/v8_extensions/atom.js | 4 +--- src/app/atom.coffee | 41 ++---------------------------------- src/window-bootstrap.coffee | 1 + 3 files changed, 4 insertions(+), 42 deletions(-) diff --git a/native/v8_extensions/atom.js b/native/v8_extensions/atom.js index c2c144bfd..5ec3a5922 100644 --- a/native/v8_extensions/atom.js +++ b/native/v8_extensions/atom.js @@ -1,11 +1,9 @@ (function () { native function sendMessageToBrowserProcess(name, array); -native function open(path); this.atom = { - sendMessageToBrowserProcess: sendMessageToBrowserProcess, - open: open + sendMessageToBrowserProcess: sendMessageToBrowserProcess }; })(); diff --git a/src/app/atom.coffee b/src/app/atom.coffee index 1fdda1f62..26c01ee27 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -1,39 +1,2 @@ -Keymap = require 'keymap' -fs = require 'fs' - -$ = require 'jquery' -_ = require 'underscore' -require 'underscore-extensions' - -module.exports = -class Atom - keymap: null - windows: null - configFilePath: null - configDirPath: null - rootViewStates: null - - constructor: (@loadPath, nativeMethods) -> - @windows = [] - @setUpKeymap() - @configDirPath = fs.absolute("~/.atom") - @configFilePath = fs.join(@configDirPath, "atom.coffee") - @rootViewStates = {} - - setUpKeymap: -> - @keymap = new Keymap() - @handleKeyEvent = (e) => @keymap.handleKeyEvent(e) - $(document).on 'keydown', @handleKeyEvent - @keymap.bindDefaultKeys() - - open: (path) -> - $native.open path - - quit: -> - $native.terminate null - - windowOpened: (window) -> - @windows.push(window) unless _.contains(@windows, window) - - windowClosed: (window) -> - _.remove(@windows, window) +atom.open = (args...) -> + @sendMessageToBrowserProcess('open', args) diff --git a/src/window-bootstrap.coffee b/src/window-bootstrap.coffee index 1ed554074..46d4750c9 100644 --- a/src/window-bootstrap.coffee +++ b/src/window-bootstrap.coffee @@ -1,4 +1,5 @@ # Like sands through the hourglass, so are the days of our lives. +require 'atom' require 'window' window.startup window.location.params.pathToOpen