<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/search.c, branch 1.22.3</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.22.3</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.22.3'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2025-03-05T07:48:23Z</updated>
<entry>
<title>config: add search-bindings.delete-to-{start,end} key bindings</title>
<updated>2025-03-05T07:48:23Z</updated>
<author>
<name>Adrian fxj9a</name>
<email>af24@tuta.io</email>
</author>
<published>2025-03-03T13:27:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6d39f66eb7c0cafb9e12be7da6831598c6dd4afb'/>
<id>urn:sha1:6d39f66eb7c0cafb9e12be7da6831598c6dd4afb</id>
<content type='text'>
Defaults to ctrl+u and ctrl+k respectively.

Closes #1972
</content>
</entry>
<entry>
<title>input: match unshifted key-bindings before shifted</title>
<updated>2025-01-31T08:07:42Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2025-01-31T08:07:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=51128a3484049e5f9b9b74276222977d12554d76'/>
<id>urn:sha1:51128a3484049e5f9b9b74276222977d12554d76</id>
<content type='text'>
That is, try to match e.g. Control+shift+a, before trying to match
Control+A.

In most cases, order doesn't matter. There are however a couple of
symbols where the layout consumes the shift-modifier, and the
generated symbol is the same in both the shifted and unshifted
form. One such example is backspace.

Before this patch, key-bindings with shift-backspace would be ignored,
if there were another key-binding with backspace.

So, for example, if we had one key-binding with Control+Backspace, and
another with Control+Shift+Backspace, the latter would never trigger,
as we would always match the first one.

By checking for unshifted matches first, we ensure
Control+Shift+Backspace does match.
</content>
</entry>
<entry>
<title>input: ignore key-bindings without modifiers when matching untranslated/raw</title>
<updated>2025-01-31T06:35:54Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2025-01-31T06:35:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=bee17a95b86a640522c25e650e13aebc82c7353d'/>
<id>urn:sha1:bee17a95b86a640522c25e650e13aebc82c7353d</id>
<content type='text'>
When matching the unshifted symbol, or the raw key code, ignore all
key bindings that don't have any modifiers.

This fixes an issue where it was impossible to enter (some of the)
numbers on the keypad, **if** there was a key-binding for
e.g. KP_Page_Up, or KP_Page_Down.
</content>
</entry>
<entry>
<title>key-bindings: try all bindings in translated mode before matching untranslated, and then finally raw</title>
<updated>2025-01-27T11:31:40Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2025-01-27T09:51:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8d6f0d0583a1cb7c245ff54ec472a03ebcdb6949'/>
<id>urn:sha1:8d6f0d0583a1cb7c245ff54ec472a03ebcdb6949</id>
<content type='text'>
When trying to match key bindings, we do three types of matching:

* Match the _translated_ symbol (e.g. Control+C)
* Match the _untranslated_ symbol (e.g. Control+Shift+c)
* Match raw keyboard codes

This was done for *each* key binding. This meant we sometimes matched
a keybinding in raw mode, even though there was a
translated/untranslated binding that would match it too. All depending
on the internal order of the key binding list.

This patch changes it, so that we first try all bindings in translated
mode, then all bindings in untranslated mode, and finally all bindings
in raw mode.

Closes #1929
</content>
</entry>
<entry>
<title>unicode-mode: move state from seat to term</title>
<updated>2024-05-21T06:36:56Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-05-21T05:06:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=18b702b2495d4fb9328930eed9875731cff4cbde'/>
<id>urn:sha1:18b702b2495d4fb9328930eed9875731cff4cbde</id>
<content type='text'>
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.

The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.

The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.

There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.

This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.

Closes #1717
</content>
</entry>
<entry>
<title>input: remove the concept of "significant" modifiers</title>
<updated>2024-02-06T10:08:42Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-02-06T09:41:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0aefc2c65de8cca39ddbf9d8c12f1a4d4206b42a'/>
<id>urn:sha1:0aefc2c65de8cca39ddbf9d8c12f1a4d4206b42a</id>
<content type='text'>
For the purpose of matching key bindings, "significant" modifiers are
no more.

We're really only interested in filtering out "locked"
modifiers. We're already doing this, so there's no need to *also*
match against a set of "significant" modifiers.

Furthermore, we *never* want to consider locked keys (e.g. when
emitting escapes to the client application), thus we can filter those
out already when retrieving the set of active modifiers.

The exception is the kitty keyboard protocol, which has support for
CapsLock and NumLock. Since we're already re-retrieving the "consumed"
modifiers (using the GTK style, rather than normal "XKB" style, to
better match the kitty terminal), we might as well re-retrieve the
effective modifiers as well.
</content>
</entry>
<entry>
<title>config: add remaining search.scrollback key bindings</title>
<updated>2023-10-08T08:38:39Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-10-08T08:37:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=3e67415e3e7b09c3e10c4ace3008bbaaae54110a'/>
<id>urn:sha1:3e67415e3e7b09c3e10c4ace3008bbaaae54110a</id>
<content type='text'>
All scrollback up/down key bindings are now available in search mode.
</content>
</entry>
<entry>
<title>search: fix mixup in search_extend_find_line()</title>
<updated>2023-10-08T08:38:39Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-10-08T08:28:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=a772179b6c850aad32f52d51c384ad933746c0cd'/>
<id>urn:sha1:a772179b6c850aad32f52d51c384ad933746c0cd</id>
<content type='text'>
The has_wrapped_around_{right,left} functions were mixed up, causing
false positives and false negatives, resulting in bad search matches.

Also make all search_extend_find* functions return a boolean; false
means no change in the selection. In this case, we can skip trying to
extend the selection, and updating the UI.
</content>
</entry>
<entry>
<title>search: don't try to extend a search match when there is none</title>
<updated>2023-10-08T08:38:39Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-09-27T16:36:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=ddf4eb3b78ebe590d0dd6675536f9a7e4043ee71'/>
<id>urn:sha1:ddf4eb3b78ebe590d0dd6675536f9a7e4043ee71</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>search: regression: refresh current view when canceling a scrollback search</title>
<updated>2023-05-15T18:34:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-05-15T18:34:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=738deb236853ebf1e19843e536b9bda053b69bf7'/>
<id>urn:sha1:738deb236853ebf1e19843e536b9bda053b69bf7</id>
<content type='text'>
3b41379be43a21a00a776d0d136c5d1b2fe4007e introduced a regression,
where canceling a scrollback search didn’t refresh the viewport
correctly; the viewport was changed, but the screen content was not
refreshed.

This worked before, because the workaround for
https://github.com/swaywm/sway/issues/6960 always called
term_damage_view() when exiting scrollback search mode.

3b41379be43a21a00a776d0d136c5d1b2fe4007e removed that call since it’s
no longer required. *Except* when executing the
BIND_ACTION_SEARCH_CANCEL binding, since then the viewport may be
moved.

Note that this regression affected *all* compositors, not just Sway.

Closes #1354
</content>
</entry>
<entry>
<title>quirks: sway does not damage surface beneath sub-surface, when unmapped</title>
<updated>2023-05-12T12:51:05Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-04-25T19:33:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=3b41379be43a21a00a776d0d136c5d1b2fe4007e'/>
<id>urn:sha1:3b41379be43a21a00a776d0d136c5d1b2fe4007e</id>
<content type='text'>
When unmapping a sub-surface, Sway &lt;= 1.8 does not damage the surface
beneath the sub-surface.

https://github.com/swaywm/sway/issues/6960

The workaround is to manually damage the main surface. Previously,
this was done when exiting scrollback search, and after the ‘flash’
OSC. But other sub-surfaces, that may also be unmapped, did not.

This patch adds a quirk handler that does this, and calls it when:

* Exiting scrollback search
* Ending the ‘flash’ OSC
* Exiting unicode input mode
* Clearing URL labels
* Removing the scrollback position indicator

Closes #1335
</content>
</entry>
<entry>
<title>input: add new Unicode input mode</title>
<updated>2022-07-29T07:26:31Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-07-28T16:09:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8967dd9cfe51276d63ef8ff64e8fc76f80a6fa3d'/>
<id>urn:sha1:8967dd9cfe51276d63ef8ff64e8fc76f80a6fa3d</id>
<content type='text'>
This mode is activated through the new key-bindings.unicode-input and
search-bindings.unicode-input key bindings.

When active, the user can “build” a Unicode codepoint by typing its
hexadecimal value.

Note that there’s no visual feedback in this mode. This is
intentional. This mode is intended to be a fallback for users that
don’t use an IME.

Closes #1116
</content>
</entry>
<entry>
<title>search: find_next(): handle trailing SPACER cells</title>
<updated>2022-07-28T19:05:06Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-07-28T16:56:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=632c4839cdb1c673bfb3903e1d43802bfdcbf03f'/>
<id>urn:sha1:632c4839cdb1c673bfb3903e1d43802bfdcbf03f</id>
<content type='text'>
Make sure to increment match_end_col to account for trailing SPACER
cells after a match.

This fixes an issue where search matches weren’t highlighted correctly
when the match *ends* with a double-width character.
</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>search: fix infinite loop when highlighting all matches</title>
<updated>2022-04-26T18:36:28Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-26T16:24:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0e9ebf433b589c15e17bd37f73991ecc71e9b3d6'/>
<id>urn:sha1:0e9ebf433b589c15e17bd37f73991ecc71e9b3d6</id>
<content type='text'>
find_next() did not always terminate correctly, causing
search_matches_next() to never terminate, which finally leads to an
infinite loop when rendering the search overlay surface, while finding
all matches to highlight.

The problem is that find_next(), after having found the initial
matching characters, enters a nested while loop that tries to match
the rest of the search criteria. This inner while loop did not check
if we’ve reached the last cell, and happily continued past
it (eventually wrappping around the scrollback buffer).

Closes #1047
</content>
</entry>
<entry>
<title>search: assert that the match is *inside* the new viewport</title>
<updated>2022-04-26T17:47:02Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-26T17:47:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=694938b85bed679c95ac506711475bf06cd80b0e'/>
<id>urn:sha1:694938b85bed679c95ac506711475bf06cd80b0e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>search: regression: crash when moving viewport</title>
<updated>2022-04-26T17:32:08Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-26T17:32:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c82c6116ede2706a9d5b28d43e8271ec13be2794'/>
<id>urn:sha1:c82c6116ede2706a9d5b28d43e8271ec13be2794</id>
<content type='text'>
5c4ddebc3c57724bd89b959a33f5ad0bd97f482b refactored
search_update_selection(), specifically, the logic that moves the
viewport.

It did so by converting the absolute row number (of the match) to
scrollback relative coordinates. This way we could ensure the viewport
wasn’t moved “too much” (e.g. beyond the scrollback start).

However, grid_row_abs_to_sb() and grid_row_sb_to_abs() doesn’t take a
partially filled scrollback into account. This means the row (numbers)
it returns may refer to *uninitialized* rows.

Since:

* The match row itself is valid (we *know* it has text on it)
* We *subtract* from it, when setting the new viewport (to center the
  match on the screen).

it’s only the *upper* part of the new viewport that may be
uninitialized. I.e. we may have adjusted it too much.

So, what we need to do is move the viewport forward until its *first*
row is initialized. Then we know the rest will be too.
</content>
</entry>
<entry>
<title>search: work around Sway sub-surface unmap bug</title>
<updated>2022-04-26T15:41:38Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-25T17:55:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=1e87dbc4dc87c9567a7851135d91728796b0696f'/>
<id>urn:sha1:1e87dbc4dc87c9567a7851135d91728796b0696f</id>
<content type='text'>
Unmapping a sub-surface in Sway does not damage the underlying
surface.

As a result, "committing" a scrollback search will typically leave
most of the foot window dimmed.

It can be seen when "cancelling" a search as well, but there it's less
obvious - only the margins are left dimmed. This is because cancelling
a search damaged the current viewport (something that shouldn't be
needed).

Out of sway, river, weston and mutter, only Sway needs this
workaround.

This is a workaround for https://github.com/swaywm/sway/issues/6960
</content>
</entry>
<entry>
<title>search: fix multiple crashes</title>
<updated>2022-04-25T18:00:47Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-25T18:00:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5c4ddebc3c57724bd89b959a33f5ad0bd97f482b'/>
<id>urn:sha1:5c4ddebc3c57724bd89b959a33f5ad0bd97f482b</id>
<content type='text'>
* When extending the selection to the next word boundary, ensure the
  row numbers are valid:

  - use selection_get_end() when retrieving the current end
    coordinate. This alone fixes a crash where we previously would
    crash in an out-of-bounds array access in grid-&gt;rows[], due to
    term-&gt;selection.coords.end being unbounded.

  - ensure the new end coordinate is bounded before and after calling
    selection_find_word_boundary_right().

* When moving the viewport (to ensure a new match is visible), make
  sure we don’t end up with the match outside the new viewport.

  Under certain, unusual, circumstances, the moved viewport _still_
  did not contain the match. This resulted in assertions triggering
  later, that assumed the match(es) are *always* visible.

  It’s fairly easy to trigger this one by running foot with e.g.

    foot -o scrollback.lines=0 --window-size-chars 25x3

  and then hitting enter a couple of times, to fill the scrollback
  history (which should consist of a single row in the example above),
  and the do a scrollback search for (part of) the prompt, and keep
  searching backward until it crashes.

  This would happen if calculated (new) viewport had to be adjusted
  (for example, to ensure it didn’t go past the scrollback end).

  This patch changes the logic used when calculating the new
  viewport. Instead of calculating the wanted viewport (match is
  vertically centered) and then trying to adjust it to ensure the new
  viewport is valid, start with a “safe” new viewport value, and then
  determine how much we can move it, if at all, to center the match.

  This is done by using scrollback relative coordinates. In this
  coordinate system, the new viewport must be

    &gt;= 0, and &lt; grid-&gt;num_lines - term-&gt;rows

  This makes it very easy to limit the amount by which the viewport is
  adjusted.

  As a side-effect, we can remove all the old re-adjustment logic.

* The match iterator no longer special cases the primary match. This
  was needed before, when the search iterator did not handle
  overlapping matches correctly. Now that we do, the iterator is
  guaranteed to find the primary match, and thus we no longer need to
  special case it.

  This fixes a bug where the primary match was returned twice, due to
  the logic checking if a secondary match is the same as the primary
  match was flawed...

Closes #1036
</content>
</entry>
</feed>
