mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge branch 'master' into plugins
This commit is contained in:
commit
16ac85fb62
@ -82,7 +82,7 @@ autocomplete_length(Autocomplete ac)
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
void
|
||||
autocomplete_add(Autocomplete ac, const char *item)
|
||||
{
|
||||
char *item_cpy;
|
||||
@ -90,21 +90,21 @@ autocomplete_add(Autocomplete ac, const char *item)
|
||||
|
||||
// if item already exists
|
||||
if (curr != NULL) {
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
item_cpy = strdup(item);
|
||||
ac->items = g_slist_insert_sorted(ac->items, item_cpy, (GCompareFunc)strcmp);
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
gboolean
|
||||
void
|
||||
autocomplete_remove(Autocomplete ac, const char * const item)
|
||||
{
|
||||
GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp);
|
||||
|
||||
if (!curr) {
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
// reset last found if it points to the item to be removed
|
||||
@ -115,7 +115,7 @@ autocomplete_remove(Autocomplete ac, const char * const item)
|
||||
free(curr->data);
|
||||
ac->items = g_slist_delete_link(ac->items, curr);
|
||||
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
GSList *
|
||||
|
@ -27,27 +27,33 @@
|
||||
|
||||
typedef char*(*autocomplete_func)(char *);
|
||||
typedef struct autocomplete_t *Autocomplete;
|
||||
typedef const char * (*PStrFunc)(const void *obj);
|
||||
typedef void * (*PCopyFunc)(const void *obj);
|
||||
typedef int (*PEqualFunc)(const void *o1, const void *o2);
|
||||
typedef int (*PEqualDeepFunc)(const void *o1, const void *o2);
|
||||
|
||||
// allocate new autocompleter with no items
|
||||
Autocomplete autocomplete_new(void);
|
||||
Autocomplete obj_autocomplete_new(PStrFunc str_func, PCopyFunc copy_func,
|
||||
PEqualDeepFunc equal_deep_func, GDestroyNotify free_func);
|
||||
|
||||
// Remove all items from the autocompleter
|
||||
void autocomplete_clear(Autocomplete ac);
|
||||
void autocomplete_reset(Autocomplete ac);
|
||||
|
||||
// free all memory used by the autocompleter
|
||||
void autocomplete_free(Autocomplete ac);
|
||||
gboolean autocomplete_add(Autocomplete ac, const char *item);
|
||||
gboolean autocomplete_remove(Autocomplete ac, const char * const item);
|
||||
GSList * autocomplete_get_list(Autocomplete ac);
|
||||
|
||||
void autocomplete_add(Autocomplete ac, const char *item);
|
||||
void autocomplete_remove(Autocomplete ac, const char * const item);
|
||||
|
||||
// find the next item prefixed with search string
|
||||
gchar * autocomplete_complete(Autocomplete ac, gchar *search_str);
|
||||
|
||||
GSList * autocomplete_get_list(Autocomplete ac);
|
||||
gint autocomplete_length(Autocomplete ac);
|
||||
|
||||
char * autocomplete_param_with_func(char *input, int *size, char *command,
|
||||
autocomplete_func func);
|
||||
|
||||
char * autocomplete_param_with_ac(char *input, int *size, char *command,
|
||||
Autocomplete ac);
|
||||
|
||||
char * autocomplete_param_no_with_func(char *input, int *size, char *command,
|
||||
int arg_number, autocomplete_func func);
|
||||
|
||||
void autocomplete_reset(Autocomplete ac);
|
||||
#endif
|
||||
|
@ -113,40 +113,6 @@ static void add_two_same_updates(void)
|
||||
autocomplete_clear(ac);
|
||||
}
|
||||
|
||||
static void add_one_returns_true(void)
|
||||
{
|
||||
Autocomplete ac = autocomplete_new();
|
||||
int result = autocomplete_add(ac, "Hello");
|
||||
|
||||
assert_true(result);
|
||||
|
||||
autocomplete_clear(ac);
|
||||
}
|
||||
|
||||
static void add_two_different_returns_true(void)
|
||||
{
|
||||
Autocomplete ac = autocomplete_new();
|
||||
int result1 = autocomplete_add(ac, "Hello");
|
||||
int result2 = autocomplete_add(ac, "Hello there");
|
||||
|
||||
assert_true(result1);
|
||||
assert_true(result2);
|
||||
|
||||
autocomplete_clear(ac);
|
||||
}
|
||||
|
||||
static void add_two_same_returns_false(void)
|
||||
{
|
||||
Autocomplete ac = autocomplete_new();
|
||||
int result1 = autocomplete_add(ac, "Hello");
|
||||
int result2 = autocomplete_add(ac, "Hello");
|
||||
|
||||
assert_true(result1);
|
||||
assert_false(result2);
|
||||
|
||||
autocomplete_clear(ac);
|
||||
}
|
||||
|
||||
void register_autocomplete_tests(void)
|
||||
{
|
||||
TEST_MODULE("autocomplete tests");
|
||||
@ -160,7 +126,4 @@ void register_autocomplete_tests(void)
|
||||
TEST(add_two_adds_two);
|
||||
TEST(add_two_same_adds_one);
|
||||
TEST(add_two_same_updates);
|
||||
TEST(add_one_returns_true);
|
||||
TEST(add_two_different_returns_true);
|
||||
TEST(add_two_same_returns_false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user