Browse Source

applied ido-matching to dmenu

master
arg@f00b4r 17 years ago
parent
commit
11cb2e7dcc
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      main.c

+ 21
- 0
main.c View File

@ -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;
@ -192,6 +200,19 @@ match(char *pattern) {
for(i = allitems; i; i=i->next) for(i = allitems; i; i=i->next)
if(plen && strncmp(pattern, i->text, plen) if(plen && strncmp(pattern, i->text, plen)
&& strstr(i->text, pattern)) { && 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) if(!j)
item = i; item = i;
else else


Loading…
Cancel
Save