From 33b4b79f2e055ad5831bc428a3c98eaee5530b9e Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 00:04:57 +0100 Subject: [PATCH] Add ch arg to win_printf_line --- src/command/cmd_funcs.c | 10 ++--- src/plugins/api.c | 2 +- src/ui/chatwin.c | 2 +- src/ui/console.c | 68 +++++++++++++++--------------- src/ui/core.c | 24 +++++------ src/ui/mucconfwin.c | 80 ++++++++++++++++++------------------ src/ui/mucwin.c | 18 ++++---- src/ui/privwin.c | 8 ++-- src/ui/ui.h | 2 +- src/ui/window.c | 18 ++++---- src/ui/window_list.c | 2 +- src/ui/xmlwin.c | 12 +++--- tests/unittests/ui/stub_ui.c | 2 +- 13 files changed, 124 insertions(+), 124 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 15d2e0e8..cd0328de 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1479,9 +1479,9 @@ _cmd_help_cmd_list(const char *const tag) cons_show(""); ProfWin *console = wins_get_console(); if (tag) { - win_printf_line(console, THEME_WHITE_BOLD, "%s commands", tag); + win_printf_line(console, THEME_WHITE_BOLD, '-', "%s commands", tag); } else { - win_printf_line(console, THEME_WHITE_BOLD, "All commands"); + win_printf_line(console, THEME_WHITE_BOLD, '-', "All commands"); } GList *ordered_commands = NULL; @@ -3108,7 +3108,7 @@ cmd_status(ProfWin *window, const char *const command, gchar **args) if (occupant) { win_show_occupant(window, occupant); } else { - win_printf_line(window, THEME_DEFAULT, "No such participant \"%s\" in room.", usr); + win_printf_line(window, THEME_DEFAULT, '-', "No such participant \"%s\" in room.", usr); } } else { ui_current_print_line("You must specify a nickname."); @@ -4681,13 +4681,13 @@ cmd_tiny(ProfWin *window, const char *const command, gchar **args) } if (!tinyurl_valid(url)) { - win_printf_line(window, THEME_ERROR, "/tiny, badly formed URL: %s", url); + win_printf_line(window, THEME_ERROR, '-', "/tiny, badly formed URL: %s", url); return TRUE; } char *tiny = tinyurl_get(url); if (!tiny) { - win_printf_line(window, THEME_ERROR, "Couldn't create tinyurl."); + win_printf_line(window, THEME_ERROR, '-', "Couldn't create tinyurl."); return TRUE; } diff --git a/src/plugins/api.c b/src/plugins/api.c index be5639dc..4073b5f5 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_printf_line(console, themeitem, "%s", parsed); + win_printf_line(console, themeitem, '-', "%s", parsed); free(parsed); diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index f8726f1e..550ba384 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -405,7 +405,7 @@ _chatwin_history(ProfChatWin *chatwin, const char *const contact) g_date_time_unref(timestamp); // header } else { - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, "%s", curr->data); + win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '-', "%s", curr->data); } curr = g_slist_next(curr); } diff --git a/src/ui/console.c b/src/ui/console.c index c6894e3d..61c07b37 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -124,7 +124,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) ProfWin *console = wins_get_console(); cons_show(""); - win_printf_line(console, THEME_WHITE_BOLD, "%s", &cmd[1]); + win_printf_line(console, THEME_WHITE_BOLD, '-', "%s", &cmd[1]); win_printf(console, '-', 0, NULL, NO_EOL, THEME_WHITE_BOLD, "", ""); int i; for (i = 0; i < strlen(cmd) - 1 ; i++) { @@ -133,11 +133,11 @@ cons_show_help(const char *const cmd, CommandHelp *help) win_printf(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", ""); cons_show(""); - win_printf_line(console, THEME_WHITE_BOLD, "Synopsis"); + win_printf_line(console, THEME_WHITE_BOLD, '-', "Synopsis"); ui_show_lines(console, help->synopsis); cons_show(""); - win_printf_line(console, THEME_WHITE_BOLD, "Description"); + win_printf_line(console, 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_printf_line(console, THEME_WHITE_BOLD, "Arguments"); + win_printf_line(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]); } @@ -156,7 +156,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) if (g_strv_length((gchar**)help->examples) > 0) { cons_show(""); - win_printf_line(console, THEME_WHITE_BOLD, "Arguments"); + win_printf_line(console, THEME_WHITE_BOLD, '-', "Arguments"); 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_printf_line(console, THEME_ERROR, "%s", fmt_msg->str); + win_printf_line(console, THEME_ERROR, '-', "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); @@ -296,7 +296,7 @@ cons_show_typing(const char *const barejid) display_usr = barejid; } - win_printf_line(console, THEME_TYPING, "!! %s is typing a message...", display_usr); + win_printf_line(console, THEME_TYPING, '-', "!! %s is typing a message...", display_usr); cons_alert(); } @@ -333,27 +333,27 @@ cons_show_incoming_room_message(const char *const nick, const char *const room, if (g_strcmp0(muc_show, "all") == 0) { if (mention) { - win_printf_line(console, THEME_MENTION, "<< room mention: %s in %s (win %d)", nick, room, ui_index); + win_printf_line(console, THEME_MENTION, '-', "<< room mention: %s in %s (win %d)", nick, room, ui_index); } else if (triggers) { char *triggers_str = _room_triggers_to_string(triggers); - win_printf_line(console, THEME_TRIGGER, "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); + win_printf_line(console, THEME_TRIGGER, '-', "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); free(triggers_str); } else { - win_printf_line(console, THEME_INCOMING, "<< room message: %s in %s (win %d)", nick, room, ui_index); + win_printf_line(console, THEME_INCOMING, '-', "<< room message: %s in %s (win %d)", nick, room, ui_index); } cons_alert(); } else if (g_strcmp0(muc_show, "first") == 0) { if (mention) { - win_printf_line(console, THEME_MENTION, "<< room mention: %s in %s (win %d)", nick, room, ui_index); + win_printf_line(console, THEME_MENTION, '-', "<< room mention: %s in %s (win %d)", nick, room, ui_index); cons_alert(); } else if (triggers) { char *triggers_str = _room_triggers_to_string(triggers); - win_printf_line(console, THEME_TRIGGER, "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); + win_printf_line(console, THEME_TRIGGER, '-', "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); free(triggers_str); cons_alert(); } else if (unread == 0) { - win_printf_line(console, THEME_INCOMING, "<< room message: %s (win %d)", room, ui_index); + win_printf_line(console, THEME_INCOMING, '-', "<< room message: %s (win %d)", room, ui_index); cons_alert(); } } @@ -372,10 +372,10 @@ cons_show_incoming_message(const char *const short_from, const int win_index, in char *chat_show = prefs_get_string(PREF_CONSOLE_CHAT); if (g_strcmp0(chat_show, "all") == 0) { - win_printf_line(console, THEME_INCOMING, "<< chat message: %s (win %d)", short_from, ui_index); + win_printf_line(console, THEME_INCOMING, '-', "<< chat message: %s (win %d)", short_from, ui_index); cons_alert(); } else if ((g_strcmp0(chat_show, "first") == 0) && unread == 0) { - win_printf_line(console, THEME_INCOMING, "<< chat message: %s (win %d)", short_from, ui_index); + win_printf_line(console, THEME_INCOMING, '-', "<< chat message: %s (win %d)", short_from, ui_index); cons_alert(); } @@ -394,10 +394,10 @@ cons_show_incoming_private_message(const char *const nick, const char *const roo char *priv_show = prefs_get_string(PREF_CONSOLE_PRIVATE); if (g_strcmp0(priv_show, "all") == 0) { - win_printf_line(console, THEME_INCOMING, "<< private message: %s in %s (win %d)", nick, room, ui_index); + win_printf_line(console, THEME_INCOMING, '-', "<< private message: %s in %s (win %d)", nick, room, ui_index); cons_alert(); } else if ((g_strcmp0(priv_show, "first") == 0) && unread == 0) { - win_printf_line(console, THEME_INCOMING, "<< private message: %s in %s (win %d)", nick, room, ui_index); + win_printf_line(console, THEME_INCOMING, '-', "<< private message: %s in %s (win %d)", nick, room, ui_index); cons_alert(); } @@ -417,16 +417,16 @@ cons_about(void) if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION - win_printf_line(console, THEME_DEFAULT, "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); + win_printf_line(console, THEME_DEFAULT, '-', "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); #else win_printf_line(console, THEME_DEFAULT, "Welcome to Profanity, version %sdev", PACKAGE_VERSION); #endif } else { - win_printf_line(console, THEME_DEFAULT, "Welcome to Profanity, version %s", PACKAGE_VERSION); + win_printf_line(console, THEME_DEFAULT, '-', "Welcome to Profanity, version %s", PACKAGE_VERSION); } } - win_printf_line(console, THEME_DEFAULT, "Copyright (C) 2012 - 2016 James Booth <%s>.", PACKAGE_BUGREPORT); + win_printf_line(console, THEME_DEFAULT, '-', "Copyright (C) 2012 - 2016 James Booth <%s>.", PACKAGE_BUGREPORT); win_println(console, 0, "License GPLv3+: GNU GPL version 3 or later "); win_println(console, 0, ""); win_println(console, 0, "This is free software; you are free to change and redistribute it."); @@ -455,7 +455,7 @@ cons_check_version(gboolean not_available_msg) if (relase_valid) { if (release_is_new(latest_release)) { - win_printf_line(console, THEME_DEFAULT, "A new version of Profanity is available: %s", latest_release); + win_printf_line(console, THEME_DEFAULT, '-', "A new version of Profanity is available: %s", latest_release); win_println(console, 0, "Check for details."); win_println(console, 0, ""); } else { @@ -605,7 +605,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) win_println(console, 0, "Features:"); GSList *feature = caps->features; while (feature) { - win_printf_line(console, THEME_DEFAULT, " %s", feature->data); + win_printf_line(console, THEME_DEFAULT, '-', " %s", feature->data); feature = g_slist_next(feature); } } @@ -863,7 +863,7 @@ cons_show_account_list(gchar **accounts) (g_strcmp0(session_get_account_name(), accounts[i]) == 0)) { resource_presence_t presence = accounts_get_last_presence(accounts[i]); theme_item_t presence_colour = theme_main_presence_attrs(string_from_resource_presence(presence)); - win_printf_line(console, presence_colour, "%s", accounts[i]); + win_printf_line(console, presence_colour, '-', "%s", accounts[i]); } else { cons_show(accounts[i]); } @@ -2078,7 +2078,7 @@ cons_navigation_help(void) { ProfWin *console = wins_get_console(); cons_show(""); - win_printf_line(console, THEME_WHITE_BOLD, "Navigation"); + win_printf_line(console, 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."); @@ -2350,23 +2350,23 @@ _cons_splash_logo(void) ProfWin *console = wins_get_console(); win_println(console, 0, "Welcome to"); - win_printf_line(console, THEME_SPLASH, " ___ _ "); - win_printf_line(console, THEME_SPLASH, " / __) (_)_ "); - win_printf_line(console, THEME_SPLASH, " ____ ____ ___ | |__ ____ ____ _| |_ _ _ "); - win_printf_line(console, THEME_SPLASH, "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |"); - win_printf_line(console, THEME_SPLASH, "| | | | | | |_| | | ( ( | | | | | | |_| |_| |"); - win_printf_line(console, THEME_SPLASH, "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |"); - win_printf_line(console, THEME_SPLASH, "|_| (____/ "); - win_printf_line(console, THEME_SPLASH, ""); + win_printf_line(console, THEME_SPLASH, '-', " ___ _ "); + win_printf_line(console, THEME_SPLASH, '-', " / __) (_)_ "); + win_printf_line(console, THEME_SPLASH, '-', " ____ ____ ___ | |__ ____ ____ _| |_ _ _ "); + win_printf_line(console, THEME_SPLASH, '-', "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |"); + win_printf_line(console, THEME_SPLASH, '-', "| | | | | | |_| | | ( ( | | | | | | |_| |_| |"); + win_printf_line(console, THEME_SPLASH, '-', "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |"); + win_printf_line(console, THEME_SPLASH, '-', "|_| (____/ "); + win_printf_line(console, THEME_SPLASH, '-', ""); if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION - win_printf_line(console, THEME_DEFAULT, "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); + win_printf_line(console, THEME_DEFAULT, '-', "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); #else win_printf_line(console, THEME_DEFAULT, "Version %sdev", PACKAGE_VERSION); #endif } else { - win_printf_line(console, THEME_DEFAULT, "Version %s", PACKAGE_VERSION); + win_printf_line(console, THEME_DEFAULT, '-', "Version %s", PACKAGE_VERSION); } } diff --git a/src/ui/core.c b/src/ui/core.c index 023af8ef..859b67f6 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -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_printf_line(window, THEME_ERROR, "%s", msg); + win_printf_line(window, THEME_ERROR, '-', "%s", msg); } void ui_current_error_line(const char *const msg) { ProfWin *current = wins_get_current(); - win_printf_line(current, THEME_ERROR, "%s", msg); + win_printf_line(current, THEME_ERROR, '-', "%s", msg); } void @@ -790,7 +790,7 @@ ui_print_system_msg_from_recipient(const char *const barejid, const char *messag } } - win_printf_line(window, THEME_DEFAULT, "*%s %s", barejid, message); + win_printf_line(window, THEME_DEFAULT, '-', "*%s %s", barejid, message); } void @@ -1028,13 +1028,13 @@ ui_ask_pgp_passphrase(const char *hint, int prev_fail) win_println(current, 0, ""); if (prev_fail) { - win_printf(current, '!', 0, NULL, 0, 0, "", "Incorrect passphrase"); + win_printf(current, '!', 0, NULL, 0, THEME_DEFAULT, "", "Incorrect passphrase"); } if (hint) { - win_printf(current, '!', 0, NULL, 0, 0, "", "Enter PGP key passphrase for %s", hint); + win_printf(current, '!', 0, NULL, 0, THEME_DEFAULT, "", "Enter PGP key passphrase for %s", hint); } else { - win_printf(current, '!', 0, NULL, 0, 0, "", "Enter PGP key passphrase"); + win_printf(current, '!', 0, NULL, 0, THEME_DEFAULT, "", "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_printf_line(window, THEME_ERROR, "%s", message_str->str); + win_printf_line(window, THEME_ERROR, '-', "%s", message_str->str); g_string_free(message_str, TRUE); } @@ -1237,7 +1237,7 @@ ui_show_lines(ProfWin *window, gchar** lines) if (lines) { int i; for (i = 0; lines[i] != NULL; i++) { - win_printf_line(window, THEME_DEFAULT, "%s", lines[i]); + win_printf_line(window, THEME_DEFAULT, '-', "%s", 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_printf_line(window, THEME_ERROR, "%s", message_str->str); + win_printf_line(window, THEME_ERROR, '-', "%s", message_str->str); g_string_free(message_str, TRUE); } @@ -1320,13 +1320,13 @@ ui_show_software_version(const char *const jid, const char *const presence, win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ":"); } if (name) { - win_printf_line(window, THEME_DEFAULT, "Name : %s", name); + win_printf_line(window, THEME_DEFAULT, '-', "Name : %s", name); } if (version) { - win_printf_line(window, THEME_DEFAULT, "Version : %s", version); + win_printf_line(window, THEME_DEFAULT, '-', "Version : %s", version); } if (os) { - win_printf_line(window, THEME_DEFAULT, "OS : %s", os); + win_printf_line(window, THEME_DEFAULT, '-', "OS : %s", os); } } diff --git a/src/ui/mucconfwin.c b/src/ui/mucconfwin.c index 2c9aaf7a..5bba3bfd 100644 --- a/src/ui/mucconfwin.c +++ b/src/ui/mucconfwin.c @@ -50,9 +50,9 @@ mucconfwin_show_form(ProfMucConfWin *confwin) win_printf(window, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", "Form title: "); win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", confwin->form->title); } else { - win_printf_line(window, THEME_DEFAULT, "Configuration for room %s.", confwin->roomjid); + win_printf_line(window, THEME_DEFAULT, '-', "Configuration for room %s.", confwin->roomjid); } - win_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); 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_printf_line(window, THEME_DEFAULT, "%s", value); + win_printf_line(window, THEME_DEFAULT, '-', "%s", 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_printf_line(window, THEME_DEFAULT, ""); - win_printf_line(window, THEME_DEFAULT, "Use '/form submit' to save changes."); - win_printf_line(window, THEME_DEFAULT, "Use '/form cancel' to cancel changes."); - win_printf_line(window, THEME_DEFAULT, "See '/form help' for more information."); - win_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); + win_printf_line(window, THEME_DEFAULT, '-', "Use '/form submit' to save changes."); + win_printf_line(window, THEME_DEFAULT, '-', "Use '/form cancel' to cancel changes."); + win_printf_line(window, THEME_DEFAULT, '-', "See '/form help' for more information."); + win_printf_line(window, THEME_DEFAULT, '-', ""); } void @@ -118,9 +118,9 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ":"); } if (field->description) { - win_printf_line(window, THEME_DEFAULT, " Description : %s", field->description); + win_printf_line(window, THEME_DEFAULT, '-', " Description : %s", field->description); } - win_printf_line(window, THEME_DEFAULT, " Type : %s", field->type); + win_printf_line(window, THEME_DEFAULT, '-', " Type : %s", field->type); int num_values = 0; GSList *curr_option = NULL; @@ -129,51 +129,51 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) switch (field->type_t) { case FIELD_TEXT_SINGLE: case FIELD_TEXT_PRIVATE: - win_printf_line(window, THEME_DEFAULT, " Set : /%s ", tag); - win_printf_line(window, THEME_DEFAULT, " Where : is any text"); + win_printf_line(window, THEME_DEFAULT, '-', " Set : /%s ", tag); + win_printf_line(window, THEME_DEFAULT, '-', " Where : is any text"); break; case FIELD_TEXT_MULTI: num_values = form_get_value_count(confwin->form, tag); - win_printf_line(window, THEME_DEFAULT, " Add : /%s add ", tag); - win_printf_line(window, THEME_DEFAULT, " Where : is any text"); + win_printf_line(window, THEME_DEFAULT, '-', " Add : /%s add ", tag); + win_printf_line(window, THEME_DEFAULT, '-', " Where : is any text"); if (num_values > 0) { - win_printf_line(window, THEME_DEFAULT, " Remove : /%s remove ", tag); - win_printf_line(window, THEME_DEFAULT, " Where : between 'val1' and 'val%d'", num_values); + win_printf_line(window, THEME_DEFAULT, '-', " Remove : /%s remove ", tag); + win_printf_line(window, THEME_DEFAULT, '-', " Where : between 'val1' and 'val%d'", num_values); } break; case FIELD_BOOLEAN: - win_printf_line(window, THEME_DEFAULT, " Set : /%s ", tag); - win_printf_line(window, THEME_DEFAULT, " Where : is either 'on' or 'off'"); + win_printf_line(window, THEME_DEFAULT, '-', " Set : /%s ", tag); + win_printf_line(window, THEME_DEFAULT, '-', " Where : is either 'on' or 'off'"); break; case FIELD_LIST_SINGLE: - win_printf_line(window, THEME_DEFAULT, " Set : /%s ", tag); - win_printf_line(window, THEME_DEFAULT, " Where : is one of"); + win_printf_line(window, THEME_DEFAULT, '-', " Set : /%s ", tag); + win_printf_line(window, THEME_DEFAULT, '-', " Where : is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; - win_printf_line(window, THEME_DEFAULT, " %s", option->value); + win_printf_line(window, THEME_DEFAULT, '-', " %s", option->value); curr_option = g_slist_next(curr_option); } break; case FIELD_LIST_MULTI: - win_printf_line(window, THEME_DEFAULT, " Add : /%s add ", tag); - win_printf_line(window, THEME_DEFAULT, " Remove : /%s remove ", tag); - win_printf_line(window, THEME_DEFAULT, " Where : is one of"); + win_printf_line(window, THEME_DEFAULT, '-', " Add : /%s add ", tag); + win_printf_line(window, THEME_DEFAULT, '-', " Remove : /%s remove ", tag); + win_printf_line(window, THEME_DEFAULT, '-', " Where : is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; - win_printf_line(window, THEME_DEFAULT, " %s", option->value); + win_printf_line(window, THEME_DEFAULT, '-', " %s", option->value); curr_option = g_slist_next(curr_option); } break; case FIELD_JID_SINGLE: - win_printf_line(window, THEME_DEFAULT, " Set : /%s ", tag); - win_printf_line(window, THEME_DEFAULT, " Where : is a valid Jabber ID"); + win_printf_line(window, THEME_DEFAULT, '-', " Set : /%s ", tag); + win_printf_line(window, THEME_DEFAULT, '-', " Where : is a valid Jabber ID"); break; case FIELD_JID_MULTI: - win_printf_line(window, THEME_DEFAULT, " Add : /%s add ", tag); - win_printf_line(window, THEME_DEFAULT, " Remove : /%s remove ", tag); - win_printf_line(window, THEME_DEFAULT, " Where : is a valid Jabber ID"); + win_printf_line(window, THEME_DEFAULT, '-', " Add : /%s add ", tag); + win_printf_line(window, THEME_DEFAULT, '-', " Remove : /%s remove ", tag); + win_printf_line(window, THEME_DEFAULT, '-', " Where : is a valid Jabber ID"); break; case FIELD_FIXED: case FIELD_UNKNOWN: @@ -182,7 +182,7 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) break; } } else { - win_printf_line(window, THEME_DEFAULT, "No such field %s", tag); + win_printf_line(window, THEME_DEFAULT, '-', "No such field %s", tag); } } @@ -193,9 +193,9 @@ mucconfwin_form_help(ProfMucConfWin *confwin) if (confwin->form->instructions) { ProfWin *window = (ProfWin*) confwin; - win_printf_line(window, THEME_DEFAULT, "Supplied instructions:"); - win_printf_line(window, THEME_DEFAULT, "%s", confwin->form->instructions); - win_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', "Supplied instructions:"); + win_printf_line(window, THEME_DEFAULT, '-', "%s", confwin->form->instructions); + win_printf_line(window, THEME_DEFAULT, '-', ""); } } @@ -245,7 +245,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) char *value = curr_value->data; GString *val_tag = g_string_new(""); g_string_printf(val_tag, "val%d", index++); - win_printf_line(window, THEME_ONLINE, " [%s] %s", val_tag->str, value); + win_printf_line(window, THEME_ONLINE, '-', " [%s] %s", val_tag->str, value); g_string_free(val_tag, TRUE); curr_value = g_slist_next(curr_value); } @@ -275,9 +275,9 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) while (curr_option) { FormOption *option = curr_option->data; if (g_strcmp0(option->value, value) == 0) { - win_printf_line(window, THEME_ONLINE, " [%s] %s", option->value, option->label); + win_printf_line(window, THEME_ONLINE, '-', " [%s] %s", option->value, option->label); } else { - win_printf_line(window, THEME_OFFLINE, " [%s] %s", option->value, option->label); + win_printf_line(window, THEME_OFFLINE, '-', " [%s] %s", option->value, option->label); } curr_option = g_slist_next(curr_option); } @@ -291,9 +291,9 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) while (curr_option) { FormOption *option = curr_option->data; if (g_slist_find_custom(curr_value, option->value, (GCompareFunc)g_strcmp0)) { - win_printf_line(window, THEME_ONLINE, " [%s] %s", option->value, option->label); + win_printf_line(window, THEME_ONLINE, '-', " [%s] %s", option->value, option->label); } else { - win_printf_line(window, THEME_OFFLINE, " [%s] %s", option->value, option->label); + win_printf_line(window, THEME_OFFLINE, '-', " [%s] %s", option->value, option->label); } curr_option = g_slist_next(curr_option); } @@ -312,7 +312,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) win_newline(window); while (curr_value) { char *value = curr_value->data; - win_printf_line(window, THEME_ONLINE, " %s", value); + win_printf_line(window, THEME_ONLINE, '-', " %s", value); curr_value = g_slist_next(curr_value); } break; diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 0b391189..b9e095ae 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -154,7 +154,7 @@ mucwin_room_info_error(ProfMucWin *mucwin, const char *const error) ProfWin *window = (ProfWin*)mucwin; win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Room info request failed: %s", error); - win_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); } void @@ -194,7 +194,7 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s", features->data); features = g_slist_next(features); } - win_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); } } @@ -506,12 +506,12 @@ mucwin_requires_config(ProfMucWin *mucwin) ui_index = 0; } - win_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); 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_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); // currently in groupchat window if (wins_is_current(window)) { @@ -643,7 +643,7 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) default: break; } - win_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); } else { switch (affiliation) { case MUC_AFFILIATION_OWNER: @@ -676,7 +676,7 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) curr_occupant = g_slist_next(curr_occupant); } - win_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); } } @@ -741,7 +741,7 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) default: break; } - win_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); } else { switch (role) { case MUC_ROLE_MODERATOR: @@ -771,7 +771,7 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) curr_occupant = g_slist_next(curr_occupant); } - win_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); } } @@ -807,7 +807,7 @@ mucwin_info(ProfMucWin *mucwin) win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Room: %s", mucwin->roomjid); win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Affiliation: %s", affiliation); win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Role: %s", role); - win_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); } void diff --git a/src/ui/privwin.c b/src/ui/privwin.c index ca20b84b..47fb19a9 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -101,7 +101,7 @@ privwin_message_occupant_offline(ProfPrivateWin *privwin) { assert(privwin != NULL); - win_printf_line((ProfWin*)privwin, THEME_ERROR, "Unable to send message, occupant no longer present in room."); + win_printf_line((ProfWin*)privwin, THEME_ERROR, '-', "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_printf_line((ProfWin*)privwin, THEME_ERROR, "Unable to send message, you are no longer present in room."); + win_printf_line((ProfWin*)privwin, THEME_ERROR, '-', "Unable to send message, you are no longer present in room."); } void @@ -119,7 +119,7 @@ privwin_occupant_offline(ProfPrivateWin *privwin) privwin->occupant_offline = TRUE; Jid *jidp = jid_create(privwin->fulljid); - win_printf_line((ProfWin*)privwin, THEME_OFFLINE, "<- %s has left the room.", jidp->resourcepart); + win_printf_line((ProfWin*)privwin, THEME_OFFLINE, '-', "<- %s has left the room.", jidp->resourcepart); jid_destroy(jidp); } @@ -176,7 +176,7 @@ privwin_occupant_online(ProfPrivateWin *privwin) privwin->occupant_offline = FALSE; Jid *jidp = jid_create(privwin->fulljid); - win_printf_line((ProfWin*)privwin, THEME_ONLINE, "-- %s has joined the room.", jidp->resourcepart); + win_printf_line((ProfWin*)privwin, THEME_ONLINE, '-', "-- %s has joined the room.", jidp->resourcepart); jid_destroy(jidp); } diff --git a/src/ui/ui.h b/src/ui/ui.h index 9ba7e65c..401ca8bd 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -359,7 +359,7 @@ void win_refresh_without_subwin(ProfWin *window); void win_refresh_with_subwin(ProfWin *window); 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_line(ProfWin *window, theme_item_t theme_item, const char *const message, ...); +void win_printf_line(ProfWin *window, theme_item_t theme_item, const char ch, 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 610c9480..5a0c062b 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -815,7 +815,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa caps_destroy(caps); } - win_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); } void @@ -829,7 +829,7 @@ win_show_info(ProfWin *window, PContact contact) theme_item_t presence_colour = theme_main_presence_attrs(presence); - win_printf_line(window, THEME_DEFAULT, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", barejid); if (name) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name); @@ -837,7 +837,7 @@ win_show_info(ProfWin *window, PContact contact) win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ":"); if (sub) { - win_printf_line(window, THEME_DEFAULT, "Subscription: %s", sub); + win_printf_line(window, THEME_DEFAULT, '-', "Subscription: %s", sub); } if (last_activity) { @@ -851,10 +851,10 @@ win_show_info(ProfWin *window, PContact contact) int seconds = span / G_TIME_SPAN_SECOND; if (hours > 0) { - win_printf_line(window, THEME_DEFAULT, "Last activity: %dh%dm%ds", hours, minutes, seconds); + win_printf_line(window, THEME_DEFAULT, '-', "Last activity: %dh%dm%ds", hours, minutes, seconds); } else { - win_printf_line(window, THEME_DEFAULT, "Last activity: %dm%ds", minutes, seconds); + win_printf_line(window, THEME_DEFAULT, '-', "Last activity: %dm%ds", minutes, seconds); } g_date_time_unref(now); @@ -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_printf_line(window, THEME_DEFAULT, "Resources:"); + win_printf_line(window, THEME_DEFAULT, '-', "Resources:"); // sort in order of availability GList *curr = resources; @@ -1038,7 +1038,7 @@ win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim } void -win_printf_line(ProfWin *window, theme_item_t theme_item, const char *const message, ...) +win_printf_line(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...) { GDateTime *timestamp = g_date_time_new_now_local(); @@ -1047,9 +1047,9 @@ win_printf_line(ProfWin *window, theme_item_t theme_item, const char *const mess GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, '-', 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL); + buffer_push(window->layout->buffer, ch, 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL); - _win_print(window, '-', 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL); + _win_print(window, ch, 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); diff --git a/src/ui/window_list.c b/src/ui/window_list.c index ef0f30b1..4996719d 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_printf_line(window, THEME_ERROR, "Lost connection."); + win_printf_line(window, 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 b24ae67b..a26da8c0 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_printf_line(window, THEME_DEFAULT, "SENT:"); - win_printf_line(window, THEME_ONLINE, "%s", &msg[6]); - win_printf_line(window, THEME_ONLINE, ""); + win_printf_line(window, THEME_DEFAULT, '-', "SENT:"); + win_printf_line(window, THEME_ONLINE, '-', "%s", &msg[6]); + win_printf_line(window, THEME_ONLINE, '-', ""); } else if (g_str_has_prefix(msg, "RECV:")) { - win_printf_line(window, THEME_DEFAULT, "RECV:"); - win_printf_line(window, THEME_AWAY, "%s", &msg[6]); - win_printf_line(window, THEME_AWAY, ""); + win_printf_line(window, THEME_DEFAULT, '-', "RECV:"); + win_printf_line(window, THEME_AWAY, '-', "%s", &msg[6]); + win_printf_line(window, THEME_AWAY, '-', ""); } } diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index a4eb7e68..740ce951 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -521,7 +521,7 @@ void win_show_subwin(ProfWin *window) {} void win_refresh_without_subwin(ProfWin *window) {} void win_refresh_with_subwin(ProfWin *window) {} 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_line(ProfWin *window, theme_item_t theme_item, const char *const message, ...) {} +void win_printf_line(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...) {} char* win_get_title(ProfWin *window) {