about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-07-23 23:05:33 +0100
committerJames Booth <boothj5@gmail.com>2015-07-23 23:05:33 +0100
commit22111bf75b34181cdab4f8369e781cb1d857fcfb (patch)
tree490fa6bec4df37a8a34c24f92c07ad16072085bb /src/ui
parent3985f22250bb5aca0036c707da47e51c662cee03 (diff)
downloadprofani-tty-22111bf75b34181cdab4f8369e781cb1d857fcfb.tar.gz
Moved help and about to new format
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/console.c36
-rw-r--r--src/ui/ui.h2
2 files changed, 38 insertions, 0 deletions
diff --git a/src/ui/console.c b/src/ui/console.c
index 98691a0a..9b18a599 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -106,6 +106,42 @@ cons_show(const char * const msg, ...)
 }
 
 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, ...)
 {
     ProfWin *console = wins_get_console();
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 637c8f75..58f1ee98 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -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);