diff --git a/src/atom/app.coffee b/src/atom/app.coffee index c54ece648..6fad8fbfd 100644 --- a/src/atom/app.coffee +++ b/src/atom/app.coffee @@ -1,9 +1,11 @@ Native = require 'native' +GlobalKeymap = require 'global-keymap' $ = require 'jquery' _ = require 'underscore' module.exports = class App + keymap: null native: null windows: null @@ -11,6 +13,18 @@ class App @native = new Native(nativeMethods) @windows = [] + @setupKeymap() + + setupKeymap: -> + @keymap = new GlobalKeymap() + @keymap.bindKeys "*", + 'meta-o': 'open' + + $(document).on 'open', => + url = @native.openDialog() + @open(url) if url + $(document).on 'keydown', (e) => @keymap.handleKeyEvent(e) + open: (url) -> @native.open url diff --git a/src/atom/global-keymap.coffee b/src/atom/global-keymap.coffee index 11e4f7ff4..22fbf853c 100644 --- a/src/atom/global-keymap.coffee +++ b/src/atom/global-keymap.coffee @@ -19,7 +19,7 @@ class GlobalKeymap handleKeyEvent: (event) -> event.keystroke = @keystrokeStringForEvent(event) - currentNode = $(event.target) + currentNode = $(event.target) while currentNode.length candidateBindingSets = @bindingSets.filter (set) -> currentNode.is(set.selector) candidateBindingSets.sort (a, b) -> b.specificity - a.specificity diff --git a/src/atom/window.coffee b/src/atom/window.coffee index 3bbd052b9..c3bc6a688 100644 --- a/src/atom/window.coffee +++ b/src/atom/window.coffee @@ -44,10 +44,10 @@ windowAdditions = $('head').append "" showConsole: -> - # $atomController.webView.inspector.showConsole true + $native.showDevTools() onerror: -> - @showConsole true + @showConsole() for key, value of windowAdditions console.warn "DOMWindow already has a key named `#{key}`" if window[key] @@ -55,4 +55,3 @@ for key, value of windowAdditions requireStylesheet 'reset.css' requireStylesheet 'atom.css' - diff --git a/src/stdlib/native.coffee b/src/stdlib/native.coffee index fc3e0e8e0..0b2a031c1 100644 --- a/src/stdlib/native.coffee +++ b/src/stdlib/native.coffee @@ -16,13 +16,7 @@ class Native # Returns null or a file path. openPanel: -> - panel = OSX.NSOpenPanel.openPanel - panel.setCanChooseDirectories true - if panel.runModal isnt OSX.NSFileHandlingPanelOKButton - return null - filename = panel.filenames.lastObject - localStorage.lastOpenedPath = filename - filename.valueOf() + atom.native.openPanel() # Returns null or a file path. savePanel: ->