Commit graph

5536 commits

Author SHA1 Message Date
Daniel Eklöf
9dc4f48e7a
vt: tag collision-count check with ‘unlikely’ 2022-06-15 19:25:00 +02:00
Daniel Eklöf
fbcb30bf98
vt: improve key calculation for compose sequences
* Don’t assume 32 bits when rotating the old key. Use the number of
  actual bits available, as determined by CELL_COMB_CHARS_{HI,LO}
* Multiply with magic hash constant

This greatly reduces the number of collisions seen. For example, the
Emoji test file (from the Unicode specification), now has zero
collisions.
2022-06-15 19:25:00 +02:00
Daniel Eklöf
edd68732ad
vt: prevent potential endless loop when finding a slot for a composed character
Composed characters are stored in a tree structure, using a key as
identifier. The key is calculated from the individual characters that
make up the composed character sequence.

Since the address space for keys is limited, collisions may occur. In
this case, we simply increment the key and try again.

It is theoretically possible to saturate the key space, in which case
we’ll get stuck in an endless loop.

Even if the key space isn’t fully saturated, we fairly easy reach a
point where there are so many collisions for each insertion, that
performance drops significantly.

Since key space is limited (it’s not like a hash table that we can
grow), our only option is to limit the number of collisions. If we
can’t find a slot within a hard code amount of collisions, the
character is simply dropped.
2022-06-15 19:25:00 +02:00
Daniel Eklöf
dbe2c0a068
selection: allow HT, VT and FF, disallow NUL in non-bracketed paste mode
This syncs foot with more recent versions of XTerm, where it’s
“disallowedPasteControls” resource has changed its default value to

  BS,DEL,ENQ,EOT,ESC,NULL

Note that we’re already stripping out ENQ,EOT,ESC in all modes.

What does it mean for foot:

* HT, VT and FF are now allowed, regardless of paste mode
* NUL is now stripped in non-bracketed paste mode

Closes #1084
2022-06-15 19:09:40 +02:00
Daniel Eklöf
d3c51b51b7
pgo: slave_spawn(): sync function signature 2022-06-13 16:32:59 +02:00
Daniel Eklöf
8436e6acea
test: config: new test for the new ‘environment’ section 2022-06-13 11:55:24 +02:00
Daniel Eklöf
604a3cdd84
changelog: new ‘environment’ section in foot.ini 2022-06-13 11:55:24 +02:00
Daniel Eklöf
5760bcb3bf
doc: document the new ‘environment’ config section 2022-06-13 11:55:23 +02:00
Daniel Eklöf
755f96321a
config: add a new ‘environment’ section
This section allows the user to define custom environment variables to
be set in the child process:

  [environment]
  name=value
2022-06-13 11:55:23 +02:00
Daniel Eklöf
497c31d9fc
commands: scroll up: simplify viewport clamping logic
When scrolling the viewport up, we need to ensure we don’t go past the
scrollback wrap around.

This was previously done using “custom” logic that tried to calculate
many rows away from the scrollback start the current viewport is.

But this is *exactly* what grid_row_abs_to_sb() does, except it
doesn’t account for uninitialized scrollback.

So, copy the logic from grid_row_abs_to_sb(), but ensure scrollback
start points to valid scrollback data. The maximum number of rows
we’re allowed to scroll is now the same as the current viewport’s
sb-relative coordinate.

Maybe closes #1074
2022-06-13 11:53:37 +02:00
Daniel Eklöf
9567694bab
grid: reflow: don’t trim trailing empty cells from logical lines
When a line in the old grid (the one being reflowed) doesn’t have a
hard linebreak, don’t trim trailing empty cells.

Doing so means we’ll “compress” (remove) empty cells between text
if/when we revert to a larger window size.

The output from neofetch suffers from this; it prints a logo to the
left, and system information to the right. The logo and the system
info column is separated by empty cells (i.e. *not* spaces).

If the window is reduced in size such that the system info is pushed
to a new line, each logo line ends with a number of empty cells. The
next time the window is resized, these empty cells were
ignored (i.e. removed).

That meant that once the window was enlarged again, the system info
column was a) no longer aligned, and b) had been pulled closer to the
logo.

This patch doesn’t special case trailing empty cells when the line
being reflowed doesn’t have a hard linebreak. This means e.g. ‘ls’
output is unaffected.

Closes #1055
2022-06-11 12:02:20 +02:00
Daniel Eklöf
cdd46cdf85
grid: invert the default value of ‘linebreak’, from false to true 2022-06-11 12:02:20 +02:00
Daniel Eklöf
377997be9d
Merge branch 'tokyonight' 2022-06-01 20:01:51 +02:00
Lorenz
e521fe5394
Add 'themes/tokyonight-storm' 2022-06-01 20:01:30 +02:00
Lorenz
b4443c7daa
Add 'themes/tokyonight-night' 2022-06-01 20:01:30 +02:00
Lorenz
45b6d91eef
Add 'themes/tokyonight-day' 2022-06-01 20:01:23 +02:00
Stefan Prosiegel
8d03652a18
themes: add catppuccin 2022-05-25 17:05:36 +02:00
Daniel Eklöf
bc7214cd88
config: use $HOME instead of getpwuid() to retrieve users’s home dir
When searching for foot.ini, use $HOME instead of getpwuid() to
retrieve the user’s home directory.
2022-05-25 17:02:41 +02:00
Daniel Eklöf
7e8b5f9610
main: minor rewording of non-UTF8 locale warnings and errors 2022-05-14 09:14:57 +02:00
Daniel Eklöf
15d45d5704
meson: -Dsystemd-units-dir installs even if systemd is not found
If -Dsystemd-units-dir is explicitly set, then install the systemd
service files regardless of whether systemd is available or not.
2022-05-12 13:46:06 +02:00
Daniel Eklöf
62fe452cc2
meson: add -Dsystemd-units-dir=<path> meson command line option
This allows package maintainers to override the location to which our
systemd service files are installed.

It’s value is an *absolute* path, and *not* relative ${prefix}.

The default is ${systemduserunitdir}.
2022-05-12 13:45:53 +02:00
Daniel Eklöf
56e5855fff
doc: benchmarks: update with desktop results for 1.12.1 (r9) 2022-05-12 13:10:24 +02:00
Daniel Eklöf
834beb966e
doc: benchmarks: update with laptop results for 1.12.1 (r9) 2022-05-12 11:53:08 +02:00
Daniel Eklöf
200c5cbc79
wayland: throttle xdg activation token requests for window urgency
When XDG activation support was added to URL mode, we introduced a
regression, where it is possible to flood the Wayland socket with XDG
activation token requests.

Start foot with “foot -o bell.urgency=yes”, then run:

  while true; do echo -en ‘\a’; done

Finally, switch keyboard focus to another window. Foot crashes.

Throttle the token requests by limiting the number of outstanding
urgency token requests to 1.

Closes #1065
2022-05-11 21:17:52 +02:00
Daniel Eklöf
fc67bff9c0
terminal: move viewport when part of it is scrolled out
If the viewport is at the top of the scrollback, and a program is
scrolling (e.g. by emitting newlines), the viewport needs to be
moved. Otherwise, the top of the viewport will show the *bottom* of
the scrollback (i.e. the newly emitted lines), and the bottom of the
viewport shows the top of the scrollback.

How do we detect if the viewport needs to be moved?

We convert its absolute row number to a scrollback relative row. This
number is also the maximum number of rows we can scroll without the
viewport being scrolled out.

In other words, if the number of rows to scroll is larger than the
viewports scrollback relative row number, the viewport needs to
moved.

How much do we need to move it? The difference between the number of
rows to scroll, and the viewports scrollback relative row number.

Example:

if the viewport is at the very top of the scrollback, its scrollback
relative row number is 0. In this case, it needs to be moved the same
number of rows as is being scrolled.
2022-05-11 17:58:18 +02:00
Lorenz
3431619d07 Themes: Add 'Monokai Pro' theme
Signed-off-by: Lorenz <lorenz@noreply.codeberg.org>
2022-05-09 06:16:05 +02:00
Daniel Eklöf
f14fc120ad
pgo: add xdg_activation_token parameter to spawn() stub 2022-05-06 10:39:49 +02:00
Daniel Eklöf
ea1aac88db
url-mode: add support for XDG activation when opening URLs
First, add a ‘token’ argument to spawn(). When non-NULL, spawn() will
set the ‘XDG_ACTIVATION_TOKEN’ environment variable in the forked
process. If DISPLAY is non-NULL, we also set DESKTOP_STARTUP_ID, for
compatibility with X11 applications. Note that failing to set either
of these environment variables are considered non-fatal - i.e. we
ignore failures.

Next, add a helper function, wayl_get_activation_token(), to generate
an XDG activation token, and call a user-provided callback when it’s
‘done (since token generation is asynchronous). This function takes an
optional ‘seat’ and ‘serial’ arguments - when both are non-NULL/zero,
we set the serial on the token. ‘win’ is a required argument, used to
set the surface on the token.

Re-write wayl_win_set_urgent() to use the new helper function.

Finally, rewrite activate_url() to first try to get an activation
token (and spawn the URL launcher in the token callback). If that
fails, or if we don’t have XDG activation support, spawn the URL
launcher immediately (like before this patch).

Closes #1058
2022-05-05 10:02:28 +02:00
Daniel Eklöf
bd8dd9ff7e
changelog: fix URL in #1047 issue link 2022-04-28 19:29:06 +02:00
Craig Barnes
7045c177fd
commands: fix LOG_DBG() usage in cmd_scrollback_{up,down}
The "end" variable was removed from both of these functions in
commit cb43c58150, but the references to it in the expansion
of LOG_DBG() weren't.
2022-04-27 20:44:14 +02:00
Daniel Eklöf
de201ead2e
changelog: add new ‘unreleased’ section 2022-04-27 20:09:16 +02:00
Daniel Eklöf
0056c3426c
Merge branch 'releases/1.12' 2022-04-27 20:08:55 +02:00
Daniel Eklöf
e95269447f
meson: bump version to 1.12.1 2022-04-27 20:06:09 +02:00
Daniel Eklöf
225f8e659e
changelog: prepare for 1.12.1 2022-04-27 20:05:51 +02:00
Daniel Eklöf
cd513e1761
Merge branch 'master' into releases/1.12 2022-04-27 20:03:53 +02:00
Daniel Eklöf
5308b8cdb8
changelog: changed behavior of “extend-to-word-boundary” 2022-04-27 18:52:08 +02:00
Daniel Eklöf
7630510448
selection: find_word_boundary_right: add “stop-on-space-to-word-boundary”
When true, selection_find_word_boundary_right() behaves as before - it
stops as soon as it encounters a character that isn’t of the
same *type* as the “initial” character (the last character in the
selection).

Take this, for example:

  The Quick Brown Fox

The selection will first stop at the end of “the”, then just *before*
“quick”, then at the end of “quick”. Then just *before* “brown”, and
then at the end of “brown”, and so on.

This suits mouse selections pretty good. But when
selection_find_word_boundary_right() is used to extend a search match,
it’s better to ignore space-to-word character transitions. That is, we
want

  The Quick Brown Fox

to first extend to the end of “the”, then immediately to the end of
“quick”, then to the end of “brown”, and so on.

Setting the ‘stop_to_space_to_word_boundary’ argument to false results
in latter behavior.

This is now done by search, when executing the
“extend-to-word-boundary” and “extend-to-next-whitespace” key
bindings.
2022-04-27 18:44:57 +02:00
Daniel Eklöf
8356dfac2f
Disable debug logging 2022-04-27 18:44:17 +02:00
Daniel Eklöf
32d9895697
term: reset sixel options when hard resetting the terminal state 2022-04-26 21:05:17 +02:00
Daniel Eklöf
aa4c7c5a30
config: add ctrl+shift+v and XF86 paste to SEARCH_CLIPBOARD_PASTE
We now bind ctrl+v, ctrl+shift+v, ctrl+y and XF86Paste to pasting from
the clipboard into the scrollback search buffer.

Why all these? Because we can, and because all are common shortcuts
for pasting:

* ctrl+v: “normal” apps use this by default
* ctrl+shift+v: used in terminals (including foot)
* ctrl+y: Emacs
* XF86Paste: special keyboard key, for pasting
2022-04-26 20:37:30 +02:00
Daniel Eklöf
0e9ebf433b
search: fix infinite loop when highlighting all matches
find_next() did not always terminate correctly, causing
search_matches_next() to never terminate, which finally leads to an
infinite loop when rendering the search overlay surface, while finding
all matches to highlight.

The problem is that find_next(), after having found the initial
matching characters, enters a nested while loop that tries to match
the rest of the search criteria. This inner while loop did not check
if we’ve reached the last cell, and happily continued past
it (eventually wrappping around the scrollback buffer).

Closes #1047
2022-04-26 20:36:28 +02:00
Daniel Eklöf
694938b85b
search: assert that the match is *inside* the new viewport 2022-04-26 19:47:02 +02:00
Daniel Eklöf
c82c6116ed
search: regression: crash when moving viewport
5c4ddebc3c refactored
search_update_selection(), specifically, the logic that moves the
viewport.

It did so by converting the absolute row number (of the match) to
scrollback relative coordinates. This way we could ensure the viewport
wasn’t moved “too much” (e.g. beyond the scrollback start).

However, grid_row_abs_to_sb() and grid_row_sb_to_abs() doesn’t take a
partially filled scrollback into account. This means the row (numbers)
it returns may refer to *uninitialized* rows.

Since:

* The match row itself is valid (we *know* it has text on it)
* We *subtract* from it, when setting the new viewport (to center the
  match on the screen).

it’s only the *upper* part of the new viewport that may be
uninitialized. I.e. we may have adjusted it too much.

So, what we need to do is move the viewport forward until its *first*
row is initialized. Then we know the rest will be too.
2022-04-26 19:32:08 +02:00
Daniel Eklöf
93dcb7dc9c
changelog: typo: space on the wrong side of the parenthesis 2022-04-26 17:52:00 +02:00
Daniel Eklöf
29f07c791e
Merge branch 'sway-sub-surface-damage-workaround'
Closes #1046
2022-04-26 17:44:16 +02:00
Daniel Eklöf
3abb23c81c
changelog: workaround for Sway bug #6960 2022-04-26 17:42:46 +02:00
Daniel Eklöf
398d96fdb2
term: flash: work around Sway sub-surface unmap bug
Unmapping a sub-surface in Sway does not damage the underlying
surface.

As a result, the OSC-555 escape (“flash”) will leave yellow margins on
~every second frame.

Out of sway, river, weston and mutter, only Sway needs this
workaround.

This is a workaround for https://github.com/swaywm/sway/issues/6960

Closes #1046
2022-04-26 17:41:38 +02:00
Daniel Eklöf
1e87dbc4dc
search: work around Sway sub-surface unmap bug
Unmapping a sub-surface in Sway does not damage the underlying
surface.

As a result, "committing" a scrollback search will typically leave
most of the foot window dimmed.

It can be seen when "cancelling" a search as well, but there it's less
obvious - only the margins are left dimmed. This is because cancelling
a search damaged the current viewport (something that shouldn't be
needed).

Out of sway, river, weston and mutter, only Sway needs this
workaround.

This is a workaround for https://github.com/swaywm/sway/issues/6960
2022-04-26 17:41:38 +02:00
Daniel Eklöf
57543c4290
Merge branch 'search-crashes'
Closes #1036
2022-04-26 17:40:58 +02:00
Daniel Eklöf
b94f540113
changelog: search mode not always highlighting all matches correctly 2022-04-26 17:40:20 +02:00