<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/terminal.h, branch 1.8.1</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.8.1</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.8.1'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2021-06-24T17:15:53Z</updated>
<entry>
<title>term: CELL_COMB_CHARS chars are keys, not indices -&gt; more range is better</title>
<updated>2021-06-24T17:15:53Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-24T17:15:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9a7c6bdcf2ed686e41a15bbf6a3fbd9e8517dc6a'/>
<id>urn:sha1:9a7c6bdcf2ed686e41a15bbf6a3fbd9e8517dc6a</id>
<content type='text'>
Bump the available key range to 30 bits. This helps reduce key
collisions when handling a large amount of grapheme clusters.
</content>
</entry>
<entry>
<title>composed: store compose chains in a binary search tree</title>
<updated>2021-06-24T15:30:49Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-24T11:17:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=fe8ca23cfee77a6cac433892755dd7455e354a9d'/>
<id>urn:sha1:fe8ca23cfee77a6cac433892755dd7455e354a9d</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>term: bump compose chain char array to 10 chars</title>
<updated>2021-06-24T15:30:49Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-24T09:24:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=fcd632729787b181eb3ec3d2bd839ed2395f1e90'/>
<id>urn:sha1:fcd632729787b181eb3ec3d2bd839ed2395f1e90</id>
<content type='text'>
There are some very long sequences out there... e.g. 👩🏼‍❤️‍💋‍👨🏽
</content>
</entry>
<entry>
<title>term: lower maximum number of characters in a compose chain</title>
<updated>2021-06-24T15:30:47Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-15T06:44:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6187aa0b1bfcba7e5d956e05685ad1de42666221'/>
<id>urn:sha1:6187aa0b1bfcba7e5d956e05685ad1de42666221</id>
<content type='text'>
Before the grapheme cluster segmentation work, we limited the number
of combining characters to base+5. I.e. 6 in total.

For a while now, we’ve had it bumped all the way up to 20. This was
the reason the unicode-random benchmark ran so much slower (i.e. cache
contention).

Looking at emoji’s, there are a couple that need 6 code points,
and *three* that needs 7.

Now, with the limit at 7 chars, and the new ‘width’ member, the
composed struct is 8 bytes larger than before.
</content>
</entry>
<entry>
<title>vt: cache grapheme cluster width in composed struct</title>
<updated>2021-06-24T15:30:45Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-27T18:07:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0a9531ac6caff2ad6abfbb804ec27cade4a92e7a'/>
<id>urn:sha1:0a9531ac6caff2ad6abfbb804ec27cade4a92e7a</id>
<content type='text'>
* Use regular wcswidth() to calculate the width
* Explicitly set to ‘2’ if we see a emoji variant selector
* Cache the result in the composed struct
</content>
</entry>
<entry>
<title>wip: grapheme shaping</title>
<updated>2021-06-24T15:30:45Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-08-20T17:25:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=b9ef703eb14ba2357b847b62a715b4e97f690209'/>
<id>urn:sha1:b9ef703eb14ba2357b847b62a715b4e97f690209</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: don’t create/destroy the title update timer each time</title>
<updated>2021-06-18T13:53:47Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-18T13:53:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=07b455e882f1925930963b643011a53906cadb9d'/>
<id>urn:sha1:07b455e882f1925930963b643011a53906cadb9d</id>
<content type='text'>
Create it once when instantiating the terminal. Add a boolean to track
whether the timer is running or not.
</content>
</entry>
<entry>
<title>render: use a timer instead of relying on the frame callback for title update throttling</title>
<updated>2021-06-18T13:36:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-15T15:27:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=535c82d628909b4f54774885e7de366c07fa9779'/>
<id>urn:sha1:535c82d628909b4f54774885e7de366c07fa9779</id>
<content type='text'>
Using the frame callback works most of the time, but e.g. Sway doesn’t
call it while the window is hidden, and thus prevents us from updating
the title in e.g. stacked views.

This patch uses a timer FD instead. We store a timestamp from when the
title was last updated. When the application wants to update the
title, we first check if we already have a timer running, and if so,
does nothing.

If no timer is running, check the timestamp. If enough time has
passed, update the title immediately.

If not, instantiate a timer and wait for it to trigger.

Set the minimum time between two updates to ~8ms (twice per frame, for
a 60Hz output, and ~once per frame on a 120Hz output).

Closes #591
</content>
</entry>
<entry>
<title>terminal: add 'charset_designator' enum to make code more self-documenting</title>
<updated>2021-06-09T09:00:25Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2021-06-09T08:51:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e030a2ca08d92eb431e9b8e494c63affeeb8c0e1'/>
<id>urn:sha1:e030a2ca08d92eb431e9b8e494c63affeeb8c0e1</id>
<content type='text'>
This commit also renames the term_set_single_shift_ascii_printer()
function to term_single_shift(), since the former is overly verbose
and not really even accurate.
</content>
</entry>
<entry>
<title>vt: fix SS2/SS3 escape sequences to act correctly as single shifts</title>
<updated>2021-06-08T20:09:40Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2021-06-08T20:09:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=a2c9c56f1962ce02e71582c06f389e53d1869e90'/>
<id>urn:sha1:a2c9c56f1962ce02e71582c06f389e53d1869e90</id>
<content type='text'>
These sequences are supposed to affect the next printable ASCII
character and then reset to the previous character set, but before
this commit they were behaving like locking shifts.
</content>
</entry>
<entry>
<title>url-mode: remove overlapping URLs, not just duplicates</title>
<updated>2021-05-22T14:42:43Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-22T14:42:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5605eb90405f732019043990cd39f1fd96e72182'/>
<id>urn:sha1:5605eb90405f732019043990cd39f1fd96e72182</id>
<content type='text'>
  echo -e '\e]8;;https://www.foo.bar\e\\https://www.foo\e]8;;\e\\.bar'

will produce an OSC-8 URL (https://www.foo) that is slightly shorter
than the auto-detected one (https://www.foo.bar).

This produces strange results in URL mode. For example, if
url.osc8-underline=always, the OSC8 underline will be removed when
url-mode is exited.

This patch changes the behavior so that auto-detected URLs that
overlap OSC-8 URLs are removed.

Note that OSC-8 URLs cannot overlap with each other, and that
auto-detected URLs also cannot overlap with each other.
</content>
</entry>
<entry>
<title>term: get rid of term-&gt;font_scale, use term-&gt;scale only</title>
<updated>2021-05-17T15:55:49Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-13T09:10:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=2afc6782361d0deaa443234466775b1121feec8f'/>
<id>urn:sha1:2afc6782361d0deaa443234466775b1121feec8f</id>
<content type='text'>
We only needed term-&gt;font_scale to be able to detect scaling factor
changes (term-&gt;font_scale != term-&gt;scale).

But, we already have the old scaling factor in all places where
term_font_dpi_changed() is called, so let’s pass the old scaling
factor as an argument instead.
</content>
</entry>
<entry>
<title>term: remove get_font_scale()</title>
<updated>2021-05-17T15:55:39Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-12T22:15:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=09354286955a6a7eb05e0e336ce7fc9cc43cb5f3'/>
<id>urn:sha1:09354286955a6a7eb05e0e336ce7fc9cc43cb5f3</id>
<content type='text'>
get_font_scale() was used to get the new scaling factor when loading
fonts. This was then compared to the last seen font scaling factor. If
there was no difference, the fonts were not reloaded.

The problem was, the initial term-&gt;scale was set differently. This
sometimes led to term-&gt;scale=2, while get_font_scale() return 1. That
meant, fonts were initially scaled by 2 (when dpi-aware=no). Later,
when mapped on an output (and thus term-&gt;scale being set to 1), the
fonts weren’t reloaded with the correct scaling factor since the
cached term-&gt;font_scale value was already 1.

Since term-&gt;scale always reflects the *new* scaling factor when
term_font_dpi_changed() is called, use that directly, and remove
get_font_scale().

Also rename the following functions:

* font_should_size_by_dpi() -&gt; font_size_by_dpi_for_scale()
* font_size_by_dpi() -&gt; font_sized_by_dpi()
* font_size_by_scale() -&gt; font_sized_by_scale()
</content>
</entry>
<entry>
<title>term: rename CELL_MULT_COL_SPACER -&gt; CELL_SPACER, and change its definition</title>
<updated>2021-05-14T12:41:02Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-14T12:41:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=d9e1aefb9173857f0632227de5ac368a505c69bf'/>
<id>urn:sha1:d9e1aefb9173857f0632227de5ac368a505c69bf</id>
<content type='text'>
Instead of using CELL_SPACER for *all* cells that previously used
CELL_MULT_COL_SPACER, include the remaining number of spacers
following, and including, itself. This is encoded by adding to the
CELL_SPACER value.

So, a double width character will now store the character itself in
the first cell (just like before), and CELL_SPACER+1 in the second
cell.

A three-cell character would store the character itself, then
CELL_SPACER+2, and finally CELL_SPACER+1.

In other words, the last spacer is always CELL_SPACER+1.

CELL_SPACER+0 is used when padding at the right margin. I.e. when
writing e.g. a double width character in the last column, we insert a
CELL_SPACER+0 pad character, and then write the double width character
in the first column on the next row.
</content>
</entry>
<entry>
<title>box-drawing: add Unicode 13 U+1FB70 - U+1FB8B</title>
<updated>2021-05-04T08:47:36Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-03T15:57:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9e5d74042256eb1a3b1adc90b9530d6458ec1f65'/>
<id>urn:sha1:9e5d74042256eb1a3b1adc90b9530d6458ec1f65</id>
<content type='text'>
Part of #471
</content>
</entry>
<entry>
<title>config: add ‘beam-thickness’ option</title>
<updated>2021-04-30T18:36:16Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-04-30T18:31:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7ce767ab87ca915b2ac4023cc95dbda81fe87abd'/>
<id>urn:sha1:7ce767ab87ca915b2ac4023cc95dbda81fe87abd</id>
<content type='text'>
* Rename cursor.style value ‘bar’ to ‘beam’. ‘bar’ remains recognized,
  but should eventually be deprecated and then removed.
* Add ‘cursor.beam-thickness’ option, a pt-or-px value specifying the
  thickness of the beam cursor. Defaults to 1.5pt.
* Rename (and export) pt_or_px_as_pixels() to
  term_pt_or_px_as_pixels()
* Change term_pt_or_px_as_pixels() to round point values instead of
  truncating them.
</content>
</entry>
<entry>
<title>csi: add support for DECSET 2026, as an alternative to BSU/ESU sequences</title>
<updated>2021-04-25T17:35:46Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2021-04-25T17:35:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f95d7d468492144d7d36c08ab1b08f13a076e3fc'/>
<id>urn:sha1:f95d7d468492144d7d36c08ab1b08f13a076e3fc</id>
<content type='text'>
See: https://gitlab.freedesktop.org/terminal-wg/specifications/-/merge_requests/2#note_847720
</content>
</entry>
<entry>
<title>term: attributes struct: use ‘bool’ instead of ‘uint32_t’ for 1-bit members</title>
<updated>2021-04-17T20:11:14Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-04-17T20:11:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9413a18d9e86f1201916ed7c8c0311d09f4b64c9'/>
<id>urn:sha1:9413a18d9e86f1201916ed7c8c0311d09f4b64c9</id>
<content type='text'>
</content>
</entry>
<entry>
<title>osc: implement OSC 17+19: change selection background/foreground colors</title>
<updated>2021-04-08T08:43:36Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-04-07T06:09:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=55b343f69030c22fcd36b88d2af445acdd69b732'/>
<id>urn:sha1:55b343f69030c22fcd36b88d2af445acdd69b732</id>
<content type='text'>
And of course, we also implement the corresponding reset sequences,
OSC 117+119.
</content>
</entry>
<entry>
<title>config/terminal: refactor: remove “default_*” color members from terminal struct</title>
<updated>2021-04-07T06:07:43Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-04-07T06:07:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=936063271f391c394ec9204f7f3aff4da5c9203c'/>
<id>urn:sha1:936063271f391c394ec9204f7f3aff4da5c9203c</id>
<content type='text'>
Access the original colors in the configuration instead.
</content>
</entry>
</feed>
