(cm, e)
| 2103 | |
| 2104 | var maybeTransition; |
| 2105 | function handleKeyBinding(cm, e) { |
| 2106 | // Handle auto keymap transitions |
| 2107 | var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto; |
| 2108 | clearTimeout(maybeTransition); |
| 2109 | if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() { |
| 2110 | if (getKeyMap(cm.options.keyMap) == startMap) { |
| 2111 | cm.options.keyMap = (next.call ? next.call(null, cm) : next); |
| 2112 | keyMapChanged(cm); |
| 2113 | } |
| 2114 | }, 50); |
| 2115 | |
| 2116 | var name = keyName(e, true), handled = false; |
| 2117 | if (!name) return false; |
| 2118 | var keymaps = allKeyMaps(cm); |
| 2119 | |
| 2120 | if (e.shiftKey) { |
| 2121 | // First try to resolve full name (including 'Shift-'). Failing |
| 2122 | // that, see if there is a cursor-motion command (starting with |
| 2123 | // 'go') bound to the keyname without 'Shift-'. |
| 2124 | handled = lookupKey("Shift-" + name, keymaps, function(b) {return doHandleBinding(cm, b, true);}) |
| 2125 | || lookupKey(name, keymaps, function(b) { |
| 2126 | if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion) |
| 2127 | return doHandleBinding(cm, b); |
| 2128 | }); |
| 2129 | } else { |
| 2130 | handled = lookupKey(name, keymaps, function(b) { return doHandleBinding(cm, b); }); |
| 2131 | } |
| 2132 | |
| 2133 | if (handled) { |
| 2134 | e_preventDefault(e); |
| 2135 | restartBlink(cm); |
| 2136 | if (ie_lt9) { e.oldKeyCode = e.keyCode; e.keyCode = 0; } |
| 2137 | signalLater(cm, "keyHandled", cm, name, e); |
| 2138 | } |
| 2139 | return handled; |
| 2140 | } |
| 2141 | |
| 2142 | function handleCharBinding(cm, e, ch) { |
| 2143 | var handled = lookupKey("'" + ch + "'", allKeyMaps(cm), |
no test coverage detected