diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-06-28 07:16:43 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-06-28 07:16:43 +0000 |
| commit | 4a0042ba1563b8d2f0669c7650e997b6c1a9d95e (patch) | |
| tree | 601ebb6f70fc49c1279ea8252782369a94c11243 /sixel.c | |
| parent | sixel: add local function sixel_insert() (diff) | |
sixel: insert: sort sixels such that those furthest up in the scrollback is at the back
Diffstat (limited to 'sixel.c')
| -rw-r--r-- | sixel.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -90,6 +90,25 @@ sixel_erase(struct terminal *term, struct sixel *sixel) static void sixel_insert(struct terminal *term, struct sixel sixel) { + const int scrollback_end + = (term->grid->offset + term->rows) & (term->grid->num_rows - 1); + + int end_row = sixel.pos.row + sixel.rows - scrollback_end; + while (end_row < 0) + end_row += term->grid->num_rows; + + tll_foreach(term->grid->sixel_images, it) { + int e = it->item.pos.row + it->item.rows - scrollback_end; + e -= scrollback_end; + while (e < 0) + e += term->grid->num_rows; + + if (e < end_row) { + tll_insert_before(term->grid->sixel_images, it, sixel); + return; + } + } + tll_push_back(term->grid->sixel_images, sixel); } |
