about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-10-15 21:05:26 +0100
committerJames Booth <boothj5@gmail.com>2016-10-15 21:05:26 +0100
commitf3aebd547cb40818f5b87be66354e359447a54c7 (patch)
tree4c921e6b0d004a45ba34041a2cd0ca48f45c3644 /src/ui
parentc814cb44b8dafc04baf402cad7f7be165aa1ce6b (diff)
downloadprofani-tty-f3aebd547cb40818f5b87be66354e359447a54c7.tar.gz
Use varargs in win_println_indent
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/console.c4
-rw-r--r--src/ui/ui.h2
-rw-r--r--src/ui/window.c26
3 files changed, 23 insertions, 9 deletions
diff --git a/src/ui/console.c b/src/ui/console.c
index 2efe85b5..ff80750e 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -113,7 +113,7 @@ cons_show_padded(int pad, const char *const msg, ...)
     va_start(arg, msg);
     GString *fmt_msg = g_string_new(NULL);
     g_string_vprintf(fmt_msg, msg, arg);
-    win_println_indent(console, pad, fmt_msg->str);
+    win_println_indent(console, pad, "%s", fmt_msg->str);
     g_string_free(fmt_msg, TRUE);
     va_end(arg);
 }
@@ -150,7 +150,7 @@ cons_show_help(const char *const cmd, CommandHelp *help)
         cons_show("");
         win_println(console, THEME_WHITE_BOLD, '-', "Arguments");
         for (i = 0; help->args[i][0] != NULL; i++) {
-            win_printf(console, '-', maxlen + 3, NULL, 0, THEME_DEFAULT, "", "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]);
+            win_println_indent(console, maxlen + 3, "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]);
         }
     }
 
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 386b3eb4..6fb97b3e 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -361,7 +361,7 @@ void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime
 
 void win_print(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...);
 void win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...);
-void win_println_indent(ProfWin *window, int pad, const char *const message);
+void win_println_indent(ProfWin *window, int pad, const char *const message, ...);
 
 void win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...);
 void win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...);
diff --git a/src/ui/window.c b/src/ui/window.c
index 1b456768..6630c60b 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1114,6 +1114,26 @@ win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char
 }
 
 void
+win_println_indent(ProfWin *window, int pad, const char *const message, ...)
+{
+    GDateTime *timestamp = g_date_time_new_now_local();
+
+    va_list arg;
+    va_start(arg, message);
+    GString *fmt_msg = g_string_new(NULL);
+    g_string_vprintf(fmt_msg, message, arg);
+
+    buffer_push(window->layout->buffer, '-', pad, timestamp, 0, THEME_DEFAULT, "", fmt_msg->str, NULL);
+
+    _win_print(window, '-', pad, timestamp, 0, THEME_DEFAULT, "", fmt_msg->str, NULL);
+    inp_nonblocking(TRUE);
+    g_date_time_unref(timestamp);
+
+    g_string_free(fmt_msg, TRUE);
+    va_end(arg);
+}
+
+void
 win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...)
 {
     GDateTime *timestamp = g_date_time_new_now_local();
@@ -1207,12 +1227,6 @@ win_update_entry_theme(ProfWin *window, const char *const id, theme_item_t theme
 }
 
 void
-win_println_indent(ProfWin *window, int pad, const char *const message)
-{
-    win_printf(window, '-', pad, NULL, 0, THEME_DEFAULT, "", "%s", message);
-}
-
-void
 win_newline(ProfWin *window)
 {
     win_appendln(window, THEME_DEFAULT, "");