Commit graph

5496 commits

Author SHA1 Message Date
Daniel Eklöf
8356dfac2f
Disable debug logging 2022-04-27 18:44:17 +02:00
Daniel Eklöf
32d9895697
term: reset sixel options when hard resetting the terminal state 2022-04-26 21:05:17 +02:00
Daniel Eklöf
aa4c7c5a30
config: add ctrl+shift+v and XF86 paste to SEARCH_CLIPBOARD_PASTE
We now bind ctrl+v, ctrl+shift+v, ctrl+y and XF86Paste to pasting from
the clipboard into the scrollback search buffer.

Why all these? Because we can, and because all are common shortcuts
for pasting:

* ctrl+v: “normal” apps use this by default
* ctrl+shift+v: used in terminals (including foot)
* ctrl+y: Emacs
* XF86Paste: special keyboard key, for pasting
2022-04-26 20:37:30 +02:00
Daniel Eklöf
0e9ebf433b
search: fix infinite loop when highlighting all matches
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
2022-04-26 20:36:28 +02:00
Daniel Eklöf
694938b85b
search: assert that the match is *inside* the new viewport 2022-04-26 19:47:02 +02:00
Daniel Eklöf
c82c6116ed
search: regression: crash when moving viewport
5c4ddebc3c 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.
2022-04-26 19:32:08 +02:00
Daniel Eklöf
93dcb7dc9c
changelog: typo: space on the wrong side of the parenthesis 2022-04-26 17:52:00 +02:00
Daniel Eklöf
29f07c791e
Merge branch 'sway-sub-surface-damage-workaround'
Closes #1046
2022-04-26 17:44:16 +02:00
Daniel Eklöf
3abb23c81c
changelog: workaround for Sway bug #6960 2022-04-26 17:42:46 +02:00
Daniel Eklöf
398d96fdb2
term: flash: work around Sway sub-surface unmap bug
Unmapping a sub-surface in Sway does not damage the underlying
surface.

As a result, the OSC-555 escape (“flash”) will leave yellow margins on
~every second frame.

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

This is a workaround for https://github.com/swaywm/sway/issues/6960

Closes #1046
2022-04-26 17:41:38 +02:00
Daniel Eklöf
1e87dbc4dc
search: work around Sway sub-surface unmap bug
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
2022-04-26 17:41:38 +02:00
Daniel Eklöf
57543c4290
Merge branch 'search-crashes'
Closes #1036
2022-04-26 17:40:58 +02:00
Daniel Eklöf
b94f540113
changelog: search mode not always highlighting all matches correctly 2022-04-26 17:40:20 +02:00
Daniel Eklöf
1b5b1d5d92
changelog: crash when extending selection in search mode 2022-04-26 17:40:00 +02:00
Daniel Eklöf
5c4ddebc3c
search: fix multiple crashes
* 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->rows[], due to
    term->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

    >= 0, and < grid->num_lines - term->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
2022-04-25 20:00:47 +02:00
Daniel Eklöf
1d4e1b921d
sixel/terminal: use the new grid and selection APIs
Use grid_row_abs_to_sb() instead of manually “rebasing” row numbers.

Use selection_get_{start,end}() to retrieve the current selection
coordinates.
2022-04-25 20:00:14 +02:00
Daniel Eklöf
6316a5eb0c
selection: add start/end coordinate getters
Internally, selection coordinates are *unbounded* (that is, the row
numbers may be larger than grid->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->selection.coords.* directly.
2022-04-25 19:59:23 +02:00
Daniel Eklöf
b4f666118f
grid: add abs-to-sb and sb-to-abs utility function
These functions convert row numbers between absolute coordinates and
“scrollback relative” coordinates.

Absolute row numbers can be used to index into the grid->rows[] array.

Scrollback relative numbers are ordered with the *oldest* row first,
and the *newest* row last. That is, in these coordinates, row 0 is the
*first* (oldest) row in the scrollback history, and row N is the
*last* (newest) row.

Scrollback relative numbers are used when we need to sort things after
their age, when determining if something has scrolled out, or when
limiting an operation to ensure we don’t go past the scrollback
wrap-around.
2022-04-25 19:57:18 +02:00
Daniel Eklöf
a26eb1ea09
input: assert serial received from compositor is non-zero 2022-04-24 20:18:51 +02:00
Daniel Eklöf
9c0f1a671c
selection: assert serial is non-zero before copying data to the clipboard 2022-04-24 20:18:51 +02:00
Daniel Eklöf
312f0dbcfd
changelog: scrollback mode freezing, with 100% CPU 2022-04-24 20:18:49 +02:00
Daniel Eklöf
1d48b7b77c
search: matches_next: assert start’s ‘col’ is valid 2022-04-24 20:17:37 +02:00
Daniel Eklöf
082e242ce5
search: matches_next: stop searching when start.row >= term->rows
As this means the last call to sarch_matches_next() found a match at
the bottom of the view, and then set the iter’s *next* start position
to a row outside the view.

This is fine, but we need to handle it, by immediately stopping the
iter.
2022-04-24 20:17:37 +02:00
Daniel Eklöf
d068e821d6
search: matches_next: don’t wrap around grid->num_rows
When bumping the iter’s start.row, we’re working with view-local
coordinates. That is, 0 >= row < term->rows.

This means it is wrong to and with grid->num_rows - 1, because a),
‘row’ should **never** be that big. And b), if we do, we’ll just end
up in an infinite loop, where the next call to matches_next() just
starts over from the beginning again (and eventually hitting the exact
same place that got us started).
2022-04-24 20:17:37 +02:00
Daniel Eklöf
f7c29ee394
search: maches_next: assert match coordinates are valid
* They are within range (i.e. ‘row’ does not exceed term->rows-1)
* ‘end’ comes after ‘start’
2022-04-24 20:17:37 +02:00
Daniel Eklöf
8c0fca30db
selection: find_word_boundary: assert ‘pos’ is valid 2022-04-24 20:17:29 +02:00
Daniel Eklöf
47d1ba58e5
changelog: UI not refreshing when pasting into the scrollback search box 2022-04-24 12:08:23 +02:00
Daniel Eklöf
2cbcfb3159
render: fix refresh logic of pending csd|search|url
Our CSDs, the search-box and URL labels are all implemented using
sub-surfaces, synchronized with the main grid.

This means we *must* commit the main surface as well, when updating
one of these sub-surfaces.

The logic for doing so in the frame callback was flawed, and only
triggered when the main grid was actually dirty.

That is, e.g. search box updates that did not also resulted in grid
updates (for example - pasting a search criteria that doesn’t match),
did not result in a UI refresh.

Closes #1040
2022-04-24 12:04:06 +02:00
Daniel Eklöf
b68d5da71b
search: fix debug log
This has been broken since the forward/backward search logic was
refactored.
2022-04-24 12:03:31 +02:00
Daniel Eklöf
f0f0fac77f
doc: foot.ini: drop empty line after *show-urls-launch* 2022-04-23 20:08:09 +02:00
Daniel Eklöf
155a2e4790
ci: enable -Db_pgo=generate on release builds
Hopefully, this’ll catch missing stubs in pgo/pgo.c in the future.
2022-04-23 11:24:44 +02:00
Daniel Eklöf
1913fb6efd
changelog: hyperlink lists under their corresponding sub-section 2022-04-23 11:13:25 +02:00
Daniel Eklöf
4ca0407945
raedme: add a reference to foot-ctlseq(7) 2022-04-23 11:11:34 +02:00
Daniel Eklöf
ce4fd6df3f
readme: add OSC 22 2022-04-23 11:10:37 +02:00
Daniel Eklöf
ae2999740e
readme: default foot.ini is now installed to /etc/xdg/foot/foot.ini 2022-04-23 11:10:09 +02:00
Daniel Eklöf
9483a3a7c0
changelog: pgo helper binary build fix (missing key-binding stubs) 2022-04-23 00:49:52 +02:00
Daniel Eklöf
8ceb6e45a4
pgo: add missing stubs for key-binding functions
* key_binding_new_for_term()
* key_binding_unref_term()
2022-04-23 00:44:46 +02:00
Daniel Eklöf
1383def2a0
changelog: convert all issue links to reference links in the 1.12.0 release 2022-04-22 20:05:33 +02:00
Daniel Eklöf
61446df895
Revert "changelog: convert all issue links to reference links in the 1.12.0 release"
This reverts commit 6652a836ad.

We only added the actual links to the 1.12.0 release, meaning all
other issue hyperlinks broke.
2022-04-22 20:02:15 +02:00
Daniel Eklöf
6652a836ad
changelog: convert all issue links to reference links in the 1.12.0 release 2022-04-22 18:54:49 +02:00
Daniel Eklöf
e284c764b7
changelog: replace all bug refs with markdown hyperlinks 2022-04-22 18:36:28 +02:00
Daniel Eklöf
2d4d919687
changelog: add new ‘unreleased’ section 2022-04-22 17:19:04 +02:00
Daniel Eklöf
d8c4e21090
Merge branch 'releases/1.12' 2022-04-22 17:18:26 +02:00
Daniel Eklöf
ea1171a5a2
meson: bump version to 1.12.0 2022-04-22 17:14:41 +02:00
Daniel Eklöf
0cdd32043e
changelog: prepare for 1.12.0 2022-04-22 17:14:00 +02:00
Daniel Eklöf
c7248cf763
meson: add -Dtests=false|true option
When set to false, no test binaries are neither built, nor
executed (with “ninja test”).

Closes #919
2022-04-22 17:05:25 +02:00
Merlin Büge
e6f884a9e1
doc + meson.build: update information about foot.ini, small cleanup
- foot.ini.5: mention location of example config file
- foot.1: replace outdated (or incomplete) information about the
  location of the config file with references to foot.ini.5
- foot.1 and foot.ini.5: conform to scdoc specification, thus surround each
  header with (at least) one blank line. additionally consistently use exactly
  one line before/after each header (was sometimes two before)
- foot.1: some parts of the keybindings had their own section, move into
  KEYBOARD SHORTCUTS section
- foot.1: move EXIT STATUS section to the end where it is commonly found
- foot.1: copy information about config file handling from the beginning of
  foot.ini.5 into the CONFIGURATION section of foot.1
- INSTALL.md: foot.ini is no longer included in the documentation
- meson.build: do not bundle foot.ini with documentation anymore, see also
  https://codeberg.org/dnkl/foot/pulls/1015

Closes #1002
2022-04-22 17:00:04 +02:00
Daniel Eklöf
9907d7bbe9
search: don't modify search.start coord *before* finding next match
The match logic uses the last start coordinate to determine which end
points in the selection to update. This sometimes fails when the start
coordinate has been changed by e.g. a key binding - the new start
coordinate is incorrectly matched against the old-but-modified start
coordinate, causing foot to e.g. *not* upate the selection start
coordinate.

Example:

  $ echo 'test\n\test\ntest'

Then do a scrollback search for 'test. The first match is found
correctly (the last 'test'), but searching for the previous match
(ctrl+r) does not select the middle 'test'.

Fix by passing the search direction to search_find_next(), and have
_it_ calculate the coordinate to start search. There are three possibilities:

* forward
* backward
* "backward", but at the same position

The first two are used when searching for next/prev match with ctrl+s
and ctrl+r. The last one is used when the search criteria is
updated. In this case, we don't want to move to the previous match,
*unless* the current match no longer matches.
2022-04-21 18:54:27 +02:00
Daniel Eklöf
dd03e10c6c
url-mode: allow locked modifiers while handling label letter input
This fixes an issue where labels couldn’t be activated if e.g. NumLock
was enabled.
2022-04-20 21:50:49 +02:00
Daniel Eklöf
6ed9a31007
changelog: move “re-mapping input” from “changed” to “added” 2022-04-20 20:56:04 +02:00