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

Added autocomplete for setting room config form tags

This commit is contained in:
James Booth 2014-09-12 13:28:33 +01:00
parent 6c45f8ffae
commit 128a4a811f
3 changed files with 17 additions and 0 deletions

View File

@ -65,6 +65,7 @@
#include "xmpp/xmpp.h"
#include "xmpp/bookmark.h"
#include "ui/ui.h"
#include "ui/windows.h"
typedef char*(*autocompleter)(char*, int*);
@ -2078,6 +2079,17 @@ _room_autocomplete(char *input, int *size)
{
char *result = NULL;
ProfWin *current = wins_get_current();
if (current != NULL) {
DataForm *form = current->form;
if (form != NULL) {
result = autocomplete_param_with_ac(input, size, "/room set", form->tag_ac, TRUE);
if (result != NULL) {
return result;
}
}
}
result = autocomplete_param_with_ac(input, size, "/room", room_ac, TRUE);
if (result != NULL) {
return result;

View File

@ -190,6 +190,7 @@ form_create(xmpp_stanza_t * const form_stanza)
form->instructions = _get_property(form_stanza, "instructions");
form->var_to_tag = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
form->tag_to_var = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
form->tag_ac = autocomplete_new();
int tag_num = 1;
@ -210,6 +211,7 @@ form_create(xmpp_stanza_t * const form_stanza)
g_string_printf(tag, "field%d", tag_num++);
g_hash_table_insert(form->var_to_tag, strdup(field->var), strdup(tag->str));
g_hash_table_insert(form->tag_to_var, strdup(tag->str), strdup(field->var));
autocomplete_add(form->tag_ac, tag->str);
g_string_free(tag, TRUE);
field->description = _get_property(field_stanza, "desc");
@ -363,6 +365,7 @@ _form_destroy(DataForm *form)
g_slist_free_full(form->fields, (GDestroyNotify)_free_field);
g_hash_table_destroy(form->var_to_tag);
g_hash_table_destroy(form->tag_to_var);
autocomplete_free(form->tag_ac);
free(form);
}
}

View File

@ -40,6 +40,7 @@
#include "config/accounts.h"
#include "contact.h"
#include "jid.h"
#include "tools/autocomplete.h"
#define JABBER_PRIORITY_MIN -128
#define JABBER_PRIORITY_MAX 127
@ -123,6 +124,7 @@ typedef struct data_form_t {
GSList *fields;
GHashTable *var_to_tag;
GHashTable *tag_to_var;
Autocomplete tag_ac;
} DataForm;
void jabber_init_module(void);