Commit graph

232 commits

Author SHA1 Message Date
Daniel Eklöf
ae6bbce6c2
meson: bump version to 1.14.0 2023-04-03 18:52:42 +02:00
Daniel Eklöf
9937d92c85
utils: xtgettcap: new utility, to send XTGETTCAP queries 2022-10-07 14:40:22 +02:00
Daniel Eklöf
aa10b1d2da
Add support for creating utmp records
This patch adds support for creating utmp records using the ‘utempter’
helper binary from the ‘libutempter’ package.

* New config option ‘main.utempter’
* New meson command line option, -Ddefault-utempter-path. Defaults to
  auto-detecting the path.

The default value of the new ‘main.utempter’ config option depends on
the meson command line option ‘-Ddefault-utempter-path’.

If ‘main.utempter’ is *not* set to ‘none’, foot will try to execute
the utempter helper binary to create utmp records when a new terminal
is instantiated. The record is removed when the terminal instance is
destroyed.
2022-09-23 23:02:25 +02:00
Vladimír Magyar
debf1b8453
chore: rename desktop files 2022-09-18 17:57:11 +02:00
Daniel Eklöf
cd1933baf1
meson: bump version to 1.13.1 2022-08-31 19:19:15 +02:00
Daniel Eklöf
e0465d3a7a
meson: bump version to 1.13.0 2022-08-07 09:32:02 +02:00
Daniel Eklöf
8967dd9cfe
input: add new Unicode input mode
This mode is activated through the new key-bindings.unicode-input and
search-bindings.unicode-input key bindings.

When active, the user can “build” a Unicode codepoint by typing its
hexadecimal value.

Note that there’s no visual feedback in this mode. This is
intentional. This mode is intended to be a fallback for users that
don’t use an IME.

Closes #1116
2022-07-29 09:26:31 +02:00
Daniel Eklöf
fabffd626b
wayland: log human readable SHM format names in debug builds 2022-06-20 18:58:40 +02:00
Daniel Eklöf
15d45d5704
meson: -Dsystemd-units-dir installs even if systemd is not found
If -Dsystemd-units-dir is explicitly set, then install the systemd
service files regardless of whether systemd is available or not.
2022-05-12 13:46:06 +02:00
Daniel Eklöf
62fe452cc2
meson: add -Dsystemd-units-dir=<path> meson command line option
This allows package maintainers to override the location to which our
systemd service files are installed.

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

The default is ${systemduserunitdir}.
2022-05-12 13:45:53 +02:00
Daniel Eklöf
e95269447f
meson: bump version to 1.12.1 2022-04-27 20:06:09 +02:00
Daniel Eklöf
ea1171a5a2
meson: bump version to 1.12.0 2022-04-22 17:14:41 +02:00
Daniel Eklöf
c7248cf763
meson: add -Dtests=false|true option
When set to false, no test binaries are neither built, nor
executed (with “ninja test”).

Closes #919
2022-04-22 17:05:25 +02:00
Merlin Büge
e6f884a9e1
doc + meson.build: update information about foot.ini, small cleanup
- foot.ini.5: mention location of example config file
- foot.1: replace outdated (or incomplete) information about the
  location of the config file with references to foot.ini.5
- foot.1 and foot.ini.5: conform to scdoc specification, thus surround each
  header with (at least) one blank line. additionally consistently use exactly
  one line before/after each header (was sometimes two before)
- foot.1: some parts of the keybindings had their own section, move into
  KEYBOARD SHORTCUTS section
- foot.1: move EXIT STATUS section to the end where it is commonly found
- foot.1: copy information about config file handling from the beginning of
  foot.ini.5 into the CONFIGURATION section of foot.1
- INSTALL.md: foot.ini is no longer included in the documentation
- meson.build: do not bundle foot.ini with documentation anymore, see also
  https://codeberg.org/dnkl/foot/pulls/1015

Closes #1002
2022-04-22 17:00:04 +02:00
Daniel Eklöf
90a2ca966f
key-binding: new API, for handling sets of key bindings
Up until now, our Wayland seats have been tracking key bindings. This
makes sense, since the seat’s keymap determines how the key bindings
are resolved.

However, tying bindings to the seat/keymap alone isn’t enough, since
we also depend on the current configuration (i.e. user settings) when
resolving a key binding.

This means configurations that doesn’t match the wayland object’s
configuration, currently don’t resolve key bindings correctly. This
applies to footclients where the user has overridden key bindings on
the command line (e.g. --override key-bindings.foo=bar).

Thus, to correctly resolve key bindings, each set of key bindings must
be tied *both* to a seat/keymap, *and* a configuration.

This patch introduces a key-binding manager, with an API to
add/remove/lookup, and load/unload keymaps from sets of key bindings.

In the API, sets are tied to a seat and terminal instance, since this
makes the most sense (we need to instantiate, or incref a set whenever
a new terminal instance is created). Internally, the set is tied to a
seat and the terminal’s configuration.

Sets are *added* when a new seat is added, and when a new terminal
instance is created. Since there can only be one instance of each
seat, sets are always removed when a seat is removed.

Terminals on the other hand can re-use the same configuration (and
typically do). Thus, sets ref-count the configuration. In other words,
when instantiating a new terminal, we may not have to instantiate a
new set of key bindings, but can often be incref:ed instead.

Whenever the keymap changes on a seat, all key bindings sets
associated with that seat reloads (re-resolves) their key bindings.

Closes #931
2022-04-17 15:39:51 +02:00
Daniel Eklöf
e95bc9283e
meson: install foot.ini to /etc/xdg/foot/foot.ini
Closes #1001
2022-04-17 11:27:53 +02:00
Daniel Eklöf
9b343fd9fb
meson: stop using deprecated functions, require meson >= 0.58
* get_pkgconfig_variable() -> get_variable()
* prog.path() -> prog.full_path()
* meson.build_root() -> meson.global_build_root()
2022-02-27 11:28:11 +01:00
Max Gautier
1783f69cbd Adding systemd unit files for socket activation
- Support for multiples concurrent instances, templated on
  WAYLAND_DISPLAY
- Use standard input for the socket file descriptor (inetd style)
- Always use the socket provided by systemd with the systemd user
  service
- wayland-instance@.target is intended to be a special target a bit like
  graphical-session.target.
2022-02-26 16:09:30 +01:00
Daniel Eklöf
990a15250a
meson: fcft-3.0.0 is buggy, require 3.0.1
Fcft-3.0.0 is known to cause crashes. We don’t want anyone ever
compiling foot against it.

Closes #935
2022-02-09 21:48:34 +01:00
Daniel Eklöf
3fea7829fa
meson: bump version to 1.11.0 2022-02-05 17:20:27 +01:00
Daniel Eklöf
e0227266ca
fcft: adapt to API changes in fcft-3.x
Fcft no longer uses wchar_t, but plain uint32_t to represent
codepoints.

Since we do a fair amount of string operations in foot, it still makes
sense to use something that actually _is_ a string (or character),
rather than an array of uint32_t.

For this reason, we switch out all wchar_t usage in foot to
char32_t. We also verify, at compile-time, that char32_t used
UTF-32 (which is what fcft expects).

Unfortunately, there are no string functions for char32_t. To avoid
having to re-implement all wcs*() functions, we add a small wrapper
layer of c32*() functions.

These wrapper functions take char32_t arguments, but then simply call
the corresponding wcs*() function.

For this to work, wcs*() must _also_ be UTF-32 compatible. We can
check for the presence of the  __STDC_ISO_10646__ macro. If set,
wchar_t is at least 4 bytes and its internal representation is UTF-32.

FreeBSD does *not* define this macro, because its internal wchar_t
representation depends on the current locale. It _does_ use UTF-32
_if_ the current locale is UTF-8.

Since foot enforces UTF-8, we simply need to check if __FreeBSD__ is
defined.

Other fcft API changes:

* fcft_glyph_rasterize() -> fcft_codepoint_rasterize()
* font.space_advance has been removed
* ‘tags’ have been removed from fcft_grapheme_rasterize()
* ‘fcft_log_init()’ removed
* ‘fcft_init()’ and ‘fcft_fini()’ must be explicitly called
2022-02-05 17:00:54 +01:00
Daniel Eklöf
379e68916e
meson: fix race build order of builtin terminfo
The builtin terminfo is used by dcs.c, which is built as part of the
static library ‘vtlib’. Thus, vtlib needs to depend on the
builtin_terminfo target.
2022-01-15 17:15:45 +01:00
Daniel Eklöf
b8fc56ecb4
script: add generate-builtin-terminfo.py
This script parses a terminfo source file and generates a C header
file with a static struct containing terminfo names and their values.

The table is sorted on the capability names
2022-01-13 13:42:11 +01:00
Daniel Eklöf
9df537a110
meson: generate-version: use CURRENT_SOURCE_DIR instead of SOURCE_ROOT 2021-12-21 13:40:54 +01:00
Daniel Eklöf
e1c3bdc6f2
test: initial external unit test suite for ‘config.c’
This patch adds a separate (external) test binary with unit tests for
config.c

This is achieved by having the test’s source file include
config.c (yes, the C file, not the header file).

This allows us to call e.g. parse_section_*() directly, without having
to go through config_load() (which requires having a readable file at
“path”).
2021-12-11 18:52:05 +01:00
Daniel Eklöf
a9026f16a7
meson: bump version to 1.10.3 2021-12-08 18:09:50 +01:00
Daniel Eklöf
46994a3e25
meson: bump version to 1.10.2 2021-12-02 20:26:59 +01:00
Daniel Eklöf
5eded7292c
meson: bump version to 1.10.1 2021-11-22 22:01:28 +01:00
Daniel Eklöf
843ba49565
footclient.desktop: new XDG desktop file, for footclient 2021-11-15 12:14:51 +01:00
Daniel Eklöf
31966f5494
meson: add -Dthemes=false|true
This adds a new meson option that controls whether the example theme
files should be installed or not. The default is true.

Previously, themes were gated by the -Ddocs option.
2021-11-14 23:12:18 +01:00
Daniel Eklöf
589404b32e
meson: bump version to 1.10.0 2021-11-14 18:12:30 +01:00
Daniel Eklöf
eebec8e38d
meson: install themes to $datadir/foot/themes 2021-10-27 17:31:02 +02:00
Craig Barnes
2e87889279 osc: use STRLEN() macro to make parse_rgb() more self-documenting
The empty literals in the macro are to ensure the argument itself
is a string literal, so it can't be used on anything else.
2021-10-20 17:05:36 +01:00
Daniel Eklöf
af3f489967
meson/pkgbuild: bump version to 1.9.2 2021-10-02 14:47:14 +02:00
Daniel Eklöf
c1f18360c2
meson/pkgbuild: bump version to 1.9.1 2021-10-01 20:52:33 +02:00
Daniel Eklöf
9434066546
meson: terminfo install location now defaults to $datadir/terminfo
The meson command line option -Dcustom-terminfo-install-location has
been changed in the following ways:

* If unset, $datadir/terminfo is used, and TERMINFO is *not* exported
* If set, that value (relative to $prefix) is used, and TERMINFO *is*
exported.
* The special value ‘no’ is removed.

-Ddefault-terminfo now also changes the terminfo names generated when
-Dterminfo=enabled.

Furthermore, the documentation for the TERMINFO environment variable
has been removed from the foot.1 and footclient.1 man pages (but as
mentioned above, foot *will* still set it if
-Dcustom-terminfo-install-location has been used).

INSTALL.md has been updated to now recommend using ncurses’ terminfo
definitions, if available. But also to document the other
alternatives; installing the terminfo definitions in a custom
location, or installing them with a diferent name. It also describes
the general problem, and the disadvantages of each alternative (but
without going into too much depth).
2021-08-30 19:09:13 +02:00
Daniel Eklöf
fec5f8784b
meson/pkgbuild: bump version to 1.9.0 2021-08-27 13:32:21 +02:00
Daniel Eklöf
88b2808dcd
meson: run generate_version.sh in a C locale
Previously, only the date command inside the script was run with
LC_TIME=C.

But there’s no reason to be that conservative; we absolutely do not
want _anything_ in that script to generate locale dependent output.
2021-08-25 19:12:45 +02:00
Daniel Eklöf
7639186865
terminfo: install to $datadir/foot/terminfo by default, append to TERMINFO_DIRS
As of 2021-07-31, ncurses ships its own version of foot’s terminfo.

Since:

* It doesn’t have the non-standard Sync,Tc,setrgbf,setrgbb
  capabilities.
* It doesn’t set hs,fsl,dsl (statusbar).
* We want to be able to update our termminfo without waiting for an
  ncurses release.
* Foot should be installable and usable on Linux systems that doesn’t
  have the latest ncurses.

we still want to ship our own version. We can however not install it
to the default terminfo location (e.g. /usr/share/terminfo), since it
will collide with the ncurses provided files.

Our options are to either rename our terminfo to something else, or to
keep the name, but install our terminfo files somewhere else.

The first option would be the easy one. However, I think it makes
sense to use the same name. For example, a user that SSH’s into a
remote system that does *not* have our own version installed,
but *does* have the ncurses one, will gracefully fall back to that
one, which is better than manually having to set
e.g. TERM=xterm-256color.

Now, if we want to use the same name, we need to install it somewhere
else. But where? And how do we ensure our version is preferred over
the ncurses one?

I opted to $datadir/foot/terminfo (e.g. /usr/share/foot/terminfo) by
default. It makes it namespaced to foot (i.e. we’re not introducing a
new “standard” terminfo location), thus guaranteeing it wont collide
with ncurses.

To enable applications to find it, we export TERMINFO_DIRS. This is a
list of *additional* directories to search for terminfo files. If it’s
already defined, we *append* to it.

The nice thing with this is, if there’s no terminfo in that
location (e.g. when you SSH into a remote), the default terminfo
location is *also* searched. But only *after* having searched through
TERMINFO_DIRS.

In short: our version is preferred, but the ncurses one (or an older
version of our terminfo package!) will be used if ours cannot be
found.

To enable packagers full control over the new behavior, the existing
meson command line options have been modified, and a new option added:

-Dterminfo=disabled|enabled|auto: *build* and *install* the terminfo
files.

-Dcustom-terminfo-install-location=<path>: *where* the terminfo files
are expected to be found.

This *needs* to be set *even* if -Dterminfo=disabled. For example, if
the packaging script builds and packages the terminfo files separate
from the regular foot build. The path is *relative to $prefix*, and
defaults to $datadir/foot/terminfo.

This is the value that will be appended to TERMINFO_DIRS. Note that
you can set it to ‘no’, in which case foot will *not* set/modify
TERMINFO_DIRS. Only do this if you don’t intend to package foot’s
terminfo files at all (i.e. you plan on using the ncurses ones only).

-Ddefault-terminfo=foot. Allows overriding the default TERM
value. This should only be changed if the target platform doesn’t
support terminfo files.

Closes #671
2021-08-17 21:04:30 +02:00
Daniel Eklöf
f9ba2a8c5c
meson: require meson >= 0.54
We use meson.override_dependency, which was added in 0.54
2021-08-08 10:44:25 +02:00
Daniel Eklöf
7c686208a1
meson: add -Ddocs=disabled|enabled|auto command line option
When enabled (the default, if scdoc is found), we build and install
the man pages, example foot.ini, readme, changelog and license files.
2021-07-24 13:12:10 +02:00
Daniel Eklöf
cd8c96d746
meson/pkgbuild: bump version to 1.8.2 2021-07-18 17:58:05 +02:00
Daniel Eklöf
1d488bb6a7
meson/pkgbuild: bump version to 1.8.1 2021-07-01 20:14:35 +02:00
Daniel Eklöf
0a455174f4
meson/pkgbuild: bump version to 1.8.0 2021-06-25 08:24:42 +02:00
Daniel Eklöf
ad981930c3
meson: add utf8proc dep to all libraries pulling in terminal.h 2021-06-24 20:29:15 +02:00
Daniel Eklöf
fe8ca23cfe
composed: store compose chains in a binary search tree
The previous implementation stored compose chains in a dynamically
allocated array. Adding a chain was easy: resize the array and append
the new chain at the end. Looking up a compose chain given a compose
chain key/index was also easy: just index into the array.

However, searching for a pre-existing chain given a codepoint sequence
was very slow. Since the array wasn’t sorted, we typically had to scan
through the entire array, just to realize that there is no
pre-existing chain, and that we need to add a new one.

Since this happens for *each* codepoint in a grapheme cluster, things
quickly became really slow.

Things were ok:ish as long as the compose chain struct was small, as
that made it possible to hold all the chains in the cache. Once the
number of chains reached a certain point, or when we were forced to
bump maximum number of allowed codepoints in a chain, we started
thrashing the cache and things got much much worse.

So what can we do?

We can’t sort the array, because

a) that would invalidate all existing chain keys in the grid (and
iterating the entire scrollback and updating compose keys is *not* an
option).

b) inserting a chain becomes slow as we need to first find _where_ to
insert it, and then memmove() the rest of the array.

This patch uses a binary search tree to store the chains instead of a
simple array.

The tree is sorted on a “key”, which is the XOR of all codepoints,
truncated to the CELL_COMB_CHARS_HI-CELL_COMB_CHARS_LO range.

The grid now stores CELL_COMB_CHARS_LO+key, instead of
CELL_COMB_CHARS_LO+index.

Since the key is truncated, collisions may occur. This is handled by
incrementing the key by 1.

Lookup is of course slower than before, O(log n) instead of
O(1).

Insertion is slightly slower as well: technically it’s O(log n)
instead of O(1). However, we also need to take into account the
re-allocating the array will occasionally force a full copy of the
array when it cannot simply be growed.

But finding a pre-existing chain is now *much* faster: O(log n)
instead of O(n). In most cases, the first lookup will either
succeed (return a true match), or fail (return NULL). However, since
key collisions are possible, it may also return false matches. This
means we need to verify the contents of the chain before deciding to
use it instead of inserting a new chain. But remember that this
comparison was being done for each and every chain in the previous
implementation.

With lookups being much faster, and in particular, no longer requiring
us to check the chain contents for every singlec chain, we can now use
a dynamically allocated ‘chars’ array in the chain. This was
previously a hardcoded array of 10 chars.

Using a dynamic allocated array means looking in the array is slower,
since we now need two loads: one to load the pointer, and a second to
load _from_ the pointer.

As a result, the base size of a compose chain (i.e. an “empty” chain)
has now been reduced from 48 bytes to 32. A chain with two codepoints
is 40 bytes. This means we have up to 4 codepoints while still using
less, or the same amount, of memory as before.

Furthermore, the Unicode random test (i.e. write random “unicode”
chars) is now **faster** than current master (i.e. before text-shaping
support was added), **with** test-shaping enabled. With text-shaping
disabled, we’re _even_ faster.
2021-06-24 17:30:49 +02:00
Daniel Eklöf
b9ef703eb1
wip: grapheme shaping 2021-06-24 17:30:45 +02:00
Daniel Eklöf
6268fc536b
meson: add -Dterminfo-install-location=disabled|custom-path
Add a new meson option, ‘terminfo-install-location’, that allows you
to customize _where_ the terminfo files are installed, relative to the
installation prefix.

It also recognizes the special value ‘disabled’, in which case the
terminfo files are not installed at all. The terminfo files _are_
however built (allowing us to catch build errors), and foot still
defaults to the ‘foot’ terminfo.

It defaults to $datadir/terminfo

If (the other option) ‘terminfo’ is set to disabled (or tic cannot be
found), terminfo-install-location is automatically set to ‘disabled’.
2021-06-23 16:43:36 +02:00
Daniel Eklöf
136d60606a
client: send overrides for everything that is publicly visible in the conf
Send a generic “overrides” list to the server, containing options in
text, on the format “section.key=value”.

This reduces the size of the base client/server protocol packet, as
well as opens up for a generic -o,--override command line option (not
yet implemented).
2021-06-23 15:12:08 +02:00
Daniel Eklöf
03e1b906ab
meson: add xdg-activation-v1.xml conditionally
Only enable XDG activation when compiling against wayland-protocols
1.21. Older versions don’t have this protocol.

When available, define HAVE_XDG_ACTIVATION.

Make all usages of xdg_activation_v1 and xdg_activation_token_v1
conditional.
2021-05-14 13:26:13 +02:00