Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Expose command state #163

Open
glennsl opened this issue Sep 29, 2019 · 1 comment
Open

[Feature] Expose command state #163

glennsl opened this issue Sep 29, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@glennsl
Copy link
Member

glennsl commented Sep 29, 2019

There's currently no way to inspect the command state, i.e. which keys have been punched in and what command is in the process of being built. Knowing this would be useful for a couple of features:

  1. Displaying the current command state, which characters and what count, if any, has been entered, in case you get distracted in the middle of something and forget.

  2. To provide contextual help. This will both reduce the need to memorize commands AND make it easier to learn them. For example, if g has been entered, the UI could display a list of possible characters to "complete" the command:

g - Go to top
t - Go to next tab
T - Go to previous tab
u - Convert to lowercase
U - Convert to uppercase
~ - Swap case
] - See all definitions

Technical details

The command state, at least in normal mode, is stored in state_current->context->ca, a cmdarg_T. state_current->context is a void* and will point to different data structures depending on mode, but normal mode is mostly what I'm interested in here (or "Normal", "Visual" and "Operator" I guess, according to get_real_state()).

A new function vimGetCommandState could return either the entire cmdarg_T struct, or a subset if that's easier to bind to from Reason. Or null if the stars aren't aligned.

@glennsl glennsl added the enhancement New feature or request label Sep 29, 2019
@bryphe
Copy link
Member

bryphe commented Oct 3, 2019

This is a great suggestion, @glennsl ! Thank you! I like the idea of vimGetCommandState. Seems like this wouldn't be too hard to wire up - all the information is around.

Contextual help would be an amazing feature and help lower the learning curve & barrier to entry significantly.

bryphe added a commit that referenced this issue Aug 26, 2020
…#218)

This adds an API to get the current pending-operator information (what operator is pending, any associated register, and count). This is part of a fix for #163 - there are still some items that would be useful that this doesn't provide (ie, typed characters _prior_ to an operator becoming active).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants