diff -ru ../y/configure.ac ./configure.ac
--- ../y/configure.ac	2009-07-05 11:46:56.000000000 +1000
+++ ./configure.ac	2009-07-05 11:47:04.000000000 +1000
@@ -90,6 +90,7 @@
 support_mousewheel=yes
 support_mouseslipwheel=yes
 support_text_blink=yes
+support_xterm_colors=88
 support_pointer_blank=yes
 support_scroll_rxvt=yes
 support_scroll_next=yes
@@ -124,6 +125,7 @@
        support_mousewheel=no
        support_mouseslipwheel=no
        support_text_blink=no
+       support_xterm_colors=no
        support_pointer_blank=no
        support_scroll_rxvt=no
        support_scroll_next=no
@@ -152,6 +154,7 @@
        support_mousewheel=yes
        support_mouseslipwheel=yes
        support_text_blink=yes
+       support_xterm_colors=88
        support_pointer_blank=yes
        support_scroll_rxvt=yes
        support_scroll_next=yes
@@ -388,6 +391,12 @@
     support_text_blink=$enableval
   fi])
 
+AC_ARG_ENABLE(xterm-colors,
+  [  --enable-xterm-colors     enable Xterm 88 or 256 color model],
+  [if test x$enableval = x88 -o x$enableval = x256 -o x$enableval = xno; then
+    support_xterm_colors=$enableval
+  fi])
+
 AC_ARG_ENABLE(pointer-blank,
   [  --enable-pointer-blank  enable pointer blank when typing or inactive pointer],
   [if test x$enableval = xyes -o x$enableval = xno; then
@@ -660,6 +669,9 @@
 if test x$support_text_blink = xyes; then
   AC_DEFINE(TEXT_BLINK, 1, Define if you want blinking text support)
 fi
+if test x$support_xterm_colors = x88 -o x$support_xterm_colors = x256; then
+  AC_DEFINE_UNQUOTED(XTERM_COLORS, $support_xterm_colors, Set to 88 or 256 depending on Xterm color cube you want)
+fi
 if test x$support_unicode3 = xyes; then
   AC_DEFINE(UNICODE_3, 1, Define if you want to represent unicode characters outside plane 0)
 fi
@@ -761,6 +773,9 @@
 if test x$terminfo != x; then
   echo "  set TERMINFO to:            $terminfo"
 fi
+if test x$support_xterm_colors != xno; then
+  echo "  Xterm color cube:           $support_xterm_colors"
+fi
 echo "  default resource name:      $RESNAME"
 echo "  resource class:             $RESCLASS"
 if test x$RESFALLBACK != x; then
diff -ru ../y/src/feature.h ./src/feature.h
--- ../y/src/feature.h	2009-07-05 11:46:56.000000000 +1000
+++ ./src/feature.h	2009-07-05 11:47:04.000000000 +1000
@@ -34,6 +34,8 @@
 # define XAPPLOADDIRLOCALE	X11LIBDIR "/%s/app-defaults"
 #endif
 
+#include "../config.h"
+
 /*-------------------------------SECURITY-------------------------------*/
 
 /*
@@ -78,7 +80,9 @@
 /*
  * Make colours match xterm colours instead of `traditional' rxvt colours
  */
-#define XTERM_COLORS
+#ifndef XTERM_COLORS
+#define XTERM_COLORS 256
+#endif
 
 /*
  * Disable separate colours for bold, underline and reverse video
diff -ru ../y/src/init.C ./src/init.C
--- ../y/src/init.C	2009-07-05 11:46:56.000000000 +1000
+++ ./src/init.C	2009-07-05 11:47:04.000000000 +1000
@@ -176,6 +176,7 @@
     "rgb:00/ff/ff",             // 6/14: bright cyan    (Cyan)
     "rgb:ff/ff/ff",             // 7/15: bright white   (White)
 
+#if XTERM_COLORS == 88
     // 88 xterm colours
     "rgb:00/00/00",
     "rgb:00/00/8b",
@@ -249,6 +250,251 @@
     "rgb:b9/b9/b9",
     "rgb:d0/d0/d0",
     "rgb:e7/e7/e7",
+#elif XTERM_COLORS == 256
+    // 256 xterm colours
+    "rgb:00/00/00",
+    "rgb:00/00/5f",
+    "rgb:00/00/87",
+    "rgb:00/00/af",
+    "rgb:00/00/d7",
+    "rgb:00/00/ff",
+    "rgb:00/5f/00",
+    "rgb:00/5f/5f",
+    "rgb:00/5f/87",
+    "rgb:00/5f/af",
+    "rgb:00/5f/d7",
+    "rgb:00/5f/ff",
+    "rgb:00/87/00",
+    "rgb:00/87/5f",
+    "rgb:00/87/87",
+    "rgb:00/87/af",
+    "rgb:00/87/d7",
+    "rgb:00/87/ff",
+    "rgb:00/af/00",
+    "rgb:00/af/5f",
+    "rgb:00/af/87",
+    "rgb:00/af/af",
+    "rgb:00/af/d7",
+    "rgb:00/af/ff",
+    "rgb:00/d7/00",
+    "rgb:00/d7/5f",
+    "rgb:00/d7/87",
+    "rgb:00/d7/af",
+    "rgb:00/d7/d7",
+    "rgb:00/d7/ff",
+    "rgb:00/ff/00",
+    "rgb:00/ff/5f",
+    "rgb:00/ff/87",
+    "rgb:00/ff/af",
+    "rgb:00/ff/d7",
+    "rgb:00/ff/ff",
+    "rgb:5f/00/00",
+    "rgb:5f/00/5f",
+    "rgb:5f/00/87",
+    "rgb:5f/00/af",
+    "rgb:5f/00/d7",
+    "rgb:5f/00/ff",
+    "rgb:5f/5f/00",
+    "rgb:5f/5f/5f",
+    "rgb:5f/5f/87",
+    "rgb:5f/5f/af",
+    "rgb:5f/5f/d7",
+    "rgb:5f/5f/ff",
+    "rgb:5f/87/00",
+    "rgb:5f/87/5f",
+    "rgb:5f/87/87",
+    "rgb:5f/87/af",
+    "rgb:5f/87/d7",
+    "rgb:5f/87/ff",
+    "rgb:5f/af/00",
+    "rgb:5f/af/5f",
+    "rgb:5f/af/87",
+    "rgb:5f/af/af",
+    "rgb:5f/af/d7",
+    "rgb:5f/af/ff",
+    "rgb:5f/d7/00",
+    "rgb:5f/d7/5f",
+    "rgb:5f/d7/87",
+    "rgb:5f/d7/af",
+    "rgb:5f/d7/d7",
+    "rgb:5f/d7/ff",
+    "rgb:5f/ff/00",
+    "rgb:5f/ff/5f",
+    "rgb:5f/ff/87",
+    "rgb:5f/ff/af",
+    "rgb:5f/ff/d7",
+    "rgb:5f/ff/ff",
+    "rgb:87/00/00",
+    "rgb:87/00/5f",
+    "rgb:87/00/87",
+    "rgb:87/00/af",
+    "rgb:87/00/d7",
+    "rgb:87/00/ff",
+    "rgb:87/5f/00",
+    "rgb:87/5f/5f",
+    "rgb:87/5f/87",
+    "rgb:87/5f/af",
+    "rgb:87/5f/d7",
+    "rgb:87/5f/ff",
+    "rgb:87/87/00",
+    "rgb:87/87/5f",
+    "rgb:87/87/87",
+    "rgb:87/87/af",
+    "rgb:87/87/d7",
+    "rgb:87/87/ff",
+    "rgb:87/af/00",
+    "rgb:87/af/5f",
+    "rgb:87/af/87",
+    "rgb:87/af/af",
+    "rgb:87/af/d7",
+    "rgb:87/af/ff",
+    "rgb:87/d7/00",
+    "rgb:87/d7/5f",
+    "rgb:87/d7/87",
+    "rgb:87/d7/af",
+    "rgb:87/d7/d7",
+    "rgb:87/d7/ff",
+    "rgb:87/ff/00",
+    "rgb:87/ff/5f",
+    "rgb:87/ff/87",
+    "rgb:87/ff/af",
+    "rgb:87/ff/d7",
+    "rgb:87/ff/ff",
+    "rgb:af/00/00",
+    "rgb:af/00/5f",
+    "rgb:af/00/87",
+    "rgb:af/00/af",
+    "rgb:af/00/d7",
+    "rgb:af/00/ff",
+    "rgb:af/5f/00",
+    "rgb:af/5f/5f",
+    "rgb:af/5f/87",
+    "rgb:af/5f/af",
+    "rgb:af/5f/d7",
+    "rgb:af/5f/ff",
+    "rgb:af/87/00",
+    "rgb:af/87/5f",
+    "rgb:af/87/87",
+    "rgb:af/87/af",
+    "rgb:af/87/d7",
+    "rgb:af/87/ff",
+    "rgb:af/af/00",
+    "rgb:af/af/5f",
+    "rgb:af/af/87",
+    "rgb:af/af/af",
+    "rgb:af/af/d7",
+    "rgb:af/af/ff",
+    "rgb:af/d7/00",
+    "rgb:af/d7/5f",
+    "rgb:af/d7/87",
+    "rgb:af/d7/af",
+    "rgb:af/d7/d7",
+    "rgb:af/d7/ff",
+    "rgb:af/ff/00",
+    "rgb:af/ff/5f",
+    "rgb:af/ff/87",
+    "rgb:af/ff/af",
+    "rgb:af/ff/d7",
+    "rgb:af/ff/ff",
+    "rgb:d7/00/00",
+    "rgb:d7/00/5f",
+    "rgb:d7/00/87",
+    "rgb:d7/00/af",
+    "rgb:d7/00/d7",
+    "rgb:d7/00/ff",
+    "rgb:d7/5f/00",
+    "rgb:d7/5f/5f",
+    "rgb:d7/5f/87",
+    "rgb:d7/5f/af",
+    "rgb:d7/5f/d7",
+    "rgb:d7/5f/ff",
+    "rgb:d7/87/00",
+    "rgb:d7/87/5f",
+    "rgb:d7/87/87",
+    "rgb:d7/87/af",
+    "rgb:d7/87/d7",
+    "rgb:d7/87/ff",
+    "rgb:d7/af/00",
+    "rgb:d7/af/5f",
+    "rgb:d7/af/87",
+    "rgb:d7/af/af",
+    "rgb:d7/af/d7",
+    "rgb:d7/af/ff",
+    "rgb:d7/d7/00",
+    "rgb:d7/d7/5f",
+    "rgb:d7/d7/87",
+    "rgb:d7/d7/af",
+    "rgb:d7/d7/d7",
+    "rgb:d7/d7/ff",
+    "rgb:d7/ff/00",
+    "rgb:d7/ff/5f",
+    "rgb:d7/ff/87",
+    "rgb:d7/ff/af",
+    "rgb:d7/ff/d7",
+    "rgb:d7/ff/ff",
+    "rgb:ff/00/00",
+    "rgb:ff/00/5f",
+    "rgb:ff/00/87",
+    "rgb:ff/00/af",
+    "rgb:ff/00/d7",
+    "rgb:ff/00/ff",
+    "rgb:ff/5f/00",
+    "rgb:ff/5f/5f",
+    "rgb:ff/5f/87",
+    "rgb:ff/5f/af",
+    "rgb:ff/5f/d7",
+    "rgb:ff/5f/ff",
+    "rgb:ff/87/00",
+    "rgb:ff/87/5f",
+    "rgb:ff/87/87",
+    "rgb:ff/87/af",
+    "rgb:ff/87/d7",
+    "rgb:ff/87/ff",
+    "rgb:ff/af/00",
+    "rgb:ff/af/5f",
+    "rgb:ff/af/87",
+    "rgb:ff/af/af",
+    "rgb:ff/af/d7",
+    "rgb:ff/af/ff",
+    "rgb:ff/d7/00",
+    "rgb:ff/d7/5f",
+    "rgb:ff/d7/87",
+    "rgb:ff/d7/af",
+    "rgb:ff/d7/d7",
+    "rgb:ff/d7/ff",
+    "rgb:ff/ff/00",
+    "rgb:ff/ff/5f",
+    "rgb:ff/ff/87",
+    "rgb:ff/ff/af",
+    "rgb:ff/ff/d7",
+    "rgb:ff/ff/ff",
+    "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",
+#else
+#error XTERM_COLORS needs to be set to 88 or 256
+#endif
 
 #ifndef NO_CURSORCOLOR
     COLOR_CURSOR_BACKGROUND,
diff -ru ../y/src/rxvt.h ./src/rxvt.h
--- ../y/src/rxvt.h	2009-07-05 11:46:56.000000000 +1000
+++ ./src/rxvt.h	2009-07-05 11:47:04.000000000 +1000
@@ -312,24 +312,46 @@
 
 #define RS_None                 0
 
+#if !defined(XTERM_COLORS) || XTERM_COLORS == 88
 #define RS_fgMask               0x0000007fUL    // 128 colors
 #define RS_bgMask               0x00003f80UL    // 128 colors
+#elif XTERM_COLORS == 256
+#define RS_fgMask               0x000001ffUL    // 512 colors
+#define RS_bgMask               0x0003fe00UL    // 512 colors
+#endif
 
 // font styles
+#if !defined(XTERM_COLORS) || XTERM_COLORS == 88
 #define RS_Bold                 0x00004000UL    // value 1
 #define RS_Italic		0x00008000UL    // value 2
+#elif XTERM_COLORS == 256
+#define RS_Bold                 0x00040000UL    // value 1
+#define RS_Italic		0x00080000UL    // value 2
+#endif
 
 // fake styles
+#if !defined(XTERM_COLORS) || XTERM_COLORS == 88
 #define RS_Blink                0x00010000UL    // blink
 #define RS_RVid                 0x00020000UL    // reverse video
 #define RS_Uline                0x00040000UL    // underline
+#elif XTERM_COLORS == 256
+#define RS_Blink                0x00100000UL    // blink	 (disabled)
+#define RS_RVid                 0x00200000UL    // reverse video (disabled)
+#define RS_Uline                0x00400000UL    // underline
+#endif
+
 
 // toggle this to force redraw, must be != RS_Careful
 #define RS_redraw               0x01000000UL
 
+#if !defined(XTERM_COLORS) || XTERM_COLORS == 88
 // 5 custom bits for extensions
 #define RS_customCount          32
 #define RS_customMask           0x00f80000UL
+#elif XTERM_COLORS == 256
+#define RS_customCount          0
+#define RS_customMask           0x00000000UL
+#endif
 #define RS_customShift          19
 
 // other flags
@@ -337,7 +359,11 @@
 
 #define RS_styleCount		4
 #define RS_styleMask		(RS_Bold | RS_Italic)
+#if !defined(XTERM_COLORS) || XTERM_COLORS == 88
 #define RS_styleShift		14
+#elif XTERM_COLORS == 256
+#define RS_styleShift		18
+#endif
 
 #define RS_baseattrMask         (RS_Italic | RS_Bold | RS_Blink | RS_RVid | RS_Uline)
 #define RS_attrMask             (RS_baseattrMask | RS_fontMask)
@@ -463,7 +489,13 @@
   Color_White = maxCOLOR,
 #endif
   minTermCOLOR = Color_White + 1,
+#if !defined(XTERM_COLORS) || XTERM_COLORS == 88
   maxTermCOLOR = Color_White + 72,
+#elif (XTERM_COLORS == 256)
+  maxTermCOLOR = Color_White + 240,
+#else
+#error XTERM_COLORS needs to be set to 88 or 256
+#endif
 #ifndef NO_CURSORCOLOR
   Color_cursor,
   Color_cursor2,
@@ -503,7 +535,11 @@
 #endif
 };
 
+#if !defined(XTERM_COLORS) || XTERM_COLORS == 88
 #define Color_Bits      7 // 0 .. maxTermCOLOR
+#elif XTERM_COLORS == 256
+#define Color_Bits      9 // 0 .. maxTermCOLOR
+#endif
 
 /*
  * Resource list
