summary refs log tree commit diff
path: root/bin/scheme.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-02-06 19:48:14 -0500
committerJune McEnroe <june@causal.agency>2021-02-06 19:48:14 -0500
commit0de28f7b4c5b1a2e1ece82043987c4f07b78a9ec (patch)
tree5a851409a1fe8ed58e87da5a55fd2837b1364daa /bin/scheme.c
parentAdd wsconsctl.conf (diff)
downloadsrc-0de28f7b4c5b1a2e1ece82043987c4f07b78a9ec.tar.gz
src-0de28f7b4c5b1a2e1ece82043987c4f07b78a9ec.zip
Add xterm output to scheme
Diffstat (limited to 'bin/scheme.c')
-rw-r--r--bin/scheme.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/bin/scheme.c b/bin/scheme.c
index 7314b4c3..33fd8b60 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;