Implemented /form help

This commit is contained in:
James Booth
2014-09-16 20:52:38 +01:00
parent 728f1f014b
commit 0d9a145d45
4 changed files with 63 additions and 13 deletions

View File

@@ -317,15 +317,16 @@ static struct cmd_t command_defs[] =
{ "/form",
cmd_form, parse_args, 1, 3, NULL,
{ "/form show|submit|cancel|set|add|remove [tag value]", "Form manipulation.",
{ "/form show|submit|cancel|set|add|remove [tag value]",
"---------------------------------------------------",
{ "/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",
@@ -1233,6 +1234,7 @@ cmd_init(void)
autocomplete_add(form_ac, "set");
autocomplete_add(form_ac, "add");
autocomplete_add(form_ac, "remove");
autocomplete_add(form_ac, "help");
cmd_history_init();
}

View File

@@ -634,12 +634,9 @@ cmd_help(gchar **args, struct cmd_help_t help)
}
cons_show("");
if (help_text != NULL) {
int i;
for (i = 0; help_text[i] != NULL; i++) {
cons_show(help_text[i]);
}
ProfWin *console = wins_get_console();
ui_show_lines(console, help_text);
} else {
cons_show("No such command.");
}
@@ -1806,6 +1803,7 @@ cmd_form(gchar **args, struct cmd_help_t help)
if ((g_strcmp0(args[0], "submit") != 0) &&
(g_strcmp0(args[0], "cancel") != 0) &&
(g_strcmp0(args[0], "show") != 0) &&
(g_strcmp0(args[0], "help") != 0) &&
(g_strcmp0(args[0], "set") != 0) &&
(g_strcmp0(args[0], "add") != 0) &&
(g_strcmp0(args[0], "remove") != 0)) {
@@ -1824,6 +1822,27 @@ cmd_form(gchar **args, struct cmd_help_t help)
return TRUE;
}
if (g_strcmp0(args[0], "help") == 0) {
char *tag = args[1];
if (tag != NULL) {
ui_show_form_field_help(current, current->form, tag);
} else {
ui_show_form_help(current, current->form);
const gchar **help_text = NULL;
Command *command = g_hash_table_lookup(commands, "/form");
if (command != NULL) {
help_text = command->help.long_help;
}
ui_show_lines(current, help_text);
}
ui_current_print_line("");
g_strfreev(split_recipient);
return TRUE;
}
if (g_strcmp0(args[0], "submit") == 0) {
iq_submit_room_config(room, current->form);