Hey,

On 11 November 2010 05:25, Dan Brown <danbr...@gmail.com> wrote:
> Why is this patch of interest? I call it "filtermode" because it uses
> dmenu to generate a list of matches, with interactivity similar to the
> trendy "instant" style of searching. For applications working with
> sets of items, this method could be faster than the existing
> dmenu-multiselect patch, in that it doesn't require the user to
> manually select each item they want. The basis for the patch is dmenu
> v4.1.1 .

I haven't got a use for this patch at the moment, but for anyone
interested I've ported the patch to tip, attached.

Thanks,
cls
diff -r 7057efb48ef3 dmenu.c
--- a/dmenu.c	Tue Nov 02 12:15:15 2010 +0000
+++ b/dmenu.c	Thu Nov 11 11:37:08 2010 +0000
@@ -54,6 +54,7 @@
 static unsigned long normcol[ColLast];
 static unsigned long selcol[ColLast];
 static Atom utf8;
+static Bool filter = False;
 static Bool topbar = True;
 static DC *dc;
 static Item *items = NULL;
@@ -295,7 +296,16 @@
 		break;
 	case XK_Return:
 	case XK_KP_Enter:
-		fputs((sel && !(ev->state & ShiftMask)) ? sel->text : text, stdout);
+		if((ev->state & ShiftMask) || !sel)
+			puts(text);
+		else if(!filter)
+			puts(sel->text);
+		else {
+			for(Item *item = sel; item; item = item->right)
+				puts(item->text);
+			for(Item *item = matches; item != sel; item = item->right)
+				puts(item->text);
+		}
 		fflush(stdout);
 		exit(EXIT_SUCCESS);
 	case XK_Right:
@@ -491,7 +501,7 @@
 
 void
 usage(void) {
-	fputs("usage: dmenu [-b] [-i] [-l lines] [-p prompt] [-fn font] [-nb color]\n"
+	fputs("usage: dmenu [-b] [-i] [-f] [-l lines] [-p prompt] [-fn font] [-nb color]\n"
 	      "             [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
 	exit(EXIT_FAILURE);
 }
@@ -509,6 +519,8 @@
 		}
 		else if(!strcmp(argv[i], "-b"))
 			topbar = False;
+		else if(!strcmp(argv[i], "-f"))
+			filter = True;
 		else if(!strcmp(argv[i], "-i"))
 			fstrncmp = strncasecmp;
 		else if(i == argc-1)

Reply via email to