aboutsummaryrefslogtreecommitdiff
path: root/sixel.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-07-16 06:10:56 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-07-16 06:13:44 +0000
commit674f0dd0fc56252d7c274eb9207f260a8e05ca2e (patch)
tree2b600b6af6079c796647305c6d0f0a08acf9805d /sixel.c
parentcsi: never call term_print() with width <= 0 (diff)
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.
Diffstat (limited to 'sixel.c')
-rw-r--r--sixel.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/sixel.c b/sixel.c
index 7d4b3d38..7dab1fcc 100644
--- a/sixel.c
+++ b/sixel.c
@@ -113,13 +113,33 @@ verify_sixel_list_order(const struct terminal *term)
{
#if defined(_DEBUG)
int prev_row = INT_MAX;
+ int prev_col = -1;
+ int prev_col_count = 0;
tll_foreach(term->grid->sixel_images, it) {
int row = rebase_row(term, it->item.pos.row + it->item.rows - 1);
- assert(row < prev_row);
- if (row >= prev_row)
+ int col = it->item.pos.col;
+ int col_count = it->item.cols;
+
+ assert(row <= prev_row);
+ if (row > prev_row)
return false;
+
+ if (row == prev_row) {
+ /* Allowed to be on the same row only if their columns
+ * don't overlap */
+
+ assert(col + col_count <= prev_col ||
+ prev_col + prev_col_count <= col);
+
+ if (!(col + col_count <= prev_col ||
+ prev_col + prev_col_count <= col))
+ return false;
+ }
+
prev_row = row;
+ prev_col = col;
+ prev_col_count = col_count;
}
#endif
return true;