<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/grid.c, branch 1.10.2</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.10.2</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.10.2'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2021-11-28T10:05:00Z</updated>
<entry>
<title>grid: uri_range_erase(): unittest: try erasing a row without any URIs</title>
<updated>2021-11-28T10:05:00Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-28T10:05:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=2fe2dfa847a2fdc3563d53a1a1a81e1853868c4f'/>
<id>urn:sha1:2fe2dfa847a2fdc3563d53a1a1a81e1853868c4f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>grid: uri_range_erase: walk the ranges backwards</title>
<updated>2021-11-28T10:03:07Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-28T09:56:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=66b8c92c30667327ce7b5de3cbc068be67b3719a'/>
<id>urn:sha1:66b8c92c30667327ce7b5de3cbc068be67b3719a</id>
<content type='text'>
This way, ranges are deleted last-to-first, thus avoiding memmoving
multiple ranges over and over again when erasing e.g. a full line.
</content>
</entry>
<entry>
<title>grid: remove useless assertion</title>
<updated>2021-11-27T17:15:59Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-27T17:15:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=747da83c765d8df4c369d3a9bf82ea87ce9f1284'/>
<id>urn:sha1:747da83c765d8df4c369d3a9bf82ea87ce9f1284</id>
<content type='text'>
  grid.c:1041:24: warning: comparison of unsigned expression in ‘&gt;= 0’ is always true [-Wtype-limits]
</content>
</entry>
<entry>
<title>grid: resize without reflowing: use URI range utility functions</title>
<updated>2021-11-27T15:31:33Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-27T15:31:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5ce6c89df638bb7bff5552997f671092cd32a858'/>
<id>urn:sha1:5ce6c89df638bb7bff5552997f671092cd32a858</id>
<content type='text'>
</content>
</entry>
<entry>
<title>grid: uri_range_{append,insert}: pass range attributes as separate parameters</title>
<updated>2021-11-27T15:25:29Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-27T15:24:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=dfeca4e13497f9a4295cb4c23e53e7639d614e45'/>
<id>urn:sha1:dfeca4e13497f9a4295cb4c23e53e7639d614e45</id>
<content type='text'>
</content>
</entry>
<entry>
<title>grid: snapshot: use uri range utility functions</title>
<updated>2021-11-27T15:11:26Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-27T15:07:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5c6c2de0517fbe93b748d3315b7b52ca682bac24'/>
<id>urn:sha1:5c6c2de0517fbe93b748d3315b7b52ca682bac24</id>
<content type='text'>
</content>
</entry>
<entry>
<title>grid: uri_range_ensure_size(): add the requested amount of entries</title>
<updated>2021-11-27T15:03:07Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-27T15:03:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5c7e881cd49d7814c7f791f5e3457aca2b5f72d3'/>
<id>urn:sha1:5c7e881cd49d7814c7f791f5e3457aca2b5f72d3</id>
<content type='text'>
</content>
</entry>
<entry>
<title>grid: reflow: no need to keep a uri-range-idx variable</title>
<updated>2021-11-26T19:57:08Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-26T19:57:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=76992713161b589407060c2fc7a42e7ffb192844'/>
<id>urn:sha1:76992713161b589407060c2fc7a42e7ffb192844</id>
<content type='text'>
The URI ranges are now an array, which means we can get the next URI
range by incrementing the pointer.

Instead of checking if range is not NULL, check that it isn’t the
range terminator (which is NULL when we don’t have any ranges, and
the first address *after* the last range otherwise).
</content>
</entry>
<entry>
<title>grid: resize without reflow: only verify URI ranges in debug builds</title>
<updated>2021-11-26T19:36:59Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-26T19:36:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=41565a0d0ef4486b8b0a223fc8cc28180022cb52'/>
<id>urn:sha1:41565a0d0ef4486b8b0a223fc8cc28180022cb52</id>
<content type='text'>
</content>
</entry>
<entry>
<title>grid: bug: OSC-8 URIs were incorrectly skipped while resizing the alt screen</title>
<updated>2021-11-26T19:29:23Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-26T19:27:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=be203aeae1280ad7cac3ec9e287d1dd97528f390'/>
<id>urn:sha1:be203aeae1280ad7cac3ec9e287d1dd97528f390</id>
<content type='text'>
</content>
</entry>
<entry>
<title>osc8: replace grid_row_uri_range_add() with internal uri_range_append()</title>
<updated>2021-11-26T19:25:07Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-26T19:25:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=4eb0aa0f185ea9da604582bf8f091ab428b27997'/>
<id>urn:sha1:4eb0aa0f185ea9da604582bf8f091ab428b27997</id>
<content type='text'>
grid_row_uri_range_add() was only used while reflowing. In this case,
we know the new URIs being added are always going at the end of the
URI list (since we’re going top-to-bottom, left-to-right).

Thus, we don’t need the insertion logic, and can simply append instead.
</content>
</entry>
<entry>
<title>osc8: uri ranges: use a dynamically re-sizable array instead of a tllist</title>
<updated>2021-11-26T19:09:15Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-26T18:55:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=ccee08a393f4c55994e921b43a16f5942816d764'/>
<id>urn:sha1:ccee08a393f4c55994e921b43a16f5942816d764</id>
<content type='text'>
</content>
</entry>
<entry>
<title>osc8: update URI ranges as we print data, *not* when the URI is closed</title>
<updated>2021-11-25T18:31:03Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-25T18:22:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8c50a7afd401686f645fb26676fbcaedb8d4ab62'/>
<id>urn:sha1:8c50a7afd401686f645fb26676fbcaedb8d4ab62</id>
<content type='text'>
At first, an OSC-8 URI range was added when we received the closing
OSC-8 escape (i.e. with an empty URI).

But, this meant that cursor movements while the OSC-8 escape was in
effect wasn’t handled correctly, since we’d add a range that spanned
the cursor movements.

Attempts were made to handle this in the cursor movement functions, by
closing and re-opening the URI.

However, there are too many corner cases to make this a viable
approach. Scrolling is one such example, line-wrapping another.

This patch takes a different approach; emit, or update the URI range
when we print to the grid. This models the intended behavior much more
closely, where an active OSC-8 URI act like any other SGR attribute -
it is applied to all cells printed to, but otherwise have no effect.

To avoid killing performance, this is only done in the “generic”
printer. This means OSC-8 open/close calls must now “switch” the ASCII
printer.

Note that the “fast” printer still needs to *erase* pre-existing OSC-8
URIs.

Closes #816
</content>
</entry>
<entry>
<title>grid: refactor grid_row_uri_range_erase()</title>
<updated>2021-11-21T17:09:27Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-20T14:46:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f27ccd999ef6fcf10f99aed9f6aec449fe071551'/>
<id>urn:sha1:f27ccd999ef6fcf10f99aed9f6aec449fe071551</id>
<content type='text'>
The old algorithm always created a new URI, followed by (maybe)
removing the existing URI, when an URI needed to be modified.

That is, if e.g. the tail of an URI was being erased, the old
algorithm would create a new URI for the part of the URI that should
remain, and then removed the old URI.

This isn’t very effective. The new algorithm instead identifies all
possible overlap cases, and handles each one differently:

* URI ends *before* erase range starts - continue with the next URI
  without further checks
* URI starts *after* the erase range ends - return, we’re done
* Erase range erases the entire URI - remove the URI
* Erase range erases a part in the middle - split the URI
* Erase range erases the head of the URI - adjust the URI’s start
* Erase range erases the tail of the URI - adjust the URI’s end
</content>
</entry>
<entry>
<title>grid: row_uri_range_erase(): assume caller has checked row-&gt;extra != NULL</title>
<updated>2021-11-21T17:09:27Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-20T13:40:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=503c2ebd50caaf1d50b57c42d319973277a583e0'/>
<id>urn:sha1:503c2ebd50caaf1d50b57c42d319973277a583e0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>grid: add grid_row_uri_range_erase()</title>
<updated>2021-11-21T17:09:26Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-20T12:42:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=1a0de0017f7b2061bad0b695a98963ca0f274e21'/>
<id>urn:sha1:1a0de0017f7b2061bad0b695a98963ca0f274e21</id>
<content type='text'>
This function handles erasing of an URI range. That is, a range of the
row is being either erased, or overwritten (from the URI perspective,
these two are the same thing).

We handle both partial overwrites (split up, or truncate URI), as well
as complete overwrites (remove URI).
</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>grid: reflow: ‘amount’ has already been added to ‘from’</title>
<updated>2021-06-02T18:13:52Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-02T17:30:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=3292bb5b8eaddb8a0354387fcc2d8f9ffd0d1ac4'/>
<id>urn:sha1:3292bb5b8eaddb8a0354387fcc2d8f9ffd0d1ac4</id>
<content type='text'>
</content>
</entry>
<entry>
<title>grid: reflow: URI range start: take over ownership of URI string</title>
<updated>2021-06-02T18:13:52Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-28T16:19:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=a003e56fdc2300818760bcdf020219604bb285ab'/>
<id>urn:sha1:a003e56fdc2300818760bcdf020219604bb285ab</id>
<content type='text'>
Instead of strdup:ing the URI, take over ownership. This is ok since
the old URI range will be free:d anyway.
</content>
</entry>
<entry>
<title>grid: reflow: debug logging</title>
<updated>2021-06-02T18:13:51Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-28T15:42:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8a9643de67458e1958839e994350621e4588808f'/>
<id>urn:sha1:8a9643de67458e1958839e994350621e4588808f</id>
<content type='text'>
</content>
</entry>
</feed>
