aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2012-02-16 00:10:32 +0100
committerAurélien Aptel <aurelien.aptel@gmail.com>2012-02-16 00:10:32 +0100
commit1ec0515e75320c42da4a224441642f82571e38b0 (patch)
tree88fe375523dfb13e52ee17ea77bd0e7960cc04f8
parentadf5d2e32a74704778e60e71be5425b7d7fff3e2 (diff)
downloadst-patched-1ec0515e75320c42da4a224441642f82571e38b0.tar.bz2
st-patched-1ec0515e75320c42da4a224441642f82571e38b0.tar.xz
st-patched-1ec0515e75320c42da4a224441642f82571e38b0.zip
fix default color overwriten bug.
-rw-r--r--config.def.h8
-rw-r--r--st.c41
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.
diff --git a/st.c b/st.c
index a86e0f9..e6a5e4e 100644
--- a/st.c
+++ b/st.c
@@ -83,13 +83,14 @@ enum { B0=1, B1=2, B2=4, B3=8, B4=16, B5=32, B6=64, B7=128 };
83typedef unsigned char uchar; 83typedef unsigned char uchar;
84typedef unsigned int uint; 84typedef unsigned int uint;
85typedef unsigned long ulong; 85typedef unsigned long ulong;
86typedef unsigned short ushort;
86 87
87typedef struct { 88typedef 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
95typedef Glyph* Line; 96typedef 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 */
158typedef 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... */
171typedef struct { 160typedef struct {
@@ -181,6 +170,19 @@ typedef struct {
181 170
182#include "config.h" 171#include "config.h"
183 172
173/* Drawing Context */
174typedef 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
184static void die(const char*, ...); 186static void die(const char*, ...);
185static void draw(void); 187static void draw(void);
186static void drawregion(int, int, int, int); 188static 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;