diff options
author | Connor Lane Smith <cls@lubutu.com> | 2011-05-14 18:39:27 +0100 |
---|---|---|
committer | Connor Lane Smith <cls@lubutu.com> | 2011-05-14 18:39:27 +0100 |
commit | 86468aafe52a94ce6ba1a3601a587c65724a61aa (patch) | |
tree | 710bf1aa90ec6919738e1572444d8ef009264c40 | |
parent | be9afce03548e8110744064d1c9c67795c13cdb6 (diff) |
instant ^E
-rw-r--r-- | dmenu.c | 36 |
1 files changed, 20 insertions, 16 deletions
@@ -55,8 +55,8 @@ static Atom utf8; | |||
55 | static Bool topbar = True; | 55 | static Bool topbar = True; |
56 | static DC *dc; | 56 | static DC *dc; |
57 | static Item *items = NULL; | 57 | static Item *items = NULL; |
58 | static Item *matches, *sel; | 58 | static Item *matches, *matchend; |
59 | static Item *prev, *curr, *next; | 59 | static Item *prev, *curr, *next, *sel; |
60 | static Window root, win; | 60 | static Window root, win; |
61 | 61 | ||
62 | static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; | 62 | static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; |
@@ -308,12 +308,15 @@ keypress(XKeyEvent *ev) { | |||
308 | cursor = len; | 308 | cursor = len; |
309 | break; | 309 | break; |
310 | } | 310 | } |
311 | while(next) { | 311 | if(next) { |
312 | sel = curr = next; | 312 | curr = matchend; |
313 | calcoffsets(); | 313 | calcoffsets(); |
314 | curr = prev; | ||
315 | calcoffsets(); | ||
316 | while(next && (curr = curr->right)) | ||
317 | calcoffsets(); | ||
314 | } | 318 | } |
315 | while(sel && sel->right) | 319 | sel = matchend; |
316 | sel = sel->right; | ||
317 | break; | 320 | break; |
318 | case XK_Escape: | 321 | case XK_Escape: |
319 | exit(EXIT_FAILURE); | 322 | exit(EXIT_FAILURE); |
@@ -381,10 +384,10 @@ keypress(XKeyEvent *ev) { | |||
381 | void | 384 | void |
382 | match(void) { | 385 | match(void) { |
383 | size_t len; | 386 | size_t len; |
384 | Item *item, *itemend, *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend; | 387 | Item *item, *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend; |
385 | 388 | ||
386 | len = strlen(text); | 389 | len = strlen(text); |
387 | matches = lexact = lprefix = lsubstr = itemend = exactend = prefixend = substrend = NULL; | 390 | matches = lexact = lprefix = lsubstr = matchend = exactend = prefixend = substrend = NULL; |
388 | for(item = items; item && item->text; item++) | 391 | for(item = items; item && item->text; item++) |
389 | if(!fstrncmp(text, item->text, len + 1)) | 392 | if(!fstrncmp(text, item->text, len + 1)) |
390 | appenditem(item, &lexact, &exactend); | 393 | appenditem(item, &lexact, &exactend); |
@@ -395,24 +398,25 @@ match(void) { | |||
395 | 398 | ||
396 | if(lexact) { | 399 | if(lexact) { |
397 | matches = lexact; | 400 | matches = lexact; |
398 | itemend = exactend; | 401 | matchend = exactend; |
399 | } | 402 | } |
400 | if(lprefix) { | 403 | if(lprefix) { |
401 | if(itemend) { | 404 | if(matchend) { |
402 | itemend->right = lprefix; | 405 | matchend->right = lprefix; |
403 | lprefix->left = itemend; | 406 | lprefix->left = matchend; |
404 | } | 407 | } |
405 | else | 408 | else |
406 | matches = lprefix; | 409 | matches = lprefix; |
407 | itemend = prefixend; | 410 | matchend = prefixend; |
408 | } | 411 | } |
409 | if(lsubstr) { | 412 | if(lsubstr) { |
410 | if(itemend) { | 413 | if(matchend) { |
411 | itemend->right = lsubstr; | 414 | matchend->right = lsubstr; |
412 | lsubstr->left = itemend; | 415 | lsubstr->left = matchend; |
413 | } | 416 | } |
414 | else | 417 | else |
415 | matches = lsubstr; | 418 | matches = lsubstr; |
419 | matchend = substrend; | ||
416 | } | 420 | } |
417 | curr = sel = matches; | 421 | curr = sel = matches; |
418 | calcoffsets(); | 422 | calcoffsets(); |