1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Use varargs in win_println_indent

This commit is contained in:
James Booth 2016-10-15 21:05:26 +01:00
parent c814cb44b8
commit f3aebd547c
4 changed files with 24 additions and 10 deletions

View File

@ -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]);
}
}

View File

@ -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, ...);

View File

@ -1113,6 +1113,26 @@ win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char
va_end(arg);
}
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, ...)
{
@ -1206,12 +1226,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)
{

View File

@ -530,7 +530,7 @@ void win_show_occupant(ProfWin *window, Occupant *occupant) {}
void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant) {}
void win_show_contact(ProfWin *window, PContact contact) {}
void win_show_info(ProfWin *window, PContact contact) {}
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_clear(ProfWin *window) {}
char* win_to_string(ProfWin *window)
{