8000 Remove "bind -k" terminfo key names by krobelus · Pull Request #11342 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

Remove "bind -k" terminfo key names#11342

Closed
krobelus wants to merge 1 commit intofish-shell:masterfrom
krobelus:remove-terminfo-keynames
Closed

Remove "bind -k" terminfo key names#11342
krobelus wants to merge 1 commit intofish-shell:masterfrom
krobelus:remove-terminfo-keynames

Conversation

@krobelus
Copy link
Contributor
@krobelus krobelus commented Apr 1, 2025

I don't think there's a relevant terminal where the "bind -k" notation is
still needed. The remaining reason to keep it is backwards compatibility.

But "bind -k" is already subtly broken on terminals that implement either
of modifyOtherKeys, application keypad mode or the kitty keyboard protocol,
since those alter the byte sequences (see #11278).

Having it randomly not work might do more harm than good. Remove it.

This is meant go into 4.1, which means that users who switch back and forth
between 4.1 and 4.0 can already use the new notation.

If someone wants to use a bind config for a wider range of versions they
could use "bind -k 2>/dev/null" etc.

'f' => opts.mode = BIND_FUNCTION_NAMES,
'h' => opts.print_help = true,
'k' => opts.use_terminfo = true,
'K' => opts.mode = BIND_KEY_NAMES,
Copy link
Member

Choose a reason for hiding this comment

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

This will remove these options so it'll fall back to the "unknown option" error.

I think we should make these print a more specific error that tells you to rewrite your bindings.

I see this being triggered by old configuration a bunch.

#[rustfmt::skip]
return Box::new([
terminfo_add!(key_a1), terminfo_add!(key_a3), terminfo_add!(key_b2),
terminfo_add!(key_backspace), terminfo_add!(key_beg), terminfo_add!(key_btab),
Copy link
Member

Choose a reason for hiding this comment

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

Does that mean we can remove the keys from terminal.rs too?

@krobelus
Copy link
Contributor Author
krobelus commented Apr 1, 2025 via email

I don't think there's a relevant terminal where the "bind -k" notation is
still needed. The remaining reason to keep it is backwards compatibility.

But "bind -k" is already subtly broken on terminals that implement either
of modifyOtherKeys, application keypad mode or the kitty keyboard protocol,
since those alter the byte sequences (see fish-shell#11278).

Having it randomly not work might do more harm than good. Remove it.

This is meant go into 4.1, which means that users who switch back and forth
between 4.1 and 4.0 can already use the new notation.

If someone wants to use the bind config for a wider range of versions they
could use "bind -k 2>/dev/null" etc.

While at it, use the new key names in "bind --key-names".
@krobelus krobelus force-pushed the remove-terminfo-keynames branch from 5b38b0d to 2908c54 Compare April 1, 2025 16:32
@faho
Copy link
Member
faho commented Apr 1, 2025

I need to check again but it looks like we use terminfo for some workarounds
for terminals that are probably still not fixed

The biggest issue with terminfo is how often it is just plain wrong.

I could not find a current terminal that has the xn capability unset correctly. You can find definitions that have it turned off, sure. You'll find an outdated "wezterm" definition (but wezterm sets $TERM to xterm-256color), you'll find "xterm+direct" (but xterm doesn't set that either). And you will find literally hundreds of museum pieces like the "wy350" from 1985.

I can't find the terminfo definition for conemu (might be one called "msys"?), but if that's the only one we're better off hardcoding a hack for it or not supporting it.

The only thing that is an even vaguely sensible use of terminfo is to check colors, and I don't know of an existing current terminal that does not understand the 256 color sequences (cool-retro-term ignores them because it doesn't do color, but I do not know of a terminal that is actually limited to 16 colors and barfs on these). We could just allow "dumb" and "xterm-mono" to turn off color, or support the "NO_COLOR" variable.

@krobelus
Copy link
Contributor Author
krobelus commented Apr 1, 2025

We could just allow "dumb" and "xterm-mono" to turn off color,

that sounds good, because it's unlikely that these are set by accident.
(of course the recommended approach is still fish_config theme choose None).

I don't know of an existing current terminal that does not understand the 256 color sequences

that's good to know.

I was also wondering what's the deal with set_a_foreground / set_foreground.
But given that our fallback doesn't define set_foreground, it might be safe to assume the set_a_foreground one is widely supported.

@faho
Copy link
Member
faho commented Apr 1, 2025

of course the recommended approach is still fish_config theme choose None

(different things - that turns off syntax highlighting, but what if you can't have color escapes at all?)

But given that our fallback doesn't define set_foreground, it might be safe to assume the set_a_foreground one is widely supported

Here's a full list of all terminfo definitions on my system that have setf but not setaf:

ctrm
emots
gs6300
hft-old
ibm+color
mgterm
ncr260wy325pp
ncr260wy325wpp
ncr260wy350pp
ncr260wy350wpp
qansi
qansi-g
qansi-m
qansi-t
qansi-w
qnx
qnx4
qnxm
qnxt
qnxt4
qnxtmono
qnxw
tek4205
tw100
wy350
wy350-vb
wy350-w
wy350-wvb
wy370
wy370-101k
wy370-105k
wy370-EPC
wy370-nk
wy370-rv
wy370-vb
wy370-w
wy370-wvb
wyse350
wyse350-vb
wyse350-w
wyse350-wvb
wyse370

Yes it's all museum pieces.

Here's the script I used:

for term in (path filter -rf /usr/share/terminfo/** | path basename)
    tput -T $term setf &>/dev/null && not tput -T $term setaf &>/dev/null && echo $term
end 

@faho faho mentioned this pull request Apr 1, 2025
@krobelus krobelus closed this in fb2d427 Apr 2, 2025
@krobelus krobelus added this to the fish 4.1 milestone Apr 2, 2025
krobelus added a commit to krobelus/fish-shell that referenced this pull request Apr 10, 2025
This reverts commit 58347d4 (update PROMPT_SP heuristic, 2016-12-23)

If we write the last column of a line:

	printf %0"$COLUMNS"d 0; sleep 3

most terminals will *not* move the cursor to the next line.

This behavior is indicated by the terminfo's xenl (AKA xen or
eat_newline_glitch) boolean capability.

We originally added checks for this capability because ConEmu and Windows
ConHost did not implement it, but they do now.

Also, as mentioned in
fish-shell#11342 (comment),
we're not aware of any present-day terminal that does not have this behavior,
but the value advertised by terminfo is sometimes wrong.

Let's get rid of this for now. A following commit will document that we
require this behavior.
krobelus added a commit that referenced this pull request Apr 11, 2025
This reverts commit 58347d4 (update PROMPT_SP heuristic, 2016-12-23)

If we write the last column of a line:

	printf %0"$COLUMNS"d 0; sleep 3

most terminals will *not* move the cursor to the next line.

This behavior is indicated by the terminfo's xenl (AKA xen or
eat_newline_glitch) boolean capability.

We originally added checks for this capability because ConEmu and Windows
ConHost did not implement it, but they do now.

Also, as mentioned in
#11342 (comment),
we're not aware of any present-day terminal that does not have this behavior,
but the value advertised by terminfo is sometimes wrong.

Let's get rid of this for now. A following commit will document that we
require this behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0