aboutsummaryrefslogtreecommitdiff
path: root/terminal.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-06-29 19:53:29 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-06-29 19:53:29 +0000
commit8f5e6e85e0401a0071814c6dac7f16adb3b0b6e4 (patch)
tree68c393cc8b3e475af2e9cd22e2e0602243f0e4f1 /terminal.c
parentchangelog: slave -> client (diff)
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.
Diffstat (limited to 'terminal.c')
-rw-r--r--terminal.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/terminal.c b/terminal.c
index b7a49375..c3a36b45 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1423,7 +1423,30 @@ term_font_size_adjust(struct terminal *term, double amount)
return false;
}
- term_set_fonts(term, (struct fcft_font *[]){data[0].font_out, data[1].font_out, data[2].font_out, data[3].font_out});
+ const int old_cell_width = term->cell_width;
+ const int old_cell_height = term->cell_height;
+
+ if (!term_set_fonts(term, (struct fcft_font *[]){data[0].font_out, data[1].font_out, data[2].font_out, data[3].font_out}))
+ return false;
+
+ if (term->cell_width < old_cell_width ||
+ term->cell_height < old_cell_height)
+ {
+ /*
+ * The cell size has decreased.
+ *
+ * This means sixels, which we cannot resize, no longer fit
+ * into their "allocated" grid space.
+ *
+ * To be able to fit them, we would have to change the grid
+ * content. Inserting empty lines _might_ seem acceptable, but
+ * we'd also need to insert empty columns, which would break
+ * existing layout completely.
+ *
+ * So we delete them.
+ */
+ sixel_destroy_all(term);
+ }
return true;
}