Commit graph

4516 commits

Author SHA1 Message Date
Daniel Eklöf
4e8db9d8b6
changelog: s/from/in 2021-07-01 20:44:53 +02:00
Daniel Eklöf
ea39496f30
changelog: add new ‘unreleased’ section 2021-07-01 20:19:28 +02:00
Daniel Eklöf
a99542aad6
Merge branch 'releases/1.8' 2021-07-01 20:19: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
7112f24671
changelog: prepare for 1.8.1 2021-07-01 20:14:20 +02:00
Daniel Eklöf
fd974e139e
Merge branch 'master' into releases/1.8 2021-07-01 20:13:49 +02:00
Daniel Eklöf
ab8f9afa90
changelog: move grapheme cluster width entry to ‘changed’, and rewrite it 2021-07-01 20:13:03 +02:00
Daniel Eklöf
d9fc1e0d8a
Merge branch 'max-grapheme-width-is-2' 2021-07-01 19:55:50 +02:00
Daniel Eklöf
5138f02214
config: rename at-most-2 (value for grapheme-width-method) to double-width 2021-07-01 08:00:23 +02:00
Daniel Eklöf
9817e44c32
config: add tweak.grapheme-width-method=wcswidth|at-most-2 2021-07-01 07:58:06 +02:00
Daniel Eklöf
031e8f5987
vt: limit grapheme width to 2 cells
All emoji graphemes are double-width. Foot doesn’t support non-latin
scripts. Ergo, this should result in the Right Thing, even though
we’re not doing it the Right Way.

Note that we’re now breaking cursor synchronization with nearly all
applications.

But the way I see it, the applications need to be
updated.
2021-07-01 07:57:56 +02:00
Daniel Eklöf
55bd3cfd62
config: add unit test for config_clone()
We’re mainly interested in seeing that we don’t leak memory, or double
free heap allocated data.

Valgrind and/or gcc/clang sanitizers are best at this, hence the very
few asserts in the test itself.
2021-06-30 21:06:21 +02:00
Daniel Eklöf
88fb8429b0
config: NOINLINE a couple of functions doing tll operations 2021-06-30 19:10:37 +02:00
Daniel Eklöf
56f592e308
Merge branch 'remove-unused-key-bindings'
Closes #614
2021-06-30 18:05:14 +02:00
Daniel Eklöf
149c52bd44
config: remove replaced/removed key bindings, instead of marking as ‘unused’
Instead of keeping removed/replaced key bindings in the key binding
array (marked as ‘unused’), remove them, by compacting the array.

The invariant is thus that there should be *no* entries in the key
binding list with the `BIND_ACTION_NONE` for action.

Add code to debug builds that verifies this, plus a unit test.

Closes #614
2021-06-30 18:05:07 +02:00
Daniel Eklöf
cf46acc68f
render: don’t look at glyphs[0]->cols when determining if overflow should be allowed
Use ‘cell_cols’ instead, which is the number of cells we’ll actually
be using.
2021-06-30 18:01:03 +02:00
Craig Barnes
3e74482d6c terminfo: add Tc, setrgbf and setrgbb capabilities
These extensions are used by tmux and neovim, in order to make use
of 24-bit colors without facing the problems that plague the `RGB`
capability.

This should allow 24-bit colors to work "out of the box" in tmux,
without the usual workaround of adding:

    set-option -ga terminal-overrides ",foot*:Tc"

...to ~/.tmux.conf.

See also:

* 18fe2e8dfa (commitcomment-31373962)
* f83c25942d/runtime/doc/term.txt (L123-L139)
* b1a8c0fe02/CHANGES (L988-L989)

Closes #615
2021-06-29 08:55:53 +01:00
Daniel Eklöf
a09f928175
input: ignore ‘unused’ URL key bindings when mapping bindings to current keymap
This is a temporary fix for #614. Long term fix is to remove the
‘replaced’ bindings from the array at config time.
2021-06-28 22:34:52 +02:00
Daniel Eklöf
117e24dbf4
term: destroy: free URLs before free:ing the grids
Fixes use-after-free when destroying a terminal with “live”
URLs (i.e. when URL mode is active).
2021-06-28 22:33:57 +02:00
Craig Barnes
5dca0458a0 log: add LOG_CLASS_NONE and use as initializer for log_level
This means that logging will be completely disabled until log_init()
has been called, which is useful to prevent log spam when running
UNITTEST{} blocks in debug builds.

Note that this doesn't change the default log level at runtime, which
was already being set to LOG_CLASS_INFO in main.c and client.c.

The new log level is also exposed to the command-line interface as
`--log-level=none`, which allows disabling logging entirely.
2021-06-26 22:15:09 +01:00
Daniel Eklöf
0ff8f72a9d
vt: don’t reset utf8proc grapheme state when we’re not at a grapheme break 2021-06-25 20:42:23 +02:00
Daniel Eklöf
d206697001
doc: benchark: laptop results for 1.8.0 2021-06-25 10:56:40 +02:00
Daniel Eklöf
e365ac0b10
doc: benchmark: add --dat to vtebench command line 2021-06-25 10:24:55 +02:00
Daniel Eklöf
2873043865
doc: benchmarks: update desktop results with 1.8.0 2021-06-25 10:23:43 +02:00
Daniel Eklöf
2535cf51db
changelog: add new ‘unreleased’ section 2021-06-25 08:44:41 +02:00
Daniel Eklöf
3d524746cd
Merge branch 'releases/1.8' 2021-06-25 08:44:11 +02:00
Daniel Eklöf
bc6b4d7b8a
generate-version: fix regression where a tagged version was parsed wrong
The regexps didn’t work when the “extra” portion of “git describe” was
missing.
2021-06-25 08:35:41 +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
8df5f90474
changelog: prepare for 1.8.0 2021-06-25 08:23:36 +02:00
Daniel Eklöf
20c0650dfd
wayland: regression: properly instantiate CSDs when there’s no decoration manager
* Set win->configure.csd_mode, not win->csd_mode. Otherwise our
  ‘configure’ handler will swap out the CSD_YES we set, for
  CSD_UNKNOWN(?), resulting in no CSDs at all.

* Don’t instantiate the CSDs in wayl_win_init(), let the ‘configure’
  event handler do that. Just like it does when we have a decoration
  manager emitting decoration configure events.
2021-06-24 23:02:40 +02:00
Daniel Eklöf
07128ee905
changelog: spelling; add missing ‘l’ in ‘experimental’ 2021-06-24 22:55:28 +02:00
Daniel Eklöf
2c32d8617a
pkgbuild: add libutf8proc dependency 2021-06-24 20:29:15 +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
3bad062f8a
vt: utf8: rotate instead of just shifting when updating compose key
This reduces the number of collisions in even more workloads.
2021-06-24 19:36:39 +02:00
Daniel Eklöf
88ce0e4375
vt: improved key hash algorithm -> reduces number of key collisions 2021-06-24 19:18:06 +02:00
Daniel Eklöf
9a7c6bdcf2
term: CELL_COMB_CHARS chars are keys, not indices -> more range is better
Bump the available key range to 30 bits. This helps reduce key
collisions when handling a large amount of grapheme clusters.
2021-06-24 19:15:53 +02:00
Daniel Eklöf
f20956ff1b
composed: insert: require key to be unique 2021-06-24 19:12:25 +02:00
Daniel Eklöf
4a6dea04c2
install: add -Dgrapheme-clustering to the list of custom meson options 2021-06-24 17:57:34 +02:00
Daniel Eklöf
80c2d9d89d
Merge branch 'harfbuzz' 2021-06-24 17:50:55 +02:00
Daniel Eklöf
3f0f5ec3b7
client: add +/-graphemes to version output 2021-06-24 17:50:44 +02:00
Daniel Eklöf
a319ddf094
foot: add +/-graphemes to version output 2021-06-24 17:50:30 +02:00
Daniel Eklöf
4ea7c5b63f
features: add feature_graphemes()
Returns true if we’re compiled with grapheme shaping support, false
otherwise.
2021-06-24 17:50:04 +02:00
Daniel Eklöf
cf101ea300
changelog: describe what (does not) happens when grapheme-shaping=no 2021-06-24 17:36:57 +02:00
Daniel Eklöf
d5d57c1b20
changelog: composed -> combining 2021-06-24 17:36:52 +02:00
Daniel Eklöf
09c4d16232
changelog: put emphasis on ‘opt-in’ as well 2021-06-24 17:33:09 +02:00
Daniel Eklöf
f19797a5af
changelog: updates to “grapheme shaping” 2021-06-24 17:30:50 +02:00
Daniel Eklöf
415ecfc6fa
vt: codespell: bumb -> bump 2021-06-24 17:30:50 +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
fcd6327297
term: bump compose chain char array to 10 chars
There are some very long sequences out there... e.g. 👩🏼‍❤️‍💋‍👨🏽
2021-06-24 17:30:49 +02:00
Daniel Eklöf
fd70058795
changelog: add a “grapheme shaping” section 2021-06-24 17:30:49 +02:00