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

VI mode <M-...> bindings #560

Closed
mkoskar opened this issue Oct 14, 2017 · 3 comments
Closed

VI mode <M-...> bindings #560

mkoskar opened this issue Oct 14, 2017 · 3 comments

Comments

@mkoskar
Copy link

mkoskar commented Oct 14, 2017

I would like to have VI insert mode bindings for <M-...> where by <M-> I don't mean traditional 8bit meta but escape prefixed sequence. E.g., <M-h> would be ^]h that is Escape + h.

So I did:

registry.add_binding(Keys.Escape, 'h', filter=insert_mode)(...)

Now that works ok, but it seems to me prompt_toolkit doesn't have a notion of timeout for when there are multiple bindings for so far ambiguous input, i.e., with above in place I can't go to command mode just by pressing Escape. And even if there is no conflicting binding, there is delay (actually as I've figured out it's the eventloop's INPUT_TIMEOUT of 1s by default).

I think we need at least one timeout (see keyseq-timeout in readline) that can be set to something relatively low, in my case I set it to 10ms. You might also have a look how vim does it, it has ttimeoutlen for keycodes, and then separate timeoutlen for mappings.

@jonathanslenders
Copy link
Member

Hi @mkoskar,

Thanks for opening this issue! This is interesting.

I didn't know about ttimeoutlen. On my system it's 100ms by default. Prompt_toolkit 2.0 (see 2.0 branch) uses 500ms. Maybe we can decrease this. Maybe 200ms or 300ms, but not too much, because Python can be a little slower than C, and we don't want to call it too early.

Further, prompt_toolkit indeed doesn't support timeoutlen yet. I had no idea that Vim has this option. In my setup it's 1000ms for this one. I think we can do the same thing here.

This feature request makes sense. I can probably implement this in the 2.0 branch.

Jonathan

@jonathanslenders
Copy link
Member

Hi @mkoskar,

Here you go: faa202f
It's on the 2.0 branch. Hope that works for you.

FYI: we would like to release 2.0 in the coming months.

@jonathanslenders
Copy link
Member

jonathanslenders commented May 15, 2018

Closing this, given that it's implemented. Both timeoutlen and ttimeoutlen are now attributes of the Application object. Feel free to open again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants