mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-13 05:33:51 -04:00
sixel: initialize the color table to colors used by the VT340
This commit is contained in:
parent
dd3bb13d97
commit
60fd4a262c
2 changed files with 40 additions and 3 deletions
|
|
@ -143,6 +143,10 @@
|
||||||
* Crash when failing to load an xcursor image ([#1624][1624]).
|
* Crash when failing to load an xcursor image ([#1624][1624]).
|
||||||
* Crash when resizing a dynamically sized sixel (no raster
|
* Crash when resizing a dynamically sized sixel (no raster
|
||||||
attributes), with a non-1:1 aspect ratio.
|
attributes), with a non-1:1 aspect ratio.
|
||||||
|
* The default sixel color table is now initialized to the colors used
|
||||||
|
by the VT340, instead of not being initialized at all (thus
|
||||||
|
requiring the sixel escape sequence to explicitly set all colors it
|
||||||
|
used).
|
||||||
|
|
||||||
[1531]: https://codeberg.org/dnkl/foot/issues/1531
|
[1531]: https://codeberg.org/dnkl/foot/issues/1531
|
||||||
[1573]: https://codeberg.org/dnkl/foot/issues/1573
|
[1573]: https://codeberg.org/dnkl/foot/issues/1573
|
||||||
|
|
|
||||||
39
sixel.c
39
sixel.c
|
|
@ -4,7 +4,7 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#define LOG_MODULE "sixel"
|
#define LOG_MODULE "sixel"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 1
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "grid.h"
|
#include "grid.h"
|
||||||
|
|
@ -19,6 +19,29 @@ static size_t count;
|
||||||
static void sixel_put_generic(struct terminal *term, uint8_t c);
|
static void sixel_put_generic(struct terminal *term, uint8_t c);
|
||||||
static void sixel_put_ar_11(struct terminal *term, uint8_t c);
|
static void sixel_put_ar_11(struct terminal *term, uint8_t c);
|
||||||
|
|
||||||
|
/* VT330/VT340 Programmer Reference Manual - Table 2-3 VT340 Default Color Map */
|
||||||
|
static const uint32_t vt340_default_colors[16] = {
|
||||||
|
0xff000000,
|
||||||
|
0xff3333cc,
|
||||||
|
0xffcc2121,
|
||||||
|
0xff33cc33,
|
||||||
|
0xffcc33cc,
|
||||||
|
0xff33cccc,
|
||||||
|
0xffcccc33,
|
||||||
|
0xff878787,
|
||||||
|
0xff424242,
|
||||||
|
0xff545499,
|
||||||
|
0xff994242,
|
||||||
|
0xff549954,
|
||||||
|
0xff995499,
|
||||||
|
0xff549999,
|
||||||
|
0xff999954,
|
||||||
|
0xffcccccc,
|
||||||
|
};
|
||||||
|
|
||||||
|
_Static_assert(sizeof(vt340_default_colors) / sizeof(vt340_default_colors[0]) == 16,
|
||||||
|
"wrong number of elements");
|
||||||
|
|
||||||
void
|
void
|
||||||
sixel_fini(struct terminal *term)
|
sixel_fini(struct terminal *term)
|
||||||
{
|
{
|
||||||
|
|
@ -68,17 +91,27 @@ sixel_init(struct terminal *term, int p1, int p2, int p3)
|
||||||
term->sixel.image.width = 0;
|
term->sixel.image.width = 0;
|
||||||
term->sixel.image.height = 0;
|
term->sixel.image.height = 0;
|
||||||
|
|
||||||
/* TODO: default palette */
|
|
||||||
|
|
||||||
if (term->sixel.use_private_palette) {
|
if (term->sixel.use_private_palette) {
|
||||||
xassert(term->sixel.private_palette == NULL);
|
xassert(term->sixel.private_palette == NULL);
|
||||||
term->sixel.private_palette = xcalloc(
|
term->sixel.private_palette = xcalloc(
|
||||||
term->sixel.palette_size, sizeof(term->sixel.private_palette[0]));
|
term->sixel.palette_size, sizeof(term->sixel.private_palette[0]));
|
||||||
|
|
||||||
|
memcpy(
|
||||||
|
term->sixel.private_palette, vt340_default_colors,
|
||||||
|
min(sizeof(vt340_default_colors),
|
||||||
|
term->sixel.palette_size * sizeof(term->sixel.private_palette[0])));
|
||||||
|
|
||||||
term->sixel.palette = term->sixel.private_palette;
|
term->sixel.palette = term->sixel.private_palette;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (term->sixel.shared_palette == NULL) {
|
if (term->sixel.shared_palette == NULL) {
|
||||||
term->sixel.shared_palette = xcalloc(
|
term->sixel.shared_palette = xcalloc(
|
||||||
term->sixel.palette_size, sizeof(term->sixel.shared_palette[0]));
|
term->sixel.palette_size, sizeof(term->sixel.shared_palette[0]));
|
||||||
|
|
||||||
|
memcpy(
|
||||||
|
term->sixel.shared_palette, vt340_default_colors,
|
||||||
|
min(sizeof(vt340_default_colors),
|
||||||
|
term->sixel.palette_size * sizeof(term->sixel.shared_palette[0])));
|
||||||
} else {
|
} else {
|
||||||
/* Shared palette - do *not* reset palette for new sixels */
|
/* Shared palette - do *not* reset palette for new sixels */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue