mirror of
https://github.com/atom/atom.git
synced 2026-02-08 21:55:05 -05:00
Add App.bindKey
This commit is contained in:
@@ -15,6 +15,9 @@ class App
|
||||
bindKeys: (selector, bindings) ->
|
||||
@globalKeymap.bindKeys(selector, bindings)
|
||||
|
||||
bindKey: (selector, pattern, eventName) ->
|
||||
@globalKeymap.bindKey(selector, pattern, eventName)
|
||||
|
||||
open: (url) ->
|
||||
OSX.NSApp.open url
|
||||
|
||||
|
||||
@@ -12,6 +12,11 @@ class GlobalKeymap
|
||||
bindKeys: (selector, bindings) ->
|
||||
@bindingSets.unshift(new BindingSet(selector, bindings))
|
||||
|
||||
bindKey: (selector, pattern, eventName) ->
|
||||
bindings = {}
|
||||
bindings[pattern] = eventName
|
||||
@bindKeys(selector, bindings)
|
||||
|
||||
handleKeyEvent: (event) ->
|
||||
currentNode = $(event.target)
|
||||
while currentNode.length
|
||||
|
||||
@@ -29,10 +29,8 @@ class VimMode
|
||||
@registerCommand i, "numeric-prefix-#{i}", => new op.NumericPrefix(i)
|
||||
|
||||
registerCommand: (binding, commandName, fn)->
|
||||
bindings = {}
|
||||
eventName = "command-mode:#{commandName}"
|
||||
bindings[binding] = eventName
|
||||
atom.bindKeys '.command-mode', bindings
|
||||
atom.bindKey '.command-mode', binding, eventName
|
||||
@editor.on eventName, =>
|
||||
possibleOperator = fn()
|
||||
@pushOperator(possibleOperator) if possibleOperator.execute?
|
||||
|
||||
Reference in New Issue
Block a user