[hackers] [dmenu] instant ^E || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Sat, 14 May 2011 19:39:37 +0200 (CEST)

changeset: 394:9448d6224fb5
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Sat May 14 18:39:27 2011 +0100
files: dmenu.c
description:
instant ^E

diff -r 2f8885a529d3 -r 9448d6224fb5 dmenu.c
--- a/dmenu.c Sat May 14 17:47:12 2011 +0100
+++ b/dmenu.c Sat May 14 18:39:27 2011 +0100
@@ -55,8 +55,8 @@
 static Bool topbar = True;
 static DC *dc;
 static Item *items = NULL;
-static Item *matches, *sel;
-static Item *prev, *curr, *next;
+static Item *matches, *matchend;
+static Item *prev, *curr, *next, *sel;
 static Window root, win;
 
 static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
@@ -308,12 +308,15 @@
                         cursor = len;
                         break;
                 }
- while(next) {
- sel = curr = next;
+ if(next) {
+ curr = matchend;
                         calcoffsets();
+ curr = prev;
+ calcoffsets();
+ while(next && (curr = curr->right))
+ calcoffsets();
                 }
- while(sel && sel->right)
- sel = sel->right;
+ sel = matchend;
                 break;
         case XK_Escape:
                 exit(EXIT_FAILURE);
@@ -381,10 +384,10 @@
 void
 match(void) {
         size_t len;
- Item *item, *itemend, *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend;
+ Item *item, *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend;
 
         len = strlen(text);
- matches = lexact = lprefix = lsubstr = itemend = exactend = prefixend = substrend = NULL;
+ matches = lexact = lprefix = lsubstr = matchend = exactend = prefixend = substrend = NULL;
         for(item = items; item && item->text; item++)
                 if(!fstrncmp(text, item->text, len + 1))
                         appenditem(item, &lexact, &exactend);
@@ -395,24 +398,25 @@
 
         if(lexact) {
                 matches = lexact;
- itemend = exactend;
+ matchend = exactend;
         }
         if(lprefix) {
- if(itemend) {
- itemend->right = lprefix;
- lprefix->left = itemend;
+ if(matchend) {
+ matchend->right = lprefix;
+ lprefix->left = matchend;
                 }
                 else
                         matches = lprefix;
- itemend = prefixend;
+ matchend = prefixend;
         }
         if(lsubstr) {
- if(itemend) {
- itemend->right = lsubstr;
- lsubstr->left = itemend;
+ if(matchend) {
+ matchend->right = lsubstr;
+ lsubstr->left = matchend;
                 }
                 else
                         matches = lsubstr;
+ matchend = substrend;
         }
         curr = sel = matches;
         calcoffsets();
Received on Sat May 14 2011 - 19:39:37 CEST

This archive was generated by hypermail 2.2.0 : Sat May 14 2011 - 19:48:06 CEST