1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added autocompletion for form list-multi values

This commit is contained in:
James Booth 2014-09-17 23:03:03 +01:00
parent e42a0847a2
commit fa7b6f3000
3 changed files with 13 additions and 3 deletions

View File

@ -2128,7 +2128,7 @@ _form_autocomplete(char *input, int *size)
form_field_type_t field_type = form_get_field_type(form, tag);
// handle boolean (set)
if ((g_strcmp0(args[0], "set") == 0) && field_type == FIELD_BOOLEAN) {
if ((g_strcmp0(args[0], "set") == 0) && field_type == FIELD_BOOLEAN) {
found = autocomplete_param_with_func(input, size, beginning->str,
prefs_autocomplete_boolean_choice);
g_string_free(beginning, TRUE);
@ -2138,7 +2138,7 @@ _form_autocomplete(char *input, int *size)
}
// handle list-single (set)
if ((g_strcmp0(args[0], "set") == 0) && field_type == FIELD_LIST_SINGLE) {
if ((g_strcmp0(args[0], "set") == 0) && field_type == FIELD_LIST_SINGLE) {
Autocomplete ac = form_get_value_ac(form, tag);
found = autocomplete_param_with_ac(input, size, beginning->str, ac, TRUE);
g_string_free(beginning, TRUE);
@ -2148,6 +2148,15 @@ _form_autocomplete(char *input, int *size)
}
// handle list-multi (add, remove)
if (((g_strcmp0(args[0], "set") == 0) || (g_strcmp0(args[0], "remove") == 0))
&& field_type == FIELD_LIST_MULTI) {
Autocomplete ac = form_get_value_ac(form, tag);
found = autocomplete_param_with_ac(input, size, beginning->str, ac, TRUE);
g_string_free(beginning, TRUE);
if (found != NULL) {
return found;
}
}
// handle text-multi (remove)

View File

@ -242,7 +242,7 @@ form_create(xmpp_stanza_t * const form_stanza)
option->label = _get_attr(field_child, "label");
option->value = _get_property(field_child, "value");
if (field->type_t == FIELD_LIST_SINGLE) {
if ((field->type_t == FIELD_LIST_SINGLE) || (field->type_t == FIELD_LIST_MULTI)) {
autocomplete_add(field->value_ac, option->value);
}

View File

@ -39,6 +39,7 @@ _new_field(void)
field->options = NULL;
field->var = NULL;
field->values = NULL;
field->value_ac = NULL;
return field;