mirror of
https://github.com/atom/atom.git
synced 2026-02-08 21:55:05 -05:00
Move GlobalKeymap instance to App. Clear bindings between examples.
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
Native = require 'native'
|
||||
GlobalKeymap = require 'global-keymap'
|
||||
$ = require 'jquery'
|
||||
|
||||
module.exports =
|
||||
class App
|
||||
globalKeymap: null
|
||||
native: null
|
||||
|
||||
constructor: ->
|
||||
@native = new Native
|
||||
@globalKeymap = new GlobalKeymap
|
||||
$(document).on 'keydown', (e) => console.log e; @globalKeymap.handleKeyEvent(e)
|
||||
|
||||
bindKeys: (selector, bindings) ->
|
||||
window.rootView.bindKeys(selector, bindings)
|
||||
@globalKeymap.bindKeys(selector, bindings)
|
||||
|
||||
open: (url) ->
|
||||
OSX.NSApp.open url
|
||||
|
||||
@@ -23,3 +23,6 @@ class GlobalKeymap
|
||||
return true
|
||||
currentNode = currentNode.parent()
|
||||
false
|
||||
|
||||
reset: ->
|
||||
@BindingSets = []
|
||||
|
||||
@@ -22,22 +22,16 @@ class RootView extends Template
|
||||
globalKeymap: null
|
||||
|
||||
initialize: ({url}) ->
|
||||
@createGlobalKeymap()
|
||||
@editor.keyEventHandler = atom.globalKeymap
|
||||
@createProject(url)
|
||||
|
||||
@bindKeys '*'
|
||||
atom.bindKeys '*'
|
||||
'meta-s': 'save'
|
||||
'meta-w': 'close'
|
||||
'meta-t': 'toggle-file-finder'
|
||||
|
||||
@on 'toggle-file-finder', => @toggleFileFinder()
|
||||
|
||||
|
||||
createGlobalKeymap: ->
|
||||
@globalKeymap = new GlobalKeymap
|
||||
@on 'keydown', (e) => @globalKeymap.handleKeyEvent(e)
|
||||
@editor.keyEventHandler = @globalKeymap
|
||||
|
||||
createProject: (url) ->
|
||||
if url
|
||||
@project = new Project(fs.directory(url))
|
||||
|
||||
Reference in New Issue
Block a user