lf icon indicating copy to clipboard operation
lf copied to clipboard

[BUG] lf receiving wrong input

Open Joyje opened this issue 1 year ago • 6 comments

map <c-i> ... gives this error message when used in lf: unknown mapping: <tab> Since <c-i> != <tab> this is obviously a bug.

Please test to confirm its not only on my setup

Joyje avatar Apr 01 '23 03:04 Joyje

I think it's a fundamental limitation of linux's usual terminal protocol that terminal programs can't distinguish <c-i> from <tab>. Same for <c-j> and <enter>. Some terminals try to work around that by extending the protocol, but that won't work everywhere and I doubt the library we use (tcell) supports it.

So, this bug might be a little more pervasive than you thought. We can't do anything about it.

ilyagr avatar Apr 01 '23 03:04 ilyagr

I think it's a fundamental limitation of linux's usual terminal protocol that terminal programs can't distinguish <c-i> from <tab>. Same for <c-j> and <enter>. Some terminals try to work around that by extending the protocol, but that won't work everywhere and I doubt the library we use (tcell) supports it.

So, this bug might be a little more pervasive than you thought. We can't do anything about it.

If that is accurate, then why can other programs, such as vim for example, differentiate between those inputs without any issues whatsoever, in the same terminal even?

Joyje avatar Apr 01 '23 03:04 Joyje

One reason it might work for you is if you use a program and a terminal that support Kitty's extension protocol. Your terminal and program should then be listed here. Note that there are only a few of them, but they do include recent versions of Vim. In principle, if you got tcell to support that protocol, it would immediately work for lf on those terminals.

Update: According to https://github.com/gdamore/tcell/issues/500#issuecomment-1374985324, the author of tcell is at least considering it.

I also don't know what happens on Windows.

If neither of these is the case, I have no idea how you got it to work. It certainly doesn't work with Vim on my terminal (alacritty).

ilyagr avatar Apr 01 '23 04:04 ilyagr

Apparently, there's an older alternative protocol: https://vimhelp.org/map.txt.html#modifyOtherKeys. It's supported by Micro's fork of tcell: https://github.com/zyedidia/tcell/.

So, you could probably hack together a version of lf that supports it by combining the two. I wouldn't move the official version of lf to use https://github.com/zyedidia/tcell/, though, as it's only being supported for the use of the Micro project.

Thanks for having me learn something new!

ilyagr avatar Apr 01 '23 04:04 ilyagr

Huh... that's interesting. I use rxvt and as far as I can see it isn't listed there so it shouldn't be compatible for me either. However, as I understand it with vim, it seems like it is implemented directly into the program so it shouldn't matter what terminal you're using, meaning it should work for you as well when using vim. That makes is kind of strange that it doesn't work for you. Maybe your version of vim is old?

Anyhow it goes to show then that this is at least fixable, no matter what terminal is used. However I understand it might be a huge project to migrate from tcells protocol to kittys protocol, and pointless even since tcell might add support for it in the future anyways as you mentioned.

Still, it is frustrating as hell.

Joyje avatar Apr 01 '23 04:04 Joyje

Thanks for having me learn something new!

The same to you! Much appreciated!

Let's hope it gets fixed by the guys building tcell.

Joyje avatar Apr 01 '23 04:04 Joyje

This is a general issue with terminals, not an issue with lf. I have added a section in the Troubleshooting page of the wiki about this.

joelim-work avatar Mar 26 '24 11:03 joelim-work

This is a general issue with terminals, not an issue with lf. I have added a section in the Troubleshooting page of the wiki about this.

Sort of, but not really. This is an issue with 'tcell', not with terminals. These key combinations still work in terminal emulators that doesn't support kitty, but only inside certain programs. How or why I do not know exactly, but if it works in 'vim' it is also possible to make it work in 'lf' somehow, if this is something we would want to pursue.

I would assume the issue is probably related to the protocols only, no matter what terminal emulator you are using, and some terminal programs such as 'vim' might use their own written protocols independenty from the terminal emulator itself. This is just an assumption however.

Also, I think the best way to handle this is to let the people developing 'tcell' fix it.

Joyje avatar Apr 12 '24 18:04 Joyje