<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/selection.c, branch releases/1.17</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=releases%2F1.17</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=releases%2F1.17'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2024-02-06T11:36:45Z</updated>
<entry>
<title>Don't use fancy Unicode quotes, stick to ASCII</title>
<updated>2024-02-06T11:36:45Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-02-06T11:36:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7999975016a57cc0a2c2e20bc55f29de32df7044'/>
<id>urn:sha1:7999975016a57cc0a2c2e20bc55f29de32df7044</id>
<content type='text'>
</content>
</entry>
<entry>
<title>util: add streq() function and use in place of strcmp(...) == 0</title>
<updated>2024-02-05T11:09:52Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2024-01-24T23:17:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e0f3703ae6c4084f9275cfc78d87e5604cc27a10'/>
<id>urn:sha1:e0f3703ae6c4084f9275cfc78d87e5604cc27a10</id>
<content type='text'>
</content>
</entry>
<entry>
<title>selection: find_word_boundary: ensure row number is bounded</title>
<updated>2023-10-08T08:38:39Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-10-03T12:07:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=ca128ae3802dde3b2bafab190a09911589d23e8a'/>
<id>urn:sha1:ca128ae3802dde3b2bafab190a09911589d23e8a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>selection: selection_update() uses view-local coordinates</title>
<updated>2023-10-08T08:38:38Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-09-27T14:23:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5e013cad78a1989f4deb0972a465dfcdad0dc1d2'/>
<id>urn:sha1:5e013cad78a1989f4deb0972a465dfcdad0dc1d2</id>
<content type='text'>
</content>
</entry>
<entry>
<title>search: add more key bindings to extend the current match</title>
<updated>2023-10-08T08:38:37Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-09-26T15:54:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=78665a7e809afd470e1236867761d51de9737eaa'/>
<id>urn:sha1:78665a7e809afd470e1236867761d51de9737eaa</id>
<content type='text'>
This patch adds the following new search key bindings:

* extend-char (shift+right)
* extend-line-down (shift+down)
* extend-backward-char (shift+left)
* extend-backward-to-word-boundary (ctrl+shift+left)
* extend-backward-to-next-whitespace (ctrl+shift+alt+left)
* extend-line-up (shift+up)

They can be used to extend the search match (i.e. the selection).

This patch also adds an initial set of key bindings to scroll in the
scrollback history:

* scrollback-up-page
* scrollback-down-page

These work just like the key bindings for the normal mode. Also note
that it was already possible to scroll using the mouse.

This patch also fixes a couple of search mode bugs:

* crashing when a search match ends in the last column
* grapheme clusters not being matched correctly
* Search match not being "extendable" after a pointer leave event
* A few others, related to either large matches, or extending matches
  after moving the viewport.

There are still a couple of (known) issues:

* A search match isn't correctly highlighted if its *starting* point
  is outside the viewport.
* Extending the match to end of the scrollback (i.e. the most recent
  output) is simply buggy.

Related to #419
</content>
</entry>
<entry>
<title>selection: add support for selecting the contents of a quote</title>
<updated>2023-09-19T14:23:34Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-09-19T14:23:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=1719ff93a75ad886ed53be468f7faa12f530e9f3'/>
<id>urn:sha1:1719ff93a75ad886ed53be468f7faa12f530e9f3</id>
<content type='text'>
This patch changes the default of triple clicking, from selecting the
current logical row, to first trying to select the contents of the
quote under the cursor, and if failing to find a quote, selecting the
current row (like before).

This is implemented by adding a new key binding, 'select-quote'.

It will search for surrounding quote characters, and if one is found
on each side of the cursor, the quote is selected. If not, the entire
row is selected instead.

Subsequent selection operations will behave as if the selection is
either a word selection (a quote was found), or a row selection (no
quote found).

Escaped quote characters are not supported: "foo \" bar" will match
'foo \', and not 'foo " bar'.

Mismatched quotes are not custom handled. They will simply not match.

Nested quotes ("123 'abc def' 456") are supported.

Closes #1364
</content>
</entry>
<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>
</feed>
