diff options
author | arg@f00b4r <unknown> | 2007-07-24 18:19:09 +0200 |
---|---|---|
committer | arg@f00b4r <unknown> | 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) { | |||
168 | dc.font.height = dc.font.ascent + dc.font.descent; | 168 | dc.font.height = dc.font.ascent + dc.font.descent; |
169 | } | 169 | } |
170 | 170 | ||
171 | static int | ||
172 | strido(const char *text, const char *pattern) { | ||
173 | for(; *text && *pattern; text++) | ||
174 | if (*text == *pattern) | ||
175 | pattern++; | ||
176 | return !*pattern; | ||
177 | } | ||
178 | |||
171 | static void | 179 | static void |
172 | match(char *pattern) { | 180 | match(char *pattern) { |
173 | unsigned int plen; | 181 | unsigned int plen; |
@@ -192,6 +200,19 @@ match(char *pattern) { | |||
192 | for(i = allitems; i; i=i->next) | 200 | for(i = allitems; i; i=i->next) |
193 | if(plen && strncmp(pattern, i->text, plen) | 201 | if(plen && strncmp(pattern, i->text, plen) |
194 | && strstr(i->text, pattern)) { | 202 | && strstr(i->text, pattern)) { |
203 | if(!j) | ||
204 | item = i; | ||
205 | else | ||
206 | j->right = i; | ||
207 | i->left = j; | ||
208 | i->right = NULL; | ||
209 | j = i; | ||
210 | nitem++; | ||
211 | } | ||
212 | for(i = allitems; i; i=i->next) | ||
213 | if(plen && strncmp(pattern, i->text, plen) | ||
214 | && !strstr(i->text, pattern) | ||
215 | && strido(i->text,pattern)) { | ||
195 | if(!j) | 216 | if(!j) |
196 | item = i; | 217 | item = i; |
197 | else | 218 | else |