<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/selection.c, branch 1.13.0</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.13.0</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.13.0'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2022-07-28T19:06:58Z</updated>
<entry>
<title>selection: rework how we update a selection</title>
<updated>2022-07-28T19:06:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-07-28T16:45:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=fa2d9f86996467ba33cc381f810ea966a4323381'/>
<id>urn:sha1:fa2d9f86996467ba33cc381f810ea966a4323381</id>
<content type='text'>
Before this patch, each selection update would result in grid covered
by the selection being walked *three* times. First to “premark” the
area that *will* be selected after the update, then again to unmark
the previous selection (excluding the cells that were premarked - but
the cells are still iterated), and then one more time to finalize the
selection state in the grid.

Furthermore, each time a frame is rendered, the entire selection were
iterated again, to ensure all the cells have their ‘selected’ bit
set.

This quickly gets *very* slow.

This patch takes a completely different approach. Instead of looking
at the selection as a range of cells to iterate, we view it as an
area, or region. Thus, on each update, we have to regions: the region
representing the previous selection, and the region representing the
to-be selection.

By diffing these two regions, we get two new regions: one that
represents the cells that were selected, but aren’t any more, and one
that represents the cells that previously were not selected, but now
will be.

We implement the regions using pixman regions. By subtracting the
current selection from the previous selection, we get the region
representing the cells that are no longer selected, and that should be
unmarked.

By subtracting the previous selection from the current, we get the
region representing the cells that was added to the selection in this
update, and that should be marked.

selection_dirty_cells() is rewritten in a similar manner. We create
pixman regions for the selection, and the current scrollback view. The
intersection represents the (selected) cells that are visible. These
need to iterated and marked as being selected.

Closes #1114
</content>
</entry>
<entry>
<title>selection: extend: use scrollback relative coordinates</title>
<updated>2022-07-28T19:06:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-07-28T16:32:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=b8506bbea049548310552e210e9cb363195fe74b'/>
<id>urn:sha1:b8506bbea049548310552e210e9cb363195fe74b</id>
<content type='text'>
When extending a selection, we determine *how* to extend it (which
endpoint to move, and whether to grow or shrink the selection) by
comparing the extension point with the old start and end coordinates.

For this to work correctly, we need to use scrollback relative
coordinates.

This fixes an issue where extending a very large selection (covering
many pages) sometimes shrunk the selection instead of growing it, or
just misbehaving in general.
</content>
</entry>
<entry>
<title>selection: foreach_selected_*(): refactor: use grid_row_abs_to_sb()</title>
<updated>2022-07-28T19:06:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-07-28T16:31:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6ebf55572e765394e90c96b5fec0e2c55b3b434e'/>
<id>urn:sha1:6ebf55572e765394e90c96b5fec0e2c55b3b434e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>selection: selection_on_rows(): use scrollback relative coords</title>
<updated>2022-07-28T19:06:57Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-07-28T16:27:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=a05eaf28bdeea793829bddb6cc99220b1adb1d6f'/>
<id>urn:sha1:a05eaf28bdeea793829bddb6cc99220b1adb1d6f</id>
<content type='text'>
When checking if the current selection intersects with the
region (passed as parameter to the function), use scrollback relative
coordinates.

This fixes an issue where selections crossing the scrollback
wrap-around being misdetected, resulting in either the selection being
canceled while scrolling, even though it wasn’t scrolled out, or the
selection _not_ being canceled, when it _was_ scrolled out.
</content>
</entry>
<entry>
<title>selection: wl_data_offer_set_action: use enum values instead of magic integers</title>
<updated>2022-06-21T17:46:31Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-06-21T17:46:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=206e9a10502b29483b9f7fc35df921716fe8d7c1'/>
<id>urn:sha1:206e9a10502b29483b9f7fc35df921716fe8d7c1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>selection: reject dnd offers with unsupported mime-types</title>
<updated>2022-06-20T18:57:26Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-06-20T18:57:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6d4d4502e9188a07751b71b0bde7448e3e9eeef4'/>
<id>urn:sha1:6d4d4502e9188a07751b71b0bde7448e3e9eeef4</id>
<content type='text'>
We were already doing this, implicitly, *if* the offer was for the
main grid.

This patch makes it more clear that we do not accept the offer.
</content>
</entry>
<entry>
<title>selection: explicitly reject *all* dnd offers not targeting the grid</title>
<updated>2022-06-20T18:57:23Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-06-20T18:57:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0d22e9fa01a8149af453ebe57b5e4ef67f00a4d9'/>
<id>urn:sha1:0d22e9fa01a8149af453ebe57b5e4ef67f00a4d9</id>
<content type='text'>
</content>
</entry>
<entry>
<title>selection: ignore drag-and-drops with unsupported mime-types</title>
<updated>2022-06-20T18:56:11Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-06-20T17:29:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=2e4da6fbf69eb9edafdd74923fc155d16fde2133'/>
<id>urn:sha1:2e4da6fbf69eb9edafdd74923fc155d16fde2133</id>
<content type='text'>
Specifically, make sure we do *not* call wl_data_offer_receive() with
a NULL mime-type, as this causes libwayland to error out, which in
turn causes foot to exit.

Closes #1092
</content>
</entry>
<entry>
<title>selection: allow HT, VT and FF, disallow NUL in non-bracketed paste mode</title>
<updated>2022-06-15T17:09:40Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-06-13T09:41:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=dbe2c0a068fb0eda9b225f51b1df785d6f076de5'/>
<id>urn:sha1:dbe2c0a068fb0eda9b225f51b1df785d6f076de5</id>
<content type='text'>
This syncs foot with more recent versions of XTerm, where it’s
“disallowedPasteControls” resource has changed its default value to

  BS,DEL,ENQ,EOT,ESC,NULL

Note that we’re already stripping out ENQ,EOT,ESC in all modes.

What does it mean for foot:

* HT, VT and FF are now allowed, regardless of paste mode
* NUL is now stripped in non-bracketed paste mode

Closes #1084
</content>
</entry>
<entry>
<title>selection: find_word_boundary_right: add “stop-on-space-to-word-boundary”</title>
<updated>2022-04-27T16:44:57Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-27T16:44:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=76305104486a90c2320dd102c32fe26831ebb658'/>
<id>urn:sha1:76305104486a90c2320dd102c32fe26831ebb658</id>
<content type='text'>
When true, selection_find_word_boundary_right() behaves as before - it
stops as soon as it encounters a character that isn’t of the
same *type* as the “initial” character (the last character in the
selection).

Take this, for example:

  The Quick Brown Fox

The selection will first stop at the end of “the”, then just *before*
“quick”, then at the end of “quick”. Then just *before* “brown”, and
then at the end of “brown”, and so on.

This suits mouse selections pretty good. But when
selection_find_word_boundary_right() is used to extend a search match,
it’s better to ignore space-to-word character transitions. That is, we
want

  The Quick Brown Fox

to first extend to the end of “the”, then immediately to the end of
“quick”, then to the end of “brown”, and so on.

Setting the ‘stop_to_space_to_word_boundary’ argument to false results
in latter behavior.

This is now done by search, when executing the
“extend-to-word-boundary” and “extend-to-next-whitespace” key
bindings.
</content>
</entry>
<entry>
<title>selection: add start/end coordinate getters</title>
<updated>2022-04-25T17:59:23Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-25T17:59:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6316a5eb0cf2b1fe25ca0e9d60c4e11fce9c22d1'/>
<id>urn:sha1:6316a5eb0cf2b1fe25ca0e9d60c4e11fce9c22d1</id>
<content type='text'>
Internally, selection coordinates are *unbounded* (that is, the row
numbers may be larger than grid-&gt;num_rows) while a selection is
ongoing. Only after it has been finalized are the coordinates bounded.

This means it isn’t safe to use term-&gt;selection.coords.* directly.
</content>
</entry>
<entry>
<title>selection: assert serial is non-zero before copying data to the clipboard</title>
<updated>2022-04-24T18:18:51Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-23T13:49:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9c0f1a671cb015b650f7ed80e8fcf66d07c9e87a'/>
<id>urn:sha1:9c0f1a671cb015b650f7ed80e8fcf66d07c9e87a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>selection: find_word_boundary: assert ‘pos’ is valid</title>
<updated>2022-04-24T18:17:29Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-23T10:23:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8c0fca30db83576f7df5d48c94ecfa9896f8a075'/>
<id>urn:sha1:8c0fca30db83576f7df5d48c94ecfa9896f8a075</id>
<content type='text'>
</content>
</entry>
<entry>
<title>search: fix next/prev not updating selection correctly when matches overlap</title>
<updated>2022-04-17T17:16:47Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-17T17:16:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c5519e2aa6aacc7b552bd4d629b21e00051c211a'/>
<id>urn:sha1:c5519e2aa6aacc7b552bd4d629b21e00051c211a</id>
<content type='text'>
When the new match overlapped with the old match, the selection wasn’t
updated correctly.
</content>
</entry>
<entry>
<title>refactor: add a ‘range’ struct, grouping a start and end coord together</title>
<updated>2022-04-09T13:09:02Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-09T13:09:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5b1f1602bccfb7c37e50a8509f44b24e9aa3b5d1'/>
<id>urn:sha1:5b1f1602bccfb7c37e50a8509f44b24e9aa3b5d1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>selection: don’t translate \r to \n when pasting</title>
<updated>2022-03-19T18:01:25Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-03-16T19:17:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=485c473e76e7b90676a484d0f433d713f0c4c9ce'/>
<id>urn:sha1:485c473e76e7b90676a484d0f433d713f0c4c9ce</id>
<content type='text'>
In non-bracketed paste mode, we translate \n to \r, and \r\n to
\r. The latter matches XTerm, urxvt, alacritty and kitty. The former
matches alacritty and kitty (xterm and urxvt just blindly replaces all
\n occurrences with \r, meaning \r\n is translated to \r\r.

For some reason, we then unconditionally translated all \r back to \n,
regardless of whether bracketed paste was enabled or not. Unsure
why/where this comes from, but it doesn't match any of the other
terminal emulators I tested.

One example where this caused issues is in older versions of nano (at
least up to 2.9).

Closes #980
</content>
</entry>
<entry>
<title>selection: foreach: sort start/end based on their scrollback-start relative values</title>
<updated>2022-02-07T14:06:55Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-02-07T13:13:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=ef522e292faccff82fde76bd4b4c65cf211a93ae'/>
<id>urn:sha1:ef522e292faccff82fde76bd4b4c65cf211a93ae</id>
<content type='text'>
When iterating the characters in a selection, we want to go from the
“start” to the “end”, where start is the upper left-most character,
and “end” is the lower right-most character.

There are two things to consider:

* The ‘start’ coordinate may actually sort after the ‘end’
  coordinate (user selected from bottom of the window and upward)
* The scrollback wraparound.

What we do is calculate both the star and end coordinates’
scrollback-start relative row numbers. That is, the number of rows
from the beginning of the scrollback. So if the very first
row (i.e. the oldest) in the scrollback is selected, that has the
scrollback-start relative number “0”.

Then we loop from whichever (start or end coordinate) is highest up in
the scrollback, to the “other” coordinate.
</content>
</entry>
<entry>
<title>selection: ensure start/end coordinates are bounded by the current grid</title>
<updated>2022-02-07T14:06:39Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-02-07T12:56:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=2e828248d07490bd56baa3458a970e1ad34ede7c'/>
<id>urn:sha1:2e828248d07490bd56baa3458a970e1ad34ede7c</id>
<content type='text'>
Closes #924
</content>
</entry>
<entry>
<title>fcft: adapt to API changes in fcft-3.x</title>
<updated>2022-02-05T16:00:54Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-08-21T12:50:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e0227266cabc015c282774ac898e3f52dce943df'/>
<id>urn:sha1:e0227266cabc015c282774ac898e3f52dce943df</id>
<content type='text'>
Fcft no longer uses wchar_t, but plain uint32_t to represent
codepoints.

Since we do a fair amount of string operations in foot, it still makes
sense to use something that actually _is_ a string (or character),
rather than an array of uint32_t.

For this reason, we switch out all wchar_t usage in foot to
char32_t. We also verify, at compile-time, that char32_t used
UTF-32 (which is what fcft expects).

Unfortunately, there are no string functions for char32_t. To avoid
having to re-implement all wcs*() functions, we add a small wrapper
layer of c32*() functions.

These wrapper functions take char32_t arguments, but then simply call
the corresponding wcs*() function.

For this to work, wcs*() must _also_ be UTF-32 compatible. We can
check for the presence of the  __STDC_ISO_10646__ macro. If set,
wchar_t is at least 4 bytes and its internal representation is UTF-32.

FreeBSD does *not* define this macro, because its internal wchar_t
representation depends on the current locale. It _does_ use UTF-32
_if_ the current locale is UTF-8.

Since foot enforces UTF-8, we simply need to check if __FreeBSD__ is
defined.

Other fcft API changes:

* fcft_glyph_rasterize() -&gt; fcft_codepoint_rasterize()
* font.space_advance has been removed
* ‘tags’ have been removed from fcft_grapheme_rasterize()
* ‘fcft_log_init()’ removed
* ‘fcft_init()’ and ‘fcft_fini()’ must be explicitly called
</content>
</entry>
<entry>
<title>selection: don’t quote file URIs on the alt screen</title>
<updated>2022-02-02T20:17:01Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-02-02T20:17:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5ee902551a44bb01429dec38fd5b315d94b28479'/>
<id>urn:sha1:5ee902551a44bb01429dec38fd5b315d94b28479</id>
<content type='text'>
Closes #379
</content>
</entry>
</feed>
