diff options
author | Aurélien Aptel <aurelien.aptel@gmail.com> | 2012-02-16 00:10:32 +0100 |
---|---|---|
committer | Aurélien Aptel <aurelien.aptel@gmail.com> | 2012-02-16 00:10:32 +0100 |
commit | 1ec0515e75320c42da4a224441642f82571e38b0 (patch) | |
tree | 88fe375523dfb13e52ee17ea77bd0e7960cc04f8 | |
parent | adf5d2e32a74704778e60e71be5425b7d7fff3e2 (diff) | |
download | st-patched-1ec0515e75320c42da4a224441642f82571e38b0.tar.bz2 st-patched-1ec0515e75320c42da4a224441642f82571e38b0.tar.xz st-patched-1ec0515e75320c42da4a224441642f82571e38b0.zip |
fix default color overwriten bug.
-rw-r--r-- | config.def.h | 8 | ||||
-rw-r--r-- | st.c | 41 |
2 files changed, 28 insertions, 21 deletions
diff --git a/config.def.h b/config.def.h index 169bcdd..047b5d1 100644 --- a/config.def.h +++ b/config.def.h | |||
@@ -30,7 +30,9 @@ static const char *colorname[] = { | |||
30 | "cyan", | 30 | "cyan", |
31 | "white", | 31 | "white", |
32 | 32 | ||
33 | /* more colors can be added to use with DefaultXX */ | 33 | [255] = 0, |
34 | |||
35 | /* more colors can be added after 255 to use with DefaultXX */ | ||
34 | "#cccccc", | 36 | "#cccccc", |
35 | "#333333", | 37 | "#333333", |
36 | }; | 38 | }; |
@@ -39,8 +41,8 @@ static const char *colorname[] = { | |||
39 | foreground, background, cursor, unfocused cursor */ | 41 | foreground, background, cursor, unfocused cursor */ |
40 | #define DefaultFG 7 | 42 | #define DefaultFG 7 |
41 | #define DefaultBG 0 | 43 | #define DefaultBG 0 |
42 | #define DefaultCS 16 | 44 | #define DefaultCS 256 |
43 | #define DefaultUCS 17 | 45 | #define DefaultUCS 257 |
44 | 46 | ||
45 | /* Special keys (change & recompile st.info accordingly) | 47 | /* Special keys (change & recompile st.info accordingly) |
46 | Keep in mind that kpress() in st.c hardcodes some keys. | 48 | Keep in mind that kpress() in st.c hardcodes some keys. |
@@ -83,13 +83,14 @@ enum { B0=1, B1=2, B2=4, B3=8, B4=16, B5=32, B6=64, B7=128 }; | |||
83 | typedef unsigned char uchar; | 83 | typedef unsigned char uchar; |
84 | typedef unsigned int uint; | 84 | typedef unsigned int uint; |
85 | typedef unsigned long ulong; | 85 | typedef unsigned long ulong; |
86 | typedef unsigned short ushort; | ||
86 | 87 | ||
87 | typedef struct { | 88 | typedef struct { |
88 | char c[UTF_SIZ]; /* character code */ | 89 | char c[UTF_SIZ]; /* character code */ |
89 | uchar mode; /* attribute flags */ | 90 | uchar mode; /* attribute flags */ |
90 | uchar fg; /* foreground */ | 91 | ushort fg; /* foreground */ |
91 | uchar bg; /* background */ | 92 | ushort bg; /* background */ |
92 | uchar state; /* state flags */ | 93 | uchar state; /* state flags */ |
93 | } Glyph; | 94 | } Glyph; |
94 | 95 | ||
95 | typedef Glyph* Line; | 96 | typedef Glyph* Line; |
@@ -154,18 +155,6 @@ typedef struct { | |||
154 | char s[ESC_BUF_SIZ]; | 155 | char s[ESC_BUF_SIZ]; |
155 | } Key; | 156 | } Key; |
156 | 157 | ||
157 | /* Drawing Context */ | ||
158 | typedef struct { | ||
159 | ulong col[256]; | ||
160 | GC gc; | ||
161 | struct { | ||
162 | int ascent; | ||
163 | int descent; | ||
164 | short lbearing; | ||
165 | short rbearing; | ||
166 | XFontSet set; | ||
167 | } font, bfont; | ||
168 | } DC; | ||
169 | 158 | ||
170 | /* TODO: use better name for vars... */ | 159 | /* TODO: use better name for vars... */ |
171 | typedef struct { | 160 | typedef struct { |
@@ -181,6 +170,19 @@ typedef struct { | |||
181 | 170 | ||
182 | #include "config.h" | 171 | #include "config.h" |
183 | 172 | ||
173 | /* Drawing Context */ | ||
174 | typedef struct { | ||
175 | ulong col[LEN(colorname) < 256 ? 256 : LEN(colorname)]; | ||
176 | GC gc; | ||
177 | struct { | ||
178 | int ascent; | ||
179 | int descent; | ||
180 | short lbearing; | ||
181 | short rbearing; | ||
182 | XFontSet set; | ||
183 | } font, bfont; | ||
184 | } DC; | ||
185 | |||
184 | static void die(const char*, ...); | 186 | static void die(const char*, ...); |
185 | static void draw(void); | 187 | static void draw(void); |
186 | static void drawregion(int, int, int, int); | 188 | static void drawregion(int, int, int, int); |
@@ -1583,16 +1585,19 @@ xloadcols(void) { | |||
1583 | XColor color; | 1585 | XColor color; |
1584 | ulong white = WhitePixel(xw.dpy, xw.scr); | 1586 | ulong white = WhitePixel(xw.dpy, xw.scr); |
1585 | 1587 | ||
1588 | /* load colors [0-15] colors and [256-LEN(colorname)[ (config.h) */ | ||
1586 | for(i = 0; i < LEN(colorname); i++) { | 1589 | for(i = 0; i < LEN(colorname); i++) { |
1590 | if(!colorname[i]) | ||
1591 | continue; | ||
1587 | if(!XAllocNamedColor(xw.dpy, xw.cmap, colorname[i], &color, &color)) { | 1592 | if(!XAllocNamedColor(xw.dpy, xw.cmap, colorname[i], &color, &color)) { |
1588 | dc.col[i] = white; | 1593 | dc.col[i] = white; |
1589 | fprintf(stderr, "Could not allocate color '%s'\n", colorname[i]); | 1594 | fprintf(stderr, "Could not allocate color '%s'\n", colorname[i]); |
1590 | } else | 1595 | } else |
1591 | dc.col[i] = color.pixel; | 1596 | dc.col[i] = color.pixel; |
1592 | } | 1597 | } |
1593 | 1598 | ||
1594 | /* same colors as xterm */ | 1599 | /* load colors [16-255] ; same colors as xterm */ |
1595 | for(r = 0; r < 6; r++) | 1600 | for(i = 16, r = 0; r < 6; r++) |
1596 | for(g = 0; g < 6; g++) | 1601 | for(g = 0; g < 6; g++) |
1597 | for(b = 0; b < 6; b++) { | 1602 | for(b = 0; b < 6; b++) { |
1598 | color.red = r == 0 ? 0 : 0x3737 + 0x2828 * r; | 1603 | color.red = r == 0 ? 0 : 0x3737 + 0x2828 * r; |