mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Moved default bindings from Global keymap constructor to a separate method.
This commit is contained in:
@@ -15,8 +15,8 @@ class App
|
||||
|
||||
setupKeymap: ->
|
||||
@keymap = new GlobalKeymap()
|
||||
|
||||
$(document).on 'keydown', (e) => @keymap.handleKeyEvent(e)
|
||||
@keymap.bindDefaultKeys()
|
||||
|
||||
open: (url) ->
|
||||
$native.open url
|
||||
|
||||
@@ -9,15 +9,15 @@ class GlobalKeymap
|
||||
constructor: ->
|
||||
@bindingSets = []
|
||||
|
||||
bindDefaultKeys: ->
|
||||
@bindKeys "*",
|
||||
'meta-n': 'newWindow'
|
||||
'meta-o': 'open'
|
||||
|
||||
$(document).on 'newWindow', => $native.newWindow()
|
||||
$(document).on 'open', =>
|
||||
$(document).on 'open', =>
|
||||
url = $native.openDialog()
|
||||
atom.open(url) if url
|
||||
|
||||
|
||||
bindKeys: (selector, bindings) ->
|
||||
@bindingSets.unshift(new BindingSet(selector, bindings))
|
||||
@@ -29,7 +29,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
|
||||
|
||||
@@ -15,11 +15,11 @@ windowAdditions =
|
||||
startup: (url) ->
|
||||
@setupKeymap()
|
||||
@attachRootView(url)
|
||||
|
||||
$(window).on 'close', =>
|
||||
|
||||
$(window).on 'close', =>
|
||||
@shutdown()
|
||||
@close()
|
||||
|
||||
|
||||
$(window).focus()
|
||||
atom.windowOpened this
|
||||
|
||||
@@ -31,7 +31,7 @@ windowAdditions =
|
||||
|
||||
setupKeymap: ->
|
||||
@keymap = new GlobalKeymap()
|
||||
|
||||
@keymap.bindDefaultKeys()
|
||||
$(document).on 'keydown', (e) => @keymap.handleKeyEvent(e)
|
||||
|
||||
attachRootView: (url) ->
|
||||
|
||||
Reference in New Issue
Block a user