Commit graph

589 commits

Author SHA1 Message Date
Andrei
19466a21d8 doc: foot.ini: fix typo 2025-10-24 11:11:52 -07:00
Daniel Eklöf
7ed36c1033
config: add colors.dim-blend-towards=black|white
Before this patch, we always blended towards black when dimming
text. However, with light color themes, it usually looks better if we
dim towards white instead.

This option allows you to choose which color to blend towards.

The default is 'black' in '[colors]', and 'white' in '[colors2]'.

Closes #2187
2025-10-10 11:10:38 +02:00
Daniel Eklöf
299186a654
render: when double-buffering, pre-apply previous frame's damage early
Foot likes it when compositor releases buffer immediately, as that
means we only have to re-render the cells that have changed since the
last frame.

For various reasons, not all compositors do this. In this case, foot
is typically forced to switch between two buffers, i.e. double-buffer.

In this case, each frame starts with copying over the damage from the
previous frame, to the new frame. Then we start rendering the updated
cells.

Bringing over the previous frame's damage can be slow, if the changed
area was large (e.g. when scrolling one or a few lines, or on full
screen updates). It's also done single-threaded. Thus it not only
slows down frame rendering, but pauses everything else (i.e. input
processing). All in all, it reduces performance and increases input
latency.

But we don't have to wait until it's time to render a frame to copy
over the previous frame's damage. We can do that as soon as the
compositor has released the buffer (for the frame _before_ the
previous frame). And we can do this in a thread.

This frees up foot to continue processing input, and reduces frame
rendering time since we can now start rendering the modified cells
immediately, without first doing a large memcpy(3).

In worst case scenarios (or perhaps we should consider them best case
scenarios...), I've seen up to a 10x performance increase in frame
rendering times (this obviously does *not* include the time it takes
to copy over the previous frame's damage, since that doesn't affect
neither input processing nor frame rendering).

Implemented by adding a callback mechanism to the shm abstraction
layer. Use it for the grid buffers, and kick off a thread that copies
the previous frame's damage, and resets the buffers age to 0 (so that
foot understands it can start render to it immediately when it later
needs to render a frame).

Since we have certain way of knowing if a compositor releases buffers
immediately or not, use a bit of heuristics; if we see 10 consecutive
non-immediate releases (that is, we reset the counter as soon as we do
see an immediate release), this new "pre-apply damage" logic is
enabled. It can be force-disabled with tweak.pre-apply-damage=no.

We also need to take care to wait for the thread before resetting the
render's "last_buf" pointer (or we'll SEGFAULT in the thread...).

We must also ensure we wait for the thread to finish before we start
rendering a new frame. Under normal circumstances, the wait time is
always 0, the thread has almost always finished long before we need to
render the next frame. But it _can_ happen.

Closes #2188
2025-10-10 10:23:17 +02:00
Daniel Eklöf
e43ea3676f
doc: foot.ini: document tweak.min-stride-alignment 2025-10-05 09:40:51 +02:00
Daniel Eklöf
1d9ac3f611
doc: foot.ini: typo: upppercase -> uppercase 2025-08-31 11:42:56 +02:00
Ryan Roden-Corrent
298196365c
config: add 'uppercase-regex-insert'
This makes the "uppercase hint character inserts selected text"
behavior added in #1975 configurable, as it can have unexpected
behavior for some users.

It defaults to "on", preserving the new behavior of `foot`, after

Fixes #2159.
2025-08-31 11:36:28 +02:00
Daniel Eklöf
b13a8f12d2
server/client: add support for sending SIGUSR to footclient
This patch adds the IPC infrastructure necessary to propagate
SIGUSR1/SIGUSR2 from a footclient process to the server process.

By targeting a particular footclient instance, only that particular
instance changes theme. This is different from when targeting the
server process, where all instances change theme.

Closes #2156
2025-08-01 09:38:05 +02:00
Daniel Eklöf
b1b2162416
doc: foot.ini: mention SIGUSR1/SIGUSR2 and reference foot(1) 2025-07-30 12:36:32 +02:00
Daniel Eklöf
3b8d59f476
doc: foot: document SIGUSR1/SIGUSR2 2025-07-30 12:36:32 +02:00
Daniel Eklöf
5a84f8d841
conf: pad: add center-when-fullscreen and center-when-maximized-and-fullscreen
Before this patch, the grid content was *always* centered when the
window was maximized or fullscreened, regardless of how the user had
configured padding.

Now, the behavior is controlled by the 'pad' option. Before this
patch, the syntax was

    pad MxN [center]

Now it is

    pad MxN [center|center-when-fullscreen|center-when-maximized-and-fullscreen]

The default is "pad 0x0 center-when-maximized-and-fullscreen", to
match current behavior.

Closes #2111
2025-05-24 09:56:16 +02:00
Daniel Eklöf
073b637d45
render: refactor to allow setting only selection bg or fg
Before this, we only applied custom selection colors, if *both* the
selection bg and fg had been set.

Since the options are already split up into two separate options, and
since it makes sense to at least be able to keep the foreground colors
unchanged (i.e. only setting the selection background), let's allow
only having one of the selection colors set.

Closes #1846
2025-05-05 13:02:32 +02:00
Daniel Eklöf
c037836bbd
doc: foot.ini: fix description of dark/light themes 2025-05-05 13:02:04 +02:00
Daniel Eklöf
970e13db8d
config: tweak.surface-bit-depth: add support for 16-bit surfaces
This adds supports for 16-bit surfaces, using the new
PIXMAN_a16b16g16r16 buffer format. This maps to
WL_SHM_FORMAT_ABGR16161616 (little-endian).

Use the new 16-bit surfaces by default, when
gamma-correct-blending=yes.
2025-05-03 09:04:15 +02:00
Ryan Roden-Corrent
0ea572dc63
Paste URL/regex selection to prompt if key is uppercase.
In copy-regex/show-urls-copy mode, if the last input character was
uppercase, copy the selection to the clipboard _and_ paste it. This is
useful for taking a file path from a command output:(log, git, test
failure, etc.) and using it in another command.

This is inspired by the behavior of copy mode in wezterm:
https://wezterm.org/quickselect.html

I could have made it check every character in the hint, but it seemed
fine to assume that if the last character was uppercase, the user
wanted this behavior.

Closes #1975.
2025-05-01 13:53:11 +02:00
Daniel Eklöf
e5a0755451
config: tweak.surface-bit-depth now defaults to 'auto'
When set to 'auto', use 10-bit surfaces if gamma-correct blending is
enabled, and 8-bit surfaces otherwise.

Note that we may still fallback to 8-bit surfaces (without disabling
gamma-correct blending) if the compositor does not support 10-bit
surfaces.

Closes #2082
2025-05-01 08:54:30 +02:00
Daniel Eklöf
b07ce56321
config: gamma-correct-blending: disable by default 2025-05-01 08:09:08 +02:00
Daniel Eklöf
d7b48d3924
doc: foot.ini: gamma-correct: tweak wording of 8- vs. 10-bit surfaces 2025-04-28 12:32:40 +02:00
Daniel Eklöf
bc5b716668
config: add initial-color-theme=1|2
This option selects which color theme to use by default. I.e. at
startup, and after a reset.

This is useful with combined theme files, where a single file defines
e.g. both a dark and light version of the theme.
2025-04-26 14:43:42 +02:00
Daniel Eklöf
10e7f29149
csi: implement private mode 2031 (dark/light mode detection)
* Recognize 'CSI ? 996 n', and respond with
  - 'CSI ? 997 ; 1 n' if the primary theme is active
  - 'CSI ? 997 ; 2 n' if the alternative theme is actice
* Implement private mode 2031, where changing the color
  theme (currently only possible via key bindings) causes the terminal
  to send the same CSI sequences as above.

In this context, foot's primary theme is considered dark, and the
alternative theme light (since the default theme is dark).

Closes #2025
2025-04-26 14:23:34 +02:00
Daniel Eklöf
6bc91b5e28
key-bindings: add bindings to switch between color themes
* color-theme-switch-1: select the primary color theme
* color-theme-switch-2: select the alternative color theme
* color-theme-toggle: toggle between the primary and alternative color themes
2025-04-26 14:20:58 +02:00
Daniel Eklöf
1423babc35
config: add new section 'colors2'
This section defines an alternative color theme. The keys are the same
as in the 'colors' section, as are the default values.

Values are *not* inherited from 'colors'. That is, if you set a value
in 'colors', but not in 'colors2', it is *not* inherited by 'colors2'.
2025-04-26 14:20:58 +02:00
Daniel Eklöf
624c383a1f
config: move cursor.color to colors.cursor 2025-04-26 10:46:39 +02:00
Daniel Eklöf
8bded8ce8c
doc: foot.ini: add newish Unicode range to 'box-drawings-uses-font-glyphs' 2025-04-19 17:10:52 +02:00
Daniel Eklöf
1bf9156628
doc: foot.ini: spaces -> tab (for indentation) 2025-04-19 11:59:50 +02:00
Daniel Eklöf
179e14e0a1
doc: foot.ini: gamma-correct-blending: mention colors being off 2025-04-19 09:16:28 +02:00
Daniel Eklöf
155c7c96b7
doc: foot.ini: key-bindings: untranslated symbols are tried before translated 2025-04-18 14:43:36 +02:00
Daniel Eklöf
9ba8caf30b
doc: foot.ini: add colors.alpha-mode 2025-04-14 17:02:45 +02:00
Daniel Eklöf
9a6227acb3
doc: foot.ini: workers: "if you have a ridiculous number of cores" 2025-04-14 07:03:37 +02:00
Daniel Eklöf
1760cb6ab8
config: update default URL regex
The old one is in some cases too liberal. The new one is stricter in
two ways:

1. The protocol list is now explicit, rather than matching anything://
2. Allowed characters are now limited to the "safe character set", the
   "reserved character set", and some from the "unsafe character set"

Furthermore, some of the characters are restricted in how/when they
are allowed:

1. Periods, commas, question marks etc are allowed inside an URL, but
   not at the end.
2. [ ], ( ), " " and ' ' are allowed but only when balanced. This
   allows us to match e.g. [http://foo.bar/foo[bar]] correctly.

Closes #2016
2025-04-07 09:11:16 +02:00
Daniel Eklöf
a43614f098
doc: foot.ini: mention virtual modifiers are allowed 2025-03-31 10:25:14 +02:00
Daniel Eklöf
6922ab2b8e
doc: foot.ini: gamma-correct: move section 2025-03-23 17:00:19 +01:00
Sam McCall
663c9082db
render: dim and brighten using linear rgb interpolation
Adds setting tweak.dim-amount, similar to bold-text-in-bright-amount.

Closes #2006
2025-03-23 15:24:23 +01:00
Daniel Eklöf
49d2c08912
doc: foot.ini: codespell: shouuld -> should 2025-03-17 12:08:27 +01:00
Daniel Eklöf
7dbfdc73b6
doc: foot.init: surface-bit-depth: mention 10-bit surfaces are slow 2025-03-17 08:51:27 +01:00
Daniel Eklöf
7f11ba59ef
fcft: require fcft >= 3.3.0, add support for new scaling-filters
Update tweak.scaling-filter to recognize the new scaling filters added
in fcft-3.3.0.

Since fcft_set_scaling_filter() is deprecated in 3.3.0, don't use it
anymore, and set the scaling filter via fcft_font_options instead.
2025-03-12 10:03:06 +01:00
Daniel Eklöf
ccf625b991
render: gamma-correct blending
This implements gamma-correct blending, which mainly affects font
rendering.

The implementation requires compile-time availability of the new
color-management protocol (available in wayland-protocols >= 1.41),
and run-time support for the same in the compositor (specifically, the
EXT_LINEAR TF function and sRGB primaries).

How it works: all colors are decoded from sRGB to linear (using a
lookup table, generated in the exact same way pixman generates it's
internal conversion tables) before being used by pixman. The resulting
image buffer is thus in decoded/linear format. We use the
color-management protocol to inform the compositor of this, by tagging
the wayland surfaces with the 'ext_linear' image attribute.

Sixes: all colors are sRGB internally, and decoded to linear before
being used in any sixels. Thus, the image buffers will contain linear
colors. This is important, since otherwise there would be a
decode/encode penalty every time a sixel is blended to the grid.

Emojis: we require fcft >= 3.2, which adds support for sRGB decoding
color glyphs. Meaning, the emoji pixman surfaces can be blended
directly to the grid, just like sixels.

Gamma-correct blending is enabled by default *when the compositor
supports it*. There's a new option to explicitly enable/disable it:
gamma-correct-blending=no|yes. If set to 'yes', and the compositor
does not implement the required color-management features, warning
logs are emitted.

There's a loss of precision when storing linear pixels in 8-bit
channels. For this reason, this patch also adds supports for 10-bit
surfaces. For now, this is disabled by default since such surfaces
only have 2 bits for alpha. It can be enabled with
tweak.surface-bit-depth=10-bit.

Perhaps, in the future, we can enable it by default if:

* gamma-correct blending is enabled
* the user has not enabled a transparent background
2025-03-05 18:45:01 +01:00
Adrian fxj9a
6d39f66eb7
config: add search-bindings.delete-to-{start,end} key bindings
Defaults to ctrl+u and ctrl+k respectively.

Closes #1972
2025-03-05 08:48:23 +01:00
Daniel Eklöf
c41008da31
config+render: allow cursor.style=hollow
Closes #1965
2025-02-19 11:50:25 +01:00
Daniel Eklöf
4abbaf1345
doc: foot.ini: font: add one more fontfeatures example
Add a fontfeatures example where we:

* set multiple features
* assign a value to the features (as opposed to just enabling a
  boolean feature)
2025-02-16 09:11:52 +01:00
Daniel Eklöf
970d95c5a1
doc: foot.ini: fix 'hashes' regex example
It's A-F, not A-f
2025-02-10 13:08:33 +01:00
Daniel Eklöf
ed35a238d6
doc: ctlseq: add OSC 66 (kitty text sizing) 2025-02-06 14:02:38 +01:00
Daniel Eklöf
9e12f791c5
doc: regex: custom regex's aren't URLs 2025-02-05 13:43:11 +01:00
Daniel Eklöf
b1f16c84e0
doc: improve regex example 2025-02-05 13:35:17 +01:00
Daniel Eklöf
0a32dc3820
spawn template variables are on the form ${}, not {} 2025-02-05 13:35:17 +01:00
Daniel Eklöf
a984531ce5
url-mode: use the first *sub* expression as URL
When auto-matching URLs (or custom regular expressions), use the
first *subexpression* as URL, rather than the while regex match.

This allows us to write custom regular expressions with prefix/suffix
strings that should not be included in the presented match.
2025-02-05 13:35:17 +01:00
Daniel Eklöf
2f902c1f5b
doc: foot.ini: document custom regular expressions 2025-02-05 13:35:17 +01:00
Daniel Eklöf
130b05f02b
foot.ini+doc: add default value of url.regex 2025-02-05 13:35:17 +01:00
Daniel Eklöf
d41b28bd02
url-mode+config: wip: add url.regex option 2025-02-05 13:35:17 +01:00
Daniel Eklöf
e76d8dd7af
config: remove url.{uri-characters,protocols} 2025-02-05 13:35:17 +01:00
Daniel Eklöf
d24f700256
key-bindings: add keypad variants to existing default key-bindings 2025-01-31 07:29:16 +01:00