fix default color overwriten bug.
This commit is contained in:
parent
be2877cd04
commit
751fb765e4
@ -30,7 +30,9 @@ static const char *colorname[] = {
|
|||||||
"cyan",
|
"cyan",
|
||||||
"white",
|
"white",
|
||||||
|
|
||||||
/* more colors can be added to use with DefaultXX */
|
[255] = 0,
|
||||||
|
|
||||||
|
/* more colors can be added after 255 to use with DefaultXX */
|
||||||
"#cccccc",
|
"#cccccc",
|
||||||
"#333333",
|
"#333333",
|
||||||
};
|
};
|
||||||
@ -39,8 +41,8 @@ static const char *colorname[] = {
|
|||||||
foreground, background, cursor, unfocused cursor */
|
foreground, background, cursor, unfocused cursor */
|
||||||
#define DefaultFG 7
|
#define DefaultFG 7
|
||||||
#define DefaultBG 0
|
#define DefaultBG 0
|
||||||
#define DefaultCS 16
|
#define DefaultCS 256
|
||||||
#define DefaultUCS 17
|
#define DefaultUCS 257
|
||||||
|
|
||||||
/* Special keys (change & recompile st.info accordingly)
|
/* Special keys (change & recompile st.info accordingly)
|
||||||
Keep in mind that kpress() in st.c hardcodes some keys.
|
Keep in mind that kpress() in st.c hardcodes some keys.
|
||||||
|
39
st.c
39
st.c
@ -83,13 +83,14 @@ enum { B0=1, B1=2, B2=4, B3=8, B4=16, B5=32, B6=64, B7=128 };
|
|||||||
typedef unsigned char uchar;
|
typedef unsigned char uchar;
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
typedef unsigned long ulong;
|
typedef unsigned long ulong;
|
||||||
|
typedef unsigned short ushort;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char c[UTF_SIZ]; /* character code */
|
char c[UTF_SIZ]; /* character code */
|
||||||
uchar mode; /* attribute flags */
|
uchar mode; /* attribute flags */
|
||||||
uchar fg; /* foreground */
|
ushort fg; /* foreground */
|
||||||
uchar bg; /* background */
|
ushort bg; /* background */
|
||||||
uchar state; /* state flags */
|
uchar state; /* state flags */
|
||||||
} Glyph;
|
} Glyph;
|
||||||
|
|
||||||
typedef Glyph* Line;
|
typedef Glyph* Line;
|
||||||
@ -154,18 +155,6 @@ typedef struct {
|
|||||||
char s[ESC_BUF_SIZ];
|
char s[ESC_BUF_SIZ];
|
||||||
} Key;
|
} Key;
|
||||||
|
|
||||||
/* Drawing Context */
|
|
||||||
typedef struct {
|
|
||||||
ulong col[256];
|
|
||||||
GC gc;
|
|
||||||
struct {
|
|
||||||
int ascent;
|
|
||||||
int descent;
|
|
||||||
short lbearing;
|
|
||||||
short rbearing;
|
|
||||||
XFontSet set;
|
|
||||||
} font, bfont;
|
|
||||||
} DC;
|
|
||||||
|
|
||||||
/* TODO: use better name for vars... */
|
/* TODO: use better name for vars... */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -181,6 +170,19 @@ typedef struct {
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
/* Drawing Context */
|
||||||
|
typedef struct {
|
||||||
|
ulong col[LEN(colorname) < 256 ? 256 : LEN(colorname)];
|
||||||
|
GC gc;
|
||||||
|
struct {
|
||||||
|
int ascent;
|
||||||
|
int descent;
|
||||||
|
short lbearing;
|
||||||
|
short rbearing;
|
||||||
|
XFontSet set;
|
||||||
|
} font, bfont;
|
||||||
|
} DC;
|
||||||
|
|
||||||
static void die(const char*, ...);
|
static void die(const char*, ...);
|
||||||
static void draw(void);
|
static void draw(void);
|
||||||
static void drawregion(int, int, int, int);
|
static void drawregion(int, int, int, int);
|
||||||
@ -1583,7 +1585,10 @@ xloadcols(void) {
|
|||||||
XColor color;
|
XColor color;
|
||||||
ulong white = WhitePixel(xw.dpy, xw.scr);
|
ulong white = WhitePixel(xw.dpy, xw.scr);
|
||||||
|
|
||||||
|
/* load colors [0-15] colors and [256-LEN(colorname)[ (config.h) */
|
||||||
for(i = 0; i < LEN(colorname); i++) {
|
for(i = 0; i < LEN(colorname); i++) {
|
||||||
|
if(!colorname[i])
|
||||||
|
continue;
|
||||||
if(!XAllocNamedColor(xw.dpy, xw.cmap, colorname[i], &color, &color)) {
|
if(!XAllocNamedColor(xw.dpy, xw.cmap, colorname[i], &color, &color)) {
|
||||||
dc.col[i] = white;
|
dc.col[i] = white;
|
||||||
fprintf(stderr, "Could not allocate color '%s'\n", colorname[i]);
|
fprintf(stderr, "Could not allocate color '%s'\n", colorname[i]);
|
||||||
@ -1591,8 +1596,8 @@ xloadcols(void) {
|
|||||||
dc.col[i] = color.pixel;
|
dc.col[i] = color.pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* same colors as xterm */
|
/* load colors [16-255] ; same colors as xterm */
|
||||||
for(r = 0; r < 6; r++)
|
for(i = 16, r = 0; r < 6; r++)
|
||||||
for(g = 0; g < 6; g++)
|
for(g = 0; g < 6; g++)
|
||||||
for(b = 0; b < 6; b++) {
|
for(b = 0; b < 6; b++) {
|
||||||
color.red = r == 0 ? 0 : 0x3737 + 0x2828 * r;
|
color.red = r == 0 ? 0 : 0x3737 + 0x2828 * r;
|
||||||
|
Loading…
Reference in New Issue
Block a user