[DRAFT] Keyboard mode experiments #1964
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Set up
There is a fixedKeymap.ts file. So you can change keybindings there. I am using dvorak-programmer keyboard so mapping is probably pretty weird for you.
I don’t think it needs anything special to run other than setting up the environment to run the extension. It took a few adjustments (see commit) but it seems to work now on my work machine.
Architecture changes
A few notes on the changes I did.
It was a bit confusing how
constructMergedKeymap
works and is quite limiting. For every function we want to assign we need to define another setting group(e.g.cursorless.experimental.keyboard.modal.keybindings.scopes
). I think we need an implementation that more freely allows us to map any “command” (green, ex, everyScope, scrollToCenter, …) to a specific handler function.My Handler functions basically set a Target, set a Modifier or excecute an cursorless action.
The functions that are assigned in
constructMergedKeymap
should(?) be able to request constrained keystrokes. Like theeveryScope
handler will request a keystroke that is constrained toSimpleScopeType
. (See Keybindings or change what layer is sampled next?)I might not understand cursorless well enough yet. But adding modifiers to explicit targets helped me a lot to understand how cursorless works. Just adding things to
that
was a bit too magical initially. So not sure if tracking targets is actually necessary.Keyboard bindings
I spend some time with the current keyboard bindings and the surrounding implementation. One roadblock is that we have much fewer keys than we can have voice commands. As such we need to rely on binding key sequences to increase the number of available commands we can input.
So for example we might bind as follows:
So if we want to select every character we would have to type
y v g
. However we know that the everyScope requires a scope. So by pressingy
we know that the next key press has to select a scope.To set that up with simple keybindings we get an explosion of bindings:
If we instead have multiple layers of keybindings we can assign every key multiple commands. Then each command could request the next key be a certain type. The everyScope would require a SimpleScopeType(?) as the next key.