Commit Graph

21 Commits

Author SHA1 Message Date
ridiculousfish
838ff86ae7 Rename printf crate to fish-printf
Preparing to publish to crates.io
2024-06-09 12:29:09 -07:00
ridiculousfish
9e406e4fbc Silence some clippies 2024-05-27 11:07:02 -07:00
ridiculousfish
f16a1361c5 Adopt the new printf crate
This drops our usage of printf-compat.
2024-05-26 16:07:27 -04:00
Johannes Altmanninger
de7f39d627 builtin bind: make function keys lowercase (f1 instead of F1)
All other key names are lowercase so this inconsistency is weird.
2024-05-22 22:38:06 +02:00
Johannes Altmanninger
7dc0446c5c Match stdlib strip_prefix return value 2024-04-20 13:34:08 +02:00
Johannes Altmanninger
24e4fdd695 Support "bind xyz" again
This was used in Vi mode (for yiw and "*p) so rejecting it is a bit reckless.
2024-04-20 13:34:08 +02:00
Johannes Altmanninger
040cb04423 Escape nonprintable characters when reporting invalid key name
Part of #10450
2024-04-18 23:27:05 +02:00
Fabian Boehm
3b6a11f881 fmt 2024-04-18 22:26:14 +02:00
Fabian Boehm
6558c0a8e5 key: Actually do engage legacy mode if first char is control
This was already in the comment.

Fixes #10450
2024-04-18 22:18:51 +02:00
Johannes Altmanninger
27b1f28108 Minimize key parsing fallback logic and update changelog 2024-04-15 09:40:21 +02:00
Johannes Altmanninger
9db53e8d26 Allow abbreviating ctrl-/alt- as c-/a-
This makes them more convenient to use interactively, similar to the existing
\c and \a versions.  The resulting bind output keeps using the canonical
ctrl/alt version.

Not sure about s- because that's somewhat ambiguous, it could be "super".
2024-04-12 11:27:55 +02:00
Johannes Altmanninger
bc4897b2b5 Remove "plus" from named keys
It's not necessary and it's confusing if the canonical version unnecessarily
deviates from the input (we use + for Vi binds).
2024-04-12 11:27:55 +02:00
Johannes Altmanninger
adb40149a3 Do not insert key's PUA encoding into the command line
If a key's codepoint is in the PUA1 range, it could
be either from our own named keys (like key::Space)
or from a CSI u key that we haven't assigned a name yet
https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional-key-definitions
(The latter can still be bound using the \u1234 or the equivalent \e[4660u
raw CSI u sequence.)

It doesn't make sense to insert a PUA character into the commandline when
the user presses PrintScreen; ignore them silently.

This partially reverts b77d1d0e2 (Stop crashing on invalid Unicode input,
2024-02-27). That commit did:
1. convert input byte sequences that map to a PUA codepoint into several
   characters, using our on-char-per-byte PUA encoding.
2. do the same for inputs that are codepoints outside the valid Unicode range.
3. render them as replacement character (one per input byte)

In future, we should probably remove these features altogether, and simply
ignore invalid Unicode code points.
2024-04-09 00:46:16 +02:00
Johannes Altmanninger
e934e1b009 Test that bind output can recreate the same bindings 2024-04-09 00:22:41 +02:00
Johannes Altmanninger
f61ef2c63d Display raw escape sequences the old way again
If a binding was input starting with "\e", it's usually a raw control sequence.
Today we display the canonical version like:

    bind --preset alt-\[,1,\;,5,C foo

even if the input is

    bind --preset \e\[1\;5C foo

Make it look like the input again.  This looks more familiar and less
surprising (especially since we canonicalize CSI to "alt-[").

Except that we use the \x01 representation instead of \ca because the
"control" part can be confusing. We're inside an escape sequence so it seems
highly unlikely that an ASCII control character actually comes from the user
holding the control key.

The downside is that this hides the canonical version; it might be surprising
that a raw-escape-sequence binding can be erased using the new syntax and
vice versa.
2024-04-09 00:07:27 +02:00
Johannes Altmanninger
d025b245f6 Fix parsing of single-digit function keys 2024-04-09 00:07:27 +02:00
Johannes Altmanninger
ece4ebaf72 fish_key_reader: show unmapped function key as hex code
We don't yet support all keys from
https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional-key-definitions
Instead of displaying a private-use character, show the character code;
this can be used to map the key even if we don't know a name for it.

    bind \uE011 'echo print screen'
    bind ctrl-\uE011 'echo do control + print screen'

Note that it's also possible to mape the raw CSI u sequence, like

    bind \e\[57361u 'echo print screen'

but we should not encourage that syntax because it does not allow adding
the modifiers like ctrl.

Of course leaking the PUA character code is not ideal.
2024-04-08 09:16:55 +02:00
Johannes Altmanninger
b97187c90b Fix crash displaying CSI u codepoints in ASCII control range 2024-04-07 09:59:09 +02:00
Johannes Altmanninger
b04dee358e Don't translate \n to enter
Apparently it's never entere because we turn off ICRNL.

I'm not sure why it says "no binding found".
2024-04-02 17:59:40 +02:00
Johannes Altmanninger
e8e91c97a6 fish_key_reader: ignore sentinel key
Also, move the undo grouping for paste to the right place.
2024-04-02 16:48:25 +02:00
Johannes Altmanninger
8bf8b10f68 Extended & human-friendly keys
See the changelog additions for user-visible changes.

Since we enable/disable terminal protocols whenever we pass terminal ownership,
tests can no longer run in parallel on the same terminal.

For the same reason, readline shortcuts in the gdb REPL will not work anymore.
As a remedy, use gdbserver, or lobby for CSI u support in libreadline.

Add sleep to some tests, otherwise they fall (both in CI and locally).

There are two weird failures on FreeBSD remaining, disable them for now
https://github.com/fish-shell/fish-shell/pull/10359/checks?check_run_id=23330096362

Design and implementation borrows heavily from Kakoune.

In future, we should try to implement more of the kitty progressive
enhancements.

Closes #10359
2024-04-02 14:35:16 +02:00