bchao1 / bullet

🚅 Interactive prompts made simple. Build a prompt like stacking blocks.
https://pypi.org/project/bullet/
MIT License
3.55k stars 113 forks source link

vi-like navigation with j & k #21

Closed Jengah closed 5 years ago

Jengah commented 5 years ago

Adds vi-like navigation for feature request in https://github.com/Mckinsey666/bullet/issues/13. Although the request only asked for changes to the Bullet and Check classes, I also extended it to the ScrollBar class as well, as it feels just as applicable.

This was tested on macOS High Sierra and Ubuntu 16.04 (with a docker image). I don't have the bandwidth to know/test this in Windows, but nothing about this should introduce a breaking change in Windows.

Although I did my best to stifle my auto-formatter/linter, it looks like some trailing spaces were cut off automatically in some places. If this is a problem, I can fix it, but I do agree with and recommend the adoption a code-formatter as mentioned in https://github.com/Mckinsey666/bullet/issues/17

Jengah commented 5 years ago

Didn't notice you recently merged in some refactors to key registration. Will rebase and make necessary changes.

rcfox commented 5 years ago

This should be easier with #23 :)

Just do something like:

@keyhandler.register(ARROW_UP_KEY)
@keyhandler.register(VIM_UP_KEY)
def moveUp(self):
    #...
bchao1 commented 5 years ago

Since PR#23 already supports this (which is more flexible than hard-coding) I will close this PR.

Jengah commented 5 years ago

23 adds the ability to handle multiple keys, but doesn't implement the change in this PR (adding vi-like bindings). I will open in another branch with the actual implementation since the Feature Request wasn't added in #23