Skip to content

[Feature] Expose command state #163

@glennsl

Description

@glennsl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions