blukat29 / vimedu

Learn basics of vim interactively.
MIT License
1 stars 1 forks source link

Redefine problem of context aware key help #4

Closed blukat29 closed 10 years ago

blukat29 commented 10 years ago

Continue from #1.

The problem we want to solve is to defining a function such that

blukat29 commented 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.

blukat29 commented 10 years ago

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.

blukat29 commented 10 years ago

Vim.handleKey(cm, key) exits in five ways:

Assume we do not consider macro function. Then we just put signals on each exit.

blukat29 commented 10 years ago

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.

blukat29 commented 10 years ago

Working on custom matchCommand function with custom fsm. This should be a good solution.