Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make vice a keyboard handler as all the nasty bugs were fixed in ace.

  • Loading branch information...
commit eb30b87ad6050125280ef1502c1c6c5d15520dd9 1 parent aac24ee
Irakli Gozalishvili authored
Showing with 15 additions and 16 deletions.
  1. +12 −11 keyboard.js
  2. +3 −5 settings.js
23 keyboard.js
View
@@ -192,25 +192,26 @@ var states = exports.states = {
]
}
-var handler = new StateHandler(states)
+var handler = exports.handler = new StateHandler(states)
exports.bindings = function(env) {
var data = {}
return {
- setKeyboardHandler: function() {},
- getKeyboardHandler: function() { return handler },
handle: function handle(e, hashId, keyOrText, keyCode) {
var action = handler.handleKeyboard(data, hashId, keyOrText, keyCode, e)
- if ((!action || !action.command) && hashId === 0 && keyCode === 0)
- action = { command: "inserttext", args: { text: keyOrText } }
- if (canon && canon.exec(action.command, env, "editor", action.args))
- return event.stopEvent(e)
+ if ((!action || !action.command) && (hashId === 0 || keyCode === 0))
+ action = canon.findKeyCommand(env, "editor", hashId, keyOrText) || { command: "inserttext", args: { text: keyOrText } }
+
+ if (action && canon.exec(action.command || action.name, env, "editor", action.args))
+ return !event.stopEvent(e)
+
+ return false
},
- onCommandKey: function onCommandKey(event, hashId, keyCode) {
- var keyString = keyUtil.keyCodeToString(keyCode)
- this.handle(event, hashId, keyString, keyCode)
+ onCommandKey: function onCommandKey(event, hashId, keyCode, keyString) {
+ keyString = keyString || keyUtil.keyCodeToString(keyCode)
+ return this.handle(event, hashId, keyString, keyCode)
},
onTextInput: function onTextInput(input) {
- this.handle({}, 0, input, 0)
+ return this.handle({}, 0, input, 0)
}
}
}
8 settings.js
View
@@ -10,9 +10,8 @@
// save `env` given on startup and use it in setting change listeners.
var env
-var keyboardBindings = require('./keyboard').bindings
+var handler = require('./keyboard').handler
var utils = require('./utils')
-var defaultKeyboardBindings;
var settings = {
isVimMode: {
@@ -22,12 +21,11 @@ var settings = {
defaultValue: true,
onChange: function onChange(event) {
if (event.value) {
- defaultKeyboardBindings = env.editor.keyBinding
- env.editor.keyBinding = keyboardBindings(env);
+ env.editor.setKeyboardHandler(handler)
utils.normalMode(env)
} else {
+ env.editor.setKeyboardHandler(null)
utils.insertMode(env)
- env.editor.keyBinding = defaultKeyboardBindings;
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.