summary refs log tree commit diff
path: root/bin/scheme.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/scheme.c')
-rw-r--r--bin/scheme.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/bin/scheme.c b/bin/scheme.c
index 396512c4..2bae8f82 100644
--- a/bin/scheme.c
+++ b/bin/scheme.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2018, 2019  C. McEnroe <june@causal.agency>
+/* Copyright (C) 2018, 2019  June McEnroe <june@causal.agency>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -92,7 +92,7 @@ static void generate(void) {
 	light[White]   = x(R, +45.0, 0.3, 0.8);
 
 	dark[Black] = x(light[Black], 0.0, 1.0, 0.3);
-	dark[White] = x(light[White], 0.0, 1.0, 0.7);
+	dark[White] = x(light[White], 0.0, 1.0, 0.75);
 	for (uint i = Red; i < White; ++i) {
 		dark[i] = x(light[i], 0.0, 1.0, 0.8);
 	}
@@ -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",
@@ -175,13 +196,17 @@ static void outputMintty(const struct HSV *hsv, uint len) {
 }
 
 static void outputCSS(const struct HSV *hsv, uint len) {
+	printf(":root {\n");
 	for (uint i = 0; i < len; ++i) {
 		struct RGB rgb = convert(hsv[i]);
+		printf("\t--ansi%u: #" FORMAT_RGB ";\n", i, rgb.r, rgb.g, rgb.b);
+	}
+	printf("}\n");
+	for (uint i = 0; i < len; ++i) {
 		printf(
-			".fg%u { color: #" FORMAT_RGB "; }\n"
-			".bg%u { background-color: #" FORMAT_RGB "; }\n",
-			i, rgb.r, rgb.g, rgb.b,
-			i, rgb.r, rgb.g, rgb.b
+			".fg%u { color: var(--ansi%u); }\n"
+			".bg%u { background-color: var(--ansi%u); }\n",
+			i, i, i, i
 		);
 	}
 }
@@ -226,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;