applied ido-matching to dmenu
authorarg@f00b4r <unknown>
Tue, 24 Jul 2007 16:19:09 +0000 (18:19 +0200)
committerarg@f00b4r <unknown>
Tue, 24 Jul 2007 16:19:09 +0000 (18:19 +0200)
main.c

diff --git a/main.c b/main.c
index 9c10958..bf53763 100644 (file)
--- a/main.c
+++ b/main.c
@@ -168,6 +168,14 @@ initfont(const char *fontstr) {
        dc.font.height = dc.font.ascent + dc.font.descent;
 }
 
+static int
+strido(const char *text, const char *pattern) {
+       for(; *text && *pattern; text++)
+               if (*text == *pattern)
+                       pattern++;
+       return !*pattern;
+}                                  
+
 static void
 match(char *pattern) {
        unsigned int plen;
@@ -192,6 +200,19 @@ match(char *pattern) {
        for(i = allitems; i; i=i->next)
                if(plen && strncmp(pattern, i->text, plen)
                                && strstr(i->text, pattern)) {
+                       if(!j)                               
+                               item = i;                              
+                       else                                     
+                               j->right = i;                          
+                       i->left = j;      
+                       i->right = NULL;                         
+                       j = i;                                      
+                       nitem++;                                       
+               }                                              
+       for(i = allitems; i; i=i->next)                            
+               if(plen && strncmp(pattern, i->text, plen)             
+                               && !strstr(i->text, pattern)          
+                               && strido(i->text,pattern)) { 
                        if(!j)
                                item = i;
                        else