diff options
Diffstat (limited to 'src/command/command.c')
-rw-r--r-- | src/command/command.c | 82 |
1 files changed, 62 insertions, 20 deletions
diff --git a/src/command/command.c b/src/command/command.c index 6d707afe..6e233238 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -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*); @@ -86,7 +87,7 @@ static char * _statuses_autocomplete(char *input, int *size); static char * _alias_autocomplete(char *input, int *size); static char * _join_autocomplete(char *input, int *size); static char * _log_autocomplete(char *input, int *size); -static char * _room_autocomplete(char *input, int *size); +static char * _form_autocomplete(char *input, int *size); GHashTable *commands = NULL; @@ -305,11 +306,27 @@ static struct cmd_t command_defs[] = NULL } } }, { "/room", - cmd_room, parse_args, 2, 2, NULL, - { "/room config accept|cancel", "Room configuration.", - { "/room config accept|cncel", - "-------------------------", - "Accept or cancel default room configuration.", + cmd_room, parse_args, 1, 1, NULL, + { "/room accept|destroy|config", "Room configuration.", + { "/room accept|destroy|config", + "---------------------------", + "accept - Accept default room configuration.", + "destroy - Reject default room configuration.", + "config - Edit room configuration.", + NULL } } }, + + { "/form", + cmd_form, parse_args, 1, 3, NULL, + { "/form show|submit|cancel|set|add|remove|help [tag] [value]", "Form manipulation.", + { "/form show|submit|cancel|set|add|remove|help [tag] [value]", + "----------------------------------------------------------", + "set tag value - Set tagged form field to value.", + "add tag value - Add value to tagged form field.", + "remove tag value - Remove value from tagged form field.", + "show - Show the current form.", + "submit - Submit the current form.", + "cancel - Cancel changes to the current form.", + "help [tag] - Display help for form, or a specific field.", NULL } } }, { "/rooms", @@ -953,7 +970,7 @@ static Autocomplete alias_ac; static Autocomplete aliases_ac; static Autocomplete join_property_ac; static Autocomplete room_ac; -static Autocomplete room_config_ac; +static Autocomplete form_ac; /* * Initialise command autocompleter and history @@ -1206,11 +1223,18 @@ cmd_init(void) autocomplete_add(alias_ac, "list"); room_ac = autocomplete_new(); + autocomplete_add(room_ac, "accept"); + autocomplete_add(room_ac, "destroy"); autocomplete_add(room_ac, "config"); - room_config_ac = autocomplete_new(); - autocomplete_add(room_config_ac, "accept"); - autocomplete_add(room_config_ac, "cancel"); + form_ac = autocomplete_new(); + autocomplete_add(form_ac, "submit"); + autocomplete_add(form_ac, "cancel"); + autocomplete_add(form_ac, "show"); + autocomplete_add(form_ac, "set"); + autocomplete_add(form_ac, "add"); + autocomplete_add(form_ac, "remove"); + autocomplete_add(form_ac, "help"); cmd_history_init(); } @@ -1256,7 +1280,7 @@ cmd_uninit(void) autocomplete_free(aliases_ac); autocomplete_free(join_property_ac); autocomplete_free(room_ac); - autocomplete_free(room_config_ac); + autocomplete_free(form_ac); } gboolean @@ -1381,7 +1405,7 @@ cmd_reset_autocomplete() autocomplete_reset(aliases_ac); autocomplete_reset(join_property_ac); autocomplete_reset(room_ac); - autocomplete_reset(room_config_ac); + autocomplete_reset(form_ac); bookmark_autocomplete_reset(); } @@ -1631,8 +1655,8 @@ _cmd_complete_parameters(char *input, int *size) } } - gchar *cmds[] = { "/help", "/prefs", "/disco", "/close", "/wins" }; - Autocomplete completers[] = { help_ac, prefs_ac, disco_ac, close_ac, wins_ac }; + gchar *cmds[] = { "/help", "/prefs", "/disco", "/close", "/wins", "/room" }; + Autocomplete completers[] = { help_ac, prefs_ac, disco_ac, close_ac, wins_ac, room_ac }; for (i = 0; i < ARRAY_SIZE(cmds); i++) { result = autocomplete_param_with_ac(input, size, cmds[i], completers[i], TRUE); @@ -1660,7 +1684,7 @@ _cmd_complete_parameters(char *input, int *size) g_hash_table_insert(ac_funcs, "/statuses", _statuses_autocomplete); g_hash_table_insert(ac_funcs, "/alias", _alias_autocomplete); g_hash_table_insert(ac_funcs, "/join", _join_autocomplete); - g_hash_table_insert(ac_funcs, "/room", _room_autocomplete); + g_hash_table_insert(ac_funcs, "/form", _form_autocomplete); char parsed[*size+1]; i = 0; @@ -2071,16 +2095,34 @@ _theme_autocomplete(char *input, int *size) } static char * -_room_autocomplete(char *input, int *size) +_form_autocomplete(char *input, int *size) { char *result = NULL; - result = autocomplete_param_with_ac(input, size, "/room config", room_config_ac, TRUE); - if (result != NULL) { - return result; + ProfWin *current = wins_get_current(); + if (current != NULL) { + DataForm *form = current->form; + if (form != NULL) { + result = autocomplete_param_with_ac(input, size, "/form set", form->tag_ac, TRUE); + if (result != NULL) { + return result; + } + result = autocomplete_param_with_ac(input, size, "/form add", form->tag_ac, TRUE); + if (result != NULL) { + return result; + } + result = autocomplete_param_with_ac(input, size, "/form remove", form->tag_ac, TRUE); + if (result != NULL) { + return result; + } + result = autocomplete_param_with_ac(input, size, "/form help", form->tag_ac, TRUE); + if (result != NULL) { + return result; + } + } } - result = autocomplete_param_with_ac(input, size, "/room", room_ac, TRUE); + result = autocomplete_param_with_ac(input, size, "/form", form_ac, TRUE); if (result != NULL) { return result; } |