Closed blukat29 closed 10 years ago
We have a database (as an JS array) with following scheme.
keys[] | type | [context]
type
is one of the
keyToKey, motion, operator, operatorMotion, action, search, ex
context
is optional. If omitted, it means open for both normal and visual mode.
If specified, it means the key is only available on the specific mode.
Since matching function already exists inside codemirror/keymap/vim.js
(arount line 1000, function matchCommand()), try make use of it. This function returns a perfect/best match, or null.
Vim.handleKey(cm, key)
exits in five ways:
macroModeState.isRecording && key == 'p'
clearInputState(cm); exitMacroMode()
.key == '<ESC>'
clearInputState(cm); if (vim.visualMode) exitVisualMode(cm);
g
key.
keyToKey
mapping found.
handleKey()
recursively.processCommand(cm, vim, command)
.Assume we do not consider macro function. Then we just put signals on each exit.
Or we could copy the Vim.handleKey
function and use only part of it. Prune some codes and make minimal handleKey
function. This way we can have our independent solution.
Working on custom matchCommand
function with custom fsm. This should be a good solution.
Continue from #1.
The problem we want to solve is to defining a function such that