change cursor shape depending on edit mode #494
Merged
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.
Modal editors such as vim/neovim/etc. often use different cursors for different edit modes.
In it's current state, this pr changes the cursor to a line if the user is in insert mode, and uses a block cursor for all other modes (including custom and emacs).
Unfortunately, there is no way to retrieve the current cursor shape in crossterm that I know of, so restoring the previous cursor when exiting reedline could prove to be quite difficult. I currently can think of two solutions for this:
Regarding configurability, I think it should be possible to configure the cursor depending on the mode, this would be quite useful for nushell as it would allow customizing the behaviour in the config record. Depending on how the implementation ends up looking, it might also be a good idea to hide this behind a
with_custom_cursors()
function.Once I've resolved all those problems, I might also look into enabling/disabling cursor blinking. Uni is starting next week so it could take a while until this is in a polished state, but I will try to come back to this regularly.