<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/selection.c, branch 1.15.3</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.15.3</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.15.3'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2023-07-22T09:21:12Z</updated>
<entry>
<title>selection: send_clipboard_or_primary(): handle selection text being NULL</title>
<updated>2023-07-22T09:21:12Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-07-22T09:21:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=fc973a3bb934de7fe6001be7b6c39714e7b5470d'/>
<id>urn:sha1:fc973a3bb934de7fe6001be7b6c39714e7b5470d</id>
<content type='text'>
</content>
</entry>
<entry>
<title>selection: selection_on_rows(): typo: row_start -&gt; row_end</title>
<updated>2022-11-24T18:18:20Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-11-24T16:05:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0fc8b65a2b77a5c4dd066e4d49be470ee1d1f70a'/>
<id>urn:sha1:0fc8b65a2b77a5c4dd066e4d49be470ee1d1f70a</id>
<content type='text'>
This fixes an issue where selections in the scroll margins were not
detected correctly. This meant they weren’t canceled as they should
have been, which in turn caused a visual glitch where text appeared to
be selected, but were in fact not.
</content>
</entry>
<entry>
<title>selection: scroll down: handle non-full scrollback correctly</title>
<updated>2022-10-16T08:31:15Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-14T16:03:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=89744f8123aadd58b74ea7b5038c3302c1ed75ed'/>
<id>urn:sha1:89744f8123aadd58b74ea7b5038c3302c1ed75ed</id>
<content type='text'>
When determining whether or not to cancel a selection (due to it, or
part of it, being "scrolled out"), we assumed the scrollback was full.

This patch changes the implementation to compare the scrollback
relative selection coordinates with the scrollback relative
end-of-the-scrollback coordinates.
</content>
</entry>
<entry>
<title>selection: mark_selected_region(): use an enum to encode how the cells are to be updated</title>
<updated>2022-08-26T19:07:20Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-08-26T19:07:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=d5df86f7853a47aa2de4aea7f4b5a84e918ea433'/>
<id>urn:sha1:d5df86f7853a47aa2de4aea7f4b5a84e918ea433</id>
<content type='text'>
</content>
</entry>
<entry>
<title>selection: restore &lt;= 1.12 behavior in block selection wrt empty cells</title>
<updated>2022-08-26T15:48:00Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-08-26T15:48:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=db2737b96a2cf82b3c1ced2549e4e795ffe13b04'/>
<id>urn:sha1:db2737b96a2cf82b3c1ced2549e4e795ffe13b04</id>
<content type='text'>
That is, highlight empty cells, regardless of whether they’re trailing
or not.
</content>
</entry>
<entry>
<title>selection: once again highlight non-trailing empty cells</title>
<updated>2022-08-22T18:14:06Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-08-22T18:14:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=21ab16239d87fe8fb4d7651b4bccbe1f611df620'/>
<id>urn:sha1:21ab16239d87fe8fb4d7651b4bccbe1f611df620</id>
<content type='text'>
Foot 1.13.0 introduced a regression where non-trailing empty cells
were highlighted inconsistently (cells that shouldn’t be highlighted,
were, seemingly at random).

86663522d5915c0fdb2b8b132bacc247fcfd1fb8 “fixed” this by never
highlighting *any* empty cells.

This meant the behavior, compared to foot 1.12 and earlier,
changed. In foot 1.12 and older versions, non-trailing empty cells
were highlighted, as long as the selection covered at least one of the
trailing non-empty cells.

This patch restores that behavior.

To understand how this works, lets first take a look at how selection
works:

When a selection is made, and updated (i.e. the mouse is dragged, or
the selection is extended through RMB etc), we need to (un)tag and dirty
the cells that are a) newly selected, or b) newly deselected. That is,
we look at the diff between the “old” and the “new” selection, and
only update those cells.

This is for performance reasons: iterating the entire selection is not
feasible with large selections. However, it also means we cannot
reason about empty cells; we simply don’t know if an empty cells is a
trailing empty cell, or a non-trailing one.

Then, when we render a frame, we iterate all the *visible*
and *selected* cells, once again tagging them as selected (this is
needed since a selected cell might have lost its selected tag if the
cell was written to, by the client application, after the selection
was made).

At this point, we *can* reason about empty cells.

So, to restore the highlighting behavior to that of foot 1.12, we do
this:

When working with the selection diffs when a selection is updated, we
don’t special case empty cells at all. Thus, all empty cells covered
by the selection is highlighted, and dirtied.

But, when rendering the frame, we _do_ special case them. The only
difference (compared to foot 1.12) is that we *must*
explicitly *clear* the selection tag, and dirty the empty cells. This
is to ensure the empty cells that were incorrectly highlighted by the
selection update algorithm, isn’t rendered as that.

This does have a slight performance impact, as empty cells are now
always re-rendered. The impact should however be small.
</content>
</entry>
<entry>
<title>selection: never highlight selected, empty cells</title>
<updated>2022-08-22T11:35:52Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-08-17T15:36:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=86663522d5915c0fdb2b8b132bacc247fcfd1fb8'/>
<id>urn:sha1:86663522d5915c0fdb2b8b132bacc247fcfd1fb8</id>
<content type='text'>
This fixes a regression, where empty cells "between" non-empty
cells (i.e. non-trailing empty cells) sometimes were incorrectly
highlighted.

The idea has always been to highlight exactly those cells that will
get extracted when they’re copied. This means we’ve not highlighted
trailing empty cells, but we _have_ highlighted other empty cells,
since they are converted to spaces when copied (whereas trailing empty
cells are skipped).

fa2d9f86996467ba33cc381f810ea966a4323381 changed how a selection is
updated. That is, which cells gets marked as selected, and which ones
gets unmarked.

Since we no longer walk all the cells, but instead work with pixman
regions representing selection diffs, we can no longer determine (with
certainty) which empty cells should be selected and which shouldn’t.

Before this patch (but after
fa2d9f86996467ba33cc381f810ea966a4323381), we sometimes incorrectly
highlighted empty cells that should not have been highlighted. This
happened when we’ve first (correctly) highlighted a region of empty
cells, but then shrink the selection such that all those empty cells
should be de-selected.

This patch changes the selection behavior to *never* highlight empty
cells. This fixes the regression, but also means slightly different
behavior, compared to pre-fa2d9f86996467ba33cc381f810ea966a4323381.

The other alternative is to always highlight all empty cells. But,
since I personally like the fact that we’re skipping trailing empty
cells, I prefer the approach taken by this patch.
</content>
</entry>
<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>
</feed>
