curseradio icon indicating copy to clipboard operation
curseradio copied to clipboard

Add Vim-like keybinds

Open AndrewOlsen opened this issue 7 years ago • 7 comments

This adds vim-like keybinds in addition to the arrow keys for moving throughout the interface. Since k is used for navigation, I am proposing to use s to stop the stream.

AndrewOlsen avatar Oct 02 '17 16:10 AndrewOlsen

Thank you for contributing, and sorry about the delay - busy week.

This looks good, but I'm a bit wary about changing the meaning of an existing keybinding (and probably one of the more commonly used ones). The basic keymap might not be ideal, but unfortunately it exists now. Possibly this should live under a config option or command line switch, although I'm open to other suggestions.

chronitis avatar Oct 09 '17 20:10 chronitis

No worries!

I think a config file would do the trick. It would allow the user to specify their own keybinds, not just vim-like ones.

What are your thoughts?

AndrewOlsen avatar Oct 09 '17 21:10 AndrewOlsen

Yes, a config file would probably work. Doubtless there are other things it can be used for, like the hardcoded OPML root it currently uses.

The xdg library (pyxdg on pypi) should let you get the appropriate config dir (~/.config/curseradio), and either python's configparser or something similar like toml would work well for config.

Edit: let me have a look at adding a config mechanism myself for the next couple of days, since that's probably slightly out-of-scope of this PR.

chronitis avatar Oct 10 '17 08:10 chronitis

Preliminary support for a config file has been added. If you create ~/.config/curseradio/curseradio.cfg with contents:

[interface]
keymap=vim

[keymap.vim]
up=k
down=j
start=g
end=G
pageup=K
pagedown=J
stop=s

you should get some more vim-familiar behaviour. The config format should probably not be considered stable (input on a better design welcome).

chronitis avatar Oct 17 '17 19:10 chronitis

Would be nice to have this merged.

oblitum avatar Dec 16 '17 18:12 oblitum

The only changes in this branch seem to be changing the list of keybinding in README.md, but no changes to code? Do you have something uncommitted or unpushed?

Adding a default set of vim-keybinding should presumably now consist of a mapping in curseradio/curseradio.py CONFIG_DEFAULT['keymap.vim'] (line 35 or so).

Edit: sorry, released that comment is not from the original author. If this pull gets updated to add a (optional) vim keymap, I'm happy to include it.

chronitis avatar Dec 17 '17 18:12 chronitis

@chronitis what needs to be done, for this to get merged?

eyJhb avatar May 06 '18 17:05 eyJhb