Retagged commands

This commit is contained in:
James Booth
2015-07-27 23:55:04 +01:00
parent eb550eedb3
commit 08f43bee8e
4 changed files with 226 additions and 239 deletions

View File

@@ -780,144 +780,110 @@ cmd_help(ProfWin *window, const char * const command, gchar **args)
if (num_args == 0) {
cons_help();
} else if (strcmp(args[0], "commands") == 0) {
cons_show("");
ProfWin *console = wins_get_console();
win_print(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "All commands");
GList *ordered_commands = NULL;
GHashTableIter iter;
gpointer key;
gpointer value;
g_hash_table_iter_init(&iter, commands);
while (g_hash_table_iter_next(&iter, &key, &value)) {
Command *pcmd = (Command *)value;
ordered_commands = g_list_insert_sorted(ordered_commands, pcmd->cmd, (GCompareFunc)g_strcmp0);
}
int maxlen = 0;
GList *curr = ordered_commands;
while (curr) {
gchar *cmd = curr->data;
int len = strlen(cmd);
if (len > maxlen) maxlen = len;
curr = g_list_next(curr);
}
GString *cmds = g_string_new("");
curr = ordered_commands;
int count = 0;
while (curr) {
gchar *cmd = curr->data;
if (count == 5) {
cons_show(cmds->str);
g_string_free(cmds, TRUE);
cmds = g_string_new("");
count = 0;
if (args[1]) {
if (!cmd_valid_tag(args[1])) {
cons_bad_cmd_usage(command);
return TRUE;
}
g_string_append_printf(cmds, "%-*s", maxlen + 1, cmd);
curr = g_list_next(curr);
count++;
}
cons_show(cmds->str);
g_string_free(cmds, TRUE);
g_list_free(ordered_commands);
g_list_free(curr);
cons_show("");
cons_show("Use /help [command] without the leading slash, for help on a specific command");
cons_show("");
cons_show("");
ProfWin *console = wins_get_console();
win_vprint(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "%s commands", args[1]);
// } else if (strcmp(args[0], "basic") == 0) {
// gchar *filter[] = { "/about", "/clear", "/close", "/connect",
// "/disconnect", "/help", "/msg", "/join", "/quit", "/vercheck",
// "/wins", "/ping" };
// _cmd_show_filtered_help("Basic commands", filter, ARRAY_SIZE(filter));
//
// } else if (strcmp(args[0], "chatting") == 0) {
// gchar *filter[] = { "/chlog", "/otr", "/gone", "/history",
// "/info", "/intype", "/msg", "/notify", "/outtype", "/status",
// "/close", "/clear", "/tiny" };
// _cmd_show_filtered_help("Chat commands", filter, ARRAY_SIZE(filter));
//
// } else if (strcmp(args[0], "groupchat") == 0) {
// gchar *filter[] = { "/close", "/clear", "/decline", "/grlog",
// "/invite", "/invites", "/join", "/leave", "/notify", "/msg", "/room",
// "/rooms", "/tiny", "/who", "/nick", "/privileges", "/info", "/occupants" };
// _cmd_show_filtered_help("Groupchat commands", filter, ARRAY_SIZE(filter));
//
// } else if (strcmp(args[0], "presences") == 0) {
// gchar *filter[] = { "/autoaway", "/away", "/chat", "/dnd",
// "/online", "/priority", "/account", "/status", "/statuses", "/who",
// "/xa" };
// _cmd_show_filtered_help("Presence commands", filter, ARRAY_SIZE(filter));
//
// } else if (strcmp(args[0], "contacts") == 0) {
// gchar *filter[] = { "/group", "/roster", "/sub", "/who" };
// _cmd_show_filtered_help("Roster commands", filter, ARRAY_SIZE(filter));
//
// } else if (strcmp(args[0], "service") == 0) {
// gchar *filter[] = { "/caps", "/disco", "/info", "/software", "/rooms" };
// _cmd_show_filtered_help("Service discovery commands", filter, ARRAY_SIZE(filter));
//
// } else if (strcmp(args[0], "settings") == 0) {
// gchar *filter[] = { "/account", "/autoaway", "/autoping", "/autoconnect", "/beep",
// "/carbons", "/chlog", "/flash", "/gone", "/grlog", "/history", "/intype",
// "/log", "/notify", "/outtype", "/prefs", "/priority", "/reconnect", "/roster",
// "/splash", "/states", "/statuses", "/theme", "/titlebar", "/vercheck",
// "/privileges", "/occupants", "/presence", "/wrap", "/winstidy" };
// _cmd_show_filtered_help("Settings commands", filter, ARRAY_SIZE(filter));
//
} else if (cmd_is_tag(args[0])) {
cons_show("");
ProfWin *console = wins_get_console();
win_vprint(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "%s commands", args[0]);
GList *ordered_commands = NULL;
GHashTableIter iter;
gpointer key;
gpointer value;
GList *ordered_commands = NULL;
GHashTableIter iter;
gpointer key;
gpointer value;
g_hash_table_iter_init(&iter, commands);
while (g_hash_table_iter_next(&iter, &key, &value)) {
Command *pcmd = (Command *)value;
if (cmd_has_tag(pcmd, args[1])) {
ordered_commands = g_list_insert_sorted(ordered_commands, pcmd->cmd, (GCompareFunc)g_strcmp0);
}
}
g_hash_table_iter_init(&iter, commands);
while (g_hash_table_iter_next(&iter, &key, &value)) {
Command *pcmd = (Command *)value;
if (cmd_has_tag(pcmd, args[0])) {
int maxlen = 0;
GList *curr = ordered_commands;
while (curr) {
gchar *cmd = curr->data;
int len = strlen(cmd);
if (len > maxlen) maxlen = len;
curr = g_list_next(curr);
}
GString *cmds = g_string_new("");
curr = ordered_commands;
int count = 0;
while (curr) {
gchar *cmd = curr->data;
if (count == 5) {
cons_show(cmds->str);
g_string_free(cmds, TRUE);
cmds = g_string_new("");
count = 0;
}
g_string_append_printf(cmds, "%-*s", maxlen + 1, cmd);
curr = g_list_next(curr);
count++;
}
cons_show(cmds->str);
g_string_free(cmds, TRUE);
g_list_free(ordered_commands);
g_list_free(curr);
cons_show("");
cons_show("Use /help [command] without the leading slash, for help on a specific command");
cons_show("");
} else {
cons_show("");
ProfWin *console = wins_get_console();
win_print(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "All commands");
GList *ordered_commands = NULL;
GHashTableIter iter;
gpointer key;
gpointer value;
g_hash_table_iter_init(&iter, commands);
while (g_hash_table_iter_next(&iter, &key, &value)) {
Command *pcmd = (Command *)value;
ordered_commands = g_list_insert_sorted(ordered_commands, pcmd->cmd, (GCompareFunc)g_strcmp0);
}
}
int maxlen = 0;
GList *curr = ordered_commands;
while (curr) {
gchar *cmd = curr->data;
int len = strlen(cmd);
if (len > maxlen) maxlen = len;
curr = g_list_next(curr);
}
GString *cmds = g_string_new("");
curr = ordered_commands;
int count = 0;
while (curr) {
gchar *cmd = curr->data;
if (count == 5) {
cons_show(cmds->str);
g_string_free(cmds, TRUE);
cmds = g_string_new("");
count = 0;
int maxlen = 0;
GList *curr = ordered_commands;
while (curr) {
gchar *cmd = curr->data;
int len = strlen(cmd);
if (len > maxlen) maxlen = len;
curr = g_list_next(curr);
}
g_string_append_printf(cmds, "%-*s", maxlen + 1, cmd);
curr = g_list_next(curr);
count++;
}
cons_show(cmds->str);
g_string_free(cmds, TRUE);
g_list_free(ordered_commands);
g_list_free(curr);
cons_show("");
cons_show("Use /help [command] without the leading slash, for help on a specific command");
cons_show("");
GString *cmds = g_string_new("");
curr = ordered_commands;
int count = 0;
while (curr) {
gchar *cmd = curr->data;
if (count == 5) {
cons_show(cmds->str);
g_string_free(cmds, TRUE);
cmds = g_string_new("");
count = 0;
}
g_string_append_printf(cmds, "%-*s", maxlen + 1, cmd);
curr = g_list_next(curr);
count++;
}
cons_show(cmds->str);
g_string_free(cmds, TRUE);
g_list_free(ordered_commands);
g_list_free(curr);
cons_show("");
cons_show("Use /help [command] without the leading slash, for help on a specific command");
cons_show("");
}
} else if (strcmp(args[0], "navigation") == 0) {
cons_navigation_help();
} else {