mirror of
https://github.com/atom/atom.git
synced 2026-02-08 21:55:05 -05:00
atom.bindKey calls RootView.bindKey
This commit is contained in:
committed by
Corey Johnson & Nathan Sobo
parent
e58f699681
commit
766f301bc1
@@ -7,6 +7,9 @@ class App
|
||||
constructor: ->
|
||||
@native = new Native
|
||||
|
||||
bindKeys: (selector, bindings) ->
|
||||
window.rootView.bindKeys(selector, bindings)
|
||||
|
||||
open: (url) ->
|
||||
OSX.NSApp.open url
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
$ = require 'jquery'
|
||||
fs = require 'fs'
|
||||
_ = require 'underscore'
|
||||
|
||||
Template = require 'template'
|
||||
Buffer = require 'buffer'
|
||||
@@ -21,21 +22,30 @@ class RootView extends Template
|
||||
globalKeymap: null
|
||||
|
||||
initialize: ({url}) ->
|
||||
@globalKeymap = new GlobalKeymap
|
||||
@on 'keydown', (e) => @globalKeymap.handleKeyEvent(e)
|
||||
@editor.keyEventHandler = @globalKeymap
|
||||
@createGlobalKeymap()
|
||||
@createProject(url)
|
||||
|
||||
@globalKeymap.bindKeys '*'
|
||||
@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))
|
||||
@editor.setBuffer(@project.open(url)) if fs.isFile(url)
|
||||
|
||||
bindKeys: (selector, bindings) ->
|
||||
@globalKeymap.bindKeys(selector, bindings)
|
||||
|
||||
addPane: (view) ->
|
||||
pane = $('<div class="pane">')
|
||||
pane.append(view)
|
||||
|
||||
Reference in New Issue
Block a user