From 0890179fc42a7304dc03c76bd680e61a43f6e072 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 11 Oct 2016 23:38:59 +0100 Subject: [PATCH] Remove win_print, use win_printf instead --- src/command/cmd_funcs.c | 14 ++-- src/plugins/api.c | 6 +- src/ui/chatwin.c | 18 ++--- src/ui/console.c | 123 +++++++++++++++++------------------ src/ui/core.c | 30 ++++----- src/ui/mucconfwin.c | 66 +++++++++---------- src/ui/mucwin.c | 106 +++++++++++++++--------------- src/ui/privwin.c | 6 +- src/ui/ui.h | 4 +- src/ui/window.c | 84 ++++++++++++------------ src/ui/window_list.c | 2 +- src/ui/xmlwin.c | 12 ++-- tests/unittests/ui/stub_ui.c | 1 - 13 files changed, 230 insertions(+), 242 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 1d7d0b7f..0117029b 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1481,7 +1481,7 @@ _cmd_help_cmd_list(const char *const tag) if (tag) { win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s commands", tag); } else { - win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "All commands"); + win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "All commands"); } GList *ordered_commands = NULL; @@ -3942,7 +3942,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: "); win_printf(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); } else { - win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room has no subject"); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room has no subject"); } return TRUE; } @@ -4050,7 +4050,7 @@ cmd_affiliation(ProfWin *window, const char *const command, gchar **args) iq_room_affiliation_list(mucwin->roomjid, "member"); iq_room_affiliation_list(mucwin->roomjid, "outcast"); } else if (g_strcmp0(affiliation, "none") == 0) { - win_print((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no affiliation."); + win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no affiliation."); } else { iq_room_affiliation_list(mucwin->roomjid, affiliation); } @@ -4118,7 +4118,7 @@ cmd_role(ProfWin *window, const char *const command, gchar **args) iq_room_role_list(mucwin->roomjid, "participant"); iq_room_role_list(mucwin->roomjid, "visitor"); } else if (g_strcmp0(role, "none") == 0) { - win_print((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no role."); + win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no role."); } else { iq_room_role_list(mucwin->roomjid, role); } @@ -4180,12 +4180,12 @@ cmd_room(ProfWin *window, const char *const command, gchar **args) if (g_strcmp0(args[0], "accept") == 0) { gboolean requires_config = muc_requires_config(mucwin->roomjid); if (!requires_config) { - win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Current room does not require configuration."); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Current room does not require configuration."); return TRUE; } else { iq_confirm_instant_room(mucwin->roomjid); muc_set_requires_config(mucwin->roomjid, FALSE); - win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room unlocked."); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room unlocked."); return TRUE; } } @@ -4687,7 +4687,7 @@ cmd_tiny(ProfWin *window, const char *const command, gchar **args) char *tiny = tinyurl_get(url); if (!tiny) { - win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", "Couldn't create tinyurl."); + win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", "Couldn't create tinyurl."); return TRUE; } diff --git a/src/plugins/api.c b/src/plugins/api.c index b504237b..3de5efab 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -85,7 +85,7 @@ api_cons_show_themed(const char *const group, const char *const key, const char char *parsed = str_replace(message, "\r\n", "\n"); theme_item_t themeitem = plugin_themes_get(group, key, def); ProfWin *console = wins_get_console(); - win_print(console, '-', 0, NULL, 0, themeitem, "", parsed); + win_printf(console, '-', 0, NULL, 0, themeitem, "", parsed); free(parsed); @@ -368,7 +368,7 @@ api_win_show(const char *tag, const char *line) } ProfWin *window = (ProfWin*)pluginwin; - win_print(window, '!', 0, NULL, 0, 0, "", line); + win_printf(window, '!', 0, NULL, 0, 0, "", line); return 1; } @@ -393,7 +393,7 @@ api_win_show_themed(const char *tag, const char *const group, const char *const theme_item_t themeitem = plugin_themes_get(group, key, def); ProfWin *window = (ProfWin*)pluginwin; - win_print(window, '!', 0, NULL, 0, themeitem, "", line); + win_printf(window, '!', 0, NULL, 0, themeitem, "", line); return 1; } diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 7ea985ea..a0b53749 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -96,9 +96,9 @@ chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted) ProfWin *window = (ProfWin*) chatwin; if (trusted) { - win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "OTR session started (trusted)."); + win_printf(window, '!', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "OTR session started (trusted)."); } else { - win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_UNTRUSTED, "", "OTR session started (untrusted)."); + win_printf(window, '!', 0, NULL, 0, THEME_OTR_STARTED_UNTRUSTED, "", "OTR session started (untrusted)."); } if (wins_is_current(window)) { @@ -125,7 +125,7 @@ chatwin_otr_unsecured(ProfChatWin *chatwin) chatwin->otr_is_trusted = FALSE; ProfWin *window = (ProfWin*)chatwin; - win_print(window, '!', 0, NULL, 0, THEME_OTR_ENDED, "", "OTR session ended."); + win_printf(window, '!', 0, NULL, 0, THEME_OTR_ENDED, "", "OTR session ended."); if (wins_is_current(window)) { title_bar_switch(); } @@ -188,7 +188,7 @@ chatwin_otr_trust(ProfChatWin *chatwin) chatwin->otr_is_trusted = TRUE; ProfWin *window = (ProfWin*)chatwin; - win_print(window, '!', 0, NULL, 0, THEME_OTR_TRUSTED, "", "OTR session trusted."); + win_printf(window, '!', 0, NULL, 0, THEME_OTR_TRUSTED, "", "OTR session trusted."); if (wins_is_current(window)) { title_bar_switch(); } @@ -203,7 +203,7 @@ chatwin_otr_untrust(ProfChatWin *chatwin) chatwin->otr_is_trusted = FALSE; ProfWin *window = (ProfWin*)chatwin; - win_print(window, '!', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted."); + win_printf(window, '!', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted."); if (wins_is_current(window)) { title_bar_switch(); } @@ -308,7 +308,7 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, if (request_receipt && id) { win_print_with_receipt((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message, id); } else { - win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); + win_printf((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); } } @@ -322,7 +322,7 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_en enc_char = prefs_get_pgp_char(); } - win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); + win_printf((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); int num = wins_get_num((ProfWin*)chatwin); status_bar_active(num); } @@ -401,11 +401,11 @@ _chatwin_history(ProfChatWin *chatwin, const char *const contact) char mm[3]; memcpy(mm, &line[3], 2); mm[2] = '\0'; int imm = atoi(mm); char ss[3]; memcpy(ss, &line[6], 2); ss[2] = '\0'; int iss = atoi(ss); GDateTime *timestamp = g_date_time_new_local(2000, 1, 1, ihh, imm, iss); - win_print((ProfWin*)chatwin, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", curr->data+11); + win_printf((ProfWin*)chatwin, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", curr->data+11); g_date_time_unref(timestamp); // header } else { - win_print((ProfWin*)chatwin, '-', 0, NULL, 0, 0, "", curr->data); + win_printf((ProfWin*)chatwin, '-', 0, NULL, 0, 0, "", curr->data); } curr = g_slist_next(curr); } diff --git a/src/ui/console.c b/src/ui/console.c index 139d0bb3..46c06b71 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -67,14 +67,14 @@ void cons_show_time(void) { ProfWin *console = wins_get_console(); - win_print(console, '-', 0, NULL, NO_EOL, 0, "", ""); + win_printf(console, '-', 0, NULL, NO_EOL, 0, "", ""); } void cons_show_word(const char *const word) { ProfWin *console = wins_get_console(); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", word); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", word); } void @@ -125,19 +125,19 @@ cons_show_help(const char *const cmd, CommandHelp *help) cons_show(""); win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s", &cmd[1]); - win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE_BOLD, "", ""); + win_printf(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_printf(console, '-', 0, NULL, NO_EOL | NO_DATE, THEME_WHITE_BOLD, "", "-"); } - win_print(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", ""); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", ""); cons_show(""); - win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Synopsis"); + win_printf(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_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Description"); win_println(console, 0, help->desc); int maxlen = 0; @@ -148,7 +148,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) if (i > 0) { cons_show(""); - win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Arguments"); + win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Arguments"); for (i = 0; help->args[i][0] != NULL; i++) { win_printf(console, '-', maxlen + 3, NULL, 0, 0, "", "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]); } @@ -156,7 +156,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) if (g_strv_length((gchar**)help->examples) > 0) { cons_show(""); - win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Examples"); + win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Examples"); ui_show_lines(console, help->examples); } } @@ -181,7 +181,7 @@ cons_show_error(const char *const msg, ...) va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - win_print(console, '-', 0, NULL, 0, THEME_ERROR, "", fmt_msg->str); + win_printf(console, '-', 0, NULL, 0, THEME_ERROR, "", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); @@ -484,7 +484,7 @@ cons_show_login_success(ProfAccount *account, gboolean secured) win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str); win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)", accounts_get_priority_for_presence_type(account->name, presence)); - win_print(console, '-', 0, NULL, NO_DATE, 0, "", "."); + win_printf(console, '-', 0, NULL, NO_DATE, 0, "", "."); if (!secured) { cons_show_error("TLS connection not established"); } @@ -555,26 +555,26 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); win_printf(console, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", fulljid); - win_print(console, '-', 0, NULL, NO_DATE, 0, "", ":"); + win_printf(console, '-', 0, NULL, NO_DATE, 0, "", ":"); // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_print(console, '-', 0, NULL, NO_EOL, 0, "", "Identity: "); + win_printf(console, '-', 0, NULL, NO_EOL, 0, "", "Identity: "); if (identity->name) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); if (identity->category || identity->type) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->type) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); if (identity->category) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->category) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); } win_newline(console); } @@ -706,10 +706,10 @@ cons_show_bookmarks(const GList *list) win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "/%s", item->nick); } if (item->autojoin) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (autojoin)"); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (autojoin)"); } if (item->password) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (private)"); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (private)"); } if (muc_active(item->barejid)) { ProfWin *roomwin = (ProfWin*)wins_get_muc(item->barejid); @@ -1014,21 +1014,21 @@ cons_show_account(ProfAccount *account) // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_print(console, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); + win_printf(console, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); if (identity->name) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); if (identity->category || identity->type) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->type) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); if (identity->category) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->category) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); } win_newline(console); } @@ -2078,7 +2078,7 @@ cons_navigation_help(void) { ProfWin *console = wins_get_console(); cons_show(""); - win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Navigation"); + win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Navigation"); cons_show("Alt-1..Alt-0, F1..F10 : Choose window."); cons_show("Alt-LEFT, Alt-RIGHT : Previous/next chat window."); cons_show("PAGEUP, PAGEDOWN : Page the main window."); @@ -2184,15 +2184,15 @@ _cons_theme_bar_prop(theme_item_t theme, char *prop) GString *propstr = g_string_new(" "); g_string_append_printf(propstr, "%-24s", prop); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", propstr->str); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", propstr->str); g_string_free(propstr, TRUE); GString *valstr = g_string_new(" "); char *setting = theme_get_string(prop); g_string_append_printf(valstr, "%s ", setting); theme_free_string(setting); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, theme, "", valstr->str); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, theme, "", valstr->str); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); g_string_free(valstr, TRUE); } @@ -2203,22 +2203,15 @@ _cons_theme_prop(theme_item_t theme, char *prop) GString *propstr = g_string_new(" "); g_string_append_printf(propstr, "%-24s", prop); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", propstr->str); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", propstr->str); g_string_free(propstr, TRUE); GString *valstr = g_string_new(""); char *setting = theme_get_string(prop); g_string_append_printf(valstr, "%s", setting); theme_free_string(setting); - win_print(console, '-', 0, NULL, NO_DATE, theme, "", valstr->str); + win_printf(console, '-', 0, NULL, NO_DATE, theme, "", valstr->str); g_string_free(valstr, TRUE); - -// GString *str = g_string_new(" "); -// char *setting = theme_get_string(prop); -// g_string_append_printf(str, "%-24s%s", prop, setting); -// theme_free_string(setting); -// win_print(console, '-', 0, NULL, 0, theme, "", str->str); -// g_string_free(str, TRUE); } void @@ -2332,22 +2325,22 @@ cons_theme_colours(void) ProfWin *console = wins_get_console(); cons_show("Available colours:"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE, "", " white "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", " bold_white"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_GREEN, "", " green "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_GREEN_BOLD, "", " bold_green"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_RED, "", " red "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_RED_BOLD, "", " bold_red"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_YELLOW, "", " yellow "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_YELLOW_BOLD, "", " bold_yellow"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_BLUE, "", " blue "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_BLUE_BOLD, "", " bold_blue"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_CYAN, "", " cyan "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_CYAN_BOLD, "", " bold_cyan"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_MAGENTA, "", " magenta "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_MAGENTA_BOLD, "", " bold_magenta"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_BLACK, "", " black "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_BLACK_BOLD, "", " bold_black"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_WHITE, "", " white "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", " bold_white"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_GREEN, "", " green "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_GREEN_BOLD, "", " bold_green"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_RED, "", " red "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_RED_BOLD, "", " bold_red"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_YELLOW, "", " yellow "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_YELLOW_BOLD, "", " bold_yellow"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_BLUE, "", " blue "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_BLUE_BOLD, "", " bold_blue"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_CYAN, "", " cyan "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_CYAN_BOLD, "", " bold_cyan"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_MAGENTA, "", " magenta "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_MAGENTA_BOLD, "", " bold_magenta"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_BLACK, "", " black "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_BLACK_BOLD, "", " bold_black"); cons_show(""); } @@ -2357,14 +2350,14 @@ _cons_splash_logo(void) ProfWin *console = wins_get_console(); win_println(console, 0, "Welcome to"); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ___ _ "); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " / __) (_)_ "); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ____ ____ ___ | |__ ____ ____ _| |_ _ _ "); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |"); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| | | | | | |_| | | ( ( | | | | | | |_| |_| |"); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |"); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "|_| (____/ "); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", ""); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ___ _ "); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", " / __) (_)_ "); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ____ ____ ___ | |__ ____ ____ _| |_ _ _ "); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |"); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| | | | | | |_| | | ( ( | | | | | | |_| |_| |"); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |"); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", "|_| (____/ "); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", ""); if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION @@ -2404,7 +2397,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) g_string_free(title, TRUE); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " - "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " - "); GString *sub = g_string_new(""); sub = g_string_append(sub, p_contact_subscription(contact)); if (p_contact_pending_out(contact)) { @@ -2441,7 +2434,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) win_printf(console, '-', 0, NULL, NO_DATE, 0, "", "%s", groups_str->str); g_string_free(groups_str, TRUE); } else { - win_print(console, '-', 0, NULL, NO_DATE, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE, 0, "", " "); } } diff --git a/src/ui/core.c b/src/ui/core.c index 7f7b3ad0..daa54ef3 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -435,7 +435,7 @@ ui_handle_otr_error(const char *const barejid, const char *const message) { ProfChatWin *chatwin = wins_get_chat(barejid); if (chatwin) { - win_print((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", message); + win_printf((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", message); } else { cons_show_error("%s - %s", barejid, message); } @@ -752,7 +752,7 @@ ui_current_print_formatted_line(const char show_char, int attrs, const char *con va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - win_print(current, show_char, 0, NULL, 0, attrs, "", fmt_msg->str); + win_printf(current, show_char, 0, NULL, 0, attrs, "", fmt_msg->str); va_end(arg); g_string_free(fmt_msg, TRUE); } @@ -760,14 +760,14 @@ ui_current_print_formatted_line(const char show_char, int attrs, const char *con void ui_win_error_line(ProfWin *window, const char *const msg) { - win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", msg); + win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", msg); } void ui_current_error_line(const char *const msg) { ProfWin *current = wins_get_current(); - win_print(current, '-', 0, NULL, 0, THEME_ERROR, "", msg); + win_printf(current, '-', 0, NULL, 0, THEME_ERROR, "", msg); } void @@ -813,7 +813,7 @@ ui_room_join(const char *const roomjid, gboolean focus) win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", affiliation: %s", affiliation); } } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); if (focus) { @@ -1028,13 +1028,13 @@ ui_ask_pgp_passphrase(const char *hint, int prev_fail) win_println(current, 0, ""); if (prev_fail) { - win_print(current, '!', 0, NULL, 0, 0, "", "Incorrect passphrase"); + win_printf(current, '!', 0, NULL, 0, 0, "", "Incorrect passphrase"); } if (hint) { win_printf(current, '!', 0, NULL, 0, 0, "", "Enter PGP key passphrase for %s", hint); } else { - win_print(current, '!', 0, NULL, 0, 0, "", "Enter PGP key passphrase"); + win_printf(current, '!', 0, NULL, 0, 0, "", "Enter PGP key passphrase"); } ui_update(); @@ -1158,7 +1158,7 @@ ui_handle_room_configuration_form_error(const char *const roomjid, const char *c g_string_append(message_str, message); } - win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", message_str->str); + win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", message_str->str); g_string_free(message_str, TRUE); } @@ -1182,7 +1182,7 @@ ui_handle_room_config_submit_result(const char *const roomjid) if (muc_window) { ui_focus_win((ProfWin*)muc_window); - win_print(muc_window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room configuration successful"); + win_printf(muc_window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room configuration successful"); } else { ProfWin *console = wins_get_console(); ui_focus_win(console); @@ -1211,13 +1211,13 @@ ui_handle_room_config_submit_result_error(const char *const roomjid, const char if (message) { win_printf(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message); } else { - win_print(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); + win_printf(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); } } else if (muc_window) { if (message) { win_printf(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message); } else { - win_print(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); + win_printf(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); } } else { if (message) { @@ -1227,7 +1227,7 @@ ui_handle_room_config_submit_result_error(const char *const roomjid, const char } } } else { - win_print(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); + win_printf(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); } } @@ -1237,7 +1237,7 @@ ui_show_lines(ProfWin *window, gchar** lines) if (lines) { int i; for (i = 0; lines[i] != NULL; i++) { - win_print(window, '-', 0, NULL, 0, 0, "", lines[i]); + win_printf(window, '-', 0, NULL, 0, 0, "", lines[i]); } } } @@ -1274,7 +1274,7 @@ ui_handle_software_version_error(const char *const roomjid, const char *const me g_string_append(message_str, message); } - win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", message_str->str); + win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", message_str->str); g_string_free(message_str, TRUE); } @@ -1317,7 +1317,7 @@ ui_show_software_version(const char *const jid, const char *const presence, win_println(window, 0, ""); theme_item_t presence_colour = theme_main_presence_attrs(presence); win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", jid); - win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":"); + win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ":"); } if (name) { win_printf(window, '-', 0, NULL, 0, 0, "", "Name : %s", name); diff --git a/src/ui/mucconfwin.c b/src/ui/mucconfwin.c index 3f8987b6..c834bb93 100644 --- a/src/ui/mucconfwin.c +++ b/src/ui/mucconfwin.c @@ -47,12 +47,12 @@ mucconfwin_show_form(ProfMucConfWin *confwin) { ProfWin *window = (ProfWin*) confwin; if (confwin->form->title) { - win_print(window, '-', 0, NULL, NO_EOL, 0, "", "Form title: "); - win_print(window, '-', 0, NULL, NO_DATE, 0, "", confwin->form->title); + win_printf(window, '-', 0, NULL, NO_EOL, 0, "", "Form title: "); + win_printf(window, '-', 0, NULL, NO_DATE, 0, "", confwin->form->title); } else { win_printf(window, '-', 0, NULL, 0, 0, "", "Configuration for room %s.", confwin->roomjid); } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); mucconfwin_form_help(confwin); @@ -64,7 +64,7 @@ mucconfwin_show_form(ProfMucConfWin *confwin) if ((g_strcmp0(field->type, "fixed") == 0) && field->values) { if (field->values) { char *value = field->values->data; - win_print(window, '-', 0, NULL, 0, 0, "", value); + win_printf(window, '-', 0, NULL, 0, 0, "", value); } } else if (g_strcmp0(field->type, "hidden") != 0 && field->var) { char *tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var); @@ -96,11 +96,11 @@ mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form) mucconfwin_show_form(confwin); - win_print(window, '-', 0, NULL, 0, 0, "", ""); - win_print(window, '-', 0, NULL, 0, 0, "", "Use '/form submit' to save changes."); - win_print(window, '-', 0, NULL, 0, 0, "", "Use '/form cancel' to cancel changes."); - win_print(window, '-', 0, NULL, 0, 0, "", "See '/form help' for more information."); - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", "Use '/form submit' to save changes."); + win_printf(window, '-', 0, NULL, 0, 0, "", "Use '/form cancel' to cancel changes."); + win_printf(window, '-', 0, NULL, 0, 0, "", "See '/form help' for more information."); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } void @@ -111,11 +111,11 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) ProfWin *window = (ProfWin*) confwin; FormField *field = form_get_field_by_tag(confwin->form, tag); if (field) { - win_print(window, '-', 0, NULL, NO_EOL, 0, "", field->label); + win_printf(window, '-', 0, NULL, NO_EOL, 0, "", field->label); if (field->required) { - win_print(window, '-', 0, NULL, NO_DATE, 0, "", " (Required):"); + win_printf(window, '-', 0, NULL, NO_DATE, 0, "", " (Required):"); } else { - win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":"); + win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ":"); } if (field->description) { win_printf(window, '-', 0, NULL, 0, 0, "", " Description : %s", field->description); @@ -130,12 +130,12 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) case FIELD_TEXT_SINGLE: case FIELD_TEXT_PRIVATE: win_printf(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is any text"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is any text"); break; case FIELD_TEXT_MULTI: num_values = form_get_value_count(confwin->form, tag); win_printf(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is any text"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is any text"); if (num_values > 0) { win_printf(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); win_printf(window, '-', 0, NULL, 0, 0, "", " Where : between 'val1' and 'val%d'", num_values); @@ -143,11 +143,11 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) break; case FIELD_BOOLEAN: win_printf(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is either 'on' or 'off'"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is either 'on' or 'off'"); break; case FIELD_LIST_SINGLE: win_printf(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is one of"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; @@ -158,7 +158,7 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) case FIELD_LIST_MULTI: win_printf(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); win_printf(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is one of"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; @@ -168,12 +168,12 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) break; case FIELD_JID_SINGLE: win_printf(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is a valid Jabber ID"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is a valid Jabber ID"); break; case FIELD_JID_MULTI: win_printf(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); win_printf(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is a valid Jabber ID"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is a valid Jabber ID"); break; case FIELD_FIXED: case FIELD_UNKNOWN: @@ -193,9 +193,9 @@ mucconfwin_form_help(ProfMucConfWin *confwin) if (confwin->form->instructions) { ProfWin *window = (ProfWin*) confwin; - win_print(window, '-', 0, NULL, 0, 0, "", "Supplied instructions:"); - win_print(window, '-', 0, NULL, 0, 0, "", confwin->form->instructions); - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", "Supplied instructions:"); + win_printf(window, '-', 0, NULL, 0, 0, "", confwin->form->instructions); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } } @@ -205,9 +205,9 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) win_printf(window, '-', 0, NULL, NO_EOL, THEME_AWAY, "", "[%s] ", tag); win_printf(window, '-', 0, NULL, NO_EOL | NO_DATE, 0, "", "%s", field->label); if (field->required) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (required): "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (required): "); } else { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ": "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ": "); } GSList *values = field->values; @@ -221,9 +221,9 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) char *value = curr_value->data; if (value) { if (g_strcmp0(field->var, "muc#roomconfig_roomsecret") == 0) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); } else { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value); } } } @@ -233,7 +233,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); } } win_newline(window); @@ -252,16 +252,16 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) break; case FIELD_BOOLEAN: if (curr_value == NULL) { - win_print(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); + win_printf(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); } else { char *value = curr_value->data; if (value == NULL) { - win_print(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); + win_printf(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); } else { if (g_strcmp0(value, "0") == 0) { - win_print(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); + win_printf(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); } else { - win_print(window, '-', 0, NULL, NO_DATE, THEME_ONLINE, "", "TRUE"); + win_printf(window, '-', 0, NULL, NO_DATE, THEME_ONLINE, "", "TRUE"); } } } @@ -303,7 +303,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value); } } win_newline(window); @@ -320,7 +320,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", value); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", value); } } win_newline(window); diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 8bb67790..7bbf65e8 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -58,7 +58,7 @@ mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } void @@ -75,7 +75,7 @@ mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, con if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } void @@ -92,7 +92,7 @@ mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, c if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } @@ -110,7 +110,7 @@ mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const ch if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } void @@ -127,7 +127,7 @@ mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, c if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } void @@ -144,7 +144,7 @@ mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *cons if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } void @@ -154,7 +154,7 @@ mucwin_room_info_error(ProfMucWin *mucwin, const char *const error) ProfWin *window = (ProfWin*)mucwin; win_printf(window, '!', 0, NULL, 0, 0, "", "Room info request failed: %s", error); - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } void @@ -166,7 +166,7 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) if ((identities && (g_slist_length(identities) > 0)) || (features && (g_slist_length(features) > 0))) { if (identities) { - win_print(window, '!', 0, NULL, 0, 0, "", "Identities:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Identities:"); } while (identities) { DiscoIdentity *identity = identities->data; // anme trpe, cat @@ -182,19 +182,19 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) if (identity->category) { identity_str = g_string_append(identity_str, identity->category); } - win_print(window, '!', 0, NULL, 0, 0, "", identity_str->str); + win_printf(window, '!', 0, NULL, 0, 0, "", identity_str->str); g_string_free(identity_str, TRUE); identities = g_slist_next(identities); } if (features) { - win_print(window, '!', 0, NULL, 0, 0, "", "Features:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Features:"); } while (features) { win_printf(window, '!', 0, NULL, 0, 0, "", " %s", features->data); features = g_slist_next(features); } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } } @@ -206,7 +206,7 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) ProfWin *window = (ProfWin*)mucwin; if ((roster == NULL) || (g_list_length(roster) == 0)) { if (presence == NULL) { - win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room is empty."); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room is empty."); } else { win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "No occupants %s.", presence); } @@ -226,12 +226,12 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick); if (roster->next) { - win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", "); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", "); } roster = g_list_next(roster); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ONLINE, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ONLINE, "", ""); } } @@ -305,7 +305,7 @@ mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *c win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", affiliation: %s", affiliation); } } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } void @@ -355,7 +355,7 @@ mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, g_string_append(line, message); } - win_print(window, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", line->str); + win_printf(window, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", line->str); g_string_free(line, TRUE); plugins_on_room_history_message(mucwin->roomjid, nick, message, timestamp); @@ -371,10 +371,10 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co pos = GPOINTER_TO_INT(curr->data); char *before_str = g_strndup(message + last_pos, pos - last_pos); - win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION, "", before_str); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION, "", before_str); g_free(before_str); char *nick_str = g_strndup(message + pos, strlen(nick)); - win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION_TERM, "", nick_str); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION_TERM, "", nick_str); g_free(nick_str); last_pos = pos + strlen(nick); @@ -382,9 +382,9 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co curr = g_slist_next(curr); } if (last_pos < strlen(message)) { - win_print(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", &message[last_pos]); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", &message[last_pos]); } else { - win_print(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", ""); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", ""); } } @@ -442,7 +442,7 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge // no triggers found if (first_trigger_pos == -1) { - win_print(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER, "", message); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER, "", message); } else { if (first_trigger_pos > 0) { char message_section[strlen(message) + 1]; @@ -452,7 +452,7 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge i++; } message_section[i] = '\0'; - win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER, "", message_section); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER, "", message_section); } char trigger_section[first_trigger_len + 1]; int i = 0; @@ -463,10 +463,10 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge trigger_section[i] = '\0'; if (first_trigger_pos + first_trigger_len < strlen(message)) { - win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER_TERM, "", trigger_section); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER_TERM, "", trigger_section); _mucwin_print_triggers(window, &message[first_trigger_pos + first_trigger_len], triggers); } else { - win_print(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER_TERM, "", trigger_section); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER_TERM, "", trigger_section); } } } @@ -481,16 +481,16 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes if (g_strcmp0(nick, mynick) != 0) { if (g_slist_length(mentions) > 0) { - win_print(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMMENTION, nick, ""); + win_printf(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMMENTION, nick, ""); _mucwin_print_mention(window, message, mynick, mentions); } else if (triggers) { - win_print(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMTRIGGER, nick, ""); + win_printf(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMTRIGGER, nick, ""); _mucwin_print_triggers(window, message, triggers); } else { - win_print(window, '-', 0, NULL, NO_ME, THEME_TEXT_THEM, nick, message); + win_printf(window, '-', 0, NULL, NO_ME, THEME_TEXT_THEM, nick, message); } } else { - win_print(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, message); + win_printf(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, message); } } @@ -506,12 +506,12 @@ mucwin_requires_config(ProfMucWin *mucwin) ui_index = 0; } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room locked, requires configuration."); win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room accept' to accept the defaults"); win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room destroy' to cancel and destroy the room"); win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room config' to edit the room configuration"); - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); // currently in groupchat window if (wins_is_current(window)) { @@ -611,10 +611,10 @@ mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation win_printf(window, '!', 0, NULL, 0, 0, "", " %s", jid); curr_jid = g_slist_next(curr_jid); } - win_print(window, '!', 0, NULL, 0, 0, "", ""); + win_printf(window, '!', 0, NULL, 0, 0, "", ""); } else { win_printf(window, '!', 0, NULL, 0, 0, "", "No users found with affiliation: %s", affiliation); - win_print(window, '!', 0, NULL, 0, 0, "", ""); + win_printf(window, '!', 0, NULL, 0, 0, "", ""); } } @@ -629,34 +629,34 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) if (!occupants) { switch (affiliation) { case MUC_AFFILIATION_OWNER: - win_print(window, '!', 0, NULL, 0, 0, "", "No owners found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No owners found."); break; case MUC_AFFILIATION_ADMIN: - win_print(window, '!', 0, NULL, 0, 0, "", "No admins found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No admins found."); break; case MUC_AFFILIATION_MEMBER: - win_print(window, '!', 0, NULL, 0, 0, "", "No members found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No members found."); break; case MUC_AFFILIATION_OUTCAST: - win_print(window, '!', 0, NULL, 0, 0, "", "No outcasts found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No outcasts found."); break; default: break; } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } else { switch (affiliation) { case MUC_AFFILIATION_OWNER: - win_print(window, '!', 0, NULL, 0, 0, "", "Owners:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Owners:"); break; case MUC_AFFILIATION_ADMIN: - win_print(window, '!', 0, NULL, 0, 0, "", "Admins:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Admins:"); break; case MUC_AFFILIATION_MEMBER: - win_print(window, '!', 0, NULL, 0, 0, "", "Members:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Members:"); break; case MUC_AFFILIATION_OUTCAST: - win_print(window, '!', 0, NULL, 0, 0, "", "Outcasts:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Outcasts:"); break; default: break; @@ -676,7 +676,7 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) curr_occupant = g_slist_next(curr_occupant); } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } } @@ -712,10 +712,10 @@ mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nick } curr_nick = g_slist_next(curr_nick); } - win_print(window, '!', 0, NULL, 0, 0, "", ""); + win_printf(window, '!', 0, NULL, 0, 0, "", ""); } else { win_printf(window, '!', 0, NULL, 0, 0, "", "No occupants found with role: %s", role); - win_print(window, '!', 0, NULL, 0, 0, "", ""); + win_printf(window, '!', 0, NULL, 0, 0, "", ""); } } @@ -730,28 +730,28 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) if (!occupants) { switch (role) { case MUC_ROLE_MODERATOR: - win_print(window, '!', 0, NULL, 0, 0, "", "No moderators found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No moderators found."); break; case MUC_ROLE_PARTICIPANT: - win_print(window, '!', 0, NULL, 0, 0, "", "No participants found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No participants found."); break; case MUC_ROLE_VISITOR: - win_print(window, '!', 0, NULL, 0, 0, "", "No visitors found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No visitors found."); break; default: break; } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } else { switch (role) { case MUC_ROLE_MODERATOR: - win_print(window, '!', 0, NULL, 0, 0, "", "Moderators:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Moderators:"); break; case MUC_ROLE_PARTICIPANT: - win_print(window, '!', 0, NULL, 0, 0, "", "Participants:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Participants:"); break; case MUC_ROLE_VISITOR: - win_print(window, '!', 0, NULL, 0, 0, "", "Visitors:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Visitors:"); break; default: break; @@ -771,7 +771,7 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) curr_occupant = g_slist_next(curr_occupant); } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } } @@ -807,7 +807,7 @@ mucwin_info(ProfMucWin *mucwin) win_printf(window, '!', 0, NULL, 0, 0, "", "Room: %s", mucwin->roomjid); win_printf(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation); win_printf(window, '!', 0, NULL, 0, 0, "", "Role: %s", role); - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } void diff --git a/src/ui/privwin.c b/src/ui/privwin.c index b540fb44..fe98aa85 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -93,7 +93,7 @@ privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message) { assert(privwin != NULL); - win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message); + win_printf((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message); } void @@ -101,7 +101,7 @@ privwin_message_occupant_offline(ProfPrivateWin *privwin) { assert(privwin != NULL); - win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, occupant no longer present in room."); + win_printf((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, occupant no longer present in room."); } void @@ -109,7 +109,7 @@ privwin_message_left_room(ProfPrivateWin *privwin) { assert(privwin != NULL); - win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, you are no longer present in room."); + win_printf((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, you are no longer present in room."); } void diff --git a/src/ui/ui.h b/src/ui/ui.h index 95e26933..d7ea0e96 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -357,8 +357,8 @@ void win_hide_subwin(ProfWin *window); void win_show_subwin(ProfWin *window); void win_refresh_without_subwin(ProfWin *window); void win_refresh_with_subwin(ProfWin *window); -void win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const from, const char *const message); -void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const from, const char *const message, ...); +void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, + theme_item_t theme_item, const char *const from, const char *const message, ...); char* win_get_title(ProfWin *window); void win_show_occupant(ProfWin *window, Occupant *occupant); void win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupant); diff --git a/src/ui/window.c b/src/ui/window.c index ebcd9e53..a410d6d5 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -683,14 +683,14 @@ win_show_occupant(ProfWin *window, Occupant *occupant) theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); if (occupant->status) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); } - win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); + win_printf(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); } void @@ -705,9 +705,9 @@ win_show_contact(ProfWin *window, PContact contact) theme_item_t presence_colour = theme_main_presence_attrs(presence); if (name) { - win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", name); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", name); } else { - win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); } win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence); @@ -735,7 +735,7 @@ win_show_contact(ProfWin *window, PContact contact) win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", p_contact_status(contact)); } - win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); + win_printf(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); } void @@ -747,7 +747,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_print(window, '!', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); + win_printf(window, '!', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); if (occupant->status) { @@ -771,21 +771,21 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_print(window, '!', 0, NULL, NO_EOL, 0, "", " Identity: "); + win_printf(window, '!', 0, NULL, NO_EOL, 0, "", " Identity: "); if (identity->name) { - win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); if (identity->category || identity->type) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->type) { - win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); if (identity->category) { - win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->category) { - win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); } win_newline(window); } @@ -815,7 +815,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa caps_destroy(caps); } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } void @@ -829,12 +829,12 @@ win_show_info(ProfWin *window, PContact contact) theme_item_t presence_colour = theme_main_presence_attrs(presence); - win_print(window, '-', 0, NULL, 0, 0, "", ""); - win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); if (name) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name); } - win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":"); + win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ":"); if (sub) { win_printf(window, '-', 0, NULL, 0, 0, "", "Subscription: %s", sub); @@ -863,7 +863,7 @@ win_show_info(ProfWin *window, PContact contact) GList *resources = p_contact_get_available_resources(contact); GList *ordered_resources = NULL; if (resources) { - win_print(window, '-', 0, NULL, 0, 0, "", "Resources:"); + win_printf(window, '-', 0, NULL, 0, 0, "", "Resources:"); // sort in order of availability GList *curr = resources; @@ -895,21 +895,21 @@ win_show_info(ProfWin *window, PContact contact) // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_print(window, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); + win_printf(window, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); if (identity->name) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); if (identity->category || identity->type) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->type) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); if (identity->category) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->category) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); } win_newline(window); } @@ -983,7 +983,7 @@ win_show_status_string(ProfWin *window, const char *const from, if (status) win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", status); - win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); + win_printf(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); } @@ -1001,10 +1001,10 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp, } else if (enc_mode == PROF_MSG_PGP) { enc_char = prefs_get_pgp_char(); } - win_print(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); + win_printf(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); break; case WIN_PRIVATE: - win_print(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); + win_printf(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); break; default: assert(FALSE); @@ -1015,19 +1015,6 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp, void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const from, const char *const message, ...) -{ - va_list arg; - va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); - g_string_vprintf(fmt_msg, message, arg); - win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str); - g_string_free(fmt_msg, TRUE); - va_end(arg); -} - -void -win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, - int flags, theme_item_t theme_item, const char *const from, const char *const message) { if (timestamp == NULL) { timestamp = g_date_time_new_now_local(); @@ -1035,11 +1022,20 @@ win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *time g_date_time_ref(timestamp); } - buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL); - _win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL); + 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, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL); + + _win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL); // TODO: cross-reference.. this should be replaced by a real event-based system inp_nonblocking(TRUE); g_date_time_unref(timestamp); + + g_string_free(fmt_msg, TRUE); + va_end(arg); } void @@ -1098,7 +1094,7 @@ win_update_entry_theme(ProfWin *window, const char *const id, theme_item_t theme void win_println(ProfWin *window, int pad, const char *const message) { - win_print(window, '-', pad, NULL, 0, 0, "", message); + win_printf(window, '-', pad, NULL, 0, 0, "", message); } void @@ -1108,7 +1104,7 @@ win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) va_start(arg, message); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - win_print(window, ch, 0, NULL, 0, 0, "", fmt_msg->str); + win_printf(window, ch, 0, NULL, 0, 0, "", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); } @@ -1116,7 +1112,7 @@ win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) void win_newline(ProfWin *window) { - win_print(window, '-', 0, NULL, NO_DATE, 0, "", ""); + win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ""); } static void diff --git a/src/ui/window_list.c b/src/ui/window_list.c index 8a3ad299..c61f9635 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -835,7 +835,7 @@ wins_lost_connection(void) while (curr) { ProfWin *window = curr->data; if (window->type != WIN_CONSOLE) { - win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", "Lost connection."); + win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", "Lost connection."); // if current win, set current_win_dirty if (wins_is_current(window)) { diff --git a/src/ui/xmlwin.c b/src/ui/xmlwin.c index 80870b46..c8af2211 100644 --- a/src/ui/xmlwin.c +++ b/src/ui/xmlwin.c @@ -45,13 +45,13 @@ xmlwin_show(ProfXMLWin *xmlwin, const char *const msg) ProfWin *window = (ProfWin*)xmlwin; if (g_str_has_prefix(msg, "SENT:")) { - win_print(window, '-', 0, NULL, 0, 0, "", "SENT:"); - win_print(window, '-', 0, NULL, 0, THEME_ONLINE, "", &msg[6]); - win_print(window, '-', 0, NULL, 0, THEME_ONLINE, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", "SENT:"); + win_printf(window, '-', 0, NULL, 0, THEME_ONLINE, "", &msg[6]); + win_printf(window, '-', 0, NULL, 0, THEME_ONLINE, "", ""); } else if (g_str_has_prefix(msg, "RECV:")) { - win_print(window, '-', 0, NULL, 0, 0, "", "RECV:"); - win_print(window, '-', 0, NULL, 0, THEME_AWAY, "", &msg[6]); - win_print(window, '-', 0, NULL, 0, THEME_AWAY, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", "RECV:"); + win_printf(window, '-', 0, NULL, 0, THEME_AWAY, "", &msg[6]); + win_printf(window, '-', 0, NULL, 0, THEME_AWAY, "", ""); } } diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index af3a18a0..275d2487 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -520,7 +520,6 @@ void win_hide_subwin(ProfWin *window) {} void win_show_subwin(ProfWin *window) {} void win_refresh_without_subwin(ProfWin *window) {} void win_refresh_with_subwin(ProfWin *window) {} -void win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message) {} void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, ...) {} char* win_get_title(ProfWin *window) {