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

Remove terminfo.rb #769

Merged
merged 1 commit into from
Nov 14, 2024
Merged

Remove terminfo.rb #769

merged 1 commit into from
Nov 14, 2024

Conversation

tompng
Copy link
Member

@tompng tompng commented Oct 18, 2024

Reline uses fiddle to load terminfo from libncurses.
Fiddle and libncurses are not available in some environment. Fiddle will be removed from default gems, so we will going to have more problem loading terminfo.
When Reline is used in most terminal emulator, terminfo has no effect. Reducing dependency is better.

Impact of removing terminfo.rb

It depends on the statistics of environment variable TERM used in real world.
I searched with "export TERM=" in github.
(This does not reflect actual terminal emulator used in real world, but I don't have idea to figure it out)

Out of 46.8k files, these TERM values (146 files) has a different key bindings from key bindings that Reline registers without terminfo.

TERM value nubmer of files
aaa-60 8
aixterm 2
cons25 17
d210-dg 3
mach 19
qansi 35
sun, sun-color 31
vt52 11
xtermc 20

Detailed result is here https://gist.github.com/tompng/2e19e75234f61e250bafd4c50ec5b7be

Checking with infocmp command, sun, vt52 and d210-dg does not have cuu cud hpa capability that Reline uses. Reline might not work even with terminfo, so exclude them.
cons25 have different hpa value, mach and xtermc does not have hpa. Perhaps Reline does not work in these environments too.

In TERM=aaa-60|aixterm|cons25|mach|qansi|xtermc, End, PageUP, PageDown, Delete(Not Backspace) won't work. But some keyboard (example: Macbook) does not have these keys in the first place.

TERM Value of kend kpp knp kdch1
aaa-60 - - - \e[P
aixterm \e[146q \e[150q \e[154q \e[P
cons25 \e[F \e[I \e[G \u007F
mach \e[Y \e[V \e[U \e[9
qansi \e[Y \e[V \e[U \e[P
xtermc \e[Y \e[V \e[U -

Other tools

Readline uses terminfo
zsh uses terminfo.
node and ipython does not seem to use terminfo

…nment.

Reline works perfectly in most major terminal emulators without terminfo.
In minor/old terminal emulator, we used to get key bindings from terminfo, but I think it is not used so much.
@hsbt
Copy link
Member

hsbt commented Oct 21, 2024

If we should extract this feature to like reline-terminfo, I can prepare that. Please let me know this.

@st0012
Copy link
Member

st0012 commented Oct 21, 2024

Having an optional dependency for a small group of users to adapt reline to their keybindings seems like a great solution.
But if we were to make things even simpler (especially for maintainers), can having an optional file work as well? We keep it in reline but avoid loading it by default.

@tompng
Copy link
Member Author

tompng commented Nov 10, 2024

I think supporting terminfo inside Reline is more maintainable compared to supporting reline-terminfo gem

Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in support for this. Thank you for spending time investigating the usage of it 👍

@st0012 st0012 mentioned this pull request Nov 14, 2024
Copy link
Member

@ima1zumi ima1zumi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I tried a quick check with TERM settings in iTerm2, and there were no issues.

@ima1zumi ima1zumi merged commit 3ceba3b into ruby:master Nov 14, 2024
40 checks passed
matzbot pushed a commit to ruby/ruby that referenced this pull request Nov 14, 2024
non-windows environment.
(ruby/reline#769)

Reline works perfectly in most major terminal emulators without terminfo.
In minor/old terminal emulator, we used to get key bindings from terminfo, but I think it is not used so much.

ruby/reline@3ceba3bff7
@tompng tompng deleted the drop_terminfo branch November 15, 2024 03:33
headius added a commit to headius/jruby that referenced this pull request Dec 4, 2024
Brings in recent fixes including ruby/reline#769
which should resolve jruby#8466 by removing all fiddle use.

Fixes jruby#8466
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants