diff libnnchat.c @ 116:741e45592522

Add simple "prediction" into tab-completion based on previously gotten last match. We assume that the last match is what the user wants, if new pattern matches previous pattern.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 24 Oct 2010 23:09:42 +0300
parents f323b137ca08
children 701c54a45466
line wrap: on
line diff
--- a/libnnchat.c	Sun Oct 24 21:52:19 2010 +0300
+++ b/libnnchat.c	Sun Oct 24 23:09:42 2010 +0300
@@ -653,7 +653,7 @@
 }
 
 
-nn_user_t *nn_user_match(const nn_userhash_t *list, const char *pattern, const char *current)
+nn_user_t *nn_user_match(const nn_userhash_t *list, const char *pattern, const char *current, BOOL again)
 {
     uint8_t hash;
     
@@ -668,6 +668,8 @@
             nn_user_t *found = NULL;
             while (curr != NULL) {
                 if (strcasecmp(curr->name, current) == 0) {
+                    if (again)
+                        return curr;
                     found = curr->next;
                     break;
                 }
@@ -679,6 +681,7 @@
                 curr = list->buckets[hash];
         }
         
+
         while (curr != NULL) {
             if (len <= strlen(curr->name) && strncasecmp(curr->name, pattern, len) == 0)
                 return curr;