Skip to content

curses: Just use our hardcoded xterm-256color entry as the fallback#10905

Merged
faho merged 1 commit intofish-shell:masterfrom
faho:no-fallback-terminfo
Dec 14, 2024
Merged

curses: Just use our hardcoded xterm-256color entry as the fallback#10905
faho merged 1 commit intofish-shell:masterfrom
faho:no-fallback-terminfo

Conversation

@faho
Copy link
Copy Markdown
Member

@faho faho commented Dec 14, 2024

The values we would try are:

xterm-256color, xterm, ansi, dumb

This is a pretty useless list, because systems without "xterm-256color" but with "ansi" basically don't exist, and it is very likely that the actual terminal is more xterm-compatible than it is ansi.

So instead we just use our xterm-256color definition, which has a high likelihood of being basically correct.

The values we would try are:

xterm-256color, xterm, ansi, dumb

This is a pretty useless list, because systems without
"xterm-256color" but with "ansi" basically don't exist,
and it is very likely that the actual terminal is more
xterm-compatible than it is ansi.

So instead we just use our xterm-256color definition, which has a high
likelihood of being basically correct.
@faho faho added this to the fish 4.0 milestone Dec 14, 2024
@faho
Copy link
Copy Markdown
Member Author

faho commented Dec 14, 2024

I am this close to just ditching any and all reading of the terminfo database.

I have a script that tries to figure out how different terminfo entries actually are, and the answer is they barely are.

The trick is that you need to filter out a lot of entries - those for 1980s hardware terminals and those invented by ncurses (as well as various variants that just repeat the same information).

E.g. there is an "ms-terminal" entry for Microsoft's terminal, which is useless because that terminal uses xterm-256color and to a first approximation nobody sets $TERM (nor should they). It is also just flat out incorrect in some ways, like claiming that "cursor_down" is \E[B. It isn't, it behaves like xterm.

Or the tmux entry which claims that exit_attribute_mode is \E[m^O when the xterm sequence just works. Or the rxvt entry, which does have some legitimate differences in terms of keys, but also has the two parts of exit_attribute_mode swapped - which is not a functional difference.

I am extremely disillusioned with the entire terminfo system and would like to get away from it.

@krobelus
Copy link
Copy Markdown
Contributor

Agreed, thanks.

terminfo seems like a needless indirection; instead of standardizing a terminfo sequence-name it's easier to standardize the actual escape-sequences, because that one needs to exist regardless.

I don't know much about this; if there is a chance a user wants to keep terminfo for now (as workaround), we could start with an ignore-terminfo feature flag? I guess we might find that when we turn it on, things will already work better on average across the userbase, since we'll no longer read wrongly configured values. It's probably fine to change it on master, as a trial balloon

@faho faho merged commit a98997f into fish-shell:master Dec 14, 2024
@faho faho deleted the no-fallback-terminfo branch December 14, 2024 11:10
@zanchey
Copy link
Copy Markdown
Member

zanchey commented Jan 4, 2025

I have a script that tries to figure out how different terminfo entries actually are, and the answer is they barely are.

kitty is the only modern terminal I know of that maintains a terminfo.

@krobelus
Copy link
Copy Markdown
Contributor

krobelus commented Jan 4, 2025

I think foot too, and both support querying terminfo capabilites via XTGETTCAP.
Querying the terminal directly instead of reading a terminfo file seems like the best approach.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jan 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants