1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-01 19:24:15 -04:00

Tidied cons_show_help

This commit is contained in:
James Booth 2016-02-18 20:52:52 +00:00
parent a14b7815ae
commit 639623d625
4 changed files with 47 additions and 50 deletions

View File

@ -1368,11 +1368,11 @@ cmd_help(ProfWin *window, const char *const command, gchar **args)
Command *command = g_hash_table_lookup(commands, cmd_with_slash); Command *command = g_hash_table_lookup(commands, cmd_with_slash);
if (command) { if (command) {
cons_show_help(command); cons_show_help(cmd_with_slash, &command->help);
} else { } else {
CommandHelp *commandHelp = plugins_get_help(cmd_with_slash); CommandHelp *commandHelp = plugins_get_help(cmd_with_slash);
if (commandHelp) { if (commandHelp) {
cons_show_plugin_help(cmd_with_slash, commandHelp); cons_show_help(cmd_with_slash, commandHelp);
} else { } else {
cons_show("No such command."); cons_show("No such command.");
} }

View File

@ -120,7 +120,7 @@ cons_show_padded(int pad, const char *const msg, ...)
} }
void void
cons_show_plugin_help(const char *const cmd, CommandHelp *help) cons_show_help(const char *const cmd, CommandHelp *help)
{ {
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
@ -162,48 +162,48 @@ cons_show_plugin_help(const char *const cmd, CommandHelp *help)
} }
} }
void //void
cons_show_help(Command *command) //cons_show_help(Command *command)
{ //{
ProfWin *console = wins_get_console(); // ProfWin *console = wins_get_console();
//
cons_show(""); // cons_show("");
win_vprint(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s", &command->cmd[1]); // win_vprint(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s", &command->cmd[1]);
win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE_BOLD, "", ""); // win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE_BOLD, "", "");
int i; // int i;
for (i = 0; i < strlen(command->cmd) - 1 ; i++) { // for (i = 0; i < strlen(command->cmd) - 1 ; i++) {
win_print(console, '-', 0, NULL, NO_EOL | NO_DATE, THEME_WHITE_BOLD, "", "-"); // win_print(console, '-', 0, NULL, NO_EOL | NO_DATE, THEME_WHITE_BOLD, "", "-");
} // }
win_print(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", ""); // win_print(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", "");
cons_show(""); // cons_show("");
//
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Synopsis"); // win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Synopsis");
ui_show_lines(console, command->help.synopsis); // ui_show_lines(console, command->help.synopsis);
cons_show(""); // cons_show("");
//
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Description"); // win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Description");
win_println(console, 0, command->help.desc); // win_println(console, 0, command->help.desc);
//
int maxlen = 0; // int maxlen = 0;
for (i = 0; command->help.args[i][0] != NULL; i++) { // for (i = 0; command->help.args[i][0] != NULL; i++) {
if (strlen(command->help.args[i][0]) > maxlen) // if (strlen(command->help.args[i][0]) > maxlen)
maxlen = strlen(command->help.args[i][0]); // maxlen = strlen(command->help.args[i][0]);
} // }
//
if (i > 0) { // if (i > 0) {
cons_show(""); // cons_show("");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Arguments"); // win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Arguments");
for (i = 0; command->help.args[i][0] != NULL; i++) { // for (i = 0; command->help.args[i][0] != NULL; i++) {
win_vprint(console, '-', maxlen + 3, NULL, 0, 0, "", "%-*s: %s", maxlen + 1, command->help.args[i][0], command->help.args[i][1]); // win_vprint(console, '-', maxlen + 3, NULL, 0, 0, "", "%-*s: %s", maxlen + 1, command->help.args[i][0], command->help.args[i][1]);
} // }
} // }
//
if (g_strv_length((gchar**)command->help.examples) > 0) { // if (g_strv_length((gchar**)command->help.examples) > 0) {
cons_show(""); // cons_show("");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Examples"); // win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Examples");
ui_show_lines(console, command->help.examples); // ui_show_lines(console, command->help.examples);
} // }
} //}
void void
cons_bad_cmd_usage(const char *const cmd) cons_bad_cmd_usage(const char *const cmd)

View File

@ -230,8 +230,7 @@ void cons_show(const char *const msg, ...);
void cons_show_padded(int pad, const char *const msg, ...); void cons_show_padded(int pad, const char *const msg, ...);
void cons_about(void); void cons_about(void);
void cons_help(void); void cons_help(void);
void cons_show_help(Command *command); void cons_show_help(const char *const cmd, CommandHelp *help);
void cons_show_plugin_help(const char *const cmd, CommandHelp *help);
void cons_bad_cmd_usage(const char *const cmd); void cons_bad_cmd_usage(const char *const cmd);
void cons_navigation_help(void); void cons_navigation_help(void);
void cons_prefs(void); void cons_prefs(void);

View File

@ -321,9 +321,7 @@ void cons_show(const char * const msg, ...)
void cons_show_padded(int pad, const char * const msg, ...) {} void cons_show_padded(int pad, const char * const msg, ...) {}
void cons_show_help(Command *command) {} void cons_show_help(const char *const cmd, CommandHelp *help) {}
void cons_show_plugin_help(const char *const cmd, CommandHelp *help) {}
void cons_about(void) {} void cons_about(void) {}
void cons_help(void) {} void cons_help(void) {}