<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/terminal.h, branch 1.8.2</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.8.2</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.8.2'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2021-07-18T14:46:43Z</updated>
<entry>
<title>render: use a single backing SHM pool for CSD surface buffers</title>
<updated>2021-07-18T14:46:43Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-18T14:46:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=20fc80e57e365f2e002eead7de110cb23ffa7adc'/>
<id>urn:sha1:20fc80e57e365f2e002eead7de110cb23ffa7adc</id>
<content type='text'>
</content>
</entry>
<entry>
<title>csi: erase scrollback: cancel selection if it touches the scrollback</title>
<updated>2021-07-18T14:14:21Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-16T14:45:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5f0ceb72f176caf7673ea1d4bc5195f26f4b4df7'/>
<id>urn:sha1:5f0ceb72f176caf7673ea1d4bc5195f26f4b4df7</id>
<content type='text'>
This breaks out the scrollback erasing logic for \E[3J from csi.c, and
moves it to the new function term_erase_scrollback(), and changes the
logic to calculate the start and end row (absolute) numbers of the
scrollback, and only iterate those, instead of iterating *all* rows,
filtering out those that are on-screen.

It also adds an intersection range check of the selection range, and
cancels the selection if it touches any of the deleted scrollback
rows.

This fixes a crash when trying to render the next frame, since the
selection now references rows that have been freed.

Closes #633
</content>
</entry>
<entry>
<title>shm: refactor: move away from a single, global, buffer list</title>
<updated>2021-07-17T17:14:42Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-16T14:48:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=53851e13ec976001cdec2077d7963c292bcd6d20'/>
<id>urn:sha1:53851e13ec976001cdec2077d7963c292bcd6d20</id>
<content type='text'>
Up until now, *all* buffers have been tracked in a single, global
buffer list. We've used 'cookies' to separate buffers from different
contexts (so that shm_get_buffer() doesn't try to re-use e.g. a
search-box buffer for the main grid).

This patch refactors this, and completely removes the global
list.

Instead of cookies, we now use 'chains'. A chain tracks both the
properties to apply to newly created buffers (scrollable, number of
pixman instances to instantiate etc), as well as the instantiated
buffers themselves.

This means there's strictly speaking not much use for shm_fini()
anymore, since its up to the chain owner to call shm_chain_free(),
which will also purge all buffers.

However, since purging a buffer may be deferred, if the buffer is
owned by the compositor at the time of the call to shm_purge() or
shm_chain_free(), we still keep a global 'deferred' list, on to which
deferred buffers are pushed. shm_fini() iterates this list and
destroys the buffers _even_ if they are still owned by the
compositor. This only happens at program termination, and not when
destroying a terminal instance. I.e. closing a window in a “foot
--server” does *not* trigger this.

Each terminal instatiates a number of chains, and these chains are
destroyed when the terminal instance is destroyed. Note that some
buffers may be put on the deferred list, as mentioned above.
</content>
</entry>
<entry>
<title>render: Allow cells to bleed into their neighbor</title>
<updated>2021-07-17T11:22:44Z</updated>
<author>
<name>Timur Celik</name>
<email>mail@timurcelik.de</email>
</author>
<published>2021-06-15T09:45:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=91801ae55da017c2dd0f44c04b8d316a9a2090ef'/>
<id>urn:sha1:91801ae55da017c2dd0f44c04b8d316a9a2090ef</id>
<content type='text'>
This patch adds a `confined` flag to each cell to track if the last
rendered glyph bled into it's right neighbor.  To keep things simple,
bleeding into any other neighbor cell than the immediate right one is
not allowed.  This should cover most use cases.

Before rendering a row we now do a prepass and mark all cells unclean
that are affected by a bleeding neighbor.  If there are consecutive
bleeding cells, the whole group must be re-rendered even if only a
single cell has changed.

The patch also deprecates both old overflowing glyph options
*allow-overflowing-double-width-glyphs* and *pua-double-width* in favor
of a single new one named *overflowing-glyphs*.
</content>
</entry>
<entry>
<title>csi: invert the meaning of DECSDM</title>
<updated>2021-07-14T17:17:44Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-14T17:17:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=fcd989734235c25e64f8fb38ffcfdf381e933873'/>
<id>urn:sha1:fcd989734235c25e64f8fb38ffcfdf381e933873</id>
<content type='text'>
There has been some confusion whether enabling DECSDM (private mode
80) enables or disables sixel scrolling.

Foot currently enables scrolling when DECSDM is set, and this patch
changes this, such that setting DECSDM now *disables* scrolling.

The confusion is apparently due to a documentation error in the VT340
manual, as described in
https://github.com/dankamongmen/notcurses/issues/1782#issuecomment-863603641.

And that makes sense, in a way: the SDM in DECSDM stands for Sixel
Display Mode. I.e. it stands to reason that enabling that disables
scrolling.

Anyway, this lead to https://github.com/hackerb9/lsix/issues/41, where
it was eventually proven (by testing on a real VT340), that foot, and
a large number of other terminals (including XTerm) has it wrong:
https://github.com/hackerb9/lsix/issues/41#issuecomment-873269599.
</content>
</entry>
<entry>
<title>url-mode: fix crash when removing duplicate and/or overlapping URLs</title>
<updated>2021-07-11T08:06:12Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-11T08:06:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=cf6d04f9f2fcb7a4f12d35edd0a6d4cd5591b59c'/>
<id>urn:sha1:cf6d04f9f2fcb7a4f12d35edd0a6d4cd5591b59c</id>
<content type='text'>
Removing overlaping and duplicated URLs is done by running two nested
loops, that both iterate the same URL list.

When a duplicate is found, one of the URLs is destroyed and removed
from the list.

Deleting and removing an item *is* safe, but only as long as _no
other_ iterator has references to it.

In this case, if we remove an item from e.g. the inner iterator, we’ll
crash if the outer iterator’s *next* item is the item being removed.

Closes #627
</content>
</entry>
<entry>
<title>config: add locked-title=no|yes</title>
<updated>2021-07-04T15:59:40Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-04T15:59:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=fcb60abc132b12ccf8fb8ff215acc924a44773d6'/>
<id>urn:sha1:fcb60abc132b12ccf8fb8ff215acc924a44773d6</id>
<content type='text'>
Closes #386
</content>
</entry>
<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>
</feed>
