mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
bindkey takes a scope, keycap is a method
This commit is contained in:
@@ -16,8 +16,8 @@ class Filefinder extends Pane
|
||||
|
||||
html: require "filefinder/filefinder.html"
|
||||
|
||||
keymap:
|
||||
'Command-T': 'toggle'
|
||||
keymap: ->
|
||||
'Command-T': @toggle
|
||||
# really wish i could put up/down keyboad shortcuts here
|
||||
# and have them activated when the filefinder is open
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class Project extends Pane
|
||||
|
||||
html: $ require "project/project.html"
|
||||
|
||||
keymap:
|
||||
keymap: ->
|
||||
'Command-Ctrl-N': 'toggle'
|
||||
|
||||
initialize: ->
|
||||
|
||||
@@ -13,7 +13,7 @@ class Tabs extends Pane
|
||||
# The Editor pane we're managing.
|
||||
editor: null
|
||||
|
||||
keymap:
|
||||
keymap: ->
|
||||
'Command-W': 'closeActiveTab'
|
||||
'Command-Shift-[': 'prevTab'
|
||||
'Command-Shift-]': 'nextTab'
|
||||
|
||||
@@ -9,7 +9,7 @@ File = require 'fs'
|
||||
|
||||
module.exports =
|
||||
class TinyTest extends Pane
|
||||
keymap:
|
||||
keymap: ->
|
||||
'Command-Ctrl-T': 'runTests'
|
||||
|
||||
runTests: ->
|
||||
|
||||
@@ -16,7 +16,7 @@ class Editor extends Pane
|
||||
position: 'main'
|
||||
html: '<div id="editor"></div>'
|
||||
|
||||
keymap:
|
||||
keymap: ->
|
||||
'Command-S' : 'save'
|
||||
'Command-Shift-S' : 'saveAs'
|
||||
'Command-C' : 'copy'
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
_ = require 'underscore'
|
||||
|
||||
ace = require 'ace/ace'
|
||||
canon = require 'pilot/canon'
|
||||
|
||||
key = require 'keymaster'
|
||||
|
||||
exports.bindKey = (name, shortcut, callback) ->
|
||||
key shortcut, -> callback(); false
|
||||
exports.bindKey = (scope, shortcut, method) ->
|
||||
key shortcut, ->
|
||||
if _.isFunction method
|
||||
method.apply scope
|
||||
else
|
||||
if scope[method]
|
||||
scope[method]()
|
||||
else
|
||||
console.error "keymap: no '#{method}' method found"
|
||||
|
||||
false
|
||||
|
||||
window.handleKeyEvent = (event) ->
|
||||
false
|
||||
# if (event.modifierFlags & OSX.NSCommandKeyMask) and event.keyCode == 50
|
||||
# console.log "Got Cmd-`"
|
||||
# true
|
||||
# else
|
||||
# false
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
_ = require 'underscore'
|
||||
|
||||
{bindKey} = require 'keybinder'
|
||||
|
||||
module.exports =
|
||||
@@ -8,22 +6,14 @@ class Pane
|
||||
|
||||
html: null
|
||||
|
||||
keymap: {}
|
||||
keymap: ->
|
||||
|
||||
constructor: (options={}) ->
|
||||
for option, value of options
|
||||
@[option] = value
|
||||
|
||||
for shortcut, method of @keymap then do (shortcut, method) =>
|
||||
bindKey method, shortcut, (args...) =>
|
||||
console.log "#{shortcut}: #{method}"
|
||||
if _.isFunction method
|
||||
method.call this
|
||||
else
|
||||
if @[method]
|
||||
@[method]()
|
||||
else
|
||||
console.error "keymap: no '#{method}' method found"
|
||||
for shortcut, method of @keymap()
|
||||
bindKey @, shortcut, method
|
||||
|
||||
@initialize options
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ class Window extends Pane
|
||||
nswindow: null
|
||||
panes: []
|
||||
|
||||
keymap:
|
||||
'Command-N' : 'new'
|
||||
'Command-O' : 'open'
|
||||
'Command-Shift-O' : 'openURL'
|
||||
'Command-Ctrl-K' : 'showConsole'
|
||||
'Command-Ctrl-R' : 'reload'
|
||||
keymap: ->
|
||||
'Command-N' : @new
|
||||
'Command-O' : @open
|
||||
'Command-Shift-O' : @openURL
|
||||
'Command-Ctrl-K' : @showConsole
|
||||
'Command-Ctrl-R' : @reload
|
||||
|
||||
constructor: (options={}) ->
|
||||
super options
|
||||
|
||||
Reference in New Issue
Block a user