<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/render.c, 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-30T16:01:03Z</updated>
<entry>
<title>render: don’t look at glyphs[0]-&gt;cols when determining if overflow should be allowed</title>
<updated>2021-06-30T16:01:03Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-30T16:01:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=cf46acc68f221aeac71bd2ef60a3beeeb0b3be47'/>
<id>urn:sha1:cf46acc68f221aeac71bd2ef60a3beeeb0b3be47</id>
<content type='text'>
Use ‘cell_cols’ instead, which is the number of cells we’ll actually
be using.
</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>render: use cell cols from compose chain, not grapheme</title>
<updated>2021-06-24T15:30:48Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-24T08:08:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=b14524215ba2119c1f37787bbd4201d6d00d13df'/>
<id>urn:sha1:b14524215ba2119c1f37787bbd4201d6d00d13df</id>
<content type='text'>
fcft’s view of how many columns a grapheme cluster is may differ from
our own. Make sure the rendered glyph matches the number of columns
that were allocated when the cluster was printed.
</content>
</entry>
<entry>
<title>render: don’t modify the cell’s x position. Fixes broken underlines</title>
<updated>2021-06-24T15:30:47Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-15T15:52:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c0d9f92e1a5aae2f0963d62f9fd480a5926f2d15'/>
<id>urn:sha1:c0d9f92e1a5aae2f0963d62f9fd480a5926f2d15</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: we’ve already assigned ‘base’ a couple of lines higher up</title>
<updated>2021-06-24T15:30:46Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-15T05:58:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=51295cd7a27641d0452db6465e852f66bfd67118'/>
<id>urn:sha1:51295cd7a27641d0452db6465e852f66bfd67118</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: repair parenthesis after rebase</title>
<updated>2021-06-24T15:30:46Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-15T04:00:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=96ff29bbd3968759f3ebb3c83a9c2c7a8ea96134'/>
<id>urn:sha1:96ff29bbd3968759f3ebb3c83a9c2c7a8ea96134</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: ensure ‘cell_cols’ have been initialized</title>
<updated>2021-06-24T15:30:46Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-31T15:50:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=b471fe31b1a65c0eb11422beb8b9e119f771925d'/>
<id>urn:sha1:b471fe31b1a65c0eb11422beb8b9e119f771925d</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: handle fcft_glyph_rasterize() failure correctly</title>
<updated>2021-06-24T15:30:46Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-31T15:11:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=50be9242852756aac6fd82b0531ed92eeb44c754'/>
<id>urn:sha1:50be9242852756aac6fd82b0531ed92eeb44c754</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: use column count from grapheme instead of first glyph, when we have one</title>
<updated>2021-06-24T15:30:46Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-30T17:37:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=bd98cb6a73d225e2dc15678d8fe06d54cc802c7a'/>
<id>urn:sha1:bd98cb6a73d225e2dc15678d8fe06d54cc802c7a</id>
<content type='text'>
</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>wayland: apply CSD/SSD changes in the surface configure event</title>
<updated>2021-06-23T10:37:56Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-22T16:58:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=2a83202fddc4423fd102b0d5f19b0b445301a88e'/>
<id>urn:sha1:2a83202fddc4423fd102b0d5f19b0b445301a88e</id>
<content type='text'>
    The configure event asks the client to change its decoration
    mode. The configured state should not be applied immediately.
    Clients must send an ack_configure in response to this event.
    See xdg_surface.configure and xdg_surface.ack_configure for
    details.

In particular, ”the configured state should *not* be applied
immediately”.

Instead, treat CSD/SSD changes like all other window dimension related
changes: store the to-be mode in win-&gt;configure, and apply it in the
surface configure event.

This fixes an issue where foot incorrectly resized the window when the
server switched between CSD/SSD at run-time.
</content>
</entry>
<entry>
<title>config: add csd.button-color option</title>
<updated>2021-06-20T08:44:50Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-20T08:44:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7334b53d833cd2695a3544ff166219e977138732'/>
<id>urn:sha1:7334b53d833cd2695a3544ff166219e977138732</id>
<content type='text'>
This option controls the foreground color of the
minimize/maximize/close buttons. I.e. the color used to draw the
minimize/maximize/close glyphs.

It defaults to default background color.
</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>config: add underline-offset option</title>
<updated>2021-06-17T15:54:21Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-17T15:52:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=cf81fff062c8cac850f491ac722d6bb79a8bde14'/>
<id>urn:sha1:cf81fff062c8cac850f491ac722d6bb79a8bde14</id>
<content type='text'>
This option allows the user to configure a custom underline
offset. That is, use the user provided offset instead of the font
provided one.

Closes #490
</content>
</entry>
<entry>
<title>vt: emit a tab character if all cells between cursor and tab stop are empty</title>
<updated>2021-06-08T17:53:26Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-05T20:48:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=94b549f93e8cc4372e5ab7dc9c832219f337819c'/>
<id>urn:sha1:94b549f93e8cc4372e5ab7dc9c832219f337819c</id>
<content type='text'>
TAB (\t) move the cursor to the next tab stop. That’s it, according to
the specification.

However, many terminal emulators try to keep tabs in the grid, to be
able to e.g. copy them. That is, copying a text chunk containing tabs
should result in tabs being pasted, not spaces.

In order to do that, we need to print a tab character to the grid. To
improve text reflow of tabs, we also print spaces to the subsequent
cells, up until (but not including) the next tab stop.

However, we can only do this if all the cells between the cursor and
the next tab stop are empty, since (obviously), we cannot overwrite
pre-existing characters.

Finally, while some fonts render tabs as spaces (i.e. an empty glyph),
some use a glyph representing “unprintable” characters, or
similar. Thus, we need to exclude cells with tab characters when
rendering.
</content>
</entry>
<entry>
<title>render: reverse video only swaps *default* fg/bg</title>
<updated>2021-06-08T17:51:13Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-07T19:46:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=39560a6ff1b398ec814c8e08fd694ea9ed4abad8'/>
<id>urn:sha1:39560a6ff1b398ec814c8e08fd694ea9ed4abad8</id>
<content type='text'>
This matches XTerm behavior, and fixes vttest 11.6.6.2:

Test non-VT100 -&gt;
Test ISO-6429 colors -&gt;
Test of VT102-style features with BCE -&gt;
Test of screen features
</content>
</entry>
<entry>
<title>config: add boolean option tweak.pua-double-width</title>
<updated>2021-06-01T15:51:09Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-31T15:10:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=4c954be7a6d86b21da512fc533eb3362ac737221'/>
<id>urn:sha1:4c954be7a6d86b21da512fc533eb3362ac737221</id>
<content type='text'>
When enabled, PUA (Private Usage Area) codepoints are always treated
as double-width glyphs, regardless of the actual glyph width.

Requires allow-overflowing-double-width-glyphs=yes
</content>
</entry>
<entry>
<title>config: add cursor.underline-thickness</title>
<updated>2021-05-22T12:49:25Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-18T16:52:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=1b5c8499947b2bb9fa9fe17af6540444984a5949'/>
<id>urn:sha1:1b5c8499947b2bb9fa9fe17af6540444984a5949</id>
<content type='text'>
Works in pretty much the same way as ‘beam-thickness’, except that the
default value is “the font’s underline thickness”.

This means, that when unset, the cursor underline thickness scales
with the font size.

But, when explicitly set, either to a point size value, or a pixel
size, it remains fixed at that size.

Closes #524
</content>
</entry>
<entry>
<title>render: stop spamming “resize” INFO logs</title>
<updated>2021-05-17T17:11:56Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-17T17:11:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9fe278388bc53cb07c20db8be9c83f50ef53d393'/>
<id>urn:sha1:9fe278388bc53cb07c20db8be9c83f50ef53d393</id>
<content type='text'>
It _may_ be acceptable in e.g. tiling WMs, where windows are seldom
resized interactively.

But in a stacking WM where the typical way of resizing windows is by
interactive resizes, this spams way too much.
</content>
</entry>
</feed>
