(wrong string) élien Aptel

From: <hg_AT_suckless.org>
Date: Thu, 16 Feb 2012 01:07:13 +0100 (CET)

changeset: 235:07b5f03730ac
user: Aurélien Aptel <aurelien.aptel_AT_gmail.com>
date: Thu Feb 16 00:10:32 2012 +0100
files: config.def.h st.c
description:
fix default color overwriten bug.


diff -r ecc6e6f67f35 -r 07b5f03730ac config.def.h
--- a/config.def.h Wed Feb 15 19:33:48 2012 +0100
+++ b/config.def.h Thu Feb 16 00:10:32 2012 +0100
_AT_@ -30,7 +30,9 @@
         "cyan",
         "white",
         
- /* more colors can be added to use with DefaultXX */
+ [255] = 0,
+
+ /* more colors can be added after 255 to use with DefaultXX */
         "#cccccc",
         "#333333",
 };
_AT_@ -39,8 +41,8 @@
    foreground, background, cursor, unfocused cursor */
 #define DefaultFG 7
 #define DefaultBG 0
-#define DefaultCS 16
-#define DefaultUCS 17
+#define DefaultCS 256
+#define DefaultUCS 257
 
 /* Special keys (change & recompile st.info accordingly)
    Keep in mind that kpress() in st.c hardcodes some keys.
diff -r ecc6e6f67f35 -r 07b5f03730ac st.c
--- a/st.c Wed Feb 15 19:33:48 2012 +0100
+++ b/st.c Thu Feb 16 00:10:32 2012 +0100
_AT_@ -83,13 +83,14 @@
 typedef unsigned char uchar;
 typedef unsigned int uint;
 typedef unsigned long ulong;
+typedef unsigned short ushort;
 
 typedef struct {
         char c[UTF_SIZ]; /* character code */
         uchar mode; /* attribute flags */
- uchar fg; /* foreground */
- uchar bg; /* background */
- uchar state; /* state flags */
+ ushort fg; /* foreground */
+ ushort bg; /* background */
+ uchar state; /* state flags */
 } Glyph;
 
 typedef Glyph* Line;
_AT_@ -154,18 +155,6 @@
         char s[ESC_BUF_SIZ];
 } 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... */
 typedef struct {
_AT_@ -181,6 +170,19 @@
 
 #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 draw(void);
 static void drawregion(int, int, int, int);
_AT_@ -1583,16 +1585,19 @@
         XColor color;
         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++) {
+ if(!colorname[i])
+ continue;
                 if(!XAllocNamedColor(xw.dpy, xw.cmap, colorname[i], &color, &color)) {
                         dc.col[i] = white;
                         fprintf(stderr, "Could not allocate color '%s'\n", colorname[i]);
                 } else
                         dc.col[i] = color.pixel;
         }
-
- /* same colors as xterm */
- for(r = 0; r < 6; r++)
+
+ /* load colors [16-255] ; same colors as xterm */
+ for(i = 16, r = 0; r < 6; r++)
                 for(g = 0; g < 6; g++)
                         for(b = 0; b < 6; b++) {
                                 color.red = r == 0 ? 0 : 0x3737 + 0x2828 * r;
Received on Thu Feb 16 2012 - 01:07:13 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 16 2012 - 01:12:07 CET