diff options
author | arg@f00b4r | 2007-07-24 18:19:09 +0200 |
---|---|---|
committer | arg@f00b4r | 2007-07-24 18:19:09 +0200 |
commit | 11cb2e7dcc341e8c7409b26420a18de3fea99323 (patch) | |
tree | 53c629bd8d2e5d302420dc59dd42c16fda211918 | |
parent | 07239bbddd22a6333495e3fab4e0a1e4878b0ca9 (diff) |
applied ido-matching to dmenu
-rw-r--r-- | main.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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 |