diff -u -r -d xwpe-1.5.21a/WeXterm.c xwpe-1.5.21.shaded/WeXterm.c --- xwpe-1.5.21a/WeXterm.c Fri Nov 19 04:06:05 1999 +++ xwpe-1.5.21.shaded/WeXterm.c Wed Nov 24 17:00:41 1999 @@ -49,8 +49,8 @@ "Red3", "Violet Red", "Brown", - "Light Gray", - "Dark Slate Grey", + "SlateGrey", + "DarkSlateGrey", "Blue", "Green", "Turquoise1", @@ -60,6 +60,26 @@ "White" }; +/* Standard background colors (after initialization pointers may not be valid) */ +static char *WpeXColorNamesBg[16] = { + "Black", + "RoyalBlue4", + "DarkOliveGreen", + "PaleTurquoise4", + "IndianRed4", + "MediumVioletRed", + "SaddleBrown", + "LightGrey", /* try Grey90 -gud */ + "Grey20", + "Blue", + "Green", + "Turquoise1", + "Red2", + "Violet", + "Gold", + "WhiteSmoke" +}; + #define OPTION_TABLE_SIZE 7 /* Translation table for command line option to X resources */ @@ -139,17 +159,17 @@ XColor exact_def; Visual *visual; int loop, depth; - char color_name[8]; - char color_class[8]; + char color_name[8]; char bgcolor_name[10]; + char color_class[8]; char bgcolor_class[10]; Screen *xscreen; - memset(color_name, 0, 8); - memset(color_class, 0, 8); - strcpy(color_name, "color"); - strcpy(color_class, "Color"); + memset(color_name, 0, 8); memset(bgcolor_name, 0, sizeof(bgcolor_name)); + memset(color_class, 0, 8); memset(bgcolor_class, 0, sizeof(bgcolor_class)); + strcpy(color_name, "color"); strcpy(bgcolor_name, "bgcolor"); + strcpy(color_class, "Color"); strcpy(bgcolor_class, "BgColor"); for (loop = 0; loop < 16; loop++) - { - /* color names start at 1 not 0 */ + { /* color names start at 1 not 0 */ + /*fgcolor:*/ color_name[5] = color_class[5] = (loop < 9)? loop + '1': '1'; if (loop > 8) { @@ -160,7 +180,20 @@ if (XrmQGetResource(xresdb, name_list, class_list, &return_value, &xval)) { WpeXColorNames[loop] = (char *)xval.addr; + WpeXColorNamesBg[loop] = (char *)xval.addr; + } + /*bgcolor:*/ + bgcolor_name[7] = bgcolor_class[7] = (loop < 9)? loop + '1': '1'; + if (loop > 8) + { + bgcolor_name[8] = bgcolor_class[8] = loop - 9 + '0'; } + name_list[1] = XrmStringToQuark(bgcolor_name); + class_list[1] = XrmStringToQuark(bgcolor_class); + if (XrmQGetResource(xresdb, name_list, class_list, &return_value, &xval)) + { + WpeXColorNamesBg[loop] = (char *)xval.addr; + } } cmap = DefaultColormap(WpeXInfo.display, WpeXInfo.screen); @@ -192,20 +225,44 @@ } for(loop = 0; loop < 16; loop++) { + /*fgcolor:*/ if (!XParseColor(WpeXInfo.display, cmap, WpeXColorNames[loop], &exact_def)) { - /* Should try a default color then bail if need be */ - fprintf(stderr, "xwpe: unable to find color \"%s\", exiting ...\n", - WpeXColorNames[loop]); - exit(1); + fprintf(stderr, "xwpe: unable to find color \"%s\", using %s\n", + WpeXColorNames[loop], loop ? "WhitePixel" : "BlackPixel"); + WpeXInfo.colors[loop] = loop ? WhitePixel (WpeXInfo.display, WpeXInfo.screen) + : BlackPixel (WpeXInfo.display, WpeXInfo.screen); + }else + if (!XAllocColor(WpeXInfo.display, cmap, &exact_def)) + { + /* use colors as is useful for a black&white screen */ + fprintf(stderr, "Xwpe: all colorcells allocated, cannot get \"%s\", using %s\n", + WpeXColorNames[loop], loop ? "WhitePixel" : "BlackPixel"); + WpeXInfo.colors[loop] = loop ? WhitePixel (WpeXInfo.display, WpeXInfo.screen) + : BlackPixel (WpeXInfo.display, WpeXInfo.screen); + }else{ + WpeXInfo.colors[loop] = exact_def.pixel; } + + /*bgcolor:*/ + if (!XParseColor(WpeXInfo.display, cmap, WpeXColorNamesBg[loop], &exact_def)) + { + /* Should try a default color then bail if need be */ + fprintf(stderr, "xwpe: unable to find bgcolor \"%s\"," + " using already allocated fgcolor (\"%s\")\n", + WpeXColorNamesBg[loop], WpeXColorNames[loop]); + WpeXInfo.bgcolors[loop] = WpeXInfo.colors[loop]; + }else if (!XAllocColor(WpeXInfo.display, cmap, &exact_def)) { - /* Should try to find closest color */ - fprintf(stderr, "Xwpe: all colorcells allocated, exiting ...\n"); - exit(1); + /* use colors as is useful for a black&white screen */ + fprintf(stderr, "Xwpe: all colorcells allocated, cannot get \"%s\"," + " using already allocated fgcolor (\"%s\")\n", + WpeXColorNamesBg[loop], WpeXColorNames[loop]); + WpeXInfo.bgcolors[loop] = WpeXInfo.colors[loop]; + }else{ + WpeXInfo.bgcolors[loop] = exact_def.pixel; } - WpeXInfo.colors[loop] = exact_def.pixel; } return ; } diff -u -r -d xwpe-1.5.21a/WeXterm.h xwpe-1.5.21.shaded/WeXterm.h --- xwpe-1.5.21a/WeXterm.h Fri Nov 19 04:06:05 1999 +++ xwpe-1.5.21.shaded/WeXterm.h Wed Nov 24 15:25:42 1999 @@ -37,6 +37,7 @@ int font_height, font_width; int altmask; int colors[16]; + int bgcolors[16]; WpeMouseShape shape_list[2]; } WpeXStruct; diff -u -r -d xwpe-1.5.21a/we_xterm.c xwpe-1.5.21.shaded/we_xterm.c --- xwpe-1.5.21a/we_xterm.c Fri Nov 19 04:06:05 1999 +++ xwpe-1.5.21.shaded/we_xterm.c Wed Nov 24 15:34:50 1999 @@ -248,7 +248,7 @@ XSetForeground(WpeXInfo.display, WpeXInfo.gc, WpeXInfo.colors[schirm[x + 1] % 16]); XSetBackground(WpeXInfo.display, WpeXInfo.gc, - WpeXInfo.colors[schirm[x + 1] / 16]); + WpeXInfo.bgcolors[schirm[x + 1] / 16]); XDrawImageString(WpeXInfo.display, WpeXInfo.window, WpeXInfo.gc, WpeXInfo.font_width*old_cursor_x, WpeXInfo.font_height*(old_cursor_y+1) - WpeXInfo.font->max_bounds.descent, @@ -265,7 +265,7 @@ XSetForeground(WpeXInfo.display, WpeXInfo.gc, WpeXInfo.colors[schirm[x + 1] / 16]); XSetBackground(WpeXInfo.display, WpeXInfo.gc, - WpeXInfo.colors[schirm[x + 1] % 16]); + WpeXInfo.bgcolors[schirm[x + 1] % 16]); XDrawImageString(WpeXInfo.display, WpeXInfo.window, WpeXInfo.gc, WpeXInfo.font_width * cur_x, WpeXInfo.font_height * (cur_y + 1) - WpeXInfo.font->max_bounds.descent, @@ -361,12 +361,12 @@ { #ifdef NOXCACHE XSetForeground(WpeXInfo.display, WpeXInfo.gc, WpeXInfo.colors[schirm[x+1] % 16]); - XSetBackground(WpeXInfo.display, WpeXInfo.gc, WpeXInfo.colors[schirm[x+1] / 16]); + XSetBackground(WpeXInfo.display, WpeXInfo.gc, WpeXInfo.bgcolors[schirm[x+1] / 16]); XDrawImageString(WpeXInfo.display, WpeXInfo.window, WpeXInfo.gc, WpeXInfo.font_width*j, WpeXInfo.font_height*(i+1) - WpeXInfo.font->max_bounds.descent, schirm + x, 1); #else - if ( oldback != WpeXInfo.colors[schirm[x+1] / 16] /* a.r. */ + if ( oldback != WpeXInfo.bgcolors[schirm[x+1] / 16] /* a.r. */ || oldfore != WpeXInfo.colors[schirm[x+1] % 16] || i != oldI || j > oldJ+1 /* is there a more elegant solution? */ @@ -375,7 +375,7 @@ { XDrawImageString(WpeXInfo.display, WpeXInfo.window, WpeXInfo.gc, oldX, oldY, stringbuf, stringcount); - oldback = WpeXInfo.colors[schirm[x+1] / 16]; + oldback = WpeXInfo.bgcolors[schirm[x+1] / 16]; oldfore = WpeXInfo.colors[schirm[x+1] % 16]; XSetForeground(WpeXInfo.display, WpeXInfo.gc, oldfore ); XSetBackground(WpeXInfo.display, WpeXInfo.gc, oldback );