C++ish declarations should be removed. Patch attached.

On Thu, Nov 11, 2010 at 11:41:58AM +0000, Connor Lane Smith wrote:
> 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 20:15:02 2010 +0200
@@ -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;
@@ -174,6 +175,7 @@
        char buf[32];
        size_t len;
        KeySym ksym;
+       Item *item;
 
        len = strlen(text);
        XLookupString(ev, buf, sizeof buf, &ksym, NULL);
@@ -295,7 +297,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 = sel; item; item = item->right)
+                               puts(item->text);
+                       for(item = matches; item != sel; item = item->right)
+                               puts(item->text);
+               }
                fflush(stdout);
                exit(EXIT_SUCCESS);
        case XK_Right:
@@ -491,7 +502,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 +520,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