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/man1/scheme.1 | 7 +++++-- bin/scheme.c | 24 +++++++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/man1/scheme.1 b/bin/man1/scheme.1 index 9aa4f054..9f72d945 100644 --- a/bin/man1/scheme.1 +++ b/bin/man1/scheme.1 @@ -1,4 +1,4 @@ -.Dd July 6, 2019 +.Dd February 6, 2021 .Dt SCHEME 1 .Os . @@ -8,7 +8,7 @@ . .Sh SYNOPSIS .Nm -.Op Fl acghilmstx +.Op Fl Xacghilmstx .Op Fl p Ar n . .Sh DESCRIPTION @@ -19,6 +19,9 @@ and outputs it in a number of formats. .Pp The arguments are as follows: .Bl -tag -width Ds +.It Fl X +Output Xresources for +.Xr xterm 1 . .It Fl a Generate the 16 ANSI colors. This is the default. 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 9dddb9c52c7a3c517bf6cefc4f528e596c6f3406&follow=1'>1sh/nodes.c.pat (unfollow)
Commit message (Expand)Author
2020-03-09Move bltin out of subdirectoryJune McEnroe
2020-03-09Import /usr/src/usr.bin/printf from FreeBSD 12.1-RELEASEJune McEnroe
2020-03-09Import /usr/src/bin/test from FreeBSD 12.1-RELEASEJune McEnroe
2020-03-09Import /usr/src/bin/kill from FreeBSD 12.1-RELEASEJune McEnroe
2020-03-09Remove extraneous files from sh sourcesJune McEnroe
2020-03-09Import /usr/src/bin/sh from FreeBSD 12.1-RELEASEJune McEnroe
2020-03-09Remove 1sh sourcesJune McEnroe
2020-03-08Add The Stone SkyJune McEnroe
2020-03-08Publish "How I Relay Chat"June McEnroe
2020-03-03Don't use $ inside $(())June McEnroe
2020-03-03Remove setoptJune McEnroe
2020-03-03Use getopts in shell scriptsJune McEnroe
2020-02-27Style %T outside of Rs in italicJune McEnroe
2020-02-26Add Fierce Femmes and Notorious LiarsJune McEnroe
2020-02-23Add This Is How You Lose the Time WarJune McEnroe
2020-02-22Add See Ya LaterJune McEnroe
2020-02-20Remove wiki scriptJune McEnroe
2020-02-19Add The Obelisk GateJune McEnroe
2020-02-17Add Four Tet — HandsJune McEnroe
2020-02-12Simplify macOS notify-sendJune McEnroe
2020-02-12Add imbox and notemap to pageJune McEnroe
2020-02-12Collapse simple linksJune McEnroe
2020-02-12Move catgirl up the pageJune McEnroe
2020-02-12Update catgirl pty grabJune McEnroe
2020-02-12Link to cgit /about pages where appropriateJune McEnroe
2020-02-11Separate LINKS from BINS for html to workJune McEnroe
2020-02-11Add margin to Bl-bullet itemsJune McEnroe
2020-02-10Match URLs inside parens or with paired parens insideJune McEnroe
2020-02-10Duplicate effective URL before passing it back to curlJune McEnroe
2020-02-09Add To Be Taught, If FortunateJune McEnroe
2020-02-04Add The Future of Another TimelineJune McEnroe
2020-01-31Reorganize the Makefile for the umpteenth timeJune McEnroe
2020-01-28Change scout sensitivity to 1.4June McEnroe
2020-01-28Import shows.txtJune McEnroe