suckless-patches / dwm-nextprevtag.inc

# HG changeset patch
# Parent acb761a37f956b8744fffffff3998111c0c1465e
# Date 1294784199 -3600
# User Julien Jehannet <julien@smaf.org>

void
view_adjacent(const Arg *arg)
{
	int i, curtags;
	int seltag = 0;
	Arg a;

	curtags = selmon->tagset[selmon->seltags];
	for(i = 0; i < LENGTH(tags); i++)
		if(curtags & (1 << i)){
			seltag = i;
			break;
		}

	seltag = (seltag + arg->i) % (int)LENGTH(tags);
	if(seltag < 0)
		seltag += LENGTH(tags);

	a.i = (1 << seltag);
	view(&a);
}

diff --git a/config.h b/config.h
--- a/config.h
+++ b/config.h
@@ -36,10 +36,11 @@ static const float mfact      = 0.55; /*
 static const int nmaster      = 1;    /* number of clients in master area */
 static const Bool resizehints = True; /* True means respect size hints in tiled resizals */
 
 #include "bstack.c"
 #include "bstackhoriz.c"
+#include "nextprevtag.c"
 static const Layout layouts[] = {
 	/* symbol     arrange function */
 	{ "τ",        tile },    /* first entry is default */
 	{ "≈",        NULL },    /* no layout function means floating behavior */
 	{ "⇔",        monocle },
@@ -135,7 +136,9 @@ static Button buttons[] = {
 	{ ClkClientWin,         MODKEY,         Button3,        resizemouse,    {0} },
 	{ ClkTagBar,            0,              Button1,        view,           {0} },
 	{ ClkTagBar,            0,              Button3,        toggleview,     {0} },
 	{ ClkTagBar,            MODKEY,         Button1,        tag,            {0} },
 	{ ClkTagBar,            MODKEY,         Button3,        toggletag,      {0} },
+	{ ClkTagBar,            0,              Button4,        view_adjacent,  { .i = -1 } },
+	{ ClkTagBar,            0,              Button5,        view_adjacent,  { .i = +1 } },
 };
 
diff --git a/nextprevtag.c b/nextprevtag.c
new file mode 100644
--- /dev/null
+++ b/nextprevtag.c
@@ -0,0 +1,21 @@
+void
+view_adjacent(const Arg *arg)
+{
+	int i, curtags;
+	int seltag = 0;
+	Arg a;
+
+	curtags = selmon->tagset[selmon->seltags];
+	for(i = 0; i < LENGTH(tags); i++)
+		if(curtags & (1 << i)){
+			seltag = i;
+			break;
+		}
+
+	seltag = (seltag + arg->i) % (int)LENGTH(tags);
+	if(seltag < 0)
+		seltag += LENGTH(tags);
+
+	a.i = (1 << seltag);
+	view(&a);
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.