Commit graph

212 commits

Author SHA1 Message Date
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
Daniel Eklöf
3e92361534
xdg-activation: initial support for setting urgency using XDG activation 2021-05-14 13:26:04 +02:00
Daniel Eklöf
96ae2d2bd7
meson: require fcft >= 2.4 2021-05-07 11:31:33 +02:00
Daniel Eklöf
7edda924a0
meson: add ‘xkb’ as a dependency to vtlib, pgolib and pgo
All of these include wayland.h (either directly, or indirectly), which
pulls in xkbcommon.h.

Reported by swayyyy on IRC:

  FAILED: libvtlib.a.p/dcs.c.o

  In file included from ../../terminal.h:19,
                   from ../../dcs.h:4,
                   from ../../dcs.c:1:
  ../../wayland.h:9:10: fatal error: xkbcommon/xkbcommon.h: No such file or directory
      9 | #include <xkbcommon/xkbcommon.h>
        |          ^
2021-05-01 22:47:35 +02:00
Daniel Eklöf
4044b6fa99
Merge branch 'releases/1.7' 2021-04-18 20:16:48 +02:00
Daniel Eklöf
0d4e61bbe8
meson/pkgbuild: bump version to 1.7.2 2021-04-18 20:12:40 +02:00
Daniel Eklöf
353c2f012a
main: call fcft_log_init(). Note that this requires fcft >= 2.3.90 2021-04-17 19:31:17 +02:00
Daniel Eklöf
ca89f977b5
meson/pkgbuild: bump version to 1.7.1 2021-03-28 14:25:29 +02:00
Daniel Eklöf
b5ceed7b2b
meson: replace log+debug+xmalloc static libraries with a single ‘common’ library
There are cyclic dependencies between the log, debug and xmalloc
libraries. While having them as separate static libraries work, as
long as consumers of them link against all of them, having them in a
single library feels slightly better.
2021-03-27 13:20:54 +01:00
Daniel Eklöf
ae6a656f49
meson: only build the pgo helper binary when -Db_pgo=generate
This is the only time it’s needed.

In non-PGO builds, it is completely unnecessary, and we’re only
wasting CPU cycles building it.

In full PGO builds, with -Db_pgo=use, we get link warnings and/or
failures, depending on compiler, since the pgo binary hasn’t been
executed.
2021-03-26 20:34:18 +01:00
Daniel Eklöf
c6fb10863d
meson: build source files common to both foot and footclient as libraries
Source files used by both foot and footclient are now compiled as
static libraries, which foot and footclient links against.
2021-03-26 20:31:09 +01:00
Daniel Eklöf
9b20764f35
features: --version now logs +/-pgo
That is, whether the binary was compiled with PGO or not.
2021-03-26 20:30:13 +01:00
Daniel Eklöf
c1a64bfb14
meson/pkgbuild: bump version to 1.7.0 2021-03-20 14:01:29 +01:00
Daniel Eklöf
928b819934
meson: SOURCE_DIR is not a valid macro in custom_target()
But appears to have been allowed in older versions of meson.

Fixes an issue where foot’s version was always reported as the last
stable release, even though it was a git build.
2021-03-11 17:30:00 +01:00
Craig Barnes
2e31a1ec7a meson: bump minimum xkbcommon version to 1.0.0
This requirement is due to the recently added maybe_repair_key_combo()
function, which is making use of xkb_keymap_key_get_mods_for_level().

See also: commit a5b554761a.
2021-03-07 19:28:17 +00:00
Daniel Eklöf
2a99c5a093
user-notification: add new function ‘user_notification_add()’ 2021-02-12 21:42:53 +01:00
Daniel Eklöf
df1ed1c8cf
Merge branch 'releases/1.6' 2021-02-12 21:41:53 +01:00
Daniel Eklöf
dcd4f1ca79
meson/pkgbuild: bump version to 1.6.4 2021-02-12 21:27:47 +01:00
Craig Barnes
5437321f97 main: client: factor out some common code for "--log-level" option 2021-02-11 11:08:18 +00:00
Daniel Eklöf
2cc84db979
urls: initial support for detecting URLs and rendering jump-labels
The jump labels work, but is currently hardcoded to use xdg-open
2021-02-07 16:33:31 +01:00
Daniel Eklöf
c4363ef336
Merge branch 'releases/1.6' 2021-01-29 20:12:32 +01:00