diff options
author | James Booth <boothj5@gmail.com> | 2016-10-15 18:29:02 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-10-15 18:29:02 +0100 |
commit | 8f1d3ab55c6108333351698518325b6291226e07 (patch) | |
tree | 18caad39aae35578f4aff6f297e0f5aa71356f10 /src/ui | |
parent | 3612270e90db7a824e7f818bb70c88021a1bc16a (diff) | |
download | profani-tty-8f1d3ab55c6108333351698518325b6291226e07.tar.gz |
Add win_print
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/chatwin.c | 38 | ||||
-rw-r--r-- | src/ui/console.c | 183 | ||||
-rw-r--r-- | src/ui/core.c | 70 | ||||
-rw-r--r-- | src/ui/mucconfwin.c | 88 | ||||
-rw-r--r-- | src/ui/mucwin.c | 154 | ||||
-rw-r--r-- | src/ui/privwin.c | 22 | ||||
-rw-r--r-- | src/ui/ui.h | 5 | ||||
-rw-r--r-- | src/ui/window.c | 50 | ||||
-rw-r--r-- | src/ui/window_list.c | 4 | ||||
-rw-r--r-- | src/ui/xmlwin.c | 12 |
10 files changed, 328 insertions, 298 deletions
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index ba2bdc38..3482e1bc 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_printf_line(window, THEME_OTR_STARTED_TRUSTED, '!', "OTR session started (trusted)."); + win_println(window, THEME_OTR_STARTED_TRUSTED, '!', "OTR session started (trusted)."); } else { - win_printf_line(window, THEME_OTR_STARTED_UNTRUSTED, '!', "OTR session started (untrusted)."); + win_println(window, 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_printf_line(window, THEME_OTR_ENDED, '!', "OTR session ended."); + win_println(window, THEME_OTR_ENDED, '!', "OTR session ended."); if (wins_is_current(window)) { title_bar_switch(); } @@ -138,41 +138,41 @@ chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *da switch (event) { case PROF_OTR_SMP_INIT: - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s wants to authenticate your identity, use '/otr secret <secret>'.", chatwin->barejid); break; case PROF_OTR_SMP_INIT_Q: - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s wants to authenticate your identity with the following question:", chatwin->barejid); - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', " %s", (char*)data); - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "use '/otr answer <answer>'."); + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', " %s", (char*)data); + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "use '/otr answer <answer>'."); break; case PROF_OTR_SMP_SENDER_FAIL: - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "Authentication failed, the secret you entered does not match the secret entered by %s.", chatwin->barejid); break; case PROF_OTR_SMP_RECEIVER_FAIL: - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "Authentication failed, the secret entered by %s does not match yours.", chatwin->barejid); break; case PROF_OTR_SMP_ABORT: - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "SMP session aborted."); + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "SMP session aborted."); break; case PROF_OTR_SMP_SUCCESS: - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "Authentication successful."); + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "Authentication successful."); break; case PROF_OTR_SMP_SUCCESS_Q: - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s successfully authenticated you.", chatwin->barejid); + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s successfully authenticated you.", chatwin->barejid); break; case PROF_OTR_SMP_FAIL_Q: - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s failed to authenticate you.", chatwin->barejid); + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s failed to authenticate you.", chatwin->barejid); break; case PROF_OTR_SMP_AUTH: - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "Authenticating %s...", chatwin->barejid); + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "Authenticating %s...", chatwin->barejid); break; case PROF_OTR_SMP_AUTH_WAIT: - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "Awaiting authentication from %s...", chatwin->barejid); + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "Awaiting authentication from %s...", chatwin->barejid); break; default: break; @@ -188,7 +188,7 @@ chatwin_otr_trust(ProfChatWin *chatwin) chatwin->otr_is_trusted = TRUE; ProfWin *window = (ProfWin*)chatwin; - win_printf_line(window, THEME_OTR_TRUSTED, '!', "OTR session trusted."); + win_println(window, 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_printf_line(window, THEME_OTR_UNTRUSTED, '!', "OTR session untrusted."); + win_println(window, THEME_OTR_UNTRUSTED, '!', "OTR session untrusted."); if (wins_is_current(window)) { title_bar_switch(); } @@ -227,7 +227,7 @@ chatwin_recipient_gone(ProfChatWin *chatwin) display_usr = chatwin->barejid; } - win_printf_line((ProfWin*)chatwin, THEME_GONE, '!', "<- %s has left the conversation.", display_usr); + win_println((ProfWin*)chatwin, THEME_GONE, '!', "<- %s has left the conversation.", display_usr); } void @@ -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_println((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 d2e49b4c..48d33bfb 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -67,7 +67,7 @@ void cons_show_time(void) { ProfWin *console = wins_get_console(); - win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", ""); + win_print(console, THEME_DEFAULT, '-', ""); } void @@ -86,7 +86,7 @@ cons_debug(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_DEFAULT, '-', "%s", fmt_msg->str); + win_println(console, THEME_DEFAULT, '-', "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); } @@ -100,7 +100,7 @@ cons_show(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_DEFAULT, '-', "%s", fmt_msg->str); + win_println(console, THEME_DEFAULT, '-', "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); } @@ -124,8 +124,8 @@ 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(console, '-', 0, NULL, NO_EOL, THEME_WHITE_BOLD, "", ""); + win_println(console, THEME_WHITE_BOLD, '-', "%s", &cmd[1]); + win_print(console, THEME_WHITE_BOLD, '-', ""); int i; for (i = 0; i < strlen(cmd) - 1 ; i++) { win_printf(console, '-', 0, NULL, NO_EOL | NO_DATE, THEME_WHITE_BOLD, "", "-"); @@ -133,12 +133,12 @@ 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_println(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_DEFAULT, '-', "%s", help->desc); + win_println(console, THEME_WHITE_BOLD, '-', "Description"); + win_println(console, THEME_DEFAULT, '-', "%s", help->desc); int maxlen = 0; for (i = 0; help->args[i][0] != NULL; i++) { @@ -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_println(console, THEME_WHITE_BOLD, '-', "Arguments"); for (i = 0; help->args[i][0] != NULL; i++) { win_printf(console, '-', maxlen + 3, NULL, 0, THEME_DEFAULT, "", "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]); } @@ -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_println(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_println(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_println(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_println(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_println(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_println(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_println(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_println(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_println(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_println(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_println(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_println(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_println(console, THEME_INCOMING, '-', "<< private message: %s in %s (win %d)", nick, room, ui_index); cons_alert(); } @@ -417,23 +417,23 @@ 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_println(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); + win_println(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_println(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, '-', "License GPLv3+: GNU GPL version 3 or later <https://www.gnu.org/licenses/gpl.html>"); - win_printf_line(console, THEME_DEFAULT, '-', ""); - win_printf_line(console, THEME_DEFAULT, '-', "This is free software; you are free to change and redistribute it."); - win_printf_line(console, THEME_DEFAULT, '-', "There is NO WARRANTY, to the extent permitted by law."); - win_printf_line(console, THEME_DEFAULT, '-', ""); - win_printf_line(console, THEME_DEFAULT, '-', "Type '/help' to show complete help."); - win_printf_line(console, THEME_DEFAULT, '-', ""); + win_println(console, THEME_DEFAULT, '-', "Copyright (C) 2012 - 2016 James Booth <%s>.", PACKAGE_BUGREPORT); + win_println(console, THEME_DEFAULT, '-', "License GPLv3+: GNU GPL version 3 or later <https://www.gnu.org/licenses/gpl.html>"); + win_println(console, THEME_DEFAULT, '-', ""); + win_println(console, THEME_DEFAULT, '-', "This is free software; you are free to change and redistribute it."); + win_println(console, THEME_DEFAULT, '-', "There is NO WARRANTY, to the extent permitted by law."); + win_println(console, THEME_DEFAULT, '-', ""); + win_println(console, THEME_DEFAULT, '-', "Type '/help' to show complete help."); + win_println(console, THEME_DEFAULT, '-', ""); if (prefs_get_boolean(PREF_VERCHECK)) { cons_check_version(FALSE); @@ -455,13 +455,13 @@ 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, '-', "Check <http://www.profanity.im> for details."); - win_printf_line(console, THEME_DEFAULT, '-', ""); + win_println(console, THEME_DEFAULT, '-', "A new version of Profanity is available: %s", latest_release); + win_println(console, THEME_DEFAULT, '-', "Check <http://www.profanity.im> for details."); + win_println(console, THEME_DEFAULT, '-', ""); } else { if (not_available_msg) { - win_printf_line(console, THEME_DEFAULT, '-', "No new version available."); - win_printf_line(console, THEME_DEFAULT, '-', ""); + win_println(console, THEME_DEFAULT, '-', "No new version available."); + win_println(console, THEME_DEFAULT, '-', ""); } } @@ -475,7 +475,7 @@ void cons_show_login_success(ProfAccount *account, gboolean secured) { ProfWin *console = wins_get_console(); - win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", "%s logged in successfully, ", account->jid); + win_print(console, THEME_DEFAULT, '-', "%s logged in successfully, ", account->jid); resource_presence_t presence = accounts_get_login_presence(account->name); const char *presence_str = string_from_resource_presence(presence); @@ -509,7 +509,7 @@ cons_show_wins(gboolean unread) GSList *curr = window_strings; while (curr) { - win_printf_line(console, THEME_DEFAULT, '-', "%s", curr->data); + win_println(console, THEME_DEFAULT, '-', "%s", curr->data); curr = g_slist_next(curr); } g_slist_free_full(window_strings, free); @@ -554,13 +554,13 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) const char *resource_presence = string_from_resource_presence(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, presence_colour, '-', "%s", fulljid); win_printf(console, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ":"); // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", "Identity: "); + win_print(console, THEME_DEFAULT, '-', "Identity: "); if (identity->name) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); if (identity->category || identity->type) { @@ -582,7 +582,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { - win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", "Software: %s", software_version->software); + win_print(console, THEME_DEFAULT, '-', "Software: %s", software_version->software); } if (software_version->software_version) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); @@ -591,7 +591,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) win_newline(console); } if (software_version->os) { - win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", "OS: %s", software_version->os); + win_print(console, THEME_DEFAULT, '-', "OS: %s", software_version->os); } if (software_version->os_version) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); @@ -602,10 +602,10 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) } if (caps->features) { - win_printf_line(console, THEME_DEFAULT, '-', "Features:"); + win_println(console, THEME_DEFAULT, '-', "Features:"); GSList *feature = caps->features; while (feature) { - win_printf_line(console, THEME_DEFAULT, '-', " %s", feature->data); + win_println(console, THEME_DEFAULT, '-', " %s", feature->data); feature = g_slist_next(feature); } } @@ -667,7 +667,7 @@ cons_show_room_list(GSList *rooms, const char *const conference_node) cons_show("Chat rooms at %s:", conference_node); while (rooms) { DiscoItem *room = rooms->data; - win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " %s", room->jid); + win_print(console, THEME_DEFAULT, '-', " %s", room->jid); if (room->name) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", (%s)", room->name); } @@ -701,7 +701,7 @@ cons_show_bookmarks(const GList *list) if (muc_active(item->barejid)) { presence_colour = THEME_ONLINE; } - win_printf(console, '-', 0, NULL, NO_EOL, presence_colour, "", " %s", item->barejid); + win_print(console, presence_colour, '-', " %s", item->barejid); if (item->nick) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "/%s", item->nick); } @@ -784,7 +784,7 @@ cons_show_disco_items(GSList *items, const char *const jid) cons_show("Service discovery items for %s:", jid); while (items) { DiscoItem *item = items->data; - win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " %s", item->jid); + win_print(console, THEME_DEFAULT, '-', " %s", item->jid); if (item->name) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", (%s)", item->name); } @@ -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_println(console, presence_colour, '-', "%s", accounts[i]); } else { cons_show(accounts[i]); } @@ -982,7 +982,7 @@ cons_show_account(ProfAccount *account) GList *curr = resources; if (curr) { - win_printf_line(console, THEME_DEFAULT, '-', "Resources:"); + win_println(console, THEME_DEFAULT, '-', "Resources:"); // sort in order of availability while (curr) { @@ -1000,7 +1000,7 @@ cons_show_account(ProfAccount *account) Resource *resource = curr->data; const char *resource_presence = string_from_resource_presence(resource->presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); - win_printf(console, '-', 0, NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence); + win_print(console, presence_colour, '-', " %s (%d), %s", resource->name, resource->priority, resource_presence); if (resource->status) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); @@ -1014,7 +1014,7 @@ cons_show_account(ProfAccount *account) // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " Identity: "); + win_print(console, THEME_DEFAULT, '-', " Identity: "); if (identity->name) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); if (identity->category || identity->type) { @@ -1036,7 +1036,7 @@ cons_show_account(ProfAccount *account) if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { - win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " Software: %s", software_version->software); + win_print(console, THEME_DEFAULT, '-', " Software: %s", software_version->software); } if (software_version->software_version) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); @@ -1045,7 +1045,7 @@ cons_show_account(ProfAccount *account) win_newline(console); } if (software_version->os) { - win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " OS: %s", software_version->os); + win_print(console, THEME_DEFAULT, '-', " OS: %s", software_version->os); } if (software_version->os_version) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); @@ -2078,7 +2078,7 @@ cons_navigation_help(void) { ProfWin *console = wins_get_console(); cons_show(""); - win_printf_line(console, THEME_WHITE_BOLD, '-', "Navigation"); + win_println(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."); @@ -2184,7 +2184,7 @@ _cons_theme_bar_prop(theme_item_t theme, char *prop) GString *propstr = g_string_new(" "); g_string_append_printf(propstr, "%-24s", prop); - win_printf(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", "%s", propstr->str); + win_print(console, THEME_TEXT, '-', "%s", propstr->str); g_string_free(propstr, TRUE); GString *valstr = g_string_new(" "); @@ -2203,7 +2203,7 @@ _cons_theme_prop(theme_item_t theme, char *prop) GString *propstr = g_string_new(" "); g_string_append_printf(propstr, "%-24s", prop); - win_printf(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", "%s", propstr->str); + win_print(console, THEME_TEXT, '-', "%s", propstr->str); g_string_free(propstr, TRUE); GString *valstr = g_string_new(""); @@ -2325,22 +2325,31 @@ cons_theme_colours(void) ProfWin *console = wins_get_console(); cons_show("Available colours:"); - 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"); + + win_print(console, THEME_WHITE, '-', " white "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", " bold_white"); + + win_print(console, THEME_GREEN, '-', " green "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_GREEN_BOLD, "", " bold_green"); + + win_print(console, THEME_RED, '-', " red "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_RED_BOLD, "", " bold_red"); + + win_print(console, THEME_YELLOW, '-', " yellow "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_YELLOW_BOLD, "", " bold_yellow"); + + win_print(console, THEME_BLUE, '-', " blue "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_BLUE_BOLD, "", " bold_blue"); + + win_print(console, THEME_CYAN, '-', " cyan "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_CYAN_BOLD, "", " bold_cyan"); + + win_print(console, THEME_MAGENTA, '-', " magenta "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_MAGENTA_BOLD, "", " bold_magenta"); + + win_print(console, THEME_BLACK, '-', " black "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_BLACK_BOLD, "", " bold_black"); + cons_show(""); } @@ -2348,25 +2357,25 @@ static void _cons_splash_logo(void) { ProfWin *console = wins_get_console(); - win_printf_line(console, THEME_DEFAULT, '-', "Welcome to"); + win_println(console, THEME_DEFAULT, '-', "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_println(console, THEME_SPLASH, '-', " ___ _ "); + win_println(console, THEME_SPLASH, '-', " / __) (_)_ "); + win_println(console, THEME_SPLASH, '-', " ____ ____ ___ | |__ ____ ____ _| |_ _ _ "); + win_println(console, THEME_SPLASH, '-', "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |"); + win_println(console, THEME_SPLASH, '-', "| | | | | | |_| | | ( ( | | | | | | |_| |_| |"); + win_println(console, THEME_SPLASH, '-', "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |"); + win_println(console, THEME_SPLASH, '-', "|_| (____/ "); + win_println(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_println(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); + win_println(console, THEME_DEFAULT, "Version %sdev", PACKAGE_VERSION); #endif } else { - win_printf_line(console, THEME_DEFAULT, '-', "Version %s", PACKAGE_VERSION); + win_println(console, THEME_DEFAULT, '-', "Version %s", PACKAGE_VERSION); } } @@ -2393,7 +2402,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) } else { presence_colour = theme_main_presence_attrs("offline"); } - win_printf(console, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", title->str); + win_print(console, presence_colour, '-', "%s", title->str); g_string_free(title, TRUE); diff --git a/src/ui/core.c b/src/ui/core.c index 7e762398..178823c8 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -413,19 +413,19 @@ ui_handle_recipient_error(const char *const recipient, const char *const err_msg ProfChatWin *chatwin = wins_get_chat(recipient); if (chatwin) { - win_printf_line((ProfWin*)chatwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); + win_println((ProfWin*)chatwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); return; } ProfMucWin *mucwin = wins_get_muc(recipient); if (mucwin) { - win_printf_line((ProfWin*)mucwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); + win_println((ProfWin*)mucwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); return; } ProfPrivateWin *privatewin = wins_get_private(recipient); if (privatewin) { - win_printf_line((ProfWin*)privatewin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); + win_println((ProfWin*)privatewin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); return; } } @@ -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_printf_line((ProfWin*)chatwin, THEME_ERROR, '!', "%s", message); + win_println((ProfWin*)chatwin, THEME_ERROR, '!', "%s", message); } else { cons_show_error("%s - %s", barejid, message); } @@ -739,7 +739,7 @@ ui_current_print_line(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(window, THEME_DEFAULT, '-', "%s", fmt_msg->str); + win_println(window, THEME_DEFAULT, '-', "%s", fmt_msg->str); va_end(arg); g_string_free(fmt_msg, TRUE); } @@ -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_printf_line(current, attrs, show_char, "%s", fmt_msg->str); + win_println(current, attrs, show_char, "%s", fmt_msg->str); va_end(arg); g_string_free(fmt_msg, TRUE); } @@ -777,7 +777,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_println(window, THEME_DEFAULT, '-', "*%s %s", barejid, message); } void @@ -789,7 +789,7 @@ ui_room_join(const char *const roomjid, gboolean focus) } char *nick = muc_nick(roomjid); - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "-> You have joined the room as %s", nick); + win_print(window, THEME_ROOMINFO, '!', "-> You have joined the room as %s", nick); if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { char *role = muc_role_str(roomjid); char *affiliation = muc_affiliation_str(roomjid); @@ -810,7 +810,7 @@ ui_room_join(const char *const roomjid, gboolean focus) status_bar_active(num); ProfWin *console = wins_get_console(); char *nick = muc_nick(roomjid); - win_printf_line(console, THEME_TYPING, '!', "-> Autojoined %s as %s (%d).", roomjid, nick, num); + win_println(console, THEME_TYPING, '!', "-> Autojoined %s as %s (%d).", roomjid, nick, num); } GList *privwins = wins_get_private_chats(roomjid); @@ -885,16 +885,16 @@ ui_room_destroyed(const char *const roomjid, const char *const reason, const cha ProfWin *console = wins_get_console(); if (reason) { - win_printf_line(console, THEME_TYPING, '!', "<- Room destroyed: %s, reason: %s", roomjid, reason); + win_println(console, THEME_TYPING, '!', "<- Room destroyed: %s, reason: %s", roomjid, reason); } else { - win_printf_line(console, THEME_TYPING, '!', "<- Room destroyed: %s", roomjid); + win_println(console, THEME_TYPING, '!', "<- Room destroyed: %s", roomjid); } if (new_jid) { if (password) { - win_printf_line(console, THEME_TYPING, '!', "Replacement room: %s, password: %s", new_jid, password); + win_println(console, THEME_TYPING, '!', "Replacement room: %s, password: %s", new_jid, password); } else { - win_printf_line(console, THEME_TYPING, '!', "Replacement room: %s", new_jid); + win_println(console, THEME_TYPING, '!', "Replacement room: %s", new_jid); } } } @@ -931,7 +931,7 @@ ui_room_kicked(const char *const roomjid, const char *const actor, const char *c } ProfWin *console = wins_get_console(); - win_printf_line(console, THEME_TYPING, '!', "<- %s", message->str); + win_println(console, THEME_TYPING, '!', "<- %s", message->str); g_string_free(message, TRUE); } @@ -967,7 +967,7 @@ ui_room_banned(const char *const roomjid, const char *const actor, const char *c } ProfWin *console = wins_get_console(); - win_printf_line(console, THEME_TYPING, '!', "<- %s", message->str); + win_println(console, THEME_TYPING, '!', "<- %s", message->str); g_string_free(message, TRUE); } @@ -1012,16 +1012,16 @@ ui_ask_pgp_passphrase(const char *hint, int prev_fail) { ProfWin *current = wins_get_current(); - win_printf_line(current, THEME_DEFAULT, '-', ""); + win_println(current, THEME_DEFAULT, '-', ""); if (prev_fail) { - win_printf_line(current, THEME_DEFAULT, '!', "Incorrect passphrase"); + win_println(current, THEME_DEFAULT, '!', "Incorrect passphrase"); } if (hint) { - win_printf_line(current, THEME_DEFAULT, '!', "Enter PGP key passphrase for %s", hint); + win_println(current, THEME_DEFAULT, '!', "Enter PGP key passphrase for %s", hint); } else { - win_printf_line(current, THEME_DEFAULT, '!', "Enter PGP key passphrase"); + win_println(current, THEME_DEFAULT, '!', "Enter PGP key passphrase"); } ui_update(); @@ -1145,7 +1145,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_println(window, THEME_ERROR, '-', "%s", message_str->str); g_string_free(message_str, TRUE); } @@ -1169,7 +1169,7 @@ ui_handle_room_config_submit_result(const char *const roomjid) if (muc_window) { ui_focus_win((ProfWin*)muc_window); - win_printf_line(muc_window, THEME_ROOMINFO, '!', "Room configuration successful"); + win_println(muc_window, THEME_ROOMINFO, '!', "Room configuration successful"); } else { ProfWin *console = wins_get_console(); ui_focus_win(console); @@ -1196,25 +1196,25 @@ ui_handle_room_config_submit_result_error(const char *const roomjid, const char if (form_window) { if (message) { - win_printf_line(form_window, THEME_ERROR, '!', "Configuration error: %s", message); + win_println(form_window, THEME_ERROR, '!', "Configuration error: %s", message); } else { - win_printf_line(form_window, THEME_ERROR, '!', "Configuration error"); + win_println(form_window, THEME_ERROR, '!', "Configuration error"); } } else if (muc_window) { if (message) { - win_printf_line(muc_window, THEME_ERROR, '!', "Configuration error: %s", message); + win_println(muc_window, THEME_ERROR, '!', "Configuration error: %s", message); } else { - win_printf_line(muc_window, THEME_ERROR, '!', "Configuration error"); + win_println(muc_window, THEME_ERROR, '!', "Configuration error"); } } else { if (message) { - win_printf_line(console, THEME_ERROR, '!', "Configuration error for %s: %s", roomjid, message); + win_println(console, THEME_ERROR, '!', "Configuration error for %s: %s", roomjid, message); } else { - win_printf_line(console, THEME_ERROR, '!', "Configuration error for %s", roomjid); + win_println(console, THEME_ERROR, '!', "Configuration error for %s", roomjid); } } } else { - win_printf_line(console, THEME_ERROR, '!', "Configuration error"); + win_println(console, THEME_ERROR, '!', "Configuration error"); } } @@ -1224,7 +1224,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_println(window, THEME_DEFAULT, '-', "%s", lines[i]); } } } @@ -1261,7 +1261,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_println(window, THEME_ERROR, '-', "%s", message_str->str); g_string_free(message_str, TRUE); } @@ -1301,19 +1301,19 @@ ui_show_software_version(const char *const jid, const char *const presence, } if (name || version || os) { - win_printf_line(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, '-', ""); theme_item_t presence_colour = theme_main_presence_attrs(presence); - win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", jid); + win_print(window, presence_colour, '-', "%s", jid); win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ":"); } if (name) { - win_printf_line(window, THEME_DEFAULT, '-', "Name : %s", name); + win_println(window, THEME_DEFAULT, '-', "Name : %s", name); } if (version) { - win_printf_line(window, THEME_DEFAULT, '-', "Version : %s", version); + win_println(window, THEME_DEFAULT, '-', "Version : %s", version); } if (os) { - win_printf_line(window, THEME_DEFAULT, '-', "OS : %s", os); + win_println(window, THEME_DEFAULT, '-', "OS : %s", os); } } diff --git a/src/ui/mucconfwin.c b/src/ui/mucconfwin.c index 16a6bb2a..8a9c3951 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_printf(window, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", "Form title: "); + win_print(window, 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_println(window, THEME_DEFAULT, '-', "Configuration for room %s.", confwin->roomjid); } - win_printf_line(window, THEME_DEFAULT, '-', ""); + win_println(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_println(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); @@ -83,7 +83,7 @@ mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag) FormField *field = form_get_field_by_tag(form, tag); ProfWin *window = (ProfWin*)confwin; _mucconfwin_form_field(window, tag, field); - win_printf_line(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, '-', ""); } void @@ -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_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, '-', "Use '/form submit' to save changes."); + win_println(window, THEME_DEFAULT, '-', "Use '/form cancel' to cancel changes."); + win_println(window, THEME_DEFAULT, '-', "See '/form help' for more information."); + win_println(window, THEME_DEFAULT, '-', ""); } void @@ -111,16 +111,16 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) ProfWin *window = (ProfWin*) confwin; FormField *field = form_get_field_by_tag(confwin->form, tag); if (field) { - win_printf(window, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", "%s", field->label); + win_print(window, THEME_DEFAULT, '-', "%s", field->label); if (field->required) { win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", " (Required):"); } else { win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ":"); } if (field->description) { - win_printf_line(window, THEME_DEFAULT, '-', " Description : %s", field->description); + win_println(window, THEME_DEFAULT, '-', " Description : %s", field->description); } - win_printf_line(window, THEME_DEFAULT, '-', " Type : %s", field->type); + win_println(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 <value>", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Where : <value> is any text"); + win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); + win_println(window, THEME_DEFAULT, '-', " Where : <value> 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 <value>", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Where : <value> is any text"); + win_println(window, THEME_DEFAULT, '-', " Add : /%s add <value>", tag); + win_println(window, THEME_DEFAULT, '-', " Where : <value> is any text"); if (num_values > 0) { - win_printf_line(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Where : <value> between 'val1' and 'val%d'", num_values); + win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag); + win_println(window, THEME_DEFAULT, '-', " Where : <value> between 'val1' and 'val%d'", num_values); } break; case FIELD_BOOLEAN: - win_printf_line(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Where : <value> is either 'on' or 'off'"); + win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); + win_println(window, THEME_DEFAULT, '-', " Where : <value> is either 'on' or 'off'"); break; case FIELD_LIST_SINGLE: - win_printf_line(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Where : <value> is one of"); + win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); + win_println(window, THEME_DEFAULT, '-', " Where : <value> is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; - win_printf_line(window, THEME_DEFAULT, '-', " %s", option->value); + win_println(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 <value>", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Where : <value> is one of"); + win_println(window, THEME_DEFAULT, '-', " Add : /%s add <value>", tag); + win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag); + win_println(window, THEME_DEFAULT, '-', " Where : <value> is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; - win_printf_line(window, THEME_DEFAULT, '-', " %s", option->value); + win_println(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 <value>", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Where : <value> is a valid Jabber ID"); + win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag); + win_println(window, THEME_DEFAULT, '-', " Where : <value> is a valid Jabber ID"); break; case FIELD_JID_MULTI: - win_printf_line(window, THEME_DEFAULT, '-', " Add : /%s add <value>", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Where : <value> is a valid Jabber ID"); + win_println(window, THEME_DEFAULT, '-', " Add : /%s add <value>", tag); + win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag); + win_println(window, THEME_DEFAULT, '-', " Where : <value> 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_println(window, THEME_DEFAULT, '-', "No such field %s", tag); } } @@ -193,16 +193,16 @@ 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_println(window, THEME_DEFAULT, '-', "Supplied instructions:"); + win_println(window, THEME_DEFAULT, '-', "%s", confwin->form->instructions); + win_println(window, THEME_DEFAULT, '-', ""); } } static void _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) { - win_printf(window, '-', 0, NULL, NO_EOL, THEME_AWAY, "", "[%s] ", tag); + win_print(window, THEME_AWAY, '-', "[%s] ", tag); win_printf(window, '-', 0, NULL, NO_EOL | NO_DATE, THEME_DEFAULT, "", "%s", field->label); if (field->required) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " (required): "); @@ -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_println(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_println(window, THEME_ONLINE, '-', " [%s] %s", option->value, option->label); } else { - win_printf_line(window, THEME_OFFLINE, '-', " [%s] %s", option->value, option->label); + win_println(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_println(window, THEME_ONLINE, '-', " [%s] %s", option->value, option->label); } else { - win_printf_line(window, THEME_OFFLINE, '-', " [%s] %s", option->value, option->label); + win_println(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_println(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 75fbc8d4..a1196ac4 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -51,7 +51,7 @@ mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your role has been changed to: %s", role); + win_print(window, THEME_ROOMINFO, '!', "Your role has been changed to: %s", role); if (actor) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); } @@ -68,7 +68,7 @@ mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, con assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your affiliation has been changed to: %s", affiliation); + win_print(window, THEME_ROOMINFO, '!', "Your affiliation has been changed to: %s", affiliation); if (actor) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); } @@ -85,7 +85,7 @@ mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, c assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); + win_print(window, THEME_ROOMINFO, '!', "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); if (actor) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); } @@ -103,7 +103,7 @@ mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const ch assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%s's role has been changed to: %s", nick, role); + win_print(window, THEME_ROOMINFO, '!', "%s's role has been changed to: %s", nick, role); if (actor) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); } @@ -120,7 +120,7 @@ mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, c assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%s's affiliation has been changed to: %s", nick, affiliation); + win_print(window, THEME_ROOMINFO, '!', "%s's affiliation has been changed to: %s", nick, affiliation); if (actor) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); } @@ -137,7 +137,7 @@ mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *cons assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation); + win_print(window, THEME_ROOMINFO, '!', "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation); if (actor) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); } @@ -153,8 +153,8 @@ mucwin_room_info_error(ProfMucWin *mucwin, const char *const error) assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf_line(window, THEME_DEFAULT, '!', "Room info request failed: %s", error); - win_printf_line(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, '!', "Room info request failed: %s", error); + win_println(window, THEME_DEFAULT, '-', ""); } 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_printf_line(window, THEME_DEFAULT, '!', "Identities:"); + win_println(window, THEME_DEFAULT, '!', "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_printf_line(window, THEME_DEFAULT, '!', "%s", identity_str->str); + win_println(window, THEME_DEFAULT, '!', "%s", identity_str->str); g_string_free(identity_str, TRUE); identities = g_slist_next(identities); } if (features) { - win_printf_line(window, THEME_DEFAULT, '!', "Features:"); + win_println(window, THEME_DEFAULT, '!', "Features:"); } while (features) { - win_printf_line(window, THEME_DEFAULT, '!', " %s", features->data); + win_println(window, THEME_DEFAULT, '!', " %s", features->data); features = g_slist_next(features); } - win_printf_line(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, '-', ""); } } @@ -206,16 +206,16 @@ 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_printf_line(window, THEME_ROOMINFO, '!', "Room is empty."); + win_println(window, THEME_ROOMINFO, '!', "Room is empty."); } else { - win_printf_line(window, THEME_ROOMINFO, '!', "No occupants %s.", presence); + win_println(window, THEME_ROOMINFO, '!', "No occupants %s.", presence); } } else { int length = g_list_length(roster); if (presence == NULL) { - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d occupants: ", length); + win_print(window, THEME_ROOMINFO, '!', "%d occupants: ", length); } else { - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d %s: ", length, presence); + win_print(window, THEME_ROOMINFO, '!', "%d %s: ", length, presence); } while (roster) { @@ -242,7 +242,7 @@ mucwin_occupant_offline(ProfMucWin *mucwin, const char *const nick) assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf_line(window, THEME_OFFLINE, '!', "<- %s has left the room.", nick); + win_println(window, THEME_OFFLINE, '!', "<- %s has left the room.", nick); } void @@ -263,7 +263,7 @@ mucwin_occupant_kicked(ProfMucWin *mucwin, const char *const nick, const char *c g_string_append(message, reason); } - win_printf_line(window, THEME_OFFLINE, '!', "<- %s", message->str); + win_println(window, THEME_OFFLINE, '!', "<- %s", message->str); g_string_free(message, TRUE); } @@ -285,7 +285,7 @@ mucwin_occupant_banned(ProfMucWin *mucwin, const char *const nick, const char *c g_string_append(message, reason); } - win_printf_line(window, THEME_OFFLINE, '!', "<- %s", message->str); + win_println(window, THEME_OFFLINE, '!', "<- %s", message->str); g_string_free(message, TRUE); } @@ -296,7 +296,7 @@ mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *c assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ONLINE, "", "-> %s has joined the room", nick); + win_print(window, THEME_ONLINE, '!', "-> %s has joined the room", nick); if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { if (role) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", role: %s", role); @@ -324,7 +324,7 @@ mucwin_occupant_nick_change(ProfMucWin *mucwin, const char *const old_nick, cons assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf_line(window, THEME_THEM, '!', "** %s is now known as %s", old_nick, nick); + win_println(window, THEME_THEM, '!', "** %s is now known as %s", old_nick, nick); } void @@ -333,7 +333,7 @@ mucwin_nick_change(ProfMucWin *mucwin, const char *const nick) assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf_line(window, THEME_ME, '!', "** You are now known as %s", nick); + win_println(window, THEME_ME, '!', "** You are now known as %s", nick); } void @@ -506,12 +506,12 @@ mucwin_requires_config(ProfMucWin *mucwin) ui_index = 0; } - win_printf_line(window, THEME_DEFAULT, '-', ""); - win_printf_line(window, THEME_ROOMINFO, '!', "Room locked, requires configuration."); - win_printf_line(window, THEME_ROOMINFO, '!', "Use '/room accept' to accept the defaults"); - win_printf_line(window, THEME_ROOMINFO, '!', "Use '/room destroy' to cancel and destroy the room"); - win_printf_line(window, THEME_ROOMINFO, '!', "Use '/room config' to edit the room configuration"); - win_printf_line(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_ROOMINFO, '!', "Room locked, requires configuration."); + win_println(window, THEME_ROOMINFO, '!', "Use '/room accept' to accept the defaults"); + win_println(window, THEME_ROOMINFO, '!', "Use '/room destroy' to cancel and destroy the room"); + win_println(window, THEME_ROOMINFO, '!', "Use '/room config' to edit the room configuration"); + win_println(window, THEME_DEFAULT, '-', ""); // currently in groupchat window if (wins_is_current(window)) { @@ -533,17 +533,17 @@ mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const sub if (subject) { if (nick) { - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "*%s has set the room subject: ", nick); + win_print(window, THEME_ROOMINFO, '!', "*%s has set the room subject: ", nick); win_printf(window, '!', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", subject); } else { - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: "); + win_print(window, THEME_ROOMINFO, '!', "Room subject: "); win_printf(window, '!', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", subject); } } else { if (nick) { - win_printf_line(window, THEME_ROOMINFO, '!', "*%s has cleared the room subject.", nick); + win_println(window, THEME_ROOMINFO, '!', "*%s has cleared the room subject.", nick); } else { - win_printf_line(window, THEME_ROOMINFO, '!', "Room subject cleared"); + win_println(window, THEME_ROOMINFO, '!', "Room subject cleared"); } } @@ -563,7 +563,7 @@ mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf_line(window, THEME_ERROR, '!', "Error kicking %s: %s", nick, error); + win_println(window, THEME_ERROR, '!', "Error kicking %s: %s", nick, error); } void @@ -574,7 +574,7 @@ mucwin_broadcast(ProfMucWin *mucwin, const char *const message) ProfWin *window = (ProfWin*)mucwin; int num = wins_get_num(window); - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room message: "); + win_print(window, THEME_ROOMINFO, '!', "Room message: "); win_printf(window, '!', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", message); // currently in groupchat window @@ -594,7 +594,7 @@ mucwin_affiliation_list_error(ProfMucWin *mucwin, const char *const affiliation, assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf_line(window, THEME_ERROR, '!', "Error retrieving %s list: %s", affiliation, error); + win_println(window, THEME_ERROR, '!', "Error retrieving %s list: %s", affiliation, error); } void @@ -604,17 +604,17 @@ mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation ProfWin *window = (ProfWin*)mucwin; if (jids) { - win_printf_line(window, THEME_DEFAULT, '!', "Affiliation: %s", affiliation); + win_println(window, THEME_DEFAULT, '!', "Affiliation: %s", affiliation); GSList *curr_jid = jids; while (curr_jid) { const char *jid = curr_jid->data; - win_printf_line(window, THEME_DEFAULT, '!', " %s", jid); + win_println(window, THEME_DEFAULT, '!', " %s", jid); curr_jid = g_slist_next(curr_jid); } - win_printf_line(window, THEME_DEFAULT, '!', ""); + win_println(window, THEME_DEFAULT, '!', ""); } else { - win_printf_line(window, THEME_DEFAULT, '!', "No users found with affiliation: %s", affiliation); - win_printf_line(window, THEME_DEFAULT, '!', ""); + win_println(window, THEME_DEFAULT, '!', "No users found with affiliation: %s", affiliation); + win_println(window, THEME_DEFAULT, '!', ""); } } @@ -629,34 +629,34 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) if (!occupants) { switch (affiliation) { case MUC_AFFILIATION_OWNER: - win_printf_line(window, THEME_DEFAULT, '!', "No owners found."); + win_println(window, THEME_DEFAULT, '!', "No owners found."); break; case MUC_AFFILIATION_ADMIN: - win_printf_line(window, THEME_DEFAULT, '!', "No admins found."); + win_println(window, THEME_DEFAULT, '!', "No admins found."); break; case MUC_AFFILIATION_MEMBER: - win_printf_line(window, THEME_DEFAULT, '!', "No members found."); + win_println(window, THEME_DEFAULT, '!', "No members found."); break; case MUC_AFFILIATION_OUTCAST: - win_printf_line(window, THEME_DEFAULT, '!', "No outcasts found."); + win_println(window, THEME_DEFAULT, '!', "No outcasts found."); break; default: break; } - win_printf_line(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, '-', ""); } else { switch (affiliation) { case MUC_AFFILIATION_OWNER: - win_printf_line(window, THEME_DEFAULT, '!', "Owners:"); + win_println(window, THEME_DEFAULT, '!', "Owners:"); break; case MUC_AFFILIATION_ADMIN: - win_printf_line(window, THEME_DEFAULT, '!', "Admins:"); + win_println(window, THEME_DEFAULT, '!', "Admins:"); break; case MUC_AFFILIATION_MEMBER: - win_printf_line(window, THEME_DEFAULT, '!', "Members:"); + win_println(window, THEME_DEFAULT, '!', "Members:"); break; case MUC_AFFILIATION_OUTCAST: - win_printf_line(window, THEME_DEFAULT, '!', "Outcasts:"); + win_println(window, THEME_DEFAULT, '!', "Outcasts:"); break; default: break; @@ -667,16 +667,16 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) Occupant *occupant = curr_occupant->data; if (occupant->affiliation == affiliation) { if (occupant->jid) { - win_printf_line(window, THEME_DEFAULT, '!', " %s (%s)", occupant->nick, occupant->jid); + win_println(window, THEME_DEFAULT, '!', " %s (%s)", occupant->nick, occupant->jid); } else { - win_printf_line(window, THEME_DEFAULT, '!', " %s", occupant->nick); + win_println(window, THEME_DEFAULT, '!', " %s", occupant->nick); } } curr_occupant = g_slist_next(curr_occupant); } - win_printf_line(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, '-', ""); } } @@ -686,7 +686,7 @@ mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const char *c assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf_line(window, THEME_ERROR, '!', "Error retrieving %s list: %s", role, error); + win_println(window, THEME_ERROR, '!', "Error retrieving %s list: %s", role, error); } void @@ -696,26 +696,26 @@ mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nick ProfWin *window = (ProfWin*)mucwin; if (nicks) { - win_printf_line(window, THEME_DEFAULT, '!', "Role: %s", role); + win_println(window, THEME_DEFAULT, '!', "Role: %s", role); GSList *curr_nick = nicks; while (curr_nick) { const char *nick = curr_nick->data; Occupant *occupant = muc_roster_item(mucwin->roomjid, nick); if (occupant) { if (occupant->jid) { - win_printf_line(window, THEME_DEFAULT, '!', " %s (%s)", nick, occupant->jid); + win_println(window, THEME_DEFAULT, '!', " %s (%s)", nick, occupant->jid); } else { - win_printf_line(window, THEME_DEFAULT, '!', " %s", nick); + win_println(window, THEME_DEFAULT, '!', " %s", nick); } } else { - win_printf_line(window, THEME_DEFAULT, '!', " %s", nick); + win_println(window, THEME_DEFAULT, '!', " %s", nick); } curr_nick = g_slist_next(curr_nick); } - win_printf_line(window, THEME_DEFAULT, '!', ""); + win_println(window, THEME_DEFAULT, '!', ""); } else { - win_printf_line(window, THEME_DEFAULT, '!', "No occupants found with role: %s", role); - win_printf_line(window, THEME_DEFAULT, '!', ""); + win_println(window, THEME_DEFAULT, '!', "No occupants found with role: %s", role); + win_println(window, THEME_DEFAULT, '!', ""); } } @@ -730,28 +730,28 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) if (!occupants) { switch (role) { case MUC_ROLE_MODERATOR: - win_printf_line(window, THEME_DEFAULT, '!', "No moderators found."); + win_println(window, THEME_DEFAULT, '!', "No moderators found."); break; case MUC_ROLE_PARTICIPANT: - win_printf_line(window, THEME_DEFAULT, '!', "No participants found."); + win_println(window, THEME_DEFAULT, '!', "No participants found."); break; case MUC_ROLE_VISITOR: - win_printf_line(window, THEME_DEFAULT, '!', "No visitors found."); + win_println(window, THEME_DEFAULT, '!', "No visitors found."); break; default: break; } - win_printf_line(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, '-', ""); } else { switch (role) { case MUC_ROLE_MODERATOR: - win_printf_line(window, THEME_DEFAULT, '!', "Moderators:"); + win_println(window, THEME_DEFAULT, '!', "Moderators:"); break; case MUC_ROLE_PARTICIPANT: - win_printf_line(window, THEME_DEFAULT, '!', "Participants:"); + win_println(window, THEME_DEFAULT, '!', "Participants:"); break; case MUC_ROLE_VISITOR: - win_printf_line(window, THEME_DEFAULT, '!', "Visitors:"); + win_println(window, THEME_DEFAULT, '!', "Visitors:"); break; default: break; @@ -762,16 +762,16 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) Occupant *occupant = curr_occupant->data; if (occupant->role == role) { if (occupant->jid) { - win_printf_line(window, THEME_DEFAULT, '!', " %s (%s)", occupant->nick, occupant->jid); + win_println(window, THEME_DEFAULT, '!', " %s (%s)", occupant->nick, occupant->jid); } else { - win_printf_line(window, THEME_DEFAULT, '!', " %s", occupant->nick); + win_println(window, THEME_DEFAULT, '!', " %s", occupant->nick); } } curr_occupant = g_slist_next(curr_occupant); } - win_printf_line(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, '-', ""); } } @@ -782,7 +782,7 @@ mucwin_affiliation_set_error(ProfMucWin *mucwin, const char *const jid, const ch assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf_line(window, THEME_ERROR, '!', "Error setting %s affiliation for %s: %s", affiliation, jid, error); + win_println(window, THEME_ERROR, '!', "Error setting %s affiliation for %s: %s", affiliation, jid, error); } void @@ -792,7 +792,7 @@ mucwin_role_set_error(ProfMucWin *mucwin, const char *const nick, const char *co assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf_line(window, THEME_ERROR, '!', "Error setting %s role for %s: %s", role, nick, error); + win_println(window, THEME_ERROR, '!', "Error setting %s role for %s: %s", role, nick, error); } void @@ -804,10 +804,10 @@ mucwin_info(ProfMucWin *mucwin) char *affiliation = muc_affiliation_str(mucwin->roomjid); ProfWin *window = (ProfWin*) mucwin; - win_printf_line(window, THEME_DEFAULT, '!', "Room: %s", mucwin->roomjid); - win_printf_line(window, THEME_DEFAULT, '!', "Affiliation: %s", affiliation); - win_printf_line(window, THEME_DEFAULT, '!', "Role: %s", role); - win_printf_line(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, '!', "Room: %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "Affiliation: %s", affiliation); + win_println(window, THEME_DEFAULT, '!', "Role: %s", role); + win_println(window, THEME_DEFAULT, '-', ""); } void diff --git a/src/ui/privwin.c b/src/ui/privwin.c index ae3f4fa0..54c54564 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_println((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_println((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_println((ProfWin*)privwin, THEME_OFFLINE, '-', "<- %s has left the room.", jidp->resourcepart); jid_destroy(jidp); } @@ -142,7 +142,7 @@ privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const g_string_append(message, reason); } - win_printf_line((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); + win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); g_string_free(message, TRUE); } @@ -165,7 +165,7 @@ privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const g_string_append(message, reason); } - win_printf_line((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); + win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); g_string_free(message, TRUE); } @@ -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_println((ProfWin*)privwin, THEME_ONLINE, '-', "-- %s has joined the room.", jidp->resourcepart); jid_destroy(jidp); } @@ -187,7 +187,7 @@ privwin_room_destroyed(ProfPrivateWin *privwin) privwin->room_left = TRUE; Jid *jidp = jid_create(privwin->fulljid); - win_printf_line((ProfWin*)privwin, THEME_OFFLINE, '!', "-- %s has been destroyed.", jidp->barejid); + win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "-- %s has been destroyed.", jidp->barejid); jid_destroy(jidp); } @@ -198,7 +198,7 @@ privwin_room_joined(ProfPrivateWin *privwin) privwin->room_left = FALSE; Jid *jidp = jid_create(privwin->fulljid); - win_printf_line((ProfWin*)privwin, THEME_OFFLINE, '!', "-- You have joined %s.", jidp->barejid); + win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "-- You have joined %s.", jidp->barejid); jid_destroy(jidp); } @@ -209,7 +209,7 @@ privwin_room_left(ProfPrivateWin *privwin) privwin->room_left = TRUE; Jid *jidp = jid_create(privwin->fulljid); - win_printf_line((ProfWin*)privwin, THEME_OFFLINE, '!', "-- You have left %s.", jidp->barejid); + win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "-- You have left %s.", jidp->barejid); jid_destroy(jidp); } @@ -232,7 +232,7 @@ privwin_room_kicked(ProfPrivateWin *privwin, const char *const actor, const char g_string_append(message, reason); } - win_printf_line((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); + win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); g_string_free(message, TRUE); } @@ -255,7 +255,7 @@ privwin_room_banned(ProfPrivateWin *privwin, const char *const actor, const char g_string_append(message, reason); } - win_printf_line((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); + win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); g_string_free(message, TRUE); } diff --git a/src/ui/ui.h b/src/ui/ui.h index 1850105b..05cac699 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -357,13 +357,14 @@ 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 ch, const char *const message, ...); +void win_print(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...); +void win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...); +void win_println_indent(ProfWin *window, int pad, const char *const message); 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); void win_show_contact(ProfWin *window, PContact contact); void win_show_info(ProfWin *window, PContact contact); -void win_println_indent(ProfWin *window, int pad, const char *const message); void win_clear(ProfWin *window); char* win_to_string(ProfWin *window); diff --git a/src/ui/window.c b/src/ui/window.c index 66dcf408..a5b063cf 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -682,7 +682,7 @@ win_show_occupant(ProfWin *window, Occupant *occupant) theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", occupant->nick); + win_print(window, presence_colour, '-', "%s", occupant->nick); win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); if (occupant->status) { @@ -704,9 +704,9 @@ win_show_contact(ProfWin *window, PContact contact) theme_item_t presence_colour = theme_main_presence_attrs(presence); if (name) { - win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", name); + win_print(window, presence_colour, '-', "%s", name); } else { - win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", barejid); + win_print(window, presence_colour, '-', "%s", barejid); } win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence); @@ -746,7 +746,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_printf(window, '!', 0, NULL, NO_EOL, presence_colour, "", "%s", occupant->nick); + win_print(window, presence_colour, '!', "%s", occupant->nick); win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); if (occupant->status) { @@ -756,11 +756,11 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_newline(window); if (occupant->jid) { - win_printf_line(window, THEME_DEFAULT, '!', " Jid: %s", occupant->jid); + win_println(window, THEME_DEFAULT, '!', " Jid: %s", occupant->jid); } - win_printf_line(window, THEME_DEFAULT, '!', " Affiliation: %s", occupant_affiliation); - win_printf_line(window, THEME_DEFAULT, '!', " Role: %s", occupant_role); + win_println(window, THEME_DEFAULT, '!', " Affiliation: %s", occupant_affiliation); + win_println(window, THEME_DEFAULT, '!', " Role: %s", occupant_role); Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick); EntityCapabilities *caps = caps_lookup(jidp->fulljid); @@ -770,7 +770,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_printf(window, '!', 0, NULL, NO_EOL, THEME_DEFAULT, "", " Identity: "); + win_print(window, THEME_DEFAULT, '!', " Identity: "); if (identity->name) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); if (identity->category || identity->type) { @@ -814,7 +814,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa caps_destroy(caps); } - win_printf_line(window, THEME_DEFAULT, '-', ""); + win_println(window, THEME_DEFAULT, '-', ""); } void @@ -828,7 +828,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_println(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); @@ -836,7 +836,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_println(window, THEME_DEFAULT, '-', "Subscription: %s", sub); } if (last_activity) { @@ -850,10 +850,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_println(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_println(window, THEME_DEFAULT, '-', "Last activity: %dm%ds", minutes, seconds); } g_date_time_unref(now); @@ -862,7 +862,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_println(window, THEME_DEFAULT, '-', "Resources:"); // sort in order of availability GList *curr = resources; @@ -1037,7 +1037,27 @@ 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 ch, const char *const message, ...) +win_print(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...) +{ + GDateTime *timestamp = g_date_time_new_now_local(); + + va_list arg; + va_start(arg, message); + GString *fmt_msg = g_string_new(NULL); + g_string_vprintf(fmt_msg, message, arg); + + buffer_push(window->layout->buffer, ch, 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL); + + _win_print(window, ch, 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL); + inp_nonblocking(TRUE); + g_date_time_unref(timestamp); + + g_string_free(fmt_msg, TRUE); + va_end(arg); +} + +void +win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...) { GDateTime *timestamp = g_date_time_new_now_local(); diff --git a/src/ui/window_list.c b/src/ui/window_list.c index 6ef166d5..1692cb4e 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -280,7 +280,7 @@ wins_private_nick_change(const char *const roomjid, const char *const oldnick, c Jid *newjid = jid_create_from_bare_and_resource(roomjid, newnick); privwin->fulljid = strdup(newjid->fulljid); - win_printf_line((ProfWin*)privwin, THEME_THEM, '!', "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart); + win_println((ProfWin*)privwin, THEME_THEM, '!', "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart); autocomplete_remove(wins_ac, oldjid->fulljid); autocomplete_remove(wins_close_ac, oldjid->fulljid); @@ -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_println(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 a26da8c0..009bb5e3 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_println(window, THEME_DEFAULT, '-', "SENT:"); + win_println(window, THEME_ONLINE, '-', "%s", &msg[6]); + win_println(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_println(window, THEME_DEFAULT, '-', "RECV:"); + win_println(window, THEME_AWAY, '-', "%s", &msg[6]); + win_println(window, THEME_AWAY, '-', ""); } } |