diff options
author | June McEnroe <programble@gmail.com> | 2018-03-31 22:25:40 -0400 |
---|---|---|
committer | June McEnroe <programble@gmail.com> | 2018-03-31 22:25:40 -0400 |
commit | 79bbd7d2fc9c83c01529fc9c45fac1e3af090866 (patch) | |
tree | 41398ced037d0dcd14509b876eb419e27ddfe650 /bin/scheme.c | |
parent | Add scheme to README (diff) | |
download | src-79bbd7d2fc9c83c01529fc9c45fac1e3af090866.tar.gz src-79bbd7d2fc9c83c01529fc9c45fac1e3af090866.zip |
Output Linux console escapes from scheme
Diffstat (limited to '')
-rw-r--r-- | bin/scheme.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/bin/scheme.c b/bin/scheme.c index fe521695..d008ea51 100644 --- a/bin/scheme.c +++ b/bin/scheme.c @@ -112,6 +112,14 @@ static void png(const struct Hsv *scheme, uint8_t len) { pngInt(crc); } +static void linux(const struct Hsv *scheme, uint8_t len) { + if (len > 16) len = 16; + for (uint8_t i = 0; i < len; ++i) { + struct Rgb rgb = toRgb(scheme[i]); + printf("\x1B]P%x%02x%02x%02x", i, rgb.r, rgb.g, rgb.b); + } +} + static void hex(const struct Hsv *scheme, uint8_t len) { for (uint8_t i = 0; i < len; ++i) { struct Rgb rgb = toRgb(scheme[i]); @@ -176,13 +184,14 @@ static struct Terminal genTerminal(struct Ansi ansi) { int main(int argc, char *argv[]) { enum { ANSI, TERMINAL } generate = ANSI; - enum { HEX, PNG } output = HEX; + enum { HEX, LINUX, PNG } output = HEX; int opt; - while (0 < (opt = getopt(argc, argv, "agtx"))) { + while (0 < (opt = getopt(argc, argv, "agltx"))) { switch (opt) { case 'a': generate = ANSI; break; case 'g': output = PNG; break; + case 'l': output = LINUX; break; case 't': generate = TERMINAL; break; case 'x': output = HEX; break; default: return EX_USAGE; @@ -207,6 +216,7 @@ int main(int argc, char *argv[]) { switch (output) { case HEX: hex(scheme, len); break; + case LINUX: linux(scheme, len); break; case PNG: png(scheme, len); break; } |