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 | 751fb765e4f26ce1500b4e8ee9f4cd5b6039b495 (patch) | |
| tree | 88fe375523dfb13e52ee17ea77bd0e7960cc04f8 /st.c | |
| parent | be2877cd042eaf5d0f7dda102f526357aa577232 (diff) | |
| download | st-751fb765e4f26ce1500b4e8ee9f4cd5b6039b495.tar.gz st-751fb765e4f26ce1500b4e8ee9f4cd5b6039b495.zip | |
fix default color overwriten bug.
Diffstat (limited to 'st.c')
| -rw-r--r-- | st.c | 41 |
1 files changed, 23 insertions, 18 deletions
| @@ -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; |
