aewl

changeset 262:d659a2dce2b5

implemented viewextend and added M-S-C-n shortcuts for extending the current view... updated man page (works great!) nice feature
author Anselm R.Garbe <arg@10ksloc.org>
date Fri, 11 Aug 2006 19:26:12 +0200
parents d6fd632d861c
children 118d3e010e5e
files config.arg.h config.default.h draw.c dwm.1 dwm.h event.c main.c tag.c
diffstat 8 files changed, 100 insertions(+), 68 deletions(-) [+]
line diff
     1.1 --- a/config.arg.h	Fri Aug 11 18:37:41 2006 +0200
     1.2 +++ b/config.arg.h	Fri Aug 11 19:26:12 2006 +0200
     1.3 @@ -18,31 +18,34 @@
     1.4  
     1.5  #define KEYS \
     1.6  static Key key[] = { \
     1.7 -	/* modifier		key		function	arguments */ \
     1.8 -	{ MODKEY,		XK_1,		view,		{ .i = 0 } }, \
     1.9 -	{ MODKEY,		XK_2,		view,		{ .i = 1 } }, \
    1.10 -	{ MODKEY,		XK_3,		view,		{ .i = 2 } }, \
    1.11 -	{ MODKEY,		XK_h,		viewprev,	{ 0 } }, \
    1.12 -	{ MODKEY,		XK_j,		focusnext,	{ 0 } }, \
    1.13 -	{ MODKEY,		XK_k,		focusprev,	{ 0 } }, \
    1.14 -	{ MODKEY,		XK_l,		viewnext,	{ 0 } }, \
    1.15 -	{ MODKEY,		XK_m,		togglemax,	{ 0 } }, \
    1.16 -	{ MODKEY,		XK_p,		spawn, \
    1.17 +	/* modifier			key		function	arguments */ \
    1.18 +	{ MODKEY,			XK_1,		view,		{ .i = 0 } }, \
    1.19 +	{ MODKEY,			XK_2,		view,		{ .i = 1 } }, \
    1.20 +	{ MODKEY,			XK_3,		view,		{ .i = 2 } }, \
    1.21 +	{ MODKEY,			XK_h,		viewprev,	{ 0 } }, \
    1.22 +	{ MODKEY,			XK_j,		focusnext,	{ 0 } }, \
    1.23 +	{ MODKEY,			XK_k,		focusprev,	{ 0 } }, \
    1.24 +	{ MODKEY,			XK_l,		viewnext,	{ 0 } }, \
    1.25 +	{ MODKEY,			XK_m,		togglemax,	{ 0 } }, \
    1.26 +	{ MODKEY,			XK_p,		spawn, \
    1.27  		{ .cmd = "exec `ls -lL /usr/bin /usr/local/bin 2>/dev/null | " \
    1.28  			"awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | dmenu`" } }, \
    1.29 -	{ MODKEY,		XK_space,	togglemode,	{ 0 } }, \
    1.30 -	{ MODKEY,		XK_Return,	zoom,		{ 0 } }, \
    1.31 -	{ MODKEY|ControlMask,	XK_1,		appendtag,	{ .i = 0 } }, \
    1.32 -	{ MODKEY|ControlMask,	XK_2,		appendtag,	{ .i = 1 } }, \
    1.33 -	{ MODKEY|ControlMask,	XK_3,		appendtag,	{ .i = 2 } }, \
    1.34 -	{ MODKEY|ShiftMask,	XK_1,		replacetag,	{ .i = 0 } }, \
    1.35 -	{ MODKEY|ShiftMask,	XK_2,		replacetag,	{ .i = 1 } }, \
    1.36 -	{ MODKEY|ShiftMask,	XK_3,		replacetag,	{ .i = 2 } }, \
    1.37 -	{ MODKEY|ShiftMask,	XK_c,		killclient,	{ 0 } }, \
    1.38 -	{ MODKEY|ShiftMask,	XK_q,		quit,		{ 0 } }, \
    1.39 -	{ MODKEY|ShiftMask,	XK_Return,	spawn, \
    1.40 +	{ MODKEY,			XK_space,	togglemode,	{ 0 } }, \
    1.41 +	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \
    1.42 +	{ MODKEY|ControlMask,		XK_1,		appendtag,	{ .i = 0 } }, \
    1.43 +	{ MODKEY|ControlMask,		XK_2,		appendtag,	{ .i = 1 } }, \
    1.44 +	{ MODKEY|ControlMask,		XK_3,		appendtag,	{ .i = 2 } }, \
    1.45 +	{ MODKEY|ShiftMask,		XK_1,		replacetag,	{ .i = 0 } }, \
    1.46 +	{ MODKEY|ShiftMask,		XK_2,		replacetag,	{ .i = 1 } }, \
    1.47 +	{ MODKEY|ShiftMask,		XK_3,		replacetag,	{ .i = 2 } }, \
    1.48 +	{ MODKEY|ShiftMask,		XK_c,		killclient,	{ 0 } }, \
    1.49 +	{ MODKEY|ShiftMask,		XK_q,		quit,		{ 0 } }, \
    1.50 +	{ MODKEY|ShiftMask,		XK_Return,	spawn, \
    1.51  		{ .cmd = "exec urxvt +sb -tr -bg black -fg '#eeeeee' -cr '#eeeeee' +sb " \
    1.52  			"-fn '-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*'" } }, \
    1.53 +	{ MODKEY|ControlMask|ShiftMask,	XK_1,		viewextend,	{ .i = 0 } }, \
    1.54 +	{ MODKEY|ShiftMask,		XK_2,		viewextend,	{ .i = 1 } }, \
    1.55 +	{ MODKEY|ShiftMask,		XK_3,		viewextend,	{ .i = 2 } }, \
    1.56  };
    1.57  
    1.58  #define RULES \
     2.1 --- a/config.default.h	Fri Aug 11 18:37:41 2006 +0200
     2.2 +++ b/config.default.h	Fri Aug 11 19:26:12 2006 +0200
     2.3 @@ -18,32 +18,37 @@
     2.4  
     2.5  #define KEYS \
     2.6  static Key key[] = { \
     2.7 -	/* modifier		key		function	arguments */ \
     2.8 -	{ MODKEY,		XK_0,		view,		{ .i = 0 } }, \
     2.9 -	{ MODKEY,		XK_1,		view,		{ .i = 1 } }, \
    2.10 -	{ MODKEY,		XK_2,		view,		{ .i = 2 } }, \
    2.11 -	{ MODKEY,		XK_3,		view,		{ .i = 3 } }, \
    2.12 -	{ MODKEY,		XK_4,		view,		{ .i = 4 } }, \
    2.13 -	{ MODKEY,		XK_h,		viewprev,	{ 0 } }, \
    2.14 -	{ MODKEY,		XK_j,		focusnext,	{ 0 } }, \
    2.15 -	{ MODKEY,		XK_k,		focusprev,	{ 0 } }, \
    2.16 -	{ MODKEY,		XK_l,		viewnext,	{ 0 } }, \
    2.17 -	{ MODKEY,		XK_m,		togglemax,	{ 0 } }, \
    2.18 -	{ MODKEY,		XK_space,	togglemode,	{ 0 } }, \
    2.19 -	{ MODKEY,		XK_Return,	zoom,		{ 0 } }, \
    2.20 -	{ MODKEY|ControlMask,	XK_0,		appendtag,	{ .i = 0 } }, \
    2.21 -	{ MODKEY|ControlMask,	XK_1,		appendtag,	{ .i = 1 } }, \
    2.22 -	{ MODKEY|ControlMask,	XK_2,		appendtag,	{ .i = 2 } }, \
    2.23 -	{ MODKEY|ControlMask,	XK_3,		appendtag,	{ .i = 3 } }, \
    2.24 -	{ MODKEY|ControlMask,	XK_4,		appendtag,	{ .i = 4 } }, \
    2.25 -	{ MODKEY|ShiftMask,	XK_0,		replacetag,	{ .i = 0 } }, \
    2.26 -	{ MODKEY|ShiftMask,	XK_1,		replacetag,	{ .i = 1 } }, \
    2.27 -	{ MODKEY|ShiftMask,	XK_2,		replacetag,	{ .i = 2 } }, \
    2.28 -	{ MODKEY|ShiftMask,	XK_3,		replacetag,	{ .i = 3 } }, \
    2.29 -	{ MODKEY|ShiftMask,	XK_4,		replacetag,	{ .i = 4 } }, \
    2.30 -	{ MODKEY|ShiftMask,	XK_c,		killclient,	{ 0 } }, \
    2.31 -	{ MODKEY|ShiftMask,	XK_q,		quit,		{ 0 } }, \
    2.32 -	{ MODKEY|ShiftMask,	XK_Return,	spawn,		{ .cmd = "exec xterm" } }, \
    2.33 +	/* modifier			key		function	arguments */ \
    2.34 +	{ MODKEY,			XK_0,		view,		{ .i = 0 } }, \
    2.35 +	{ MODKEY,			XK_1,		view,		{ .i = 1 } }, \
    2.36 +	{ MODKEY,			XK_2,		view,		{ .i = 2 } }, \
    2.37 +	{ MODKEY,			XK_3,		view,		{ .i = 3 } }, \
    2.38 +	{ MODKEY,			XK_4,		view,		{ .i = 4 } }, \
    2.39 +	{ MODKEY,			XK_h,		viewprev,	{ 0 } }, \
    2.40 +	{ MODKEY,			XK_j,		focusnext,	{ 0 } }, \
    2.41 +	{ MODKEY,			XK_k,		focusprev,	{ 0 } }, \
    2.42 +	{ MODKEY,			XK_l,		viewnext,	{ 0 } }, \
    2.43 +	{ MODKEY,			XK_m,		togglemax,	{ 0 } }, \
    2.44 +	{ MODKEY,			XK_space,	togglemode,	{ 0 } }, \
    2.45 +	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \
    2.46 +	{ MODKEY|ControlMask,		XK_0,		appendtag,	{ .i = 0 } }, \
    2.47 +	{ MODKEY|ControlMask,		XK_1,		appendtag,	{ .i = 1 } }, \
    2.48 +	{ MODKEY|ControlMask,		XK_2,		appendtag,	{ .i = 2 } }, \
    2.49 +	{ MODKEY|ControlMask,		XK_3,		appendtag,	{ .i = 3 } }, \
    2.50 +	{ MODKEY|ControlMask,		XK_4,		appendtag,	{ .i = 4 } }, \
    2.51 +	{ MODKEY|ShiftMask,		XK_0,		replacetag,	{ .i = 0 } }, \
    2.52 +	{ MODKEY|ShiftMask,		XK_1,		replacetag,	{ .i = 1 } }, \
    2.53 +	{ MODKEY|ShiftMask,		XK_2,		replacetag,	{ .i = 2 } }, \
    2.54 +	{ MODKEY|ShiftMask,		XK_3,		replacetag,	{ .i = 3 } }, \
    2.55 +	{ MODKEY|ShiftMask,		XK_4,		replacetag,	{ .i = 4 } }, \
    2.56 +	{ MODKEY|ShiftMask,		XK_c,		killclient,	{ 0 } }, \
    2.57 +	{ MODKEY|ShiftMask,		XK_q,		quit,		{ 0 } }, \
    2.58 +	{ MODKEY|ShiftMask,		XK_Return,	spawn,		{ .cmd = "exec xterm" } }, \
    2.59 +	{ MODKEY|ControlMask|ShiftMask,	XK_0,		viewextend,	{ .i = 0 } }, \
    2.60 +	{ MODKEY|ControlMask|ShiftMask,	XK_1,		viewextend,	{ .i = 1 } }, \
    2.61 +	{ MODKEY|ControlMask|ShiftMask,	XK_2,		viewextend,	{ .i = 2 } }, \
    2.62 +	{ MODKEY|ControlMask|ShiftMask,	XK_3,		viewextend,	{ .i = 3 } }, \
    2.63 +	{ MODKEY|ControlMask|ShiftMask,	XK_4,		viewextend,	{ .i = 4 } }, \
    2.64  };
    2.65  
    2.66  #define RULES \
     3.1 --- a/draw.c	Fri Aug 11 18:37:41 2006 +0200
     3.2 +++ b/draw.c	Fri Aug 11 19:26:12 2006 +0200
     3.3 @@ -109,9 +109,9 @@
     3.4  		dc.x += dc.w;
     3.5  		dc.w = textw(tags[i]);
     3.6  		if(istile)
     3.7 -			drawtext(tags[i], tsel[i]);
     3.8 +			drawtext(tags[i], seltag[i]);
     3.9  		else
    3.10 -			drawtext(tags[i], !tsel[i]);
    3.11 +			drawtext(tags[i], !seltag[i]);
    3.12  	}
    3.13  	x = dc.x + dc.w;
    3.14  	dc.w = textw(stext);
     4.1 --- a/dwm.1	Fri Aug 11 18:37:41 2006 +0200
     4.2 +++ b/dwm.1	Fri Aug 11 19:26:12 2006 +0200
     4.3 @@ -36,14 +36,21 @@
     4.4  .B Standard input
     4.5  is read and displayed in the status text area.
     4.6  .TP
     4.7 -.B Button[1-3]
     4.8 -click on a tag label focuses that tag.
     4.9 +.B Button[1,3]
    4.10 +click on a tag label focuses that
    4.11 +.B tag.
    4.12 +.TP
    4.13 +.B Button2
    4.14 +click on a tag label (un)extends the current
    4.15 +.B tag.
    4.16  .TP
    4.17  .B Button[1,4]
    4.18 -click on the bar focuses the previous tag.
    4.19 +click on the bar focuses the previous
    4.20 +.B tag.
    4.21  .TP
    4.22  .B Button[2,5]
    4.23 -click on the bar focuses the next tag.
    4.24 +click on the bar focuses the next
    4.25 +.B tag.
    4.26  .SS Keyboard commands
    4.27  .TP
    4.28  .B Mod1-Return
    4.29 @@ -108,6 +115,12 @@
    4.30  .B nth tag
    4.31  to current
    4.32  .B window.
    4.33 +.TP
    4.34 +.B Mod1-Control-Shift-[0..n]
    4.35 +(Un)extends
    4.36 +.B nth tag
    4.37 +with current
    4.38 +.B tag.
    4.39  .SS Mouse commands
    4.40  .TP
    4.41  .B Mod1-Button1
     5.1 --- a/dwm.h	Fri Aug 11 18:37:41 2006 +0200
     5.2 +++ b/dwm.h	Fri Aug 11 19:26:12 2006 +0200
     5.3 @@ -74,7 +74,7 @@
     5.4  extern void (*handler[LASTEvent])(XEvent *);
     5.5  extern void (*arrange)(Arg *);
     5.6  extern Atom wmatom[WMLast], netatom[NetLast];
     5.7 -extern Bool running, issel, *tsel;
     5.8 +extern Bool running, issel, *seltag;
     5.9  extern Client *clients, *sel;
    5.10  extern Cursor cursor[CurLast];
    5.11  extern DC dc;
    5.12 @@ -128,6 +128,7 @@
    5.13  extern void settags(Client *c);
    5.14  extern void togglemode(Arg *arg);
    5.15  extern void view(Arg *arg);
    5.16 +extern void viewextend(Arg *arg);
    5.17  extern void viewnext(Arg *arg);
    5.18  extern void viewprev(Arg *arg);
    5.19  
     6.1 --- a/event.c	Fri Aug 11 18:37:41 2006 +0200
     6.2 +++ b/event.c	Fri Aug 11 19:26:12 2006 +0200
     6.3 @@ -108,11 +108,8 @@
     6.4  			for(a.i = 0; a.i < ntags; a.i++) {
     6.5  				x += textw(tags[a.i]);
     6.6  				if(ev->x < x) {
     6.7 -					if(ev->button == Button3) {
     6.8 -						tsel[a.i] = True;
     6.9 -						arrange(NULL);
    6.10 -						drawall();
    6.11 -					}
    6.12 +					if(ev->button == Button3)
    6.13 +						viewextend(&a);
    6.14  					else
    6.15  						view(&a);
    6.16  					return;
     7.1 --- a/main.c	Fri Aug 11 18:37:41 2006 +0200
     7.2 +++ b/main.c	Fri Aug 11 19:26:12 2006 +0200
     7.3 @@ -83,7 +83,7 @@
     7.4  /* extern */
     7.5  
     7.6  char stext[1024];
     7.7 -Bool *tsel;
     7.8 +Bool *seltag;
     7.9  int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
    7.10  unsigned int ntags;
    7.11  Atom wmatom[WMLast], netatom[NetLast];
    7.12 @@ -213,8 +213,8 @@
    7.13  	initrregs();
    7.14  
    7.15  	for(ntags = 0; tags[ntags]; ntags++);
    7.16 -	tsel = emallocz(sizeof(Bool) * ntags);
    7.17 -	tsel[DEFTAG] = True;
    7.18 +	seltag = emallocz(sizeof(Bool) * ntags);
    7.19 +	seltag[DEFTAG] = True;
    7.20  
    7.21  	/* style */
    7.22  	dc.bg = getcolor(BGCOLOR);
     8.1 --- a/tag.c	Fri Aug 11 18:37:41 2006 +0200
     8.2 +++ b/tag.c	Fri Aug 11 19:26:12 2006 +0200
     8.3 @@ -181,7 +181,7 @@
     8.4  	unsigned int i;
     8.5  
     8.6  	for(i = 0; i < ntags; i++)
     8.7 -		if(c->tags[i] && tsel[i])
     8.8 +		if(c->tags[i] && seltag[i])
     8.9  			return True;
    8.10  	return False;
    8.11  }
    8.12 @@ -229,7 +229,7 @@
    8.13  	}
    8.14  	if(!matched)
    8.15  		for(i = 0; i < ntags; i++)
    8.16 -			c->tags[i] = tsel[i];
    8.17 +			c->tags[i] = seltag[i];
    8.18  }
    8.19  
    8.20  void
    8.21 @@ -245,8 +245,21 @@
    8.22  	unsigned int i;
    8.23  
    8.24  	for(i = 0; i < ntags; i++)
    8.25 -		tsel[i] = False;
    8.26 -	tsel[arg->i] = True;
    8.27 +		seltag[i] = False;
    8.28 +	seltag[arg->i] = True;
    8.29 +	arrange(NULL);
    8.30 +	drawall();
    8.31 +}
    8.32 +
    8.33 +void
    8.34 +viewextend(Arg *arg)
    8.35 +{
    8.36 +	unsigned int i;
    8.37 +
    8.38 +	seltag[arg->i] = !seltag[arg->i];
    8.39 +	for(i = 0; !seltag[i] && i < ntags; i++);
    8.40 +	if(i == ntags)
    8.41 +		seltag[arg->i] = True; /* cannot toggle last view */
    8.42  	arrange(NULL);
    8.43  	drawall();
    8.44  }
    8.45 @@ -256,7 +269,7 @@
    8.46  {
    8.47  	unsigned int i;
    8.48  
    8.49 -	for(i = 0; !tsel[i]; i++);
    8.50 +	for(i = 0; !seltag[i]; i++);
    8.51  	arg->i = (i < ntags-1) ? i+1 : 0;
    8.52  	view(arg);
    8.53  }
    8.54 @@ -266,7 +279,7 @@
    8.55  {
    8.56  	unsigned int i;
    8.57  
    8.58 -	for(i = 0; !tsel[i]; i++);
    8.59 +	for(i = 0; !seltag[i]; i++);
    8.60  	arg->i = (i > 0) ? i-1 : ntags-1;
    8.61  	view(arg);
    8.62  }