applied ido-matching to dmenu
11cb2e7d
1 file(s) · +21 −0
| 168 | 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 | 179 | static void |
|
| 172 | 180 | match(char *pattern) { |
|
| 173 | 181 | unsigned int plen; |
|
| 192 | 200 | for(i = allitems; i; i=i->next) |
|
| 193 | 201 | if(plen && strncmp(pattern, i->text, plen) |
|
| 194 | 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 | 216 | if(!j) |
|
| 196 | 217 | item = i; |
|
| 197 | 218 | else |
|