cosmopolitan/tool/viz/xterm256info.c

708 lines
34 KiB
C

/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
╞══════════════════════════════════════════════════════════════════════════════╡
│ Copyright 2020 Justine Alexandra Roberts Tunney │
│ │
│ This program is free software; you can redistribute it and/or modify │
│ it under the terms of the GNU General Public License as published by │
│ the Free Software Foundation; version 2 of the License. │
│ │
│ This program is distributed in the hope that it will be useful, but │
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
│ General Public License for more details. │
│ │
│ You should have received a copy of the GNU General Public License │
│ along with this program; if not, write to the Free Software │
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
│ 02110-1301 USA │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "dsp/tty/xtermname.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
struct Rgb {
uint8_t r, g, b;
};
const struct Rgb kTango[16] = {
{0x00, 0x00, 0x00}, {0x80, 0x00, 0x00}, {0x00, 0x80, 0x00},
{0x80, 0x80, 0x00}, {0x00, 0x00, 0x80}, {0x80, 0x00, 0x80},
{0x00, 0x80, 0x80}, {0xc0, 0xc0, 0xc0}, {0x80, 0x80, 0x80},
{0xff, 0x00, 0x00}, {0x00, 0xff, 0x00}, {0xff, 0xff, 0x00},
{0x00, 0x00, 0xff}, {0xff, 0x00, 0xff}, {0x00, 0xff, 0xff},
{0xff, 0xff, 0xff},
};
const struct Rgb kXtermRgb[] = {
/* 0..15: ansi 16-color palette */
{0x00, 0x00, 0x00},
{0x80, 0x00, 0x00},
{0x00, 0x80, 0x00},
{0x80, 0x80, 0x00},
{0x00, 0x00, 0x80},
{0x80, 0x00, 0x80},
{0x00, 0x80, 0x80},
{0xc0, 0xc0, 0xc0},
{0x80, 0x80, 0x80},
{0xff, 0x00, 0x00},
{0x00, 0xff, 0x00},
{0xff, 0xff, 0x00},
{0x00, 0x00, 0xff},
{0xff, 0x00, 0xff},
{0x00, 0xff, 0xff},
{0xff, 0xff, 0xff},
/* 16..231: xterm256 color cubes */
{0x00, 0x00, 0x00},
{0x00, 0x00, 0x5f},
{0x00, 0x00, 0x87},
{0x00, 0x00, 0xaf},
{0x00, 0x00, 0xd7},
{0x00, 0x00, 0xff},
{0x00, 0x5f, 0x00},
{0x00, 0x5f, 0x5f},
{0x00, 0x5f, 0x87},
{0x00, 0x5f, 0xaf},
{0x00, 0x5f, 0xd7},
{0x00, 0x5f, 0xff},
{0x00, 0x87, 0x00},
{0x00, 0x87, 0x5f},
{0x00, 0x87, 0x87},
{0x00, 0x87, 0xaf},
{0x00, 0x87, 0xd7},
{0x00, 0x87, 0xff},
{0x00, 0xaf, 0x00},
{0x00, 0xaf, 0x5f},
{0x00, 0xaf, 0x87},
{0x00, 0xaf, 0xaf},
{0x00, 0xaf, 0xd7},
{0x00, 0xaf, 0xff},
{0x00, 0xd7, 0x00},
{0x00, 0xd7, 0x5f},
{0x00, 0xd7, 0x87},
{0x00, 0xd7, 0xaf},
{0x00, 0xd7, 0xd7},
{0x00, 0xd7, 0xff},
{0x00, 0xff, 0x00},
{0x00, 0xff, 0x5f},
{0x00, 0xff, 0x87},
{0x00, 0xff, 0xaf},
{0x00, 0xff, 0xd7},
{0x00, 0xff, 0xff},
{0x5f, 0x00, 0x00},
{0x5f, 0x00, 0x5f},
{0x5f, 0x00, 0x87},
{0x5f, 0x00, 0xaf},
{0x5f, 0x00, 0xd7},
{0x5f, 0x00, 0xff},
{0x5f, 0x5f, 0x00},
{0x5f, 0x5f, 0x5f},
{0x5f, 0x5f, 0x87},
{0x5f, 0x5f, 0xaf},
{0x5f, 0x5f, 0xd7},
{0x5f, 0x5f, 0xff},
{0x5f, 0x87, 0x00},
{0x5f, 0x87, 0x5f},
{0x5f, 0x87, 0x87},
{0x5f, 0x87, 0xaf},
{0x5f, 0x87, 0xd7},
{0x5f, 0x87, 0xff},
{0x5f, 0xaf, 0x00},
{0x5f, 0xaf, 0x5f},
{0x5f, 0xaf, 0x87},
{0x5f, 0xaf, 0xaf},
{0x5f, 0xaf, 0xd7},
{0x5f, 0xaf, 0xff},
{0x5f, 0xd7, 0x00},
{0x5f, 0xd7, 0x5f},
{0x5f, 0xd7, 0x87},
{0x5f, 0xd7, 0xaf},
{0x5f, 0xd7, 0xd7},
{0x5f, 0xd7, 0xff},
{0x5f, 0xff, 0x00},
{0x5f, 0xff, 0x5f},
{0x5f, 0xff, 0x87},
{0x5f, 0xff, 0xaf},
{0x5f, 0xff, 0xd7},
{0x5f, 0xff, 0xff},
{0x87, 0x00, 0x00},
{0x87, 0x00, 0x5f},
{0x87, 0x00, 0x87},
{0x87, 0x00, 0xaf},
{0x87, 0x00, 0xd7},
{0x87, 0x00, 0xff},
{0x87, 0x5f, 0x00},
{0x87, 0x5f, 0x5f},
{0x87, 0x5f, 0x87},
{0x87, 0x5f, 0xaf},
{0x87, 0x5f, 0xd7},
{0x87, 0x5f, 0xff},
{0x87, 0x87, 0x00},
{0x87, 0x87, 0x5f},
{0x87, 0x87, 0x87},
{0x87, 0x87, 0xaf},
{0x87, 0x87, 0xd7},
{0x87, 0x87, 0xff},
{0x87, 0xaf, 0x00},
{0x87, 0xaf, 0x5f},
{0x87, 0xaf, 0x87},
{0x87, 0xaf, 0xaf},
{0x87, 0xaf, 0xd7},
{0x87, 0xaf, 0xff},
{0x87, 0xd7, 0x00},
{0x87, 0xd7, 0x5f},
{0x87, 0xd7, 0x87},
{0x87, 0xd7, 0xaf},
{0x87, 0xd7, 0xd7},
{0x87, 0xd7, 0xff},
{0x87, 0xff, 0x00},
{0x87, 0xff, 0x5f},
{0x87, 0xff, 0x87},
{0x87, 0xff, 0xaf},
{0x87, 0xff, 0xd7},
{0x87, 0xff, 0xff},
{0xaf, 0x00, 0x00},
{0xaf, 0x00, 0x5f},
{0xaf, 0x00, 0x87},
{0xaf, 0x00, 0xaf},
{0xaf, 0x00, 0xd7},
{0xaf, 0x00, 0xff},
{0xaf, 0x5f, 0x00},
{0xaf, 0x5f, 0x5f},
{0xaf, 0x5f, 0x87},
{0xaf, 0x5f, 0xaf},
{0xaf, 0x5f, 0xd7},
{0xaf, 0x5f, 0xff},
{0xaf, 0x87, 0x00},
{0xaf, 0x87, 0x5f},
{0xaf, 0x87, 0x87},
{0xaf, 0x87, 0xaf},
{0xaf, 0x87, 0xd7},
{0xaf, 0x87, 0xff},
{0xaf, 0xaf, 0x00},
{0xaf, 0xaf, 0x5f},
{0xaf, 0xaf, 0x87},
{0xaf, 0xaf, 0xaf},
{0xaf, 0xaf, 0xd7},
{0xaf, 0xaf, 0xff},
{0xaf, 0xd7, 0x00},
{0xaf, 0xd7, 0x5f},
{0xaf, 0xd7, 0x87},
{0xaf, 0xd7, 0xaf},
{0xaf, 0xd7, 0xd7},
{0xaf, 0xd7, 0xff},
{0xaf, 0xff, 0x00},
{0xaf, 0xff, 0x5f},
{0xaf, 0xff, 0x87},
{0xaf, 0xff, 0xaf},
{0xaf, 0xff, 0xd7},
{0xaf, 0xff, 0xff},
{0xd7, 0x00, 0x00},
{0xd7, 0x00, 0x5f},
{0xd7, 0x00, 0x87},
{0xd7, 0x00, 0xaf},
{0xd7, 0x00, 0xd7},
{0xd7, 0x00, 0xff},
{0xd7, 0x5f, 0x00},
{0xd7, 0x5f, 0x5f},
{0xd7, 0x5f, 0x87},
{0xd7, 0x5f, 0xaf},
{0xd7, 0x5f, 0xd7},
{0xd7, 0x5f, 0xff},
{0xd7, 0x87, 0x00},
{0xd7, 0x87, 0x5f},
{0xd7, 0x87, 0x87},
{0xd7, 0x87, 0xaf},
{0xd7, 0x87, 0xd7},
{0xd7, 0x87, 0xff},
{0xd7, 0xaf, 0x00},
{0xd7, 0xaf, 0x5f},
{0xd7, 0xaf, 0x87},
{0xd7, 0xaf, 0xaf},
{0xd7, 0xaf, 0xd7},
{0xd7, 0xaf, 0xff},
{0xd7, 0xd7, 0x00},
{0xd7, 0xd7, 0x5f},
{0xd7, 0xd7, 0x87},
{0xd7, 0xd7, 0xaf},
{0xd7, 0xd7, 0xd7},
{0xd7, 0xd7, 0xff},
{0xd7, 0xff, 0x00},
{0xd7, 0xff, 0x5f},
{0xd7, 0xff, 0x87},
{0xd7, 0xff, 0xaf},
{0xd7, 0xff, 0xd7},
{0xd7, 0xff, 0xff},
{0xff, 0x00, 0x00},
{0xff, 0x00, 0x5f},
{0xff, 0x00, 0x87},
{0xff, 0x00, 0xaf},
{0xff, 0x00, 0xd7},
{0xff, 0x00, 0xff},
{0xff, 0x5f, 0x00},
{0xff, 0x5f, 0x5f},
{0xff, 0x5f, 0x87},
{0xff, 0x5f, 0xaf},
{0xff, 0x5f, 0xd7},
{0xff, 0x5f, 0xff},
{0xff, 0x87, 0x00},
{0xff, 0x87, 0x5f},
{0xff, 0x87, 0x87},
{0xff, 0x87, 0xaf},
{0xff, 0x87, 0xd7},
{0xff, 0x87, 0xff},
{0xff, 0xaf, 0x00},
{0xff, 0xaf, 0x5f},
{0xff, 0xaf, 0x87},
{0xff, 0xaf, 0xaf},
{0xff, 0xaf, 0xd7},
{0xff, 0xaf, 0xff},
{0xff, 0xd7, 0x00},
{0xff, 0xd7, 0x5f},
{0xff, 0xd7, 0x87},
{0xff, 0xd7, 0xaf},
{0xff, 0xd7, 0xd7},
{0xff, 0xd7, 0xff},
{0xff, 0xff, 0x00},
{0xff, 0xff, 0x5f},
{0xff, 0xff, 0x87},
{0xff, 0xff, 0xaf},
{0xff, 0xff, 0xd7},
{0xff, 0xff, 0xff},
/* 232..255: xterm256 grayscale */
{0x08, 0x08, 0x08}, /* 8 */
{0x12, 0x12, 0x12}, /* 10 */
{0x1c, 0x1c, 0x1c}, /* 10 */
{0x26, 0x26, 0x26}, /* 10 */
{0x30, 0x30, 0x30}, /* .. */
{0x3a, 0x3a, 0x3a},
{0x44, 0x44, 0x44},
{0x4e, 0x4e, 0x4e},
{0x58, 0x58, 0x58},
{0x62, 0x62, 0x62},
{0x6c, 0x6c, 0x6c},
{0x76, 0x76, 0x76},
{0x80, 0x80, 0x80},
{0x8a, 0x8a, 0x8a},
{0x94, 0x94, 0x94},
{0x9e, 0x9e, 0x9e},
{0xa8, 0xa8, 0xa8},
{0xb2, 0xb2, 0xb2},
{0xbc, 0xbc, 0xbc},
{0xc6, 0xc6, 0xc6},
{0xd0, 0xd0, 0xd0},
{0xda, 0xda, 0xda},
{0xe4, 0xe4, 0xe4},
{0xee, 0xee, 0xee},
};
const struct Rgb kXtermRgbAppleFg[] = {
{0, 0, 0}, {192, 55, 41}, {48, 187, 49}, {173, 172, 53},
{73, 76, 224}, {209, 65, 209}, {60, 187, 199}, {203, 204, 205},
{154, 155, 156}, {249, 59, 44}, {62, 229, 55}, {234, 234, 62},
{89, 63, 251}, {247, 67, 245}, {48, 239, 239}, {233, 235, 235},
{47, 49, 49}, {60, 46, 142}, {67, 51, 180}, {74, 56, 218},
{82, 62, 248}, {89, 63, 251}, {46, 127, 43}, {46, 127, 127},
{49, 127, 167}, {60, 127, 207}, {63, 127, 241}, {70, 126, 251},
{57, 161, 50}, {47, 161, 122}, {50, 161, 161}, {60, 161, 200},
{53, 161, 237}, {65, 160, 252}, {45, 194, 51}, {58, 194, 118},
{51, 194, 156}, {59, 194, 194}, {48, 194, 233}, {63, 194, 252},
{62, 227, 55}, {55, 227, 115}, {48, 227, 151}, {63, 227, 189},
{52, 227, 227}, {66, 227, 253}, {51, 252, 57}, {53, 252, 111},
{63, 252, 147}, {58, 252, 184}, {59, 252, 222}, {62, 253, 251},
{138, 49, 43}, {134, 55, 134}, {134, 58, 174}, {133, 61, 213},
{134, 67, 244}, {134, 65, 251}, {125, 124, 46}, {124, 125, 125},
{122, 125, 165}, {123, 126, 205}, {124, 126, 243}, {125, 125, 251},
{120, 159, 47}, {118, 159, 121}, {118, 159, 160}, {117, 160, 199},
{118, 160, 238}, {119, 160, 252}, {115, 193, 53}, {113, 193, 117},
{114, 193, 155}, {111, 193, 193}, {113, 194, 232}, {112, 193, 252},
{110, 226, 53}, {108, 226, 114}, {110, 226, 151}, {106, 226, 189},
{105, 227, 227}, {105, 226, 252}, {99, 251, 59}, {103, 251, 111},
{104, 251, 146}, {97, 252, 184}, {102, 252, 221}, {98, 254, 250},
{175, 54, 40}, {172, 58, 130}, {170, 61, 170}, {170, 66, 210},
{169, 67, 245}, {168, 69, 251}, {164, 123, 47}, {162, 123, 124},
{161, 124, 163}, {161, 124, 203}, {160, 125, 238}, {160, 125, 251},
{158, 157, 47}, {157, 158, 120}, {157, 158, 159}, {155, 158, 198},
{155, 159, 236}, {155, 158, 252}, {153, 192, 55}, {152, 192, 117},
{151, 192, 154}, {151, 192, 193}, {150, 192, 231}, {150, 192, 251},
{148, 225, 53}, {147, 225, 114}, {146, 225, 150}, {147, 226, 188},
{145, 226, 226}, {145, 226, 250}, {142, 251, 61}, {141, 251, 111},
{141, 252, 146}, {142, 253, 183}, {139, 254, 221}, {138, 255, 249},
{211, 59, 40}, {209, 63, 126}, {207, 63, 166}, {206, 64, 206},
{205, 69, 243}, {204, 72, 252}, {202, 121, 45}, {201, 122, 122},
{200, 122, 161}, {199, 123, 200}, {199, 124, 238}, {197, 124, 252},
{197, 156, 51}, {195, 156, 119}, {195, 157, 157}, {194, 157, 196},
{193, 157, 234}, {193, 157, 252}, {191, 190, 54}, {190, 190, 116},
{189, 191, 153}, {190, 191, 191}, {188, 191, 229}, {187, 191, 251},
{186, 224, 55}, {185, 224, 113}, {184, 224, 150}, {184, 224, 187},
{184, 225, 225}, {182, 224, 251}, {180, 253, 62}, {180, 253, 111},
{179, 253, 146}, {179, 253, 183}, {179, 254, 220}, {177, 252, 249},
{244, 59, 43}, {243, 62, 123}, {241, 65, 162}, {241, 69, 202},
{240, 70, 238}, {238, 69, 252}, {239, 119, 50}, {238, 120, 120},
{236, 121, 159}, {235, 121, 198}, {235, 123, 236}, {234, 123, 252},
{234, 154, 53}, {233, 154, 118}, {232, 155, 156}, {231, 155, 194},
{231, 156, 233}, {230, 156, 252}, {229, 188, 53}, {228, 189, 115},
{227, 189, 152}, {227, 189, 190}, {226, 189, 228}, {225, 189, 253},
{223, 222, 60}, {223, 223, 113}, {222, 223, 149}, {222, 223, 186},
{222, 223, 224}, {220, 223, 252}, {218, 251, 61}, {217, 251, 109},
{217, 251, 145}, {217, 251, 182}, {216, 251, 219}, {216, 251, 250},
{252, 63, 43}, {252, 64, 120}, {252, 64, 159}, {252, 65, 198},
{252, 67, 236}, {252, 72, 252}, {253, 117, 47}, {253, 118, 118},
{253, 119, 156}, {253, 120, 194}, {253, 120, 233}, {252, 121, 252},
{253, 152, 49}, {252, 152, 116}, {252, 153, 153}, {253, 153, 192},
{252, 154, 229}, {251, 154, 251}, {253, 186, 56}, {251, 187, 114},
{251, 187, 151}, {252, 187, 188}, {252, 188, 226}, {251, 188, 251},
{251, 221, 61}, {250, 221, 112}, {250, 221, 148}, {250, 221, 185},
{251, 222, 222}, {251, 222, 251}, {251, 250, 58}, {250, 250, 109},
{249, 250, 144}, {247, 251, 181}, {247, 253, 218}, {254, 255, 255},
{52, 53, 53}, {57, 58, 59}, {66, 67, 67}, {75, 76, 76},
{84, 85, 85}, {92, 93, 94}, {101, 102, 102}, {109, 111, 111},
{118, 119, 119}, {126, 127, 128}, {134, 136, 136}, {143, 144, 145},
{151, 152, 153}, {159, 161, 161}, {167, 169, 169}, {176, 177, 177},
{184, 185, 186}, {192, 193, 194}, {200, 201, 202}, {208, 209, 210},
{216, 218, 218}, {224, 226, 226}, {232, 234, 234}, {240, 242, 242},
};
const struct Rgb kXtermRgbAppleBg[] = {
{0, 0, 0}, {151, 4, 12}, {23, 164, 26}, {153, 152, 29},
{8, 43, 181}, {177, 25, 176}, {26, 166, 177}, {191, 191, 191},
{132, 132, 132}, {227, 10, 23}, {33, 215, 38}, {229, 228, 49},
{11, 36, 251}, {227, 35, 227}, {39, 229, 228}, {230, 229, 230},
{0, 0, 0}, {1, 7, 93}, {3, 14, 133}, {5, 21, 172},
{7, 28, 211}, {11, 36, 251}, {8, 94, 11}, {10, 95, 95},
{11, 96, 133}, {13, 97, 173}, {15, 99, 212}, {18, 101, 251},
{17, 134, 20}, {18, 134, 96}, {18, 135, 134}, {20, 136, 173},
{21, 137, 212}, {23, 138, 251}, {25, 173, 29}, {26, 174, 98},
{26, 174, 136}, {27, 175, 174}, {28, 175, 213}, {30, 176, 252},
{33, 213, 38}, {34, 213, 101}, {34, 214, 137}, {35, 214, 175},
{36, 215, 214}, {37, 215, 253}, {41, 253, 47}, {42, 253, 104},
{42, 253, 140}, {43, 253, 177}, {44, 254, 215}, {45, 255, 254},
{94, 2, 4}, {94, 8, 94}, {94, 15, 133}, {94, 22, 172},
{95, 29, 211}, {95, 36, 251}, {95, 94, 14}, {95, 95, 95},
{95, 96, 134}, {95, 97, 173}, {96, 99, 212}, {96, 101, 251},
{96, 134, 22}, {96, 134, 96}, {96, 135, 135}, {97, 136, 173},
{97, 137, 212}, {97, 138, 252}, {98, 173, 30}, {98, 174, 98},
{98, 174, 136}, {98, 175, 174}, {98, 176, 213}, {99, 177, 252},
{100, 213, 39}, {100, 213, 101}, {100, 214, 138}, {100, 214, 176},
{101, 215, 214}, {101, 215, 253}, {102, 253, 48}, {103, 253, 104},
{103, 253, 140}, {103, 253, 177}, {103, 254, 215}, {104, 255, 254},
{133, 3, 9}, {133, 10, 94}, {134, 16, 133}, {134, 23, 172},
{134, 30, 212}, {134, 37, 251}, {134, 94, 18}, {134, 95, 96},
{134, 96, 134}, {134, 97, 173}, {135, 99, 212}, {135, 101, 251},
{135, 134, 25}, {135, 134, 97}, {135, 135, 135}, {135, 136, 174},
{135, 137, 213}, {136, 138, 252}, {136, 173, 32}, {136, 174, 99},
{136, 174, 136}, {136, 175, 175}, {136, 176, 213}, {137, 177, 252},
{137, 213, 40}, {137, 213, 102}, {138, 214, 138}, {138, 214, 176},
{138, 215, 214}, {138, 216, 253}, {139, 253, 49}, {139, 253, 105},
{139, 253, 140}, {139, 254, 178}, {140, 254, 216}, {140, 255, 254},
{173, 6, 15}, {173, 12, 95}, {173, 18, 134}, {173, 24, 173},
{173, 31, 212}, {174, 38, 251}, {173, 95, 22}, {174, 95, 96},
{174, 96, 135}, {174, 98, 173}, {174, 99, 212}, {174, 101, 252},
{174, 134, 28}, {174, 135, 98}, {174, 135, 136}, {174, 136, 174},
{174, 137, 213}, {175, 139, 252}, {175, 174, 35}, {175, 174, 100},
{175, 174, 137}, {175, 175, 175}, {175, 176, 214}, {175, 177, 253},
{176, 213, 43}, {176, 213, 102}, {176, 214, 139}, {176, 214, 176},
{176, 215, 215}, {176, 216, 253}, {177, 253, 51}, {177, 253, 105},
{177, 253, 141}, {177, 254, 178}, {178, 254, 216}, {178, 255, 254},
{213, 9, 21}, {213, 15, 96}, {213, 20, 135}, {241, 69, 202},
{213, 32, 212}, {213, 39, 251}, {213, 95, 27}, {213, 96, 97},
{213, 97, 135}, {213, 98, 174}, {213, 100, 213}, {213, 102, 252},
{213, 134, 32}, {213, 135, 99}, {213, 135, 136}, {214, 136, 175},
{214, 137, 213}, {214, 139, 252}, {214, 174, 38}, {214, 174, 101},
{214, 175, 138}, {214, 175, 176}, {214, 176, 214}, {214, 177, 253},
{215, 213, 45}, {215, 214, 103}, {215, 214, 139}, {215, 214, 177},
{215, 215, 215}, {215, 216, 254}, {216, 253, 53}, {216, 253, 106},
{216, 253, 141}, {216, 254, 178}, {216, 254, 216}, {216, 255, 255},
{252, 13, 27}, {252, 18, 98}, {252, 22, 135}, {252, 28, 174},
{252, 34, 213}, {252, 40, 252}, {252, 96, 32}, {252, 96, 99},
{252, 97, 136}, {253, 99, 175}, {253, 100, 213}, {253, 102, 252},
{253, 135, 36}, {253, 135, 100}, {253, 136, 137}, {253, 137, 175},
{253, 138, 214}, {253, 139, 253}, {253, 174, 42}, {253, 174, 102},
{253, 175, 138}, {253, 175, 176}, {253, 176, 215}, {254, 177, 253},
{254, 213, 48}, {254, 214, 105}, {254, 214, 140}, {254, 215, 177},
{254, 215, 216}, {254, 216, 254}, {255, 253, 56}, {255, 253, 108},
{255, 253, 142}, {255, 254, 179}, {255, 254, 217}, {255, 255, 255},
{8, 8, 8}, {18, 18, 18}, {28, 28, 28}, {38, 38, 38},
{48, 48, 48}, {58, 58, 58}, {68, 68, 68}, {78, 78, 78},
{88, 88, 88}, {98, 98, 98}, {108, 108, 108}, {118, 118, 118},
{128, 128, 128}, {138, 138, 138}, {148, 148, 148}, {158, 158, 158},
{168, 168, 168}, {178, 178, 178}, {188, 188, 188}, {198, 198, 198},
{208, 208, 208}, {218, 218, 218}, {228, 228, 228}, {238, 238, 238},
};
const struct XtermDb {
struct Rgb rgb;
const char *text;
} kXtermDb[] = {
{{0x00, 0x00, 0x00}, "0 Black #000000"},
{{0x80, 0x00, 0x00}, "1 Maroon #800000"},
{{0x00, 0x80, 0x00}, "2 Green #008000"},
{{0x80, 0x80, 0x00}, "3 Olive #808000"},
{{0x00, 0x00, 0x80}, "4 Navy #000080"},
{{0x80, 0x00, 0x80}, "5 Purple #800080"},
{{0x00, 0x80, 0x80}, "6 Teal #008080"},
{{0xc0, 0xc0, 0xc0}, "7 Silver #c0c0c0"},
{{0x80, 0x80, 0x80}, "8 Grey #808080"},
{{0xff, 0x00, 0x00}, "9 Red #ff0000"},
{{0x00, 0xff, 0x00}, "10 Lime #00ff00"},
{{0xff, 0xff, 0x00}, "11 Yellow #ffff00"},
{{0x00, 0x00, 0xff}, "12 Blue #0000ff"},
{{0xff, 0x00, 0xff}, "13 Fuchsia #ff00ff"},
{{0x00, 0xff, 0xff}, "14 Aqua #00ffff"},
{{0xff, 0xff, 0xff}, "15 White #ffffff"},
{{0x00, 0x00, 0x00}, "16 Grey0 #000000"},
{{0x00, 0x00, 0x5f}, "17 NavyBlue #00005f"},
{{0x00, 0x00, 0x87}, "18 DarkBlue #000087"},
{{0x00, 0x00, 0xaf}, "19 Blue3 #0000af"},
{{0x00, 0x00, 0xd7}, "20 Blue3 #0000d7"},
{{0x00, 0x00, 0xff}, "21 Blue1 #0000ff"},
{{0x00, 0x5f, 0x00}, "22 DarkGreen #005f00"},
{{0x00, 0x5f, 0x5f}, "23 DeepSkyBlue4 #005f5f"},
{{0x00, 0x5f, 0x87}, "24 DeepSkyBlue4 #005f87"},
{{0x00, 0x5f, 0xaf}, "25 DeepSkyBlue4 #005faf"},
{{0x00, 0x5f, 0xd7}, "26 DodgerBlue3 #005fd7"},
{{0x00, 0x5f, 0xff}, "27 DodgerBlue2 #005fff"},
{{0x00, 0x87, 0x00}, "28 Green4 #008700"},
{{0x00, 0x87, 0x5f}, "29 SpringGreen4 #00875f"},
{{0x00, 0x87, 0x87}, "30 Turquoise4 #008787"},
{{0x00, 0x87, 0xaf}, "31 DeepSkyBlue3 #0087af"},
{{0x00, 0x87, 0xd7}, "32 DeepSkyBlue3 #0087d7"},
{{0x00, 0x87, 0xff}, "33 DodgerBlue1 #0087ff"},
{{0x00, 0xaf, 0x00}, "34 Green3 #00af00"},
{{0x00, 0xaf, 0x5f}, "35 SpringGreen3 #00af5f"},
{{0x00, 0xaf, 0x87}, "36 DarkCyan #00af87"},
{{0x00, 0xaf, 0xaf}, "37 LightSeaGreen #00afaf"},
{{0x00, 0xaf, 0xd7}, "38 DeepSkyBlue2 #00afd7"},
{{0x00, 0xaf, 0xff}, "39 DeepSkyBlue1 #00afff"},
{{0x00, 0xd7, 0x00}, "40 Green3 #00d700"},
{{0x00, 0xd7, 0x5f}, "41 SpringGreen3 #00d75f"},
{{0x00, 0xd7, 0x87}, "42 SpringGreen2 #00d787"},
{{0x00, 0xd7, 0xaf}, "43 Cyan3 #00d7af"},
{{0x00, 0xd7, 0xd7}, "44 DarkTurquoise #00d7d7"},
{{0x00, 0xd7, 0xff}, "45 Turquoise2 #00d7ff"},
{{0x00, 0xff, 0x00}, "46 Green1 #00ff00"},
{{0x00, 0xff, 0x5f}, "47 SpringGreen2 #00ff5f"},
{{0x00, 0xff, 0x87}, "48 SpringGreen1 #00ff87"},
{{0x00, 0xff, 0xaf}, "49 MediumSpringGreen #00ffaf"},
{{0x00, 0xff, 0xd7}, "50 Cyan2 #00ffd7"},
{{0x00, 0xff, 0xff}, "51 Cyan1 #00ffff"},
{{0x5f, 0x00, 0x00}, "52 DarkRed #5f0000"},
{{0x5f, 0x00, 0x5f}, "53 DeepPink4 #5f005f"},
{{0x5f, 0x00, 0x87}, "54 Purple4 #5f0087"},
{{0x5f, 0x00, 0xaf}, "55 Purple4 #5f00af"},
{{0x5f, 0x00, 0xd7}, "56 Purple3 #5f00d7"},
{{0x5f, 0x00, 0xff}, "57 BlueViolet #5f00ff"},
{{0x5f, 0x5f, 0x00}, "58 Orange4 #5f5f00"},
{{0x5f, 0x5f, 0x5f}, "59 Grey37 #5f5f5f"},
{{0x5f, 0x5f, 0x87}, "60 MediumPurple4 #5f5f87"},
{{0x5f, 0x5f, 0xaf}, "61 SlateBlue3 #5f5faf"},
{{0x5f, 0x5f, 0xd7}, "62 SlateBlue3 #5f5fd7"},
{{0x5f, 0x5f, 0xff}, "63 RoyalBlue1 #5f5fff"},
{{0x5f, 0x87, 0x00}, "64 Chartreuse4 #5f8700"},
{{0x5f, 0x87, 0x5f}, "65 DarkSeaGreen4 #5f875f"},
{{0x5f, 0x87, 0x87}, "66 PaleTurquoise4 #5f8787"},
{{0x5f, 0x87, 0xaf}, "67 SteelBlue #5f87af"},
{{0x5f, 0x87, 0xd7}, "68 SteelBlue3 #5f87d7"},
{{0x5f, 0x87, 0xff}, "69 CornflowerBlue #5f87ff"},
{{0x5f, 0xaf, 0x00}, "70 Chartreuse3 #5faf00"},
{{0x5f, 0xaf, 0x5f}, "71 DarkSeaGreen4 #5faf5f"},
{{0x5f, 0xaf, 0x87}, "72 CadetBlue #5faf87"},
{{0x5f, 0xaf, 0xaf}, "73 CadetBlue #5fafaf"},
{{0x5f, 0xaf, 0xd7}, "74 SkyBlue3 #5fafd7"},
{{0x5f, 0xaf, 0xff}, "75 SteelBlue1 #5fafff"},
{{0x5f, 0xd7, 0x00}, "76 Chartreuse3 #5fd700"},
{{0x5f, 0xd7, 0x5f}, "77 PaleGreen3 #5fd75f"},
{{0x5f, 0xd7, 0x87}, "78 SeaGreen3 #5fd787"},
{{0x5f, 0xd7, 0xaf}, "79 Aquamarine3 #5fd7af"},
{{0x5f, 0xd7, 0xd7}, "80 MediumTurquoise #5fd7d7"},
{{0x5f, 0xd7, 0xff}, "81 SteelBlue1 #5fd7ff"},
{{0x5f, 0xff, 0x00}, "82 Chartreuse2 #5fff00"},
{{0x5f, 0xff, 0x5f}, "83 SeaGreen2 #5fff5f"},
{{0x5f, 0xff, 0x87}, "84 SeaGreen1 #5fff87"},
{{0x5f, 0xff, 0xaf}, "85 SeaGreen1 #5fffaf"},
{{0x5f, 0xff, 0xd7}, "86 Aquamarine1 #5fffd7"},
{{0x5f, 0xff, 0xff}, "87 DarkSlateGray2 #5fffff"},
{{0x87, 0x00, 0x00}, "88 DarkRed #870000"},
{{0x87, 0x00, 0x5f}, "89 DeepPink4 #87005f"},
{{0x87, 0x00, 0x87}, "90 DarkMagenta #870087"},
{{0x87, 0x00, 0xaf}, "91 DarkMagenta #8700af"},
{{0x87, 0x00, 0xd7}, "92 DarkViolet #8700d7"},
{{0x87, 0x00, 0xff}, "93 Purple #8700ff"},
{{0x87, 0x5f, 0x00}, "94 Orange4 #875f00"},
{{0x87, 0x5f, 0x5f}, "95 LightPink4 #875f5f"},
{{0x87, 0x5f, 0x87}, "96 Plum4 #875f87"},
{{0x87, 0x5f, 0xaf}, "97 MediumPurple3 #875faf"},
{{0x87, 0x5f, 0xd7}, "98 MediumPurple3 #875fd7"},
{{0x87, 0x5f, 0xff}, "99 SlateBlue1 #875fff"},
{{0x87, 0x87, 0x00}, "100 Yellow4 #878700"},
{{0x87, 0x87, 0x5f}, "101 Wheat4 #87875f"},
{{0x87, 0x87, 0x87}, "102 Grey53 #878787"},
{{0x87, 0x87, 0xaf}, "103 LightSlateGrey #8787af"},
{{0x87, 0x87, 0xd7}, "104 MediumPurple #8787d7"},
{{0x87, 0x87, 0xff}, "105 LightSlateBlue #8787ff"},
{{0x87, 0xaf, 0x00}, "106 Yellow4 #87af00"},
{{0x87, 0xaf, 0x5f}, "107 DarkOliveGreen3 #87af5f"},
{{0x87, 0xaf, 0x87}, "108 DarkSeaGreen #87af87"},
{{0x87, 0xaf, 0xaf}, "109 LightSkyBlue3 #87afaf"},
{{0x87, 0xaf, 0xd7}, "110 LightSkyBlue3 #87afd7"},
{{0x87, 0xaf, 0xff}, "111 SkyBlue2 #87afff"},
{{0x87, 0xd7, 0x00}, "112 Chartreuse2 #87d700"},
{{0x87, 0xd7, 0x5f}, "113 DarkOliveGreen3 #87d75f"},
{{0x87, 0xd7, 0x87}, "114 PaleGreen3 #87d787"},
{{0x87, 0xd7, 0xaf}, "115 DarkSeaGreen3 #87d7af"},
{{0x87, 0xd7, 0xd7}, "116 DarkSlateGray3 #87d7d7"},
{{0x87, 0xd7, 0xff}, "117 SkyBlue1 #87d7ff"},
{{0x87, 0xff, 0x00}, "118 Chartreuse1 #87ff00"},
{{0x87, 0xff, 0x5f}, "119 LightGreen #87ff5f"},
{{0x87, 0xff, 0x87}, "120 LightGreen #87ff87"},
{{0x87, 0xff, 0xaf}, "121 PaleGreen1 #87ffaf"},
{{0x87, 0xff, 0xd7}, "122 Aquamarine1 #87ffd7"},
{{0x87, 0xff, 0xff}, "123 DarkSlateGray1 #87ffff"},
{{0xaf, 0x00, 0x00}, "124 Red3 #af0000"},
{{0xaf, 0x00, 0x5f}, "125 DeepPink4 #af005f"},
{{0xaf, 0x00, 0x87}, "126 MediumVioletRed #af0087"},
{{0xaf, 0x00, 0xaf}, "127 Magenta3 #af00af"},
{{0xaf, 0x00, 0xd7}, "128 DarkViolet #af00d7"},
{{0xaf, 0x00, 0xff}, "129 Purple #af00ff"},
{{0xaf, 0x5f, 0x00}, "130 DarkOrange3 #af5f00"},
{{0xaf, 0x5f, 0x5f}, "131 IndianRed #af5f5f"},
{{0xaf, 0x5f, 0x87}, "132 HotPink3 #af5f87"},
{{0xaf, 0x5f, 0xaf}, "133 MediumOrchid3 #af5faf"},
{{0xaf, 0x5f, 0xd7}, "134 MediumOrchid #af5fd7"},
{{0xaf, 0x5f, 0xff}, "135 MediumPurple2 #af5fff"},
{{0xaf, 0x87, 0x00}, "136 DarkGoldenrod #af8700"},
{{0xaf, 0x87, 0x5f}, "137 LightSalmon3 #af875f"},
{{0xaf, 0x87, 0x87}, "138 RosyBrown #af8787"},
{{0xaf, 0x87, 0xaf}, "139 Grey63 #af87af"},
{{0xaf, 0x87, 0xd7}, "140 MediumPurple2 #af87d7"},
{{0xaf, 0x87, 0xff}, "141 MediumPurple1 #af87ff"},
{{0xaf, 0xaf, 0x00}, "142 Gold3 #afaf00"},
{{0xaf, 0xaf, 0x5f}, "143 DarkKhaki #afaf5f"},
{{0xaf, 0xaf, 0x87}, "144 NavajoWhite3 #afaf87"},
{{0xaf, 0xaf, 0xaf}, "145 Grey69 #afafaf"},
{{0xaf, 0xaf, 0xd7}, "146 LightSteelBlue3 #afafd7"},
{{0xaf, 0xaf, 0xff}, "147 LightSteelBlue #afafff"},
{{0xaf, 0xd7, 0x00}, "148 Yellow3 #afd700"},
{{0xaf, 0xd7, 0x5f}, "149 DarkOliveGreen3 #afd75f"},
{{0xaf, 0xd7, 0x87}, "150 DarkSeaGreen3 #afd787"},
{{0xaf, 0xd7, 0xaf}, "151 DarkSeaGreen2 #afd7af"},
{{0xaf, 0xd7, 0xd7}, "152 LightCyan3 #afd7d7"},
{{0xaf, 0xd7, 0xff}, "153 LightSkyBlue1 #afd7ff"},
{{0xaf, 0xff, 0x00}, "154 GreenYellow #afff00"},
{{0xaf, 0xff, 0x5f}, "155 DarkOliveGreen2 #afff5f"},
{{0xaf, 0xff, 0x87}, "156 PaleGreen1 #afff87"},
{{0xaf, 0xff, 0xaf}, "157 DarkSeaGreen2 #afffaf"},
{{0xaf, 0xff, 0xd7}, "158 DarkSeaGreen1 #afffd7"},
{{0xaf, 0xff, 0xff}, "159 PaleTurquoise1 #afffff"},
{{0xd7, 0x00, 0x00}, "160 Red3 #d70000"},
{{0xd7, 0x00, 0x5f}, "161 DeepPink3 #d7005f"},
{{0xd7, 0x00, 0x87}, "162 DeepPink3 #d70087"},
{{0xd7, 0x00, 0xaf}, "163 Magenta3 #d700af"},
{{0xd7, 0x00, 0xd7}, "164 Magenta3 #d700d7"},
{{0xd7, 0x00, 0xff}, "165 Magenta2 #d700ff"},
{{0xd7, 0x5f, 0x00}, "166 DarkOrange3 #d75f00"},
{{0xd7, 0x5f, 0x5f}, "167 IndianRed #d75f5f"},
{{0xd7, 0x5f, 0x87}, "168 HotPink3 #d75f87"},
{{0xd7, 0x5f, 0xaf}, "169 HotPink2 #d75faf"},
{{0xd7, 0x5f, 0xd7}, "170 Orchid #d75fd7"},
{{0xd7, 0x5f, 0xff}, "171 MediumOrchid1 #d75fff"},
{{0xd7, 0x87, 0x00}, "172 Orange3 #d78700"},
{{0xd7, 0x87, 0x5f}, "173 LightSalmon3 #d7875f"},
{{0xd7, 0x87, 0x87}, "174 LightPink3 #d78787"},
{{0xd7, 0x87, 0xaf}, "175 Pink3 #d787af"},
{{0xd7, 0x87, 0xd7}, "176 Plum3 #d787d7"},
{{0xd7, 0x87, 0xff}, "177 Violet #d787ff"},
{{0xd7, 0xaf, 0x00}, "178 Gold3 #d7af00"},
{{0xd7, 0xaf, 0x5f}, "179 LightGoldenrod3 #d7af5f"},
{{0xd7, 0xaf, 0x87}, "180 Tan #d7af87"},
{{0xd7, 0xaf, 0xaf}, "181 MistyRose3 #d7afaf"},
{{0xd7, 0xaf, 0xd7}, "182 Thistle3 #d7afd7"},
{{0xd7, 0xaf, 0xff}, "183 Plum2 #d7afff"},
{{0xd7, 0xd7, 0x00}, "184 Yellow3 #d7d700"},
{{0xd7, 0xd7, 0x5f}, "185 Khaki3 #d7d75f"},
{{0xd7, 0xd7, 0x87}, "186 LightGoldenrod2 #d7d787"},
{{0xd7, 0xd7, 0xaf}, "187 LightYellow3 #d7d7af"},
{{0xd7, 0xd7, 0xd7}, "188 Grey84 #d7d7d7"},
{{0xd7, 0xd7, 0xff}, "189 LightSteelBlue1 #d7d7ff"},
{{0xd7, 0xff, 0x00}, "190 Yellow2 #d7ff00"},
{{0xd7, 0xff, 0x5f}, "191 DarkOliveGreen1 #d7ff5f"},
{{0xd7, 0xff, 0x87}, "192 DarkOliveGreen1 #d7ff87"},
{{0xd7, 0xff, 0xaf}, "193 DarkSeaGreen1 #d7ffaf"},
{{0xd7, 0xff, 0xd7}, "194 Honeydew2 #d7ffd7"},
{{0xd7, 0xff, 0xff}, "195 LightCyan1 #d7ffff"},
{{0xff, 0x00, 0x00}, "196 Red1 #ff0000"},
{{0xff, 0x00, 0x5f}, "197 DeepPink2 #ff005f"},
{{0xff, 0x00, 0x87}, "198 DeepPink1 #ff0087"},
{{0xff, 0x00, 0xaf}, "199 DeepPink1 #ff00af"},
{{0xff, 0x00, 0xd7}, "200 Magenta2 #ff00d7"},
{{0xff, 0x00, 0xff}, "201 Magenta1 #ff00ff"},
{{0xff, 0x5f, 0x00}, "202 OrangeRed1 #ff5f00"},
{{0xff, 0x5f, 0x5f}, "203 IndianRed1 #ff5f5f"},
{{0xff, 0x5f, 0x87}, "204 IndianRed1 #ff5f87"},
{{0xff, 0x5f, 0xaf}, "205 HotPink #ff5faf"},
{{0xff, 0x5f, 0xd7}, "206 HotPink #ff5fd7"},
{{0xff, 0x5f, 0xff}, "207 MediumOrchid1 #ff5fff"},
{{0xff, 0x87, 0x00}, "208 DarkOrange #ff8700"},
{{0xff, 0x87, 0x5f}, "209 Salmon1 #ff875f"},
{{0xff, 0x87, 0x87}, "210 LightCoral #ff8787"},
{{0xff, 0x87, 0xaf}, "211 PaleVioletRed1 #ff87af"},
{{0xff, 0x87, 0xd7}, "212 Orchid2 #ff87d7"},
{{0xff, 0x87, 0xff}, "213 Orchid1 #ff87ff"},
{{0xff, 0xaf, 0x00}, "214 Orange1 #ffaf00"},
{{0xff, 0xaf, 0x5f}, "215 SandyBrown #ffaf5f"},
{{0xff, 0xaf, 0x87}, "216 LightSalmon1 #ffaf87"},
{{0xff, 0xaf, 0xaf}, "217 LightPink1 #ffafaf"},
{{0xff, 0xaf, 0xd7}, "218 Pink1 #ffafd7"},
{{0xff, 0xaf, 0xff}, "219 Plum1 #ffafff"},
{{0xff, 0xd7, 0x00}, "220 Gold1 #ffd700"},
{{0xff, 0xd7, 0x5f}, "221 LightGoldenrod2 #ffd75f"},
{{0xff, 0xd7, 0x87}, "222 LightGoldenrod2 #ffd787"},
{{0xff, 0xd7, 0xaf}, "223 NavajoWhite1 #ffd7af"},
{{0xff, 0xd7, 0xd7}, "224 MistyRose1 #ffd7d7"},
{{0xff, 0xd7, 0xff}, "225 Thistle1 #ffd7ff"},
{{0xff, 0xff, 0x00}, "226 Yellow1 #ffff00"},
{{0xff, 0xff, 0x5f}, "227 LightGoldenrod1 #ffff5f"},
{{0xff, 0xff, 0x87}, "228 Khaki1 #ffff87"},
{{0xff, 0xff, 0xaf}, "229 Wheat1 #ffffaf"},
{{0xff, 0xff, 0xd7}, "230 Cornsilk1 #ffffd7"},
{{0xff, 0xff, 0xff}, "231 Grey100 #ffffff"},
{{0x08, 0x08, 0x08}, "232 Grey3 #080808"},
{{0x12, 0x12, 0x12}, "233 Grey7 #121212"},
{{0x1c, 0x1c, 0x1c}, "234 Grey11 #1c1c1c"},
{{0x26, 0x26, 0x26}, "235 Grey15 #262626"},
{{0x30, 0x30, 0x30}, "236 Grey19 #303030"},
{{0x3a, 0x3a, 0x3a}, "237 Grey23 #3a3a3a"},
{{0x44, 0x44, 0x44}, "238 Grey27 #444444"},
{{0x4e, 0x4e, 0x4e}, "239 Grey30 #4e4e4e"},
{{0x58, 0x58, 0x58}, "240 Grey35 #585858"},
{{0x62, 0x62, 0x62}, "241 Grey39 #626262"},
{{0x6c, 0x6c, 0x6c}, "242 Grey42 #6c6c6c"},
{{0x76, 0x76, 0x76}, "243 Grey46 #767676"},
{{0x80, 0x80, 0x80}, "244 Grey50 #808080"},
{{0x8a, 0x8a, 0x8a}, "245 Grey54 #8a8a8a"},
{{0x94, 0x94, 0x94}, "246 Grey58 #949494"},
{{0x9e, 0x9e, 0x9e}, "247 Grey62 #9e9e9e"},
{{0xa8, 0xa8, 0xa8}, "248 Grey66 #a8a8a8"},
{{0xb2, 0xb2, 0xb2}, "249 Grey70 #b2b2b2"},
{{0xbc, 0xbc, 0xbc}, "250 Grey74 #bcbcbc"},
{{0xc6, 0xc6, 0xc6}, "251 Grey78 #c6c6c6"},
{{0xd0, 0xd0, 0xd0}, "252 Grey82 #d0d0d0"},
{{0xda, 0xda, 0xda}, "253 Grey85 #dadada"},
{{0xe4, 0xe4, 0xe4}, "254 Grey89 #e4e4e4"},
{{0xee, 0xee, 0xee}, "255 Grey93 #eeeeee"},
};
int main(int argc, char *argv[]) {
size_t i;
printf("BG FG BB BF XTERM NAME HEX\n");
for (i = 0; i < 256; ++i) {
printf("\e[48;5;%dm \e[0m \e[38;5;%dm██\e[0m \e[1;48;5;%dm "
"\e[0m \e[1;38;5;%dm██\e[0m %-6hhu%-18s#%02hhx%02hhx%02hhx\n",
i, i, i, i, i, IndexDoubleNulString(kXtermName, i), kXtermRgb[i].r,
kXtermRgb[i].g, kXtermRgb[i].b);
}
return 0;
}