diff options
author | James Booth <boothj5@gmail.com> | 2014-09-16 20:52:38 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-09-16 20:52:38 +0100 |
commit | 0d9a145d453f9d6b4653d75e9ab7c3179f32c695 (patch) | |
tree | 147f621d71fa0a9e798c56be16b671ab9bc13f46 /src/command | |
parent | 728f1f014b9e63f8f093ebf411244673d9a9dbae (diff) | |
download | profani-tty-0d9a145d453f9d6b4653d75e9ab7c3179f32c695.tar.gz |
Implemented /form help
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/command.c | 8 | ||||
-rw-r--r-- | src/command/commands.c | 29 |
2 files changed, 29 insertions, 8 deletions
diff --git a/src/command/command.c b/src/command/command.c index 0f820a33..a60cf9e5 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -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(); } diff --git a/src/command/commands.c b/src/command/commands.c index e96d2f7a..fa439955 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -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); |