Commit graph

2734 commits

Author SHA1 Message Date
Daniel Eklöf
d0c5cf6e9f
sixel: reflow: drop sixels that crosses the scrollback history’s end
This fixes various crashes that occurred after a reflow due to the
sixel image list invariants no longer being true.
2020-10-11 19:26:09 +02:00
Daniel Eklöf
d54adc5263
sixel: unhook: do overwrite *after* linefeeding
This ensures the overwrite is done when the scrollback history is in
the same state as when we then insert the new image.
2020-10-11 19:26:07 +02:00
Daniel Eklöf
0e4b0fefc1
sixel: overwrite: use pixman to calculate new the sixel boundaries
When punching a hole in a sixel (and thus splitting it up into up to
four new sixels), use pixman to calculate the new sixel coordinates
and sizes.
2020-10-11 19:26:05 +02:00
Daniel Eklöf
329a290f82
sixel: ovewrite-by-rectangle: in debug builds, cross-reference against pixman
Use pixman to calculate the intersection of the rectangle being
overwritten, and the sixel(s). Verify our code matches.
2020-10-11 19:26:03 +02:00
Daniel Eklöf
09e8a5b11d
sixel: verify scrollback consistency: new verify function
Verifies sixels have been scrolled out correctly
2020-10-11 19:26:01 +02:00
Daniel Eklöf
cc54c1bea7
sixel: add comments to verify_*() functions 2020-10-11 19:26:00 +02:00
Daniel Eklöf
0a802c2693
sixel: verify-*: don’t return anything; rely on asserts only 2020-10-11 19:25:58 +02:00
Daniel Eklöf
eec0971739
sixel: scroll up/down: early return when list is empty
Branch tagged as ‘likely’ for performance reason
2020-10-11 19:25:56 +02:00
Daniel Eklöf
3540031dc6
sixel: cell-size-changed: don’t verify sixels here
The state after this function is an intermediate state and isn’t
necessarily valid.

This sixels needs to be ‘reflowed’ to ensure a valid state. This is
something that should be done by the caller after the text grid has
been reflowed and the sixel coordinates have been re-mapped to the new
grid.

TODO: can/should we update the sixel cols/rows in sixel_reflow()
instead?
2020-10-11 19:25:55 +02:00
Daniel Eklöf
f834ae8add
sixel: unhook: look total number of sixels
This helps debug sixel overwrites, as it makes it more visible when
there are sixels that _should_ have been removed.
2020-10-11 19:25:53 +02:00
Daniel Eklöf
47c884da53
sixel: scroll-up: don’t break out early of loop
This function loops the list of sixels, and discards those that would
be scrolled out if the grid offset is moved forward by the specified
number of rows.

The criteria is when the rebased row value is less than the number of
rows to scroll.

A rebased row number is a zero-based number starting at the beginning
of the scrollback. Thus, when scrolling 5 rows, rows with a rebased
row number between 0-4 will be scrolled out.

For performance reasons, we used to break out of the loop as soon as a
row number *larger* than the scroll count.

This however does not work. The sixels are sorted by their *end*
row. While this works in most cases (think images outputted in the
shell in the normal screen), it doesn’t always.

In the alt screen, where applications can print images just about
anywhere, it is possible to have *any* start row number anywhere in
the sixel list. Just as long as their *end* row numbers are sorted.

For example, a huuuge sixel that covers the entire scrollback. This
sixel will naturally be first in the list (and thus sixel_scroll_up()
will visit it *last*, since it iterates the list in reverse), but
should still be destroyed when scrolling.
2020-10-11 19:25:51 +02:00
Daniel Eklöf
5a2cc9c9ae
sixel: verify-list-order: add an ‘index’ variable
This will make it easier when debugging assertions in this function.
2020-10-11 19:25:50 +02:00
Daniel Eklöf
96a20c9df7
sixel: overwrite-by-rectangle: assert sixels don’t cross scrollback wrap-around 2020-10-11 19:25:48 +02:00
Daniel Eklöf
6a8130c122
sixel: scroll: call sixel_erase() instead of sixel_destroy()
This ensures the screen is updated correctly. Without this, the sixel
image would remain on screen until force-refreshed by some other means.
2020-10-11 19:25:46 +02:00
Daniel Eklöf
74703822fb
sixel: TOOD -> TODO (fixes codespell build error) 2020-10-11 19:25:44 +02:00
Daniel Eklöf
29d0068462
sixel: verify-no-overlap: free pixman regions 2020-10-11 19:25:43 +02:00
Daniel Eklöf
e8f703eb65
sixel: verify-no-overlap: initialize ‘intersection’ pixman region 2020-10-11 19:25:41 +02:00
Daniel Eklöf
e19ee5f4d1
render: resize: call sixel_reflow() after reflowing grids 2020-10-11 19:25:39 +02:00
Daniel Eklöf
af7fd00909
sixel: unhook: only call render_refresh() once 2020-10-11 19:25:38 +02:00
Daniel Eklöf
2e7afc615c
sixel: implement reflow
Move sixel reflow from grid_reflow() to sixel_reflow(). This lets us
use internal sixel functions to update the sixels.

Note that grid_reflow() still needs to remap the sixelss coordinates.
2020-10-11 19:25:36 +02:00
Daniel Eklöf
660d6a06eb
term: update sixel rows/cols *after* cell dimension change, *before* resize
This fixes an issue where we resized+reflowed with bad rows/cols
values in the sixels.
2020-10-11 19:25:34 +02:00
Daniel Eklöf
da866f6453
sixel: verify-sixels: check for bad list order last 2020-10-11 19:25:32 +02:00
Daniel Eklöf
0876c7eafe
sixel: verify-no-wraparound-crossover: fix calculation of ‘end’ row 2020-10-11 19:25:31 +02:00
Daniel Eklöf
74c7373efc
sixel: add sixel_cell_size_changed()
This function should be called *after* the cell dimensions have
changed, but *before* resizing/reflowing the grids.
2020-10-11 19:25:29 +02:00
Daniel Eklöf
5e5036bec9
sixel: debug: more fine-grained verification of sixel image list
* Verify no sixel crosses the scrollback wrap-around
* Verify no sixels overlap
2020-10-11 19:25:27 +02:00
Daniel Eklöf
c4b84249a8
grid: reflow: re-insert sixels *after* new grid offset has been set
Also make sure to destroy sixels that are too big to fit in the scrollback.

Fixes issues with the sixel list not being sorted correctly.
2020-10-11 19:25:26 +02:00
Daniel Eklöf
368305aa59
sixel: overwrite: calculate split-up image pieces’ rows/cols from their width/height 2020-10-11 19:25:24 +02:00
Daniel Eklöf
e694f293ac
sixel: overwrite: remove asserts
Sixels may extend outside the visible screen area
2020-10-11 19:25:22 +02:00
Daniel Eklöf
9cccc76520
term: re-calculate sixel images’ rows/cols values when cell size changes 2020-10-11 19:25:20 +02:00
Daniel Eklöf
cdcdfe527c
sixel: fix sheared image when image crosses scrollback wrap-around
When a sixel image crosses the scrollback wrap-around, it is split up
into (at least) two pieces.

We use cursor->point.col for all pieces’ x-coordinate. This caused the
final image to appear sheared, since we do a carriage-return (after a
number of linefeeds) after each piece - this causes the cursor’s
position to be reset to the left margin.

The solution is simple; remember the cursor’s initial x-coordinate,
and use that to position all image pieces.

Closes #151.
2020-10-11 19:25:18 +02:00
Daniel Eklöf
7a7ba599c3
sixel: overwrite-by-rectangle expects ‘width’ to not exceed screen
This fixes a crash when the emitted sixel extends beyond the right
margin. The crash only happens when there are other sixel images
already emitted.

Fixes part of #151
2020-10-11 19:25:16 +02:00
Daniel Eklöf
2c515c27e5
sixel: fold long line 2020-10-11 19:25:14 +02:00
Daniel Eklöf
ab618dd192
doc: foot.1: remove ‘--’ from example command line 2020-10-11 19:25:07 +02:00
Daniel Eklöf
9de744ae39
doc: foot.ini: mention that ‘lines’ is rounded up to nearest power of 2 2020-10-11 19:25:06 +02:00
Daniel Eklöf
8257954bfa
doc: foot.ini: “top at” -> “top of” 2020-10-11 19:25:01 +02:00
Daniel Eklöf
6714c3343f
doc: foot.ini: it’s foot.ini, not foot.init 2020-10-11 19:24:56 +02:00
Daniel Eklöf
a53e8c2866
render: apply opacity correctly when in reverse video mode 2020-10-11 19:24:50 +02:00
Daniel Eklöf
5aa170b9f6
doc: foot.ini: the tweak section is called ‘tweak’, not ‘tweaks’ 2020-10-11 19:24:13 +02:00
Daniel Eklöf
852fc049c8
config: ignore key/value pairs following an invalid section name
When we detected an invalid section name, we correctly logged this and
warned the user.

However, the internal state machine now had an invalid section enum
value. This caused a crash when the next key/value pair was to be
parsed and we tried to lookup which parser function to call.

Closes #159.
2020-10-11 19:24:08 +02:00
Daniel Eklöf
3c057fb600
changelog: trackpad scrolling: ‘multiplier’ is in the ‘scrollback’ section 2020-10-11 19:23:35 +02:00
Daniel Eklöf
aa3fcc1251
changelog: multiplier: the option belongs to the ‘scrollback’ section 2020-10-11 19:23:33 +02:00
Daniel Eklöf
8181113e3c
changelog: multiplier default value changed from 1.0 -> 3.0 2020-10-11 19:23:31 +02:00
Daniel Eklöf
bf17026ed7
config: change default multiplier from 1.0 -> 3.0 2020-10-11 19:23:29 +02:00
Daniel Eklöf
1bc9c1c230
changelog: reword trackpad scrolling speed entry 2020-10-11 19:23:27 +02:00
Daniel Eklöf
8e04b08615
input: trackpad scroll: correctly convert pixel movements to line movements
Trackpad scroll movements are in pixels. Foot previously “translated”
these directly to line movements (i.e. a one pixel scroll event was
translated into a one line scroll).

Now we use the line height of the terminal and correctly convert
pixels to lines.

This makes the trackpad scroll speed in foot consistent with the
scroll speed in e.g. Alacritty and Kitty.
2020-10-11 19:23:25 +02:00
Daniel Eklöf
661fa98cb2
grid: reflow: fix release build; ‘idx’ is only used in an assert() 2020-10-11 19:23:12 +02:00
Daniel Eklöf
0e9eea85af
grid: reflow: handle viewport being too far down when enlarging the window
If the viewport is close to the bottom, but not *at* the bottom, and
we’re enlarging the window, the translated viewport will be too far
down.
2020-10-11 19:23:11 +02:00
Daniel Eklöf
b12ce3d7d7
grid: reflow: retain scrollback position
Closes #142
2020-10-11 19:23:09 +02:00
Daniel Eklöf
acd1d6a4a3
changelog: fixed color flashes with OSC 4,10,11 2020-10-11 19:23:06 +02:00
Daniel Eklöf
af2873987f
render: remove render_refresh_margins() 2020-10-11 19:23:04 +02:00