changeset: 213:eba01cf4a1f2
tag: tip
user: arg_AT_f00b4r
date: Tue Jul 24 18:19:09 2007 +0200
summary: applied ido-matching to dmenu
diff -r 494de087c3ef -r eba01cf4a1f2 main.c
--- a/main.c Fri Jun 01 12:28:30 2007 +0200
+++ b/main.c Tue Jul 24 18:19:09 2007 +0200
@@ -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
Received on Tue Jul 24 2007 - 18:26:20 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:57:40 UTC