@ -179,8 +179,8 @@ typedef unsigned long ulong;
typedef unsigned short ushort ;
typedef unsigned short ushort ;
typedef XftDraw * Draw ;
typedef XftDraw * Draw ;
typedef XftColor Colo u r;
typedef XftColor Colo r;
typedef Colormap Colo u rmap;
typedef Colormap Colo rmap;
typedef struct {
typedef struct {
char c [ UTF_SIZ ] ; /* character code */
char c [ UTF_SIZ ] ; /* character code */
@ -241,7 +241,7 @@ typedef struct {
/* Purely graphic info */
/* Purely graphic info */
typedef struct {
typedef struct {
Display * dpy ;
Display * dpy ;
Colo u rmap cmap ;
Colo rmap cmap ;
Window win ;
Window win ;
Drawable buf ;
Drawable buf ;
Atom xembed , wmdeletewin , netwmname , netwmpid ;
Atom xembed , wmdeletewin , netwmname , netwmpid ;
@ -340,7 +340,7 @@ typedef struct {
/* Drawing Context */
/* Drawing Context */
typedef struct {
typedef struct {
Colo u r col [ MAX ( LEN ( colorname ) , 256 ) ] ;
Colo r col [ MAX ( LEN ( colorname ) , 256 ) ] ;
Font font , bfont , ifont , ibfont ;
Font font , bfont , ifont , ibfont ;
GC gc ;
GC gc ;
} DC ;
} DC ;
@ -1631,7 +1631,7 @@ tdefcolor(int *attr, int *npar, int l) {
uint r , g , b ;
uint r , g , b ;
switch ( attr [ * npar + 1 ] ) {
switch ( attr [ * npar + 1 ] ) {
case 2 : /* direct colo u r in RGB space */
case 2 : /* direct colo r in RGB space */
if ( * npar + 4 > = l ) {
if ( * npar + 4 > = l ) {
fprintf ( stderr ,
fprintf ( stderr ,
" erresc(38): Incorrect number of parameters (%d) \n " ,
" erresc(38): Incorrect number of parameters (%d) \n " ,
@ -1648,7 +1648,7 @@ tdefcolor(int *attr, int *npar, int l) {
else
else
idx = TRUECOLOR ( r , g , b ) ;
idx = TRUECOLOR ( r , g , b ) ;
break ;
break ;
case 5 : /* indexed colo u r */
case 5 : /* indexed colo r */
if ( * npar + 2 > = l ) {
if ( * npar + 2 > = l ) {
fprintf ( stderr ,
fprintf ( stderr ,
" erresc(38): Incorrect number of parameters (%d) \n " ,
" erresc(38): Incorrect number of parameters (%d) \n " ,
@ -1663,8 +1663,8 @@ tdefcolor(int *attr, int *npar, int l) {
break ;
break ;
case 0 : /* implemented defined (only foreground) */
case 0 : /* implemented defined (only foreground) */
case 1 : /* transparent */
case 1 : /* transparent */
case 3 : /* direct colo u r in CMY space */
case 3 : /* direct colo r in CMY space */
case 4 : /* direct colo u r in CMYK space */
case 4 : /* direct colo r in CMYK space */
default :
default :
fprintf ( stderr ,
fprintf ( stderr ,
" erresc(38): gfx attr %d unknown \n " , attr [ * npar ] ) ;
" erresc(38): gfx attr %d unknown \n " , attr [ * npar ] ) ;
@ -2151,7 +2151,7 @@ strhandle(void) {
/* FALLTHROUGH */
/* FALLTHROUGH */
case 104 : /* color reset, here p = NULL */
case 104 : /* color reset, here p = NULL */
j = ( narg > 1 ) ? atoi ( strescseq . args [ 1 ] ) : - 1 ;
j = ( narg > 1 ) ? atoi ( strescseq . args [ 1 ] ) : - 1 ;
if ( ! xsetcolorname ( j , p ) ) {
if ( xsetcolorname ( j , p ) ) {
fprintf ( stderr , " erresc: invalid color %s \n " , p ) ;
fprintf ( stderr , " erresc: invalid color %s \n " , p ) ;
} else {
} else {
/*
/*
@ -2720,14 +2720,14 @@ xloadcols(void) {
int i ;
int i ;
XRenderColor color = { . alpha = 0xffff } ;
XRenderColor color = { . alpha = 0xffff } ;
static bool loaded ;
static bool loaded ;
Colo u r * cp ;
Colo r * cp ;
if ( loaded ) {
if ( loaded ) {
for ( cp = dc . col ; cp < dc . col + LEN ( dc . col ) ; + + cp )
for ( cp = dc . col ; cp < dc . col + LEN ( dc . col ) ; + + cp )
XftColorFree ( xw . dpy , xw . vis , xw . cmap , cp ) ;
XftColorFree ( xw . dpy , xw . vis , xw . cmap , cp ) ;
}
}
/* load colo u rs [0-15] and [256-LEN(colorname)] (config.h) */
/* load colo rs [0-15] and [256-LEN(colorname)] (config.h) */
for ( i = 0 ; i < LEN ( colorname ) ; i + + ) {
for ( i = 0 ; i < LEN ( colorname ) ; i + + ) {
if ( ! colorname [ i ] )
if ( ! colorname [ i ] )
continue ;
continue ;
@ -2736,7 +2736,7 @@ xloadcols(void) {
}
}
}
}
/* load colo u rs [16-231] ; same colou rs as xterm */
/* load colo rs [16-231] ; same colors as xterm */
for ( i = 16 ; i < 6 * 6 * 6 + 16 ; i + + ) {
for ( i = 16 ; i < 6 * 6 * 6 + 16 ; i + + ) {
color . red = sixd_to_16bit ( ( ( i - 16 ) / 36 ) % 6 ) ;
color . red = sixd_to_16bit ( ( ( i - 16 ) / 36 ) % 6 ) ;
color . green = sixd_to_16bit ( ( ( i - 16 ) / 6 ) % 6 ) ;
color . green = sixd_to_16bit ( ( ( i - 16 ) / 6 ) % 6 ) ;
@ -2745,7 +2745,7 @@ xloadcols(void) {
die ( " Could not allocate color %d \n " , i ) ;
die ( " Could not allocate color %d \n " , i ) ;
}
}
/* load colo u rs [232-255] ; grayscale */
/* load colo rs [232-255] ; grayscale */
for ( ; i < 256 ; i + + ) {
for ( ; i < 256 ; i + + ) {
color . red = color . green = color . blue = 0x0808 + 0x0a0a * ( i - ( 6 * 6 * 6 + 16 ) ) ;
color . red = color . green = color . blue = 0x0808 + 0x0a0a * ( i - ( 6 * 6 * 6 + 16 ) ) ;
if ( ! XftColorAllocValue ( xw . dpy , xw . vis , xw . cmap , & color , & dc . col [ i ] ) )
if ( ! XftColorAllocValue ( xw . dpy , xw . vis , xw . cmap , & color , & dc . col [ i ] ) )
@ -2757,33 +2757,45 @@ xloadcols(void) {
int
int
xsetcolorname ( int x , const char * name ) {
xsetcolorname ( int x , const char * name ) {
XRenderColor color = { . alpha = 0xffff } ;
XRenderColor color = { . alpha = 0xffff } ;
Colour colour ;
Color ncolor ;
if ( ! BETWEEN ( x , 0 , LEN ( colorname ) ) )
if ( ! BETWEEN ( x , 0 , LEN ( colorname ) ) )
return - 1 ;
return 1 ;
if ( ! name ) {
if ( ! name ) {
if ( BETWEEN ( x , 16 , 16 + 215 ) ) {
if ( BETWEEN ( x , 16 , 16 + 215 ) ) { /* 256 color */
int r = ( x - 16 ) / 36 , g = ( ( x - 16 ) % 36 ) / 6 , b = ( x - 16 ) % 6 ;
color . red = sixd_to_16bit ( ( ( x - 16 ) / 36 ) % 6 ) ;
color . red = sixd_to_16bit ( r ) ;
color . green = sixd_to_16bit ( ( ( x - 16 ) / 6 ) % 6 ) ;
color . green = sixd_to_16bit ( g ) ;
color . blue = sixd_to_16bit ( ( ( x - 16 ) / 1 ) % 6 ) ;
color . blue = sixd_to_16bit ( b ) ;
if ( ! XftColorAllocValue ( xw . dpy , xw . vis ,
if ( ! XftColorAllocValue ( xw . dpy , xw . vis , xw . cmap , & color , & colour ) )
xw . cmap , & color , & ncolor ) ) {
return 0 ; /* something went wrong */
return 1 ;
dc . col [ x ] = colour ;
}
return 1 ;
} else if ( BETWEEN ( x , 16 + 216 , 255 ) ) {
XftColorFree ( xw . dpy , xw . vis , xw . cmap , & dc . col [ x ] ) ;
color . red = color . green = color . blue = 0x0808 + 0x0a0a * ( x - ( 16 + 216 ) ) ;
dc . col [ x ] = ncolor ;
if ( ! XftColorAllocValue ( xw . dpy , xw . vis , xw . cmap , & color , & colour ) )
return 0 ;
return 0 ; /* something went wrong */
} else if ( BETWEEN ( x , 16 + 216 , 255 ) ) { /* greyscale */
dc . col [ x ] = colour ;
color . red = color . green = color . blue = \
return 1 ;
0x0808 + 0x0a0a * ( x - ( 16 + 216 ) ) ;
} else {
if ( ! XftColorAllocValue ( xw . dpy , xw . vis ,
xw . cmap , & color , & ncolor ) ) {
return 1 ;
}
XftColorFree ( xw . dpy , xw . vis , xw . cmap , & dc . col [ x ] ) ;
dc . col [ x ] = ncolor ;
return 0 ;
} else { /* system colors */
name = colorname [ x ] ;
name = colorname [ x ] ;
}
}
}
}
if ( ! XftColorAllocName ( xw . dpy , xw . vis , xw . cmap , name , & colour ) )
if ( ! XftColorAllocName ( xw . dpy , xw . vis , xw . cmap , name , & ncolor ) )
return 0 ;
return 1 ;
dc . col [ x ] = colour ;
return 1 ;
XftColorFree ( xw . dpy , xw . vis , xw . cmap , & dc . col [ x ] ) ;
dc . col [ x ] = ncolor ;
return 0 ;
}
}
void
void
@ -3099,7 +3111,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
FcPattern * fcpattern , * fontpattern ;
FcPattern * fcpattern , * fontpattern ;
FcFontSet * fcsets [ ] = { NULL } ;
FcFontSet * fcsets [ ] = { NULL } ;
FcCharSet * fccharset ;
FcCharSet * fccharset ;
Colo u r * fg , * bg , * temp , revfg , revbg , truefg , truebg ;
Colo r * fg , * bg , * temp , revfg , revbg , truefg , truebg ;
XRenderColor colfg , colbg ;
XRenderColor colfg , colbg ;
XRectangle r ;
XRectangle r ;
int oneatatime ;
int oneatatime ;
@ -3145,8 +3157,8 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
if ( base . mode & ATTR_BOLD ) {
if ( base . mode & ATTR_BOLD ) {
/*
/*
* change basic system colo u rs [ 0 - 7 ]
* change basic system colo rs [ 0 - 7 ]
* to bright system colo u rs [ 8 - 15 ]
* to bright system colo rs [ 8 - 15 ]
*/
*/
if ( BETWEEN ( base . fg , 0 , 7 ) )
if ( BETWEEN ( base . fg , 0 , 7 ) )
fg = & dc . col [ base . fg + 8 ] ;
fg = & dc . col [ base . fg + 8 ] ;