[wiki] [sites] wiki updated

From: <hg_AT_suckless.org>
Date: Thu, 18 Aug 2011 15:30:22 +0200 (CEST)

changeset: 757:4a205a61164f
tag: tip
user: voltaic <voltaic_AT_gmail.com>
date: Thu Aug 18 09:29:27 2011 -0400
files: dwm.suckless.org/patches/dwm-5.9-statuscolors.diff
description:
Forgot to add the file "dwm-5.9-statuscolors.diff" to the last commit. Sorry about the noise.


diff -r 33215a5aedbc -r 4a205a61164f dwm.suckless.org/patches/dwm-5.9-statuscolors.diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwm.suckless.org/patches/dwm-5.9-statuscolors.diff Thu Aug 18 09:29:27 2011 -0400
_AT_@ -0,0 +1,236 @@
+diff -up dwm-5.9/config.def.h dwm-5.9-colors/config.def.h
+--- dwm-5.9/config.def.h 2011-07-10 16:24:25.000000000 -0400
++++ dwm-5.9-colors/config.def.h 2011-08-18 02:02:47.033830823 -0400
+_AT_@ -1,13 +1,16 @@
+ /* See LICENSE file for copyright and license details. */
+
+ /* appearance */
++#define NUMCOLORS 4 // need at least 3
++static const char colors[NUMCOLORS][ColLast][8] = {
++ // border foreground background
++ { "#cccccc", "#000000", "#cccccc" }, // 0 = normal
++ { "#0066ff", "#ffffff", "#0066ff" }, // 1 = selected
++ { "#0066ff", "#0066ff", "#ffffff" }, // 2 = urgent/warning
++ { "#ff0000", "#ffffff", "#ff0000" }, // 3 = error
++ // add more here
++};
+ static const char font[] = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*";
+-static const char normbordercolor[] = "#cccccc";
+-static const char normbgcolor[] = "#cccccc";
+-static const char normfgcolor[] = "#000000";
+-static const char selbordercolor[] = "#0066ff";
+-static const char selbgcolor[] = "#0066ff";
+-static const char selfgcolor[] = "#ffffff";
+ static const unsigned int borderpx = 1; /* border pixel of windows */
+ static const unsigned int snap = 32; /* snap pixel */
+ static const Bool showbar = True; /* False means no bar */
+_AT_@ -45,7 +48,7 @@ static const Layout layouts[] = {
+ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
+
+ /* commands */
+-static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
++static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", colors[0][ColBG], "-nf", colors[0][ColFG],"-sb", colors[1][ColBG], "-sf", colors[1][ColFG], NULL };
+ static const char *termcmd[] = { "uxterm", NULL };
+
+ static Key keys[] = {
+Only in dwm-5.9: config.h
+Only in dwm-5.9: dwm
+diff -up dwm-5.9/dwm.c dwm-5.9-colors/dwm.c
+--- dwm-5.9/dwm.c 2011-07-10 16:24:25.000000000 -0400
++++ dwm-5.9-colors/dwm.c 2011-08-18 02:07:20.788935100 -0400
+_AT_@ -48,6 +48,7 @@
+ #define LENGTH(X) (sizeof X / sizeof X[0])
+ #define MAX(A, B) ((A) > (B) ? (A) : (B))
+ #define MIN(A, B) ((A) < (B) ? (A) : (B))
++#define MAXCOLORS 8
+ #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
+ #define WIDTH(X) ((X)->w + 2 * (X)->bw)
+ #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
+_AT_@ -97,9 +98,8 @@ struct Client {
+
+ typedef struct {
+ int x, y, w, h;
+- unsigned long norm[ColLast];
+- unsigned long sel[ColLast];
+- Drawable drawable;
++ unsigned long colors[MAXCOLORS][ColLast];
++ Drawable drawable;
+ GC gc;
+ struct {
+ int ascent;
+_AT_@ -175,8 +175,9 @@ static void die(const char *errstr, ...)
+ static Monitor *dirtomon(int dir);
+ static void drawbar(Monitor *m);
+ static void drawbars(void);
+-static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
+-static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
++static void drawcoloredtext(char *text);
++static void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]);
++static void drawtext(const char *text, unsigned long col[ColLast], Bool pad);
+ static void enternotify(XEvent *e);
+ static void expose(XEvent *e);
+ static void focus(Client *c);
+_AT_@ -736,14 +737,13 @@ drawbar(Monitor *m) {
+ dc.x = 0;
+ for(i = 0; i < LENGTH(tags); i++) {
+ dc.w = TEXTW(tags[i]);
+- col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
+- drawtext(tags[i], col, urg & 1 << i);
+- drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+- occ & 1 << i, urg & 1 << i, col);
++ col = dc.colors[ (m->tagset[m->seltags] & 1 << i ? 1:(urg & 1 << i ? 2:0))];
++ drawtext(tags[i], col, True);
++ drawsquare(m == selmon && selmon->sel && selmon->sel->tags & 1 << i, occ & 1 << i, col);
+ dc.x += dc.w;
+ }
+ dc.w = blw = TEXTW(m->ltsymbol);
+- drawtext(m->ltsymbol, dc.norm, False);
++ drawtext(m->ltsymbol, dc.colors[0], True);
+ dc.x += dc.w;
+ x = dc.x;
+ if(m == selmon) { /* status is only drawn on selected monitor */
+_AT_@ -753,19 +753,19 @@ drawbar(Monitor *m) {
+ dc.x = x;
+ dc.w = m->ww - x;
+ }
+- drawtext(stext, dc.norm, False);
++ drawcoloredtext(stext);
+ }
+ else
+ dc.x = m->ww;
+ if((dc.w = dc.x - x) > bh) {
+ dc.x = x;
+ if(m->sel) {
+- col = m == selmon ? dc.sel : dc.norm;
+- drawtext(m->sel->name, col, False);
+- drawsquare(m->sel->isfixed, m->sel->isfloating, False, col);
++ col = m == selmon ? dc.colors[1] : dc.colors[0];
++ drawtext(m->sel->name, col, True);
++ drawsquare(m->sel->isfixed, m->sel->isfloating, col);
+ }
+ else
+- drawtext(NULL, dc.norm, False);
++ drawtext(NULL, dc.colors[0], False);
+ }
+ XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0);
+ XSync(dpy, False);
+_AT_@ -780,10 +780,39 @@ drawbars(void) {
+ }
+
+ void
+-drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
+- int x;
++drawcoloredtext(char *text) {
++ Bool first=True;
++ char *buf = text, *ptr = buf, c = 1;
++ unsigned long *col = dc.colors[0];
++ int i, ox = dc.x;
++
++ while( *ptr ) {
++ for( i = 0; *ptr < 0 || *ptr > NUMCOLORS; i++, ptr++);
++ if( !*ptr ) break;
++ c=*ptr;
++ *ptr=0;
++ if( i ) {
++ dc.w = selmon->ww - dc.x;
++ drawtext(buf, col, first);
++ dc.x += textnw(buf, i) + textnw(&c,1);
++ if( first ) dc.x += ( dc.font.ascent + dc.font.descent ) / 2;
++ first = False;
++ } else if( first ) {
++ ox = dc.x += textnw(&c,1);
++ }
++ *ptr = c;
++ col = dc.colors[ c-1 ];
++ buf = ++ptr;
++ }
++ if( !first ) dc.x-=(dc.font.ascent+dc.font.descent)/2;
++ drawtext(buf, col, True);
++ dc.x = ox;
++}
+
+- XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
++void
++drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]) {
++ int x;
++ XSetForeground(dpy, dc.gc, col[ ColFG ]);
+ x = (dc.font.ascent + dc.font.descent + 2) / 4;
+ if(filled)
+ XFillRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1, x+1, x+1);
+_AT_@ -792,17 +821,17 @@ drawsquare(Bool filled, Bool empty, Bool
+ }
+
+ void
+-drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
++drawtext(const char *text, unsigned long col[ColLast], Bool pad) {
+ char buf[256];
+ int i, x, y, h, len, olen;
+
+- XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
++ XSetForeground(dpy, dc.gc, col[ ColBG ]);
+ XFillRectangle(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.w, dc.h);
+ if(!text)
+ return;
+ olen = strlen(text);
+- h = dc.font.ascent + dc.font.descent;
+- y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
++ h = pad ? (dc.font.ascent + dc.font.descent) : 0;
++ y = dc.y + ((dc.h + dc.font.ascent - dc.font.descent) / 2);
+ x = dc.x + (h / 2);
+ /* shorten text if necessary */
+ for(len = MIN(olen, sizeof buf); len && textnw(text, len) > dc.w - h; len--);
+_AT_@ -811,7 +840,7 @@ drawtext(const char *text, unsigned long
+ memcpy(buf, text, len);
+ if(len < olen)
+ for(i = len; i && i > len - 3; buf[--i] = '.');
+- XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
++ XSetForeground(dpy, dc.gc, col[ ColFG ]);
+ if(dc.font.set)
+ XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
+ else
+_AT_@ -861,7 +890,7 @@ focus(Client *c) {
+ detachstack(c);
+ attachstack(c);
+ grabbuttons(c, True);
+- XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
++ XSetWindowBorder(dpy, c->win, dc.colors[1][ColBorder]);
+ setfocus(c);
+ }
+ else
+_AT_@ -1137,7 +1166,7 @@ manage(Window w, XWindowAttributes *wa)
+ }
+ wc.border_width = c->bw;
+ XConfigureWindow(dpy, w, CWBorderWidth, &wc);
+- XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
++ XSetWindowBorder(dpy, w, dc.colors[0][ColBorder]);
+ configure(c); /* propagates border_width, if size doesn't change */
+ updatesizehints(c);
+ updatewmhints(c);
+_AT_@ -1550,12 +1579,11 @@ setup(void) {
+ cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
+ cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
+ /* init appearance */
+- dc.norm[ColBorder] = getcolor(normbordercolor);
+- dc.norm[ColBG] = getcolor(normbgcolor);
+- dc.norm[ColFG] = getcolor(normfgcolor);
+- dc.sel[ColBorder] = getcolor(selbordercolor);
+- dc.sel[ColBG] = getcolor(selbgcolor);
+- dc.sel[ColFG] = getcolor(selfgcolor);
++ for(int i=0; i<NUMCOLORS; i++) {
++ dc.colors[i][ColBorder] = getcolor( colors[i][ColBorder] );
++ dc.colors[i][ColFG] = getcolor( colors[i][ColFG] );
++ dc.colors[i][ColBG] = getcolor( colors[i][ColBG] );
++ }
+ dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
+ dc.gc = XCreateGC(dpy, root, 0, NULL);
+ XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
+_AT_@ -1716,7 +1744,7 @@ unfocus(Client *c, Bool setfocus) {
+ if(!c)
+ return;
+ grabbuttons(c, False);
+- XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
++ XSetWindowBorder(dpy, c->win, dc.colors[0][ColBorder]);
+ if(setfocus)
+ XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+ }
+Only in dwm-5.9: dwm.o
Received on Thu Aug 18 2011 - 15:30:22 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 13 2012 - 19:31:49 CEST