1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

Completion list is now sorted.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@360 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-06-17 13:16:42 +00:00 committed by cras
parent 8c60237fbe
commit f0d6ef99dc
3 changed files with 12 additions and 3 deletions

View File

@ -353,6 +353,11 @@ int g_istr_equal(gconstpointer v, gconstpointer v2)
return g_strcasecmp((const char *) v, (const char *) v2) == 0; return g_strcasecmp((const char *) v, (const char *) v2) == 0;
} }
int g_istr_cmp(gconstpointer v, gconstpointer v2)
{
return g_strcasecmp((const char *) v, (const char *) v2);
}
/* a char* hash function from ASU */ /* a char* hash function from ASU */
unsigned int g_istr_hash(gconstpointer v) unsigned int g_istr_hash(gconstpointer v)
{ {

View File

@ -40,6 +40,9 @@ char *convert_home(const char *path);
int g_istr_equal(gconstpointer v, gconstpointer v2); int g_istr_equal(gconstpointer v, gconstpointer v2);
unsigned int g_istr_hash(gconstpointer v); unsigned int g_istr_hash(gconstpointer v);
/* Case-insensitive GCompareFunc func */
int g_istr_cmp(gconstpointer v, gconstpointer v2);
/* Find `mask' from `data', you can use * and ? wildcards. */ /* Find `mask' from `data', you can use * and ? wildcards. */
int match_wildcards(const char *mask, const char *data); int match_wildcards(const char *mask, const char *data);

View File

@ -21,6 +21,7 @@
#include "module.h" #include "module.h"
#include "signals.h" #include "signals.h"
#include "commands.h" #include "commands.h"
#include "misc.h"
#include "lib-config/iconfig.h" #include "lib-config/iconfig.h"
#include "settings.h" #include "settings.h"
@ -194,7 +195,7 @@ static GList *completion_get_settings(const char *key)
SETTINGS_REC *rec = tmp->data; SETTINGS_REC *rec = tmp->data;
if (g_strncasecmp(rec->key, key, len) == 0) if (g_strncasecmp(rec->key, key, len) == 0)
complist = g_list_append(complist, g_strdup(rec->key)); complist = g_list_insert_sorted(complist, g_strdup(rec->key), (GCompareFunc) g_istr_cmp);
} }
g_slist_free(sets); g_slist_free(sets);
return complist; return complist;
@ -218,7 +219,7 @@ static GList *completion_get_commands(const char *cmd, char cmdchar)
if (g_strncasecmp(rec->cmd, cmd, len) == 0) { if (g_strncasecmp(rec->cmd, cmd, len) == 0) {
word = g_strdup_printf("%c%s", cmdchar, rec->cmd); word = g_strdup_printf("%c%s", cmdchar, rec->cmd);
if (glist_find_icase_string(complist, word) == NULL) if (glist_find_icase_string(complist, word) == NULL)
complist = g_list_append(complist, word); complist = g_list_insert_sorted(complist, word, (GCompareFunc) g_istr_cmp);
else else
g_free(word); g_free(word);
} }
@ -250,7 +251,7 @@ static GList *completion_get_subcommands(const char *cmd)
continue; continue;
if (g_strncasecmp(rec->cmd, cmd, len) == 0) if (g_strncasecmp(rec->cmd, cmd, len) == 0)
complist = g_list_append(complist, g_strdup(rec->cmd+skip)); complist = g_list_insert_sorted(complist, g_strdup(rec->cmd+skip), (GCompareFunc) g_istr_cmp);
} }
return complist; return complist;
} }