Commit graph

87 commits

Author SHA1 Message Date
Daniel Eklöf
8168fc19df
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-09 07:44:17 +02:00
Daniel Eklöf
42cc84eab7
sixel: TOOD -> TODO (fixes codespell build error) 2020-10-09 07:44:17 +02:00
Daniel Eklöf
8129ff69c9
sixel: verify-no-overlap: free pixman regions 2020-10-09 07:44:16 +02:00
Daniel Eklöf
2f5df30ef5
sixel: verify-no-overlap: initialize ‘intersection’ pixman region 2020-10-09 07:44:16 +02:00
Daniel Eklöf
47298776dc
sixel: unhook: only call render_refresh() once 2020-10-09 07:44:16 +02:00
Daniel Eklöf
dbfc636ade
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-09 07:44:16 +02:00
Daniel Eklöf
9102194846
sixel: verify-sixels: check for bad list order last 2020-10-09 07:44:16 +02:00
Daniel Eklöf
14b4231c09
sixel: verify-no-wraparound-crossover: fix calculation of ‘end’ row 2020-10-09 07:44:16 +02:00
Daniel Eklöf
52a7155897
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-09 07:44:16 +02:00
Daniel Eklöf
cf48d1dc4c
sixel: debug: more fine-grained verification of sixel image list
* Verify no sixel crosses the scrollback wrap-around
* Verify no sixels overlap
2020-10-09 07:44:15 +02:00
Daniel Eklöf
5a6b96817d
sixel: overwrite: calculate split-up image pieces’ rows/cols from their width/height 2020-10-09 07:44:15 +02:00
Daniel Eklöf
a53a81cebf
sixel: overwrite: remove asserts
Sixels may extend outside the visible screen area
2020-10-09 07:44:15 +02:00
Daniel Eklöf
bc75f4744c
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-09 07:44:15 +02:00
Daniel Eklöf
96405c2ca9
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-09 07:44:13 +02:00
Daniel Eklöf
7e026ba119
sixel: fold long line 2020-10-09 07:43:57 +02:00
Daniel Eklöf
aa3985a298
Don't use "case X ... Y:", if possible/where it makes sense 2020-08-23 10:07:08 +02:00
Daniel Eklöf
e32c0d9bf6
Cast printf formatter %p arguments to void* 2020-08-23 10:07:08 +02:00
Daniel Eklöf
dabdffafa5
don't use empty struct initializers 2020-08-23 10:07:00 +02:00
Craig Barnes
7a77958ba2 Convert most dynamic allocations to use functions from xmalloc.h 2020-08-08 20:37:57 +01:00
Daniel Eklöf
f6473756d9
sixel: remove sixel-to-be-splitted *before* splitting it
This fixes an assertion in debug builds, due to the pre-splitted and
splitted sixels overlapping.
2020-07-23 18:15:29 +02:00
Daniel Eklöf
fda6e9c2c9
sixel: overwrite: use target sixel's height, not cell height
When copying the image data for the left and right parts of the
splitted images, use the sixel's height, not the cell height.

This fixes a crash when the sixel didn't cover the entire cell height.
2020-07-23 18:13:54 +02:00
Daniel Eklöf
674f0dd0fc
sixel: verify list order: fix assertion when two sixels are on the same row
Two sixel may in fact exist on the same row, assuming their columns
don't overlap.
2020-07-16 08:13:44 +02:00
Daniel Eklöf
b9719673a1
term: rename term_formfeed() -> term_carriage_return() 2020-07-14 09:29:10 +02:00
Daniel Eklöf
3063204289
sixel: overwrite_by_row: handle case where 'width' goes past end of row
Cap 'width' to maximum number of columns available.
2020-07-07 10:42:59 +02:00
Daniel Eklöf
fad5838dba
Merge branch 'master' into sixel-performance 2020-06-29 22:03:26 +02:00
Daniel Eklöf
62be729c45
scroll: destroy scrolled out sixels before scroll is applied
The logic that breaks out of sixel loops does not work for rows that
has already wrapped around.

Thus, we need to destroy sixels that are about to be scrolled
out *before* we actually scroll.

Since this is the *only* time we destroy sixels (instead of
overwriting it), rename the sixel functions. And, since they now do a
very specific thing, they can be greatly simplified (and thus faster).
2020-06-29 22:01:02 +02:00
Daniel Eklöf
8f5e6e85e0
sixel: destroy all sixels when font size is decreased
If changing the font size causes the cell size to decrease, either
horizontally or vertically (or both), then delete all sixels since the
grid space they allocated no longer is enough to hold the images.
2020-06-29 21:53:29 +02:00
Daniel Eklöf
1140dd37d3
sixel: overwrite-by-rectangle: optimize: break out of loop as soon as possible
Since the images are sorted, we can break out of the loop as soon as
we detect an image that *ends before* the rectangle's top starts.

In order for the row comparisons to work, the row numbers must be
re-based against the current scrollback offset, or the
scrollback *end*, to be precise.
2020-06-28 19:22:23 +02:00
Daniel Eklöf
aa1951a4d2
sixel: overwrite-by-row: optimize: break out of loop as soon as possible
Since the images are sorted, we can break out of the loop as soon as
we detect an image that *ends before* the row we're looking for.

In order for the row comparisons to work, the row numbers must be
re-based against the current scrollback offset, or the
scrollback *end*, to be precise.
2020-06-28 14:24:30 +02:00
Daniel Eklöf
4006fc86e4
sixel: overwrite: pass 'width' to sixel_overwrite_at_cursor()
This is necessary to handle multi-column characters correctly.
2020-06-28 11:01:19 +02:00
Daniel Eklöf
0483466f68
sixel: insert: calculate end rows in a single statement 2020-06-28 10:45:05 +02:00
Daniel Eklöf
4a0042ba15
sixel: insert: sort sixels such that those furthest up in the scrollback is at the back 2020-06-28 09:16:43 +02:00
Daniel Eklöf
247e0c42d3
sixel: add local function sixel_insert()
Replace all tll_push_*() calls with calls to this function.
2020-06-28 08:37:25 +02:00
Daniel Eklöf
186a07c364
sixel: split -> overwrite 2020-06-27 15:29:47 +02:00
Daniel Eklöf
ae727e372a
term: erasing characters now splits sixels instead of deleting them 2020-06-27 15:22:31 +02:00
Daniel Eklöf
0953ffd2d3
sixel: delete/split: early(ier) exit when there aren't in sixel images
Avoid unnecessary wrap checks if the sixel image list is empty.
2020-06-27 14:43:29 +02:00
Daniel Eklöf
8cdfd03c4b
sixel: split: make pixman instantiation generic 2020-06-27 14:26:13 +02:00
Daniel Eklöf
cc65002539
sixel: never generate scrollback wrapping sixel images
Instead, split them up into two (or more...).

This makes the intersection detection logic *much* simpler.
2020-06-27 14:19:08 +02:00
Daniel Eklöf
e896c2fa55
sixel: refactor handling of wrap-around delete- and split regions
Handle these on a higher abstraction level. The low level functions
that detect sixel intersections now assume the specified rectangle (or
line region) does *not* cross the wrap-around.

This is ensured by detecting a wrap-around region before hand, and
splitting it up into two, non wrapping regions.
2020-06-27 13:56:13 +02:00
Daniel Eklöf
3715a37be9
sixel: split_by_rectangle: bug: typo in boundary check 2020-06-27 13:19:19 +02:00
Daniel Eklöf
37ceb65729
sixel: split: make sure relative row/column values are bounded 2020-06-27 13:18:54 +02:00
Daniel Eklöf
d9b7a85722
sixel: split: push front instead of back
This reduces the burden on sixel_split_by_rectangle(), which would
otherwise consider the newly added/splitted sixels. Since we already
know they aren't covered by the specified rectangle, we can skip that.
2020-06-27 12:50:39 +02:00
Daniel Eklöf
dfc205e706
sixel: add sixel_split_by_rectangle()
This function splits a sixel image into up to four pieces. The four
pieces correspond to the relative complement (set difference) of the
sixel image and the specified rectangle.

Use this function when (possibly) overwriting existing sixel images
when generating a new one, i.e. in sixel_unhook().
2020-06-27 12:45:22 +02:00
Daniel Eklöf
f4fcdbf38b
sixel: hopefully fix erasing of scrollback wrap-around sixels
If a sixel image crossed the scrollback wrap around, the logic that
detected whether a row, or a row range, intersected with the sixel was
incorrect.
2020-06-27 11:00:28 +02:00
Daniel Eklöf
bc82d4ee28
sixel: wip: split up image being overwritten, rather than erasing it
Instead of completely erasing a sixel image when it is being
"overwritten" (text is printed somewhere within the image, or another
sixel image is emitted within the first image), split it up into up to
four pieces: 'above', 'below', 'to-the-left' and 'to-the-right'.

This is currently very un-optimized, but seems to produce correct
results.
2020-06-23 21:07:12 +02:00
Daniel Eklöf
dec796f525
sixel: if the client has specified a size, do not change that
We used to auto-resize images to always be a multiple of 6.

This is incorrect. The client may, for example, have specified a size
to align the image to a cell boundary, which may not be a multiple of
6.

Furthermore, in e.g. Jexer, which splits up an image into stripes,
that the next image would "overwrite" the previous one. Since the next
image was started on a cell row that the previous image had overflowed
into.
2020-06-11 18:40:52 +02:00
Daniel Eklöf
6454e897ab
sixel: only use configured alpha when color matches the default bg 2020-06-10 18:52:53 +02:00
Daniel Eklöf
e0dc01f2ee
sixel: don't erase if cursor is *before* the image 2020-06-10 18:43:42 +02:00
Daniel Eklöf
cc5dedc259
sixel: do not reset palette after each image
A client can re-use the palette between images. Resetting the palette
breaks this.

Now we initialize the palette on demand, and resets it when the
palette size is changed (by the client).
2020-06-10 18:38:46 +02:00
Daniel Eklöf
12fda70402
sixel: log message: fix spelling 2020-06-09 17:34:04 +02:00