applied ido-matching to dmenu
This commit is contained in:
parent
07239bbddd
commit
11cb2e7dcc
21
main.c
21
main.c
@ -168,6 +168,14 @@ initfont(const char *fontstr) {
|
|||||||
dc.font.height = dc.font.ascent + dc.font.descent;
|
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
|
static void
|
||||||
match(char *pattern) {
|
match(char *pattern) {
|
||||||
unsigned int plen;
|
unsigned int plen;
|
||||||
@ -201,6 +209,19 @@ match(char *pattern) {
|
|||||||
j = i;
|
j = i;
|
||||||
nitem++;
|
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
|
||||||
|
j->right = i;
|
||||||
|
i->left = j;
|
||||||
|
i->right = NULL;
|
||||||
|
j = i;
|
||||||
|
nitem++;
|
||||||
|
}
|
||||||
curr = prev = next = sel = item;
|
curr = prev = next = sel = item;
|
||||||
calcoffsets();
|
calcoffsets();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user