mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Updated help category output
This commit is contained in:
parent
cb7504e67f
commit
36ebf0fc17
@ -3702,26 +3702,6 @@ command_docgen(void)
|
|||||||
while (curr) {
|
while (curr) {
|
||||||
Command *pcmd = curr->data;
|
Command *pcmd = curr->data;
|
||||||
|
|
||||||
|
|
||||||
// old style
|
|
||||||
if (pcmd->help.usage) {
|
|
||||||
// fprintf(toc_fragment, "<a href=\"#%s\">%s</a>,\n", &pcmd->cmd[1], pcmd->cmd);
|
|
||||||
// fprintf(main_fragment, "<a name=\"%s\"></a>\n", &pcmd->cmd[1]);
|
|
||||||
// fprintf(main_fragment, "<h4>%s</h4>\n", pcmd->cmd);
|
|
||||||
// fputs("<p>Usage:</p>\n", main_fragment);
|
|
||||||
// fprintf(main_fragment, "<p><pre><code>%s</code></pre></p>\n", pcmd->help.usage);
|
|
||||||
//
|
|
||||||
// fputs("<p>Details:</p>\n", main_fragment);
|
|
||||||
// fputs("<p><pre><code>", main_fragment);
|
|
||||||
// int i = 2;
|
|
||||||
// while (pcmd->help.long_help[i]) {
|
|
||||||
// fprintf(main_fragment, "%s\n", pcmd->help.long_help[i++]);
|
|
||||||
// }
|
|
||||||
// fputs("</code></pre></p>\n<a href=\"#top\"><h5>back to top</h5></a><br><hr>\n", main_fragment);
|
|
||||||
// fputs("\n", main_fragment);
|
|
||||||
|
|
||||||
// new style
|
|
||||||
} else {
|
|
||||||
fprintf(toc_fragment, "<a href=\"#%s\">%s</a>,\n", &pcmd->cmd[1], pcmd->cmd);
|
fprintf(toc_fragment, "<a href=\"#%s\">%s</a>,\n", &pcmd->cmd[1], pcmd->cmd);
|
||||||
fprintf(main_fragment, "<a name=\"%s\"></a>\n", &pcmd->cmd[1]);
|
fprintf(main_fragment, "<a name=\"%s\"></a>\n", &pcmd->cmd[1]);
|
||||||
fprintf(main_fragment, "<h4>%s</h4>\n", pcmd->cmd);
|
fprintf(main_fragment, "<h4>%s</h4>\n", pcmd->cmd);
|
||||||
@ -3775,7 +3755,7 @@ command_docgen(void)
|
|||||||
|
|
||||||
fputs("<a href=\"#top\"><h5>back to top</h5></a><br><hr>\n", main_fragment);
|
fputs("<a href=\"#top\"><h5>back to top</h5></a><br><hr>\n", main_fragment);
|
||||||
fputs("\n", main_fragment);
|
fputs("\n", main_fragment);
|
||||||
}
|
|
||||||
curr = g_list_next(curr);
|
curr = g_list_next(curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3783,5 +3763,6 @@ command_docgen(void)
|
|||||||
|
|
||||||
fclose(toc_fragment);
|
fclose(toc_fragment);
|
||||||
fclose(main_fragment);
|
fclose(main_fragment);
|
||||||
|
printf("\nProcessed %d commands.\n\n", g_list_length(cmds));
|
||||||
g_list_free(cmds);
|
g_list_free(cmds);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,6 @@ static void _update_presence(const resource_presence_t presence,
|
|||||||
static gboolean _cmd_set_boolean_preference(gchar *arg, struct cmd_help_t help,
|
static gboolean _cmd_set_boolean_preference(gchar *arg, struct cmd_help_t help,
|
||||||
const char * const display, preference_t pref);
|
const char * const display, preference_t pref);
|
||||||
static void _cmd_show_filtered_help(char *heading, gchar *cmd_filter[], int filter_size);
|
static void _cmd_show_filtered_help(char *heading, gchar *cmd_filter[], int filter_size);
|
||||||
static gint _compare_commands(Command *a, Command *b);
|
|
||||||
static void _who_room(ProfWin *window, gchar **args, struct cmd_help_t help);
|
static void _who_room(ProfWin *window, gchar **args, struct cmd_help_t help);
|
||||||
static void _who_roster(ProfWin *window, gchar **args, struct cmd_help_t help);
|
static void _who_roster(ProfWin *window, gchar **args, struct cmd_help_t help);
|
||||||
|
|
||||||
@ -779,8 +778,8 @@ cmd_help(ProfWin *window, gchar **args, struct cmd_help_t help)
|
|||||||
cons_help();
|
cons_help();
|
||||||
} else if (strcmp(args[0], "commands") == 0) {
|
} else if (strcmp(args[0], "commands") == 0) {
|
||||||
cons_show("");
|
cons_show("");
|
||||||
cons_show("All commands");
|
ProfWin *console = wins_get_console();
|
||||||
cons_show("");
|
win_print(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "All commands");
|
||||||
|
|
||||||
GList *ordered_commands = NULL;
|
GList *ordered_commands = NULL;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
@ -789,15 +788,36 @@ cmd_help(ProfWin *window, gchar **args, struct cmd_help_t help)
|
|||||||
|
|
||||||
g_hash_table_iter_init(&iter, commands);
|
g_hash_table_iter_init(&iter, commands);
|
||||||
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
||||||
ordered_commands = g_list_insert_sorted(ordered_commands, value, (GCompareFunc)_compare_commands);
|
Command *pcmd = (Command *)value;
|
||||||
|
ordered_commands = g_list_insert_sorted(ordered_commands, pcmd->cmd, (GCompareFunc)g_strcmp0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int maxlen = 0;
|
||||||
GList *curr = ordered_commands;
|
GList *curr = ordered_commands;
|
||||||
while (curr) {
|
while (curr) {
|
||||||
Command *cmd = curr->data;
|
gchar *cmd = curr->data;
|
||||||
cons_show("%-13s: %s", cmd->cmd, cmd->help.short_help);
|
int len = strlen(cmd);
|
||||||
|
if (len > maxlen) maxlen = len;
|
||||||
curr = g_list_next(curr);
|
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(ordered_commands);
|
||||||
g_list_free(curr);
|
g_list_free(curr);
|
||||||
|
|
||||||
@ -4748,23 +4768,43 @@ _cmd_set_boolean_preference(gchar *arg, struct cmd_help_t help,
|
|||||||
static void
|
static void
|
||||||
_cmd_show_filtered_help(char *heading, gchar *cmd_filter[], int filter_size)
|
_cmd_show_filtered_help(char *heading, gchar *cmd_filter[], int filter_size)
|
||||||
{
|
{
|
||||||
|
ProfWin *console = wins_get_console();
|
||||||
cons_show("");
|
cons_show("");
|
||||||
cons_show("%s", heading);
|
win_print(console, '-', NULL, 0, THEME_WHITE_BOLD, "", heading);
|
||||||
cons_show("");
|
|
||||||
|
|
||||||
GList *ordered_commands = NULL;
|
GList *ordered_commands = NULL;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < filter_size; i++) {
|
for (i = 0; i < filter_size; i++) {
|
||||||
Command *cmd = g_hash_table_lookup(commands, cmd_filter[i]);
|
Command *pcmd = g_hash_table_lookup(commands, cmd_filter[i]);
|
||||||
ordered_commands = g_list_insert_sorted(ordered_commands, cmd, (GCompareFunc)_compare_commands);
|
ordered_commands = g_list_insert_sorted(ordered_commands, pcmd->cmd, (GCompareFunc)g_strcmp0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int maxlen = 0;
|
||||||
GList *curr = ordered_commands;
|
GList *curr = ordered_commands;
|
||||||
while (curr) {
|
while (curr) {
|
||||||
Command *cmd = curr->data;
|
gchar *cmd = curr->data;
|
||||||
cons_show("%-12s: %s", cmd->cmd, cmd->help.short_help);
|
int len = strlen(cmd);
|
||||||
|
if (len > maxlen) maxlen = len;
|
||||||
curr = g_list_next(curr);
|
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(ordered_commands);
|
||||||
g_list_free(curr);
|
g_list_free(curr);
|
||||||
|
|
||||||
@ -4772,20 +4812,3 @@ _cmd_show_filtered_help(char *heading, gchar *cmd_filter[], int filter_size)
|
|||||||
cons_show("Use /help [command] without the leading slash, for help on a specific command");
|
cons_show("Use /help [command] without the leading slash, for help on a specific command");
|
||||||
cons_show("");
|
cons_show("");
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
gint _compare_commands(Command *a, Command *b)
|
|
||||||
{
|
|
||||||
const char * utf8_str_a = a->cmd;
|
|
||||||
const char * utf8_str_b = b->cmd;
|
|
||||||
|
|
||||||
gchar *key_a = g_utf8_collate_key(utf8_str_a, -1);
|
|
||||||
gchar *key_b = g_utf8_collate_key(utf8_str_b, -1);
|
|
||||||
|
|
||||||
gint result = g_strcmp0(key_a, key_b);
|
|
||||||
|
|
||||||
g_free(key_a);
|
|
||||||
g_free(key_b);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
@ -1533,9 +1533,9 @@ cons_help(void)
|
|||||||
void
|
void
|
||||||
cons_navigation_help(void)
|
cons_navigation_help(void)
|
||||||
{
|
{
|
||||||
|
ProfWin *console = wins_get_console();
|
||||||
cons_show("");
|
cons_show("");
|
||||||
cons_show("Navigation:");
|
win_print(console, '-', NULL, 0, THEME_WHITE_BOLD, "", "Navigation");
|
||||||
cons_show("");
|
|
||||||
cons_show("Alt-1..Alt-0, F1..F10 : Choose window.");
|
cons_show("Alt-1..Alt-0, F1..F10 : Choose window.");
|
||||||
cons_show("Alt-LEFT, Alt-RIGHT : Previous/next chat window");
|
cons_show("Alt-LEFT, Alt-RIGHT : Previous/next chat window");
|
||||||
cons_show("PAGEUP, PAGEDOWN : Page the main window.");
|
cons_show("PAGEUP, PAGEDOWN : Page the main window.");
|
||||||
|
Loading…
Reference in New Issue
Block a user