Compare commits

..

No commits in common. "master" and "1.20.2" have entirely different histories.

167 changed files with 2453 additions and 6907 deletions

View file

@ -29,7 +29,7 @@ body:
- type: input
id: compositor
attributes:
label: Compositor Name and Version
label: Compositor Version
description: "The name and version of your compositor"
placeholder: "sway version 1.9"
validations:
@ -38,36 +38,15 @@ body:
id: distro
attributes:
label: Distribution
description: "The name of the Linux distribution, or BSD flavor, you are running. And, if applicable, the version"
placeholder: "Fedora Workstation 41"
description: "The name of the Linux distribution, or BSD flavor, you are running"
placeholder: "Arch Linux"
validations:
required: true
- type: input
id: multiplexer
attributes:
label: Terminal multiplexer
description: "Terminal multiplexers are terminal emulators themselves, therefore the issue may be in the multiplexer, not foot. Please list which multiplexer(s) you use here (and mention in the problem description below if the issue only occurs in the multiplexer, but not in bare metal foot)"
placeholder: "tmux, zellij"
- type: input
id: application
attributes:
label: Shell, TUI, application
description: "Application(s) in which the problem occurs (list all known)"
placeholder: "bash, neovim"
- type: checkboxes
id: server
attributes:
label: Server/standalone mode
description: Does the issue occur in foot server, or standalone mode, or both? Note that you **cannot** test standalone mode by manually running `foot` from a `footclient` instance, since then the standalone foot will simply inherit the server process' context.
options:
- label: Standalone
- label: Server
- type: textarea
id: config
attributes:
label: Foot config
description: Paste your entire `foot.ini` here (do not forget to sanitize it!)
render: ini
description: Paste your entire `foot.ini` here
validations:
required: true
- type: textarea

View file

@ -1,7 +1,7 @@
# -*- yaml -*-
steps:
- name: pychecks
- name: codespell
when:
- event: [manual, pull_request]
- event: [push, tag]
@ -11,15 +11,10 @@ steps:
- apk add openssl
- apk add python3
- apk add py3-pip
- python3 -m venv venv
- source venv/bin/activate
- python -m pip install --upgrade pip
- python3 -m venv codespell-venv
- source codespell-venv/bin/activate
- pip install codespell
- pip install mypy
- pip install ruff
- codespell
- mypy
- ruff check
- codespell -Lser,doas,zar README.md INSTALL.md CHANGELOG.md *.c *.h doc/*.scd
- deactivate
- name: subprojects

View file

@ -1,17 +1,5 @@
# Changelog
* [Unreleased](#unreleased)
* [1.26.1](#1-26-1)
* [1.26.0](#1-26-0)
* [1.25.0](#1-25-0)
* [1.24.0](#1-24-0)
* [1.23.1](#1-23-1)
* [1.23.0](#1-23-0)
* [1.22.3](#1-22-3)
* [1.22.2](#1-22-2)
* [1.22.1](#1-22-1)
* [1.22.0](#1-22-0)
* [1.21.0](#1-21-0)
* [1.20.2](#1-20-2)
* [1.20.1](#1-20-1)
* [1.20.0](#1-20-0)
@ -69,584 +57,6 @@
* [1.2.0](#1-2-0)
## Unreleased
### Added
### Changed
### Deprecated
### Removed
### Fixed
* Other output (key presses, query replies etc) being mixed with paste
data, both interactive pastes and OSC-52 ([#2307][2307]).
[2307]: https://codeberg.org/dnkl/foot/issues/2307
### Security
### Contributors
## 1.26.1
### Fixed
* Wrong documented default value for `initial-color-theme` in
`foot.ini(5)` ([#2292][2292]).
* Occasional crashes when closing a window and
`tweak.pre-apply-damage=yes` (the default) ([#2288][2288]).
[2292]: https://codeberg.org/dnkl/foot/issues/2292
[2288]: https://codeberg.org/dnkl/foot/issues/2288
### Contributors
* Roshless
* vlkrs
## 1.26.0
### Added
* `toplevel-tag` option (and `--toplevel-tag` command line options to
`foot` and `footclient`), allowing you to set a custom toplevel
tag. The compositor must implement the new `xdg-toplevel-tag-v1`
Wayland protocol ([#2212][2212]).
* `[colors-dark]` section to `foot.ini`. Replaces `[colors]`.
* `[colors-light]` section to `foot.ini`. Replaces `[colors2]`.
* `XTGETTCAP`: added `query-os-name`, returning the OS foot is
compiled for (e.g. _'Linux'_) ([#2209][2209]).
* `pad` option now supports 4-directional padding format:
`LEFTxTOPxRIGHTxBOTTOM` (e.g., `20x10x20x10`).
* `--config=PATH` option is now automatically passed to new
terminals spawned via `spawn-terminal` action ([#2259][2259]).
* Preliminary (untested) support for background blur via the new
`ext-background-effect-v1` protocol. Enable by setting
`colors-{dark,light}.blur=yes`. Foot needs to have been **built**
against `wayland-protocols >= 1.45`, and the compositor **must**
implement the `ext-background-effect-v1` protocol, **and** the
`blur` effect.
[2212]: https://codeberg.org/dnkl/foot/issues/2212
[2209]: https://codeberg.org/dnkl/foot/issues/2209
[2259]: https://codeberg.org/dnkl/foot/pulls/2259
### Changed
* When enabling _"focus mode"_ (private mode 1004), foot now sends a
focus event immediately, to inform the application what the current
state is ([#2202][2202]).
* Scrollback search is now case sensitive when the search string
contains at least one upper case character.
* Mouse tracking in SGR pixel mode no longer emits negative column/row
pixel values ([#2226][2226]).
* Foot now always uses ARGB SHM surfaces. In earlier versions, XRGB
surfaces were used for opaque surfaces. Unfortunately, several
compositors had issues when foot switched between ARGB and XRGB
surfaces (for example when switching color theme, or toggling
fullscreen).
[2202]: https://codeberg.org/dnkl/foot/issues/2202
[2226]: https://codeberg.org/dnkl/foot/issues/2226
### Deprecated
* `[colors]` section in `foot.ini`. Use `[colors-dark]` instead.
* `[colors2]` section in `foot.ini`. Use `[colors-light]` instead.
### Removed
* `cursor.color` config option (deprecated in 1.23.0). Use
`colors-{dark,light}.cursor` instead.
### Fixed
* Search mode: composing keys not ignored.
* Crash when triple-clicking a soft-wrapped line and there is a quote
character in the last column.
* Crash when reverse-scrolling (terminfo capability `rin`) such that
the current viewport ends up outside the scrollback ([#2232][2232]).
* Regression: visual glitches in rare circumstances.
* Key release events for shortcuts being sent to the client
application (kitty keyboard protocol only) ([#2257][2257]).
* Crash when application emits sixel RA with a height of 0, a width >
0, and then starts writing sixel data ([#2267][2267]).
* Crash if shutting down terminal instance while a "pre-apply damage"
thread is running ([#2263][2263]).
[2232]: https://codeberg.org/dnkl/foot/issues/2232
[2257]: https://codeberg.org/dnkl/foot/issues/2257
[2267]: https://codeberg.org/dnkl/foot/issues/2267
[2263]: https://codeberg.org/dnkl/foot/issues/2263
### Contributors
* Andrei
* Barinderpreet Singh
* c4llv07e
* Johannes Altmanninger
* nariby
* pi66
* Ronan Pigott
* Stéphane Klein
* valoq
* Whyme Lyu
* Yaakov Selkowitz
## 1.25.0
### Added
* Performance increased and input latency decreased on compositors
that do not release SHM buffers immediately ([#2188][2188]).
* `colors{,2}.dim-blend-towards=black|white` option, allowing you to
select towards which color to blend when dimming text. Defaults to
`black` in `[colors]`, and `white` in `[colors2]` ([#2187][2187]).
[2188]: https://codeberg.org/dnkl/foot/issues/2188
[2187]: https://codeberg.org/dnkl/foot/issues/2187
### Changed
* SHM buffer sizes are now rounded up to nearest page size, and their
stride is always an even multiple of 256 bytes (by default,
configurable by setting `tweak.min-stride-alignment`). This allows
compositor to directly import foot's SHM buffers to the GPU, with
e.g. integrated graphics ([#2182][2182]).
* Jump label colors in the modus-operandi theme, for improved
readability.
[2182]: https://codeberg.org/dnkl/foot/issues/2182
### Fixed
* URL labels misplaces when URL contains double-width characters
([#2179][2179]).
* One space too much consumed when copying (or pipe:ing) contents with
tabs ([#2194][2194])
* Ensure we render a new frame when changing fullscreen state. Before,
this was automatically done if the window was also resized. But, it
is possible for a compositor to change an application's fullscreen
state without resizing the window.
[2179]: https://codeberg.org/dnkl/foot/issues/2179
[2194]: https://codeberg.org/dnkl/foot/issues/2194
### Contributors
* Charalampos Mitrodimas
* Matthias Heyman
## 1.24.0
### Added
* The `uppercase-regex-insert` option controls whether an uppercase hint
character will insert the selected text into the prompt in `regex-copy`
or `show-urls-copy` mode. It defaults to `true`. ([#2159][2159]).
[2159]: https://codeberg.org/dnkl/foot/issues/2159
### Changed
* The label letters are no longer sorted before being assigned to URLs
([#2140][2140]).
* Sending SIGUSR1/SIGUSR2 to a `foot --server` process now causes
newly spawned client instances to use the selected theme, instead of
the original one.
* SIGUSR1/SIGUSR2 can now be sent to `footclient` processes, to change
the theme of that particular instance ([#2156][2156]).
[2156]: https://codeberg.org/dnkl/foot/issues/2156
### Fixed
* Invalid configuration values overriding valid ones in surprising
ways.
* Bug where the libutempter utmp backend did not record logouts
correctly.
### Contributors
* Ryan Roden-Corrent
* Tobias Mock
## 1.23.1
### Changed
* URL labels are now assigned in reverse order, from bottom to
top. This ensures the **last** URL (which is often the one you are
interested in) is always assigned the same key ([#2140][2140]).
* Sending `SIGUSR1` no longer **toggles** between `[colors]` and
`[colors2]`, but explicitly changes to `[colors]`. `SIGUSR2` changes
to `[colors2]` ([#2144][2144]).
[2140]: https://codeberg.org/dnkl/foot/issues/2140
[2144]: https://codeberg.org/dnkl/foot/issues/2144
### Fixed
* 10-bit surfaces sometimes used instead of 16-bit.
* OSC-104/110/111/112/117/119 (reset colors) not taking the currently
active theme into account.
## 1.23.0
### Added
* `colors2` config section. This section duplicates the `colors`
section, and lets you define an alternative color theme.
* `key-bindings.color-theme-switch-1`,
`key-bindings.color-theme-switch-2` and
`key-bindings.color-theme-toggle` key bindings. These can be used to
switch between the primary and alternative color themes. They are
not bound by default.
* Sending `SIGUSR1` to the foot process now triggers a theme switch
(in server mode, **all** instances toggles their themes).
* Support for private mode 2031 - [_Dark and Light Mode
Detection_](https://contour-terminal.org/vt-extensions/color-palette-update-notifications/)
([#2025][2025])
* Added `initial-color-theme=1|2` config option. `1` uses colors from
the `[colors]` section, `2` uses `[colors2]`.
* Combined dark/light theme files for (dark variant is the default,
set `initial-color-theme=2` to use the light variant by default):
- gruvbox
- nvim
- paper-color
- selenized
- solarized
* `regex-copy`/`show-urls-copy` will copy and paste the selected text if the hint
is completed with an uppercase character ([#1975][1975]).
* `16-bit` to `tweak.surface-bit-depth`. Makes foot use 16-bit image
buffers. They provide the necessary color precision required by
`gamma-correct-blending=yes`.
* New cursor shapes, from `cursor-shape-v1` version 2.
* `center-when-fullscreen` and `center-when-maximized-and-fullscreen`
to the `pad` option. This allows you to configure when the grid is
centered in more detail ([#2111][2111]).
[2025]: https://codeberg.org/dnkl/foot/issues/2025
[1975]: https://codeberg.org/dnkl/foot/issues/1975
[2111]: https://codeberg.org/dnkl/foot/issues/2111
### Changed
* `cursor.color` moved to `colors.cursor`.
* OSC-11 without an alpha value will now restore the configured
(i.e. from `foot.ini`) alpha, rather than keeping whatever the
current alpha value is, unchanged.
* `gamma-correct-blending=yes` now defaults to `16-bit` image buffers,
instead of `10-bit`.
* Allow setting either selection background, or selection foreground,
only ([#1846][1846]).
* Drop required version of libxkbcommon from 1.8.0 back to 1.0.0
([#2103][2103]).
* OSC-52: an empty payload now clears the clipboard.
* DA (Device Attributes): include `52` in the reply, to indicate
OSC-52 support (when at least _copy_ has been enabled in
`security.osc52`).
[1846]: https://codeberg.org/dnkl/foot/issues/1846
[2103]: https://codeberg.org/dnkl/foot/issues/2103
### Deprecated
* `cursor.color` config option; use `colors.cursor` instead.
### Removed
* Subsurface unmap quirk for Sway. This was a workaround added in
1.12.1, for Sway issue [#6960][sway-6960].
### Fixed
* `REP`: wrong width of repeated multi-codepoint graphemes.
* Incorrect surface commit after a configure event, under certain
conditions ([#2105][2105]).
[2105]: https://codeberg.org/dnkl/foot/issues/2105
### Contributors
* Chen Mulong
* Kirill Primak
* Ryan Roden-Corrent
* tokyo4j
## 1.22.3
### Added
* `auto` to the `tweak.surface-bit-depth` option.
### Changed
* `gamma-correct-blending` now defaults to `no` instead of `yes`.
* `tweak.surface-bit-depth` default value changed to `auto`; uses
10-bit surfaces when `gamma-correct-blending=yes`, and 8-bit
surfaces otherwise.
### Fixed
* Inaccurate colors when `gamma-correct-blending=yes` ([#2082][2082]).
[2082]: https://codeberg.org/dnkl/foot/issues/2082
## 1.22.2
### Changed
* `gamma-correct-blending=yes` now uses a pure gamma 2.2 transfer
function, instead of the piece-wise sRGB transfer function, to match
what compositors do.
### Fixed
* Wrong colors when `gamma-correct-blending=yes` (the default when
there is compositor support). Note that some colors will still be
off by a **very** small amount, due to loss of precision when
converting to a linear color space. ([#2035][2035]).
[2035]: https://codeberg.org/dnkl/foot/issues/2035
## 1.22.1
### Fixed
* `colors.alpha-mode=matching` not working as intended.
* Grapheme shaping was allowed to be "enabled" at runtime, even though
disabled at compile time. This caused mis-rendering of certain
codepoints ([#2039][2039]).
* Keyboard modifiers not being reset on keyboard leave events
([#2034][2034]).
* Fallback font (and possibly wrong color) being used when a character
was followed by a zero-width grapheme breaking codepoint (for
example, _LEFT-TO-RIGHT MARK_) ([#2049][2049]).
* Regression: alpha applied to inversed text/selections
([#2073][2073]).
[2039]: https://codeberg.org/dnkl/foot/issues/2039
[2034]: https://codeberg.org/dnkl/foot/issues/2034
[2049]: https://codeberg.org/dnkl/foot/issues/2049
[2073]: https://codeberg.org/dnkl/foot/issues/2073
### Contributors
* Jan Palus
* valoq
## 1.22.0
### Added
* Support for toplevel edge constraints. When the compositor indicates
the toplevel has edge constraints, foot will not allow the window to
be resized (via CSDs) in the constrained directions.
* Virtual modifiers (e.g. `Alt` instead of `Mod1`, `Super` instead of
`Mod4` etc) in key bindings are now recognized as being virtual, and
are automatically mapped to the corresponding real modifier. This
means you can use e.g. `Alt+b` instead of `Mod1+b`.
* `alpha-mode` option to `foot.ini`. Defaults to `default`. This
config changes how alpha is handled on background colours not set by
the terminal.(e.g. vim) ([#2026](2026))
[2026]: https://codeberg.org/dnkl/foot/issues/2026
### Changed
* UTF-8 error recovery now discards fewer bytes.
* Auto-calculated dimmed and brightened colors (e.g. when custom dim
colors has not configured) is now done by linear RGB interpolation,
rather than converting to HSL and adjusting the luminance
([#2006][2006]).
* Virtual modifiers in keyboard events from the compositor are now
supported. This works around various issues seen when running foot
under mutter (GNOME) ([#2009][2009]):
- Some key combinations generating the wrong escape sequence in the
kitty keyboard protocol.
- some of foot's default shortcuts not working (mainly those using
`Mod1`) out of the box.
* Default URL regex changed to a much more strict variant
([#2016][2016]). You can manually set the [old
one](https://codeberg.org/dnkl/foot/src/tag/1.21.0/foot.ini#L72), if
you prefer it over the new regex.
* A tiled window can now be resized in the corners (via CSDs), unless
the compositor has indicated the toplevel has edge constraints.
[2006]: https://codeberg.org/dnkl/foot/issues/2006
[2009]: https://codeberg.org/dnkl/foot/issues/2009
[2016]: https://codeberg.org/dnkl/foot/issues/2016
### Fixed
* Regression: assertion in `url-mode.c` when activating a second URL
via `show-urls-persistent` ([#2000][2000]).
* Build failure (`srgb.h` not found) when doing a parallel build.
* Regression: reflowing (changing the window size) removing empty
lines ([#2011][2011]).
* `url/regex-copy` not handling double-width characters correctly
([#2027][2027]).
[2000]: https://codeberg.org/dnkl/foot/issues/2000
[2011]: https://codeberg.org/dnkl/foot/issues/2011
[2027]: https://codeberg.org/dnkl/foot/issues/2027
### Contributors
* Alex Xu (Hello71)
* datsudo
* Dominique Martinet
* Fazzi
* llyyr
* Łukasz Wojniłowicz
* Sam McCall
## 1.21.0
### Added
* Support for the new Wayland protocol `xdg-system-bell-v1` protocol
(added in wayland-protocols 1.38), via the new config option
`bell.system=no|yes` (defaults to `yes`).
* Support for custom regex matching ([#1386][1386],
[#1872][1872])
* Support for kitty's text-sizing protocol (`w`, width, only), OSC-66.
* `cursor.style` can now be set to `hollow` ([#1965][1965]).
* `search-bindings.delete-to-start` and
`search-bindings.delete-to-end` key bindings, defaulting to
`Control+u` and `Control+k` respectively ([#1972][1972]).
* Gamma-correct font rendering. Requires compositor support
(`wp_color_management_v1`, and specifically, the `ext_linear`
transfer function). Enabled by default when compositor support is
available. Can be explicitly enabled or disabled with
`gamma-correct-blending=no|yes`.
[1386]: https://codeberg.org/dnkl/foot/issues/1386
[1872]: https://codeberg.org/dnkl/foot/issues/1872
[1965]: https://codeberg.org/dnkl/foot/issues/1965
[1972]: https://codeberg.org/dnkl/foot/issues/1972
### Changed
* Do not try to set a zero width, or height, if the compositor sends a
_configure_ event with only one dimension being zero
([#1925][1925]).
* Auto-detection of URLs (i.e. not OSC-8 based URLs) are now regex
based.
* Rename Tokyo Night Day theme to Tokyo Night Light and update colors.
* fcft >= 3.3.1 is now required.
- `tweak.scaling-filter` now supports more scaling-filters
- scaled bitmap fonts (when enabled in FontConfig) no longer have a
scaling-filter applied
* Linefeed:ing control characters (e.g. `\n`) no longer **clears** a
row's internal linebreak flag. This fixes an issue where
e.g. multi-line prompt input in fish is treated as separate lines,
rather than one logical, when selecting and copying it
([#1487][1487]).
* wayland-protocols >= 1.41 is now required.
[1925]: https://codeberg.org/dnkl/foot/issues/1925
[1487]: https://codeberg.org/dnkl/foot/issues/1487
### Removed
* `url.uri-characters` and `url.protocols`. Both options have been
replaced by `url.regex`.
* `notify` option (has been deprecated since 1.18.0).
* `notify-focus-inhibit` option (has been deprecated since 1.18.0).
### Fixed
* Kitty keyboard protocol: alternate key reporting failing to report
the alternate codepoint in some corner cases ([#1918][1918]).
* `foot` and `footclient` hanging, or terminating with `SIGABRT`, when
starting inside a directory whose total length is more than 1024
characters.
* Regression: reflowing (resizing the window) a line that ends with a
double-width glyph that was pushed to the next line due to there
being only one cell left on current line, did not remove the virtual
space inserted at the end of the current line.
* Wrong key bindings executed when using alternative keyboard layouts
([#1929][1929]).
* Foot not closing file descriptors for unrecognized or `no_keymap`
keymaps.
* Combining characters (including emojis consisting of multiple
codepoints) not being handled correctly when _insert mode_ is
enabled ([#1947][1947]).
* Reflow of the cursor (active + saved) when at the end of the line
with a pending wrap (LCF set) ([#1954][1954]).
* ~~Zero-width characters that also are grapheme breaks (e.g. U+200B,
ZERO WIDTH SPACE) being ignored (discarded and never stored in the
grid) ([#1960][1960]).~~ (reverted)
* `--server=<FD>` not working on FreeBSD ([#1956][1956]).
* Crash when resetting the terminal and an application had previously
set a custom app ID ([#1963][1963])
* Grapheme clustering state not reset on cursor movements.
* Kitty keyboard protocol: no release events emitted for composed
keys.
* IME: the initial cursor position was reported as 0,0,0,0
([#1994][1994]).
[1918]: https://codeberg.org/dnkl/foot/issues/1918
[1929]: https://codeberg.org/dnkl/foot/issues/1929
[1947]: https://codeberg.org/dnkl/foot/issues/1947
[1954]: https://codeberg.org/dnkl/foot/issues/1954
[1960]: https://codeberg.org/dnkl/foot/issues/1960
[1956]: https://codeberg.org/dnkl/foot/issues/1956
[1963]: https://codeberg.org/dnkl/foot/issues/1963
[1994]: https://codeberg.org/dnkl/foot/issues/1994
### Contributors
* Adrian fxj9a
* Alexander Orzechowski
* Attila Fidan
* camel-cdr
* Craig Barnes
* Guillaume Outters
* Johannes Altmanninger
* Ludovico Gerardi
* sewn
* Thomas Bonnefille
## 1.20.2
### Changed

View file

@ -53,7 +53,7 @@ decisions when appropriate.
Participants in the foot community are expected to uphold the described
standards not only in official community spaces (issue trackers, IRC channels,
etc.) but in all public spaces. The Code of Conduct however does acknowledge
that people are fallible and that it is possible to truly correct a past
that people are fallible and that it is possible to truely correct a past
pattern of unacceptable behavior. That is to say, the scope of the Code of
Conduct does not necessarily extend into the distant past.

View file

@ -65,7 +65,7 @@ The fast, lightweight and minimalistic Wayland terminal emulator.
* [Synchronized Updates](https://gitlab.freedesktop.org/terminal-wg/specifications/-/merge_requests/2) support
* [Sixel image support](https://en.wikipedia.org/wiki/Sixel)
![tux-with-foot](doc/sixel-tux-foot.png "Sixel screenshot")
![wow](doc/sixel-wow.png "Sixel screenshot")
# Installing
@ -641,10 +641,6 @@ All replies are in `tigetstr()` format. That is, given the same
capability name, foot's reply is identical to what `tigetstr()` would
have returned.
In addition to queries for terminfo entries, the `query-os-name` query
will be answered with a response of the form `uname=$(uname -s)`,
where `$(uname -s)` is the name of the OS foot was compiled for.
# Credits
@ -693,11 +689,8 @@ Every now and then I post foot related updates on
# Sponsoring/donations
* Liberapay: https://liberapay.com/dnkl
* GitHub Sponsors: https://github.com/sponsors/dnkl
[![Donate using Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/dnkl/donate)
# License

View file

@ -2,6 +2,7 @@
#include <stdio.h>
#include <math.h>
#include <fenv.h>
#include <errno.h>
#define LOG_MODULE "box-drawing"
@ -1461,12 +1462,14 @@ draw_box_drawings_light_arc(struct buf *buf, char32_t wc)
*/
for (double i = y_min*16; i <= y_max*16; i++) {
errno = 0;
feclearexcept(FE_ALL_EXCEPT);
double y = i / 16.;
double x = circle_hemisphere * sqrt(c_r2 - (y - c_y) * (y - c_y)) + c_x;
/* See math_error(7) */
if (errno != 0)
if (errno != 0 ||
fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW))
{
continue;
}

View file

@ -34,7 +34,7 @@ _Static_assert(
#if !defined(__STDC_UTF_32__) || !__STDC_UTF_32__
#error "char32_t does not use UTF-32"
#endif
#if (!defined(__STDC_ISO_10646__) || !__STDC_ISO_10646__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
#if (!defined(__STDC_ISO_10646__) || !__STDC_ISO_10646__) && !defined(__FreeBSD__)
#error "wchar_t does not use UTF-32"
#endif
@ -53,14 +53,6 @@ UNITTEST
xassert(c32cmp(U"b", U"a") > 0);
}
UNITTEST
{
xassert(c32ncmp(U"foo", U"foot", 3) == 0);
xassert(c32ncmp(U"foot", U"FOOT", 4) > 0);
xassert(c32ncmp(U"a", U"b", 1) < 0);
xassert(c32ncmp(U"bb", U"aa", 2) > 0);
}
UNITTEST
{
char32_t copy[16];
@ -135,20 +127,6 @@ UNITTEST
xassert(c32cmp(dst, U"foobar12345678") == 0);
}
UNITTEST
{
xassert(!isc32upper(U'a'));
xassert(isc32upper(U'A'));
xassert(!isc32upper(U'a'));
}
UNITTEST
{
xassert(hasc32upper(U"abc1A"));
xassert(!hasc32upper(U"abc1_aaa"));
xassert(!hasc32upper(U""));
}
UNITTEST
{
char32_t *c = xc32dup(U"foobar");

View file

@ -20,10 +20,6 @@ static inline int c32cmp(const char32_t *s1, const char32_t *s2) {
return wcscmp((const wchar_t *)s1, (const wchar_t *)s2);
}
static inline int c32ncmp(const char32_t *s1, const char32_t *s2, size_t n) {
return wcsncmp((const wchar_t *)s1, (const wchar_t *)s2, n);
}
static inline char32_t *c32ncpy(char32_t *dst, const char32_t *src, size_t n) {
return (char32_t *)wcsncpy((wchar_t *)dst, (const wchar_t *)src, n);
}
@ -64,10 +60,6 @@ static inline char32_t toc32upper(char32_t c) {
return (char32_t)towupper((wint_t)c);
}
static inline bool isc32upper(char32_t c32) {
return iswupper((wint_t)c32);
}
static inline bool isc32space(char32_t c32) {
return iswspace((wint_t)c32);
}
@ -80,13 +72,6 @@ static inline bool isc32graph(char32_t c32) {
return iswgraph((wint_t)c32);
}
static inline bool hasc32upper(const char32_t *s) {
for (int i = 0; s[i] != '\0'; i++) {
if (isc32upper(s[i])) return true;
}
return false;
}
static inline int c32width(char32_t c) {
#if defined(FOOT_GRAPHEME_CLUSTERING)
return utf8proc_charwidth((utf8proc_int32_t)c);

View file

@ -29,17 +29,3 @@ struct client_data {
} __attribute__((packed));
_Static_assert(sizeof(struct client_data) == 10, "protocol struct size error");
enum client_ipc_code {
FOOT_IPC_SIGUSR,
};
struct client_ipc_hdr {
enum client_ipc_code ipc_code;
uint8_t size;
} __attribute__((packed));
struct client_ipc_sigusr {
int signo;
} __attribute__((packed));

109
client.c
View file

@ -1,13 +1,12 @@
#include <errno.h>
#include <getopt.h>
#include <limits.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <getopt.h>
#include <signal.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/un.h>
@ -23,6 +22,7 @@
#include "foot-features.h"
#include "macros.h"
#include "util.h"
#include "version.h"
#include "xmalloc.h"
extern char **environ;
@ -34,20 +34,13 @@ struct string {
typedef tll(struct string) string_list_t;
static volatile sig_atomic_t aborted = 0;
static volatile sig_atomic_t sigusr = 0;
static void
sigint_handler(int signo)
sig_handler(int signo)
{
aborted = 1;
}
static void
sigusr_handler(int signo)
{
sigusr = signo;
}
static ssize_t
sendall(int sock, const void *_buf, size_t len)
{
@ -69,6 +62,20 @@ sendall(int sock, const void *_buf, size_t len)
return len;
}
static const char *
version_and_features(void)
{
static char buf[256];
snprintf(buf, sizeof(buf),
"version: %s %cpgo %cime %cgraphemes %cassertions",
FOOT_VERSION,
feature_pgo() ? '+' : '-',
feature_ime() ? '+' : '-',
feature_graphemes() ? '+' : '-',
feature_assertions() ? '+' : '-');
return buf;
}
static void
print_usage(const char *prog_name)
{
@ -77,7 +84,6 @@ print_usage(const char *prog_name)
" -t,--term=TERM value to set the environment variable TERM to (" FOOT_DEFAULT_TERM ")\n"
" -T,--title=TITLE initial window title (foot)\n"
" -a,--app-id=ID window application ID (foot)\n"
" --toplevel-tag=TAG set a custom toplevel tag\n"
" -w,--window-size-pixels=WIDTHxHEIGHT initial width and height, in pixels\n"
" -W,--window-size-chars=WIDTHxHEIGHT initial width and height, in characters\n"
" -m,--maximized start in maximized mode\n"
@ -139,10 +145,6 @@ send_string_list(int fd, const string_list_t *string_list)
return true;
}
enum {
TOPLEVEL_TAG_OPTION = CHAR_MAX + 1,
};
int
main(int argc, char *const *argv)
{
@ -157,7 +159,6 @@ main(int argc, char *const *argv)
{"term", required_argument, NULL, 't'},
{"title", required_argument, NULL, 'T'},
{"app-id", required_argument, NULL, 'a'},
{"toplevel-tag", required_argument, NULL, TOPLEVEL_TAG_OPTION},
{"window-size-pixels", required_argument, NULL, 'w'},
{"window-size-chars", required_argument, NULL, 'W'},
{"maximized", no_argument, NULL, 'm'},
@ -227,12 +228,6 @@ main(int argc, char *const *argv)
goto err;
break;
case TOPLEVEL_TAG_OPTION:
snprintf(buf, sizeof(buf), "toplevel-tag=%s", optarg);
if (!push_string(&overrides, buf, &total_len))
goto err;
break;
case 'L':
if (!push_string(&overrides, "login-shell=yes", &total_len))
goto err;
@ -333,7 +328,7 @@ main(int argc, char *const *argv)
break;
case 'v':
print_version_and_features("footclient ");
printf("footclient %s\n", version_and_features());
ret = EXIT_SUCCESS;
goto err;
@ -404,10 +399,10 @@ main(int argc, char *const *argv)
const char *cwd = custom_cwd;
if (cwd == NULL) {
errno = 0;
size_t buf_len = 1024;
do {
_cwd = xrealloc(_cwd, buf_len);
errno = 0;
if (getcwd(_cwd, buf_len) == NULL && errno != ERANGE) {
LOG_ERRNO("failed to get current working directory");
goto err;
@ -527,63 +522,15 @@ main(int argc, char *const *argv)
if (!send_string_list(fd, &envp))
goto err;
struct sigaction sa_int = {.sa_handler = &sigint_handler};
struct sigaction sa_usr = {.sa_handler = &sigusr_handler};
sigemptyset(&sa_int.sa_mask);
sigemptyset(&sa_usr.sa_mask);
if (sigaction(SIGINT, &sa_int, NULL) < 0 ||
sigaction(SIGTERM, &sa_int, NULL) < 0 ||
sigaction(SIGUSR1, &sa_usr, NULL) < 0 ||
sigaction(SIGUSR2, &sa_usr, NULL) < 0)
{
struct sigaction sa = {.sa_handler = &sig_handler};
sigemptyset(&sa.sa_mask);
if (sigaction(SIGINT, &sa, NULL) < 0 || sigaction(SIGTERM, &sa, NULL) < 0) {
LOG_ERRNO("failed to register signal handlers");
goto err;
}
int exit_code;
ssize_t rcvd = -1;
while (true) {
rcvd = recv(fd, &exit_code, sizeof(exit_code), 0);
const int got_sigusr = sigusr;
sigusr = 0;
if (rcvd < 0 && errno == EINTR) {
if (aborted)
break;
else if (got_sigusr != 0) {
LOG_DBG("sending sigusr %d to server", got_sigusr);
struct {
struct client_ipc_hdr hdr;
struct client_ipc_sigusr sigusr;
} ipc = {
.hdr = {
.ipc_code = FOOT_IPC_SIGUSR,
.size = sizeof(struct client_ipc_sigusr),
},
.sigusr = {
.signo = got_sigusr,
},
};
ssize_t count = send(fd, &ipc, sizeof(ipc), 0);
if (count < 0) {
LOG_ERRNO("failed to send SIGUSR IPC to server");
goto err;
} else if ((size_t)count != sizeof(ipc)) {
LOG_ERR("failed to send SIGUSR IPC to server");
goto err;
}
}
continue;
}
break;
}
ssize_t rcvd = recv(fd, &exit_code, sizeof(exit_code), 0);
if (rcvd == -1 && errno == EINTR)
xassert(aborted);

View file

@ -6,7 +6,6 @@ _foot()
local cur prev flags word commands match previous_words i offset
flags=(
"--app-id"
"--toplevel-tag"
"--check-config"
"--config"
"--font"
@ -41,7 +40,7 @@ _foot()
for word in "${previous_words[@]}" ; do
match=$(printf "$commands" | grep -Fx "$word" 2>/dev/null)
if [[ ! -z "$match" ]] ; then
if [[ ${COMP_WORDS[i-1]} =~ ^(--app-id|--toplevel-tag|--config|--font|--log-level|--pty|--term|--title|--window-size-pixels|--window-size-chars|--working-directory)$ ]] ; then
if [[ ${COMP_WORDS[i-1]} =~ ^(--app-id|--config|--font|--log-level|--pty|--term|--title|--window-size-pixels|--window-size-chars|--working-directory)$ ]] ; then
(( i++ ))
continue
fi
@ -76,7 +75,7 @@ _foot()
COMPREPLY=( $(compgen -W "none error warning info" -- ${cur}) ) ;;
--log-colorize|-l)
COMPREPLY=( $(compgen -W "never always auto" -- ${cur}) ) ;;
--app-id|--toplevel-tag|--help|--override|--pty|--title|--version|--window-size-chars|--window-size-pixels|--check-config|-[ahoTvWwC])
--app-id|--help|--override|--pty|--title|--version|--window-size-chars|--window-size-pixels|--check-config|-[ahoTvWwC])
# Don't autocomplete for these flags
: ;;
*)

View file

@ -6,7 +6,6 @@ _footclient()
local cur prev flags word commands match previous_words i offset
flags=(
"--app-id"
"--toplevel-tag"
"--fullscreen"
"--help"
"--hold"
@ -36,7 +35,7 @@ _footclient()
for word in "${previous_words[@]}" ; do
match=$(printf "$commands" | grep -Fx "$word" 2>/dev/null)
if [[ ! -z "$match" ]] ; then
if [[ ${COMP_WORDS[i-1]} =~ ^(--app-id|--toplevel-tag|--log-level|--server-socket|--term|--title|--window-size-pixels|--window-size-chars|--working-directory)$ ]] ; then
if [[ ${COMP_WORDS[i-1]} =~ ^(--app-id|--log-level|--server-socket|--term|--title|--window-size-pixels|--window-size-chars|--working-directory)$ ]] ; then
(( i++ ))
continue
fi
@ -68,7 +67,7 @@ _footclient()
COMPREPLY=( $(compgen -W "none error warning info" -- ${cur}) ) ;;
--log-colorize|-l)
COMPREPLY=( $(compgen -W "never always auto" -- ${cur}) ) ;;
--app-id|--toplevel-tag|--help|--override|--title|--version|--window-size-chars|--window-size-pixels|-[ahoTvWw])
--app-id|--help|--override|--title|--version|--window-size-chars|--window-size-pixels|-[ahoTvWw])
# Don't autocomplete for these flags
: ;;
*)

View file

@ -6,7 +6,6 @@ complete -c foot -x -s f -l font -a "(fc-list : family | sed 's/,/
complete -c foot -x -s t -l term -a '(find /usr/share/terminfo -type f -printf "%f\n")' -d "value to set the environment variable TERM to (foot)"
complete -c foot -x -s T -l title -d "initial window title"
complete -c foot -x -s a -l app-id -d "value to set the app-id property on the Wayland window to (foot)"
complete -c foot -x -l toplevel-tag -d "value to set the toplevel-tag property on the Wayland window to"
complete -c foot -s m -l maximized -d "start in maximized mode"
complete -c foot -s F -l fullscreen -d "start in fullscreen mode"
complete -c foot -s L -l login-shell -d "start shell as a login shell"

View file

@ -2,7 +2,6 @@ complete -c footclient -x -a "(__fish_complete_subcom
complete -c footclient -x -s t -l term -a '(find /usr/share/terminfo -type f -printf "%f\n")' -d "value to set the environment variable TERM to (foot)"
complete -c footclient -x -s T -l title -d "initial window title"
complete -c footclient -x -s a -l app-id -d "value to set the app-id property on the Wayland window to (foot)"
complete -c footclient -x -l toplevel-tag -d "value to set the toplevel-tag property on the Wayland window to"
complete -c footclient -s m -l maximized -d "start in maximized mode"
complete -c footclient -s F -l fullscreen -d "start in fullscreen mode"
complete -c footclient -s L -l login-shell -d "start shell as a login shell"

View file

@ -9,7 +9,6 @@ _arguments \
'(-t --term)'{-t,--term}'[value to set the environment variable TERM to (foot)]:term:->terms' \
'(-T --title)'{-T,--title}'[initial window title]:()' \
'(-a --app-id)'{-a,--app-id}'[value to set the app-id property on the Wayland window to (foot)]:()' \
'--toplevel-tag=[value to set the toplevel-tag property on the Wayland window to]:()' \
'(-m --maximized)'{-m,--maximized}'[start in maximized mode]' \
'(-F --fullscreen)'{-F,--fullscreen}'[start in fullscreen mode]' \
'(-L --login-shell)'{-L,--login-shell}'[start shell as a login shell]' \

View file

@ -5,7 +5,6 @@ _arguments \
'(-t --term)'{-t,--term}'[value to set the environment variable TERM to (foot)]:term:->terms' \
'(-T --title)'{-T,--title}'[initial window title]:()' \
'(-a --app-id)'{-a,--app-id}'[value to set the app-id property on the Wayland window to (foot)]:()' \
'--toplevel-tag=[value to set the toplevel-tag property on the Wayland window to]:()' \
'(-m --maximized)'{-m,--maximized}'[start in maximized mode]' \
'(-F --fullscreen)'{-F,--fullscreen}'[start in fullscreen mode]' \
'(-L --login-shell)'{-L,--login-shell}'[start shell as a login shell]' \

View file

@ -4,54 +4,8 @@
#include <stdbool.h>
#include "debug.h"
#include "terminal.h"
uint32_t
composed_key_from_chars(const uint32_t chars[], size_t count)
{
if (count == 0)
return 0;
uint32_t key = chars[0];
for (size_t i = 1; i < count; i++)
key = composed_key_from_key(key, chars[i]);
return key;
}
uint32_t
composed_key_from_key(uint32_t prev_key, uint32_t next_char)
{
unsigned bits = 32 - __builtin_clz(CELL_COMB_CHARS_HI - CELL_COMB_CHARS_LO);
/* Rotate old key 8 bits */
uint32_t new_key = (prev_key << 8) | (prev_key >> (bits - 8));
/* xor with new char */
new_key ^= next_char;
/* Multiply with magic hash constant */
new_key *= 2654435761ul;
/* And mask, to ensure the new value is within range */
new_key &= CELL_COMB_CHARS_HI - CELL_COMB_CHARS_LO;
return new_key;
}
UNITTEST
{
const char32_t chars[] = U"abcdef";
uint32_t k1 = composed_key_from_key(chars[0], chars[1]);
uint32_t k2 = composed_key_from_chars(chars, 2);
xassert(k1 == k2);
uint32_t k3 = composed_key_from_key(k2, chars[2]);
uint32_t k4 = composed_key_from_chars(chars, 3);
xassert(k3 == k4);
}
const struct composed *
struct composed *
composed_lookup(struct composed *root, uint32_t key)
{
struct composed *node = root;
@ -66,41 +20,6 @@ composed_lookup(struct composed *root, uint32_t key)
return NULL;
}
const struct composed *
composed_lookup_without_collision(struct composed *root, uint32_t *key,
const char32_t *prefix_text, size_t prefix_len,
char32_t wc, int forced_width)
{
while (true) {
const struct composed *cc = composed_lookup(root, *key);
if (cc == NULL)
return NULL;
bool match = cc->count == prefix_len + 1 &&
cc->forced_width == forced_width &&
cc->chars[prefix_len] == wc;
if (match) {
for (size_t i = 0; i < prefix_len; i++) {
if (cc->chars[i] != prefix_text[i]) {
match = false;
break;
}
}
}
if (match)
return cc;
(*key)++;
*key &= CELL_COMB_CHARS_HI - CELL_COMB_CHARS_LO;
/* TODO: this will loop infinitely if the composed table is full */
}
return NULL;
}
void
composed_insert(struct composed **root, struct composed *node)
{

View file

@ -10,16 +10,9 @@ struct composed {
uint32_t key;
uint8_t count;
uint8_t width;
uint8_t forced_width;
};
uint32_t composed_key_from_chars(const uint32_t chars[], size_t count);
uint32_t composed_key_from_key(uint32_t prev_key, uint32_t next_char);
const struct composed *composed_lookup(struct composed *root, uint32_t key);
const struct composed *composed_lookup_without_collision(
struct composed *root, uint32_t *key,
const char32_t *prefix, size_t prefix_len, char32_t wc, int forced_width);
struct composed *composed_lookup(struct composed *root, uint32_t key);
void composed_insert(struct composed **root, struct composed *node);
void composed_free(struct composed *root);

884
config.c

File diff suppressed because it is too large Load diff

181
config.h
View file

@ -1,8 +1,7 @@
#pragma once
#include <regex.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdbool.h>
#include <uchar.h>
#include <xkbcommon/xkbcommon.h>
@ -28,7 +27,7 @@ struct font_size_adjustment {
float percent;
};
enum cursor_style { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BEAM, CURSOR_HOLLOW };
enum cursor_style { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BEAM };
enum cursor_unfocused_style {
CURSOR_UNFOCUSED_UNCHANGED,
CURSOR_UNFOCUSED_HOLLOW,
@ -61,7 +60,6 @@ enum binding_aux_type {
BINDING_AUX_NONE,
BINDING_AUX_PIPE,
BINDING_AUX_TEXT,
BINDING_AUX_REGEX,
};
struct binding_aux {
@ -75,8 +73,6 @@ struct binding_aux {
uint8_t *data;
size_t len;
} text;
char *regex_name;
};
};
@ -124,107 +120,11 @@ struct env_var {
};
typedef tll(struct env_var) env_var_list_t;
struct custom_regex {
char *name;
char *regex;
regex_t preg;
struct config_spawn_template launch;
};
struct color_theme {
uint32_t fg;
uint32_t bg;
uint32_t flash;
uint32_t flash_alpha;
uint32_t table[256];
uint16_t alpha;
uint32_t selection_fg;
uint32_t selection_bg;
uint32_t url;
uint32_t dim[8];
uint32_t sixel[16];
enum {
DIM_BLEND_TOWARDS_BLACK,
DIM_BLEND_TOWARDS_WHITE,
} dim_blend_towards;
enum {
ALPHA_MODE_DEFAULT,
ALPHA_MODE_MATCHING,
ALPHA_MODE_ALL
} alpha_mode;
struct {
uint32_t text;
uint32_t cursor;
} cursor;
struct {
uint32_t fg;
uint32_t bg;
} jump_label;
struct {
uint32_t fg;
uint32_t bg;
} scrollback_indicator;
struct {
struct {
uint32_t fg;
uint32_t bg;
} no_match;
struct {
uint32_t fg;
uint32_t bg;
} match;
} search_box;
struct {
bool cursor:1;
bool jump_label:1;
bool scrollback_indicator:1;
bool url:1;
bool search_box_no_match:1;
bool search_box_match:1;
uint8_t dim;
} use_custom;
bool blur;
};
enum which_color_theme {
COLOR_THEME_DARK,
COLOR_THEME_LIGHT,
COLOR_THEME_1, /* Deprecated */
COLOR_THEME_2, /* Deprecated */
};
enum shm_bit_depth {
SHM_BITS_AUTO,
SHM_BITS_8,
SHM_BITS_10,
SHM_BITS_16,
};
enum center_when {
CENTER_INVALID,
CENTER_NEVER,
CENTER_FULLSCREEN,
CENTER_MAXIMIZED_AND_FULLSCREEN,
CENTER_ALWAYS,
};
struct config {
char *conf_path;
char *term;
char *shell;
char *title;
char *app_id;
char *toplevel_tag;
char32_t *word_delimiters;
bool login_shell;
bool locked_title;
@ -235,21 +135,15 @@ struct config {
uint32_t height;
} size;
unsigned pad_left;
unsigned pad_top;
unsigned pad_right;
unsigned pad_bottom;
enum center_when center_when;
unsigned pad_x;
unsigned pad_y;
bool center;
bool resize_by_cells;
bool resize_keep_grid;
uint16_t resize_delay_ms;
struct {
float amount;
} dim;
struct {
bool enabled;
bool palette_based;
@ -259,8 +153,6 @@ struct config {
enum { STARTUP_WINDOWED, STARTUP_MAXIMIZED, STARTUP_FULLSCREEN } startup_mode;
bool dpi_aware;
bool gamma_correct;
bool uppercase_regex_insert;
struct config_font_list fonts[4];
struct font_size_adjustment font_size_adjustment;
@ -294,7 +186,6 @@ struct config {
bool urgent;
bool notify;
bool flash;
bool system_bell;
struct config_spawn_template command;
bool command_focused;
} bell;
@ -328,15 +219,58 @@ struct config {
OSC8_UNDERLINE_ALWAYS,
} osc8_underline;
char *regex;
regex_t preg;
char32_t **protocols;
char32_t *uri_characters;
size_t prot_count;
size_t max_prot_len;
} url;
tll(struct custom_regex) custom_regexes;
struct {
uint32_t fg;
uint32_t bg;
uint32_t flash;
uint32_t flash_alpha;
uint32_t table[256];
uint16_t alpha;
uint32_t selection_fg;
uint32_t selection_bg;
uint32_t url;
struct color_theme colors_dark;
struct color_theme colors_light;
enum which_color_theme initial_color_theme;
uint32_t dim[8];
uint32_t sixel[16];
struct {
uint32_t fg;
uint32_t bg;
} jump_label;
struct {
uint32_t fg;
uint32_t bg;
} scrollback_indicator;
struct {
struct {
uint32_t fg;
uint32_t bg;
} no_match;
struct {
uint32_t fg;
uint32_t bg;
} match;
} search_box;
struct {
bool selection:1;
bool jump_label:1;
bool scrollback_indicator:1;
bool url:1;
bool search_box_no_match:1;
bool search_box_match:1;
uint8_t dim;
} use_custom;
} colors;
struct {
enum cursor_style style;
@ -345,6 +279,10 @@ struct config {
bool enabled;
uint32_t rate_ms;
} blink;
struct {
uint32_t text;
uint32_t cursor;
} color;
struct pt_or_px beam_thickness;
struct pt_or_px underline_thickness;
} cursor;
@ -447,9 +385,6 @@ struct config {
bool box_drawing_solid_shades;
bool font_monospace_warn;
bool sixel;
enum shm_bit_depth surface_bit_depth;
uint32_t min_stride_alignment;
bool preapply_damage;
} tweak;
struct {

85
csi.c
View file

@ -117,9 +117,9 @@ csi_sgr(struct terminal *term)
style > UNDERLINE_SINGLE;
break;
}
} else
term->bits_affecting_ascii_printer.underline_style = false;
term_update_ascii_printer(term);
term_update_ascii_printer(term);
}
break;
}
case 5: term->vt.attrs.blink = true; break;
@ -422,8 +422,6 @@ decset_decrst(struct terminal *term, unsigned param, bool enable)
case 1004:
term->focus_events = enable;
if (enable)
term_to_slave(term, term->kbd_focus ? "\033[I" : "\033[O", 3);
break;
case 1005:
@ -560,13 +558,7 @@ decset_decrst(struct terminal *term, unsigned param, bool enable)
break;
case 2027:
#if defined(FOOT_GRAPHEME_CLUSTERING)
term->grapheme_shaping = enable;
#endif
break;
case 2031:
term->report_theme_changes = enable;
break;
case 2048:
@ -663,7 +655,6 @@ decrqm(const struct terminal *term, unsigned param)
case 2027: return term->conf->tweak.grapheme_width_method != GRAPHEME_WIDTH_DOUBLE
? DECRPM_PERMANENTLY_RESET
: decrpm(term->grapheme_shaping);
case 2031: return decrpm(term->report_theme_changes);
case 2048: return decrpm(term->size_notifications);
case 8452: return decrpm(term->sixel.cursor_right_of_graphics);
case 737769: return decrpm(term_ime_is_enabled(term));
@ -709,7 +700,6 @@ xtsave(struct terminal *term, unsigned param)
case 2004: term->xtsave.bracketed_paste = term->bracketed_paste; break;
case 2026: term->xtsave.app_sync_updates = term->render.app_sync_updates.enabled; break;
case 2027: term->xtsave.grapheme_shaping = term->grapheme_shaping; break;
case 2031: term->xtsave.report_theme_changes = term->report_theme_changes; break;
case 2048: term->xtsave.size_notifications = term->size_notifications; break;
case 8452: term->xtsave.sixel_cursor_right_of_graphics = term->sixel.cursor_right_of_graphics; break;
case 737769: term->xtsave.ime = term_ime_is_enabled(term); break;
@ -754,7 +744,6 @@ xtrestore(struct terminal *term, unsigned param)
case 2004: enable = term->xtsave.bracketed_paste; break;
case 2026: enable = term->xtsave.app_sync_updates; break;
case 2027: enable = term->xtsave.grapheme_shaping; break;
case 2031: enable = term->xtsave.report_theme_changes; break;
case 2048: enable = term->xtsave.size_notifications; break;
case 8452: enable = term->xtsave.sixel_cursor_right_of_graphics; break;
case 737769: enable = term->xtsave.ime; break;
@ -801,20 +790,10 @@ csi_dispatch(struct terminal *term, uint8_t final)
int count = vt_param_get(term, 0, 1);
LOG_DBG("REP: '%lc' %d times", (wint_t)term->vt.last_printed, count);
int width;
if (term->vt.last_printed >= CELL_COMB_CHARS_LO) {
const struct composed *comp = composed_lookup(
term->composed, term->vt.last_printed - CELL_COMB_CHARS_LO);
xassert(comp != NULL);
width = comp->forced_width > 0 ? comp->forced_width : comp->width;
} else
width = c32width(term->vt.last_printed);
const int width = c32width(term->vt.last_printed);
if (width > 0) {
for (int i = 0; i < count; i++)
term_print(term, term->vt.last_printed, width, false);
term_print(term, term->vt.last_printed, width);
}
}
break;
@ -852,7 +831,6 @@ csi_dispatch(struct terminal *term, uint8_t final)
* - 22 ANSI color, e.g., VT525.
* - 28 Rectangular editing.
* - 29 ANSI text locator (i.e., DEC Locator mode).
* - 52 Clipboard access
*
* Note: we report ourselves as a VT220, mainly to be able
* to pass parameters, to indicate we support sixel, and
@ -863,15 +841,13 @@ csi_dispatch(struct terminal *term, uint8_t final)
*
* Note: tertiary DA responds with "FOOT".
*/
char reply[32];
int len = snprintf(
reply, sizeof(reply), "\033[?62%s;22;28%sc",
term->conf->tweak.sixel ? ";4" : "",
(term->conf->security.osc52 == OSC52_ENABLED ||
term->conf->security.osc52 == OSC52_COPY_ENABLED ? ";52" : ""));
term_to_slave(term, reply, len);
if (term->conf->tweak.sixel) {
static const char reply[] = "\033[?62;4;22;28c";
term_to_slave(term, reply, sizeof(reply) - 1);
} else {
static const char reply[] = "\033[?62;22;28c";
term_to_slave(term, reply, sizeof(reply) - 1);
}
break;
}
@ -1561,32 +1537,6 @@ csi_dispatch(struct terminal *term, uint8_t final)
break;
}
case 'n': {
const int param = vt_param_get(term, 0, 0);
switch (param) {
case 996: { /* Query current theme mode (see private mode 2031) */
/*
* 1 - dark mode
* 2 - light mode
*
* In foot, the themes aren't necessarily light/dark,
* but by convention, the primary theme is dark, and
* the alternative theme is light.
*/
char reply[16] = {0};
int chars = snprintf(
reply, sizeof(reply),
"\033[?997;%dn",
term->colors.active_theme == COLOR_THEME_DARK ? 1 : 2);
term_to_slave(term, reply, chars);
break;
}
}
break;
}
case 'p': {
/*
* Request status of ECMA-48/"ANSI" private mode (DECRQM
@ -1644,10 +1594,10 @@ csi_dispatch(struct terminal *term, uint8_t final)
* 64 - vt520
* 65 - vt525
*
* Param 2 - firmware version xterm uses its version
* number. We do to, in the format "MAJORMINORPATCH",
* where all three version numbers are always two
* digits. So e.g. 1.25.0 is reported as 012500.
* Param 2 - firmware version
* xterm uses its version number. We use an xterm
* version number too, since e.g. Emacs uses this to
* determine level of support.
*
* We report ourselves as a VT220. This must be
* synchronized with the primary DA response.
@ -1806,8 +1756,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
case 1: /* blinking block */
case 2: /* steady block */
term->cursor_style = term->conf->cursor.style == CURSOR_HOLLOW
? CURSOR_HOLLOW : CURSOR_BLOCK;
term->cursor_style = CURSOR_BLOCK;
break;
case 3: /* blinking underline */

View file

@ -54,7 +54,7 @@ cursor_shape_to_server_shape(enum cursor_shape shape)
}
enum wp_cursor_shape_device_v1_shape
cursor_string_to_server_shape(const char *xcursor, int bound_version)
cursor_string_to_server_shape(const char *xcursor)
{
if (xcursor == NULL)
return 0;
@ -72,7 +72,7 @@ cursor_string_to_server_shape(const char *xcursor, int bound_version)
[WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_VERTICAL_TEXT] = {"vertical-text"},
[WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALIAS] = {"alias", "dnd-link"},
[WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_COPY] = {"copy", "dnd-copy"},
[WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_MOVE] = {"move", "dnd-move"},
[WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_MOVE] = {"move"}, /* dnd-move? */
[WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NO_DROP] = {"no-drop", "dnd-no-drop"},
[WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NOT_ALLOWED] = {"not-allowed", "crossed_circle"},
[WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_GRAB] = {"grab", "hand1"},
@ -94,29 +94,9 @@ cursor_string_to_server_shape(const char *xcursor, int bound_version)
[WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_SCROLL] = {"all-scroll", "fleur"},
[WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ZOOM_IN] = {"zoom-in"},
[WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ZOOM_OUT] = {"zoom-out"},
#if defined(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK_SINCE_VERSION) /* 1.42 */
[WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK] = {"dnd-ask"},
#endif
#if defined(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE_SINCE_VERSION) /* 1.42 */
[WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE] = {"all-resize"},
#endif
};
for (size_t i = 0; i < ALEN(table); i++) {
#if defined(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK_SINCE_VERSION)
if (i == WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK &&
bound_version < WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK_SINCE_VERSION)
{
continue;
}
#endif
#if defined(WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE_SINCE_VERSION)
if (i == WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE &&
bound_version < WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE_SINCE_VERSION)
{
continue;
}
#endif
for (size_t j = 0; j < ALEN(table[i]); j++) {
if (table[i][j] != NULL && streq(xcursor, table[i][j])) {
return i;

View file

@ -26,4 +26,4 @@ const char *const *cursor_shape_to_string(enum cursor_shape shape);
enum wp_cursor_shape_device_v1_shape cursor_shape_to_server_shape(
enum cursor_shape shape);
enum wp_cursor_shape_device_v1_shape cursor_string_to_server_shape(
const char *xcursor, int bound_version);
const char *xcursor);

1
dcs.c
View file

@ -422,7 +422,6 @@ decrqss_unhook(struct terminal *term)
int mode;
switch (term->cursor_style) {
case CURSOR_HOLLOW: /* FALLTHROUGH */
case CURSOR_BLOCK: mode = 2; break;
case CURSOR_UNDERLINE: mode = 4; break;
case CURSOR_BEAM: mode = 6; break;

View file

@ -337,9 +337,6 @@ that corresponds to one of the following modes:
| 2027
: contour
: Grapheme cluster processing
| 2031
: contour
: Request color theme updates
| 2048
: TODO
: In-band window resize notifications
@ -660,13 +657,6 @@ manipulation sequences. The generic format is:
: xterm
: Report the current entry on the palette stack, and the number of
palettes stored on the stack.
| \\E[ ? 996 n
: Query the current (color) theme mode
: contour
: The current color theme mode (light or dark) is reported as *CSI ?
997 ; 1|2 n*, where *1* means dark and *2* light. By convention, the
primary theme in foot is considered dark, and the alternative theme
light.
# OSC
@ -739,10 +729,7 @@ All _OSC_ sequences begin with *\\E]*, sometimes abbreviated _OSC_.
: Copy _Pd_ (base64 encoded text) to the clipboard. _Pc_ denotes the
target: *c* targets the clipboard and *s* and *p* the primary
selection.
| \\E] 66 ; _params_ ; text \\E\\
: kitty
: Text sizing protocol (only 'w', width, supported)
| \\E] 99 ; _params_ ; _payload_ \\E\\
| \\E] 99 ; _params_ ; _payload_ \\E\\
: kitty
: Desktop notification; uses *desktop-notifications.command* in
*foot.ini*(5).

View file

@ -27,9 +27,6 @@ the foot command line
*-c*,*--config*=_PATH_
Path to configuration file, see *foot.ini*(5) for details.
The configuration file is automatically passed to new terminals
spawned via *spawn-terminal* (see *foot.ini*(5)).
*-C*,*--check-config*
Verify configuration and then exit with 0 if ok, otherwise exit
with 230 (see *EXIT STATUS*).
@ -70,11 +67,6 @@ the foot command line
Value to set the *app-id* property on the Wayland window
to. Default: _foot_ (normal mode), or _footclient_ (server mode).
*toplevel-tag*=_TAG_
Value to set the *toplevel-tag* property on the Wayland window
to. The compositor can use this value for session management,
window rules etc. Default: _not set_
*-m*,*--maximized*
Start in maximized mode. If both *--maximized* and *--fullscreen*
are specified, the _last_ one takes precedence.
@ -260,6 +252,9 @@ These keyboard shortcuts affect the search selection:
*ctrl*+*shift*+*left*
Extend current selection to the left to the last word boundary.
*ctrl*+*shift*+*w*
Extend the current selection to the right to the last whitespace.
*shift*+*down*
Extend current selection down one line
@ -306,12 +301,6 @@ These shortcuts affect the search box in scrollback-search mode:
*alt*+*delete*, *ctrl*+*delete*
Deletes the **word after** the cursor.
*ctrl*+*u*
Deletes from the cursor to the start of the input
*ctrl*+*k*
Deletes from the cursor to the end of the input
These shortcuts affect scrolling in scrollback-search mode:
*shift*+*page-up*
@ -694,21 +683,6 @@ variables may be defined in *foot.ini*(5).
In addition to the variables listed above, custom environment
variables to unset may be defined in *foot.ini*(5).
# Signals
The following signals have special meaning in foot:
- SIGUSR1: switch to the dark color theme (*[colors-dark]*).
- SIGUSR2: switch to the light color theme (*[colors-light]*).
Note: you can send SIGUSR1/SIGUSR2 to a *foot --server* process too,
in which case all client instances will switch theme. Furthermore, all
future client instances will also use the selected theme.
You can also send SIGUSR1/SIGUSR2 to a footclient instance, see
*footclient*(1) for details.
# BUGS
Please report bugs to https://codeberg.org/dnkl/foot/issues

View file

@ -24,12 +24,12 @@ commented out will usually be installed to */etc/xdg/foot/foot.ini*.
Options are set using KEY=VALUE pairs:
*\[colors-dark\]*++
*\[colors\]*++
*background=000000*++
*foreground=ffffff*
Empty values (*KEY=*) are not supported. String options do allow the
empty string to be set, but it must be quoted: *KEY=""*
empty string to be set, but it must be quoted: *KEY=""*)
# SECTION: main
@ -58,16 +58,9 @@ empty string to be set, but it must be quoted: *KEY=""*
- Dina:weight=bold:slant=italic
- Courier New:size=12
- Fantasque Sans Mono:fontfeatures=ss01
- Iosevka:fontfeatures=cv01=1:fontfeatures=cv06=1
- Meslo LG S:size=12, Noto Color Emoji:size=12
- Courier New:pixelsize=8
Be aware that, depending on your setup, there may be global
FontConfig options that overrides options set here. If an option
appears to have no effect, ensure there is no global configuration
file that sets the same option with *assign* or *assign_replace*;
use one of the many *append* or possibly *prepend* modes.
For each option, the first font is the primary font. The remaining
fonts are fallback fonts that will be used whenever a glyph cannot
be found in the primary font.
@ -96,7 +89,7 @@ empty string to be set, but it must be quoted: *KEY=""*
*font-size-adjustment*
Amount, in _points_, _pixels_ or _percent_, to increment/decrement
the font size when zooming in or out.
the font size when zooming in our out.
Examples:
```
@ -129,7 +122,7 @@ empty string to be set, but it must be quoted: *KEY=""*
e.g. *line-height=12px*.
*Warning*: when changing the font size at runtime (i.e. zooming in
or out), foot will change the line height by the same
our out), foot will change the line height by the same
percentage. However, due to rounding, it is possible the line
height will be "too small" for some font sizes, causing
e.g. underscores to "disappear".
@ -161,7 +154,7 @@ empty string to be set, but it must be quoted: *KEY=""*
*underline-offset*
Use a custom offset for underlines. The offset is, by default, in
_points_ and relative to the font's baseline. A positive value
_points_ and relative the font's baseline. A positive value
positions the underline under the baseline, while a negative value
positions it above the baseline.
@ -198,49 +191,9 @@ empty string to be set, but it must be quoted: *KEY=""*
Default: _unset_
*gamma-correct-blending*
Boolean. When enabled, foot will do gamma-correct blending in
linear color space. This is how font glyphs are supposed to be
rendered, but since nearly no applications or toolkits are doing
it on Linux, the result may not look like you are used to.
Compared to the default (disabled), bright glyphs on a dark
background will appear thicker, and dark glyphs on a light
background will appear thinner.
FreeType can limit the effect of the latter, with a technique
called stem darkening. It is only available for CFF fonts
(OpenType, .otf) and disabled by default (in FreeType). You can
enable it by setting the environment variable
*FREETYPE_PROPERTIES="cff:no-stem-darkening=0"* before starting
foot.
Also be aware that many fonts have been developed on systems that
do not do gamma-correct blending, and may therefore look thicker
than intended when rendered with gamma-correct blending, since the
font designer set the font weight based on incorrect rendering.
In order to represent colors faithfully, higher precision image
buffers are required. By default, foot will use either 16-bit, or
10-bit color channels, depending on availability, when
gamma-correct blending is enabled. However, the high precision
buffers are slow; if you want to use gamma-correct blending, but
prefer speed (throughput and input latency) over accurate colors,
you can force 8-bit color channels by setting
*tweak.surface-bit-depth=8-bit*.
Default: _no_.
*uppercase-regex-insert*
Boolean. When enabled, inputting an uppercase hint character in
*show-urls-copy* or *regex-copy* mode will insert the selected
text into the prompt in addition to copying it to the clipboard.
Default: _yes_
*box-drawings-uses-font-glyphs*
Boolean. When disabled, foot generates box/line drawing characters
itself. There are several advantages to doing this instead of using
itself. The are several advantages to doing this instead of using
font glyphs:
- No antialiasing effects where e.g. line endpoints appear
@ -260,7 +213,6 @@ empty string to be set, but it must be quoted: *KEY=""*
- U+02500 - U+0259F
- U+02800 - U+028FF
- U+1CD00 - U+1CDE5
- U+1Fb00 - U+1FB9B
Default: _no_.
@ -281,7 +233,7 @@ empty string to be set, but it must be quoted: *KEY=""*
scaling factor *does* double the font size.
Note that this option typically does not work with bitmap fonts,
which only contain a pre-defined set of sizes, and cannot be
which only contains a pre-defined set of sizes, and cannot be
dynamically scaled. Whichever size (of the available ones) that
best matches the DPI or scaling factor, will be used.
@ -296,40 +248,18 @@ empty string to be set, but it must be quoted: *KEY=""*
*pad*
Padding between border and glyphs, in pixels (subject to output
scaling), in the form
scaling), in the form _XxY_.
```
_XxY_ [center | center-when-fullscreen | center-when-maximized-and-fullscreen]
```
or
```
RIGHTxTOPxLEFTxBOTTOM [center | center-when-fullscreen | center-when-maximized-and-fullscreen]
```
This will add _at least_ X pixels on both the left and right
sides, and Y pixels on the top and bottom sides. The grid content
will be anchored in the top left corner. I.e. if the window
manager forces an odd window size on foot, the additional pixels
will be added to the right and bottom sides.
- `_XxY_` adds _at least_:
- X pixels on the left and right sides.
- Y pixels on the top and bottom sides.
To instead center the grid content, append *center* (e.g. *pad=5x5
center*).
- `LEFTxTOPxRIGHTxBOTTOM` adds **at least**:
- LEFT pixels to the left
- TOP pixels to the top
- RIGHT pixels to the right
- BOTTOM pixels to the bottom
When no centering is specified, the grid content is anchored to
the top left corner. I.e. if the window manager forces an odd
window size on foot, the additional pixels will be added to the
right and bottom sides.
If *center* is specified, the grid content is instead
centered. This may cause "jumpiness" when resizing the window.
With *center-when-fullscreen* and
*center-when-maximized-and-fullscreen*, the grid is anchored to
the top left corner, unless the window is maximized, or
fullscreened.
Default: _0x0_ center-when-maximized-and-fullscreen.
Default: _0x0_.
*resize-delay-ms*
@ -348,7 +278,7 @@ empty string to be set, but it must be quoted: *KEY=""*
Emphasis is on _while_ here; as soon as the interactive resize
ends (i.e. when you let go of the window border), the final
dimensions are sent to the client, without any delays.
dimensions is sent to the client, without any delays.
Setting it to 0 disables the delay completely.
@ -363,7 +293,7 @@ empty string to be set, but it must be quoted: *KEY=""*
as necessary to accommodate window sizes that are not multiples of
the cell size.
This option only applies to floating windows. Sizes of maximized, tiled
This option only applies to floating windows. Sizes of maxmized, tiled
or fullscreen windows will not be constrained to multiples of the cell
size.
@ -381,19 +311,6 @@ empty string to be set, but it must be quoted: *KEY=""*
Default: _yes_
*initial-color-theme*
Selects which color theme to use, *dark*, or *light*.
*dark* uses the colors defined in the *colors-dark* section, while
*light* uses the colors from the *colors-light* section.
Use the *color-theme-switch-dark*, *color-theme-switch-light* and
*color-theme-toggle* key bindings to switch between the two themes
at runtime, or send SIGUSR1/SIGUSR2 to the foot process (see
*foot*(1) for details).
Default: _dark_
*initial-window-size-pixels*
Initial window width and height in _pixels_ (subject to output
scaling), in the form _WIDTHxHEIGHT_. The height _includes_ the
@ -410,7 +327,7 @@ empty string to be set, but it must be quoted: *KEY=""*
*initial-window-size-chars*
Initial window width and height in _characters_, in the form
_WIDTHxHEIGHT_. Mutually exclusive to
*initial-window-size-pixels*.
*initial-window-size-pixels*.'
Note that if you have a multi-monitor setup, with different
scaling factors, there is a possibility the window size will not
@ -440,15 +357,10 @@ empty string to be set, but it must be quoted: *KEY=""*
apply window management rules. Default: _foot_ (normal mode), or
_footclient_ (server mode).
*toplevel-tag*
Value to set the *toplevel-tag* property on the Wayland window
to. The compositor can use this value for session management,
window rules etc. Default: _not set_
*bold-text-in-bright*
Semi-boolean. When enabled, bold text is rendered in a brighter
color (in addition to using a bold font). The color is brightened
by blending it with white.
by increasing its luminance.
If set to *palette-based*, rather than a simple *yes|true*, colors
matching one of the 8 regular palette colors will be brightened
@ -471,10 +383,6 @@ empty string to be set, but it must be quoted: *KEY=""*
multithreading. Default: the number of available logical CPUs
(including SMT). Note that this is not always the best value. In
some cases, the number of physical _cores_ is better.
In case you have a ridiculous amount of cores and/or threads,
consider limiting the number of *workers*, since foot cannot
parallelize more than the number of visible rows.
*utmp-helper*
Path to utmp logging helper binary.
@ -537,17 +445,10 @@ Note: do not set *TERM* here; use the *term* option in the main
# SECTION: bell
*system*
Boolean, when set to _yes_, ring the system bell. The bell is rung
independent of whether the foot window has keyboard focus or
not. Exact behavior is compositor dependent.
Default: _yes_
*urgent*
Boolean, when set to _yes_, foot will signal urgency to the
compositor through the XDG activation protocol whenever *BEL* is
received, and the window does NOT have keyboard focus.
When set to _yes_, foot will signal urgency to the compositor
through the XDG activation protocol whenever *BEL* is received,
and the window does NOT have keyboard focus.
If the compositor does not implement this protocol, the margins
will be painted in red instead.
@ -558,25 +459,25 @@ Note: do not set *TERM* here; use the *term* option in the main
Default: _no_
*notify*
Boolean, when set to _yes_, foot will emit a desktop notification
using the command specified in the *notify* option whenever *BEL*
is received. By default, bell notifications are shown only when
the window does *not* have keyboard focus. See
When set to _yes_, foot will emit a desktop notification using the
command specified in the *notify* option whenever *BEL* is
received. By default, bell notifications are shown only when the
window does *not* have keyboard focus. See
_desktop-notifications.inhibit-when-focused_.
Default: _no_
*visual*
Boolean, when set to _yes_, foot will flash the terminal
window. Default: _no_
When set to _yes_, foot will flash the terminal window. Default:
_no_
*command*
When set, foot will execute this command when *BEL* is received.
Default: none
*command-focused*
Boolean, whether to run the command on *BEL* even while
focused. Default: _no_
Whether to run the command on *BEL* even while focused. Default:
_no_
# SECTION: desktop-notifications
@ -599,7 +500,7 @@ Note: do not set *TERM* here; use the *term* option in the main
option, or preferably, by setting the *image-path* hint (with
e.g. notify-send's *--hint* option).
_${category}_ is replaced by the notification's category. Can
_${category}_ is replaced by the notification's catogory. Can
be used together with e.g. notify-send's *--category* option.
_${urgency}_ is replaced with the notifications urgency;
@ -711,7 +612,7 @@ xdgtoken=95ebdfe56e4f47ddb5bba9d7dc3a2c35
Foot recognizes this as:
- notification has the daemon assigned ID 17
- the user triggered the default action
- the notification sent an XDG activation token
- the notification send an XDG activation token
Example #2:
17++
@ -727,7 +628,7 @@ xdgtoken=95ebdfe56e4f47ddb5bba9d7dc3a2c35
Foot recognizes this as:
- notification has the daemon assigned ID 17
- the user triggered the first custom action, "1"
- the user triggered the first custom action, "1
Default: _notify-send++
--wait++
@ -771,7 +672,7 @@ xdgtoken=95ebdfe56e4f47ddb5bba9d7dc3a2c35
least one), *command-action-argument* will be expanded with the
action's name and label.
Then, _${action-argument}_ is expanded in *command* to the full list
Then, _${action-argument}_ is expanded *command* to the full list
of actions.
If *command-action-argument* is set to the empty string, no
@ -847,9 +748,6 @@ xdgtoken=95ebdfe56e4f47ddb5bba9d7dc3a2c35
# SECTION: url
Note that you can also add custom regular expressions, see the 'regex'
section.
*launch*
Command to execute when opening URLs. _${url}_ will be replaced
with the actual URL. Default: _xdg-open ${url}_.
@ -877,48 +775,19 @@ section.
Default: _sadfjklewcmpgh_.
*regex*
Regular expression to use when auto-detecting URLs. The format is
"POSIX-Extended Regular Expressions". Note that the first marked
subexpression is used as the URL. In other words, if you want the
whole regex match to be used as an URL, surround all of it with
parenthesis: *(regex-pattern)*.
*protocols*
Comma separated list of protocols (schemes) that should be
recognized in URL mode. Note that only auto-detected URLs are
affected by this option. OSC-8 URLs are always enabled, regardless
of protocol. Default: _http, https, ftp, ftps, file, gemini,
gopher, irc, ircs_.
*uri-characters*
Set of characters allowed in auto-detected URLs. Any character not
included in this set constitutes a URL delimiter.
Default: _(((https?://|mailto:|ftp://|file:|ssh:|ssh://|git://|tel:|magnet:|ipfs://|ipns://|gemini://|gopher://|news:)|www\.)([0-9a-zA-Z:/?#@!$&\*+,;=.~\_%^\-]+|\([]\["0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]\*\)|\[[\(\)"0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]\*\]|"[]\[\(\)0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]\*"|'[]\[\(\)0-9a-zA-Z:/?#@!$&\*+,;=.~\_%^\-]\*')+([0-9a-zA-Z/#@$&\*+=~\_%^\-]|\([]\["0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]\*\)|\[[\(\)"0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]\*\]|"[]\[\(\)0-9a-zA-Z:/?#@!$&'\*+,;=.~\_%^\-]\*"|'[]\[\(\)0-9a-zA-Z:/?#@!$&\*+,;=.~\_%^\-]\*'))_
# SECTION: regex
Similar to the 'url' mode, but with custom defined regular expressions
(and launchers).
To use a custom defined regular expression, you also need to add a key
binding for it. This is done in the *key-binding* section, see below
for details. For example, a regex to detect hash digests (e.g. git
commit hashes) could look like:
```
[regex:hashes]
regex=([a-fA-F0-9]{7,128})
launch=path-to-script-or-application ${match}
[key-bindings]
regex-launch=[hashes] Control+Shift+q
regex-copy=[hashes] Control+Mod1+Shift+q
```
*launch*
Command to execute when "launching" a regex match. _${match}_ will
be replaced with the actual URL. Default: _not set_.
*regex*
Regular expression to use when matching text. The format is
"POSIX-Extended Regular Expressions". Note that the first marked
subexpression is used as the match. In other words, if you want
the whole regex match to be used, surround all of it with
parenthesis: *(regex-pattern)*.
Default: _not set_.
Default:
_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-\_.,~:;/?#@!$&%\*+="'()[]_
# SECTION: cursor
@ -927,8 +796,8 @@ applications can change these at runtime.
*style*
Configures the default cursor style, and is one of: *block*,
*beam*, *underline* or *hollow*. Note that this can be overridden
by applications. Default: _block_.
*beam* or *underline*. Note that this can be overridden by
applications. Default: _block_.
*unfocused-style*
Configures how the cursor is rendered when the terminal window is
@ -944,10 +813,19 @@ applications can change these at runtime.
by applications. Related option: *blink-rate*. Default: _no_.
*blink-rate*
The rate at which the cursor blinks, when cursor blinking has been
The rate at which the cursor blink, when cursor blinking has been
enabled. Expressed in milliseconds between each blink. Default:
_500_.
*color*
Two space separated RRGGBB values (i.e. plain old 6-digit hex
values, without prefix) specifying the foreground (text) and
background (cursor) colors for the cursor.
Example: *ff0000 00ff00* (green cursor, red text)
Default: the regular foreground and background colors, reversed.
*beam-thickness*
Thickness (width) of the beam styled cursor. The value is in
points, and its exact value thus depends on the monitor's DPI. To
@ -998,34 +876,16 @@ applications can change these at runtime.
Default: _400_.
# SECTION: colors-dark, colors-light
# SECTION: colors
These two sections controls the 16 ANSI colors, the default foreground
and background colors, and the extended 256 color palette. Note that
This section controls the 16 ANSI colors, the default foreground and
background colors, and the extended 256 color palette. Note that
applications can change these at runtime.
The colors are in RRGGBB format (i.e. plain old 6-digit hex values,
without prefix). That is, they do *not* have an alpha component. You
can configure the background transparency with the _alpha_ option.
*colors-dark* is intended to define a dark color theme, and
*colors-light* is intended to define a light color theme. You can
switch between them using the *color-theme-switch-dark*,
*color-theme-switch-light* and *color-theme-toggle* key bindings, or
by sending SIGUSR1/SIGUSR2 to the foot process.
The default theme used is *colors-dark*, unless
*initial-color-theme=light* has been set.
*cursor*
Two space separated RRGGBB values (i.e. plain old 6-digit hex
values, without prefix) specifying the foreground (text) and
background (cursor) colors for the cursor.
Example: *ff0000 00ff00* (green cursor, red text)
Default: the regular foreground and background colors, reversed.
*foreground*
Default foreground color. This is the color used when no ANSI
color is being used. Default: _839496_.
@ -1051,9 +911,8 @@ The default theme used is *colors-dark*, unless
an entry in the color palette. Applications emit them by combining
a color value, and a "dim" attribute.
By default, foot implements this by blending the current color
with black or white, depending on what the *dim-blend-towards*
option is set to . This is a generic approach that applies to both
By default, foot implements this by reducing the luminance of the
current color. This is a generic approach that applies to both
colors from the 256-color palette, as well as 24-bit RGB colors.
You can change this behavior by setting the *dimN* options. When
@ -1065,7 +924,7 @@ The default theme used is *colors-dark*, unless
the corresponding *regularN* color will be used.
If the current color does not match any known color, it is dimmed
by blending with black (i.e. the same behavior as if the *dimN*
by reducing the luminance (i.e. the same behavior as if the *dimN*
options are unconfigured). 24-bit RGB colors will typically fall
into this category.
@ -1093,40 +952,10 @@ The default theme used is *colors-dark*, unless
Background translucency. A value in the range 0.0-1.0, where 0.0
means completely transparent, and 1.0 is opaque. Default: _1.0_.
*alpha-mode*
Specifies when *alpha* is applied. One of *default*, *matching* or
*all*.
*default* applies *alpha* to cells with the default background
color, excluding cells with the same RGB value as the default
background color.
*matching* is the same as *default*, but also applies *alpha* to
cells with the same RGB value as the default background color.
*all* applies *alpha* to all cells, regardless of background color.
Default: _default_
*blur*
Boolean. When enabled, foot will blur the background (main window
only, not CSDs etc), when it is transparent. This feature requires
the compositor to implement the _ext-background-effect-v1_
protocol (and specifically, the _blur_ effect).
Default: _no_
*dim-blend-towards*
Which color to blend towards when "auto" dimming a color (see
*dim0*..*dim7* above). One of *black* or *white*. Blending towards
black makes the text darker, while blending towards white makes it
whiter (but still dimmer than normal text).
Default: _black_ (*colors-dark*), _white_ (*colors-light*)
*selection-foreground*, *selection-background*
Foreground (text) and background color to use in selected
text. Default: _inverse foreground/background_.
text. Note that *both* options must be set, or the default will be
used. Default: _inverse foreground/background_.
*jump-labels*
Two color values specifying the foreground (text) and background
@ -1206,7 +1035,7 @@ Examples:
*hide-when-maximized*
Boolean. When enabled, the CSD titlebar is hidden when the window
is maximized. To completely disable the titlebar, set *size* to 0
is maximized. The completely disable the titlebar, set *size* to 0
instead. Default: _no_.
*double-click-to-maximize*
@ -1228,8 +1057,8 @@ Examples:
minimize/maximize/close buttons. Default: _26_.
*button-color*
Foreground color on the minimize/maximize/close buttons and the
titlebar text. Default: use the default _background_ color.
Foreground color on the minimize/maximize/close buttons. Default:
use the default _background_ color.
*button-minimize-color*
Minimize button's background color. Default: use the default
@ -1256,42 +1085,11 @@ Note that if *Shift* is one of the modifiers, the _key_ *must not* be
in upper case. For example, *Control+Shift+V* will never trigger, but
*Control+Shift+v* will.
The default key bindings all use "real" modifiers (*Mod1*, *Mod4*
etc), but "virtual" modifiers (*Alt*, *Super* etc) are allowed.
Note that *Alt* is usually called *Mod1*.
*xkbcli interactive-wayland* can be useful for finding keysym names.
When matching key presses to key bindings, foot uses a couple of
different approaches.
As an example, let's say you press ctrl+shift+c (assume plain us ASCII
layout). XKB will tell foot *Control+C* was pressed. Note the lack of
the shift modifier, and the upper case 'C'. Internally, this is called
the "translated" form.
The "untranslated" form (*Control+Shift+c*) is derived from the
translated form, and is what foot tries to match first.
If no "untranslated" key bindings can be found, foot proceeds to
checking the "translated" variant.
This means you can use either form in your foot configuration, and
that *Control+Shift+c* (and similar) has higher priority than
*Control+C*. Also note that while foot normally detects when the same
combination is assigned to multiple actions, it will not detect
*Control+C* vs. *Control+Shift+c* collisions. Call it a known bug...
Finally, foot tries to match the raw key code. Here, the primary
layout is queried for all key codes that generate a particular XKB
symbol, and the pressed key's code is matched against this. For
example, if you use the layouts *"us,de(neo)"*, the 'r' key generates
the symbol 'c' in the neo layout. I.e. to get a 'c', you press
'r'. The match logic described above will only match 'c' key bindings
(e.g. *Control+Shift+c*). The raw mode however, will match 'r' key
bindings (e.g. *Control+Shift+r*). This is useful for non-latin
layouts, where you would otherwise have to customize all key bindings.
A key combination can only be mapped to *one* action. Let's say you
A key combination can only be mapped to *one* action. Lets say you
want to bind *Control+Shift+R* to *fullscreen*. Since this is the
default shortcut for *search-start*, you first need to unmap the
default binding. This can be done by setting _action=none_;
@ -1302,8 +1100,7 @@ e.g. *search-start=none*.
application. Default: _none_.
*scrollback-up-page*
Scrolls up/back one page in history. Default: _Shift+Page\_Up
Shift+KP\_Page\_Up_.
Scrolls up/back one page in history. Default: _Shift+Page\_Up_.
*scrollback-up-half-page*
Scrolls up/back half of a page in history. Default: _none_.
@ -1313,7 +1110,7 @@ e.g. *search-start=none*.
*scrollback-down-page*
Scroll down/forward one page in history. Default:
_Shift+Page\_Down Shift+KP\_Page\_Down_.
_Shift+Page\_Down_.
*scrollback-down-half-page*
Scroll down/forward half of a page in history. Default: _none_.
@ -1402,41 +1199,14 @@ e.g. *search-start=none*.
*show-urls-copy*
Enter URL mode, where all currently visible URLs are tagged with a
jump label with a key sequence that will place the URL in the
clipboard. If the hint is completed with an uppercase character,
the match will also be pasted. Default: _none_.
*regex-launch*
Enter regex mode. This works exactly the same as URL mode; all
regex matches are tagged with a jump label with a key sequence
that will "launch" to match (and exit regex mode).
The name of the regex section must be specified in the key
binding:
```
[regex:hashes]
regex=([a-fA-F0-9]{7,128})
launch=path-to-script-or-application ${match}
[key-bindings]
regex-launch=[hashes] Control+Shift+q
regex-copy=[hashes] Control+Mod1+Shift+q
```
Default: _none_.
*regex-copy*
Same as *regex-launch*, but the match is placed in the clipboard,
instead of "launched", upon activation. If the hint is completed
with an uppercase character, the match will also be pasted.
Default: _none_.
clipboard. Default: _none_.
*prompt-prev*
Jump to the previous, currently not visible, prompt (requires
shell integration, see *foot*(1)). Default: _Control+Shift+z_.
*prompt-next*
Jump to the next prompt (requires shell integration, see
Jump the next prompt (requires shell integration, see
*foot*(1)). Default: _Control+Shift+x_.
*unicode-input*
@ -1465,25 +1235,6 @@ e.g. *search-start=none*.
Default: _Control+Shift+u_.
*color-theme-switch-dark*, *color-theme-switch-light*, *color-theme-toggle*
Switch between the dark color theme (defined in the *colors-dark*
section), and the light color theme (defined in the *colors-light*
section).
*color-theme-switch-dark* applies the dark color theme regardless
of which color theme is currently active.
*color-theme-switch-light* applies the light color theme
regardless of which color theme is currently active.
*color-theme-toggle* toggles between the primary and alternative
color themes.
Note: you can also send SIGUSR1/SIGUSR2 to the foot process to
change the theme (see *foot*(1) for details.)
Default: _none_
*quit*
Quit foot. Default: _none_.
@ -1501,8 +1252,7 @@ scrollback search mode. The syntax is exactly the same as the regular
*commit*
Exit search mode and copy current selection into the _primary
selection_. Viewport is **not** restored. To copy the selection to
the regular _clipboard_, use *Control+Shift+c*. Default: _Return
KP_Enter_.
the regular _clipboard_, use *Control+Shift+c*. Default: _Return_.
*find-prev*
Search **backwards** in the scrollback history for the next
@ -1550,12 +1300,6 @@ scrollback search mode. The syntax is exactly the same as the regular
Deletes the **word after** the cursor. Default: _Mod1+d
Control+Delete_.
*delete-to-start*
Deletes search input before the cursor. Default: _Ctrl+u_.
*delete-to-end*
Deletes search input after the cursor. Default: _Ctrl+k_.
*extend-char*
Extend current selection to the right, by one character. Default:
_Shift+Right_.
@ -1599,8 +1343,7 @@ scrollback search mode. The syntax is exactly the same as the regular
details. Default: _none_.
*scrollback-up-page*
Scrolls up/back one page in history. Default: _Shift+Page\_Up
Shift+KP\_Page\_Up_.
Scrolls up/back one page in history. Default: _Shift+Page\_Up_.
*scrollback-up-half-page*
Scrolls up/back half of a page in history. Default: _none_.
@ -1610,7 +1353,7 @@ scrollback search mode. The syntax is exactly the same as the regular
*scrollback-down-page*
Scroll down/forward one page in history. Default:
_Shift+Page\_Down Shift+KP\_Page\_Down_.
_Shift+Page\_Down_.
*scrollback-down-half-page*
Scroll down/forward half of a page in history. Default: _none_.
@ -1703,7 +1446,7 @@ events never generate a *COUNT* larger than 1. That is,
Foot also recognizes tiltable wheels; to map these, use
*BTN_WHEEL_LEFT* and *BTN_WHEEL_RIGHT*.
A modifier+button combination can only be mapped to *one* action. Let's
A modifier+button combination can only be mapped to *one* action. Lets
say you want to bind *BTN\_MIDDLE* to *fullscreen*. Since
*BTN\_MIDDLE* is the default binding for *primary-paste*, you first
need to unmap the default binding. This can be done by setting
@ -1836,8 +1579,9 @@ any of these options.
*scaling-filter*
Overrides the default scaling filter used when down-scaling bitmap
fonts (e.g. emoji fonts). Possible values are *none*, *nearest*,
*bilinear*, *impulse*, *box*, *linear*, *cubic*, *gaussian*,
*lanczos2*, *lanczos3* or *lanczos3-stretched*.
*bilinear*, *cubic* or *lanczos3*. *cubic* and *lanczos3* produce
the best results, but are slower (with *lanczos3* being the best
_and_ slowest).
Default: _lanczos3_.
@ -1905,8 +1649,8 @@ any of these options.
must be patched to use it.
Until this has happened, foot offers an interim workaround; an
attempt to mitigate the screen flicker *without* affecting either
performance or latency.
attempt to mitigate the screen flicker *without* affecting neither
performance nor latency.
It is based on the fact that the screen is updated at a fixed
interval (typically 60Hz). For us, this means it does not matter
@ -2056,103 +1800,15 @@ any of these options.
Default: _512_. Maximum allowed: _2048_ (2GB).
*min-stride-alignment*
This option controls the minimum stride alignment, in bytes, when
allocating SHM buffers.
In some circumstances, a compositor can import foot's SHM buffers
directly to the GPU, without copying the buffer to GPU memory
(typically on integrated graphics). Different drivers have
different requirements for this, and one of those requirements is
typically the stride alignment. At the time of writing, AMD GPUs
require 256-byte alignment.
Note that doing a direct import typically disables immediate
buffer release (if the compositor supports that), which means foot
has to double buffer. This adds a performance penalty in foot, but
the overall system performance should still be better.
If you are not using integrated graphics, or if the compositor
does not support GPU direct imports, this option has close to zero
impact. You can save a small amount of memory by setting this to
0.
Ultimately, it is up to the compositor to decide whether to do
immediate buffer releases, or try to optimize GPU imports.
Default: _256_
*sixel*
Boolean. When enabled, foot will process sixel images. Default:
_yes_
*dim-amount*
Amount by which dimmed text is darkened. Default: _1.5_.
*bold-text-in-bright-amount*
Amount by which bold fonts are brightened when
*bold-text-in-bright* is set to *yes* (the *palette-based* variant
is not affected by this option). Default: _1.3_.
*surface-bit-depth*
Selects which RGB bit depth to use for image buffers. One of
*auto*, *8-bit*, *10-bit* or *16-bit*.
*auto* chooses bit depth depending on other settings, and
availability.
*8-bit*, uses 8 bits for each color channel, alpha included. This
is the default when *gamma-correct-blending=no*.
*10-bit* uses 10 bits for each RGB channel, and 2 bits for the
alpha channel. Thus, it provides higher precision color channels,
but a lower precision alpha channel.
*16-bit* 16 bits for each color channel, alpha included. If
available, this is the default when *gamma-correct-blending=yes*.
Note that both *10-bit* and *16-bit* are much slower than *8-bit*;
if you want to use gamma-correct blending, and if you prefer speed
(throughput and input latency) over accurate colors, you can set
*surface-bit-depth=8-bit* explicitly.
Default: _auto_
*pre-apply-damage*
Boolean. When enabled, foot will attempt to "pre-apply" the damage
from the last frame when foot is forced to double-buffer
(i.e. when the compositor does not release SHM buffers
immediately). All text after this assumes the compositor is not
releasing buffers immediately.
When this option is disabled, each time foot needs to render a
frame, it has to first copy over areas that changed in the last
frame (i.e. all changes between the last two frames). This is
basically a *memcpy*(3), which can be slow if the changed area is
large. It is also done on the main thread, which means foot cannot
do anything else at the same time; no other rendering, no VT
parsing. After the changes have been brought over to the new
frame, foot proceeds with rendering the cells that has changed
between the last frame and the new frame.
When this option is enabled, the changes between the last two frames
are brought over to what will become the next frame before foot
starts rendering the next frame. As soon as the compositor
releases the previous buffer (typically right after foot has
pushed a new frame), foot kicks off a thread that copies over the
changes to the newly released buffer. Since this is done in a
thread, foot can continue processing input at the same
time. Later, when it is time to render a new frame, the changes
have already been transferred, and foot can immediately start with
the actual rendering.
Thus, having this option enabled improves both performance
(copying the last two frames' changes is threaded), and improves
input latency (rendering the next frame no longer has to first bring
over the changes between the last two frames).
Default: _yes_
# SEE ALSO
*foot*(1), *footclient*(1)

View file

@ -33,11 +33,6 @@ terminal has terminated.
Value to set the *app-id* property on the Wayland window
to. Default: _foot_ (normal mode), or _footclient_ (server mode).
*toplevel-tag*=_TAG_
Value to set the *toplevel-tag* property on the Wayland window
to. The compositor can use this value for session management,
window rules etc. Default: _not set_
*-w*,*--window-size-pixels*=_WIDTHxHEIGHT_
Set initial window width and height, in pixels. Default: _700x500_.
@ -194,21 +189,6 @@ variables may be defined in *foot.ini*(5).
In addition to the variables listed above, custom environment
variables to unset may be defined in *foot.ini*(5).
# Signals
The following signals have special meaning in footclient:
- SIGUSR1: switch to the dark color theme (*[colors-dark]*).
- SIGUSR2: switch to the light color theme (*[colors-light]*).
When sending SIGUSR1/SIGUSR2 to a footclient instance, the theme is
changed in that instance only. This is different from when you send
SIGUSR1/SIGUSR2 to the server process, where all instances change the
theme.
Note: for obvious reasons, this is not supported when footclient is
started with *--no-wait*.
# SEE ALSO
*foot*(1)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 KiB

BIN
doc/sixel-wow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 KiB

View file

@ -256,8 +256,8 @@ extract_one(const struct terminal *term, const struct row *row,
}
}
if (next_tab_stop > col)
ctx->tab_spaces_left = next_tab_stop - col - 1;
xassert(next_tab_stop >= col);
ctx->tab_spaces_left = next_tab_stop - col;
}
}

30
fdm.c
View file

@ -18,18 +18,6 @@
#include "debug.h"
#include "xmalloc.h"
#if !defined(SIGABBREV_NP)
#include <stdio.h>
static const char *
sigabbrev_np(int sig)
{
static char buf[16];
snprintf(buf, sizeof(buf), "<%d>", sig);
return buf;
}
#endif
struct fd_handler {
int fd;
int events;
@ -125,8 +113,7 @@ fdm_destroy(struct fdm *fdm)
for (int i = 0; i < SIGRTMAX; i++) {
if (fdm->signal_handlers[i].callback != NULL)
LOG_WARN("handler for signal %d (SIG%s) not removed",
i, sigabbrev_np(i));
LOG_WARN("handler for signal %d not removed", i);
}
if (tll_length(fdm->hooks_low) > 0 ||
@ -351,8 +338,7 @@ bool
fdm_signal_add(struct fdm *fdm, int signo, fdm_signal_handler_t handler, void *data)
{
if (fdm->signal_handlers[signo].callback != NULL) {
LOG_ERR("signal %d (SIG%s) already has a handler",
signo, sigabbrev_np(signo));
LOG_ERR("signal %d already has a handler", signo);
return false;
}
@ -361,16 +347,14 @@ fdm_signal_add(struct fdm *fdm, int signo, fdm_signal_handler_t handler, void *d
sigaddset(&mask, signo);
if (sigprocmask(SIG_BLOCK, &mask, &original) < 0) {
LOG_ERRNO("failed to block signal %d (SIG%s)",
signo, sigabbrev_np(signo));
LOG_ERRNO("failed to block signal %d", signo);
return false;
}
struct sigaction action = {.sa_handler = &signal_handler};
sigemptyset(&action.sa_mask);
if (sigaction(signo, &action, NULL) < 0) {
LOG_ERRNO("failed to set signal handler for signal %d (SIG%s)",
signo, sigabbrev_np(signo));
LOG_ERRNO("failed to set signal handler for signal %d", signo);
sigprocmask(SIG_SETMASK, &original, NULL);
return false;
}
@ -390,8 +374,7 @@ fdm_signal_del(struct fdm *fdm, int signo)
struct sigaction action = {.sa_handler = SIG_DFL};
sigemptyset(&action.sa_mask);
if (sigaction(signo, &action, NULL) < 0) {
LOG_ERRNO("failed to restore signal handler for signal %d (SIG%s)",
signo, sigabbrev_np(signo));
LOG_ERRNO("failed to restore signal handler for signal %d", signo);
return false;
}
@ -403,8 +386,7 @@ fdm_signal_del(struct fdm *fdm, int signo)
sigemptyset(&mask);
sigaddset(&mask, signo);
if (sigprocmask(SIG_UNBLOCK, &mask, NULL) < 0) {
LOG_ERRNO("failed to unblock signal %d (SIG%s)",
signo, sigabbrev_np(signo));
LOG_ERRNO("failed to unblock signal %d", signo);
return false;
}

View file

@ -1,42 +0,0 @@
#include "foot-features.h"
#include "version.h"
const char version_and_features[] =
"version: " FOOT_VERSION
#if defined(FOOT_PGO_ENABLED) && FOOT_PGO_ENABLED
" +pgo"
#else
" -pgo"
#endif
#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED
" +ime"
#else
" -ime"
#endif
#if defined(FOOT_GRAPHEME_CLUSTERING) && FOOT_GRAPHEME_CLUSTERING
" +graphemes"
#else
" -graphemes"
#endif
#if defined(HAVE_XDG_TOPLEVEL_TAG)
" +toplevel-tag"
#else
" -toplevel-tag"
#endif
#if defined(HAVE_EXT_BACKGROUND_EFFECT)
" +blur"
#else
" -blur"
#endif
#if !defined(NDEBUG)
" +assertions"
#else
" -assertions"
#endif
;

View file

@ -1,13 +1,48 @@
#pragma once
#include <stdio.h>
#include <stdbool.h>
extern const char version_and_features[];
static inline void
print_version_and_features(const char *prefix)
static inline bool feature_assertions(void)
{
fputs(prefix, stdout);
fputs(version_and_features, stdout);
fputc('\n', stdout);
#if defined(NDEBUG)
return false;
#else
return true;
#endif
}
static inline bool feature_ime(void)
{
#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED
return true;
#else
return false;
#endif
}
static inline bool feature_pgo(void)
{
#if defined(FOOT_PGO_ENABLED) && FOOT_PGO_ENABLED
return true;
#else
return false;
#endif
}
static inline bool feature_graphemes(void)
{
#if defined(FOOT_GRAPHEME_CLUSTERING) && FOOT_GRAPHEME_CLUSTERING
return true;
#else
return false;
#endif
}
static inline bool feature_xdg_toplevel_icon(void)
{
#if defined(HAVE_XDG_TOPLEVEL_ICON)
return true;
#else
return false;
#endif
}

View file

@ -22,13 +22,11 @@
# strikeout-thickness=<font strikeout thickness>
# box-drawings-uses-font-glyphs=no
# dpi-aware=no
# gamma-correct-blending=no
# initial-color-theme=dark
# initial-window-size-pixels=700x500 # Or,
# initial-window-size-chars=<COLSxROWS>
# initial-window-mode=windowed
# pad=0x0 center-when-maximized-and-fullscreen
# pad=0x0 # optionally append 'center'
# resize-by-cells=yes
# resize-keep-grid=yes
# resize-delay-ms=100
@ -40,8 +38,6 @@
# utmp-helper=/usr/lib/utempter/utempter # When utmp backend is libutempter (Linux)
# utmp-helper=/usr/libexec/ulog-helper # When utmp backend is ulog (FreeBSD)
# uppercase-regex-insert=yes
[environment]
# name=value
@ -49,7 +45,6 @@
# osc52=enabled # disabled|copy-enabled|paste-enabled|enabled
[bell]
# system=yes
# urgent=no
# notify=no
# visual=no
@ -73,22 +68,12 @@
# launch=xdg-open ${url}
# label-letters=sadfjklewcmpgh
# osc8-underline=url-mode
# regex=(((https?://|mailto:|ftp://|file:|ssh:|ssh://|git://|tel:|magnet:|ipfs://|ipns://|gemini://|gopher://|news:)|www\.)([0-9a-zA-Z:/?#@!$&*+,;=.~_%^\-]+|\([]\["0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]*\)|\[[\(\)"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]*\]|"[]\[\(\)0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]*"|'[]\[\(\)0-9a-zA-Z:/?#@!$&*+,;=.~_%^\-]*')+([0-9a-zA-Z/#@$&*+=~_%^\-]|\([]\["0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]*\)|\[[\(\)"0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]*\]|"[]\[\(\)0-9a-zA-Z:/?#@!$&'*+,;=.~_%^\-]*"|'[]\[\(\)0-9a-zA-Z:/?#@!$&*+,;=.~_%^\-]*'))
# You can define your own regex's, by adding a section called
# 'regex:<ID>' with a 'regex' and 'launch' key. These can then be tied
# to a key-binding. See foot.ini(5) for details
# [regex:your-fancy-name]
# regex=<a POSIX-Extended Regular Expression>
# launch=<path to script or application> ${match}
#
# [key-bindings]
# regex-launch=[your-fancy-name] Control+Shift+q
# regex-copy=[your-fancy-name] Control+Alt+Shift+q
# protocols=http, https, ftp, ftps, file, gemini, gopher
# uri-characters=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.,~:;/?#@!$&%*+="'()[]
[cursor]
# style=block
# color=<inverse foreground/background>
# blink=no
# blink-rate=500
# beam-thickness=1.5
@ -101,16 +86,13 @@
[touch]
# long-press-delay=400
[colors-dark]
[colors]
# alpha=1.0
# alpha-mode=default # Can be `default`, `matching` or `all`
# background=242424
# foreground=ffffff
# flash=7f7f00
# flash-alpha=0.5
# cursor=<inverse foreground/background>
## Normal/regular colors (color palette 0-7)
# regular0=242424 # black
# regular1=f62b5a # red
@ -132,7 +114,6 @@
# bright7=ffffff # bright white
## dimmed colors (see foot.ini(5) man page)
# dim-blend-towards=black
# dim0=<not set>
# ...
# dim7=<not-set>
@ -169,11 +150,6 @@
# search-box-match=<regular0> <regular3> # black-on-yellow
# urls=<regular3>
[colors-light]
# Alternative color theme, see man page foot.ini(5)
# Same builtin defaults as [color], except for:
# dim-blend-towards=white
[csd]
# preferred=server
# size=26
@ -190,10 +166,10 @@
# button-close-color=<regular1>
[key-bindings]
# scrollback-up-page=Shift+Page_Up Shift+KP_Page_Up
# scrollback-up-page=Shift+Page_Up
# scrollback-up-half-page=none
# scrollback-up-line=none
# scrollback-down-page=Shift+Page_Down Shift+KP_Page_Down
# scrollback-down-page=Shift+Page_Down
# scrollback-down-half-page=none
# scrollback-down-line=none
# scrollback-home=none
@ -219,15 +195,12 @@
# prompt-prev=Control+Shift+z
# prompt-next=Control+Shift+x
# unicode-input=Control+Shift+u
# color-theme-switch-1=none
# color-theme-switch-2=none
# color-theme-toggle=none
# noop=none
# quit=none
[search-bindings]
# cancel=Control+g Control+c Escape
# commit=Return KP_Enter
# commit=Return
# find-prev=Control+r
# find-next=Control+s
# cursor-left=Left Control+b
@ -240,8 +213,6 @@
# delete-prev-word=Mod1+BackSpace Control+BackSpace
# delete-next=Delete
# delete-next-word=Mod1+d Control+Delete
# delete-to-start=Control+u
# delete-to-end=Control+k
# extend-char=Shift+Right
# extend-to-word-boundary=Control+w Control+Shift+Right
# extend-to-next-whitespace=Control+Shift+w
@ -253,10 +224,10 @@
# clipboard-paste=Control+v Control+Shift+v Control+y XF86Paste
# primary-paste=Shift+Insert
# unicode-input=none
# scrollback-up-page=Shift+Page_Up Shift+KP_Page_Up
# scrollback-up-page=Shift+Page_Up
# scrollback-up-half-page=none
# scrollback-up-line=none
# scrollback-down-page=Shift+Page_Down Shift+KP_Page_Down
# scrollback-down-page=Shift+Page_Down
# scrollback-down-half-page=none
# scrollback-down-line=none
# scrollback-home=none

381
grid.c
View file

@ -16,10 +16,6 @@
#define TIME_REFLOW 0
#if defined(TIME_REFLOW)
#include "misc.h"
#endif
/*
* "sb" (scrollback relative) coordinates
*
@ -40,8 +36,7 @@ grid_row_abs_to_sb(const struct grid *grid, int screen_rows, int abs_row)
return rebased_row;
}
int
grid_row_sb_to_abs(const struct grid *grid, int screen_rows, int sb_rel_row)
int grid_row_sb_to_abs(const struct grid *grid, int screen_rows, int sb_rel_row)
{
const int scrollback_start = grid->offset + screen_rows;
int abs_row = sb_rel_row + scrollback_start;
@ -439,7 +434,7 @@ grid_row_alloc(int cols, bool initialize)
{
struct row *row = xmalloc(sizeof(*row));
row->dirty = false;
row->linebreak = true;
row->linebreak = false;
row->extra = NULL;
row->shell_integration.prompt_marker = false;
row->shell_integration.cmd_start = -1;
@ -501,6 +496,7 @@ grid_resize_without_reflow(
sizeof(struct cell) * min(old_cols, new_cols));
new_row->dirty = old_row->dirty;
new_row->linebreak = false;
new_row->shell_integration.prompt_marker = old_row->shell_integration.prompt_marker;
new_row->shell_integration.cmd_start = min(old_row->shell_integration.cmd_start, new_cols - 1);
new_row->shell_integration.cmd_end = min(old_row->shell_integration.cmd_end, new_cols - 1);
@ -711,6 +707,7 @@ _line_wrap(struct grid *old_grid, struct row **new_grid, struct row *row,
} else {
/* Scrollback is full, need to reuse a row */
grid_row_reset_extra(new_row);
new_row->linebreak = false;
new_row->shell_integration.prompt_marker = false;
new_row->shell_integration.cmd_start = -1;
new_row->shell_integration.cmd_end = -1;
@ -814,7 +811,7 @@ tp_cmp(const void *_a, const void *_b)
void
grid_resize_and_reflow(
struct grid *grid, const struct terminal *term, int new_rows, int new_cols,
struct grid *grid, int new_rows, int new_cols,
int old_screen_rows, int new_screen_rows,
size_t tracking_points_count,
struct coord *const _tracking_points[static tracking_points_count])
@ -892,8 +889,6 @@ grid_resize_and_reflow(
i, tracking_points[i]->row, tracking_points[i]->col);
}
int coalesced_linebreaks = 0;
/*
* Walk the old grid
*/
@ -935,8 +930,7 @@ grid_resize_and_reflow(
if (!old_row->linebreak && col_count > 0) {
/* Don't truncate logical lines */
while (col_count < old_cols && old_row->cells[col_count].wc == 0)
col_count++;
col_count = old_cols;
}
xassert(col_count >= 0 && col_count <= old_cols);
@ -960,7 +954,7 @@ grid_resize_and_reflow(
/* Does this row have any URIs? */
struct row_range *uri_range, *uri_range_terminator;
struct row_range *underline_range, *underline_range_terminator;
const struct row_data *extra = old_row->extra;
struct row_data *extra = old_row->extra;
if (extra != NULL && extra->uri_ranges.count > 0) {
uri_range = &extra->uri_ranges.v[0];
@ -984,177 +978,213 @@ grid_resize_and_reflow(
} else
underline_range = underline_range_terminator = NULL;
if (unlikely(col_count > 0 && coalesced_linebreaks > 0)) {
for (size_t line_no = 0; line_no < coalesced_linebreaks; line_no++) {
/* Erase the remaining cells */
memset(&new_row->cells[new_col_idx], 0,
(new_cols - new_col_idx) * sizeof(new_row->cells[0]));
new_row->linebreak = true;
line_wrap();
for (int start = 0, left = col_count; left > 0;) {
int end;
bool tp_break = false;
bool uri_break = false;
bool underline_break = false;
bool ftcs_break = false;
/* Figure out where to end this chunk */
{
const int uri_col = uri_range != uri_range_terminator
? ((uri_range->start >= start ? uri_range->start : uri_range->end) + 1)
: INT_MAX;
const int underline_col = underline_range != underline_range_terminator
? ((underline_range->start >= start ? underline_range->start : underline_range->end) + 1)
: INT_MAX;
const int tp_col = tp != NULL ? tp->col + 1 : INT_MAX;
const int ftcs_col = old_row->shell_integration.cmd_start >= start
? old_row->shell_integration.cmd_start + 1
: old_row->shell_integration.cmd_end >= start
? old_row->shell_integration.cmd_end + 1
: INT_MAX;
end = min(col_count, min(min(tp_col, min(uri_col, underline_col)), ftcs_col));
uri_break = end == uri_col;
underline_break = end == underline_col;
tp_break = end == tp_col;
ftcs_break = end == ftcs_col;
}
coalesced_linebreaks = 0;
}
for (int c = 0; c < col_count;) {
const struct cell *old = &old_row->cells[c];
/* Row full, emit newline and get a new, fresh, row */
xassert(new_col_idx <= new_cols);
if (unlikely(new_col_idx >= new_cols))
line_wrap();
char32_t wc = old->wc;
int width = 1;
if (unlikely(wc >= CELL_COMB_CHARS_LO && wc <= CELL_COMB_CHARS_HI)) {
const struct composed *composed =
composed_lookup(term->composed, wc - CELL_COMB_CHARS_LO);
width = composed->forced_width > 0 ? composed->forced_width : composed->width;
} else if (unlikely(c + 1 < col_count && (old + 1)->wc >= CELL_SPACER + 1)) {
/* Wide character, get its width from the next cell's
SPACER value */
width = (old + 1)->wc - CELL_SPACER + 1;
}
int cols = end - start;
xassert(cols > 0);
xassert(start + cols <= old_cols);
/*
* Check if character fits, if not, emit spacers, and push
the character to the next row */
if (unlikely(new_col_idx + width > new_cols && width <= new_cols)) {
for (; new_col_idx < new_cols; new_col_idx++) {
new_row->cells[new_col_idx].wc = CELL_SPACER;
new_row->cells[new_col_idx].attrs = (struct attributes){0};
}
line_wrap();
}
* Copy the row chunk to the new grid. Note that there may
* be fewer cells left on the new row than what we have in
* the chunk. I.e. the chunk may have to be split up into
* multiple memcpy:ies.
*/
new_row->shell_integration.prompt_marker = old_row->shell_integration.prompt_marker;
for (int count = cols, from = start; count > 0;) {
xassert(new_col_idx <= new_cols);
int new_row_cells_left = new_cols - new_col_idx;
for (int i = 0; i < width; i++) {
if (unlikely(uri_range != NULL && uri_range != uri_range_terminator)) {
if (unlikely(uri_range->start == c)) {
reflow_range_start(
uri_range, ROW_RANGE_URI, new_row, new_col_idx);
}
if (unlikely(uri_range->end == c)) {
reflow_range_end(
uri_range, ROW_RANGE_URI, new_row, new_col_idx);
grid_row_uri_range_destroy(uri_range);
uri_range++;
}
/* Row full, emit newline and get a new, fresh, row */
if (new_row_cells_left <= 0) {
line_wrap();
new_row_cells_left = new_cols;
}
if (unlikely(underline_range != NULL && underline_range != underline_range_terminator)) {
if (unlikely(underline_range->start == c)) {
reflow_range_start(
underline_range, ROW_RANGE_UNDERLINE, new_row, new_col_idx);
}
if (unlikely(underline_range->end == c)) {
reflow_range_end(
underline_range, ROW_RANGE_UNDERLINE, new_row, new_col_idx);
grid_row_underline_range_destroy(underline_range);
underline_range++;
}
}
if (unlikely(tp != NULL)) {
if (unlikely(tp->col == c)) {
do {
xassert(tp->row == old_row_idx);
tp->row = new_row_idx;
tp->col = new_col_idx;
next_tp++;
tp = *next_tp;
} while (tp->row == old_row_idx && tp->col == c);
if (tp->row != old_row_idx)
tp = NULL;
LOG_DBG("next TP (tp=%p): %dx%d",
(void*)tp, (*next_tp)->row, (*next_tp)->col);
}
}
if (unlikely(old_row->shell_integration.cmd_start == c))
new_row->shell_integration.cmd_start = new_col_idx;
if (unlikely(old_row->shell_integration.cmd_end == c))
new_row->shell_integration.cmd_end = new_col_idx;
if (unlikely(width > new_cols)) {
/* Wide character no longer fits on a row, replace
it with a single space */
new_row->cells[new_col_idx++].wc = 0;
c++;
/* Walk past the SPACER cells */
for (int i = 1; i < width; i++, c++, old++)
;
/* Continue with next character in the *old* grid */
break;
}
new_row->cells[new_col_idx++] = *old;
/* Number of cells we can copy */
int amount = min(count, new_row_cells_left);
xassert(amount > 0);
/*
* TODO: simulate LCF instead?
*
* Rows have linebreak=true by default. This is needed
* for a number of reasons. However, we want non-empty
* rows to have linebreak=false, *until* we reach the
* end of an old row with linebreak=true, at which
* point we set linebreak=true on the new row.
* If we're going to reach the end of the new row, we
* need to make sure we don't end in the middle of a
* multi-column character.
*/
new_row->linebreak = false;
old++;
c++;
int spacers = 0;
if (new_col_idx + amount >= new_cols) {
/*
* While the cell *after* the last cell is a CELL_SPACER
*
* This means we have a multi-column character
* that doesn't fit on the current row. We need to
* push it to the next row, and insert CELL_SPACER
* cells as padding.
*/
while (
unlikely(
amount > 1 &&
from + amount < old_cols &&
old_row->cells[from + amount].wc >= CELL_SPACER + 1))
{
amount--;
spacers++;
}
xassert(
amount == 1 ||
old_row->cells[from + amount - 1].wc <= CELL_SPACER + 1);
}
xassert(new_col_idx + amount <= new_cols);
xassert(from + amount <= old_cols);
if (from == 0)
new_row->shell_integration.prompt_marker = old_row->shell_integration.prompt_marker;
memcpy(
&new_row->cells[new_col_idx], &old_row->cells[from],
amount * sizeof(struct cell));
count -= amount;
from += amount;
new_col_idx += amount;
xassert(new_col_idx <= new_cols);
if (unlikely(spacers > 0)) {
xassert(new_col_idx + spacers == new_cols);
const struct cell *cell = &old_row->cells[from - 1];
for (int i = 0; i < spacers; i++, new_col_idx++) {
new_row->cells[new_col_idx].wc = CELL_SPACER;
new_row->cells[new_col_idx].attrs = cell->attrs;
}
}
}
xassert(new_col_idx > 0);
if (tp_break) {
do {
xassert(tp != NULL);
xassert(tp->row == old_row_idx);
xassert(tp->col == end - 1);
tp->row = new_row_idx;
tp->col = new_col_idx - 1;
next_tp++;
tp = *next_tp;
} while (tp->row == old_row_idx && tp->col == end - 1);
if (tp->row != old_row_idx)
tp = NULL;
LOG_DBG("next TP (tp=%p): %dx%d",
(void*)tp, (*next_tp)->row, (*next_tp)->col);
}
if (uri_break) {
xassert(uri_range != NULL);
if (uri_range->start == end - 1)
reflow_range_start(
uri_range, ROW_RANGE_URI, new_row, new_col_idx - 1);
if (uri_range->end == end - 1) {
reflow_range_end(
uri_range, ROW_RANGE_URI, new_row, new_col_idx - 1);
grid_row_uri_range_destroy(uri_range);
uri_range++;
}
}
if (underline_break) {
xassert(underline_range != NULL);
if (underline_range->start == end - 1)
reflow_range_start(
underline_range, ROW_RANGE_UNDERLINE, new_row, new_col_idx - 1);
if (underline_range->end == end - 1) {
reflow_range_end(
underline_range, ROW_RANGE_UNDERLINE, new_row, new_col_idx - 1);
grid_row_underline_range_destroy(underline_range);
underline_range++;
}
}
if (ftcs_break) {
xassert(old_row->shell_integration.cmd_start == start + cols - 1 ||
old_row->shell_integration.cmd_end == start + cols - 1);
if (old_row->shell_integration.cmd_start == start + cols - 1)
new_row->shell_integration.cmd_start = new_col_idx - 1;
if (old_row->shell_integration.cmd_end == start + cols - 1)
new_row->shell_integration.cmd_end = new_col_idx - 1;
}
left -= cols;
start += cols;
}
if (old_row->linebreak) {
if (col_count > 0) {
/* Erase the remaining cells */
memset(&new_row->cells[new_col_idx], 0,
(new_cols - new_col_idx) * sizeof(new_row->cells[0]));
new_row->linebreak = true;
/* Erase the remaining cells */
memset(&new_row->cells[new_col_idx], 0,
(new_cols - new_col_idx) * sizeof(new_row->cells[0]));
new_row->linebreak = true;
if (r + 1 < old_rows)
line_wrap();
else if (new_row->extra != NULL) {
if (new_row->extra->uri_ranges.count > 0) {
/*
* line_wrap() "closes" still-open URIs. Since
* this is the *last* row, and since we're
* line-breaking due to a hard line-break (rather
* than running out of cells in the "new_row"),
* there shouldn't be an open URI (it would have
* been closed when we reached the end of the URI
* while reflowing the last "old" row).
*/
int last_idx = new_row->extra->uri_ranges.count - 1;
xassert(new_row->extra->uri_ranges.v[last_idx].end >= 0);
}
if (new_row->extra->underline_ranges.count > 0) {
int last_idx = new_row->extra->underline_ranges.count - 1;
xassert(new_row->extra->underline_ranges.v[last_idx].end >= 0);
if (r + 1 < old_rows) {
/* Not the last (old) row */
line_wrap();
} else if (new_row->extra != NULL) {
if (new_row->extra->uri_ranges.count > 0) {
/*
* line_wrap() "closes" still-open URIs. Since
* this is the *last* row, and since we're
* line-breaking due to a hard line-break (rather
* than running out of cells in the "new_row"),
* there shouldn't be an open URI (it would have
* been closed when we reached the end of the URI
* while reflowing the last "old" row).
*/
int last_idx = new_row->extra->uri_ranges.count - 1;
xassert(new_row->extra->uri_ranges.v[last_idx].end >= 0);
}
if (new_row->extra->underline_ranges.count > 0) {
int last_idx = new_row->extra->underline_ranges.count - 1;
xassert(new_row->extra->underline_ranges.v[last_idx].end >= 0);
}
}
} else {
/*
* rows have linebreak=true by default. But we don't
* want trailing empty lines to result in actual lines
* in the new grid (think: empty window with prompt at
* the top)
*/
coalesced_linebreaks++;
}
}
@ -1244,26 +1274,15 @@ grid_resize_and_reflow(
saved_cursor.row = min(saved_cursor.row, new_screen_rows - 1);
saved_cursor.col = min(saved_cursor.col, new_cols - 1);
if (grid->cursor.lcf) {
if (cursor.col + 1 < new_cols) {
cursor.col++;
grid->cursor.lcf = false;
}
}
if (grid->saved_cursor.lcf) {
if (saved_cursor.col + 1 < new_cols) {
saved_cursor.col++;
grid->saved_cursor.lcf = false;
}
}
grid->cur_row = new_grid[(grid->offset + cursor.row) & (new_rows - 1)];
xassert(grid->cur_row != NULL);
grid->cursor.point = cursor;
grid->saved_cursor.point = saved_cursor;
grid->cursor.lcf = false;
grid->saved_cursor.lcf = false;
/* Free sixels we failed to "map" to the new grid */
tll_foreach(untranslated_sixels, it)
sixel_destroy(&it->item);

2
grid.h
View file

@ -16,7 +16,7 @@ void grid_resize_without_reflow(
int old_screen_rows, int new_screen_rows);
void grid_resize_and_reflow(
struct grid *grid, const struct terminal *term, int new_rows, int new_cols,
struct grid *grid, int new_rows, int new_cols,
int old_screen_rows, int new_screen_rows,
size_t tracking_points_count,
struct coord *const _tracking_points[static tracking_points_count]);

35
hsl.c
View file

@ -2,6 +2,41 @@
#include <math.h>
#include "util.h"
void
rgb_to_hsl(uint32_t rgb, int *hue, int *sat, int *lum)
{
double r = (double)((rgb >> 16) & 0xff) / 255.;
double g = (double)((rgb >> 8) & 0xff) / 255.;
double b = (double)((rgb >> 0) & 0xff) / 255.;
double x_max = max(max(r, g), b);
double x_min = min(min(r, g), b);
double V = x_max;
double C = x_max - x_min;
double L = (x_max + x_min) / 2.;
*lum = 100 * L;
if (C == 0.0)
*hue = 0;
else if (V == r)
*hue = 60. * (0. + (g - b) / C);
else if (V == g)
*hue = 60. * (2. + (b - r) / C);
else if (V == b)
*hue = 60. * (4. + (r - g) / C);
if (*hue < 0)
*hue += 360;
double S = C == 0.0
? 0
: C / (1. - fabs(2. * L - 1.));
*sat = 100 * S;
}
uint32_t
hsl_to_rgb(int hue, int sat, int lum)
{

1
hsl.h
View file

@ -2,4 +2,5 @@
#include <stdint.h>
void rgb_to_hsl(uint32_t rgb, int *hue, int *sat, int *lum);
uint32_t hsl_to_rgb(int hue, int sat, int lum);

10
ime.c
View file

@ -68,16 +68,6 @@ enter(void *data, struct zwp_text_input_v3 *zwp_text_input_v3,
/* The main grid is the *only* input-receiving surface we have */
seat->ime_focus = term;
const struct coord *cursor = &term->grid->cursor.point;
term_ime_set_cursor_rect(
term,
term->margins.left + cursor->col * term->cell_width,
term->margins.top + cursor->row * term->cell_height,
term->cell_width,
term->cell_height);
ime_enable(seat);
}

826
input.c

File diff suppressed because it is too large Load diff

View file

@ -11,24 +11,14 @@
#include "terminal.h"
#include "util.h"
#include "wayland.h"
#include "xkbcommon-vmod.h"
#include "xmalloc.h"
struct vmod_map {
const char *name;
xkb_mod_mask_t virtual_mask;
xkb_mod_mask_t real_mask;
};
struct key_set {
struct key_binding_set public;
const struct config *conf;
const struct seat *seat;
size_t conf_ref_count;
/* Virtual to real modifier mappings */
struct vmod_map vmods[8];
};
typedef tll(struct key_set) bind_set_list_t;
@ -54,50 +44,6 @@ key_binding_manager_destroy(struct key_binding_manager *mgr)
free(mgr);
}
static void
initialize_vmod_mappings(struct key_set *set)
{
if (set->seat == NULL || set->seat->kbd.xkb_keymap == NULL)
return;
set->vmods[0].name = XKB_VMOD_NAME_ALT;
set->vmods[1].name = XKB_VMOD_NAME_HYPER;
set->vmods[2].name = XKB_VMOD_NAME_LEVEL3;
set->vmods[3].name = XKB_VMOD_NAME_LEVEL5;
set->vmods[4].name = XKB_VMOD_NAME_META;
set->vmods[5].name = XKB_VMOD_NAME_NUM;
set->vmods[6].name = XKB_VMOD_NAME_SCROLL;
set->vmods[7].name = XKB_VMOD_NAME_SUPER;
struct xkb_state *scratch_state = xkb_state_new(set->seat->kbd.xkb_keymap);
xassert(scratch_state != NULL);
for (size_t i = 0; i < ALEN(set->vmods); i++) {
xkb_mod_index_t virt_idx = xkb_keymap_mod_get_index(
set->seat->kbd.xkb_keymap, set->vmods[i].name);
if (virt_idx != XKB_MOD_INVALID) {
xkb_mod_mask_t vmask = 1 << virt_idx;
xkb_state_update_mask(scratch_state, vmask, 0, 0, 0, 0, 0);
set->vmods[i].real_mask = xkb_state_serialize_mods(
scratch_state, XKB_STATE_MODS_DEPRESSED) & ~vmask;
set->vmods[i].virtual_mask = vmask;
LOG_DBG("%s: 0x%04x -> 0x%04x",
set->vmods[i].name,
set->vmods[i].virtual_mask,
set->vmods[i].real_mask);
} else {
set->vmods[i].virtual_mask = 0;
set->vmods[i].real_mask = 0;
LOG_DBG("%s: virtual modifier not available", set->vmods[i].name);
}
}
xkb_state_unref(scratch_state);
}
void
key_binding_new_for_seat(struct key_binding_manager *mgr,
const struct seat *seat)
@ -121,7 +67,6 @@ key_binding_new_for_seat(struct key_binding_manager *mgr,
};
tll_push_back(mgr->binding_sets, set);
initialize_vmod_mappings(&tll_back(mgr->binding_sets));
LOG_DBG("new (seat): set=%p, seat=%p, conf=%p, ref-count=1",
(void *)&tll_back(mgr->binding_sets),
@ -162,7 +107,6 @@ key_binding_new_for_conf(struct key_binding_manager *mgr,
};
tll_push_back(mgr->binding_sets, set);
initialize_vmod_mappings(&tll_back(mgr->binding_sets));
load_keymap(&tll_back(mgr->binding_sets));
@ -461,35 +405,18 @@ sort_binding_list(key_binding_list_t *list)
}
static xkb_mod_mask_t
mods_to_mask(const struct seat *seat,
const struct vmod_map *vmods, size_t vmod_count,
const config_modifier_list_t *mods)
mods_to_mask(const struct seat *seat, const config_modifier_list_t *mods)
{
xkb_mod_mask_t mask = 0;
tll_foreach(*mods, it) {
const xkb_mod_index_t idx = xkb_keymap_mod_get_index(seat->kbd.xkb_keymap, it->item);
xkb_mod_index_t idx = xkb_keymap_mod_get_index(seat->kbd.xkb_keymap, it->item);
if (idx == XKB_MOD_INVALID) {
LOG_ERR("%s: invalid modifier name", it->item);
continue;
}
xkb_mod_mask_t mod = 1 << idx;
/* Check if this is a virtual modifier, and if so, use the
real modifier it maps to instead */
for (size_t i = 0; i < vmod_count; i++) {
if (vmods[i].virtual_mask == mod) {
mask |= vmods[i].real_mask;
mod = 0;
LOG_DBG("%s: virtual modifier, mapped to 0x%04x",
it->item, vmods[i].real_mask);
break;
}
}
mask |= mod;
mask |= 1 << idx;
}
return mask;
@ -502,8 +429,7 @@ convert_key_binding(struct key_set *set,
{
const struct seat *seat = set->seat;
xkb_mod_mask_t mods = mods_to_mask(
seat, set->vmods, ALEN(set->vmods), &conf_binding->modifiers);
xkb_mod_mask_t mods = mods_to_mask(seat, &conf_binding->modifiers);
xkb_keysym_t sym = maybe_repair_key_combo(seat, conf_binding->k.sym, mods);
struct key_binding binding = {
@ -561,7 +487,7 @@ convert_mouse_binding(struct key_set *set,
.type = MOUSE_BINDING,
.action = conf_binding->action,
.aux = &conf_binding->aux,
.mods = mods_to_mask(set->seat, set->vmods, ALEN(set->vmods), &conf_binding->modifiers),
.mods = mods_to_mask(set->seat, &conf_binding->modifiers),
.m = {
.button = conf_binding->m.button,
.count = conf_binding->m.count,
@ -602,8 +528,7 @@ load_keymap(struct key_set *set)
convert_mouse_bindings(set);
set->public.selection_overrides = mods_to_mask(
set->seat, set->vmods, ALEN(set->vmods),
&set->conf->mouse.selection_override_modifiers);
set->seat, &set->conf->mouse.selection_override_modifiers);
}
void
@ -613,10 +538,8 @@ key_binding_load_keymap(struct key_binding_manager *mgr,
tll_foreach(mgr->binding_sets, it) {
struct key_set *set = &it->item;
if (set->seat == seat) {
initialize_vmod_mappings(set);
if (set->seat == seat)
load_keymap(set);
}
}
}

View file

@ -41,13 +41,6 @@ enum bind_action_normal {
BIND_ACTION_PROMPT_NEXT,
BIND_ACTION_UNICODE_INPUT,
BIND_ACTION_QUIT,
BIND_ACTION_REGEX_LAUNCH,
BIND_ACTION_REGEX_COPY,
BIND_ACTION_THEME_SWITCH_1,
BIND_ACTION_THEME_SWITCH_2,
BIND_ACTION_THEME_SWITCH_DARK,
BIND_ACTION_THEME_SWITCH_LIGHT,
BIND_ACTION_THEME_TOGGLE,
/* Mouse specific actions - i.e. they require a mouse coordinate */
BIND_ACTION_SCROLLBACK_UP_MOUSE,
@ -61,7 +54,7 @@ enum bind_action_normal {
BIND_ACTION_SELECT_QUOTE,
BIND_ACTION_SELECT_ROW,
BIND_ACTION_KEY_COUNT = BIND_ACTION_THEME_TOGGLE + 1,
BIND_ACTION_KEY_COUNT = BIND_ACTION_QUIT + 1,
BIND_ACTION_COUNT = BIND_ACTION_SELECT_ROW + 1,
};
@ -89,8 +82,6 @@ enum bind_action_search {
BIND_ACTION_SEARCH_DELETE_PREV_WORD,
BIND_ACTION_SEARCH_DELETE_NEXT,
BIND_ACTION_SEARCH_DELETE_NEXT_WORD,
BIND_ACTION_SEARCH_DELETE_TO_START,
BIND_ACTION_SEARCH_DELETE_TO_END,
BIND_ACTION_SEARCH_EXTEND_CHAR,
BIND_ACTION_SEARCH_EXTEND_WORD,
BIND_ACTION_SEARCH_EXTEND_WORD_WS,

65
main.c
View file

@ -31,6 +31,7 @@
#include "shm.h"
#include "terminal.h"
#include "util.h"
#include "version.h"
#include "xmalloc.h"
#include "xsnprintf.h"
@ -45,31 +46,19 @@ fdm_sigint(struct fdm *fdm, int signo, void *data)
return true;
}
struct sigusr_context {
struct terminal *term;
struct server *server;
};
static bool
fdm_sigusr(struct fdm *fdm, int signo, void *data)
static const char *
version_and_features(void)
{
xassert(signo == SIGUSR1 || signo == SIGUSR2);
struct sigusr_context *ctx = data;
if (ctx->server != NULL) {
if (signo == SIGUSR1)
server_global_theme_switch_to_dark(ctx->server);
else
server_global_theme_switch_to_light(ctx->server);
} else {
if (signo == SIGUSR1)
term_theme_switch_to_dark(ctx->term);
else
term_theme_switch_to_light(ctx->term);
}
return true;
static char buf[256];
snprintf(buf, sizeof(buf),
"version: %s %cpgo %cime %cgraphemes %ctoplevel-icon %cassertions",
FOOT_VERSION,
feature_pgo() ? '+' : '-',
feature_ime() ? '+' : '-',
feature_graphemes() ? '+' : '-',
feature_xdg_toplevel_icon() ? '+' : '-',
feature_assertions() ? '+' : '-');
return buf;
}
static void
@ -84,7 +73,6 @@ print_usage(const char *prog_name)
" -t,--term=TERM value to set the environment variable TERM to (" FOOT_DEFAULT_TERM ")\n"
" -T,--title=TITLE initial window title (foot)\n"
" -a,--app-id=ID window application ID (foot)\n"
" --toplevel-tag=TAG set a custom toplevel tag\n"
" -m,--maximized start in maximized mode\n"
" -F,--fullscreen start in fullscreen mode\n"
" -L,--login-shell start shell as a login shell\n"
@ -186,7 +174,6 @@ sanitize_signals(void)
enum {
PTY_OPTION = CHAR_MAX + 1,
TOPLEVEL_TAG_OPTION = CHAR_MAX + 2,
};
int
@ -216,7 +203,6 @@ main(int argc, char *const *argv)
{"term", required_argument, NULL, 't'},
{"title", required_argument, NULL, 'T'},
{"app-id", required_argument, NULL, 'a'},
{"toplevel-tag", required_argument, NULL, TOPLEVEL_TAG_OPTION},
{"login-shell", no_argument, NULL, 'L'},
{"working-directory", required_argument, NULL, 'D'},
{"font", required_argument, NULL, 'f'},
@ -288,10 +274,6 @@ main(int argc, char *const *argv)
tll_push_back(overrides, xstrjoin("app-id=", optarg));
break;
case TOPLEVEL_TAG_OPTION:
tll_push_back(overrides, xstrjoin("toplevel-tag=", optarg));
break;
case 'D': {
struct stat st;
if (stat(optarg, &st) < 0 || !(st.st_mode & S_IFDIR)) {
@ -396,7 +378,7 @@ main(int argc, char *const *argv)
break;
case 'v':
print_version_and_features("foot ");
printf("foot %s\n", version_and_features());
return EXIT_SUCCESS;
case 'h':
@ -424,7 +406,7 @@ main(int argc, char *const *argv)
argv += optind;
}
LOG_INFO("%s", version_and_features);
LOG_INFO("%s", version_and_features());
{
struct utsname name;
@ -534,6 +516,7 @@ main(int argc, char *const *argv)
(enum fcft_log_colorize)log_colorize,
as_server && log_syslog,
(enum fcft_log_class)log_level);
fcft_set_scaling_filter(conf.tweak.fcft_filter);
if (conf_server_socket_path != NULL) {
free(conf.server_socket_path);
@ -568,10 +551,10 @@ main(int argc, char *const *argv)
char *_cwd = NULL;
if (cwd == NULL) {
errno = 0;
size_t buf_len = 1024;
do {
_cwd = xrealloc(_cwd, buf_len);
errno = 0;
if (getcwd(_cwd, buf_len) == NULL && errno != ERANGE) {
LOG_ERRNO("failed to get current working directory");
goto out;
@ -604,7 +587,6 @@ main(int argc, char *const *argv)
}
shm_set_max_pool_size(conf.tweak.max_shm_pool_size);
shm_set_min_stride_alignment(conf.tweak.min_stride_alignment);
if ((fdm = fdm_init()) == NULL)
goto out;
@ -643,17 +625,6 @@ main(int argc, char *const *argv)
goto out;
}
struct sigusr_context sigusr_context = {
.term = term,
.server = server,
};
if (!fdm_signal_add(fdm, SIGUSR1, &fdm_sigusr, &sigusr_context) ||
!fdm_signal_add(fdm, SIGUSR2, &fdm_sigusr, &sigusr_context))
{
goto out;
}
struct sigaction sig_ign = {.sa_handler = SIG_IGN};
sigemptyset(&sig_ign.sa_mask);
if (sigaction(SIGHUP, &sig_ign, NULL) < 0 ||
@ -689,8 +660,6 @@ out:
wayl_destroy(wayl);
key_binding_manager_destroy(key_binding_manager);
reaper_destroy(reaper);
fdm_signal_del(fdm, SIGUSR1);
fdm_signal_del(fdm, SIGUSR2);
fdm_signal_del(fdm, SIGTERM);
fdm_signal_del(fdm, SIGINT);
fdm_destroy(fdm);

View file

@ -1,5 +1,5 @@
project('foot', 'c',
version: '1.26.1',
version: '1.20.2',
license: 'MIT',
meson_version: '>=0.59.0',
default_options: [
@ -12,11 +12,6 @@ is_debug_build = get_option('buildtype').startswith('debug')
cc = meson.get_compiler('c')
# Newer clang versions warns when using __COUNTER__ without -std=c2y
if cc.has_argument('-Wc2y-extensions')
add_project_arguments('-Wno-c2y-extensions', language: 'c')
endif
if cc.has_function('memfd_create',
args: ['-D_GNU_SOURCE'],
prefix: '#include <sys/mman.h>')
@ -30,12 +25,6 @@ if cc.has_function('execvpe',
add_project_arguments('-DEXECVPE', language: 'c')
endif
if cc.has_function('sigabbrev_np',
args: ['-D_GNU_SOURCE'],
prefix: '#include <string.h>')
add_project_arguments('-DSIGABBREV_NP', language: 'c')
endif
utmp_backend = get_option('utmp-backend')
if utmp_backend == 'auto'
host_os = host_machine.system()
@ -58,7 +47,7 @@ if utmp_backend == 'none'
elif utmp_backend == 'libutempter'
utmp_add = 'add'
utmp_del = 'del'
utmp_del_have_argument = false
utmp_del_have_argument = true
if utmp_default_helper_path == 'auto'
utmp_default_helper_path = join_paths('/usr', get_option('libdir'), 'utempter', 'utempter')
endif
@ -143,7 +132,7 @@ math = cc.find_library('m')
threads = [dependency('threads'), cc.find_library('stdthreads', required: false)]
libepoll = dependency('epoll-shim', required: false)
pixman = dependency('pixman-1')
wayland_protocols = dependency('wayland-protocols', version: '>=1.41',
wayland_protocols = dependency('wayland-protocols', version: '>=1.32',
fallback: 'wayland-protocols',
default_options: ['tests=false'])
wayland_client = dependency('wayland-client')
@ -156,12 +145,8 @@ if utf8proc.found()
add_project_arguments('-DFOOT_GRAPHEME_CLUSTERING=1', language: 'c')
endif
if pixman.version().version_compare('>=0.46.0')
add_project_arguments('-DHAVE_PIXMAN_RGBA_16', language: 'c')
endif
tllist = dependency('tllist', version: '>=1.1.0', fallback: 'tllist')
fcft = dependency('fcft', version: ['>=3.3.1', '<4.0.0'], fallback: 'fcft')
fcft = dependency('fcft', version: ['>=3.0.1', '<4.0.0'], fallback: 'fcft')
wayland_protocols_datadir = wayland_protocols.get_variable('pkgdatadir')
@ -184,18 +169,14 @@ wl_proto_xml = [
wayland_protocols_datadir / 'unstable/tablet/tablet-unstable-v2.xml', # required by cursor-shape-v1
wayland_protocols_datadir / 'staging/cursor-shape/cursor-shape-v1.xml',
wayland_protocols_datadir / 'staging/single-pixel-buffer/single-pixel-buffer-v1.xml',
wayland_protocols_datadir / 'staging/xdg-toplevel-icon/xdg-toplevel-icon-v1.xml',
wayland_protocols_datadir / 'staging/xdg-system-bell/xdg-system-bell-v1.xml',
wayland_protocols_datadir / 'staging/color-management/color-management-v1.xml',
]
]
if (wayland_protocols.version().version_compare('>=1.43'))
wl_proto_xml += [wayland_protocols_datadir / 'staging/xdg-toplevel-tag/xdg-toplevel-tag-v1.xml']
add_project_arguments('-DHAVE_XDG_TOPLEVEL_TAG=1', language: 'c')
endif
if (wayland_protocols.version().version_compare('>=1.45'))
wl_proto_xml += [wayland_protocols_datadir / 'staging/ext-background-effect/ext-background-effect-v1.xml']
add_project_arguments('-DHAVE_EXT_BACKGROUND_EFFECT=1', language: 'c')
if wayland_protocols.version().version_compare('>=1.37')
add_project_arguments('-DHAVE_XDG_TOPLEVEL_ICON', language: 'c')
wl_proto_xml += [wayland_protocols_datadir / 'staging/xdg-toplevel-icon/xdg-toplevel-icon-v1.xml']
xdg_toplevel_icon = true
else
xdg_toplevel_icon = false
endif
foreach prot : wl_proto_xml
@ -238,13 +219,6 @@ emoji_variation_sequences = custom_target(
command: [python, generate_emoji_variation_sequences, '@INPUT@', '@OUTPUT@']
)
generate_srgb_funcs = files('scripts/srgb.py')
srgb_funcs = custom_target(
'generate_srgb_funcs',
output: ['srgb.c', 'srgb.h'],
command: [python, generate_srgb_funcs, '@OUTPUT0@', '@OUTPUT1@']
)
common = static_library(
'common',
'log.c', 'log.h',
@ -277,7 +251,7 @@ vtlib = static_library(
'osc.c', 'osc.h',
'sixel.c', 'sixel.h',
'vt.c', 'vt.h',
builtin_terminfo, srgb_funcs,
builtin_terminfo, emoji_variation_sequences,
wl_proto_src + wl_proto_headers,
version,
dependencies: [libepoll, pixman, fcft, tllist, wayland_client, xkb, utf8proc],
@ -289,7 +263,6 @@ pgolib = static_library(
'grid.c', 'grid.h',
'selection.c', 'selection.h',
'terminal.c', 'terminal.h',
emoji_variation_sequences,
wl_proto_src + wl_proto_headers,
dependencies: [libepoll, pixman, fcft, tllist, wayland_client, xkb, utf8proc],
link_with: vtlib,
@ -320,7 +293,7 @@ executable(
'commands.c', 'commands.h',
'extract.c', 'extract.h',
'fdm.c', 'fdm.h',
'foot-features.c', 'foot-features.h',
'foot-features.h',
'ime.c', 'ime.h',
'input.c', 'input.h',
'key-binding.c', 'key-binding.h',
@ -339,8 +312,7 @@ executable(
'url-mode.c', 'url-mode.h',
'user-notification.c', 'user-notification.h',
'wayland.c', 'wayland.h', 'shm-formats.h',
'xkbcommon-vmod.h',
srgb_funcs, wl_proto_src + wl_proto_headers, version,
wl_proto_src + wl_proto_headers, version,
dependencies: [math, threads, libepoll, pixman, wayland_client, wayland_cursor, xkb, fontconfig, utf8proc,
tllist, fcft],
link_with: pgolib,
@ -349,7 +321,7 @@ executable(
executable(
'footclient',
'client.c', 'client-protocol.h',
'foot-features.c', 'foot-features.h',
'foot-features.h',
'macros.h',
'util.h',
version,
@ -441,6 +413,7 @@ summary(
'Themes': get_option('themes'),
'IME': get_option('ime'),
'Grapheme clustering': utf8proc.found(),
'Wayland: xdg-toplevel-icon-v1': xdg_toplevel_icon,
'utmp backend': utmp_backend,
'utmp helper default path': utmp_default_helper_path,
'Build terminfo': tic.found(),

View file

@ -114,7 +114,7 @@ consume_stdout(struct notification *notif, bool eof)
while (left > 0) {
line = data;
size_t len = left;
char *eol = (char *)memchr(line, '\n', left);
char *eol = memchr(line, '\n', left);
if (eol != NULL) {
*eol = '\0';

View file

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>org.codeberg.dnkl.foot</id>
<metadata_license>MIT</metadata_license>
<project_license>MIT</project_license>
<developer_name>dnkl</developer_name>
<name>foot</name>
<summary>The fast, lightweight and minimalistic Wayland terminal emulator.</summary>
<description>
<ul>
<li>Fast</li>
<li>Lightweight, in dependencies, on-disk and in-memory</li>
<li>Wayland native</li>
<li>DE agnostic</li>
<li>Server/daemon mode</li>
<li>User configurable font fallback</li>
<li>On-the-fly font resize</li>
<li>On-the-fly DPI font size adjustment</li>
<li>Scrollback search</li>
<li>Keyboard driven URL detection</li>
<li>Color emoji support</li>
<li>IME (via text-input-v3)</li>
<li>Multi-seat</li>
<li>True Color (24bpp)</li>
<li>Styled and colored underlines</li>
<li>Synchronized Updates support</li>
<li>Sixel image support</li>
</ul>
</description>
<screenshots>
<screenshot type="default">
<caption>Foot with sixel graphics</caption>
<image>https://codeberg.org/dnkl/foot/media/branch/master/doc/sixel-wow.png</image>
</screenshot>
</screenshots>
<releases>
<release version="1.18.1" date="2024-08-14"/>
<release version="1.18.0" date="2024-08-02"/>
<release version="1.17.2" date="2024-04-17"/>
<release version="1.17.1" date="2024-04-11"/>
<release version="1.17.0" date="2024-04-02"/>
<release version="1.16.2" date="2023-10-17"/>
<release version="1.16.1" date="2023-10-12"/>
<release version="1.16.0" date="2023-10-11"/>
<release version="1.15.3" date="2023-08-07"/>
<release version="1.15.2" date="2023-07-30"/>
<release version="1.15.1" date="2023-07-21"/>
<release version="1.15.0" date="2023-07-14"/>
<release version="1.14.0" date="2023-04-03"/>
<release version="1.13.1" date="2022-08-31"/>
<release version="1.13.0" date="2022-08-07"/>
</releases>
<launchable type="desktop-id">org.codeberg.dnkl.foot.desktop</launchable>
<url type="homepage">https://codeberg.org/dnkl/foot</url>
<url type="bugtracker">https://codeberg.org/dnkl/foot/issues</url>
<content_rating type="oars-1.1"/>
</component>

224
osc.c
View file

@ -73,19 +73,16 @@ osc_to_clipboard(struct terminal *term, const char *target,
}
char *decoded = base64_decode(base64_data, NULL);
if (decoded == NULL || decoded[0] == '\0') {
if (decoded == NULL) {
if (errno == EINVAL)
LOG_WARN("OSC: invalid clipboard data: %s", base64_data);
else
LOG_ERRNO("base64_decode() failed");
}
if (decoded == NULL) {
if (errno == EINVAL)
LOG_WARN("OSC: invalid clipboard data: %s", base64_data);
else
LOG_ERRNO("base64_decode() failed");
if (to_clipboard)
selection_clipboard_unset(seat);
if (to_primary)
selection_primary_unset(seat);
free(decoded);
return;
}
@ -513,7 +510,7 @@ osc_uri(struct terminal *term, char *string)
key_value = strtok_r(NULL, ":", &ctx))
{
const char *key = key_value;
char *operator = (char *)strchr(key_value, '=');
char *operator = strchr(key_value, '=');
if (operator == NULL)
continue;
@ -525,14 +522,12 @@ osc_uri(struct terminal *term, char *string)
id = sdbm_hash(value);
}
LOG_DBG("OSC-8: URL=%s, id=%" PRIu64, uri, id);
if (uri[0] == '\0') {
LOG_DBG("OSC-8: close");
if (uri[0] == '\0')
term_osc8_close(term);
} else {
LOG_DBG("OSC-8: URL=%s, id=%" PRIu64, uri, id);
else
term_osc8_open(term, id, uri);
}
}
static void
@ -615,6 +610,7 @@ verify_kitty_id_is_valid(const char *id)
}
UNIGNORE_WARNINGS
static void
kitty_notification(struct terminal *term, char *string)
{
@ -1139,134 +1135,6 @@ out:
free(sound_name);
}
static void
kitty_text_size(struct terminal *term, char *string)
{
char *text = strchr(string, ';');
if (text == NULL)
return;
char *parameters = string;
*text = '\0';
text++;
char32_t *wchars = ambstoc32(text);
if (wchars == NULL)
return;
int forced_width = 0;
char *ctx = NULL;
for (char *param = strtok_r(parameters, ":", &ctx);
param != NULL;
param = strtok_r(NULL, ":", &ctx))
{
/* All parameters are on the form X=value, where X is always
exactly one character */
if (param[0] == '\0' || param[1] != '=')
continue;
char *value = &param[2];
switch (param[0]) {
case 'w': {
errno = 0;
char *end = NULL;
unsigned long w = strtoul(value, &end, 10);
if (*end == '\0' && errno == 0 && w <= 7) {
forced_width = (int)w;
break;
} else
LOG_ERR("OSC-66: invalid 'w' value, ignoring");
break;
}
case 's':
case 'n':
case 'd':
case 'v':
LOG_WARN("OSC-66: unsupported: '%c' parameter, ignoring", param[0]);
break;
}
}
const size_t len = c32len(wchars);
if (forced_width == 0) {
/*
* w=0 means we split the text up as we'd normally do... Since
* we don't support any other parameters of the text-sizing
* protocol, that means we just process the string as if it
* has been printed without this OSC.
*/
for (size_t i = 0; i < len; i++)
term_process_and_print_non_ascii(term, wchars[i]);
free(wchars);
return;
}
size_t max_cp_width = 0;
size_t all_cp_width = 0;
for (size_t i = 0; i < len; i++) {
const size_t cp_width = c32width(wchars[i]);
all_cp_width += cp_width;
max_cp_width = max(max_cp_width, cp_width);
}
size_t calculated_width = 0;
switch (term->conf->tweak.grapheme_width_method) {
case GRAPHEME_WIDTH_WCSWIDTH: calculated_width = all_cp_width; break;
case GRAPHEME_WIDTH_MAX: calculated_width = max_cp_width; break;
case GRAPHEME_WIDTH_DOUBLE: calculated_width = min(max_cp_width, 2); break;
}
const size_t width = forced_width == 0 ? calculated_width : forced_width;
LOG_DBG("len=%zu, forced=%d, calculated=%zu, using=%zu",
len, forced_width, calculated_width, width);
#if 0
if (len == 1 && calculated_width == forced_width) {
/*
* Optimization: if there's a single codepoint, and either
* w=0, or the 'w' matches the calculated width, print
* codepoint directly instead of creating a combining
* character.
*/
term_print(term, wchars[0], width);
free(wchars);
return;
}
#endif
uint32_t key = composed_key_from_chars(wchars, len);
const struct composed *composed = composed_lookup_without_collision(
term->composed, &key, wchars, len - 1, wchars[len - 1], forced_width);
if (composed == NULL) {
struct composed *new_cc = xmalloc(sizeof(*new_cc));
new_cc->chars = wchars;
new_cc->count = len;
new_cc->key = key;
new_cc->width = width;
new_cc->forced_width = forced_width;
term->composed_count++;
composed_insert(&term->composed, new_cc);
composed = new_cc;
} else if (composed->width == width) {
free(wchars);
}
term_print(
term, CELL_COMB_CHARS_LO + composed->key,
composed->forced_width > 0 ? composed->forced_width : composed->width,
false);
}
void
osc_dispatch(struct terminal *term)
{
@ -1460,17 +1328,15 @@ osc_dispatch(struct terminal *term)
case 11:
term->colors.bg = color;
if (!have_alpha)
alpha = term_theme_get(term)->alpha;
if (have_alpha) {
const bool changed = term->colors.alpha != alpha;
term->colors.alpha = alpha;
const bool changed = term->colors.alpha != alpha;
term->colors.alpha = alpha;
if (changed) {
wayl_win_alpha_changed(term->window);
term_font_subpixel_changed(term);
if (changed) {
wayl_win_alpha_changed(term->window);
term_font_subpixel_changed(term);
}
}
term_damage_color(term, COLOR_DEFAULT, 0);
term_damage_margins(term);
break;
@ -1482,10 +1348,12 @@ osc_dispatch(struct terminal *term)
case 17:
term->colors.selection_bg = color;
term->colors.use_custom_selection = true;
break;
case 19:
term->colors.selection_fg = color;
term->colors.use_custom_selection = true;
break;
}
@ -1503,10 +1371,6 @@ osc_dispatch(struct terminal *term)
osc_selection(term, string);
break;
case 66: /* text-size protocol (kitty) */
kitty_text_size(term, string);
break;
case 99: /* Kitty notifications */
kitty_notification(term, string);
break;
@ -1514,11 +1378,10 @@ osc_dispatch(struct terminal *term)
case 104: {
/* Reset Color Number 'c' (whole table if no parameter) */
const struct color_theme *theme = term_theme_get(term);
if (string[0] == '\0') {
LOG_DBG("resetting all colors");
memcpy(term->colors.table, theme->table, sizeof(term->colors.table));
for (size_t i = 0; i < ALEN(term->colors.table); i++)
term->colors.table[i] = term->conf->colors.table[i];
term_damage_view(term);
}
@ -1540,7 +1403,7 @@ osc_dispatch(struct terminal *term)
}
LOG_DBG("resetting color #%u", idx);
term->colors.table[idx] = theme->table[idx];
term->colors.table[idx] = term->conf->colors.table[idx];
term_damage_color(term, COLOR_BASE256, idx);
}
@ -1553,20 +1416,16 @@ osc_dispatch(struct terminal *term)
case 110: /* Reset default text foreground color */
LOG_DBG("resetting foreground color");
const struct color_theme *theme = term_theme_get(term);
term->colors.fg = theme->fg;
term->colors.fg = term->conf->colors.fg;
term_damage_color(term, COLOR_DEFAULT, 0);
break;
case 111: { /* Reset default text background color */
LOG_DBG("resetting background color");
bool alpha_changed = term->colors.alpha != term->conf->colors.alpha;
const struct color_theme *theme = term_theme_get(term);
bool alpha_changed = term->colors.alpha != theme->alpha;
term->colors.bg = theme->bg;
term->colors.alpha = theme->alpha;
term->colors.bg = term->conf->colors.bg;
term->colors.alpha = term->conf->colors.alpha;
if (alpha_changed) {
wayl_win_alpha_changed(term->window);
@ -1578,37 +1437,24 @@ osc_dispatch(struct terminal *term)
break;
}
case 112: {
case 112:
LOG_DBG("resetting cursor color");
const struct color_theme *theme = term_theme_get(term);
term->colors.cursor_fg = theme->cursor.text;
term->colors.cursor_bg = theme->cursor.cursor;
if (term->conf->colors_dark.use_custom.cursor) {
term->colors.cursor_fg |= 1u << 31;
term->colors.cursor_bg |= 1u << 31;
}
term->colors.cursor_fg = term->conf->cursor.color.text;
term->colors.cursor_bg = term->conf->cursor.color.cursor;
term_damage_cursor(term);
break;
}
case 117: {
case 117:
LOG_DBG("resetting selection background color");
const struct color_theme *theme = term_theme_get(term);
term->colors.selection_bg = theme->selection_bg;
term->colors.selection_bg = term->conf->colors.selection_bg;
term->colors.use_custom_selection = term->conf->colors.use_custom.selection;
break;
}
case 119: {
case 119:
LOG_DBG("resetting selection foreground color");
const struct color_theme *theme = term_theme_get(term);
term->colors.selection_fg = theme->selection_fg;
term->colors.selection_fg = term->conf->colors.selection_fg;
term->colors.use_custom_selection = term->conf->colors.use_custom.selection;
break;
}
case 133:
/*

View file

@ -74,8 +74,6 @@ void render_refresh_icon(struct terminal *term) {}
void render_overlay(struct terminal *term) {}
void render_buffer_release_callback(struct buffer *buf, void *data) {}
bool
render_xcursor_is_valid(const struct seat *seat, const char *cursor)
{
@ -103,7 +101,6 @@ wayl_win_init(struct terminal *term, const char *token)
void wayl_win_destroy(struct wl_window *win) {}
void wayl_win_alpha_changed(struct wl_window *win) {}
bool wayl_win_set_urgent(struct wl_window *win) { return true; }
bool wayl_win_ring_bell(const struct wl_window *win) { return true; }
bool wayl_fractional_scaling(const struct wayland *wayl) { return true; }
pid_t
@ -130,12 +127,6 @@ render_worker_thread(void *_ctx)
return 0;
}
bool
wayl_do_linear_blending(const struct wayland *wayl, const struct config *conf)
{
return false;
}
struct extraction_context *
extract_begin(enum selection_kind kind, bool strip_trailing_empty)
{
@ -203,13 +194,9 @@ void urls_reset(struct terminal *term) {}
void shm_unref(struct buffer *buf) {}
void shm_chain_free(struct buffer_chain *chain) {}
enum shm_bit_depth shm_chain_bit_depth(const struct buffer_chain *chain) { return SHM_BITS_8; }
struct buffer_chain *
shm_chain_new(
struct wayland *wayl, bool scrollable, size_t pix_instances,
enum shm_bit_depth desired_bit_depth,
void (*release_cb)(struct buffer *buf, void *data), void *cb_data)
shm_chain_new(struct wl_shm *shm, bool scrollable, size_t pix_instances)
{
return NULL;
}

View file

@ -1,10 +0,0 @@
[tool.pyright]
strict = ['scripts']
[tool.mypy]
files = '$MYPY_CONFIG_FILE_DIR/scripts'
strict = true
[tool.codespell]
skip = 'pyproject.toml,./subprojects,./pkg,./src,./bld,foot.info,./unicode,./venv'
ignore-regex = 'terminfo capability `rin`|\* Simon Ser|\* \[zar\]\(https://codeberg.org/zar\)|iterm theme|iterm.toml|iterm/OneHalfDark.itermcolors'

View file

@ -67,7 +67,6 @@ quirk_weston_csd_off(struct terminal *term)
quirk_weston_subsurface_desync_off(term->window->csd.surface[i].sub);
}
#if 0
static bool
is_sway(void)
{
@ -83,4 +82,12 @@ is_sway(void)
return is_sway;
}
#endif
void
quirk_sway_subsurface_unmap(struct terminal *term)
{
if (!is_sway())
return;
wl_surface_damage_buffer(term->window->surface.surf, 0, 0, INT32_MAX, INT32_MAX);
}

View file

@ -21,3 +21,5 @@ void quirk_weston_subsurface_desync_off(struct wl_subsurface *sub);
/* Shortcuts to call desync_{on,off} on all CSD subsurfaces */
void quirk_weston_csd_on(struct terminal *term);
void quirk_weston_csd_off(struct terminal *term);
void quirk_sway_subsurface_unmap(struct terminal *term);

896
render.c

File diff suppressed because it is too large Load diff

View file

@ -47,6 +47,3 @@ struct csd_data {
};
struct csd_data get_csd_data(const struct terminal *term, enum csd_surface surf_idx);
void render_buffer_release_callback(struct buffer *buf, void *data);
void render_wait_for_preapply_damage(struct terminal *term);

View file

@ -11,7 +11,7 @@ import termios
from datetime import datetime
def main() -> None:
def main():
parser = argparse.ArgumentParser()
parser.add_argument('files', type=argparse.FileType('rb'), nargs='+')
parser.add_argument('--iterations', type=int, default=20)
@ -24,12 +24,12 @@ def main() -> None:
termios.TIOCGWINSZ,
struct.pack('HHHH', 0, 0, 0, 0)))
times: dict[str, list[float]] = {name: [] for name in [f.name for f in args.files]}
times = {name: [] for name in [f.name for f in args.files]}
for f in args.files:
bench_bytes = f.read()
for _ in range(args.iterations):
for i in range(args.iterations):
start = datetime.now()
sys.stdout.buffer.write(bench_bytes)
stop = datetime.now()
@ -48,4 +48,4 @@ def main() -> None:
if __name__ == '__main__':
main()
sys.exit(main())

View file

@ -8,8 +8,6 @@ import struct
import sys
import termios
from typing import Any
class ColorVariant(enum.IntEnum):
NONE = enum.auto()
@ -19,7 +17,7 @@ class ColorVariant(enum.IntEnum):
RGB = enum.auto()
def main() -> None:
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'out', type=argparse.FileType(mode='w'), nargs='?', help='name of output file')
@ -40,16 +38,10 @@ def main() -> None:
opts = parser.parse_args()
out = opts.out if opts.out is not None else sys.stdout
lines: int | None = None
cols: int | None = None
width: int | None = None
height: int | None = None
if opts.rows is None or opts.cols is None:
try:
def dummy(*args: Any) -> None:
def dummy(*args):
"""Need a handler installed for sigwait() to trigger."""
_ = args
pass
signal.signal(signal.SIGWINCH, dummy)
@ -61,9 +53,6 @@ def main() -> None:
termios.TIOCGWINSZ,
struct.pack('HHHH', 0, 0, 0, 0)))
assert width is not None
assert height is not None
if width > 0 and height > 0:
break
@ -82,11 +71,9 @@ def main() -> None:
if opts.rows is not None:
lines = opts.rows
assert lines is not None
height = 15 * lines # PGO helper binary hardcodes cell height to 15px
if opts.cols is not None:
cols = opts.cols
assert cols is not None
width = 8 * cols # PGO help binary hardcodes cell width to 8px
if lines is None or cols is None or height is None or width is None:
@ -203,8 +190,8 @@ def main() -> None:
# The sixel 'alphabet'
sixels = '?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'
last_pos: tuple[int, int] | None = None
last_size: tuple[int, int] = 0, 0
last_pos = None
last_size = None
for _ in range(20):
if last_pos is not None and random.randrange(2):
@ -267,4 +254,4 @@ def main() -> None:
if __name__ == '__main__':
main()
sys.exit(main())

View file

@ -1,12 +1,14 @@
#!/usr/bin/env python3
import argparse
import os
import re
import sys
from typing import Dict, Union
class Capability:
def __init__(self, name: str, value: bool | int | str):
def __init__(self, name: str, value: Union[bool, int, str]):
self._name = name
self._value = value
@ -15,37 +17,25 @@ class Capability:
return self._name
@property
def value(self) -> bool | int | str:
def value(self) -> Union[bool, int, str]:
return self._value
def __lt__(self, other: object) -> bool:
if not isinstance(other, Capability):
return NotImplemented
def __lt__(self, other):
return self._name < other._name
def __le__(self, other: object) -> bool:
if not isinstance(other, Capability):
return NotImplemented
def __le__(self, other):
return self._name <= other._name
def __eq__(self, other: object) -> bool:
if not isinstance(other, Capability):
return NotImplemented
def __eq__(self, other):
return self._name == other._name
def __ne__(self, other: object) -> bool:
if not isinstance(other, Capability):
return NotImplemented
return bool(self._name != other._name)
def __ne__(self, other):
return self._name != other._name
def __gt__(self, other: object) -> bool:
if not isinstance(other, Capability):
return NotImplemented
return bool(self._name > other._name)
def __gt__(self, other):
return self._name > other._name
def __ge__(self, other: object) -> bool:
if not isinstance(other, Capability):
return NotImplemented
def __ge__(self, other):
return self._name >= other._name
@ -63,7 +53,7 @@ class StringCapability(Capability):
# see terminfo(5) for valid escape sequences
# Control characters
def translate_ctrl_chr(m: re.Match[str]) -> str:
def translate_ctrl_chr(m):
ctrl = m.group(1)
if ctrl == '?':
return '\\x7f'
@ -95,7 +85,7 @@ class Fragment:
def __init__(self, name: str, description: str):
self._name = name
self._description = description
self._caps = dict[str, Capability]()
self._caps = {}
@property
def name(self) -> str:
@ -106,18 +96,18 @@ class Fragment:
return self._description
@property
def caps(self) -> dict[str, Capability]:
def caps(self) -> Dict[str, Capability]:
return self._caps
def add_capability(self, cap: Capability) -> None:
def add_capability(self, cap: Capability):
assert cap.name not in self._caps
self._caps[cap.name] = cap
def del_capability(self, name: str) -> None:
def del_capability(self, name: str):
del self._caps[name]
def main() -> None:
def main():
parser = argparse.ArgumentParser()
parser.add_argument('source_entry_name')
parser.add_argument('source', type=argparse.FileType('r'))
@ -130,15 +120,15 @@ def main() -> None:
source = opts.source
target = opts.target
lines = list[str]()
for line in source.readlines():
line = line.strip()
if line.startswith('#'):
lines = []
for l in source.readlines():
l = l.strip()
if l.startswith('#'):
continue
lines.append(line)
lines.append(l)
fragments = dict[str, Fragment]()
cur_fragment: Fragment | None = None
fragments = {}
cur_fragment = None
for m in re.finditer(
r'(?P<name>(?P<entry_name>[-+\w@]+)\|(?P<entry_desc>.+?),)|'
@ -157,20 +147,17 @@ def main() -> None:
elif m.group('bool_cap') is not None:
name = m.group('bool_name')
assert cur_fragment is not None
cur_fragment.add_capability(BoolCapability(name))
elif m.group('int_cap') is not None:
name = m.group('int_name')
int_value = int(m.group('int_val'), 0)
assert cur_fragment is not None
cur_fragment.add_capability(IntCapability(name, int_value))
value = int(m.group('int_val'), 0)
cur_fragment.add_capability(IntCapability(name, value))
elif m.group('str_cap') is not None:
name = m.group('str_name')
str_value = m.group('str_val')
assert cur_fragment is not None
cur_fragment.add_capability(StringCapability(name, str_value))
value = m.group('str_val')
cur_fragment.add_capability(StringCapability(name, value))
else:
assert False
@ -179,9 +166,6 @@ def main() -> None:
for frag in fragments.values():
for cap in frag.caps.values():
if cap.name == 'use':
assert isinstance(cap, StringCapability)
assert isinstance(cap.value, str)
use_frag = fragments[cap.value]
for use_cap in use_frag.caps.values():
frag.add_capability(use_cap)
@ -201,9 +185,8 @@ def main() -> None:
entry.add_capability(StringCapability('TN', target_entry_name))
entry.add_capability(StringCapability('name', target_entry_name))
entry.add_capability(IntCapability('RGB', 8)) # 8 bits per channel
entry.add_capability(StringCapability('query-os-name', os.uname().sysname))
terminfo_parts = list[str]()
terminfo_parts = []
for cap in sorted(entry.caps.values()):
name = cap.name
value = str(cap.value)
@ -227,4 +210,4 @@ def main() -> None:
if __name__ == '__main__':
main()
sys.exit(main())

View file

@ -1,10 +1,11 @@
#!/usr/bin/env python3
import argparse
import sys
class Codepoint:
def __init__(self, start: int, end: None | int = None):
def __init__(self, start: int, end: None|int = None):
self.start = start
self.end = start if end is None else end
self.vs15 = False
@ -14,7 +15,7 @@ class Codepoint:
return f'{self.start:x}-{self.end:x}, vs15={self.vs15}, vs16={self.vs16}'
def main() -> None:
def main():
parser = argparse.ArgumentParser()
parser.add_argument('input', type=argparse.FileType('r'))
parser.add_argument('output', type=argparse.FileType('w'))
@ -99,4 +100,4 @@ def main() -> None:
if __name__ == '__main__':
main()
sys.exit(main())

View file

@ -1,70 +0,0 @@
#!/usr/bin/env python3
import argparse
import math
# Note: we use a pure gamma 2.2 function, rather than the piece-wise
# sRGB transfer function, since that is what all compositors do.
def srgb_to_linear(f: float) -> float:
assert(f >= 0 and f <= 1.0)
return math.pow(f, 2.2)
def linear_to_srgb(f: float) -> float:
return math.pow(f, 1 / 2.2)
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument('c_output', type=argparse.FileType('w'))
parser.add_argument('h_output', type=argparse.FileType('w'))
opts = parser.parse_args()
linear_table: list[int] = []
for i in range(256):
linear_table.append(int(srgb_to_linear(float(i) / 255) * 65535 + 0.5))
opts.h_output.write("#pragma once\n")
opts.h_output.write("#include <stdint.h>\n")
opts.h_output.write("\n")
opts.h_output.write('/* 8-bit input, 16-bit output */\n')
opts.h_output.write("extern const uint16_t srgb_decode_8_to_16_table[256];")
opts.h_output.write('\n')
opts.h_output.write('static inline uint16_t\n')
opts.h_output.write('srgb_decode_8_to_16(uint8_t v)\n')
opts.h_output.write('{\n')
opts.h_output.write(' return srgb_decode_8_to_16_table[v];\n')
opts.h_output.write('}\n')
opts.h_output.write('\n')
opts.h_output.write('/* 8-bit input, 8-bit output */\n')
opts.h_output.write("extern const uint8_t srgb_decode_8_to_8_table[256];\n")
opts.h_output.write('\n')
opts.h_output.write('static inline uint8_t\n')
opts.h_output.write('srgb_decode_8_to_8(uint8_t v)\n')
opts.h_output.write('{\n')
opts.h_output.write(' return srgb_decode_8_to_8_table[v];\n')
opts.h_output.write('}\n')
opts.c_output.write('#include "srgb.h"\n')
opts.c_output.write('\n')
opts.c_output.write("const uint16_t srgb_decode_8_to_16_table[256] = {\n")
for i in range(256):
opts.c_output.write(f' {linear_table[i]},\n')
opts.c_output.write('};\n')
opts.c_output.write("const uint8_t srgb_decode_8_to_8_table[256] = {\n")
for i in range(256):
opts.c_output.write(f' {linear_table[i] >> 8},\n')
opts.c_output.write('};\n')
if __name__ == '__main__':
main()

View file

@ -283,13 +283,8 @@ matches_cell(const struct terminal *term, const struct cell *cell, size_t search
if (composed == NULL && base == 0 && term->search.buf[search_ofs] == U' ')
return 1;
if (hasc32upper(term->search.buf)) {
if (c32ncmp(&base, &term->search.buf[search_ofs], 1) != 0)
return -1;
} else {
if (c32ncasecmp(&base, &term->search.buf[search_ofs], 1) != 0)
return -1;
}
if (c32ncasecmp(&base, &term->search.buf[search_ofs], 1) != 0)
return -1;
if (composed != NULL) {
if (search_ofs + composed->count > term->search.len)
@ -1270,29 +1265,6 @@ execute_binding(struct seat *seat, struct terminal *term,
return true;
}
case BIND_ACTION_SEARCH_DELETE_TO_START: {
if (term->search.cursor > 0) {
memmove(&term->search.buf[0],
&term->search.buf[term->search.cursor],
(term->search.len - term->search.cursor)
* sizeof(char32_t));
term->search.len -= term->search.cursor;
term->search.cursor = 0;
*update_search_result = *redraw = true;
}
return true;
}
case BIND_ACTION_SEARCH_DELETE_TO_END: {
if (term->search.cursor < term->search.len) {
term->search.buf[term->search.cursor] = '\0';
term->search.len = term->search.cursor;
*update_search_result = *redraw = true;
}
return true;
}
case BIND_ACTION_SEARCH_EXTEND_CHAR: {
struct coord target;
if (search_extend_find_char_right(term, &target)) {
@ -1416,34 +1388,11 @@ search_input(struct seat *seat, struct terminal *term,
bool update_search_result = false;
bool redraw = false;
/*
* Key bindings
*/
/* Match untranslated symbols */
tll_foreach(bindings->search, it) {
const struct key_binding *bind = &it->item;
if (bind->mods != mods || bind->mods == 0)
continue;
for (size_t i = 0; i < raw_count; i++) {
if (bind->k.sym == raw_syms[i]) {
if (execute_binding(seat, term, bind, serial,
&update_search_result, &search_direction,
&redraw))
{
goto update_search;
}
return;
}
}
}
/* Match translated symbol */
/* Key bindings */
tll_foreach(bindings->search, it) {
const struct key_binding *bind = &it->item;
/* Match translated symbol */
if (bind->k.sym == sym &&
bind->mods == (mods & ~consumed)) {
@ -1455,15 +1404,24 @@ search_input(struct seat *seat, struct terminal *term,
}
return;
}
}
/* Match raw key code */
tll_foreach(bindings->search, it) {
const struct key_binding *bind = &it->item;
if (bind->mods != mods || bind->mods == 0)
if (bind->mods != mods)
continue;
/* Match untranslated symbols */
for (size_t i = 0; i < raw_count; i++) {
if (bind->k.sym == raw_syms[i]) {
if (execute_binding(seat, term, bind, serial,
&update_search_result, &search_direction,
&redraw))
{
goto update_search;
}
return;
}
}
/* Match raw key code */
tll_foreach(bind->k.key_codes, code) {
if (code->item == key) {
if (execute_binding(seat, term, bind, serial,
@ -1484,8 +1442,7 @@ search_input(struct seat *seat, struct terminal *term,
count = xkb_compose_state_get_utf8(
seat->kbd.xkb_compose_state, (char *)buf, sizeof(buf));
xkb_compose_state_reset(seat->kbd.xkb_compose_state);
} else if (compose_status == XKB_COMPOSE_CANCELLED ||
compose_status == XKB_COMPOSE_COMPOSING) {
} else if (compose_status == XKB_COMPOSE_CANCELLED) {
count = 0;
} else {
count = xkb_state_key_get_utf8(

View file

@ -19,7 +19,6 @@
#include "char32.h"
#include "commands.h"
#include "config.h"
#include "debug.h"
#include "extract.h"
#include "grid.h"
#include "misc.h"
@ -559,15 +558,9 @@ selection_find_quote_left(struct terminal *term, struct coord *pos,
if (*quote_char == '\0' ? (wc == '"' || wc == '\'')
: wc == *quote_char)
{
xassert(next_col + 1 <= term->cols);
if (next_col + 1 == term->cols) {
xassert(next_row < pos->row);
pos->row = next_row + 1;
pos->col = 0;
} else {
pos->row = next_row;
pos->col = next_col + 1;
}
pos->row = next_row;
pos->col = next_col + 1;
xassert(pos->col < term->cols);
*quote_char = wc;
return true;

View file

@ -4,7 +4,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/socket.h>
@ -24,13 +23,11 @@
#include "wayland.h"
#include "xmalloc.h"
#define NON_ZERO_OPT (INT_MIN / 7)
struct client;
struct terminal_instance;
struct server {
struct config *conf;
const struct config *conf;
struct fdm *fdm;
struct reaper *reaper;
struct wayland *wayl;
@ -156,61 +153,10 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
xassert(events & EPOLLIN);
if (client->instance != NULL) {
struct client_ipc_hdr ipc_hdr;
ssize_t count = read(fd, &ipc_hdr, sizeof(ipc_hdr));
if (count != sizeof(ipc_hdr)) {
LOG_WARN("client unexpectedly sent %zd bytes", count);
return true; /* TODO: shutdown instead? */
}
switch (ipc_hdr.ipc_code) {
case FOOT_IPC_SIGUSR: {
xassert(ipc_hdr.size == sizeof(struct client_ipc_sigusr));
struct client_ipc_sigusr sigusr;
count = read(fd, &sigusr, sizeof(sigusr));
if (count < 0) {
LOG_ERRNO("failed to read SIGUSR IPC data from client");
return true; /* TODO: shutdown instead? */
}
if ((size_t)count != sizeof(sigusr)) {
LOG_ERR("failed to read SIGUSR IPC data from client");
return true; /* TODO: shutdown instead? */
}
switch (sigusr.signo) {
case SIGUSR1:
term_theme_switch_to_dark(client->instance->terminal);
break;
case SIGUSR2:
term_theme_switch_to_light(client->instance->terminal);
break;
default:
LOG_ERR(
"client sent bad SIGUSR number: %d "
"(expected SIGUSR1=%d or SIGUSR2=%d)",
sigusr.signo, SIGUSR1, SIGUSR2);
break;
}
return true;
}
default:
LOG_WARN(
"client sent unrecognized IPC (0x%04x), ignoring %hhu bytes",
ipc_hdr.ipc_code, ipc_hdr.size);
/* TODO: slightly broken, since not all data is guaranteed
to be readable yet */
uint8_t dummy[ipc_hdr.size];
(void)!!read(fd, dummy, ipc_hdr.size);
return true;
}
uint8_t dummy[128];
ssize_t count = read(fd, dummy, sizeof(dummy));
LOG_WARN("client unexpectedly sent %zd bytes", count);
return true; /* TODO: shutdown instead? */
}
if (client->buffer.data == NULL) {
@ -265,12 +211,6 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
return true;
}
if (tll_length(server->wayl->monitors) == 0) {
LOG_ERR("no monitors available for new terminal");
client_send_exit_code(client, -26);
goto shutdown;
}
/* All initialization data received - time to instantiate a terminal! */
xassert(client->instance == NULL);
@ -528,7 +468,7 @@ prepare_socket(int fd)
}
int const socket_options[] = { SO_DOMAIN, SO_ACCEPTCONN, SO_TYPE };
int const socket_options_values[] = { AF_UNIX, NON_ZERO_OPT, SOCK_STREAM};
int const socket_options_values[] = { AF_UNIX, 1, SOCK_STREAM};
char const * const socket_options_names[] = { "SO_DOMAIN", "SO_ACCEPTCONN", "SO_TYPE" };
xassert(ALEN(socket_options) == ALEN(socket_options_values));
@ -543,8 +483,6 @@ prepare_socket(int fd)
LOG_ERRNO("failed to read socket option from passed file descriptor");
return false;
}
if (socket_options_values[i] == NON_ZERO_OPT && socket_option)
socket_option = NON_ZERO_OPT;
if (socket_option != socket_options_values[i]) {
LOG_ERR("wrong socket value for socket option '%s' on passed file descriptor",
socket_options_names[i]);
@ -556,7 +494,7 @@ prepare_socket(int fd)
}
struct server *
server_init(struct config *conf, struct fdm *fdm, struct reaper *reaper,
server_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
struct wayland *wayl)
{
int fd;
@ -668,23 +606,3 @@ server_destroy(struct server *server)
unlink(server->sock_path);
free(server);
}
void
server_global_theme_switch_to_dark(struct server *server)
{
server->conf->initial_color_theme = COLOR_THEME_DARK;
tll_foreach(server->clients, it)
term_theme_switch_to_dark(it->item->instance->terminal);
tll_foreach(server->terminals, it)
term_theme_switch_to_dark(it->item->terminal);
}
void
server_global_theme_switch_to_light(struct server *server)
{
server->conf->initial_color_theme = COLOR_THEME_LIGHT;
tll_foreach(server->clients, it)
term_theme_switch_to_light(it->item->instance->terminal);
tll_foreach(server->terminals, it)
term_theme_switch_to_light(it->item->terminal);
}

View file

@ -6,9 +6,6 @@
#include "wayland.h"
struct server;
struct server *server_init(struct config *conf, struct fdm *fdm,
struct server *server_init(const struct config *conf, struct fdm *fdm,
struct reaper *reaper, struct wayland *wayl);
void server_destroy(struct server *server);
void server_global_theme_switch_to_dark(struct server *server);
void server_global_theme_switch_to_light(struct server *server);

View file

@ -117,22 +117,5 @@ static const struct shm_formats {
{WL_SHM_FORMAT_ARGB16161616, "ARGB16161616"},
{WL_SHM_FORMAT_ABGR16161616, "ABGR16161616"},
#endif
#if WAYLAND_VERSION_MAJOR > 1 || WAYLAND_VERSION_MINOR >= 23
{WL_SHM_FORMAT_C1, "C1"},
{WL_SHM_FORMAT_C2, "C2"},
{WL_SHM_FORMAT_C4, "C4"},
{WL_SHM_FORMAT_D1, "D1"},
{WL_SHM_FORMAT_D2, "D2"},
{WL_SHM_FORMAT_D4, "D4"},
{WL_SHM_FORMAT_D8, "D8"},
{WL_SHM_FORMAT_R1, "R1"},
{WL_SHM_FORMAT_R2, "R2"},
{WL_SHM_FORMAT_R4, "R4"},
{WL_SHM_FORMAT_R10, "R10"},
{WL_SHM_FORMAT_R12, "R12"},
{WL_SHM_FORMAT_AVUY8888, "AVUY8888"},
{WL_SHM_FORMAT_XVUY8888, "XVUY8888"},
{WL_SHM_FORMAT_P030, "P030"},
#endif
};
#endif

169
shm.c
View file

@ -13,6 +13,7 @@
#include <pixman.h>
#include <fcft/stride.h>
#include <tllist.h>
#define LOG_MODULE "shm"
@ -20,7 +21,6 @@
#include "log.h"
#include "debug.h"
#include "macros.h"
#include "stride.h"
#include "xmalloc.h"
#if !defined(MAP_UNINITIALIZED)
@ -61,8 +61,6 @@ static off_t max_pool_size = 512 * 1024 * 1024;
static bool can_punch_hole = false;
static bool can_punch_hole_initialized = false;
static size_t min_stride_alignment = 0;
struct buffer_pool {
int fd; /* memfd */
struct wl_shm_pool *wl_pool;
@ -84,11 +82,9 @@ struct buffer_private {
struct buffer_pool *pool;
off_t offset; /* Offset into memfd where data begins */
size_t size;
bool with_alpha;
bool scrollable;
void (*release_cb)(struct buffer *buf, void *data);
void *cb_data;
};
struct buffer_chain {
@ -96,12 +92,6 @@ struct buffer_chain {
struct wl_shm *shm;
size_t pix_instances;
bool scrollable;
pixman_format_code_t pixman_fmt;
enum wl_shm_format shm_format;
void (*release_cb)(struct buffer *buf, void *data);
void *cb_data;
};
static tll(struct buffer_private *) deferred;
@ -117,12 +107,6 @@ shm_set_max_pool_size(off_t _max_pool_size)
max_pool_size = _max_pool_size;
}
void
shm_set_min_stride_alignment(size_t _min_stride_alignment)
{
min_stride_alignment = _min_stride_alignment;
}
static void
buffer_destroy_dont_close(struct buffer *buf)
{
@ -131,7 +115,6 @@ buffer_destroy_dont_close(struct buffer *buf)
if (buf->pix[i] != NULL)
pixman_image_unref(buf->pix[i]);
}
if (buf->wl_buf != NULL)
wl_buffer_destroy(buf->wl_buf);
@ -234,10 +217,6 @@ buffer_release(void *data, struct wl_buffer *wl_buffer)
xassert(found);
if (!found)
LOG_WARN("deferred delete: buffer not on the 'deferred' list");
} else {
if (buffer->release_cb != NULL) {
buffer->release_cb(&buffer->public, buffer->cb_data);
}
}
}
@ -245,6 +224,7 @@ static const struct wl_buffer_listener buffer_listener = {
.release = &buffer_release,
};
#if __SIZEOF_POINTER__ == 8
static size_t
page_size(void)
{
@ -261,6 +241,7 @@ page_size(void)
xassert(size > 0);
return size;
}
#endif
static bool
instantiate_offset(struct buffer_private *buf, off_t new_offset)
@ -281,7 +262,7 @@ instantiate_offset(struct buffer_private *buf, off_t new_offset)
wl_buf = wl_shm_pool_create_buffer(
pool->wl_pool, new_offset,
buf->public.width, buf->public.height, buf->public.stride,
buf->chain->shm_format);
buf->with_alpha ? WL_SHM_FORMAT_ARGB8888 : WL_SHM_FORMAT_XRGB8888);
if (wl_buf == NULL) {
LOG_ERR("failed to create SHM buffer");
@ -291,10 +272,9 @@ instantiate_offset(struct buffer_private *buf, off_t new_offset)
/* One pixman image for each worker thread (do we really need multiple?) */
for (size_t i = 0; i < buf->public.pix_instances; i++) {
pix[i] = pixman_image_create_bits_no_clear(
buf->chain->pixman_fmt,
buf->with_alpha ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
buf->public.width, buf->public.height,
(uint32_t *)mmapped, buf->public.stride);
if (pix[i] == NULL) {
LOG_ERR("failed to create pixman image");
goto err;
@ -326,7 +306,8 @@ err:
static void NOINLINE
get_new_buffers(struct buffer_chain *chain, size_t count,
int widths[static count], int heights[static count],
struct buffer *bufs[static count], bool immediate_purge)
struct buffer *bufs[static count], bool with_alpha,
bool immediate_purge)
{
xassert(count == 1 || !chain->scrollable);
/*
@ -345,14 +326,7 @@ get_new_buffers(struct buffer_chain *chain, size_t count,
size_t total_size = 0;
for (size_t i = 0; i < count; i++) {
stride[i] = stride_for_format_and_width(
chain->pixman_fmt, widths[i]);
if (min_stride_alignment > 0) {
const size_t m = min_stride_alignment;
stride[i] = (stride[i] + m - 1) / m * m;
}
xassert(min_stride_alignment == 0 || stride[i] % min_stride_alignment == 0);
with_alpha ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8, widths[i]);
sizes[i] = stride[i] * heights[i];
total_size += sizes[i];
}
@ -394,11 +368,9 @@ get_new_buffers(struct buffer_chain *chain, size_t count,
goto err;
}
const size_t page_sz = page_size();
#if __SIZEOF_POINTER__ == 8
off_t offset = chain->scrollable && max_pool_size > 0
? (max_pool_size / 4) & ~(page_sz - 1)
? (max_pool_size / 4) & ~(page_size() - 1)
: 0;
off_t memfd_size = chain->scrollable && max_pool_size > 0
? max_pool_size
@ -408,8 +380,7 @@ get_new_buffers(struct buffer_chain *chain, size_t count,
off_t memfd_size = total_size;
#endif
/* Page align */
memfd_size = (memfd_size + page_sz - 1) & ~(page_sz - 1);
xassert(chain->scrollable || (offset == 0 && memfd_size == total_size));
LOG_DBG("memfd-size: %lu, initial offset: %lu", memfd_size, offset);
@ -441,9 +412,6 @@ get_new_buffers(struct buffer_chain *chain, size_t count,
memfd_size = total_size;
chain->scrollable = false;
/* Page align */
memfd_size = (memfd_size + page_sz - 1) & ~(page_sz - 1);
if (ftruncate(pool_fd, memfd_size) < 0) {
LOG_ERRNO("failed to set size of SHM backing memory file");
goto err;
@ -509,12 +477,11 @@ get_new_buffers(struct buffer_chain *chain, size_t count,
.chain = chain,
.ref_count = immediate_purge ? 0 : 1,
.busy = true,
.with_alpha = with_alpha,
.pool = pool,
.offset = 0,
.size = sizes[i],
.scrollable = chain->scrollable,
.release_cb = chain->release_cb,
.cb_data = chain->cb_data,
};
if (!instantiate_offset(buf, offset)) {
@ -580,13 +547,13 @@ shm_did_not_use_buf(struct buffer *_buf)
void
shm_get_many(struct buffer_chain *chain, size_t count,
int widths[static count], int heights[static count],
struct buffer *bufs[static count])
struct buffer *bufs[static count], bool with_alpha)
{
get_new_buffers(chain, count, widths, heights, bufs, true);
get_new_buffers(chain, count, widths, heights, bufs, with_alpha, true);
}
struct buffer *
shm_get_buffer(struct buffer_chain *chain, int width, int height)
shm_get_buffer(struct buffer_chain *chain, int width, int height, bool with_alpha)
{
LOG_DBG(
"chain=%p: looking for a reusable %dx%d buffer "
@ -597,7 +564,9 @@ shm_get_buffer(struct buffer_chain *chain, int width, int height)
tll_foreach(chain->bufs, it) {
struct buffer_private *buf = it->item;
if (buf->public.width != width || buf->public.height != height) {
if (buf->public.width != width || buf->public.height != height ||
with_alpha != buf->with_alpha)
{
LOG_DBG("purging mismatching buffer %p", (void *)buf);
if (buffer_unref_no_remove_from_chain(buf))
tll_remove(chain->bufs, it);
@ -613,9 +582,9 @@ shm_get_buffer(struct buffer_chain *chain, int width, int height)
else
#endif
{
if (cached == NULL) {
if (cached == NULL)
cached = buf;
} else {
else {
/* We have multiple buffers eligible for
* reuse. Pick the "youngest" one, and mark the
* other one for purging */
@ -639,7 +608,7 @@ shm_get_buffer(struct buffer_chain *chain, int width, int height)
}
if (cached != NULL) {
LOG_DBG("reusing buffer %p from cache", (void *)cached);
LOG_DBG("re-using buffer %p from cache", (void *)cached);
cached->busy = true;
for (size_t i = 0; i < cached->public.pix_instances; i++)
pixman_region32_clear(&cached->public.dirty[i]);
@ -648,7 +617,7 @@ shm_get_buffer(struct buffer_chain *chain, int width, int height)
}
struct buffer *ret;
get_new_buffers(chain, 1, &width, &height, &ret, false);
get_new_buffers(chain, 1, &width, &height, &ret, with_alpha, false);
return ret;
}
@ -990,90 +959,14 @@ shm_unref(struct buffer *_buf)
}
struct buffer_chain *
shm_chain_new(struct wayland *wayl, bool scrollable, size_t pix_instances,
enum shm_bit_depth desired_bit_depth,
void (*release_cb)(struct buffer *buf, void *data), void *cb_data)
shm_chain_new(struct wl_shm *shm, bool scrollable, size_t pix_instances)
{
pixman_format_code_t pixman_fmt = PIXMAN_a8r8g8b8;
enum wl_shm_format shm_fmt = WL_SHM_FORMAT_ARGB8888;
static bool have_logged = false;
static bool have_logged_10_fallback = false;
#if defined(HAVE_PIXMAN_RGBA_16)
static bool have_logged_16_fallback = false;
if (desired_bit_depth == SHM_BITS_16) {
if (wayl->shm_have_abgr161616) {
pixman_fmt = PIXMAN_a16b16g16r16;
shm_fmt = WL_SHM_FORMAT_ABGR16161616;
if (!have_logged) {
have_logged = true;
LOG_INFO("using 16-bit BGR surfaces");
}
} else {
if (!have_logged_16_fallback) {
have_logged_16_fallback = true;
LOG_WARN(
"16-bit surfaces requested, but compositor does not "
"implement ABGR161616+XBGR161616");
}
}
}
#endif
if (desired_bit_depth >= SHM_BITS_10 && pixman_fmt == PIXMAN_a8r8g8b8) {
if (wayl->shm_have_argb2101010) {
pixman_fmt = PIXMAN_a2r10g10b10;
shm_fmt = WL_SHM_FORMAT_ARGB2101010;
if (!have_logged) {
have_logged = true;
LOG_INFO("using 10-bit RGB surfaces");
}
}
else if (wayl->shm_have_abgr2101010) {
pixman_fmt = PIXMAN_a2b10g10r10;
shm_fmt = WL_SHM_FORMAT_ABGR2101010;
if (!have_logged) {
have_logged = true;
LOG_INFO("using 10-bit BGR surfaces");
}
}
else {
if (!have_logged_10_fallback) {
have_logged_10_fallback = true;
LOG_WARN(
"10-bit surfaces requested, but compositor does not "
"implement ARGB2101010+XRGB2101010, or "
"ABGR2101010+XBGR2101010");
}
}
} else {
if (!have_logged) {
have_logged = true;
LOG_INFO("using 8-bit RGB surfaces");
}
}
struct buffer_chain *chain = xmalloc(sizeof(*chain));
*chain = (struct buffer_chain){
.bufs = tll_init(),
.shm = wayl->shm,
.shm = shm,
.pix_instances = pix_instances,
.scrollable = scrollable,
.pixman_fmt = pixman_fmt,
.shm_format = shm_fmt,
.release_cb = release_cb,
.cb_data = cb_data,
};
return chain;
}
@ -1093,17 +986,3 @@ shm_chain_free(struct buffer_chain *chain)
free(chain);
}
enum shm_bit_depth
shm_chain_bit_depth(const struct buffer_chain *chain)
{
const pixman_format_code_t fmt = chain->pixman_fmt;
return fmt == PIXMAN_a8r8g8b8
? SHM_BITS_8
#if defined(HAVE_PIXMAN_RGBA_16)
: fmt == PIXMAN_a16b16g16r16
? SHM_BITS_16
#endif
: SHM_BITS_10;
}

17
shm.h
View file

@ -9,9 +9,6 @@
#include <tllist.h>
#include "config.h"
#include "wayland.h"
struct damage;
struct buffer {
@ -42,20 +39,13 @@ struct buffer {
};
void shm_fini(void);
/* TODO: combine into shm_init() */
void shm_set_max_pool_size(off_t max_pool_size);
void shm_set_min_stride_alignment(size_t min_stride_alignment);
struct buffer_chain;
struct buffer_chain *shm_chain_new(
struct wayland *wayl, bool scrollable, size_t pix_instances,
enum shm_bit_depth desired_bit_depth,
void (*release_cb)(struct buffer *buf, void *data), void *cb_data);
struct wl_shm *shm, bool scrollable, size_t pix_instances);
void shm_chain_free(struct buffer_chain *chain);
enum shm_bit_depth shm_chain_bit_depth(const struct buffer_chain *chain);
/*
* Returns a single buffer.
*
@ -65,7 +55,8 @@ enum shm_bit_depth shm_chain_bit_depth(const struct buffer_chain *chain);
*
* A newly allocated buffer has an age of 1234.
*/
struct buffer *shm_get_buffer(struct buffer_chain *chain, int width, int height);
struct buffer *shm_get_buffer(
struct buffer_chain *chain, int width, int height, bool with_alpha);
/*
* Returns many buffers, described by 'info', all sharing the same SHM
* buffer pool.
@ -83,7 +74,7 @@ struct buffer *shm_get_buffer(struct buffer_chain *chain, int width, int height)
void shm_get_many(
struct buffer_chain *chain, size_t count,
int widths[static count], int heights[static count],
struct buffer *bufs[static count]);
struct buffer *bufs[static count], bool with_alpha);
void shm_did_not_use_buf(struct buffer *buf);

115
sixel.c
View file

@ -10,7 +10,6 @@
#include "grid.h"
#include "hsl.h"
#include "render.h"
#include "srgb.h"
#include "util.h"
#include "xmalloc.h"
#include "xsnprintf.h"
@ -20,40 +19,6 @@ static size_t count;
static void sixel_put_generic(struct terminal *term, uint8_t c);
static void sixel_put_ar_11(struct terminal *term, uint8_t c);
static uint32_t
color_decode_srgb(const struct terminal *term, uint16_t r, uint16_t g, uint16_t b)
{
if (term->sixel.linear_blending) {
if (term->sixel.use_10bit) {
r = srgb_decode_8_to_16(r) >> 6;
g = srgb_decode_8_to_16(g) >> 6;
b = srgb_decode_8_to_16(b) >> 6;
} else {
r = srgb_decode_8_to_8(r);
g = srgb_decode_8_to_8(g);
b = srgb_decode_8_to_8(b);
}
} else {
if (term->sixel.use_10bit) {
r <<= 2;
g <<= 2;
b <<= 2;
}
}
uint32_t color;
if (term->sixel.use_10bit) {
if (PIXMAN_FORMAT_TYPE(term->sixel.pixman_fmt) == PIXMAN_TYPE_ARGB)
color = 0x3u << 30 | r << 20 | g << 10 | b;
else
color = 0x3u << 30 | b << 20 | g << 10 | r;
} else
color = 0xffu << 24 | r << 16 | g << 8 | b;
return color;
}
void
sixel_fini(struct terminal *term)
{
@ -110,34 +75,6 @@ sixel_init(struct terminal *term, int p1, int p2, int p3)
term->sixel.image.height = 0;
term->sixel.image.alloc_height = 0;
term->sixel.image.bottom_pixel = 0;
term->sixel.linear_blending = wayl_do_linear_blending(term->wl, term->conf);
term->sixel.pixman_fmt = PIXMAN_a8r8g8b8;
/*
* Use higher-precision sixel surfaces if we're using
* higher-precision window surfaces.
*
* This is to a) get more accurate colors when doing gamma-correct
* blending, and b) use the same pixman format as the main
* surfaces, for (hopefully) better performance.
*
* For now, don't support 16-bit surfaces (too much sixel logic
* that assumes 32-bit pixels).
*/
if (shm_chain_bit_depth(term->render.chains.grid) >= SHM_BITS_10) {
if (term->wl->shm_have_argb2101010) {
term->sixel.use_10bit = true;
term->sixel.pixman_fmt = PIXMAN_a2r10g10b10;
}
else if (term->wl->shm_have_abgr2101010) {
term->sixel.use_10bit = true;
term->sixel.pixman_fmt = PIXMAN_a2b10g10r10;
}
}
const size_t active_palette_entries = min(
ALEN(term->conf->colors_dark.sixel), term->sixel.palette_size);
if (term->sixel.use_private_palette) {
xassert(term->sixel.private_palette == NULL);
@ -145,36 +82,21 @@ sixel_init(struct terminal *term, int p1, int p2, int p3)
term->sixel.palette_size, sizeof(term->sixel.private_palette[0]));
memcpy(
term->sixel.private_palette, term->conf->colors_dark.sixel,
active_palette_entries * sizeof(term->sixel.private_palette[0]));
if (term->sixel.linear_blending || term->sixel.use_10bit) {
for (size_t i = 0; i < active_palette_entries; i++) {
uint8_t r = (term->sixel.private_palette[i] >> 16) & 0xff;
uint8_t g = (term->sixel.private_palette[i] >> 8) & 0xff;
uint8_t b = (term->sixel.private_palette[i] >> 0) & 0xff;
term->sixel.private_palette[i] = color_decode_srgb(term, r, g, b);
}
}
term->sixel.private_palette, term->conf->colors.sixel,
min(sizeof(term->conf->colors.sixel),
term->sixel.palette_size * sizeof(term->sixel.private_palette[0])));
term->sixel.palette = term->sixel.private_palette;
} else {
if (term->sixel.shared_palette == NULL) {
term->sixel.shared_palette = xcalloc(
term->sixel.palette_size, sizeof(term->sixel.shared_palette[0]));
memcpy(
term->sixel.shared_palette, term->conf->colors_dark.sixel,
active_palette_entries * sizeof(term->sixel.shared_palette[0]));
if (term->sixel.linear_blending || term->sixel.use_10bit) {
for (size_t i = 0; i < active_palette_entries; i++) {
uint8_t r = (term->sixel.private_palette[i] >> 16) & 0xff;
uint8_t g = (term->sixel.private_palette[i] >> 8) & 0xff;
uint8_t b = (term->sixel.private_palette[i] >> 0) & 0xff;
term->sixel.private_palette[i] = color_decode_srgb(term, r, g, b);
}
}
term->sixel.shared_palette, term->conf->colors.sixel,
min(sizeof(term->conf->colors.sixel),
term->sixel.palette_size * sizeof(term->sixel.shared_palette[0])));
} else {
/* Shared palette - do *not* reset palette for new sixels */
}
@ -566,7 +488,7 @@ blend_new_image_over_old(const struct terminal *term,
int stride = new_width * sizeof(uint32_t);
uint32_t *new_data = xmalloc(stride * new_height);
pixman_image_t *pix2 = pixman_image_create_bits_no_clear(
term->sixel.pixman_fmt, new_width, new_height, new_data, stride);
PIXMAN_a8r8g8b8, new_width, new_height, new_data, stride);
#if defined(_DEBUG)
/* Fill new image with an easy-to-recognize color (green) */
@ -729,7 +651,8 @@ sixel_overwrite(struct terminal *term, struct sixel *six,
}
pixman_image_t *new_pix = pixman_image_create_bits_no_clear(
term->sixel.pixman_fmt, new_width, new_height, new_data, new_width * sizeof(uint32_t));
PIXMAN_a8r8g8b8,
new_width, new_height, new_data, new_width * sizeof(uint32_t));
struct sixel new_six = {
.pix = NULL,
@ -1025,7 +948,7 @@ sixel_sync_cache(const struct terminal *term, struct sixel *six)
uint8_t *scaled_data = xmalloc(scaled_height * scaled_stride);
pixman_image_t *scaled_pix = pixman_image_create_bits_no_clear(
term->sixel.pixman_fmt, scaled_width, scaled_height,
PIXMAN_a8r8g8b8, scaled_width, scaled_height,
(uint32_t *)scaled_data, scaled_stride);
pixman_image_composite32(
@ -1309,7 +1232,7 @@ sixel_unhook(struct terminal *term)
image.pos.row, image.pos.row + image.rows);
image.original.pix = pixman_image_create_bits_no_clear(
term->sixel.pixman_fmt, image.original.width, image.original.height,
PIXMAN_a8r8g8b8, image.original.width, image.original.height,
img_data, stride);
pixel_row_idx += height;
@ -1559,9 +1482,6 @@ resize(struct terminal *term, int new_width_mutable, int new_height_mutable)
new_height_mutable = term->sixel.max_height;
}
if (unlikely(new_height_mutable == 0)) {
new_height_mutable = 6 * term->sixel.pan;
}
uint32_t *old_data = term->sixel.image.data;
const int old_width = term->sixel.image.width;
@ -2086,14 +2006,15 @@ decgci(struct terminal *term, uint8_t c)
}
case 2: { /* RGB */
uint16_t r = 255 * min(c1, 100) / 100;
uint16_t g = 255 * min(c2, 100) / 100;
uint16_t b = 255 * min(c3, 100) / 100;
uint8_t r = 255 * min(c1, 100) / 100;
uint8_t g = 255 * min(c2, 100) / 100;
uint8_t b = 255 * min(c3, 100) / 100;
LOG_DBG("setting palette #%d = RGB %hu/%hu/%hu",
LOG_DBG("setting palette #%d = RGB %hhu/%hhu/%hhu",
term->sixel.color_idx, r, g, b);
term->sixel.palette[term->sixel.color_idx] = color_decode_srgb(term, r, g, b);
term->sixel.palette[term->sixel.color_idx] =
0xffu << 24 | r << 16 | g << 8 | b;
break;
}
}

50
slave.c
View file

@ -436,54 +436,8 @@ slave_spawn(int ptmx, int argc, const char *cwd, char *const *argv,
add_to_env(&custom_env, "COLORTERM", "truecolor");
add_to_env(&custom_env, "PWD", cwd);
del_from_env(&custom_env, "TERM_PROGRAM"); /* Wezterm, Ghostty */
del_from_env(&custom_env, "TERM_PROGRAM_VERSION"); /* Wezterm, Ghostty */
del_from_env(&custom_env, "TERMINAL_NAME"); /* Contour */
del_from_env(&custom_env, "TERMINAL_VERSION_STRING"); /* Contour */
del_from_env(&custom_env, "TERMINAL_VERSION_TRIPLE"); /* Contour */
/* XTerm specific */
del_from_env(&custom_env, "XTERM_SHELL");
del_from_env(&custom_env, "XTERM_VERSION");
del_from_env(&custom_env, "XTERM_LOCALE");
/* Mlterm specific */
del_from_env(&custom_env, "MLTERM");
/* Zutty specific */
del_from_env(&custom_env, "ZUTTY_VERSION");
/* Ghostty specific */
del_from_env(&custom_env, "GHOSTTY_BIN_DIR");
del_from_env(&custom_env, "GHOSTTY_SHELL_INTEGRATION_NO_SUDO");
del_from_env(&custom_env, "GHOSTTY_RESOURCES_DIR");
/* Kitty specific */
del_from_env(&custom_env, "KITTY_WINDOW_ID");
del_from_env(&custom_env, "KITTY_PID");
del_from_env(&custom_env, "KITTY_PUBLIC_KEY");
del_from_env(&custom_env, "KITTY_INSTALLATION_DIR");
/* Contour specific */
del_from_env(&custom_env, "CONTOUR_PROFILE");
/* Wezterm specific */
del_from_env(&custom_env, "WEZTERM_PANE");
del_from_env(&custom_env, "WEZTERM_EXECUTABLE");
del_from_env(&custom_env, "WEZTERM_CONFIG_FILE");
del_from_env(&custom_env, "WEZTERM_EXECUTABLE_DIR");
del_from_env(&custom_env, "WEZTERM_UNIX_SOCKET");
del_from_env(&custom_env, "WEZTERM_CONFIG_DIR");
/* Alacritty specific */
del_from_env(&custom_env, "ALACRITTY_LOG");
del_from_env(&custom_env, "ALACRITTY_WINDOW_ID");
del_from_env(&custom_env, "ALACRITTY_SOCKET");
/* VTE, gnome-terminal, kgx etc */
del_from_env(&custom_env, "VTE_VERSION");
del_from_env(&custom_env, "GNOME_TERMINAL_SERVICE");
del_from_env(&custom_env, "GNOME_TERMINAL_SCREEN");
del_from_env(&custom_env, "TERM_PROGRAM");
del_from_env(&custom_env, "TERM_PROGRAM_VERSION");
#if defined(FOOT_TERMINFO_PATH)
add_to_env(&custom_env, "TERMINFO", FOOT_TERMINFO_PATH);

View file

@ -27,7 +27,6 @@
#include "commands.h"
#include "config.h"
#include "debug.h"
#include "emoji-variation-sequences.h"
#include "extract.h"
#include "grid.h"
#include "ime.h"
@ -120,10 +119,7 @@ term_to_slave(struct terminal *term, const void *data, size_t len)
return false;
}
if (unlikely(tll_length(term->ptmx_buffers) > 0 ||
term->is_sending_paste_data ||
tll_length(term->ptmx_paste_buffers) > 0))
{
if (tll_length(term->ptmx_buffers) > 0 || term->is_sending_paste_data) {
/*
* Don't even try to send data *now* if there's queued up
* data, since that would result in events arriving out of
@ -202,7 +198,7 @@ add_utmp_record(const struct config *conf, struct reaper *reaper, int ptmx)
return true;
char *const argv[] = {conf->utmp_helper_path, UTMP_ADD, getenv("WAYLAND_DISPLAY"), NULL};
return spawn(reaper, NULL, argv, ptmx, -1, -1, NULL, NULL, NULL) >= 0;
return spawn(reaper, NULL, argv, ptmx, ptmx, -1, NULL, NULL, NULL) >= 0;
#else
return true;
#endif
@ -226,7 +222,7 @@ del_utmp_record(const struct config *conf, struct reaper *reaper, int ptmx)
;
char *const argv[] = {conf->utmp_helper_path, UTMP_DEL, del_argument, NULL};
return spawn(reaper, NULL, argv, ptmx, -1, -1, NULL, NULL, NULL) >= 0;
return spawn(reaper, NULL, argv, ptmx, ptmx, -1, NULL, NULL, NULL) >= 0;
#else
return true;
#endif
@ -391,16 +387,12 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
bool
term_ptmx_pause(struct terminal *term)
{
if (term->ptmx < 0)
return false;
return fdm_event_del(term->fdm, term->ptmx, EPOLLIN);
}
bool
term_ptmx_resume(struct terminal *term)
{
if (term->ptmx < 0)
return false;
return fdm_event_add(term->fdm, term->ptmx, EPOLLIN);
}
@ -722,9 +714,6 @@ initialize_render_workers(struct terminal *term)
goto err_sem_destroy;
}
mtx_init(&term->render.workers.preapplied_damage.lock, mtx_plain);
cnd_init(&term->render.workers.preapplied_damage.cond);
term->render.workers.threads = xcalloc(
term->render.workers.count, sizeof(term->render.workers.threads[0]));
@ -997,7 +986,6 @@ struct font_load_data {
const char **names;
const char *attrs;
const struct fcft_font_options *options;
struct fcft_font **font;
};
@ -1005,8 +993,7 @@ static int
font_loader_thread(void *_data)
{
struct font_load_data *data = _data;
*data->font = fcft_from_name2(
data->count, data->names, data->attrs, data->options);
*data->font = fcft_from_name(data->count, data->names, data->attrs);
return *data->font != NULL;
}
@ -1073,34 +1060,14 @@ reload_fonts(struct terminal *term, bool resize_grid)
[1] = xstrjoin(dpi, !custom_bold ? ":weight=bold" : ""),
[2] = xstrjoin(dpi, !custom_italic ? ":slant=italic" : ""),
[3] = xstrjoin(dpi, !custom_bold_italic ? ":weight=bold:slant=italic" : ""),
};
struct fcft_font_options *options = fcft_font_options_create();
options->scaling_filter = conf->tweak.fcft_filter;
options->color_glyphs.format = PIXMAN_a8r8g8b8;
options->color_glyphs.srgb_decode =
wayl_do_linear_blending(term->wl, term->conf);
if (shm_chain_bit_depth(term->render.chains.grid) >= SHM_BITS_10) {
/*
* Use a high-res buffer type for emojis. We don't want to use
* an a2r10g0b10 type of surface, since we need more than 2
* bits for alpha.
*/
#if defined(HAVE_PIXMAN_RGBA_16)
options->color_glyphs.format = PIXMAN_a16b16g16r16;
#else
options->color_glyphs.format = PIXMAN_rgba_float;
#endif
}
};
struct fcft_font *fonts[4];
struct font_load_data data[4] = {
{count_regular, names_regular, attrs[0], options, &fonts[0]},
{count_bold, names_bold, attrs[1], options, &fonts[1]},
{count_italic, names_italic, attrs[2], options, &fonts[2]},
{count_bold_italic, names_bold_italic, attrs[3], options, &fonts[3]},
{count_regular, names_regular, attrs[0], &fonts[0]},
{count_bold, names_bold, attrs[1], &fonts[1]},
{count_italic, names_italic, attrs[2], &fonts[2]},
{count_bold_italic, names_bold_italic, attrs[3], &fonts[3]},
};
thrd_t tids[4] = {0};
@ -1125,8 +1092,6 @@ reload_fonts(struct terminal *term, bool resize_grid)
success = false;
}
fcft_font_options_destroy(options);
for (size_t i = 0; i < 4; i++) {
for (size_t j = 0; j < counts[i]; j++)
free(names[i][j]);
@ -1267,19 +1232,6 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
goto err;
}
const enum shm_bit_depth desired_bit_depth =
conf->tweak.surface_bit_depth == SHM_BITS_AUTO
? wayl_do_linear_blending(wayl, conf) ? SHM_BITS_16 : SHM_BITS_8
: conf->tweak.surface_bit_depth;
const struct color_theme *theme = NULL;
switch (conf->initial_color_theme) {
case COLOR_THEME_DARK: theme = &conf->colors_dark; break;
case COLOR_THEME_LIGHT: theme = &conf->colors_light; break;
case COLOR_THEME_1: BUG("COLOR_THEME_1 should not be used"); break;
case COLOR_THEME_2: BUG("COLOR_THEME_2 should not be used"); break;
}
/* Initialize configure-based terminal attributes */
*term = (struct terminal) {
.fdm = fdm,
@ -1297,7 +1249,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
},
.font_dpi = 0.,
.font_dpi_before_unmap = -1.,
.font_subpixel = (theme->alpha == 0xffff /* Can't do subpixel rendering on transparent background */
.font_subpixel = (conf->colors.alpha == 0xffff /* Can't do subpixel rendering on transparent background */
? FCFT_SUBPIXEL_DEFAULT
: FCFT_SUBPIXEL_NONE),
.cursor_keys_mode = CURSOR_KEYS_NORMAL,
@ -1313,14 +1265,14 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
.state = 0, /* STATE_GROUND */
},
.colors = {
.fg = theme->fg,
.bg = theme->bg,
.alpha = theme->alpha,
.cursor_fg = (theme->use_custom.cursor ? 1u << 31 : 0) | theme->cursor.text,
.cursor_bg = (theme->use_custom.cursor ? 1u << 31 : 0) | theme->cursor.cursor,
.selection_fg = theme->selection_fg,
.selection_bg = theme->selection_bg,
.active_theme = conf->initial_color_theme,
.fg = conf->colors.fg,
.bg = conf->colors.bg,
.alpha = conf->colors.alpha,
.cursor_fg = conf->cursor.color.text,
.cursor_bg = conf->cursor.color.cursor,
.selection_fg = conf->colors.selection_fg,
.selection_bg = conf->colors.selection_bg,
.use_custom_selection = conf->colors.use_custom.selection,
},
.color_stack = {
.stack = NULL,
@ -1363,14 +1315,13 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
.wl = wayl,
.render = {
.chains = {
.grid = shm_chain_new(wayl, true, 1 + conf->render_worker_count,
desired_bit_depth, &render_buffer_release_callback, term),
.search = shm_chain_new(wayl, false, 1 ,desired_bit_depth, NULL, NULL),
.scrollback_indicator = shm_chain_new(wayl, false, 1, desired_bit_depth, NULL, NULL),
.render_timer = shm_chain_new(wayl, false, 1, desired_bit_depth, NULL, NULL),
.url = shm_chain_new(wayl, false, 1, desired_bit_depth, NULL, NULL),
.csd = shm_chain_new(wayl, false, 1, desired_bit_depth, NULL, NULL),
.overlay = shm_chain_new(wayl, false, 1, desired_bit_depth, NULL, NULL),
.grid = shm_chain_new(wayl->shm, true, 1 + conf->render_worker_count),
.search = shm_chain_new(wayl->shm, false, 1),
.scrollback_indicator = shm_chain_new(wayl->shm, false, 1),
.render_timer = shm_chain_new(wayl->shm, false, 1),
.url = shm_chain_new(wayl->shm, false, 1),
.csd = shm_chain_new(wayl->shm, false, 1),
.overlay = shm_chain_new(wayl->shm, false, 1),
},
.scrollback_lines = conf->scrollback.lines,
.app_sync_updates.timer_fd = app_sync_updates_fd,
@ -1417,7 +1368,6 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
pixman_region32_init(&term->render.last_overlay_clip);
term_update_ascii_printer(term);
memcpy(term->colors.table, theme->table, sizeof(term->colors.table));
for (size_t i = 0; i < 4; i++) {
const struct config_font_list *font_list = &conf->fonts[i];
@ -1452,6 +1402,8 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
xassert(tll_length(term->wl->monitors) > 0);
term->scale = tll_front(term->wl->monitors).scale;
memcpy(term->colors.table, term->conf->colors.table, sizeof(term->colors.table));
/* Initialize the Wayland window backend */
if ((term->window = wayl_win_init(term, token)) == NULL)
goto err;
@ -1511,9 +1463,6 @@ term_window_configured(struct terminal *term)
if (!term->shutdown.in_progress) {
xassert(term->window->is_configured);
fdm_add(term->fdm, term->ptmx, EPOLLIN, &fdm_ptmx, term);
const bool gamma_correct = wayl_do_linear_blending(term->wl, term->conf);
LOG_INFO("gamma-correct blending: %s", gamma_correct ? "enabled" : "disabled");
}
}
@ -1901,8 +1850,6 @@ term_destroy(struct terminal *term)
}
}
free(term->render.workers.threads);
mtx_destroy(&term->render.workers.preapplied_damage.lock);
cnd_destroy(&term->render.workers.preapplied_damage.cond);
mtx_destroy(&term->render.workers.lock);
sem_destroy(&term->render.workers.start);
sem_destroy(&term->render.workers.done);
@ -2077,25 +2024,12 @@ static inline void
erase_line(struct terminal *term, struct row *row)
{
erase_cell_range(term, row, 0, term->cols - 1);
row->linebreak = true;
row->linebreak = false;
row->shell_integration.prompt_marker = false;
row->shell_integration.cmd_start = -1;
row->shell_integration.cmd_end = -1;
}
static void
term_theme_apply(struct terminal *term, const struct color_theme *theme)
{
term->colors.fg = theme->fg;
term->colors.bg = theme->bg;
term->colors.alpha = theme->alpha;
term->colors.cursor_fg = (theme->use_custom.cursor ? 1u << 31 : 0) | theme->cursor.text;
term->colors.cursor_bg = (theme->use_custom.cursor ? 1u << 31 : 0) | theme->cursor.cursor;
term->colors.selection_fg = theme->selection_fg;
term->colors.selection_bg = theme->selection_bg;
memcpy(term->colors.table, theme->table, sizeof(term->colors.table));
}
void
term_reset(struct terminal *term, bool hard)
{
@ -2179,20 +2113,19 @@ term_reset(struct terminal *term, bool hard)
if (!hard)
return;
const struct color_theme *theme = NULL;
switch (term->conf->initial_color_theme) {
case COLOR_THEME_DARK: theme = &term->conf->colors_dark; break;
case COLOR_THEME_LIGHT: theme = &term->conf->colors_light; break;
case COLOR_THEME_1: BUG("COLOR_THEME_1 should not be used"); break;
case COLOR_THEME_2: BUG("COLOR_THEME_2 should not be used"); break;
}
term->flash.active = false;
term->blink.state = BLINK_ON;
fdm_del(term->fdm, term->blink.fd); term->blink.fd = -1;
term_theme_apply(term, theme);
term->colors.active_theme = term->conf->initial_color_theme;
term->colors.fg = term->conf->colors.fg;
term->colors.bg = term->conf->colors.bg;
term->colors.alpha = term->conf->colors.alpha;
term->colors.cursor_fg = term->conf->cursor.color.text;
term->colors.cursor_bg = term->conf->cursor.color.cursor;
term->colors.selection_fg = term->conf->colors.selection_fg;
term->colors.selection_bg = term->conf->colors.selection_bg;
term->colors.use_custom_selection = term->conf->colors.use_custom.selection;
memcpy(term->colors.table, term->conf->colors.table,
sizeof(term->colors.table));
free(term->color_stack.stack);
term->color_stack.stack = NULL;
term->color_stack.size = 0;
@ -2793,11 +2726,13 @@ UNITTEST
},
.kind = SELECTION_NONE,
.auto_scroll = {
.fd = -1,
.fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK),
},
},
};
xassert(term.selection.auto_scroll.fd >= 0);
#define populate_scrollback() do { \
for (int i = 0; i < scrollback_rows; i++) { \
if (term.normal.rows[i] == NULL) { \
@ -2887,7 +2822,7 @@ UNITTEST
/* Cleanup */
tll_free(term.normal.sixel_images);
xassert(term.selection.auto_scroll.fd == -1);
close(term.selection.auto_scroll.fd);
for (int i = 0; i < scrollback_rows; i++)
grid_row_free(term.normal.rows[i]);
free(term.normal.rows);
@ -2920,8 +2855,6 @@ term_cursor_to(struct terminal *term, int row, int col)
term->grid->cursor.point.col = col;
term->grid->cursor.point.row = row;
term_reset_grapheme_state(term);
term->grid->cur_row = grid_row(term->grid, row);
}
@ -2938,7 +2871,6 @@ term_cursor_col(struct terminal *term, int col)
term->grid->cursor.lcf = false;
term->grid->cursor.point.col = col;
term_reset_grapheme_state(term);
}
void
@ -2948,7 +2880,6 @@ term_cursor_left(struct terminal *term, int count)
term->grid->cursor.point.col -= move_amount;
xassert(term->grid->cursor.point.col >= 0);
term->grid->cursor.lcf = false;
term_reset_grapheme_state(term);
}
void
@ -2958,7 +2889,6 @@ term_cursor_right(struct terminal *term, int count)
term->grid->cursor.point.col += move_amount;
xassert(term->grid->cursor.point.col < term->cols);
term->grid->cursor.lcf = false;
term_reset_grapheme_state(term);
}
void
@ -3172,17 +3102,11 @@ term_scroll_reverse_partial(struct terminal *term,
sixel_scroll_down(term, rows);
const bool view_follows = term->grid->view == term->grid->offset;
bool view_follows = term->grid->view == term->grid->offset;
term->grid->offset -= rows;
term->grid->offset += term->grid->num_rows;
term->grid->offset &= term->grid->num_rows - 1;
/* How many lines from the scrollback start is the current viewport? */
const int view_sb_start_distance = grid_row_abs_to_sb(
term->grid, term->rows, term->grid->view);
const int offset_sb_start_distance = grid_row_abs_to_sb(
term->grid, term->rows, term->grid->offset);
xassert(term->grid->offset >= 0);
xassert(term->grid->offset < term->grid->num_rows);
@ -3190,11 +3114,6 @@ term_scroll_reverse_partial(struct terminal *term,
term_damage_scroll(term, DAMAGE_SCROLL_REVERSE, region, rows);
selection_view_up(term, term->grid->offset);
term->grid->view = term->grid->offset;
} else if (unlikely(view_sb_start_distance > offset_sb_start_distance)) {
/* Part of current view is being scrolled out */
int new_view = term->grid->offset;
selection_view_up(term, new_view);
term->grid->view = new_view;
}
/* Bottom non-scrolling region */
@ -3211,16 +3130,11 @@ term_scroll_reverse_partial(struct terminal *term,
erase_line(term, row);
}
if (unlikely(view_sb_start_distance > offset_sb_start_distance))
term_damage_view(term);
term->grid->cur_row = grid_row(term->grid, term->grid->cursor.point.row);
#if defined(_DEBUG)
for (int r = 0; r < term->rows; r++)
xassert(grid_row(term->grid, r) != NULL);
for (int r = 0; r < term->rows; r++)
xassert(grid_row_in_view(term->grid, r) != NULL);
#endif
}
@ -3239,14 +3153,13 @@ term_carriage_return(struct terminal *term)
void
term_linefeed(struct terminal *term)
{
term->grid->cur_row->linebreak = true;
term->grid->cursor.lcf = false;
if (term->grid->cursor.point.row == term->scroll_region.end - 1)
term_scroll(term, 1);
else
term_cursor_down(term, 1);
term_reset_grapheme_state(term);
}
void
@ -3427,13 +3340,10 @@ report_mouse_click(struct terminal *term, int encoded_button, int row, int col,
encoded_button, col + 1, row + 1, release ? 'm' : 'M');
break;
case MOUSE_SGR_PIXELS: {
const int bounded_col = max(col_pixels, 0);
const int bounded_row = max(row_pixels, 0);
case MOUSE_SGR_PIXELS:
snprintf(response, sizeof(response), "\033[<%d;%d;%d%c",
encoded_button, bounded_col + 1, bounded_row + 1, release ? 'm' : 'M');
encoded_button, col_pixels + 1, row_pixels + 1, release ? 'm' : 'M');
break;
}
case MOUSE_URXVT:
snprintf(response, sizeof(response), "\033[%d;%d;%dM",
@ -3614,9 +3524,7 @@ term_xcursor_update_for_seat(struct terminal *term, struct seat *seat)
if (seat->pointer.hidden)
shape = CURSOR_SHAPE_HIDDEN;
else if (cursor_string_to_server_shape(
term->mouse_user_cursor,
term->wl->shape_manager_version) != 0 ||
else if (cursor_string_to_server_shape(term->mouse_user_cursor) != 0 ||
render_xcursor_is_valid(seat, term->mouse_user_cursor))
{
shape = CURSOR_SHAPE_CUSTOM;
@ -3707,7 +3615,7 @@ term_set_app_id(struct terminal *term, const char *app_id)
term->app_id = NULL;
}
const size_t length = app_id != NULL ? strlen(app_id) : 0;
const size_t length = strlen(app_id);
if (length > 2048) {
/*
* Not sure if there's a limit in the protocol, or the
@ -3775,9 +3683,6 @@ term_bell(struct terminal *term)
}
}
if (term->conf->bell.system_bell)
wayl_win_ring_bell(term->window);
if (term->conf->bell.notify) {
notify_notify(term, &(struct notification){
.title = xstrdup("Bell"),
@ -3805,18 +3710,8 @@ term_bell(struct terminal *term)
bool
term_spawn_new(const struct terminal *term)
{
char *argv[4];
int argc = 0;
argv[argc++] = term->foot_exe;
if (term->conf->conf_path != NULL) {
argv[argc++] = "--config";
argv[argc++] = term->conf->conf_path;
}
argv[argc] = NULL;
return spawn(
term->reaper, term->cwd, argv,
term->reaper, term->cwd, (char *const []){term->foot_exe, NULL},
-1, -1, -1, NULL, NULL, NULL) >= 0;
}
@ -3924,7 +3819,7 @@ print_spacer(struct terminal *term, int col, int remaining)
struct cell *cell = &row->cells[col];
cell->wc = CELL_SPACER + remaining;
cell->attrs = (struct attributes){0};
cell->attrs = term->vt.attrs;
}
/*
@ -3994,7 +3889,7 @@ term_fill(struct terminal *term, int r, int c, uint8_t data, size_t count,
}
void
term_print(struct terminal *term, char32_t wc, int width, bool insert_mode_disable)
term_print(struct terminal *term, char32_t wc, int width)
{
xassert(width > 0);
@ -4016,8 +3911,7 @@ term_print(struct terminal *term, char32_t wc, int width, bool insert_mode_disab
}
print_linewrap(term);
if (!insert_mode_disable)
print_insert(term, width);
print_insert(term, width);
int col = grid->cursor.point.col;
@ -4046,11 +3940,9 @@ term_print(struct terminal *term, char32_t wc, int width, bool insert_mode_disab
cell->wc = term->vt.last_printed = wc;
cell->attrs = term->vt.attrs;
if (unlikely(term->vt.osc8.uri != NULL)) {
for (int i = 0; i < width && (col + i) < term->cols; i++) {
grid_row_uri_range_put(
row, col + i, term->vt.osc8.uri, term->vt.osc8.id);
}
if (term->vt.osc8.uri != NULL) {
grid_row_uri_range_put(
row, col, term->vt.osc8.uri, term->vt.osc8.id);
switch (term->conf->url.osc8_underline) {
case OSC8_UNDERLINE_ALWAYS:
@ -4091,7 +3983,7 @@ term_print(struct terminal *term, char32_t wc, int width, bool insert_mode_disab
static void
ascii_printer_generic(struct terminal *term, char32_t wc)
{
term_print(term, wc, 1, false);
term_print(term, wc, 1);
}
static void
@ -4173,260 +4065,6 @@ term_single_shift(struct terminal *term, enum charset_designator idx)
term->ascii_printer = &ascii_printer_single_shift;
}
#if defined(FOOT_GRAPHEME_CLUSTERING)
static int
emoji_vs_compare(const void *_key, const void *_entry)
{
const struct emoji_vs *key = _key;
const struct emoji_vs *entry = _entry;
uint32_t cp = key->start;
if (cp < entry->start)
return -1;
else if (cp > entry->end)
return 1;
else
return 0;
}
UNITTEST
{
/* Verify the emoji_vs list is sorted */
int64_t last_end = -1;
for (size_t i = 0; i < sizeof(emoji_vs) / sizeof(emoji_vs[0]); i++) {
const struct emoji_vs *vs = &emoji_vs[i];
xassert(vs->start <= vs->end);
xassert(vs->start > last_end);
xassert(vs->vs15 || vs->vs16);
last_end = vs->end;
}
}
#endif
void
term_process_and_print_non_ascii(struct terminal *term, char32_t wc)
{
int width = c32width(wc);
bool insert_mode_disable = false;
const bool grapheme_clustering = term->grapheme_shaping;
#if !defined(FOOT_GRAPHEME_CLUSTERING)
xassert(!grapheme_clustering);
#endif
if (term->grid->cursor.point.col > 0 &&
(grapheme_clustering ||
(!grapheme_clustering && width == 0 && wc >= 0x300)))
{
int col = term->grid->cursor.point.col;
if (!term->grid->cursor.lcf)
col--;
/* Skip past spacers */
struct row *row = term->grid->cur_row;
while (row->cells[col].wc >= CELL_SPACER && col > 0)
col--;
xassert(col >= 0 && col < term->cols);
char32_t base = row->cells[col].wc;
char32_t UNUSED last = base;
/* Is base cell already a cluster? */
const struct composed *composed =
(base >= CELL_COMB_CHARS_LO && base <= CELL_COMB_CHARS_HI)
? composed_lookup(term->composed, base - CELL_COMB_CHARS_LO)
: NULL;
uint32_t key;
if (composed != NULL) {
base = composed->chars[0];
last = composed->chars[composed->count - 1];
key = composed_key_from_key(composed->key, wc);
} else
key = composed_key_from_key(base, wc);
#if defined(FOOT_GRAPHEME_CLUSTERING)
if (grapheme_clustering) {
/* Check if we're on a grapheme cluster break */
if (utf8proc_grapheme_break_stateful(
last, wc, &term->vt.grapheme_state))
{
term_reset_grapheme_state(term);
goto out;
}
}
#endif
int base_width = c32width(base);
if (base_width > 0) {
term->grid->cursor.point.col = col;
term->grid->cursor.lcf = false;
insert_mode_disable = true;
if (composed == NULL) {
bool base_from_primary;
bool comb_from_primary;
bool pre_from_primary;
char32_t precomposed = term->fonts[0] != NULL
? fcft_precompose(
term->fonts[0], base, wc, &base_from_primary,
&comb_from_primary, &pre_from_primary)
: (char32_t)-1;
int precomposed_width = c32width(precomposed);
/*
* Only use the pre-composed character if:
*
* 1. we *have* a pre-composed character
* 2. the width matches the base characters width
* 3. it's in the primary font, OR one of the base or
* combining characters are *not* from the primary
* font
*/
if (precomposed != (char32_t)-1 &&
precomposed_width == base_width &&
(pre_from_primary ||
!base_from_primary ||
!comb_from_primary))
{
wc = precomposed;
width = precomposed_width;
term_reset_grapheme_state(term);
goto out;
}
}
size_t wanted_count = composed != NULL ? composed->count + 1 : 2;
if (wanted_count > 255) {
xassert(composed != NULL);
#if defined(LOG_ENABLE_DBG) && LOG_ENABLE_DBG
LOG_WARN("combining character overflow:");
LOG_WARN(" base: 0x%04x", composed->chars[0]);
for (size_t i = 1; i < composed->count; i++)
LOG_WARN(" cc: 0x%04x", composed->chars[i]);
LOG_ERR(" new: 0x%04x", wc);
#endif
/* This is going to break anyway... */
wanted_count--;
}
xassert(wanted_count <= 255);
/* Check if we already have a match for the entire compose chain */
const struct composed *cc =
composed_lookup_without_collision(
term->composed, &key,
composed != NULL ? composed->chars : &(char32_t){base},
composed != NULL ? composed->count : 1,
wc, 0);
if (cc != NULL) {
/* We *do* have a match! */
wc = CELL_COMB_CHARS_LO + cc->key;
width = cc->width;
goto out;
} else {
/* No match - allocate a new chain below */
}
if (unlikely(term->composed_count >=
(CELL_COMB_CHARS_HI - CELL_COMB_CHARS_LO)))
{
/* We reached our maximum number of allowed composed
* character chains. Fall through here and print the
* current zero-width character to the current cell */
LOG_WARN("maximum number of composed characters reached");
term_reset_grapheme_state(term);
goto out;
}
/* Allocate new chain */
struct composed *new_cc = xmalloc(sizeof(*new_cc));
new_cc->chars = xmalloc(wanted_count * sizeof(new_cc->chars[0]));
new_cc->key = key;
new_cc->count = wanted_count;
new_cc->chars[0] = base;
new_cc->chars[wanted_count - 1] = wc;
new_cc->forced_width = composed != NULL ? composed->forced_width : 0;
if (composed != NULL) {
memcpy(&new_cc->chars[1], &composed->chars[1],
(wanted_count - 2) * sizeof(new_cc->chars[0]));
}
const int grapheme_width =
composed != NULL ? composed->width : base_width;
switch (term->conf->tweak.grapheme_width_method) {
case GRAPHEME_WIDTH_MAX:
new_cc->width = max(grapheme_width, width);
break;
case GRAPHEME_WIDTH_DOUBLE:
new_cc->width = min(grapheme_width + width, 2);
#if defined(FOOT_GRAPHEME_CLUSTERING)
/* Handle VS-15 and VS-16 variation selectors */
if (unlikely(grapheme_clustering &&
(wc == 0xfe0e || wc == 0xfe0f) &&
new_cc->count == 2))
{
const struct emoji_vs *vs =
bsearch(
&(struct emoji_vs){.start = new_cc->chars[0]},
emoji_vs, sizeof(emoji_vs) / sizeof(emoji_vs[0]),
sizeof(struct emoji_vs),
&emoji_vs_compare);
if (vs != NULL) {
xassert(new_cc->chars[0] >= vs->start &&
new_cc->chars[0] <= vs->end);
/* Force a grapheme width of 1 for VS-15, and 2 for VS-16 */
if (wc == 0xfe0e) {
if (vs->vs15)
new_cc->width = 1;
} else if (wc == 0xfe0f) {
if (vs->vs16)
new_cc->width = 2;
}
}
}
#endif
break;
case GRAPHEME_WIDTH_WCSWIDTH:
new_cc->width = grapheme_width + width;
break;
}
term->composed_count++;
composed_insert(&term->composed, new_cc);
wc = CELL_COMB_CHARS_LO + new_cc->key;
width = new_cc->forced_width > 0 ? new_cc->forced_width : new_cc->width;
xassert(wc >= CELL_COMB_CHARS_LO);
xassert(wc <= CELL_COMB_CHARS_HI);
goto out;
}
} else
term_reset_grapheme_state(term);
out:
if (width > 0)
term_print(term, wc, width, insert_mode_disable);
}
enum term_surface
term_surface_kind(const struct terminal *term, const struct wl_surface *surface)
{
@ -4757,76 +4395,3 @@ term_send_size_notification(struct terminal *term)
term->rows, term->cols, height, width);
term_to_slave(term, buf, n);
}
void
term_theme_switch_to_dark(struct terminal *term)
{
if (term->colors.active_theme == COLOR_THEME_DARK)
return;
term_theme_apply(term, &term->conf->colors_dark);
term->colors.active_theme = COLOR_THEME_DARK;
wayl_win_alpha_changed(term->window);
term_font_subpixel_changed(term);
if (term->report_theme_changes)
term_to_slave(term, "\033[?997;1n", 9);
term_damage_view(term);
term_damage_margins(term);
render_refresh(term);
}
void
term_theme_switch_to_light(struct terminal *term)
{
if (term->colors.active_theme == COLOR_THEME_LIGHT)
return;
term_theme_apply(term, &term->conf->colors_light);
term->colors.active_theme = COLOR_THEME_LIGHT;
wayl_win_alpha_changed(term->window);
term_font_subpixel_changed(term);
if (term->report_theme_changes)
term_to_slave(term, "\033[?997;2n", 9);
term_damage_view(term);
term_damage_margins(term);
render_refresh(term);
}
void
term_theme_toggle(struct terminal *term)
{
if (term->colors.active_theme == COLOR_THEME_DARK) {
term_theme_apply(term, &term->conf->colors_light);
term->colors.active_theme = COLOR_THEME_LIGHT;
if (term->report_theme_changes)
term_to_slave(term, "\033[?997;2n", 9);
} else {
term_theme_apply(term, &term->conf->colors_dark);
term->colors.active_theme = COLOR_THEME_DARK;
if (term->report_theme_changes)
term_to_slave(term, "\033[?997;1n", 9);
}
wayl_win_alpha_changed(term->window);
term_font_subpixel_changed(term);
term_damage_view(term);
term_damage_margins(term);
render_refresh(term);
}
const struct color_theme *
term_theme_get(const struct terminal *term)
{
return term->colors.active_theme == COLOR_THEME_DARK
? &term->conf->colors_dark
: &term->conf->colors_light;
}

View file

@ -88,7 +88,7 @@ struct range {
struct cursor {
struct coord point;
bool lcf; /* Last Column Flag; https://github.com/mattiase/wraptest#basic-vt-line-wrapping-rules */
bool lcf;
};
enum damage_type {DAMAGE_SCROLL, DAMAGE_SCROLL_REVERSE,
@ -404,7 +404,7 @@ struct colors {
uint32_t cursor_bg; /* cursor color */
uint32_t selection_fg;
uint32_t selection_bg;
enum which_color_theme active_theme;
bool use_custom_selection;
};
struct terminal {
@ -517,7 +517,6 @@ struct terminal {
bool num_lock_modifier;
bool bell_action_enabled;
bool report_theme_changes;
/* Saved DECSET modes - we save the SET state */
struct {
@ -548,7 +547,6 @@ struct terminal {
bool ime:1;
bool app_sync_updates:1;
bool grapheme_shaping:1;
bool report_theme_changes:1;
bool size_notifications:1;
@ -706,14 +704,6 @@ struct terminal {
tll(int) queue;
thrd_t *threads;
struct buffer *buf;
struct {
mtx_t lock;
cnd_t cond;
struct buffer *buf;
struct timespec start;
struct timespec stop;
} preapplied_damage;
} workers;
/* Last rendered cursor position */
@ -724,8 +714,6 @@ struct terminal {
} last_cursor;
struct buffer *last_buf; /* Buffer we rendered to last time */
size_t frames_since_last_immediate_release;
bool preapply_last_frame_damage;
enum overlay_style last_overlay_style;
struct buffer *last_overlay_buf;
@ -789,10 +777,6 @@ struct terminal {
bool transparent_bg;
bool linear_blending;
bool use_10bit;
pixman_format_code_t pixman_fmt;
/* Application configurable */
unsigned palette_size; /* Number of colors in palette */
unsigned max_width; /* Maximum image width, in pixels */
@ -805,7 +789,6 @@ struct terminal {
bool urls_show_uri_on_jump_label;
struct grid *url_grid_snapshot;
bool ime_reenable_after_url_mode;
const struct config_spawn_template *url_launch;
#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED
bool ime_enabled;
@ -910,9 +893,7 @@ void term_cursor_up(struct terminal *term, int count);
void term_cursor_down(struct terminal *term, int count);
void term_cursor_blink_update(struct terminal *term);
void term_process_and_print_non_ascii(struct terminal *term, char32_t wc);
void term_print(struct terminal *term, char32_t wc, int width,
bool insert_mode_disable);
void term_print(struct terminal *term, char32_t wc, int width);
void term_fill(struct terminal *term, int row, int col, uint8_t c, size_t count,
bool use_sgr_attrs);
@ -994,11 +975,6 @@ void term_enable_size_notifications(struct terminal *term);
void term_disable_size_notifications(struct terminal *term);
void term_send_size_notification(struct terminal *term);
void term_theme_switch_to_dark(struct terminal *term);
void term_theme_switch_to_light(struct terminal *term);
void term_theme_toggle(struct terminal *term);
const struct color_theme *term_theme_get(const struct terminal *term);
static inline void term_reset_grapheme_state(struct terminal *term)
{
#if defined(FOOT_GRAPHEME_CLUSTERING)

View file

@ -106,6 +106,50 @@ test_c32string(struct context *ctx, bool (*parse_fun)(struct context *ctx),
}
}
static void
test_protocols(struct context *ctx, bool (*parse_fun)(struct context *ctx),
const char *key, char32_t **const *ptr)
{
ctx->key = key;
static const struct {
const char *option_string;
int count;
const char32_t *value[2];
bool invalid;
} input[] = {
{""},
{"http", 1, {U"http://"}},
{" http", 1, {U"http://"}},
{"http, https", 2, {U"http://", U"https://"}},
{"longprotocolislong", 1, {U"longprotocolislong://"}},
};
for (size_t i = 0; i < ALEN(input); i++) {
ctx->value = input[i].option_string;
if (input[i].invalid) {
if (parse_fun(ctx)) {
BUG("[%s].%s=%s: did not fail to parse as expected",
ctx->section, ctx->key, &ctx->value[0]);
}
} else {
if (!parse_fun(ctx)) {
BUG("[%s].%s=%s: failed to parse",
ctx->section, ctx->key, &ctx->value[0]);
}
for (int c = 0; c < input[i].count; c++) {
if (c32cmp((*ptr)[c], input[i].value[c]) != 0) {
BUG("[%s].%s=%s: set value[%d] (%ls) not the expected one (%ls)",
ctx->section, ctx->key, &ctx->value[c], c,
(const wchar_t *)(*ptr)[c],
(const wchar_t *)input[i].value[c]);
}
}
}
}
}
static void
test_boolean(struct context *ctx, bool (*parse_fun)(struct context *ctx),
const char *key, const bool *ptr)
@ -399,16 +443,6 @@ test_color(struct context *ctx, bool (*parse_fun)(struct context *ctx),
BUG("[%s].%s=%s: failed to parse",
ctx->section, ctx->key, ctx->value);
}
uint32_t color = input[i].color;
if (alpha_allowed && strlen(input[i].option_string) == 6)
color |= 0xff000000;
if (*ptr != color) {
BUG("[%s].%s=%s: expected 0x%08x, got 0x%08x",
ctx->section, ctx->key, ctx->value,
color, *ptr);
}
}
}
}
@ -455,18 +489,6 @@ test_two_colors(struct context *ctx, bool (*parse_fun)(struct context *ctx),
BUG("[%s].%s=%s: failed to parse",
ctx->section, ctx->key, ctx->value);
}
if (*ptr1 != input[i].color1) {
BUG("[%s].%s=%s: expected 0x%08x, got 0x%08x",
ctx->section, ctx->key, ctx->value,
input[i].color1, *ptr1);
}
if (*ptr2 != input[i].color2) {
BUG("[%s].%s=%s: expected 0x%08x, got 0x%08x",
ctx->section, ctx->key, ctx->value,
input[i].color2, *ptr2);
}
}
}
}
@ -482,7 +504,6 @@ test_section_main(void)
test_string(&ctx, &parse_section_main, "shell", &conf.shell);
test_string(&ctx, &parse_section_main, "term", &conf.term);
test_string(&ctx, &parse_section_main, "app-id", &conf.app_id);
test_string(&ctx, &parse_section_main, "toplevel-tag", &conf.toplevel_tag);
test_string(&ctx, &parse_section_main, "utmp-helper", &conf.utmp_helper_path);
test_c32string(&ctx, &parse_section_main, "word-delimiters", &conf.word_delimiters);
@ -490,9 +511,8 @@ test_section_main(void)
test_boolean(&ctx, &parse_section_main, "login-shell", &conf.login_shell);
test_boolean(&ctx, &parse_section_main, "box-drawings-uses-font-glyphs", &conf.box_drawings_uses_font_glyphs);
test_boolean(&ctx, &parse_section_main, "locked-title", &conf.locked_title);
test_boolean(&ctx, &parse_section_main, "notify-focus-inhibit", &conf.desktop_notifications.inhibit_when_focused); /* Deprecated */
test_boolean(&ctx, &parse_section_main, "dpi-aware", &conf.dpi_aware);
test_boolean(&ctx, &parse_section_main, "gamma-correct-blending", &conf.gamma_correct);
test_boolean(&ctx, &parse_section_main, "uppercase-regex-insert", &conf.uppercase_regex_insert);
test_pt_or_px(&ctx, &parse_section_main, "font-size-adjustment", &conf.font_size_adjustment.pt_or_px); /* TODO: test N% values too */
test_pt_or_px(&ctx, &parse_section_main, "line-height", &conf.line_height);
@ -505,6 +525,8 @@ test_section_main(void)
test_uint16(&ctx, &parse_section_main, "resize-delay-ms", &conf.resize_delay_ms);
test_uint16(&ctx, &parse_section_main, "workers", &conf.render_worker_count);
test_spawn_template(&ctx, &parse_section_main, "notify", &conf.desktop_notifications.command); /* Deprecated */
test_enum(&ctx, &parse_section_main, "selection-target",
4,
(const char *[]){"none", "primary", "clipboard", "both"},
@ -521,14 +543,6 @@ test_section_main(void)
(int []){STARTUP_WINDOWED, STARTUP_MAXIMIZED, STARTUP_FULLSCREEN},
(int *)&conf.startup_mode);
test_enum(
&ctx, &parse_section_main, "initial-color-theme",
2,
(const char *[]){"dark", "light", "1", "2"},
(int []){COLOR_THEME_DARK, COLOR_THEME_LIGHT,
COLOR_THEME_DARK, COLOR_THEME_LIGHT},
(int *)&conf.initial_color_theme);
/* TODO: font (custom) */
/* TODO: include (custom) */
/* TODO: bold-text-in-bright (enum/boolean) */
@ -565,7 +579,6 @@ test_section_bell(void)
test_boolean(&ctx, &parse_section_bell, "urgent", &conf.bell.urgent);
test_boolean(&ctx, &parse_section_bell, "notify", &conf.bell.notify);
test_boolean(&ctx, &parse_section_bell, "system", &conf.bell.system_bell);
test_boolean(&ctx, &parse_section_bell, "command-focused",
&conf.bell.command_focused);
test_spawn_template(&ctx, &parse_section_bell, "command",
@ -633,6 +646,9 @@ test_section_url(void)
(int []){OSC8_UNDERLINE_URL_MODE, OSC8_UNDERLINE_ALWAYS},
(int *)&conf.url.osc8_underline);
test_c32string(&ctx, &parse_section_url, "label-letters", &conf.url.label_letters);
test_protocols(&ctx, &parse_section_url, "protocols", &conf.url.protocols);
/* TODO: uri-characters (wchar string, but sorted) */
config_free(&conf);
}
@ -703,161 +719,64 @@ test_section_touch(void)
}
static void
test_section_colors_dark(void)
test_section_colors(void)
{
struct config conf = {0};
struct context ctx = {
.conf = &conf, .section = "colors-dark", .path = "unittest"};
.conf = &conf, .section = "colors", .path = "unittest"};
test_invalid_key(&ctx, &parse_section_colors, "invalid-key");
test_color(&ctx, &parse_section_colors_dark, "foreground", false, &conf.colors_dark.fg);
test_color(&ctx, &parse_section_colors_dark, "background", false, &conf.colors_dark.bg);
test_color(&ctx, &parse_section_colors_dark, "regular0", false, &conf.colors_dark.table[0]);
test_color(&ctx, &parse_section_colors_dark, "regular1", false, &conf.colors_dark.table[1]);
test_color(&ctx, &parse_section_colors_dark, "regular2", false, &conf.colors_dark.table[2]);
test_color(&ctx, &parse_section_colors_dark, "regular3", false, &conf.colors_dark.table[3]);
test_color(&ctx, &parse_section_colors_dark, "regular4", false, &conf.colors_dark.table[4]);
test_color(&ctx, &parse_section_colors_dark, "regular5", false, &conf.colors_dark.table[5]);
test_color(&ctx, &parse_section_colors_dark, "regular6", false, &conf.colors_dark.table[6]);
test_color(&ctx, &parse_section_colors_dark, "regular7", false, &conf.colors_dark.table[7]);
test_color(&ctx, &parse_section_colors_dark, "bright0", false, &conf.colors_dark.table[8]);
test_color(&ctx, &parse_section_colors_dark, "bright1", false, &conf.colors_dark.table[9]);
test_color(&ctx, &parse_section_colors_dark, "bright2", false, &conf.colors_dark.table[10]);
test_color(&ctx, &parse_section_colors_dark, "bright3", false, &conf.colors_dark.table[11]);
test_color(&ctx, &parse_section_colors_dark, "bright4", false, &conf.colors_dark.table[12]);
test_color(&ctx, &parse_section_colors_dark, "bright5", false, &conf.colors_dark.table[13]);
test_color(&ctx, &parse_section_colors_dark, "bright6", false, &conf.colors_dark.table[14]);
test_color(&ctx, &parse_section_colors_dark, "bright7", false, &conf.colors_dark.table[15]);
test_color(&ctx, &parse_section_colors_dark, "dim0", false, &conf.colors_dark.dim[0]);
test_color(&ctx, &parse_section_colors_dark, "dim1", false, &conf.colors_dark.dim[1]);
test_color(&ctx, &parse_section_colors_dark, "dim2", false, &conf.colors_dark.dim[2]);
test_color(&ctx, &parse_section_colors_dark, "dim3", false, &conf.colors_dark.dim[3]);
test_color(&ctx, &parse_section_colors_dark, "dim4", false, &conf.colors_dark.dim[4]);
test_color(&ctx, &parse_section_colors_dark, "dim5", false, &conf.colors_dark.dim[5]);
test_color(&ctx, &parse_section_colors_dark, "dim6", false, &conf.colors_dark.dim[6]);
test_color(&ctx, &parse_section_colors_dark, "dim7", false, &conf.colors_dark.dim[7]);
test_color(&ctx, &parse_section_colors_dark, "selection-foreground", false, &conf.colors_dark.selection_fg);
test_color(&ctx, &parse_section_colors_dark, "selection-background", false, &conf.colors_dark.selection_bg);
test_color(&ctx, &parse_section_colors_dark, "urls", false, &conf.colors_dark.url);
test_two_colors(&ctx, &parse_section_colors_dark, "jump-labels", false,
&conf.colors_dark.jump_label.fg,
&conf.colors_dark.jump_label.bg);
test_two_colors(&ctx, &parse_section_colors_dark, "scrollback-indicator", false,
&conf.colors_dark.scrollback_indicator.fg,
&conf.colors_dark.scrollback_indicator.bg);
test_two_colors(&ctx, &parse_section_colors_dark, "search-box-no-match", false,
&conf.colors_dark.search_box.no_match.fg,
&conf.colors_dark.search_box.no_match.bg);
test_two_colors(&ctx, &parse_section_colors_dark, "search-box-match", false,
&conf.colors_dark.search_box.match.fg,
&conf.colors_dark.search_box.match.bg);
test_two_colors(&ctx, &parse_section_colors_dark, "cursor", false,
&conf.colors_dark.cursor.text,
&conf.colors_dark.cursor.cursor);
test_enum(&ctx, &parse_section_colors_dark, "alpha-mode", 3,
(const char *[]){"default", "matching", "all"},
(int []){ALPHA_MODE_DEFAULT, ALPHA_MODE_MATCHING, ALPHA_MODE_ALL},
(int *)&conf.colors_dark.alpha_mode);
test_enum(&ctx, &parse_section_colors_dark, "dim-blend-towards", 2,
(const char *[]){"black", "white"},
(int []){DIM_BLEND_TOWARDS_BLACK, DIM_BLEND_TOWARDS_WHITE},
(int *)&conf.colors_dark.dim_blend_towards);
test_color(&ctx, &parse_section_colors, "foreground", false, &conf.colors.fg);
test_color(&ctx, &parse_section_colors, "background", false, &conf.colors.bg);
test_color(&ctx, &parse_section_colors, "regular0", false, &conf.colors.table[0]);
test_color(&ctx, &parse_section_colors, "regular1", false, &conf.colors.table[1]);
test_color(&ctx, &parse_section_colors, "regular2", false, &conf.colors.table[2]);
test_color(&ctx, &parse_section_colors, "regular3", false, &conf.colors.table[3]);
test_color(&ctx, &parse_section_colors, "regular4", false, &conf.colors.table[4]);
test_color(&ctx, &parse_section_colors, "regular5", false, &conf.colors.table[5]);
test_color(&ctx, &parse_section_colors, "regular6", false, &conf.colors.table[6]);
test_color(&ctx, &parse_section_colors, "regular7", false, &conf.colors.table[7]);
test_color(&ctx, &parse_section_colors, "bright0", false, &conf.colors.table[8]);
test_color(&ctx, &parse_section_colors, "bright1", false, &conf.colors.table[9]);
test_color(&ctx, &parse_section_colors, "bright2", false, &conf.colors.table[10]);
test_color(&ctx, &parse_section_colors, "bright3", false, &conf.colors.table[11]);
test_color(&ctx, &parse_section_colors, "bright4", false, &conf.colors.table[12]);
test_color(&ctx, &parse_section_colors, "bright5", false, &conf.colors.table[13]);
test_color(&ctx, &parse_section_colors, "bright6", false, &conf.colors.table[14]);
test_color(&ctx, &parse_section_colors, "bright7", false, &conf.colors.table[15]);
test_color(&ctx, &parse_section_colors, "dim0", false, &conf.colors.dim[0]);
test_color(&ctx, &parse_section_colors, "dim1", false, &conf.colors.dim[1]);
test_color(&ctx, &parse_section_colors, "dim2", false, &conf.colors.dim[2]);
test_color(&ctx, &parse_section_colors, "dim3", false, &conf.colors.dim[3]);
test_color(&ctx, &parse_section_colors, "dim4", false, &conf.colors.dim[4]);
test_color(&ctx, &parse_section_colors, "dim5", false, &conf.colors.dim[5]);
test_color(&ctx, &parse_section_colors, "dim6", false, &conf.colors.dim[6]);
test_color(&ctx, &parse_section_colors, "dim7", false, &conf.colors.dim[7]);
test_color(&ctx, &parse_section_colors, "selection-foreground", false, &conf.colors.selection_fg);
test_color(&ctx, &parse_section_colors, "selection-background", false, &conf.colors.selection_bg);
test_color(&ctx, &parse_section_colors, "urls", false, &conf.colors.url);
test_two_colors(&ctx, &parse_section_colors, "jump-labels", false,
&conf.colors.jump_label.fg,
&conf.colors.jump_label.bg);
test_two_colors(&ctx, &parse_section_colors, "scrollback-indicator", false,
&conf.colors.scrollback_indicator.fg,
&conf.colors.scrollback_indicator.bg);
test_two_colors(&ctx, &parse_section_colors, "search-box-no-match", false,
&conf.colors.search_box.no_match.fg,
&conf.colors.search_box.no_match.bg);
test_two_colors(&ctx, &parse_section_colors, "search-box-match", false,
&conf.colors.search_box.match.fg,
&conf.colors.search_box.match.bg);
for (size_t i = 0; i < 255; i++) {
char key_name[4];
sprintf(key_name, "%zu", i);
test_color(&ctx, &parse_section_colors_dark, key_name, false,
&conf.colors_dark.table[i]);
test_color(&ctx, &parse_section_colors, key_name, false,
&conf.colors.table[i]);
}
test_boolean(&ctx, &parse_section_colors_dark, "blur", &conf.colors_dark.blur);
test_invalid_key(&ctx, &parse_section_colors_dark, "256");
/* TODO: alpha (float in range 0-1, converted to uint16_t) */
config_free(&conf);
}
static void
test_section_colors_light(void)
{
struct config conf = {0};
struct context ctx = {
.conf = &conf, .section = "colors-light", .path = "unittest"};
test_invalid_key(&ctx, &parse_section_colors, "invalid-key");
test_color(&ctx, &parse_section_colors_light, "foreground", false, &conf.colors_light.fg);
test_color(&ctx, &parse_section_colors_light, "background", false, &conf.colors_light.bg);
test_color(&ctx, &parse_section_colors_light, "regular0", false, &conf.colors_light.table[0]);
test_color(&ctx, &parse_section_colors_light, "regular1", false, &conf.colors_light.table[1]);
test_color(&ctx, &parse_section_colors_light, "regular2", false, &conf.colors_light.table[2]);
test_color(&ctx, &parse_section_colors_light, "regular3", false, &conf.colors_light.table[3]);
test_color(&ctx, &parse_section_colors_light, "regular4", false, &conf.colors_light.table[4]);
test_color(&ctx, &parse_section_colors_light, "regular5", false, &conf.colors_light.table[5]);
test_color(&ctx, &parse_section_colors_light, "regular6", false, &conf.colors_light.table[6]);
test_color(&ctx, &parse_section_colors_light, "regular7", false, &conf.colors_light.table[7]);
test_color(&ctx, &parse_section_colors_light, "bright0", false, &conf.colors_light.table[8]);
test_color(&ctx, &parse_section_colors_light, "bright1", false, &conf.colors_light.table[9]);
test_color(&ctx, &parse_section_colors_light, "bright2", false, &conf.colors_light.table[10]);
test_color(&ctx, &parse_section_colors_light, "bright3", false, &conf.colors_light.table[11]);
test_color(&ctx, &parse_section_colors_light, "bright4", false, &conf.colors_light.table[12]);
test_color(&ctx, &parse_section_colors_light, "bright5", false, &conf.colors_light.table[13]);
test_color(&ctx, &parse_section_colors_light, "bright6", false, &conf.colors_light.table[14]);
test_color(&ctx, &parse_section_colors_light, "bright7", false, &conf.colors_light.table[15]);
test_color(&ctx, &parse_section_colors_light, "dim0", false, &conf.colors_light.dim[0]);
test_color(&ctx, &parse_section_colors_light, "dim1", false, &conf.colors_light.dim[1]);
test_color(&ctx, &parse_section_colors_light, "dim2", false, &conf.colors_light.dim[2]);
test_color(&ctx, &parse_section_colors_light, "dim3", false, &conf.colors_light.dim[3]);
test_color(&ctx, &parse_section_colors_light, "dim4", false, &conf.colors_light.dim[4]);
test_color(&ctx, &parse_section_colors_light, "dim5", false, &conf.colors_light.dim[5]);
test_color(&ctx, &parse_section_colors_light, "dim6", false, &conf.colors_light.dim[6]);
test_color(&ctx, &parse_section_colors_light, "dim7", false, &conf.colors_light.dim[7]);
test_color(&ctx, &parse_section_colors_light, "selection-foreground", false, &conf.colors_light.selection_fg);
test_color(&ctx, &parse_section_colors_light, "selection-background", false, &conf.colors_light.selection_bg);
test_color(&ctx, &parse_section_colors_light, "urls", false, &conf.colors_light.url);
test_two_colors(&ctx, &parse_section_colors_light, "jump-labels", false,
&conf.colors_light.jump_label.fg,
&conf.colors_light.jump_label.bg);
test_two_colors(&ctx, &parse_section_colors_light, "scrollback-indicator", false,
&conf.colors_light.scrollback_indicator.fg,
&conf.colors_light.scrollback_indicator.bg);
test_two_colors(&ctx, &parse_section_colors_light, "search-box-no-match", false,
&conf.colors_light.search_box.no_match.fg,
&conf.colors_light.search_box.no_match.bg);
test_two_colors(&ctx, &parse_section_colors_light, "search-box-match", false,
&conf.colors_light.search_box.match.fg,
&conf.colors_light.search_box.match.bg);
test_two_colors(&ctx, &parse_section_colors_light, "cursor", false,
&conf.colors_light.cursor.text,
&conf.colors_light.cursor.cursor);
test_enum(&ctx, &parse_section_colors_light, "alpha-mode", 3,
(const char *[]){"default", "matching", "all"},
(int []){ALPHA_MODE_DEFAULT, ALPHA_MODE_MATCHING, ALPHA_MODE_ALL},
(int *)&conf.colors_light.alpha_mode);
test_enum(&ctx, &parse_section_colors_light, "dim-blend-towards", 2,
(const char *[]){"black", "white"},
(int []){DIM_BLEND_TOWARDS_BLACK, DIM_BLEND_TOWARDS_WHITE},
(int *)&conf.colors_light.dim_blend_towards);
for (size_t i = 0; i < 255; i++) {
char key_name[4];
sprintf(key_name, "%zu", i);
test_color(&ctx, &parse_section_colors_light, key_name, false,
&conf.colors_light.table[i]);
}
test_boolean(&ctx, &parse_section_colors_light, "blur", &conf.colors_light.blur);
test_invalid_key(&ctx, &parse_section_colors_light, "256");
test_invalid_key(&ctx, &parse_section_colors, "256");
/* TODO: alpha (float in range 0-1, converted to uint16_t) */
@ -923,7 +842,7 @@ static void
test_key_binding(struct context *ctx, bool (*parse_fun)(struct context *ctx),
int action, int max_action, const char *const *map,
struct config_key_binding_list *bindings,
enum key_binding_type type, bool need_argv, bool need_section_id)
enum key_binding_type type)
{
xassert(map[action] != NULL);
xassert(bindings->count == 0);
@ -935,10 +854,7 @@ test_key_binding(struct context *ctx, bool (*parse_fun)(struct context *ctx),
const bool alt = action % 3;
const bool shift = action % 4;
const bool super = action % 5;
const bool argv = need_argv;
const bool section_id = need_section_id;
xassert(!(argv && section_id));
const bool argv = action % 6;
static const char *const args[] = {
"command", "arg1", "arg2", "arg3 has spaces"};
@ -977,7 +893,7 @@ test_key_binding(struct context *ctx, bool (*parse_fun)(struct context *ctx),
xkb_keysym_get_name(sym, sym_name, sizeof(sym_name));
snprintf(value, sizeof(value), "%s%s%s",
argv ? "[command arg1 arg2 \"arg3 has spaces\"] " : section_id ? "[foobar]" : "",
argv ? "[command arg1 arg2 \"arg3 has spaces\"] " : "",
modifier_string, sym_name);
break;
}
@ -986,7 +902,7 @@ test_key_binding(struct context *ctx, bool (*parse_fun)(struct context *ctx),
const char *const button_name = button_map[button_idx].name;
int chars = snprintf(
value, sizeof(value), "%s%s%s",
argv ? "[command arg1 arg2 \"arg3 has spaces\"] " : section_id ? "[foobar]" : "",
argv ? "[command arg1 arg2 \"arg3 has spaces\"] " : "",
modifier_string, button_name);
xassert(click_count > 0);
@ -1027,18 +943,6 @@ test_key_binding(struct context *ctx, bool (*parse_fun)(struct context *ctx),
ctx->section, ctx->key, ctx->value,
ALEN(args), binding->aux.pipe.args[ALEN(args)]);
}
} else if (section_id) {
if (binding->aux.regex_name == NULL) {
BUG("[%s].%s=%s: regex name is NULL",
ctx->section, ctx->key, ctx->value);
}
if (!streq(binding->aux.regex_name, "foobar")) {
BUG("[%s].%s=%s: regex name not the expected one: "
"expected=\"%s\", got=\"%s\"",
ctx->section, ctx->key, ctx->value,
"foobar", binding->aux.regex_name);
}
} else {
if (binding->aux.pipe.args != NULL) {
BUG("[%s].%s=%s: pipe argv not NULL",
@ -1234,9 +1138,7 @@ test_section_key_bindings(void)
test_key_binding(
&ctx, &parse_section_key_bindings,
action, BIND_ACTION_KEY_COUNT - 1,
binding_action_map, &conf.bindings.key, KEY_BINDING,
action >= BIND_ACTION_PIPE_SCROLLBACK && action <= BIND_ACTION_PIPE_COMMAND_OUTPUT,
action >= BIND_ACTION_REGEX_LAUNCH && action <= BIND_ACTION_REGEX_COPY);
binding_action_map, &conf.bindings.key, KEY_BINDING);
}
config_free(&conf);
@ -1271,8 +1173,7 @@ test_section_search_bindings(void)
test_key_binding(
&ctx, &parse_section_search_bindings,
action, BIND_ACTION_SEARCH_COUNT - 1,
search_binding_action_map, &conf.bindings.search, KEY_BINDING,
false, false);
search_binding_action_map, &conf.bindings.search, KEY_BINDING);
}
config_free(&conf);
@ -1308,8 +1209,7 @@ test_section_url_bindings(void)
test_key_binding(
&ctx, &parse_section_url_bindings,
action, BIND_ACTION_URL_COUNT - 1,
url_binding_action_map, &conf.bindings.url, KEY_BINDING,
false, false);
url_binding_action_map, &conf.bindings.url, KEY_BINDING);
}
config_free(&conf);
@ -1345,8 +1245,7 @@ test_section_mouse_bindings(void)
test_key_binding(
&ctx, &parse_section_mouse_bindings,
action, BIND_ACTION_COUNT - 1,
binding_action_map, &conf.bindings.mouse, MOUSE_BINDING,
false, false);
binding_action_map, &conf.bindings.mouse, MOUSE_BINDING);
}
config_free(&conf);
@ -1510,9 +1409,6 @@ test_section_tweak(void)
test_float(&ctx, &parse_section_tweak, "bold-text-in-bright-amount",
&conf.bold_in_bright.amount);
test_uint32(&ctx, &parse_section_tweak, "min-stride-alignment",
&conf.tweak.min_stride_alignment);
#if 0 /* Must be equal to, or less than INT32_MAX */
test_uint32(&ctx, &parse_section_tweak, "max-shm-pool-size-mb",
&conf.tweak.max_shm_pool_size);
@ -1535,8 +1431,7 @@ main(int argc, const char *const *argv)
test_section_cursor();
test_section_mouse();
test_section_touch();
test_section_colors_dark();
test_section_colors_light();
test_section_colors();
test_section_csd();
test_section_key_bindings();
test_section_key_bindings_collisions();

View file

@ -1,8 +1,10 @@
# -*- conf -*-
# Aero root theme
[colors-dark]
cursor=1a1a1a 9fd5f5
[cursor]
color=1a1a1a 9fd5f5
[colors]
foreground=dedeef
background=1a1a1a

View file

@ -1,57 +0,0 @@
# -*- conf -*-
# Alacritty
[colors-dark]
cursor = 181818 d8d8d8
background= 181818
foreground= d8d8d8
#black
regular0= 181818
#red
regular1= ac4242
#green
regular2= 90a959
#yellow
regular3= f4bf75
#blue
regular4= 6a9fb5
#magenta
regular5= aa759f
#cyan
regular6= 75b5aa
#white/grey
regular7= d8d8d8
#grey/black
bright0= 6b6b6b
#red
bright1= c55555
#green
bright2= aac474
#yellow
bright3= feca88
#blue
bright4= 82b8c8
#pink
bright5= c28cb8
#cyan
bright6= 93d3c3
#grey
bright7= f8f8f8

View file

@ -1,8 +1,10 @@
# -*- conf -*-
# https://github.com/romainl/Apprentice
[colors-dark]
cursor=262626 6c6c6c
[cursor]
color=262626 6c6c6c
[colors]
foreground=bcbcbc
background=262626
regular0=1c1c1c

View file

@ -2,8 +2,10 @@
# theme: Ayu Mirage
# description: a theme based on Ayu Mirage for Sublime Text (original: https://github.com/dempfi/ayu)
[colors-dark]
cursor = ffcc66 665a44
[cursor]
color = ffcc66 665a44
[colors]
foreground = cccac2
background = 242936

View file

@ -1,7 +1,7 @@
# _*_ conf _*_
# Catppuccin Frappe
[colors-dark]
[colors]
foreground=c6d0f5
background=303446
@ -23,11 +23,6 @@ bright5=f4b8e4
bright6=81c8be
bright7=a5adce
cursor=232634 f2d5cf
16=ef9f76
17=f2d5cf
selection-foreground=c6d0f5
selection-background=4f5369

View file

@ -1,10 +1,7 @@
# _*_ conf _*_
# Catppuccin Latte
[main]
initial-color-theme=light
[colors-light]
[colors]
foreground=4c4f69
background=eff1f5
@ -26,11 +23,6 @@ bright5=ea76cb
bright6=179299
bright7=bcc0cc
cursor=eff1f5 dc8a78
16=fe640b
17=dc8a78
selection-foreground=4c4f69
selection-background=ccced7

View file

@ -1,7 +1,7 @@
# _*_ conf _*_
# Catppuccin Macchiato
[colors-dark]
[colors]
foreground=cad3f5
background=24273a
@ -23,11 +23,6 @@ bright5=f5bde6
bright6=8bd5ca
bright7=a5adcb
cursor=181926 f4dbd6
16=f5a97f
17=f4dbd6
selection-foreground=cad3f5
selection-background=454a5f

View file

@ -1,7 +1,7 @@
# _*_ conf _*_
# Catppuccin Mocha
[colors-dark]
[colors]
foreground=cdd6f4
background=1e1e2e
@ -23,11 +23,6 @@ bright5=f5c2e7
bright6=94e2d5
bright7=a6adc8
cursor=11111b f5e0dc
16=fab387
17=f5e0dc
selection-foreground=cdd6f4
selection-background=414356

View file

@ -3,8 +3,10 @@
# author: ayushnix (https://sr.ht/~ayushnix)
# description: A dark theme with bright cyberpunk colors (WCAG AAA compliant)
[colors-dark]
cursor = 181818 cdcdcd
[cursor]
color = 181818 cdcdcd
[colors]
foreground = cdcdcd
background = 181818
regular0 = 181818

View file

@ -1,8 +1,10 @@
# -*- conf -*-
# Derp
[colors-dark]
cursor=000000 ffffff
[cursor]
color=000000 ffffff
[colors]
foreground=ffffff
background=000000
regular0=111111

View file

@ -2,8 +2,10 @@
# Deus
# Color palette based on: https://github.com/ajmwagar/vim-deus
[colors-dark]
cursor=2c323b eaeaea
[cursor]
color=2c323b eaeaea
[colors]
background=2c323b
foreground=eaeaea
regular0=242a32

View file

@ -1,8 +1,10 @@
# -*- conf -*-
# Dracula
[colors-dark]
cursor=282a36 f8f8f2
[cursor]
color=282a36 f8f8f2
[colors]
foreground=f8f8f2
background=282a36
regular0=000000 # black

View file

@ -1,8 +1,10 @@
# -*- conf -*-
# Dracula iTerm2 variant
[colors-dark]
cursor=ffffff bbbbbb
[cursor]
color=ffffff bbbbbb
[colors]
foreground=f8f8f2
background=1e1f29
regular0=000000 # black

View file

@ -5,11 +5,10 @@
# text and the white background.
# author: Eugen Rahaian <eugen@rah.ro>
[main]
initial-color-theme=light
[cursor]
color=ffffff 515151
[colors-light]
cursor=ffffff 515151
[colors]
background= ffffff
foreground= 000000

View file

@ -1,42 +0,0 @@
# -*- conf -*-
# Gruvbox
[colors-dark]
background=282828
foreground=ebdbb2
regular0=282828
regular1=cc241d
regular2=98971a
regular3=d79921
regular4=458588
regular5=b16286
regular6=689d6a
regular7=a89984
bright0=928374
bright1=fb4934
bright2=b8bb26
bright3=fabd2f
bright4=83a598
bright5=d3869b
bright6=8ec07c
bright7=ebdbb2
[colors-light]
background=fbf1c7
foreground=3c3836
regular0=fbf1c7
regular1=cc241d
regular2=98971a
regular3=d79921
regular4=458588
regular5=b16286
regular6=689d6a
regular7=7c6f64
bright0=928374
bright1=9d0006
bright2=79740e
bright3=b57614
bright4=076678
bright5=8f3f71
bright6=427b58
bright7=3c3836

View file

@ -1,7 +1,7 @@
# -*- conf -*-
# Gruvbox
[colors-dark]
[colors]
background=282828
foreground=ebdbb2
regular0=282828

View file

@ -1,10 +1,7 @@
# -*- conf -*-
# Gruvbox - Light
[main]
initial-color-theme=light
[colors-light]
[colors]
background=fbf1c7
foreground=3c3836
regular0=fbf1c7

View file

@ -1,7 +1,8 @@
# -*- conf -*-
[cursor]
color=141414 c9c9c9
[colors-dark]
cursor=141414 c9c9c9
[colors]
foreground=c9c9c9
background=141414
regular0=191918 # black

View file

@ -2,7 +2,7 @@
# this foot theme is based on alacritty iterm theme:
# https://github.com/alacritty/alacritty-theme/blob/master/themes/iterm.toml
[colors-dark]
[colors]
foreground=fffbf6
background=101421

View file

@ -2,8 +2,10 @@
# JetBrains Darcula
# Palette based on the same theme from https://github.com/dexpota/kitty-themes
[colors-dark]
cursor=202020 ffffff
[cursor]
color=202020 ffffff
[colors]
background=202020
foreground=adadad
regular0=000000 # black

View file

@ -1,7 +1,9 @@
# -*- conf -*-
[colors-dark]
cursor=111111 cccccc
[cursor]
color=111111 cccccc
[colors]
foreground=dddddd
background=000000
regular0=000000 # black

View file

@ -2,11 +2,10 @@
# Material Amber
# Based on material.io guidelines with Amber 50 background
[main]
initial-color-theme=light
[cursor]
color=fff8e1 21201d
[colors-light]
cursor=fff8e1 21201d
[colors]
foreground = 21201d
background = fff8e1

View file

@ -2,7 +2,7 @@
# Material
# From https://github.com/MartinSeeler/iterm2-material-design
[colors-dark]
[colors]
foreground=ECEFF1
background=263238
regular0=546E7A # black

View file

@ -3,11 +3,7 @@
# modus-operandi
# See: https://protesilaos.com/emacs/modus-themes
#
[main]
initial-color-theme=light
[colors-light]
[colors]
background=ffffff
foreground=000000
regular0=000000
@ -26,5 +22,3 @@ bright4=2544bb
bright5=5317ac
bright6=005a5f
bright7=ffffff
jump-labels=dce0e8 0000ff

View file

@ -4,7 +4,7 @@
# See: https://protesilaos.com/emacs/modus-themes
#
[colors-dark]
[colors]
background=000000
foreground=ffffff
regular0=000000

View file

@ -1,25 +0,0 @@
# -*- conf -*-
#
# modus-vivendi-tinted
# See: https://protesilaos.com/emacs/modus-themes
#
[colors-dark]
background=0d0e1c
foreground=ffffff
regular0=000000
regular1=ff5f59
regular2=44bc44
regular3=d0bc00
regular4=2fafff
regular5=feacd0
regular6=00d3d0
regular7=a6a6a6
bright0=595959
bright1=ff6b55
bright2=ff6b55
bright3=fec43f
bright4=fec43f
bright5=b6a0ff
bright6=6ae4b9
bright7=777777

View file

@ -1,23 +0,0 @@
# -*- conf -*-
# Molokai
# Based on zhou13's at https://github.com/zhou13/molokai-terminal/blob/master/xterm/Xresources
[colors-dark]
background=1B1D1E
foreground=CCCCCC
regular0=1B1D1E
regular1=FF0044
regular2=82B414
regular3=FD971F
regular4=266C98
regular5=AC0CB1
regular6=AE81FF
regular7=CCCCCC
bright0=808080
bright1=F92672
bright2=A6E22E
bright3=E6DB74
bright4=7070F0
bright5=D63AE1
bright6=66D9EF
bright7=F8F8F2

Some files were not shown because too many files have changed in this diff Show more