From 34894724b0a85f7d047f31dcdc893dbd47b8f9c3 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sat, 6 Feb 2021 19:48:14 -0500 Subject: Add xterm output to scheme --- bin/scheme.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'bin/scheme.c') diff --git a/bin/scheme.c b/bin/scheme.c index b921a77e..2bae8f82 100644 --- a/bin/scheme.c +++ b/bin/scheme.c @@ -156,6 +156,27 @@ static void outputEnum(const struct HSV *hsv, uint len) { printf("};\n"); } +#define FORMAT_X "rgb:%02hhX/%02hhX/%02hhX" + +static const char *Resources[SchemeLen] = { + [Background] = "background", + [Foreground] = "foreground", + [Bold] = "colorBD", + [Selection] = "highlightColor", + [Cursor] = "cursorColor", +}; + +static void outputXTerm(const struct HSV *hsv, uint len) { + for (uint i = 0; i < len; ++i) { + struct RGB rgb = convert(hsv[i]); + if (Resources[i]) { + printf("XTerm*%s: " FORMAT_X "\n", Resources[i], rgb.r, rgb.g, rgb.b); + } else { + printf("XTerm*color%u: " FORMAT_X "\n", i, rgb.r, rgb.g, rgb.b); + } + } +} + static const char *Mintty[SchemeLen] = { "Black", "Red", "Green", "Yellow", "Blue", "Magenta", "Cyan", "White", @@ -230,8 +251,9 @@ int main(int argc, char *argv[]) { uint len = 16; int opt; - while (0 < (opt = getopt(argc, argv, "acghilmp:stx"))) { + while (0 < (opt = getopt(argc, argv, "Xacghilmp:stx"))) { switch (opt) { + break; case 'X': output = outputXTerm; break; case 'a': len = 16; break; case 'c': output = outputEnum; break; case 'g': output = outputPNG; -- cgit 1.4.1