Moved help and about to new format

This commit is contained in:
James Booth
2015-07-23 23:05:33 +01:00
parent 3985f22250
commit 22111bf75b
6 changed files with 244 additions and 111 deletions

View File

@@ -105,6 +105,42 @@ cons_show(const char * const msg, ...)
va_end(arg);
}
void
cons_show_help(Command *command)
{
ProfWin *console = wins_get_console();
cons_show("");
cons_show("Synopsis:");
ui_show_lines(console, command->help.synopsis);
cons_show("");
cons_show("Description:");
win_println(console, command->help.desc);
int i;
int maxlen = 0;
for (i = 0; command->help.args[i][0] != NULL; i++) {
if (strlen(command->help.args[i][0]) > maxlen)
maxlen = strlen(command->help.args[i][0]);
}
if (i > 0) {
cons_show("");
cons_show("Arguments:");
for (i = 0; command->help.args[i][0] != NULL; i++) {
win_vprint(console, '-', 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) {
cons_show("");
cons_show("Examples:");
ui_show_lines(console, command->help.examples);
}
}
void
cons_show_error(const char * const msg, ...)
{

View File

@@ -35,6 +35,7 @@
#ifndef UI_UI_H
#define UI_UI_H
#include "command/commands.h"
#include "ui/win_types.h"
#include "muc.h"
@@ -241,6 +242,7 @@ void ui_inp_history_append(char *inp);
void cons_show(const char * const msg, ...);
void cons_about(void);
void cons_help(void);
void cons_show_help(Command *command);
void cons_navigation_help(void);
void cons_prefs(void);
void cons_show_ui_prefs(void);