Commit graph

19608 commits

Author SHA1 Message Date
Johannes Altmanninger
769b38da88 Move cursor on mouse click via kitty's OSC 133 click_events=1
When the user clicks somewhere in the prompt, kitty asks the shell
to move the cursor there (since there is not much else to do).

This is currently implemented by sending an array of
forward-char-passive commands.  This has problems, for example it
is really slow on large command lines (probably because we repaint
everytime).

Implement kitty's `click_events=1` flag to set the
position directly.  To convert from terminal-coordinates
to fish-coordinates, query [CSI 6 n Report Cursor
Position](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html)
and use it to compute the left prompt's terminal-coordinates (which
are (0, 0) in fish-coordinates).

Unfortunately this doesn't work correctly while the terminal is
scrolled.  This is probably because the cursor position is wrong
if off-screen.  To fix that we could probably record the cursor
position while not scrolled, but it doesn't seem terribly important
(the existing implementation also doesn't get it right).

Also add parsing for some unused mouse events; I'll probably remove
them again unless we can use them now.

Future work:

1. Knowledge of the position of the prompt will
   also enable us to make [ctrl-l scroll instead of erasing]
   (https://codeberg.org/dnkl/foot/wiki#how-do-i-make-ctrl-l-scroll-the-content-instead-of-erasing-it)
   (as of wiki commit b57489e298f95d037fdf34da00ea60a5e8eafd6d) which
   might be a better default.

2. We still turn off mouse reporting.  If we turned it on, it
   would be harder to select text in the terminal itself (not fish).
   This would typically mean that mouse-drag will alter fish's
   selection and shift+mouse-drag or alt+mouse-drag can be used.

   To improve this, we could try to synchronize the selection:
   if parts of the fish commandline are selected in the terminal's
   selection, copy that to fish's selection and vice versa.

   Or maybe there is an intuitive criteria, like: whenever we receive
   a mouse event outside fish, turn off mouse reporting, and turn
   it back on whenver we receive new keyboard input.  One problem
   is that we lose one event (though we could send it back to the
   terminal). Another problem is we would turn it back on too late
   in some scenarios.
2024-12-22 11:25:38 +01:00
Johannes Altmanninger
381b38af0a Skip tmux multiline prompt test for BusyBox less
BusyBox less is present on alpine CI; it doesn't support the "+q"
command passing style, so it's not directly usable by this test.
2024-12-21 14:41:41 +01:00
Johannes Altmanninger
965bc78d33 Work around weird CI failures due to missing pre-execute \r\n
I forgot that 610338cc70 (On undo after execute, restore the cursor
position, 2024-12-21) would cause a fallout to tests:

It makes us reuse in another place our usual cursor-movement sequences.

This causes failures like this (linebreaks added for readability):

	Testing file pexpects/bind.py:Failed to match pattern: (?:\r\n|\x1b\[2 q)[^\n]*def abc\r\n
	bind.py:45: timeout from expect_prompt(TO_END + "def abc\r\n")  # emacs transpose words, default timeout: no delay

	Escaped buffer:
	\x1b[?2004h\x1b[>4;1m\x1b[=5u\x1b=\rprompt 2>echo \rprompt 2>echo abc \rprompt 2>echo def abc\r
	prompt 2>echo def abc\x1b[?2004l\x1b[>4;0m\x1b[=0u\x1b>\x1b]133;C\x07def abc\r\n\x1b]133;D;0\x07\x1b[?25h⏎
	\r⏎ \r\rprompt 3>\x1b[?2004h\x1b[>4;1m\x1b[=5u\x1b=

It seems that we don't print anything where we should print something
like "\r\n" or "\e[2 q" to move the cursor below the command line.

I haven't gotten to the bottom of this but it might be related to
terminfo. Once we get rid of that, we can unconditionally print
our canonical movement sequences.

This issue seems to only affect tests, since fish operates fine in
a sourcehut CI system. Let's ignore it for now.
2024-12-21 14:37:57 +01:00
Johannes Altmanninger
610338cc70 On undo after execute, restore the cursor position
Ever since 149594f974 (Initial revision, 2005-09-20), we move the
cursor to the end of the commandline just before executing it.

This is so we can move the cursor to the line below the command line,
so moving the cursor is relevant if one presses enter on say, the
first line of a multi-line commandline.

As mentioned in #10838 and others, it can be useful to restore the
cursor position when recalling commandline from history. Make undo
restore the position where enter was pressed, instead of implicitly
moving the cursor to the end. This allows to quickly correct small
mistakes in large commandlines that failed recently.

This requires a new way of moving the cursor below the command line.
Test changes include unrelated cleanup of history.py.
2024-12-21 13:10:34 +01:00
Johannes Altmanninger
f9fb026085 Document possible CMake/Rust versions usable for Git bisect
rustc and CMake are usually backwards compatible but with Corrosion
in the mix this is often not the case.
Here's the canonical place to document it.
2024-12-21 13:07:01 +01:00
Johannes Altmanninger
1e7de063bd Fix regression of builtin read not exiting on ctrl-c
Commit 8bf8b10f68 (Extended & human-friendly keys, 2024-03-30) stopped
ctrl-c from exiting without a motivation. Unfortunately this was
only noticeable on terminals that speak the kitty keyboard protocol,
which is probably no one had noticed so far.

Closes #10928
2024-12-21 05:54:52 +01:00
David Adam
541f8b47bf Revert "Add completions for dust"
This reverts commit 27c7578760.

dust generates its own completions (which are shipped in the wrong spot
in the Debian packages, but which are also more up-to-date).

Closes #10922.
2024-12-19 19:49:01 +08:00
David Adam
6eec2db292 fish.spec: update dependencies for the terminfo database
RH/Fedora and openSUSE use different package names.

Closes #10920.
2024-12-19 14:48:01 +08:00
Johannes Altmanninger
039011bc81 Make full autosuggestions case-correcting again
Fixes ca21872d14 (Clean up the accept-autosuggestion code path a
little bit, 2024-11-14).
Fixes #10915
2024-12-18 19:02:27 +01:00
metamuffin
9abec243a4
Completions for mksquashfs (#10909) 2024-12-18 10:36:30 -06:00
Fabian Boehm
f89e26b06e installable: Reword $HOME error 2024-12-18 17:26:25 +01:00
David Adam
80d53b129f macOS codesigning: use stable Rust
The apple-codesign crate has a fairly aggressive MSRV policy, and the
compiler itself still targets 10.12 which is well below the minimum
version of macOS for aarch64. Just use stable.
2024-12-18 23:38:13 +08:00
Ilya Grigoriev
7162822486 rclone.fish: assume a recent version if the version cannot be parsed
The version of rclone is set during compilation and could be any crazy string depending on the packager, whether it's a dev build, etc. If it cannot be parsed, let's assume a recent version.

Follows up on cc8fa0f7
2024-12-18 15:31:51 +01:00
David Adam
7c2a379674 RPM/Debian packaging: add find dependency
Closes #10913
2024-12-18 11:04:41 +08:00
Klaus Hipp
25534bf657 Add tex-fmt completions 2024-12-18 02:21:57 +08:00
David Adam
687001f8b7 Merge branch 'Integration_4.0.0'
This merge throws away a commit from master which was a duplicate of one on
Integration_4.0.0, and just allows the history to remain mostly-linear.
2024-12-17 23:54:00 +08:00
David Adam
e6fea730e2 Update Cargo.lock with version number bump from Cargo.toml 2024-12-17 23:48:48 +08:00
Fabian Boehm
b56bb80a14 tests/version: Update for "-beta"
We used to call our beta versions "...b1", but cargo doesn't like
that.

So we need to adjust the regex here.
2024-12-17 16:44:34 +01:00
Fabian Boehm
5fc47f37a6 Update Cargo.lock
This includes the crate version, so any build would otherwise claim
it's "dirty"
2024-12-17 16:44:10 +01:00
David Adam
8557c3c48c Release 4.0b1 2024-12-17 22:51:11 +08:00
David Adam
c54dfa12c1 CHANGELOG: work on 4.0.0 2024-12-17 22:23:32 +08:00
Klaus Hipp
67fa71a94d
Update zed completions (#10907)
Add uninstall option.
2024-12-16 19:42:57 -06:00
Johannes Altmanninger
0275c5e803 Swap variable overrides and time in not statement
This is allowed

	time a=b echo 123

but -- due to an oversight in 3de95038b0 (Make "time" a job prefix,
2019-12-21) -- this is not allowed:

	not time a=b echo 123

Instead, this one one works:

	not a=b time echo 123

which is weird because without the "not" this would run "/bin/time".

It seems wrong that "not" is not like the others. Swap the order
for consistency.

Note that unlike "not", "time" currently needs to come before variable
assignments, so "a=b time true" is disallowed. This matches zsh. POSIX
shells call "/bin/time" here. Since it's ambiguous, erroring out seems
fine. It's weird that we're inconsistent with not here but I guess
"command not" is not expected to have subtly different behavior.

Closes #10890
2024-12-16 06:33:47 +01:00
Johannes Altmanninger
8fd0399ed3 Remove runaway kw_builtin in not statement definition
This was added accidentally in 971d257e67 (Port AST to Rust,
2023-04-02).  It does not seem to be causing an observable effect
(although I didn't try hard).
2024-12-16 06:33:47 +01:00
Johannes Altmanninger
ac951427af Fix alt-l on multiline tokens
This would invoke test with extra arguments.
2024-12-16 06:33:47 +01:00
Fabian Boehm
95f4c9c07e One more FreeBSD-only-in-CI 2024-12-15 17:38:37 +01:00
Fabian Boehm
8add30e3bf pexpects: Disable exit on CI Darwin/FreeBSD 2024-12-15 17:33:12 +01:00
Fabian Boehm
cb3fbd3a5c pexpects: Disable 2 only on CI
As the comment says
2024-12-15 17:32:47 +01:00
Fabian Boehm
9b9663ea44 CHANGELOG: We need a C compiler even for the main binary
Not just libc.c, but also the rsconf tests.
2024-12-15 17:15:35 +01:00
David Adam
a23cd62ec7 RPM/Debian packaging: update dependencies to match reality 2024-12-15 23:53:55 +08:00
David Adam
489d6b9dd8 CHANGELOG: work on 4.0.0 2024-12-15 23:52:30 +08:00
Fabian Boehm
10ac98e2ea installable: Only panic without sphinx if FISH_BUILD_DOCS=1
It's pretty annoying that this panics without sphinx, because the
install itself would be *working*.

So instead we tell the user that they need to clean or set
$FISH_BUILD_DOCS if they want to try again.
2024-12-15 09:00:16 +01:00
Fabian Boehm
46ce01223b staticbuilds: Fix aarch64 cross-compile
We get "undefined reference to `__memmove_chk'" when compiling
pcre2 (via pcre2-sys) on newer Ubuntu.

That one is used with higher fortify_source levels, and Ubuntu 24.04
defaults to 3, while my arch system (where I cannot reproduce)
defaults to 2.
2024-12-14 13:39:20 +01:00
Fabian Boehm
50c737fa55 CHANGELOG 2024-12-14 12:14:55 +01:00
Fabian Boehm
a98997fab0 curses: Just use our hardcoded xterm-256color entry as the fallback
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.
2024-12-14 12:10:34 +01:00
Fabian Boehm
cc8fa0f780 completions/rclone: Make version check more lenient
This has been observed to be "rclone 1.68.2" instead of "rclone
v1.68.2", missing the "v".
2024-12-14 11:20:29 +01:00
Fabian Boehm
378e9b236a Silence time_t deprecation
This is not something that affects us or we can do anything about.
2024-12-14 09:34:52 +01:00
Johannes Altmanninger
0a145cff3c Fix clippy lints 2024-12-14 09:31:20 +01:00
Johannes Altmanninger
f9febba2b0 Fix replacing completions with a -foo prefix
Fixes #10904
2024-12-14 09:31:20 +01:00
Fabian Boehm
84d8655677 fmt! 2024-12-13 21:57:07 +01:00
Fabian Boehm
abc1a45ea1 Shorten error for broken $TERM 2024-12-13 21:46:17 +01:00
Fabian Boehm
be16eeef69 Make --install install without confirmation, and not exit 2024-12-13 19:19:26 +01:00
Fabian Boehm
6d28845c2b Automatically attempt to install
This is fairly subtle.

When installable, and we either can't find the version file or it is
outdated, we ask the user to confirm installation (just like `--install`).

We do that only if we are really truly interactive (with a tty!) to
avoid `fish -c` running into problems.
This check could be tightened even more, because currently:

```fish
fish -ic 'echo foo'
```

asks, while

```fish
fish -ic 'echo foo' < /dev/null
```

does not.

`fish -c` will still error out if it can't find the config, but it
will just run if it is out of date.
2024-12-13 19:19:26 +01:00
Fabian Boehm
99fa8aaaa7 Really hide install() from clippy 2024-12-11 17:21:34 +01:00
Fabian Boehm
fa298c41e0 Hide install() from clippy
Not checkable because it would require sphinx
2024-12-11 17:18:34 +01:00
Fabian Boehm
327aa964e9 Disable default features for cargo test
Unfortunately it does not appear like #[cfg(test)] works for build.rs?

Investigating a better solution, but this is a good idea anyway (or `make
test` would generate man pages via build.rs!)
2024-12-11 17:05:38 +01:00
Fabian Boehm
6c852655dd Disable man page building in clippy
This would otherwise break any clippy run if you didn't have sphinx installed.
2024-12-11 16:56:14 +01:00
Fabian Boehm
0e0d56d805 format 2024-12-11 16:51:25 +01:00
Fabian Boehm
2d2f18c159 installable builds: Fail when building man pages fails
This is unfortunately necessary, because otherwise it would not rerun
the build script just because you installed sphinx.

Because we use the man pages for --help output, they're pretty
necessary.

To override it, you can set $FISH_BUILD_DOCS=0, like

```fish
FISH_BUILD_DOCS=0 cargo install --path .
```
2024-12-11 16:49:49 +01:00
David Adam
c58313fb2b README: minor formatting update 2024-12-11 08:04:52 +08:00