|
|
void | enable (bool enable) |
| | Enable/Disable vim-mode throughout the application instance.
|
| |
|
bool | enabled () |
| | Is vim-mode enabled?
|
| |
|
Count | n () |
| | The vim-count from the current key sequence.
|
| |
| void | addBinding (const QString &sequence, const QString &action) |
| | Register a keybinding with Vim-mode. More...
|
| |
| void | addBindings (const QMap< QString, QString > &map) |
| | Convenient alternative to multiple calls of Vim::addBinding. More...
|
| |
| void | registerKeyPress (QKeyEvent *event, std::function< bool(const Action &action)> callback, bool allowCount=true) |
| | Process a key press in vim-mode. More...
|
| |
|
void | resetStroke () |
| | Discard the current key sequence and reset vim status indicator.
|
| |
|
QString | getStatusText () |
| | Get the vim status text for the current key sequence.
|
| |
Everything related to vim-mode inside schim.
| void Vim::registerKeyPress |
( |
QKeyEvent * |
event, |
|
|
std::function< bool(const Action &action)> |
callback, |
|
|
bool |
allowCount = true |
|
) |
| |
Process a key press in vim-mode.
- Parameters
-
| event | KeyPress event that triggered this. |
| callback | Callback for when the input key sequence matches a binding. |
| allowCount | Process vim-counts as part of a key sequence. |
When a widget receives a KeyPress event, it should call this function if vim-like behavior is desired. The event will be processed, the current vim key sequence will be updated and it will be shown in the vim status indicator of the main window. If the sequence matches a binding callback will be called with an appropriate Vim::Action.
- Note
- If vim-mode is not enabled, this function does nothing.
-
If
allowCount is false, treat numbers as normal key sequences.
- See also
Vim::Action
-
Vim::addBinding
First we determine if we are listening for the user to input a count (only if allowCount is true). We correspondingly process all digits the user enters and form a count.
Then, we test if the sequence matches a binding. If it does, callback is called. Otherwise, we test if any binding starts with the sequence that has been input so far. If even this is not the case, the sequence is discarded and the vim status is reset.