Mon Apr 18 18:00:17 2005 Michael Jennings (mej)

Applied a patch from Fredrik Svensson <fred@ludd.ltu.se> for 256-color
support (a la xterm).  I also renamed and imported a couple of his
test scripts into utils/, and in playing around with them, I found and
fixed an X server resource leak.  Use Etpalette to view the 256-color
palette.
----------------------------------------------------------------------


SVN revision: 14228
eterm-0.10
Michael Jennings 18 years ago
parent 4d779be4e2
commit 05469ad9f0
  1. 8
      ChangeLog
  2. 1
      src/options.c
  3. 2
      src/screen.c
  4. 20
      src/screen.h
  5. 282
      src/term.c
  6. 16
      src/term.h
  7. 7
      src/windows.c
  8. 109
      utils/Etcolors
  9. 33
      utils/Etgen-color-cube
  10. 31
      utils/Etgen-color-cube-c
  11. 45
      utils/Etpalette

@ -5317,3 +5317,11 @@ Mon Apr 18 16:00:22 2005 Michael Jennings (mej)
Remove unused NO_XLOCALE crap and do it right.
----------------------------------------------------------------------
Mon Apr 18 18:00:17 2005 Michael Jennings (mej)
Applied a patch from Fredrik Svensson <fred@ludd.ltu.se> for 256-color
support (a la xterm). I also renamed and imported a couple of his
test scripts into utils/, and in playing around with them, I found and
fixed an X server resource leak. Use Etpalette to view the 256-color
palette.
----------------------------------------------------------------------

@ -2516,6 +2516,7 @@ init_defaults(void)
rs_path = NULL;
#endif
colorfgbg = DEFAULT_RSTYLE;
MEMSET(PixColors, 0, sizeof(PixColors));
/* Font stuff. */
MEMSET(rs_font, 0, sizeof(char *) * NFONTS);

@ -491,7 +491,7 @@ scr_color(unsigned int color, unsigned int Intensity)
break;
}
} else {
if ((rstyle & Intensity) && color >= minColor && color <= maxColor) {
if ((rstyle & Intensity) && (color >= minColor) && (color <= maxColor)) {
switch (Intensity) {
case RS_Bold:
if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_BOLD_BRIGHTENS_FOREGROUND)) {

@ -118,11 +118,11 @@ enum {
#define RS_multi2 (RS_multi0|RS_multi1) /* multibyte 2nd byte */
#define RS_multiMask (RS_multi0|RS_multi1) /* multibyte mask */
#endif
#define RS_fgMask 0x00001F00u /* 32 colors */
#define RS_Overscore 0x00002000u /* overscore */
#define RS_Italic 0x00004000u /* italic */
#define RS_Bold 0x00008000u /* bold */
#define RS_bgMask 0x001F0000u /* 32 colors */
#define RS_fgMask 0x0003FE00u /* 512 colors */
#define RS_bgMask 0x000001FFu /* 512 colors */
#define RS_Overscore 0x00040000u /* overscore */
#define RS_Italic 0x00080000u /* italic */
#define RS_Bold 0x00100000u /* bold */
#define RS_Dim 0x00200000u /* dim (apply alpha) */
#define RS_Conceal 0x00400000u /* conceal */
#define RS_Blink 0x00800000u /* blink */
@ -130,15 +130,15 @@ enum {
#define RS_attrMask (0xFF000000u|RS_Overscore|RS_Italic|RS_Bold|RS_Dim|RS_Conceal|RS_Blink)
/* how to build & extract colors and attributes */
#define GET_FGCOLOR(r) (((r) & RS_fgMask)>>8)
#define GET_BGCOLOR(r) (((r) & RS_bgMask)>>16)
#define GET_FGCOLOR(r) (((r) & RS_fgMask)>>9)
#define GET_BGCOLOR(r) (((r) & RS_bgMask))
#define GET_ATTR(r) (((r) & RS_attrMask))
#define GET_BGATTR(r) (((r) & (RS_attrMask | RS_bgMask)))
#define SET_FGCOLOR(r,fg) (((r) & ~RS_fgMask) | ((fg)<<8))
#define SET_BGCOLOR(r,bg) (((r) & ~RS_bgMask) | ((bg)<<16))
#define SET_FGCOLOR(r,fg) (((r) & ~RS_fgMask) | ((fg)<<9))
#define SET_BGCOLOR(r,bg) (((r) & ~RS_bgMask) | (bg))
#define SET_ATTR(r,a) (((r) & ~RS_attrMask)| (a))
#define DEFAULT_RSTYLE (RS_None | (fgColor<<8) | (bgColor<<16))
#define DEFAULT_RSTYLE (RS_None | (fgColor<<9) | (bgColor))
/* screen_t flags */
#define Screen_Relative (1<<0) /* relative origin mode flag */

@ -58,7 +58,6 @@ unsigned char meta_char = 033; /* Alt-key prefix */
unsigned long PrivateModes = PrivMode_Default;
unsigned long SavedModes = PrivMode_Default;
char *def_colorName[] = {
"rgb:aa/aa/aa", "rgb:0/0/0", /* fg/bg */
"rgb:0/0/0", /* 0: black (#000000) */
/* low-intensity colors */
"rgb:cc/00/00", /* 1: red */
@ -77,6 +76,254 @@ char *def_colorName[] = {
"rgb:ff/00/ff", /* 5/13: bright magenta */
"rgb:00/ff/ff", /* 6/14: bright cyan */
"rgb:ff/ff/ff", /* 7/15: bright white */
/* 6x6x6 color cube generated with color-cube-gen.pl */
"rgb:00/00/00",
"rgb:00/00/2a",
"rgb:00/00/55",
"rgb:00/00/7f",
"rgb:00/00/aa",
"rgb:00/00/d4",
"rgb:00/2a/00",
"rgb:00/2a/2a",
"rgb:00/2a/55",
"rgb:00/2a/7f",
"rgb:00/2a/aa",
"rgb:00/2a/d4",
"rgb:00/55/00",
"rgb:00/55/2a",
"rgb:00/55/55",
"rgb:00/55/7f",
"rgb:00/55/aa",
"rgb:00/55/d4",
"rgb:00/7f/00",
"rgb:00/7f/2a",
"rgb:00/7f/55",
"rgb:00/7f/7f",
"rgb:00/7f/aa",
"rgb:00/7f/d4",
"rgb:00/aa/00",
"rgb:00/aa/2a",
"rgb:00/aa/55",
"rgb:00/aa/7f",
"rgb:00/aa/aa",
"rgb:00/aa/d4",
"rgb:00/d4/00",
"rgb:00/d4/2a",
"rgb:00/d4/55",
"rgb:00/d4/7f",
"rgb:00/d4/aa",
"rgb:00/d4/d4",
"rgb:2a/00/00",
"rgb:2a/00/2a",
"rgb:2a/00/55",
"rgb:2a/00/7f",
"rgb:2a/00/aa",
"rgb:2a/00/d4",
"rgb:2a/2a/00",
"rgb:2a/2a/2a",
"rgb:2a/2a/55",
"rgb:2a/2a/7f",
"rgb:2a/2a/aa",
"rgb:2a/2a/d4",
"rgb:2a/55/00",
"rgb:2a/55/2a",
"rgb:2a/55/55",
"rgb:2a/55/7f",
"rgb:2a/55/aa",
"rgb:2a/55/d4",
"rgb:2a/7f/00",
"rgb:2a/7f/2a",
"rgb:2a/7f/55",
"rgb:2a/7f/7f",
"rgb:2a/7f/aa",
"rgb:2a/7f/d4",
"rgb:2a/aa/00",
"rgb:2a/aa/2a",
"rgb:2a/aa/55",
"rgb:2a/aa/7f",
"rgb:2a/aa/aa",
"rgb:2a/aa/d4",
"rgb:2a/d4/00",
"rgb:2a/d4/2a",
"rgb:2a/d4/55",
"rgb:2a/d4/7f",
"rgb:2a/d4/aa",
"rgb:2a/d4/d4",
"rgb:55/00/00",
"rgb:55/00/2a",
"rgb:55/00/55",
"rgb:55/00/7f",
"rgb:55/00/aa",
"rgb:55/00/d4",
"rgb:55/2a/00",
"rgb:55/2a/2a",
"rgb:55/2a/55",
"rgb:55/2a/7f",
"rgb:55/2a/aa",
"rgb:55/2a/d4",
"rgb:55/55/00",
"rgb:55/55/2a",
"rgb:55/55/55",
"rgb:55/55/7f",
"rgb:55/55/aa",
"rgb:55/55/d4",
"rgb:55/7f/00",
"rgb:55/7f/2a",
"rgb:55/7f/55",
"rgb:55/7f/7f",
"rgb:55/7f/aa",
"rgb:55/7f/d4",
"rgb:55/aa/00",
"rgb:55/aa/2a",
"rgb:55/aa/55",
"rgb:55/aa/7f",
"rgb:55/aa/aa",
"rgb:55/aa/d4",
"rgb:55/d4/00",
"rgb:55/d4/2a",
"rgb:55/d4/55",
"rgb:55/d4/7f",
"rgb:55/d4/aa",
"rgb:55/d4/d4",
"rgb:7f/00/00",
"rgb:7f/00/2a",
"rgb:7f/00/55",
"rgb:7f/00/7f",
"rgb:7f/00/aa",
"rgb:7f/00/d4",
"rgb:7f/2a/00",
"rgb:7f/2a/2a",
"rgb:7f/2a/55",
"rgb:7f/2a/7f",
"rgb:7f/2a/aa",
"rgb:7f/2a/d4",
"rgb:7f/55/00",
"rgb:7f/55/2a",
"rgb:7f/55/55",
"rgb:7f/55/7f",
"rgb:7f/55/aa",
"rgb:7f/55/d4",
"rgb:7f/7f/00",
"rgb:7f/7f/2a",
"rgb:7f/7f/55",
"rgb:7f/7f/7f",
"rgb:7f/7f/aa",
"rgb:7f/7f/d4",
"rgb:7f/aa/00",
"rgb:7f/aa/2a",
"rgb:7f/aa/55",
"rgb:7f/aa/7f",
"rgb:7f/aa/aa",
"rgb:7f/aa/d4",
"rgb:7f/d4/00",
"rgb:7f/d4/2a",
"rgb:7f/d4/55",
"rgb:7f/d4/7f",
"rgb:7f/d4/aa",
"rgb:7f/d4/d4",
"rgb:aa/00/00",
"rgb:aa/00/2a",
"rgb:aa/00/55",
"rgb:aa/00/7f",
"rgb:aa/00/aa",
"rgb:aa/00/d4",
"rgb:aa/2a/00",
"rgb:aa/2a/2a",
"rgb:aa/2a/55",
"rgb:aa/2a/7f",
"rgb:aa/2a/aa",
"rgb:aa/2a/d4",
"rgb:aa/55/00",
"rgb:aa/55/2a",
"rgb:aa/55/55",
"rgb:aa/55/7f",
"rgb:aa/55/aa",
"rgb:aa/55/d4",
"rgb:aa/7f/00",
"rgb:aa/7f/2a",
"rgb:aa/7f/55",
"rgb:aa/7f/7f",
"rgb:aa/7f/aa",
"rgb:aa/7f/d4",
"rgb:aa/aa/00",
"rgb:aa/aa/2a",
"rgb:aa/aa/55",
"rgb:aa/aa/7f",
"rgb:aa/aa/aa",
"rgb:aa/aa/d4",
"rgb:aa/d4/00",
"rgb:aa/d4/2a",
"rgb:aa/d4/55",
"rgb:aa/d4/7f",
"rgb:aa/d4/aa",
"rgb:aa/d4/d4",
"rgb:d4/00/00",
"rgb:d4/00/2a",
"rgb:d4/00/55",
"rgb:d4/00/7f",
"rgb:d4/00/aa",
"rgb:d4/00/d4",
"rgb:d4/2a/00",
"rgb:d4/2a/2a",
"rgb:d4/2a/55",
"rgb:d4/2a/7f",
"rgb:d4/2a/aa",
"rgb:d4/2a/d4",
"rgb:d4/55/00",
"rgb:d4/55/2a",
"rgb:d4/55/55",
"rgb:d4/55/7f",
"rgb:d4/55/aa",
"rgb:d4/55/d4",
"rgb:d4/7f/00",
"rgb:d4/7f/2a",
"rgb:d4/7f/55",
"rgb:d4/7f/7f",
"rgb:d4/7f/aa",
"rgb:d4/7f/d4",
"rgb:d4/aa/00",
"rgb:d4/aa/2a",
"rgb:d4/aa/55",
"rgb:d4/aa/7f",
"rgb:d4/aa/aa",
"rgb:d4/aa/d4",
"rgb:d4/d4/00",
"rgb:d4/d4/2a",
"rgb:d4/d4/55",
"rgb:d4/d4/7f",
"rgb:d4/d4/aa",
"rgb:d4/d4/d4",
/* grayscale */
"rgb:08/08/08",
"rgb:12/12/12",
"rgb:1c/1c/1c",
"rgb:26/26/26",
"rgb:30/30/30",
"rgb:3a/3a/3a",
"rgb:44/44/44",
"rgb:4e/4e/4e",
"rgb:58/58/58",
"rgb:62/62/62",
"rgb:6c/6c/6c",
"rgb:76/76/76",
"rgb:80/80/80",
"rgb:8a/8a/8a",
"rgb:94/94/94",
"rgb:9e/9e/9e",
"rgb:a8/a8/a8",
"rgb:b2/b2/b2",
"rgb:bc/bc/bc",
"rgb:c6/c6/c6",
"rgb:d0/d0/d0",
"rgb:da/da/da",
"rgb:e4/e4/e4",
"rgb:ee/ee/ee",
/* fg/bg */
"rgb:aa/aa/aa", "rgb:0/0/0",
#ifndef NO_CURSORCOLOR
NULL, NULL, /* cursorColor, cursorColor2 */
#endif /* NO_CURSORCOLOR */
@ -1268,9 +1515,11 @@ process_xterm_seq(void)
if (ch) {
if (ch == '\t')
ch = ' '; /* translate '\t' to space */
else if (ch < ' ')
else if (ch < ' ') {
if (ch == 27 && (ch = cmd_getc()) == '\\') /* ESC \ (ST) is String Terminator in Xterm */
break;
return; /* control character - exit */
}
if (n < sizeof(string) - 1)
string[n++] = ch;
}
@ -1652,6 +1901,13 @@ process_sgr_mode(unsigned int nargs, int arg[])
case 37:
scr_color(minColor + (arg[i] - 30), RS_Bold);
break;
case 38:
if (arg[i+1] == 5) {
i += 2;
if (arg[i] >= 0 && arg[i] < 256)
scr_color(arg[i], RS_Bold);
}
break;
/* default fg */
case 39:
scr_color(restoreFG, RS_Bold);
@ -1668,6 +1924,13 @@ process_sgr_mode(unsigned int nargs, int arg[])
case 47:
scr_color(minColor + (arg[i] - 40), RS_Blink);
break;
case 48:
if (arg[i+1] == 5) {
i += 2;
if (arg[i] >= 0 && arg[i] < 256)
scr_color(arg[i], RS_Blink);
}
break;
/* default bg */
case 49:
scr_color(restoreBG, RS_Blink);
@ -1843,6 +2106,7 @@ append_to_icon_name(const char *str)
* 1 = change icon name
* 2 = change title
* 3 = set text property on window
* 4 = set any of 256 colors
* 46 = change logfile (not implemented)
* 50 = change font
*
@ -1861,6 +2125,7 @@ xterm_seq(int op, const char *str)
XColor xcol;
char *nstr, *tnstr, *valptr;
unsigned char eterm_seq_op;
unsigned int i;
XWMHints *wm_hints;
#ifdef PIXMAP_SUPPORT
@ -1894,6 +2159,17 @@ xterm_seq(int op, const char *str)
}
set_text_property(TermWin.parent, nstr, valptr);
break;
case ESCSEQ_XTERM_CHANGE_COLOR: /* Changing existing colors 256 */
while ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
i = (unsigned int) strtoul(nstr, (char **) NULL, 0);
nstr = (char *) strsep(&tnstr, ";");
if ((i < 256) && (nstr != NULL)) {
D_COLORS(("Changing color : [%d] -> %s\n", i, nstr));
set_window_color(i, nstr);
}
}
break;
case ESCSEQ_XTERM_TAKEOVER: /* 5 */
XSetInputFocus(Xdisplay, TermWin.parent, RevertToParent, CurrentTime);
XRaiseWindow(Xdisplay, TermWin.parent);

@ -63,6 +63,7 @@
# define ESCSEQ_XTERM_ICONNAME 1
# define ESCSEQ_XTERM_TITLE 2
# define ESCSEQ_XTERM_PROP 3
# define ESCSEQ_XTERM_CHANGE_COLOR 4
# define ESCSEQ_XTERM_FGCOLOR 10
# define ESCSEQ_XTERM_BGCOLOR 11
# define ESCSEQ_XTERM_CURSOR_COLOR 12
@ -84,13 +85,11 @@
# define ESCSEQ_XTERM_RESTOREFG 39 /* change default fg color */
# define ESCSEQ_XTERM_RESTOREBG 49 /* change default bg color */
# define restoreFG 39 /* restore default fg color */
# define restoreBG 49 /* restore default bg color */
# define restoreFG 512 /* restore default fg color */
# define restoreBG 513 /* restore default bg color */
enum color_list {
fgColor,
bgColor,
minColor, /* 2 */
enum ansi_color_list {
minColor, /* 0 */
BlackColor = minColor,
Red3Color,
Green3Color,
@ -110,6 +109,11 @@ enum color_list {
CyanColor,
maxBright, /* minBright + 7 */
WhiteColor = maxBright,
};
enum color_list { /* Extra colors */
fgColor = 256,
bgColor,
# ifndef NO_CURSORCOLOR
cursorColor,
cursorColor2,

@ -261,6 +261,7 @@ process_colors(void)
Pixel pixel;
for (i = 0; i < NRS_COLORS; i++) {
D_COLORS(("Adding color %d of %d (%s)\n",i,NRS_COLORS,def_colorName[i]));
if ((Xdepth <= 2) || ((pixel = get_color_by_name(rs_color[i], def_colorName[i])) == (Pixel) (-1))) {
switch (i) {
case fgColor:
@ -304,6 +305,7 @@ process_colors(void)
break;
}
}
D_COLORS(("Pixel : %x\n",pixel));
PixColors[i] = pixel;
}
@ -677,7 +679,7 @@ stored_palette(char op)
{
static Pixel default_colors[NRS_COLORS + EXTRA_COLORS];
static unsigned char stored = 0;
unsigned char i;
unsigned int i;
if (op == SAVE) {
for (i = 0; i < NRS_COLORS; i++) {
@ -719,6 +721,9 @@ set_window_color(int idx, const char *color)
print_warning("Unable to allocate \"%s\" in the color map.\n", color);
return;
}
if ((idx > maxBright) && (idx < 256) && (PixColors[idx])) {
XFreeColors(Xdisplay, cmap, (unsigned long *) &(PixColors[idx]), 1, 0);
}
PixColors[idx] = xcol.pixel;
} else {
print_warning("Unable to resolve \"%s\" as a color name.\n", color);

@ -14,63 +14,64 @@ echo "you have configured. You may need to widen your terminal to see it proper
echo
echo "FG BG"
echo "-- --"
echo " 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"
echo " 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15"
fgstyle=""
for fg in 0 1 2 3 4 5 6 7 ; do
line=" $fg "
case $fg in
0) fg_esc=30 ;;
1) fg_esc=31 ;;
2) fg_esc=32 ;;
3) fg_esc=33 ;;
4) fg_esc=34 ;;
5) fg_esc=35 ;;
6) fg_esc=36 ;;
7) fg_esc=37 ;;
esac
for bgstyle in "" ";5"; do
for bg in 0 1 2 3 4 5 6 7 ; do
case $bg in
0) bg_esc=40 ;;
1) bg_esc=41 ;;
2) bg_esc=42 ;;
3) bg_esc=43 ;;
4) bg_esc=44 ;;
5) bg_esc=45 ;;
6) bg_esc=46 ;;
7) bg_esc=47 ;;
esac
line="${line}[${fg_esc};${bg_esc}${fgstyle}${bgstyle}m txt "
for fg in 00 01 02 03 04 05 06 07 ; do
line="$fg "
case $fg in
00) fg_esc=30 ;;
01) fg_esc=31 ;;
02) fg_esc=32 ;;
03) fg_esc=33 ;;
04) fg_esc=34 ;;
05) fg_esc=35 ;;
06) fg_esc=36 ;;
07) fg_esc=37 ;;
esac
for bgstyle in "" ";5"; do
for bg in 00 01 02 03 04 05 06 07 ; do
case $bg in
00) bg_esc=40 ;;
01) bg_esc=41 ;;
02) bg_esc=42 ;;
03) bg_esc=43 ;;
04) bg_esc=44 ;;
05) bg_esc=45 ;;
06) bg_esc=46 ;;
07) bg_esc=47 ;;
esac
line="${line}[${fg_esc};${bg_esc}${fgstyle}${bgstyle}m @@ "
done
done
done
echo "$line"
echo "$line"
done
fgstyle=";1"
for fg in 8 9 10 11 12 13 14 15 ; do
case $fg in
8) fg_esc=30; line=" $fg " ;;
9) fg_esc=31; line=" $fg " ;;
10) fg_esc=32; line="$fg " ;;
11) fg_esc=33; line="$fg " ;;
12) fg_esc=34; line="$fg " ;;
13) fg_esc=35; line="$fg " ;;
14) fg_esc=36; line="$fg " ;;
15) fg_esc=37; line="$fg " ;;
esac
for bgstyle in "" ";5"; do
for bg in 0 1 2 3 4 5 6 7 ; do
case $bg in
0) bg_esc=40 ;;
1) bg_esc=41 ;;
2) bg_esc=42 ;;
3) bg_esc=43 ;;
4) bg_esc=44 ;;
5) bg_esc=45 ;;
6) bg_esc=46 ;;
7) bg_esc=47 ;;
esac
line="${line}[${fg_esc};${bg_esc}${fgstyle}${bgstyle}m txt "
for fg in 08 09 10 11 12 13 14 15 ; do
line="$fg "
case $fg in
08) fg_esc=30 ;;
09) fg_esc=31 ;;
10) fg_esc=32 ;;
11) fg_esc=33 ;;
12) fg_esc=34 ;;
13) fg_esc=35 ;;
14) fg_esc=36 ;;
15) fg_esc=37 ;;
esac
for bgstyle in "" ";5"; do
for bg in 0 1 2 3 4 5 6 7 ; do
case $bg in
0) bg_esc=40 ;;
1) bg_esc=41 ;;
2) bg_esc=42 ;;
3) bg_esc=43 ;;
4) bg_esc=44 ;;
5) bg_esc=45 ;;
6) bg_esc=46 ;;
7) bg_esc=47 ;;
esac
line="${line}[${fg_esc};${bg_esc}${fgstyle}${bgstyle}m @@ "
done
done
done
echo "$line"
echo "$line"
done

@ -0,0 +1,33 @@
#!/usr/bin/perl
# Built from
# Author: Todd Larason <jtl@molehill.org>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.1 1999/07/11 08:49:54 dawes Exp $
# adapted to the special needs for Eterm by Fredrik Svensson <fred@ludd.ltu.se>
$redmax = 1;
$greenmax = 1;
$bluemax = 2*3*2*3*2*3;
# adjust if 255 color should be included use adj = 1. Not possible if any maxvalue is 1.
$adj = 0;
# colors 16-231 are a 6x6x6 color cube
for ($red = 0; $red < $redmax; $red++) {
for ($green = 0; $green < $greenmax; $green++) {
for ($blue = 0; $blue < $bluemax; $blue++) {
printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\",
16 + ($red * $greenmax * $bluemax) + ($green * $bluemax) + $blue,
int ($red * 255 / ($redmax - $adj) ),
int ($green * 255 / ($greenmax - $adj)),
int ($blue * 255 / ($bluemax - $adj )));
}
}
}
# colors 232-255 are a grayscale ramp, intentionally leaving out
# black and white
for ($gray = 0; $gray < 24; $gray++) {
$level = ($gray * 10) + 8;
printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\",
232 + $gray, $level, $level, $level);
}

@ -0,0 +1,31 @@
#!/usr/bin/perl
# Built from
# Author: Todd Larason <jtl@molehill.org>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.1 1999/07/11 08:49:54 dawes Exp $
# adapted to the special needs for Eterm by Fredrik Svensson <fred@ludd.ltu.se>
$redmax = 2*3;
$greenmax = 2*3;
$bluemax = 2*3;
$adj = 0;
# colors 16-231 are a 6x6x6 color cube
for ($red = 0; $red < $redmax; $red++) {
for ($green = 0; $green < $greenmax; $green++) {
for ($blue = 0; $blue < $bluemax; $blue++) {
printf(" \"rgb:%2.2x/%2.2x/%2.2x\",\n",
int ($red * 255 / ($redmax - $adj) ),
int ($green * 255 / ($greenmax - $adj)),
int ($blue * 255 / ($bluemax - $adj )));
}
}
}
# colors 232-255 are a grayscale ramp, intentionally leaving out
# black and white
for ($gray = 0; $gray < 24; $gray++) {
$level = ($gray * 10) + 8;
printf(" \"rgb:%2.2x/%2.2x/%2.2x\",\n",
$level, $level, $level);
}

@ -0,0 +1,45 @@
#!/usr/bin/perl
# Based on a script by
# Author: Todd Larason <jtl@molehill.org>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.1 1999/07/11 08:49:54 dawes Exp $
# adapted to the special needs for Eterm by Fredrik Svensson <fred@ludd.ltu.se>
# display the colors
# first the system ones:
print "System colors:\n";
for ($color = 0; $color < 8; $color++) {
print "\x1b[48;5;${color}m ";
}
print "\x1b[0m\n";
for ($color = 8; $color < 16; $color++) {
print "\x1b[48;5;${color}m ";
}
print "\x1b[0m\n\n";
# now the color cube
print "Color cube, 6x6x6:\n";
for ($green = 0; $green < 6; $green++) {
for ($red = 0; $red < 6; $red++) {
for ($blue = 0; $blue < 6; $blue++) {
$color = 16 + ($red * 36) + ($green * 6) + $blue;
print "\x1b[48;5;${color}m ";
}
print "\x1b[0m ";
}
print "\n";
}
# now the grayscale ramp
print "Grayscale ramp:\n";
for ($color = 232; $color < 256; $color++) {
print "\x1b[48;5;${color}m ";
}
print "\x1b[0m\n";
print "Eterm special colors:\n";
for ($color = 256; $color < 294; $color++) {
print "\x1b[48;5;${color}m ";
}
print "\x1b[0m\n";
Loading…
Cancel
Save