paul-nameless / tg

terminal telegram client
The Unlicense
943 stars 75 forks source link

basic input editing #226

Closed Galicarnax closed 3 years ago

Galicarnax commented 3 years ago

Basic text manipulation when using StatusView' input. Key bindings similar to those in Vim's command line:

Navigation/editing attempts to be wide-charactare aware. Some key bindings (e.g., ctrl+arrows) might not work in some terminal emulators (curses returns different terminal-dependent values for keys). Current version tested in Linux only, with kitty, terminator, alacritty.

paul-nameless commented 3 years ago

Thanks for the PR and big work that you've done, it's really good staff 👍

As bash and emacs user, I would appreciate to have ctrl+b, ctrl+f for backward/forward one char movement. It would be good to have consistency and to be user friendly for those who have muscle memory of this key binding.

For the beginning of line I would suggest to use ctrl+a (also this is keybinding in shell). Or if you prefer we could add vim keybindings as well.

My personal feature request is alt+delete for backward word deletion, do you think it will be complicated to add?

Also, unfortunately for me some keybinding not working, though it's okay if they working for you.

Galicarnax commented 3 years ago

Perhapse, optimal solution would be to have a single param in config, something like INPUT_KEYS_STYLE, which might be set to, say, EMACS or VIM. The only problem here is that, to my knowledge, there is no universal way with curses to have certain key bindings (involving ctrl and alt modifiers) to behave identically across all terminal emulators. Well, having it working at least on some terminals is better than not working on all terminals, I think... So I'll try to make it.