aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarg@f00b4r <unknown>2007-07-24 18:19:09 +0200
committerarg@f00b4r <unknown>2007-07-24 18:19:09 +0200
commit11cb2e7dcc341e8c7409b26420a18de3fea99323 (patch)
tree53c629bd8d2e5d302420dc59dd42c16fda211918
parent07239bbddd22a6333495e3fab4e0a1e4878b0ca9 (diff)
applied ido-matching to dmenu
-rw-r--r--main.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/main.c b/main.c
index 9c10958..bf53763 100644
--- a/main.c
+++ b/main.c
@@ -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
171static int
172strido(const char *text, const char *pattern) {
173 for(; *text && *pattern; text++)
174 if (*text == *pattern)
175 pattern++;
176 return !*pattern;
177}
178
171static void 179static void
172match(char *pattern) { 180match(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