From 1e50af3db8cd0ca273de485cea89c9e3f1b46d03 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Thu, 10 Nov 2011 01:17:53 -0800 Subject: [PATCH] cmd-D, cmd-shift-d, and cmd-shift-D are now all the same binding --- src/stdlib/key-binder.coffee | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/stdlib/key-binder.coffee b/src/stdlib/key-binder.coffee index 395090513..e1c1c6627 100644 --- a/src/stdlib/key-binder.coffee +++ b/src/stdlib/key-binder.coffee @@ -18,13 +18,13 @@ class KeyBinder load: (path) -> try - Watcher.watch path, => - # Should we keep track of which file bindings are associated with? - # That way we could clear bindings when the file is changed - # or deleted. I think the answer is yes, but I don't want to - # do this right now. - console.log "#{@name}: Reloading #{path}" - @load path +# Watcher.watch path, => +# # Should we keep track of which file bindings are associated with? +# # That way we could clear bindings when the file is changed +# # or deleted. I think the answer is yes, but I don't want to +# # do this right now. +# console.log "#{@name}: Reloading #{path}" +# @load path json = CoffeeScript.eval "return " + (fs.read path) # Iterate in reverse order scopes are declared. @@ -45,7 +45,9 @@ class KeyBinder keys.push @modifierKeys.control if event.modifierFlags & OSX.NSAlternateKeyMask keys.push @modifierKeys.alt - keys.push event.charactersIgnoringModifiers.charCodeAt 0 + if event.modifierFlags & OSX.NSShiftKeyMask + keys.push @modifierKeys.shift + keys.push event.charactersIgnoringModifiers.toLowerCase().charCodeAt 0 binding = keys.sort().join "-" @@ -101,14 +103,17 @@ class KeyBinder modifiers = [] key = null - for k in keys if modifier = @modifierKeys[k.toLowerCase()] - modifiers.push modifier unless modifier == @modifierKeys['shift'] # Shift is implied? YES + modifiers.push modifier else if key throw "#{@name}: #{binding} specifies TWO keys, we don't handle that yet." else if namedKey = @namedKeys[k.toLowerCase()] key = namedKey + else if shiftedKey = @shiftedKeys[k.charCodeAt 0] + if not _.include modifiers, @modifierKeys.shift + modifiers.push @modifierKeys.shift + key = k.toLowerCase().charCodeAt 0 else if k.length > 1 throw "#{@name}: #{binding} uses an unknown key #{k}." else @@ -177,3 +182,12 @@ class KeyBinder '[': 219 ']': 221 '\\': 220 + + shiftedKeys: + 48: ')', 49: '!', 50: '@', 51: '#', 52: '$', 53: '%', 54: '^' + 55: '&', 56: '*', 57: '(', 65: 'A', 66: 'B', 67: 'C', 68: 'D' + 69: 'E', 70: 'F', 71: 'G', 72: 'H', 73: 'I', 74: 'J', 75: 'K' + 76: 'L', 77: 'M', 78: 'N', 79: 'O', 80: 'P', 81: 'Q', 82: 'R' + 83: 'S', 84: 'T', 85: 'U', 86: 'V', 87: 'W', 88: 'X', 89: 'Y' + 90: 'Z', 186: ':', 187: '+', 188: '<', 189: '_', 190: '>' + 191: '?', 192: '~', 219: '{', 220: '|', 221: '}', 222: '"'