about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-02-18 01:20:17 +0000
committerJames Booth <boothj5@gmail.com>2016-02-18 01:20:37 +0000
commita14b7815ae86bb1d552197d32c215157aaa4dc10 (patch)
tree656155d5eea213f173ed778d5d14a00c7ebcdac9 /src/ui
parent2ac911618a89c1a67a6fcf679b99a84a2ba94339 (diff)
downloadprofani-tty-a14b7815ae86bb1d552197d32c215157aaa4dc10.tar.gz
Added new help format to c plugins WIP
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/console.c43
-rw-r--r--src/ui/ui.h1
2 files changed, 44 insertions, 0 deletions
diff --git a/src/ui/console.c b/src/ui/console.c
index f4ce0e3c..aaf502f2 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -120,6 +120,49 @@ cons_show_padded(int pad, const char *const msg, ...)
 }
 
 void
+cons_show_plugin_help(const char *const cmd, CommandHelp *help)
+{
+    ProfWin *console = wins_get_console();
+
+    cons_show("");
+    win_vprint(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s", &cmd[1]);
+    win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE_BOLD, "", "");
+    int i;
+    for (i = 0; i < strlen(cmd) - 1 ; i++) {
+        win_print(console, '-', 0, NULL, NO_EOL | NO_DATE, THEME_WHITE_BOLD, "", "-");
+    }
+    win_print(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", "");
+    cons_show("");
+
+    win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Synopsis");
+    ui_show_lines(console, help->synopsis);
+    cons_show("");
+
+    win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Description");
+    win_println(console, 0, help->desc);
+
+    int maxlen = 0;
+    for (i = 0; help->args[i][0] != NULL; i++) {
+        if (strlen(help->args[i][0]) > maxlen)
+            maxlen = strlen(help->args[i][0]);
+    }
+
+    if (i > 0) {
+        cons_show("");
+        win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Arguments");
+        for (i = 0; help->args[i][0] != NULL; i++) {
+            win_vprint(console, '-', maxlen + 3, NULL, 0, 0, "", "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]);
+        }
+    }
+
+    if (g_strv_length((gchar**)help->examples) > 0) {
+        cons_show("");
+        win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Examples");
+        ui_show_lines(console, help->examples);
+    }
+}
+
+void
 cons_show_help(Command *command)
 {
     ProfWin *console = wins_get_console();
diff --git a/src/ui/ui.h b/src/ui/ui.h
index afca8448..a29c8f36 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -231,6 +231,7 @@ void cons_show_padded(int pad, const char *const msg, ...);
 void cons_about(void);
 void cons_help(void);
 void cons_show_help(Command *command);
+void cons_show_plugin_help(const char *const cmd, CommandHelp *help);
 void cons_bad_cmd_usage(const char *const cmd);
 void cons_navigation_help(void);
 void cons_prefs(void);