aboutsummaryrefslogtreecommitdiff
path: root/sixel.c (follow)
Commit message (Collapse)AuthorAgeLines
* sixel: reflow: drop sixels that crosses the scrollback history’s endDaniel Eklöf2020-10-11-0/+23
| | | | | This fixes various crashes that occurred after a reflow due to the sixel image list invariants no longer being true.
* sixel: unhook: do overwrite *after* linefeedingDaniel Eklöf2020-10-11-2/+5
| | | | | This ensures the overwrite is done when the scrollback history is in the same state as when we then insert the new image.
* sixel: overwrite: use pixman to calculate new the sixel boundariesDaniel Eklöf2020-10-11-75/+74
| | | | | | 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.
* sixel: ovewrite-by-rectangle: in debug builds, cross-reference against pixmanDaniel Eklöf2020-10-11-2/+38
| | | | | Use pixman to calculate the intersection of the rectangle being overwritten, and the sixel(s). Verify our code matches.
* sixel: verify scrollback consistency: new verify functionDaniel Eklöf2020-10-11-0/+26
| | | | Verifies sixels have been scrolled out correctly
* sixel: add comments to verify_*() functionsDaniel Eklöf2020-10-11-0/+23
|
* sixel: verify-*: don’t return anything; rely on asserts onlyDaniel Eklöf2020-10-11-18/+7
|
* sixel: scroll up/down: early return when list is emptyDaniel Eklöf2020-10-11-0/+6
| | | | Branch tagged as ‘likely’ for performance reason
* sixel: cell-size-changed: don’t verify sixels hereDaniel Eklöf2020-10-11-2/+0
| | | | | | | | | | | | | 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?
* sixel: unhook: look total number of sixelsDaniel Eklöf2020-10-11-0/+3
| | | | | This helps debug sixel overwrites, as it makes it more visible when there are sixels that _should_ have been removed.
* sixel: scroll-up: don’t break out early of loopDaniel Eklöf2020-10-11-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* sixel: verify-list-order: add an ‘index’ variableDaniel Eklöf2020-10-11-0/+4
| | | | This will make it easier when debugging assertions in this function.
* sixel: overwrite-by-rectangle: assert sixels don’t cross scrollback wrap-aroundDaniel Eklöf2020-10-11-4/+7
|
* sixel: scroll: call sixel_erase() instead of sixel_destroy()Daniel Eklöf2020-10-11-2/+2
| | | | | This ensures the screen is updated correctly. Without this, the sixel image would remain on screen until force-refreshed by some other means.
* sixel: TOOD -> TODO (fixes codespell build error)Daniel Eklöf2020-10-11-1/+1
|
* sixel: verify-no-overlap: free pixman regionsDaniel Eklöf2020-10-11-0/+5
|
* sixel: verify-no-overlap: initialize ‘intersection’ pixman regionDaniel Eklöf2020-10-11-0/+1
|
* sixel: unhook: only call render_refresh() onceDaniel Eklöf2020-10-11-2/+3
|
* sixel: implement reflowDaniel Eklöf2020-10-11-0/+48
| | | | | | | 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.
* sixel: verify-sixels: check for bad list order lastDaniel Eklöf2020-10-11-2/+2
|
* sixel: verify-no-wraparound-crossover: fix calculation of ‘end’ rowDaniel Eklöf2020-10-11-1/+1
|
* sixel: add sixel_cell_size_changed()Daniel Eklöf2020-10-11-0/+24
| | | | | This function should be called *after* the cell dimensions have changed, but *before* resizing/reflowing the grids.
* sixel: debug: more fine-grained verification of sixel image listDaniel Eklöf2020-10-11-5/+63
| | | | | * Verify no sixel crosses the scrollback wrap-around * Verify no sixels overlap
* sixel: overwrite: calculate split-up image pieces’ rows/cols from their width/heightDaniel Eklöf2020-10-11-8/+3
|
* sixel: overwrite: remove assertsDaniel Eklöf2020-10-11-12/+1
| | | | Sixels may extend outside the visible screen area
* sixel: fix sheared image when image crosses scrollback wrap-aroundDaniel Eklöf2020-10-11-1/+11
| | | | | | | | | | | | | | | 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.
* sixel: overwrite-by-rectangle expects ‘width’ to not exceed screenDaniel Eklöf2020-10-11-1/+2
| | | | | | | | 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
* sixel: fold long lineDaniel Eklöf2020-10-11-1/+3
|
* Don't use "case X ... Y:", if possible/where it makes senseDaniel Eklöf2020-08-23-4/+16
|
* Cast printf formatter %p arguments to void*Daniel Eklöf2020-08-23-1/+1
|
* don't use empty struct initializersDaniel Eklöf2020-08-23-1/+1
|
* Convert most dynamic allocations to use functions from xmalloc.hCraig Barnes2020-08-08-8/+9
|
* sixel: remove sixel-to-be-splitted *before* splitting itDaniel Eklöf2020-07-23-4/+8
| | | | | This fixes an assertion in debug builds, due to the pre-splitted and splitted sixels overlapping.
* sixel: overwrite: use target sixel's height, not cell heightDaniel Eklöf2020-07-23-2/+2
| | | | | | | 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.
* sixel: verify list order: fix assertion when two sixels are on the same rowDaniel Eklöf2020-07-16-2/+22
| | | | | Two sixel may in fact exist on the same row, assuming their columns don't overlap.
* term: rename term_formfeed() -> term_carriage_return()Daniel Eklöf2020-07-14-1/+1
|
* sixel: overwrite_by_row: handle case where 'width' goes past end of rowDaniel Eklöf2020-07-07-1/+4
| | | | Cap 'width' to maximum number of columns available.
* Merge branch 'master' into sixel-performanceDaniel Eklöf2020-06-29-0/+11
|\
| * sixel: destroy all sixels when font size is decreasedDaniel Eklöf2020-06-29-0/+11
| | | | | | | | | | | | 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.
* | scroll: destroy scrolled out sixels before scroll is appliedDaniel Eklöf2020-06-29-127/+55
| | | | | | | | | | | | | | | | | | | | | | | | 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).
* | sixel: overwrite-by-rectangle: optimize: break out of loop as soon as possibleDaniel Eklöf2020-06-28-0/+18
| | | | | | | | | | | | | | | | | | 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.
* | sixel: overwrite-by-row: optimize: break out of loop as soon as possibleDaniel Eklöf2020-06-28-14/+24
| | | | | | | | | | | | | | | | | | 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.
* | sixel: overwrite: pass 'width' to sixel_overwrite_at_cursor()Daniel Eklöf2020-06-28-2/+2
| | | | | | | | This is necessary to handle multi-column characters correctly.
* | sixel: insert: calculate end rows in a single statementDaniel Eklöf2020-06-28-8/+21
| |
* | sixel: insert: sort sixels such that those furthest up in the scrollback is at the backDaniel Eklöf2020-06-28-0/+19
| |
* | sixel: add local function sixel_insert()Daniel Eklöf2020-06-28-2/+8
|/ | | | Replace all tll_push_*() calls with calls to this function.
* sixel: split -> overwriteDaniel Eklöf2020-06-27-15/+15
|
* term: erasing characters now splits sixels instead of deleting themDaniel Eklöf2020-06-27-12/+22
|
* sixel: delete/split: early(ier) exit when there aren't in sixel imagesDaniel Eklöf2020-06-27-9/+16
| | | | Avoid unnecessary wrap checks if the sixel image list is empty.
* sixel: split: make pixman instantiation genericDaniel Eklöf2020-06-27-34/+27
|
* sixel: never generate scrollback wrapping sixel imagesDaniel Eklöf2020-06-27-53/+96
| | | | | | Instead, split them up into two (or more...). This makes the intersection detection logic *much* simpler.
* sixel: refactor handling of wrap-around delete- and split regionsDaniel Eklöf2020-06-27-39/+99
| | | | | | | | | 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.
* sixel: split_by_rectangle: bug: typo in boundary checkDaniel Eklöf2020-06-27-1/+1
|
* sixel: split: make sure relative row/column values are boundedDaniel Eklöf2020-06-27-4/+4
|
* sixel: split: push front instead of backDaniel Eklöf2020-06-27-4/+4
| | | | | | 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.
* sixel: add sixel_split_by_rectangle()Daniel Eklöf2020-06-27-57/+74
| | | | | | | | | 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().
* sixel: hopefully fix erasing of scrollback wrap-around sixelsDaniel Eklöf2020-06-27-10/+27
| | | | | | 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.
* sixel: wip: split up image being overwritten, rather than erasing itDaniel Eklöf2020-06-23-1/+139
| | | | | | | | | | 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.
* sixel: if the client has specified a size, do not change thatDaniel Eklöf2020-06-11-5/+16
| | | | | | | | | | | | | 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.
* sixel: only use configured alpha when color matches the default bgDaniel Eklöf2020-06-10-4/+11
|
* sixel: don't erase if cursor is *before* the imageDaniel Eklöf2020-06-10-1/+2
|
* sixel: do not reset palette after each imageDaniel Eklöf2020-06-10-5/+18
| | | | | | | | 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).
* sixel: log message: fix spellingDaniel Eklöf2020-06-09-1/+1
|
* sixel: don't erase image when printing text *next* to it.Daniel Eklöf2020-06-06-5/+18
|
* sixel: fix asan runtime warning: left shift of 255 by 24 cannot...Daniel Eklöf2020-06-06-4/+4
| | | | be represented in type 'int'
* util.h: new header file defining commonly used macrosDaniel Eklöf2020-05-01-5/+1
|
* grid: move 'cursor' state from terminal to gridDaniel Eklöf2020-04-16-3/+3
| | | | | This way, the 'normal' and 'alt' grids have their own cursor state, and we don't need to switch between them.
* sixel: improve handling of images when reflowing the gridsDaniel Eklöf2020-03-13-14/+7
| | | | | | | | | | | Update the sixels' 'row' attribute when re-flowing a grid, to ensure it is rendered at the correct place. This should work in most cases, but will break when the cell size has changed (e.g. font size increase/decrease, or a DPI change). This patch also moves the sixel image list from the terminal struct into the grid struct. The sixels are per-grid after all.
* sixel: don't try to dirty an un-allocated rowDaniel Eklöf2020-03-06-0/+5
| | | | This may happen e.g. when resizing a grid
* sixel: CSI setters also write a reply to the clientDaniel Eklöf2020-02-24-5/+9
|
* term: term_erase(): call sixel_delete_*()Daniel Eklöf2020-02-24-2/+2
| | | | | This ensures sixel images are removed, regardless of _how_ the screen was erased.
* sixel: ensure 'start' row is not outside the grid row rangeDaniel Eklöf2020-02-24-1/+3
|
* sixel: add sixel_delete_at_row and sixel_delete_in_rangeDaniel Eklöf2020-02-24-7/+65
| | | | | These are utility functions to erase sixel images that are at the specified row, or in a row range.
* sixel: destroy_at_cursor(): skip images on 'other' gridDaniel Eklöf2020-02-22-0/+3
|
* sixel: track which grid image was created onDaniel Eklöf2020-02-22-0/+1
|
* sixel: rename: purge_at_cursor() -> delete_at_cursor()Daniel Eklöf2020-02-22-2/+2
|
* sixel: purge images in unhook, rather than in initDaniel Eklöf2020-02-22-2/+2
| | | | | This fixes an issue where the cursor was seen blinking in animated GIFs.
* sixel: purge images at current cursor rowDaniel Eklöf2020-02-22-7/+18
| | | | | When printing a character, or starting a new sixel image, purge all images that cover the cursor's current row.
* sixel: oopsDaniel Eklöf2020-02-22-2/+2
|
* sixel: don't ever shrink the imageDaniel Eklöf2020-02-22-3/+9
|
* sixel: add HLS color format supportDaniel Eklöf2020-02-22-2/+5
|
* sixel: add comments to max_width()/max_height()Daniel Eklöf2020-02-22-0/+2
|
* sixel: application configurable image max width/heightDaniel Eklöf2020-02-22-3/+72
|
* sixel: application configurable palette size (color count)Daniel Eklöf2020-02-22-6/+35
| | | | | This implements the CSI escapes for retrieving and (re)setting the palette size.
* sixel: use terminal's background color, not palette[0]Daniel Eklöf2020-02-22-3/+3
|
* sixel: finalize: use width/height from image, not row/col posDaniel Eklöf2020-02-22-10/+4
|
* sixel: resize: initialize new rows/columns with the background colorDaniel Eklöf2020-02-22-9/+15
|
* sixel: mention why we add oneDaniel Eklöf2020-02-22-1/+3
|
* sixel: clean up state machineDaniel Eklöf2020-02-22-91/+97
| | | | | Use proper state names, and implement the state machine using switch statements.
* sixel: use a struct coord for current sixel positionDaniel Eklöf2020-02-22-24/+22
|
* sixel: rename state SIXEL_SIXEL -> SIXEL_GROUNDDaniel Eklöf2020-02-22-6/+6
|
* sixel: raster: only resize image buffer if necessaryDaniel Eklöf2020-02-22-1/+3
|
* sixel: resize image buffer after receiving a "raster" commandDaniel Eklöf2020-02-22-0/+1
|
* sixel: resize image buffer dynamicallyDaniel Eklöf2020-02-22-23/+80
|
* sixel: add sixel_destroy()Daniel Eklöf2020-02-21-4/+13
|
* sixel: always bump row on unhookDaniel Eklöf2020-02-21-6/+4
|
* sixel: ugly hack to remove over-written sixel imagesDaniel Eklöf2020-02-21-0/+8
|
* sixel: calculate image height in (cell) rowsDaniel Eklöf2020-02-21-0/+1
|
* sixel: wip: maintain a list of finished, and "active" sixel imagesDaniel Eklöf2020-02-21-24/+20
| | | | | | | | | | | | | | | | | | | In unhook, add the generated image to a list of finished sixel images, along with positioning and size information. When rendering, loop this list of images, and render the images (or parts of) that are visible. When scrolling, check if any part of the images cover the re-cycled lines, and if so, remove the *entire* image from the list. This means we have the following limitations: * The renderer always renders the whole (visible area of) the image(s). There are times when this isn't necessary - for example, when the image is scrolled inside the visible area. * It would be nice if we could crop the image when parts of it is scrolled out.
* sixel: initial supportDaniel Eklöf2020-02-21-0/+284
This implements basic parsing of sixel data. Lots of limitations and temporary solutions as this is still work-in-progress: * Maximum image size hardcoded to 800x800 * No HLS color format support * Image is always rendered at 0x0 in the terminal