mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Add keycap (and bound meta-o) to App
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -44,10 +44,10 @@ windowAdditions =
|
||||
$('head').append "<style path='#{fullPath}'>#{content}</style>"
|
||||
|
||||
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'
|
||||
|
||||
|
||||
@@ -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: ->
|
||||
|
||||
Reference in New Issue
Block a user