From 095c129a6b8bdf0d357b4de7301fc21d918dcef0 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 10 Oct 2016 22:42:08 +0100 Subject: [PATCH 01/28] Update boothj5 theme --- themes/boothj5 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/boothj5 b/themes/boothj5 index b22e8648..fc7c8b8a 100644 --- a/themes/boothj5 +++ b/themes/boothj5 @@ -95,11 +95,11 @@ intype=true enc.warn=true resource.title=true resource.message=true -statuses.console=all +statuses.console=none statuses.chat=none statuses.muc=none roster=true -roster.offline=true +roster.offline=false roster.empty=false roster.by=group roster.order=presence From 0337c5b22c8138ea7473b15e0687a04acb4eb70a Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 11 Oct 2016 23:10:48 +0100 Subject: [PATCH 02/28] Rename win_vprint -> win_printf --- src/command/cmd_funcs.c | 16 ++--- src/ui/chatwin.c | 2 +- src/ui/console.c | 100 +++++++++++++-------------- src/ui/core.c | 46 ++++++------- src/ui/mucconfwin.c | 50 +++++++------- src/ui/mucwin.c | 128 +++++++++++++++++------------------ src/ui/privwin.c | 18 ++--- src/ui/ui.h | 2 +- src/ui/window.c | 62 ++++++++--------- src/ui/window_list.c | 2 +- tests/unittests/ui/stub_ui.c | 2 +- 11 files changed, 214 insertions(+), 214 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 15fa7372..1d7d0b7f 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1479,7 +1479,7 @@ _cmd_help_cmd_list(const char *const tag) cons_show(""); ProfWin *console = wins_get_console(); if (tag) { - win_vprint(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s commands", tag); + win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s commands", tag); } else { win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "All commands"); } @@ -3108,7 +3108,7 @@ cmd_status(ProfWin *window, const char *const command, gchar **args) if (occupant) { win_show_occupant(window, occupant); } else { - win_vprint(window, '-', 0, NULL, 0, 0, "", "No such participant \"%s\" in room.", usr); + win_printf(window, '-', 0, NULL, 0, 0, "", "No such participant \"%s\" in room.", usr); } } else { ui_current_print_line("You must specify a nickname."); @@ -3881,7 +3881,7 @@ cmd_kick(ProfWin *window, const char *const command, gchar **args) char *reason = args[1]; iq_room_kick_occupant(mucwin->roomjid, nick, reason); } else { - win_vprint((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Occupant does not exist: %s", nick); + win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Occupant does not exist: %s", nick); } } else { cons_bad_cmd_usage(command); @@ -3939,8 +3939,8 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) if (args[0] == NULL) { char *subject = muc_subject(mucwin->roomjid); if (subject) { - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: "); - win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: "); + win_printf(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); } else { win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room has no subject"); } @@ -3974,7 +3974,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) message_send_groupchat_subject(mucwin->roomjid, new_subject->str); g_string_free(new_subject, TRUE); } else { - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room does not have a subject, use /subject set "); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room does not have a subject, use /subject set "); } } else { cons_bad_cmd_usage(command); @@ -3991,7 +3991,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) message_send_groupchat_subject(mucwin->roomjid, new_subject->str); g_string_free(new_subject, TRUE); } else { - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room does not have a subject, use /subject set "); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room does not have a subject, use /subject set "); } } else { cons_bad_cmd_usage(command); @@ -4681,7 +4681,7 @@ cmd_tiny(ProfWin *window, const char *const command, gchar **args) } if (!tinyurl_valid(url)) { - win_vprint(window, '-', 0, NULL, 0, THEME_ERROR, "", "/tiny, badly formed URL: %s", url); + win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", "/tiny, badly formed URL: %s", url); return TRUE; } diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 9098d4cc..7ea985ea 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -227,7 +227,7 @@ chatwin_recipient_gone(ProfChatWin *chatwin) display_usr = chatwin->barejid; } - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_GONE, "", "<- %s has left the conversation.", display_usr); + win_printf((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_GONE, "", "<- %s has left the conversation.", display_usr); } void diff --git a/src/ui/console.c b/src/ui/console.c index 98967206..139d0bb3 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_vprint(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s", &cmd[1]); + win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s", &cmd[1]); win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE_BOLD, "", ""); int i; for (i = 0; i < strlen(cmd) - 1 ; i++) { @@ -150,7 +150,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) cons_show(""); win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Arguments"); for (i = 0; help->args[i][0] != NULL; i++) { - win_vprint(console, '-', maxlen + 3, NULL, 0, 0, "", "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]); + win_printf(console, '-', maxlen + 3, NULL, 0, 0, "", "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]); } } @@ -296,7 +296,7 @@ cons_show_typing(const char *const barejid) display_usr = barejid; } - win_vprint(console, '-', 0, NULL, 0, THEME_TYPING, "", "!! %s is typing a message...", display_usr); + win_printf(console, '-', 0, NULL, 0, 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_vprint(console, '-', 0, NULL, 0, THEME_MENTION, "", "<< room mention: %s in %s (win %d)", nick, room, ui_index); + win_printf(console, '-', 0, NULL, 0, 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_vprint(console, '-', 0, NULL, 0, THEME_TRIGGER, "", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); + win_printf(console, '-', 0, NULL, 0, THEME_TRIGGER, "", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); free(triggers_str); } else { - win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s in %s (win %d)", nick, room, ui_index); + win_printf(console, '-', 0, NULL, 0, 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_vprint(console, '-', 0, NULL, 0, THEME_MENTION, "", "<< room mention: %s in %s (win %d)", nick, room, ui_index); + win_printf(console, '-', 0, NULL, 0, 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_vprint(console, '-', 0, NULL, 0, THEME_TRIGGER, "", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); + win_printf(console, '-', 0, NULL, 0, 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_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s (win %d)", room, ui_index); + win_printf(console, '-', 0, NULL, 0, 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_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< chat message: %s (win %d)", short_from, ui_index); + win_printf(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< chat message: %s (win %d)", short_from, ui_index); cons_alert(); } else if ((g_strcmp0(chat_show, "first") == 0) && unread == 0) { - win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< chat message: %s (win %d)", short_from, ui_index); + win_printf(console, '-', 0, NULL, 0, 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_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< private message: %s in %s (win %d)", nick, room, ui_index); + win_printf(console, '-', 0, NULL, 0, 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_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< private message: %s in %s (win %d)", nick, room, ui_index); + win_printf(console, '-', 0, NULL, 0, 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_vprint(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); + win_printf(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); #else - win_vprint(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %sdev", PACKAGE_VERSION); + win_printf(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %sdev", PACKAGE_VERSION); #endif } else { - win_vprint(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %s", PACKAGE_VERSION); + win_printf(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %s", PACKAGE_VERSION); } } - win_vprint(console, '-', 0, NULL, 0, 0, "", "Copyright (C) 2012 - 2016 James Booth <%s>.", PACKAGE_BUGREPORT); + win_printf(console, '-', 0, NULL, 0, 0, "", "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_vprint(console, '-', 0, NULL, 0, 0, "", "A new version of Profanity is available: %s", latest_release); + win_printf(console, '-', 0, NULL, 0, 0, "", "A new version of Profanity is available: %s", latest_release); win_println(console, 0, "Check for details."); win_println(console, 0, ""); } else { @@ -475,14 +475,14 @@ void cons_show_login_success(ProfAccount *account, gboolean secured) { ProfWin *console = wins_get_console(); - win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "%s logged in successfully, ", account->jid); + win_printf(console, '-', 0, NULL, NO_EOL, 0, "", "%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); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str); - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)", + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)", accounts_get_priority_for_presence_type(account->name, presence)); win_print(console, '-', 0, NULL, NO_DATE, 0, "", "."); if (!secured) { @@ -554,7 +554,7 @@ 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_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", fulljid); + win_printf(console, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", fulljid); win_print(console, '-', 0, NULL, NO_DATE, 0, "", ":"); // show identity @@ -582,19 +582,19 @@ 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_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "Software: %s", software_version->software); + win_printf(console, '-', 0, NULL, NO_EOL, 0, "", "Software: %s", software_version->software); } if (software_version->software_version) { - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(console); } if (software_version->os) { - win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "OS: %s", software_version->os); + win_printf(console, '-', 0, NULL, NO_EOL, 0, "", "OS: %s", software_version->os); } if (software_version->os_version) { - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(console); @@ -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_vprint(console, '-', 0, NULL, 0, 0, "", " %s", feature->data); + win_printf(console, '-', 0, NULL, 0, 0, "", " %s", feature->data); feature = g_slist_next(feature); } } @@ -667,9 +667,9 @@ 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_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " %s", room->jid); + win_printf(console, '-', 0, NULL, NO_EOL, 0, "", " %s", room->jid); if (room->name) { - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", room->name); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", room->name); } win_newline(console); rooms = g_slist_next(rooms); @@ -701,9 +701,9 @@ cons_show_bookmarks(const GList *list) if (muc_active(item->barejid)) { presence_colour = THEME_ONLINE; } - win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", " %s", item->barejid); + win_printf(console, '-', 0, NULL, NO_EOL, presence_colour, "", " %s", item->barejid); if (item->nick) { - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "/%s", item->nick); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "/%s", item->nick); } if (item->autojoin) { win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (autojoin)"); @@ -715,7 +715,7 @@ cons_show_bookmarks(const GList *list) ProfWin *roomwin = (ProfWin*)wins_get_muc(item->barejid); if (roomwin) { int num = wins_get_num(roomwin); - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (win %d)", num); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (win %d)", num); } } win_newline(console); @@ -784,11 +784,11 @@ 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_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " %s", item->jid); + win_printf(console, '-', 0, NULL, NO_EOL, 0, "", " %s", item->jid); if (item->name) { - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", item->name); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", item->name); } - win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", ""); + win_printf(console, '-', 0, NULL, NO_DATE, 0, "", ""); items = g_slist_next(items); } } else { @@ -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_vprint(console, '-', 0, NULL, 0, presence_colour, "", "%s", accounts[i]); + win_printf(console, '-', 0, NULL, 0, presence_colour, "", "%s", accounts[i]); } else { cons_show(accounts[i]); } @@ -1000,12 +1000,12 @@ 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_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence); + win_printf(console, '-', 0, NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence); if (resource->status) { - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); } - win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", ""); + win_printf(console, '-', 0, NULL, NO_DATE, 0, "", ""); Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name); EntityCapabilities *caps = caps_lookup(jidp->fulljid); jid_destroy(jidp); @@ -1036,19 +1036,19 @@ cons_show_account(ProfAccount *account) if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { - win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); + win_printf(console, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); } if (software_version->software_version) { - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(console); } if (software_version->os) { - win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); + win_printf(console, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); } if (software_version->os_version) { - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(console); @@ -2368,12 +2368,12 @@ _cons_splash_logo(void) if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION - win_vprint(console, '-', 0, NULL, 0, 0, "", "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); + win_printf(console, '-', 0, NULL, 0, 0, "", "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); #else - win_vprint(console, '-', 0, NULL, 0, 0, "", "Version %sdev", PACKAGE_VERSION); + win_printf(console, '-', 0, NULL, 0, 0, "", "Version %sdev", PACKAGE_VERSION); #endif } else { - win_vprint(console, '-', 0, NULL, 0, 0, "", "Version %s", PACKAGE_VERSION); + win_printf(console, '-', 0, NULL, 0, 0, "", "Version %s", PACKAGE_VERSION); } } @@ -2400,7 +2400,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) } else { presence_colour = theme_main_presence_attrs("offline"); } - win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", title->str); + win_printf(console, '-', 0, NULL, NO_EOL, presence_colour, "", title->str); g_string_free(title, TRUE); @@ -2420,9 +2420,9 @@ _show_roster_contacts(GSList *list, gboolean show_groups) } if (show_groups) { - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", sub->str); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", sub->str); } else { - win_vprint(console, '-', 0, NULL, NO_DATE, presence_colour, "", "%s", sub->str); + win_printf(console, '-', 0, NULL, NO_DATE, presence_colour, "", "%s", sub->str); } g_string_free(sub, TRUE); @@ -2438,7 +2438,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) } groups = g_slist_next(groups); } - win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", "%s", groups_str->str); + win_printf(console, '-', 0, NULL, NO_DATE, 0, "", "%s", groups_str->str); g_string_free(groups_str, TRUE); } else { win_print(console, '-', 0, NULL, NO_DATE, 0, "", " "); diff --git a/src/ui/core.c b/src/ui/core.c index c471aad7..7f7b3ad0 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_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", "Error from %s: %s", recipient, err_msg); + win_printf((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", "Error from %s: %s", recipient, err_msg); return; } ProfMucWin *mucwin = wins_get_muc(recipient); if (mucwin) { - win_vprint((ProfWin*)mucwin, '!', 0, NULL, 0, THEME_ERROR, "", "Error from %s: %s", recipient, err_msg); + win_printf((ProfWin*)mucwin, '!', 0, NULL, 0, THEME_ERROR, "", "Error from %s: %s", recipient, err_msg); return; } ProfPrivateWin *privatewin = wins_get_private(recipient); if (privatewin) { - win_vprint((ProfWin*)privatewin, '!', 0, NULL, 0, THEME_ERROR, "", "Error from %s: %s", recipient, err_msg); + win_printf((ProfWin*)privatewin, '!', 0, NULL, 0, THEME_ERROR, "", "Error from %s: %s", recipient, err_msg); return; } } @@ -790,7 +790,7 @@ ui_print_system_msg_from_recipient(const char *const barejid, const char *messag } } - win_vprint(window, '-', 0, NULL, 0, 0, "", "*%s %s", barejid, message); + win_printf(window, '-', 0, NULL, 0, 0, "", "*%s %s", barejid, message); } void @@ -802,15 +802,15 @@ ui_room_join(const char *const roomjid, gboolean focus) } char *nick = muc_nick(roomjid); - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "-> You have joined the room as %s", nick); + win_printf(window, '!', 0, NULL, NO_EOL, 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); if (role) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", role: %s", role); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", role: %s", role); } if (affiliation) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", affiliation: %s", affiliation); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", affiliation: %s", affiliation); } } win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); @@ -823,7 +823,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_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "-> Autojoined %s as %s (%d).", roomjid, nick, num); + win_printf(console, '!', 0, NULL, 0, THEME_TYPING, "", "-> Autojoined %s as %s (%d).", roomjid, nick, num); } GList *privwins = wins_get_private_chats(roomjid); @@ -898,16 +898,16 @@ ui_room_destroyed(const char *const roomjid, const char *const reason, const cha ProfWin *console = wins_get_console(); if (reason) { - win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- Room destroyed: %s, reason: %s", roomjid, reason); + win_printf(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- Room destroyed: %s, reason: %s", roomjid, reason); } else { - win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- Room destroyed: %s", roomjid); + win_printf(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- Room destroyed: %s", roomjid); } if (new_jid) { if (password) { - win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "Replacement room: %s, password: %s", new_jid, password); + win_printf(console, '!', 0, NULL, 0, THEME_TYPING, "", "Replacement room: %s, password: %s", new_jid, password); } else { - win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "Replacement room: %s", new_jid); + win_printf(console, '!', 0, NULL, 0, THEME_TYPING, "", "Replacement room: %s", new_jid); } } } @@ -944,7 +944,7 @@ ui_room_kicked(const char *const roomjid, const char *const actor, const char *c } ProfWin *console = wins_get_console(); - win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- %s", message->str); + win_printf(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- %s", message->str); g_string_free(message, TRUE); } @@ -980,7 +980,7 @@ ui_room_banned(const char *const roomjid, const char *const actor, const char *c } ProfWin *console = wins_get_console(); - win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- %s", message->str); + win_printf(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- %s", message->str); g_string_free(message, TRUE); } @@ -1032,7 +1032,7 @@ ui_ask_pgp_passphrase(const char *hint, int prev_fail) } if (hint) { - win_vprint(current, '!', 0, NULL, 0, 0, "", "Enter PGP key passphrase for %s", hint); + win_printf(current, '!', 0, NULL, 0, 0, "", "Enter PGP key passphrase for %s", hint); } else { win_print(current, '!', 0, NULL, 0, 0, "", "Enter PGP key passphrase"); } @@ -1209,21 +1209,21 @@ ui_handle_room_config_submit_result_error(const char *const roomjid, const char if (form_window) { if (message) { - win_vprint(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message); + win_printf(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message); } else { win_print(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); } } else if (muc_window) { if (message) { - win_vprint(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message); + win_printf(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message); } else { win_print(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); } } else { if (message) { - win_vprint(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error for %s: %s", roomjid, message); + win_printf(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error for %s: %s", roomjid, message); } else { - win_vprint(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error for %s", roomjid); + win_printf(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error for %s", roomjid); } } } else { @@ -1316,17 +1316,17 @@ ui_show_software_version(const char *const jid, const char *const presence, if (name || version || os) { win_println(window, 0, ""); theme_item_t presence_colour = theme_main_presence_attrs(presence); - win_vprint(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", jid); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", jid); win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":"); } if (name) { - win_vprint(window, '-', 0, NULL, 0, 0, "", "Name : %s", name); + win_printf(window, '-', 0, NULL, 0, 0, "", "Name : %s", name); } if (version) { - win_vprint(window, '-', 0, NULL, 0, 0, "", "Version : %s", version); + win_printf(window, '-', 0, NULL, 0, 0, "", "Version : %s", version); } if (os) { - win_vprint(window, '-', 0, NULL, 0, 0, "", "OS : %s", os); + win_printf(window, '-', 0, NULL, 0, 0, "", "OS : %s", os); } } diff --git a/src/ui/mucconfwin.c b/src/ui/mucconfwin.c index b31bb928..3f8987b6 100644 --- a/src/ui/mucconfwin.c +++ b/src/ui/mucconfwin.c @@ -50,7 +50,7 @@ mucconfwin_show_form(ProfMucConfWin *confwin) win_print(window, '-', 0, NULL, NO_EOL, 0, "", "Form title: "); win_print(window, '-', 0, NULL, NO_DATE, 0, "", confwin->form->title); } else { - win_vprint(window, '-', 0, NULL, 0, 0, "", "Configuration for room %s.", confwin->roomjid); + win_printf(window, '-', 0, NULL, 0, 0, "", "Configuration for room %s.", confwin->roomjid); } win_print(window, '-', 0, NULL, 0, 0, "", ""); @@ -118,9 +118,9 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":"); } if (field->description) { - win_vprint(window, '-', 0, NULL, 0, 0, "", " Description : %s", field->description); + win_printf(window, '-', 0, NULL, 0, 0, "", " Description : %s", field->description); } - win_vprint(window, '-', 0, NULL, 0, 0, "", " Type : %s", field->type); + win_printf(window, '-', 0, NULL, 0, 0, "", " Type : %s", field->type); int num_values = 0; GSList *curr_option = NULL; @@ -129,50 +129,50 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) switch (field->type_t) { case FIELD_TEXT_SINGLE: case FIELD_TEXT_PRIVATE: - win_vprint(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); + win_printf(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); win_print(window, '-', 0, NULL, 0, 0, "", " Where : is any text"); break; case FIELD_TEXT_MULTI: num_values = form_get_value_count(confwin->form, tag); - win_vprint(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); + win_printf(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); win_print(window, '-', 0, NULL, 0, 0, "", " Where : is any text"); if (num_values > 0) { - win_vprint(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); - win_vprint(window, '-', 0, NULL, 0, 0, "", " Where : between 'val1' and 'val%d'", num_values); + win_printf(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : between 'val1' and 'val%d'", num_values); } break; case FIELD_BOOLEAN: - win_vprint(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); + win_printf(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); win_print(window, '-', 0, NULL, 0, 0, "", " Where : is either 'on' or 'off'"); break; case FIELD_LIST_SINGLE: - win_vprint(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); + win_printf(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); win_print(window, '-', 0, NULL, 0, 0, "", " Where : is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; - win_vprint(window, '-', 0, NULL, 0, 0, "", " %s", option->value); + win_printf(window, '-', 0, NULL, 0, 0, "", " %s", option->value); curr_option = g_slist_next(curr_option); } break; case FIELD_LIST_MULTI: - win_vprint(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); - win_vprint(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); + win_printf(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); + win_printf(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); win_print(window, '-', 0, NULL, 0, 0, "", " Where : is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; - win_vprint(window, '-', 0, NULL, 0, 0, "", " %s", option->value); + win_printf(window, '-', 0, NULL, 0, 0, "", " %s", option->value); curr_option = g_slist_next(curr_option); } break; case FIELD_JID_SINGLE: - win_vprint(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); + win_printf(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); win_print(window, '-', 0, NULL, 0, 0, "", " Where : is a valid Jabber ID"); break; case FIELD_JID_MULTI: - win_vprint(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); - win_vprint(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); + win_printf(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); + win_printf(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); win_print(window, '-', 0, NULL, 0, 0, "", " Where : is a valid Jabber ID"); break; case FIELD_FIXED: @@ -182,7 +182,7 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) break; } } else { - win_vprint(window, '-', 0, NULL, 0, 0, "", "No such field %s", tag); + win_printf(window, '-', 0, NULL, 0, 0, "", "No such field %s", tag); } } @@ -202,8 +202,8 @@ mucconfwin_form_help(ProfMucConfWin *confwin) static void _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) { - win_vprint(window, '-', 0, NULL, NO_EOL, THEME_AWAY, "", "[%s] ", tag); - win_vprint(window, '-', 0, NULL, NO_EOL | NO_DATE, 0, "", "%s", field->label); + win_printf(window, '-', 0, NULL, NO_EOL, THEME_AWAY, "", "[%s] ", tag); + win_printf(window, '-', 0, NULL, NO_EOL | NO_DATE, 0, "", "%s", field->label); if (field->required) { win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (required): "); } else { @@ -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_vprint(window, '-', 0, NULL, 0, THEME_ONLINE, "", " [%s] %s", val_tag->str, value); + win_printf(window, '-', 0, NULL, 0, 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_vprint(window, '-', 0, NULL, 0, THEME_ONLINE, "", " [%s] %s", option->value, option->label); + win_printf(window, '-', 0, NULL, 0, THEME_ONLINE, "", " [%s] %s", option->value, option->label); } else { - win_vprint(window, '-', 0, NULL, 0, THEME_OFFLINE, "", " [%s] %s", option->value, option->label); + win_printf(window, '-', 0, NULL, 0, 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_vprint(window, '-', 0, NULL, 0, THEME_ONLINE, "", " [%s] %s", option->value, option->label); + win_printf(window, '-', 0, NULL, 0, THEME_ONLINE, "", " [%s] %s", option->value, option->label); } else { - win_vprint(window, '-', 0, NULL, 0, THEME_OFFLINE, "", " [%s] %s", option->value, option->label); + win_printf(window, '-', 0, NULL, 0, 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_vprint(window, '-', 0, NULL, 0, THEME_ONLINE, "", " %s", value); + win_printf(window, '-', 0, NULL, 0, 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 3f773431..8bb67790 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -51,12 +51,12 @@ mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your role has been changed to: %s", role); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your role has been changed to: %s", role); if (actor) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); } if (reason) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } @@ -68,12 +68,12 @@ mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, con assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your affiliation has been changed to: %s", affiliation); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your affiliation has been changed to: %s", affiliation); if (actor) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); } if (reason) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } @@ -85,12 +85,12 @@ mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, c assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); if (actor) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); } if (reason) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } @@ -103,12 +103,12 @@ mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const ch assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%s's role has been changed to: %s", nick, role); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%s's role has been changed to: %s", nick, role); if (actor) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); } if (reason) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } @@ -120,12 +120,12 @@ mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, c assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%s's affiliation has been changed to: %s", nick, affiliation); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%s's affiliation has been changed to: %s", nick, affiliation); if (actor) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); } if (reason) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } @@ -137,12 +137,12 @@ mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *cons assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation); if (actor) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); } if (reason) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } @@ -153,7 +153,7 @@ mucwin_room_info_error(ProfMucWin *mucwin, const char *const error) assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_vprint(window, '!', 0, NULL, 0, 0, "", "Room info request failed: %s", error); + win_printf(window, '!', 0, NULL, 0, 0, "", "Room info request failed: %s", error); win_print(window, '-', 0, NULL, 0, 0, "", ""); } @@ -191,7 +191,7 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) win_print(window, '!', 0, NULL, 0, 0, "", "Features:"); } while (features) { - win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", features->data); + win_printf(window, '!', 0, NULL, 0, 0, "", " %s", features->data); features = g_slist_next(features); } win_print(window, '-', 0, NULL, 0, 0, "", ""); @@ -208,14 +208,14 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) if (presence == NULL) { win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room is empty."); } else { - win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "No occupants %s.", presence); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "No occupants %s.", presence); } } else { int length = g_list_length(roster); if (presence == NULL) { - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d occupants: ", length); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d occupants: ", length); } else { - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d %s: ", length, presence); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d %s: ", length, presence); } while (roster) { @@ -223,7 +223,7 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) const char *presence_str = string_from_resource_presence(occupant->presence); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick); if (roster->next) { win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", "); @@ -242,7 +242,7 @@ mucwin_occupant_offline(ProfMucWin *mucwin, const char *const nick) assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_vprint(window, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s has left the room.", nick); + win_printf(window, '!', 0, NULL, 0, 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_vprint(window, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); + win_printf(window, '!', 0, NULL, 0, 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_vprint(window, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); + win_printf(window, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); g_string_free(message, TRUE); } @@ -296,13 +296,13 @@ mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *c assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ONLINE, "", "-> %s has joined the room", nick); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ONLINE, "", "-> %s has joined the room", nick); if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { if (role) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", role: %s", role); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", role: %s", role); } if (affiliation) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", affiliation: %s", affiliation); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", affiliation: %s", affiliation); } } win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); @@ -324,7 +324,7 @@ mucwin_occupant_nick_change(ProfMucWin *mucwin, const char *const old_nick, cons assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_vprint(window, '!', 0, NULL, 0, THEME_THEM, "", "** %s is now known as %s", old_nick, nick); + win_printf(window, '!', 0, NULL, 0, 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_vprint(window, '!', 0, NULL, 0, THEME_ME, "", "** You are now known as %s", nick); + win_printf(window, '!', 0, NULL, 0, THEME_ME, "", "** You are now known as %s", nick); } void @@ -507,10 +507,10 @@ mucwin_requires_config(ProfMucWin *mucwin) } win_print(window, '-', 0, NULL, 0, 0, "", ""); - win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room locked, requires configuration."); - win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room accept' to accept the defaults"); - win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room destroy' to cancel and destroy the room"); - win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room config' to edit the room configuration"); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room locked, requires configuration."); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room accept' to accept the defaults"); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room destroy' to cancel and destroy the room"); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room config' to edit the room configuration"); win_print(window, '-', 0, NULL, 0, 0, "", ""); // currently in groupchat window @@ -533,17 +533,17 @@ mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const sub if (subject) { if (nick) { - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "*%s has set the room subject: ", nick); - win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "*%s has set the room subject: ", nick); + win_printf(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); } else { - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: "); - win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: "); + win_printf(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); } } else { if (nick) { - win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "*%s has cleared the room subject.", nick); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "*%s has cleared the room subject.", nick); } else { - win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room subject cleared"); + win_printf(window, '!', 0, NULL, 0, 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_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error kicking %s: %s", nick, error); + win_printf(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error kicking %s: %s", nick, error); } void @@ -574,8 +574,8 @@ mucwin_broadcast(ProfMucWin *mucwin, const char *const message) ProfWin *window = (ProfWin*)mucwin; int num = wins_get_num(window); - win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room message: "); - win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", message); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room message: "); + win_printf(window, '!', 0, NULL, NO_DATE, 0, "", "%s", message); // currently in groupchat window if (wins_is_current(window)) { @@ -594,7 +594,7 @@ mucwin_affiliation_list_error(ProfMucWin *mucwin, const char *const affiliation, assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error retrieving %s list: %s", affiliation, error); + win_printf(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error retrieving %s list: %s", affiliation, error); } void @@ -604,16 +604,16 @@ mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation ProfWin *window = (ProfWin*)mucwin; if (jids) { - win_vprint(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation); + win_printf(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation); GSList *curr_jid = jids; while (curr_jid) { const char *jid = curr_jid->data; - win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", jid); + win_printf(window, '!', 0, NULL, 0, 0, "", " %s", jid); curr_jid = g_slist_next(curr_jid); } win_print(window, '!', 0, NULL, 0, 0, "", ""); } else { - win_vprint(window, '!', 0, NULL, 0, 0, "", "No users found with affiliation: %s", affiliation); + win_printf(window, '!', 0, NULL, 0, 0, "", "No users found with affiliation: %s", affiliation); win_print(window, '!', 0, NULL, 0, 0, "", ""); } } @@ -667,9 +667,9 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) Occupant *occupant = curr_occupant->data; if (occupant->affiliation == affiliation) { if (occupant->jid) { - win_vprint(window, '!', 0, NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid); + win_printf(window, '!', 0, NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid); } else { - win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", occupant->nick); + win_printf(window, '!', 0, NULL, 0, 0, "", " %s", occupant->nick); } } @@ -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_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error retrieving %s list: %s", role, error); + win_printf(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error retrieving %s list: %s", role, error); } void @@ -696,25 +696,25 @@ mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nick ProfWin *window = (ProfWin*)mucwin; if (nicks) { - win_vprint(window, '!', 0, NULL, 0, 0, "", "Role: %s", role); + win_printf(window, '!', 0, NULL, 0, 0, "", "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_vprint(window, '!', 0, NULL, 0, 0, "", " %s (%s)", nick, occupant->jid); + win_printf(window, '!', 0, NULL, 0, 0, "", " %s (%s)", nick, occupant->jid); } else { - win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", nick); + win_printf(window, '!', 0, NULL, 0, 0, "", " %s", nick); } } else { - win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", nick); + win_printf(window, '!', 0, NULL, 0, 0, "", " %s", nick); } curr_nick = g_slist_next(curr_nick); } win_print(window, '!', 0, NULL, 0, 0, "", ""); } else { - win_vprint(window, '!', 0, NULL, 0, 0, "", "No occupants found with role: %s", role); + win_printf(window, '!', 0, NULL, 0, 0, "", "No occupants found with role: %s", role); win_print(window, '!', 0, NULL, 0, 0, "", ""); } } @@ -762,9 +762,9 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) Occupant *occupant = curr_occupant->data; if (occupant->role == role) { if (occupant->jid) { - win_vprint(window, '!', 0, NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid); + win_printf(window, '!', 0, NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid); } else { - win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", occupant->nick); + win_printf(window, '!', 0, NULL, 0, 0, "", " %s", occupant->nick); } } @@ -782,7 +782,7 @@ mucwin_affiliation_set_error(ProfMucWin *mucwin, const char *const jid, const ch assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error setting %s affiliation for %s: %s", affiliation, jid, error); + win_printf(window, '!', 0, NULL, 0, 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_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error setting %s role for %s: %s", role, nick, error); + win_printf(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error setting %s role for %s: %s", role, nick, error); } void @@ -804,9 +804,9 @@ mucwin_info(ProfMucWin *mucwin) char *affiliation = muc_affiliation_str(mucwin->roomjid); ProfWin *window = (ProfWin*) mucwin; - win_vprint(window, '!', 0, NULL, 0, 0, "", "Room: %s", mucwin->roomjid); - win_vprint(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation); - win_vprint(window, '!', 0, NULL, 0, 0, "", "Role: %s", role); + win_printf(window, '!', 0, NULL, 0, 0, "", "Room: %s", mucwin->roomjid); + win_printf(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation); + win_printf(window, '!', 0, NULL, 0, 0, "", "Role: %s", role); win_print(window, '-', 0, NULL, 0, 0, "", ""); } diff --git a/src/ui/privwin.c b/src/ui/privwin.c index 1caf4845..b540fb44 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -119,7 +119,7 @@ privwin_occupant_offline(ProfPrivateWin *privwin) privwin->occupant_offline = TRUE; Jid *jidp = jid_create(privwin->fulljid); - win_vprint((ProfWin*)privwin, '-', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %s has left the room.", jidp->resourcepart); + win_printf((ProfWin*)privwin, '-', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %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_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %s", message->str); + win_printf((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %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_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %s", message->str); + win_printf((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %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_vprint((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ONLINE, NULL, "-- %s has joined the room.", jidp->resourcepart); + win_printf((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ONLINE, NULL, "-- %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_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- %s has been destroyed.", jidp->barejid); + win_printf((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- %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_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- You have joined %s.", jidp->barejid); + win_printf((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- 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_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- You have left %s.", jidp->barejid); + win_printf((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- 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_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); + win_printf((ProfWin*)privwin, '!', 0, NULL, 0, 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_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); + win_printf((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); g_string_free(message, TRUE); } diff --git a/src/ui/ui.h b/src/ui/ui.h index bff1c921..95e26933 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -358,7 +358,7 @@ void win_show_subwin(ProfWin *window); void win_refresh_without_subwin(ProfWin *window); void win_refresh_with_subwin(ProfWin *window); void win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const from, const char *const message); -void win_vprint(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const from, const char *const message, ...); +void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const from, const char *const message, ...); char* win_get_title(ProfWin *window); void win_show_occupant(ProfWin *window, Occupant *occupant); void win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupant); diff --git a/src/ui/window.c b/src/ui/window.c index 4cbe25f4..ebcd9e53 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -684,10 +684,10 @@ win_show_occupant(ProfWin *window, Occupant *occupant) theme_item_t presence_colour = theme_main_presence_attrs(presence_str); win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); if (occupant->status) { - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); } win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); @@ -710,7 +710,7 @@ win_show_contact(ProfWin *window, PContact contact) win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); } - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence); if (last_activity) { GDateTime *now = g_date_time_new_now_local(); @@ -724,15 +724,15 @@ win_show_contact(ProfWin *window, PContact contact) int seconds = span / G_TIME_SPAN_SECOND; if (hours > 0) { - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds); } else { - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dm%ds", minutes, seconds); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dm%ds", minutes, seconds); } } if (status) { - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", p_contact_status(contact)); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", p_contact_status(contact)); } win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); @@ -748,20 +748,20 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa theme_item_t presence_colour = theme_main_presence_attrs(presence_str); win_print(window, '!', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); if (occupant->status) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); } win_newline(window); if (occupant->jid) { - win_vprint(window, '!', 0, NULL, 0, 0, "", " Jid: %s", occupant->jid); + win_printf(window, '!', 0, NULL, 0, 0, "", " Jid: %s", occupant->jid); } - win_vprint(window, '!', 0, NULL, 0, 0, "", " Affiliation: %s", occupant_affiliation); - win_vprint(window, '!', 0, NULL, 0, 0, "", " Role: %s", occupant_role); + win_printf(window, '!', 0, NULL, 0, 0, "", " Affiliation: %s", occupant_affiliation); + win_printf(window, '!', 0, NULL, 0, 0, "", " Role: %s", occupant_role); Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick); EntityCapabilities *caps = caps_lookup(jidp->fulljid); @@ -793,19 +793,19 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { - win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); + win_printf(window, '!', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); } if (software_version->software_version) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(window); } if (software_version->os) { - win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); + win_printf(window, '!', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); } if (software_version->os_version) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(window); @@ -832,12 +832,12 @@ win_show_info(ProfWin *window, PContact contact) win_print(window, '-', 0, NULL, 0, 0, "", ""); win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); if (name) { - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name); } win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":"); if (sub) { - win_vprint(window, '-', 0, NULL, 0, 0, "", "Subscription: %s", sub); + win_printf(window, '-', 0, NULL, 0, 0, "", "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_vprint(window, '-', 0, NULL, 0, 0, "", "Last activity: %dh%dm%ds", hours, minutes, seconds); + win_printf(window, '-', 0, NULL, 0, 0, "", "Last activity: %dh%dm%ds", hours, minutes, seconds); } else { - win_vprint(window, '-', 0, NULL, 0, 0, "", "Last activity: %dm%ds", minutes, seconds); + win_printf(window, '-', 0, NULL, 0, 0, "", "Last activity: %dm%ds", minutes, seconds); } g_date_time_unref(now); @@ -881,9 +881,9 @@ win_show_info(ProfWin *window, PContact contact) 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_vprint(window, '-', 0, NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence); if (resource->status) { - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); } win_newline(window); @@ -917,19 +917,19 @@ win_show_info(ProfWin *window, PContact contact) if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { - win_vprint(window, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); + win_printf(window, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); } if (software_version->software_version) { - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(window); } if (software_version->os) { - win_vprint(window, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); + win_printf(window, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); } if (software_version->os_version) { - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(window); @@ -961,12 +961,12 @@ win_show_status_string(ProfWin *window, const char *const from, } - win_vprint(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s %s", pre, from); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s %s", pre, from); if (show) - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", show); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", show); else - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", default_show); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", default_show); if (last_activity) { gchar *date_fmt = NULL; @@ -975,13 +975,13 @@ win_show_status_string(ProfWin *window, const char *const from, prefs_free_string(time_pref); assert(date_fmt != NULL); - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", last activity: %s", date_fmt); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", last activity: %s", date_fmt); g_free(date_fmt); } if (status) - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", status); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", status); win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); @@ -1013,7 +1013,7 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp, } void -win_vprint(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, +win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const from, const char *const message, ...) { va_list arg; diff --git a/src/ui/window_list.c b/src/ui/window_list.c index 057d2033..8a3ad299 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_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_THEM, NULL, "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart); + win_printf((ProfWin*)privwin, '!', 0, NULL, 0, THEME_THEM, NULL, "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart); autocomplete_remove(wins_ac, oldjid->fulljid); autocomplete_remove(wins_close_ac, oldjid->fulljid); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 85cbffc2..af3a18a0 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_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message) {} -void win_vprint(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, ...) {} +void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, ...) {} char* win_get_title(ProfWin *window) { return NULL; From 0890179fc42a7304dc03c76bd680e61a43f6e072 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 11 Oct 2016 23:38:59 +0100 Subject: [PATCH 03/28] Remove win_print, use win_printf instead --- src/command/cmd_funcs.c | 14 ++-- src/plugins/api.c | 6 +- src/ui/chatwin.c | 18 ++--- src/ui/console.c | 123 +++++++++++++++++------------------ src/ui/core.c | 30 ++++----- src/ui/mucconfwin.c | 66 +++++++++---------- src/ui/mucwin.c | 106 +++++++++++++++--------------- src/ui/privwin.c | 6 +- src/ui/ui.h | 4 +- src/ui/window.c | 84 ++++++++++++------------ src/ui/window_list.c | 2 +- src/ui/xmlwin.c | 12 ++-- tests/unittests/ui/stub_ui.c | 1 - 13 files changed, 230 insertions(+), 242 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 1d7d0b7f..0117029b 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1481,7 +1481,7 @@ _cmd_help_cmd_list(const char *const tag) if (tag) { win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s commands", tag); } else { - win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "All commands"); + win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "All commands"); } GList *ordered_commands = NULL; @@ -3942,7 +3942,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: "); win_printf(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); } else { - win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room has no subject"); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room has no subject"); } return TRUE; } @@ -4050,7 +4050,7 @@ cmd_affiliation(ProfWin *window, const char *const command, gchar **args) iq_room_affiliation_list(mucwin->roomjid, "member"); iq_room_affiliation_list(mucwin->roomjid, "outcast"); } else if (g_strcmp0(affiliation, "none") == 0) { - win_print((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no affiliation."); + win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no affiliation."); } else { iq_room_affiliation_list(mucwin->roomjid, affiliation); } @@ -4118,7 +4118,7 @@ cmd_role(ProfWin *window, const char *const command, gchar **args) iq_room_role_list(mucwin->roomjid, "participant"); iq_room_role_list(mucwin->roomjid, "visitor"); } else if (g_strcmp0(role, "none") == 0) { - win_print((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no role."); + win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no role."); } else { iq_room_role_list(mucwin->roomjid, role); } @@ -4180,12 +4180,12 @@ cmd_room(ProfWin *window, const char *const command, gchar **args) if (g_strcmp0(args[0], "accept") == 0) { gboolean requires_config = muc_requires_config(mucwin->roomjid); if (!requires_config) { - win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Current room does not require configuration."); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Current room does not require configuration."); return TRUE; } else { iq_confirm_instant_room(mucwin->roomjid); muc_set_requires_config(mucwin->roomjid, FALSE); - win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room unlocked."); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room unlocked."); return TRUE; } } @@ -4687,7 +4687,7 @@ cmd_tiny(ProfWin *window, const char *const command, gchar **args) char *tiny = tinyurl_get(url); if (!tiny) { - win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", "Couldn't create tinyurl."); + win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", "Couldn't create tinyurl."); return TRUE; } diff --git a/src/plugins/api.c b/src/plugins/api.c index b504237b..3de5efab 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -85,7 +85,7 @@ api_cons_show_themed(const char *const group, const char *const key, const char char *parsed = str_replace(message, "\r\n", "\n"); theme_item_t themeitem = plugin_themes_get(group, key, def); ProfWin *console = wins_get_console(); - win_print(console, '-', 0, NULL, 0, themeitem, "", parsed); + win_printf(console, '-', 0, NULL, 0, themeitem, "", parsed); free(parsed); @@ -368,7 +368,7 @@ api_win_show(const char *tag, const char *line) } ProfWin *window = (ProfWin*)pluginwin; - win_print(window, '!', 0, NULL, 0, 0, "", line); + win_printf(window, '!', 0, NULL, 0, 0, "", line); return 1; } @@ -393,7 +393,7 @@ api_win_show_themed(const char *tag, const char *const group, const char *const theme_item_t themeitem = plugin_themes_get(group, key, def); ProfWin *window = (ProfWin*)pluginwin; - win_print(window, '!', 0, NULL, 0, themeitem, "", line); + win_printf(window, '!', 0, NULL, 0, themeitem, "", line); return 1; } diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 7ea985ea..a0b53749 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -96,9 +96,9 @@ chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted) ProfWin *window = (ProfWin*) chatwin; if (trusted) { - win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "OTR session started (trusted)."); + win_printf(window, '!', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "OTR session started (trusted)."); } else { - win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_UNTRUSTED, "", "OTR session started (untrusted)."); + win_printf(window, '!', 0, NULL, 0, THEME_OTR_STARTED_UNTRUSTED, "", "OTR session started (untrusted)."); } if (wins_is_current(window)) { @@ -125,7 +125,7 @@ chatwin_otr_unsecured(ProfChatWin *chatwin) chatwin->otr_is_trusted = FALSE; ProfWin *window = (ProfWin*)chatwin; - win_print(window, '!', 0, NULL, 0, THEME_OTR_ENDED, "", "OTR session ended."); + win_printf(window, '!', 0, NULL, 0, THEME_OTR_ENDED, "", "OTR session ended."); if (wins_is_current(window)) { title_bar_switch(); } @@ -188,7 +188,7 @@ chatwin_otr_trust(ProfChatWin *chatwin) chatwin->otr_is_trusted = TRUE; ProfWin *window = (ProfWin*)chatwin; - win_print(window, '!', 0, NULL, 0, THEME_OTR_TRUSTED, "", "OTR session trusted."); + win_printf(window, '!', 0, NULL, 0, THEME_OTR_TRUSTED, "", "OTR session trusted."); if (wins_is_current(window)) { title_bar_switch(); } @@ -203,7 +203,7 @@ chatwin_otr_untrust(ProfChatWin *chatwin) chatwin->otr_is_trusted = FALSE; ProfWin *window = (ProfWin*)chatwin; - win_print(window, '!', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted."); + win_printf(window, '!', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted."); if (wins_is_current(window)) { title_bar_switch(); } @@ -308,7 +308,7 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, if (request_receipt && id) { win_print_with_receipt((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message, id); } else { - win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); + win_printf((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); } } @@ -322,7 +322,7 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_en enc_char = prefs_get_pgp_char(); } - win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); + win_printf((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); int num = wins_get_num((ProfWin*)chatwin); status_bar_active(num); } @@ -401,11 +401,11 @@ _chatwin_history(ProfChatWin *chatwin, const char *const contact) char mm[3]; memcpy(mm, &line[3], 2); mm[2] = '\0'; int imm = atoi(mm); char ss[3]; memcpy(ss, &line[6], 2); ss[2] = '\0'; int iss = atoi(ss); GDateTime *timestamp = g_date_time_new_local(2000, 1, 1, ihh, imm, iss); - win_print((ProfWin*)chatwin, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", curr->data+11); + win_printf((ProfWin*)chatwin, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", curr->data+11); g_date_time_unref(timestamp); // header } else { - win_print((ProfWin*)chatwin, '-', 0, NULL, 0, 0, "", curr->data); + win_printf((ProfWin*)chatwin, '-', 0, NULL, 0, 0, "", curr->data); } curr = g_slist_next(curr); } diff --git a/src/ui/console.c b/src/ui/console.c index 139d0bb3..46c06b71 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -67,14 +67,14 @@ void cons_show_time(void) { ProfWin *console = wins_get_console(); - win_print(console, '-', 0, NULL, NO_EOL, 0, "", ""); + win_printf(console, '-', 0, NULL, NO_EOL, 0, "", ""); } void cons_show_word(const char *const word) { ProfWin *console = wins_get_console(); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", word); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", word); } void @@ -125,19 +125,19 @@ cons_show_help(const char *const cmd, CommandHelp *help) cons_show(""); win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s", &cmd[1]); - win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE_BOLD, "", ""); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_WHITE_BOLD, "", ""); int i; for (i = 0; i < strlen(cmd) - 1 ; i++) { - win_print(console, '-', 0, NULL, NO_EOL | NO_DATE, THEME_WHITE_BOLD, "", "-"); + win_printf(console, '-', 0, NULL, NO_EOL | NO_DATE, THEME_WHITE_BOLD, "", "-"); } - win_print(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", ""); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", ""); cons_show(""); - win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Synopsis"); + win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Synopsis"); ui_show_lines(console, help->synopsis); cons_show(""); - win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Description"); + win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Description"); win_println(console, 0, help->desc); int maxlen = 0; @@ -148,7 +148,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) if (i > 0) { cons_show(""); - win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Arguments"); + win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Arguments"); for (i = 0; help->args[i][0] != NULL; i++) { win_printf(console, '-', maxlen + 3, NULL, 0, 0, "", "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]); } @@ -156,7 +156,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) if (g_strv_length((gchar**)help->examples) > 0) { cons_show(""); - win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Examples"); + win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Examples"); ui_show_lines(console, help->examples); } } @@ -181,7 +181,7 @@ cons_show_error(const char *const msg, ...) va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - win_print(console, '-', 0, NULL, 0, THEME_ERROR, "", fmt_msg->str); + win_printf(console, '-', 0, NULL, 0, THEME_ERROR, "", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); @@ -484,7 +484,7 @@ cons_show_login_success(ProfAccount *account, gboolean secured) win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str); win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)", accounts_get_priority_for_presence_type(account->name, presence)); - win_print(console, '-', 0, NULL, NO_DATE, 0, "", "."); + win_printf(console, '-', 0, NULL, NO_DATE, 0, "", "."); if (!secured) { cons_show_error("TLS connection not established"); } @@ -555,26 +555,26 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); win_printf(console, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", fulljid); - win_print(console, '-', 0, NULL, NO_DATE, 0, "", ":"); + win_printf(console, '-', 0, NULL, NO_DATE, 0, "", ":"); // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_print(console, '-', 0, NULL, NO_EOL, 0, "", "Identity: "); + win_printf(console, '-', 0, NULL, NO_EOL, 0, "", "Identity: "); if (identity->name) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); if (identity->category || identity->type) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->type) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); if (identity->category) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->category) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); } win_newline(console); } @@ -706,10 +706,10 @@ cons_show_bookmarks(const GList *list) win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "/%s", item->nick); } if (item->autojoin) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (autojoin)"); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (autojoin)"); } if (item->password) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (private)"); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (private)"); } if (muc_active(item->barejid)) { ProfWin *roomwin = (ProfWin*)wins_get_muc(item->barejid); @@ -1014,21 +1014,21 @@ cons_show_account(ProfAccount *account) // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_print(console, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); + win_printf(console, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); if (identity->name) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); if (identity->category || identity->type) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->type) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); if (identity->category) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->category) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); } win_newline(console); } @@ -2078,7 +2078,7 @@ cons_navigation_help(void) { ProfWin *console = wins_get_console(); cons_show(""); - win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Navigation"); + win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Navigation"); cons_show("Alt-1..Alt-0, F1..F10 : Choose window."); cons_show("Alt-LEFT, Alt-RIGHT : Previous/next chat window."); cons_show("PAGEUP, PAGEDOWN : Page the main window."); @@ -2184,15 +2184,15 @@ _cons_theme_bar_prop(theme_item_t theme, char *prop) GString *propstr = g_string_new(" "); g_string_append_printf(propstr, "%-24s", prop); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", propstr->str); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", propstr->str); g_string_free(propstr, TRUE); GString *valstr = g_string_new(" "); char *setting = theme_get_string(prop); g_string_append_printf(valstr, "%s ", setting); theme_free_string(setting); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, theme, "", valstr->str); - win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, theme, "", valstr->str); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); g_string_free(valstr, TRUE); } @@ -2203,22 +2203,15 @@ _cons_theme_prop(theme_item_t theme, char *prop) GString *propstr = g_string_new(" "); g_string_append_printf(propstr, "%-24s", prop); - win_print(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", propstr->str); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", propstr->str); g_string_free(propstr, TRUE); GString *valstr = g_string_new(""); char *setting = theme_get_string(prop); g_string_append_printf(valstr, "%s", setting); theme_free_string(setting); - win_print(console, '-', 0, NULL, NO_DATE, theme, "", valstr->str); + win_printf(console, '-', 0, NULL, NO_DATE, theme, "", valstr->str); g_string_free(valstr, TRUE); - -// GString *str = g_string_new(" "); -// char *setting = theme_get_string(prop); -// g_string_append_printf(str, "%-24s%s", prop, setting); -// theme_free_string(setting); -// win_print(console, '-', 0, NULL, 0, theme, "", str->str); -// g_string_free(str, TRUE); } void @@ -2332,22 +2325,22 @@ cons_theme_colours(void) ProfWin *console = wins_get_console(); cons_show("Available colours:"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE, "", " white "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", " bold_white"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_GREEN, "", " green "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_GREEN_BOLD, "", " bold_green"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_RED, "", " red "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_RED_BOLD, "", " bold_red"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_YELLOW, "", " yellow "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_YELLOW_BOLD, "", " bold_yellow"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_BLUE, "", " blue "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_BLUE_BOLD, "", " bold_blue"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_CYAN, "", " cyan "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_CYAN_BOLD, "", " bold_cyan"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_MAGENTA, "", " magenta "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_MAGENTA_BOLD, "", " bold_magenta"); - win_print(console, '-', 0, NULL, NO_EOL, THEME_BLACK, "", " black "); - win_print(console, '-', 0, NULL, NO_DATE, THEME_BLACK_BOLD, "", " bold_black"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_WHITE, "", " white "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", " bold_white"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_GREEN, "", " green "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_GREEN_BOLD, "", " bold_green"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_RED, "", " red "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_RED_BOLD, "", " bold_red"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_YELLOW, "", " yellow "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_YELLOW_BOLD, "", " bold_yellow"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_BLUE, "", " blue "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_BLUE_BOLD, "", " bold_blue"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_CYAN, "", " cyan "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_CYAN_BOLD, "", " bold_cyan"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_MAGENTA, "", " magenta "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_MAGENTA_BOLD, "", " bold_magenta"); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_BLACK, "", " black "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_BLACK_BOLD, "", " bold_black"); cons_show(""); } @@ -2357,14 +2350,14 @@ _cons_splash_logo(void) ProfWin *console = wins_get_console(); win_println(console, 0, "Welcome to"); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ___ _ "); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " / __) (_)_ "); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ____ ____ ___ | |__ ____ ____ _| |_ _ _ "); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |"); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| | | | | | |_| | | ( ( | | | | | | |_| |_| |"); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |"); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "|_| (____/ "); - win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", ""); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ___ _ "); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", " / __) (_)_ "); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ____ ____ ___ | |__ ____ ____ _| |_ _ _ "); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |"); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| | | | | | |_| | | ( ( | | | | | | |_| |_| |"); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |"); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", "|_| (____/ "); + win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", ""); if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION @@ -2404,7 +2397,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) g_string_free(title, TRUE); - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " - "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " - "); GString *sub = g_string_new(""); sub = g_string_append(sub, p_contact_subscription(contact)); if (p_contact_pending_out(contact)) { @@ -2441,7 +2434,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) win_printf(console, '-', 0, NULL, NO_DATE, 0, "", "%s", groups_str->str); g_string_free(groups_str, TRUE); } else { - win_print(console, '-', 0, NULL, NO_DATE, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE, 0, "", " "); } } diff --git a/src/ui/core.c b/src/ui/core.c index 7f7b3ad0..daa54ef3 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -435,7 +435,7 @@ ui_handle_otr_error(const char *const barejid, const char *const message) { ProfChatWin *chatwin = wins_get_chat(barejid); if (chatwin) { - win_print((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", message); + win_printf((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", message); } else { cons_show_error("%s - %s", barejid, message); } @@ -752,7 +752,7 @@ ui_current_print_formatted_line(const char show_char, int attrs, const char *con va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - win_print(current, show_char, 0, NULL, 0, attrs, "", fmt_msg->str); + win_printf(current, show_char, 0, NULL, 0, attrs, "", fmt_msg->str); va_end(arg); g_string_free(fmt_msg, TRUE); } @@ -760,14 +760,14 @@ ui_current_print_formatted_line(const char show_char, int attrs, const char *con void ui_win_error_line(ProfWin *window, const char *const msg) { - win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", msg); + win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", msg); } void ui_current_error_line(const char *const msg) { ProfWin *current = wins_get_current(); - win_print(current, '-', 0, NULL, 0, THEME_ERROR, "", msg); + win_printf(current, '-', 0, NULL, 0, THEME_ERROR, "", msg); } void @@ -813,7 +813,7 @@ ui_room_join(const char *const roomjid, gboolean focus) win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", affiliation: %s", affiliation); } } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); if (focus) { @@ -1028,13 +1028,13 @@ ui_ask_pgp_passphrase(const char *hint, int prev_fail) win_println(current, 0, ""); if (prev_fail) { - win_print(current, '!', 0, NULL, 0, 0, "", "Incorrect passphrase"); + win_printf(current, '!', 0, NULL, 0, 0, "", "Incorrect passphrase"); } if (hint) { win_printf(current, '!', 0, NULL, 0, 0, "", "Enter PGP key passphrase for %s", hint); } else { - win_print(current, '!', 0, NULL, 0, 0, "", "Enter PGP key passphrase"); + win_printf(current, '!', 0, NULL, 0, 0, "", "Enter PGP key passphrase"); } ui_update(); @@ -1158,7 +1158,7 @@ ui_handle_room_configuration_form_error(const char *const roomjid, const char *c g_string_append(message_str, message); } - win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", message_str->str); + win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", message_str->str); g_string_free(message_str, TRUE); } @@ -1182,7 +1182,7 @@ ui_handle_room_config_submit_result(const char *const roomjid) if (muc_window) { ui_focus_win((ProfWin*)muc_window); - win_print(muc_window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room configuration successful"); + win_printf(muc_window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room configuration successful"); } else { ProfWin *console = wins_get_console(); ui_focus_win(console); @@ -1211,13 +1211,13 @@ ui_handle_room_config_submit_result_error(const char *const roomjid, const char if (message) { win_printf(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message); } else { - win_print(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); + win_printf(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); } } else if (muc_window) { if (message) { win_printf(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message); } else { - win_print(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); + win_printf(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); } } else { if (message) { @@ -1227,7 +1227,7 @@ ui_handle_room_config_submit_result_error(const char *const roomjid, const char } } } else { - win_print(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); + win_printf(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); } } @@ -1237,7 +1237,7 @@ ui_show_lines(ProfWin *window, gchar** lines) if (lines) { int i; for (i = 0; lines[i] != NULL; i++) { - win_print(window, '-', 0, NULL, 0, 0, "", lines[i]); + win_printf(window, '-', 0, NULL, 0, 0, "", lines[i]); } } } @@ -1274,7 +1274,7 @@ ui_handle_software_version_error(const char *const roomjid, const char *const me g_string_append(message_str, message); } - win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", message_str->str); + win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", message_str->str); g_string_free(message_str, TRUE); } @@ -1317,7 +1317,7 @@ ui_show_software_version(const char *const jid, const char *const presence, win_println(window, 0, ""); theme_item_t presence_colour = theme_main_presence_attrs(presence); win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", jid); - win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":"); + win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ":"); } if (name) { win_printf(window, '-', 0, NULL, 0, 0, "", "Name : %s", name); diff --git a/src/ui/mucconfwin.c b/src/ui/mucconfwin.c index 3f8987b6..c834bb93 100644 --- a/src/ui/mucconfwin.c +++ b/src/ui/mucconfwin.c @@ -47,12 +47,12 @@ mucconfwin_show_form(ProfMucConfWin *confwin) { ProfWin *window = (ProfWin*) confwin; if (confwin->form->title) { - win_print(window, '-', 0, NULL, NO_EOL, 0, "", "Form title: "); - win_print(window, '-', 0, NULL, NO_DATE, 0, "", confwin->form->title); + win_printf(window, '-', 0, NULL, NO_EOL, 0, "", "Form title: "); + win_printf(window, '-', 0, NULL, NO_DATE, 0, "", confwin->form->title); } else { win_printf(window, '-', 0, NULL, 0, 0, "", "Configuration for room %s.", confwin->roomjid); } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); mucconfwin_form_help(confwin); @@ -64,7 +64,7 @@ mucconfwin_show_form(ProfMucConfWin *confwin) if ((g_strcmp0(field->type, "fixed") == 0) && field->values) { if (field->values) { char *value = field->values->data; - win_print(window, '-', 0, NULL, 0, 0, "", value); + win_printf(window, '-', 0, NULL, 0, 0, "", value); } } else if (g_strcmp0(field->type, "hidden") != 0 && field->var) { char *tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var); @@ -96,11 +96,11 @@ mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form) mucconfwin_show_form(confwin); - win_print(window, '-', 0, NULL, 0, 0, "", ""); - win_print(window, '-', 0, NULL, 0, 0, "", "Use '/form submit' to save changes."); - win_print(window, '-', 0, NULL, 0, 0, "", "Use '/form cancel' to cancel changes."); - win_print(window, '-', 0, NULL, 0, 0, "", "See '/form help' for more information."); - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", "Use '/form submit' to save changes."); + win_printf(window, '-', 0, NULL, 0, 0, "", "Use '/form cancel' to cancel changes."); + win_printf(window, '-', 0, NULL, 0, 0, "", "See '/form help' for more information."); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } void @@ -111,11 +111,11 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) ProfWin *window = (ProfWin*) confwin; FormField *field = form_get_field_by_tag(confwin->form, tag); if (field) { - win_print(window, '-', 0, NULL, NO_EOL, 0, "", field->label); + win_printf(window, '-', 0, NULL, NO_EOL, 0, "", field->label); if (field->required) { - win_print(window, '-', 0, NULL, NO_DATE, 0, "", " (Required):"); + win_printf(window, '-', 0, NULL, NO_DATE, 0, "", " (Required):"); } else { - win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":"); + win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ":"); } if (field->description) { win_printf(window, '-', 0, NULL, 0, 0, "", " Description : %s", field->description); @@ -130,12 +130,12 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) case FIELD_TEXT_SINGLE: case FIELD_TEXT_PRIVATE: win_printf(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is any text"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is any text"); break; case FIELD_TEXT_MULTI: num_values = form_get_value_count(confwin->form, tag); win_printf(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is any text"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is any text"); if (num_values > 0) { win_printf(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); win_printf(window, '-', 0, NULL, 0, 0, "", " Where : between 'val1' and 'val%d'", num_values); @@ -143,11 +143,11 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) break; case FIELD_BOOLEAN: win_printf(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is either 'on' or 'off'"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is either 'on' or 'off'"); break; case FIELD_LIST_SINGLE: win_printf(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is one of"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; @@ -158,7 +158,7 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) case FIELD_LIST_MULTI: win_printf(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); win_printf(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is one of"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is one of"); curr_option = field->options; while (curr_option) { option = curr_option->data; @@ -168,12 +168,12 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) break; case FIELD_JID_SINGLE: win_printf(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is a valid Jabber ID"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is a valid Jabber ID"); break; case FIELD_JID_MULTI: win_printf(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); win_printf(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); - win_print(window, '-', 0, NULL, 0, 0, "", " Where : is a valid Jabber ID"); + win_printf(window, '-', 0, NULL, 0, 0, "", " Where : is a valid Jabber ID"); break; case FIELD_FIXED: case FIELD_UNKNOWN: @@ -193,9 +193,9 @@ mucconfwin_form_help(ProfMucConfWin *confwin) if (confwin->form->instructions) { ProfWin *window = (ProfWin*) confwin; - win_print(window, '-', 0, NULL, 0, 0, "", "Supplied instructions:"); - win_print(window, '-', 0, NULL, 0, 0, "", confwin->form->instructions); - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", "Supplied instructions:"); + win_printf(window, '-', 0, NULL, 0, 0, "", confwin->form->instructions); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } } @@ -205,9 +205,9 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) win_printf(window, '-', 0, NULL, NO_EOL, THEME_AWAY, "", "[%s] ", tag); win_printf(window, '-', 0, NULL, NO_EOL | NO_DATE, 0, "", "%s", field->label); if (field->required) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (required): "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (required): "); } else { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ": "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ": "); } GSList *values = field->values; @@ -221,9 +221,9 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) char *value = curr_value->data; if (value) { if (g_strcmp0(field->var, "muc#roomconfig_roomsecret") == 0) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); } else { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value); } } } @@ -233,7 +233,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); } } win_newline(window); @@ -252,16 +252,16 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) break; case FIELD_BOOLEAN: if (curr_value == NULL) { - win_print(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); + win_printf(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); } else { char *value = curr_value->data; if (value == NULL) { - win_print(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); + win_printf(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); } else { if (g_strcmp0(value, "0") == 0) { - win_print(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); + win_printf(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); } else { - win_print(window, '-', 0, NULL, NO_DATE, THEME_ONLINE, "", "TRUE"); + win_printf(window, '-', 0, NULL, NO_DATE, THEME_ONLINE, "", "TRUE"); } } } @@ -303,7 +303,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value); } } win_newline(window); @@ -320,7 +320,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", value); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", value); } } win_newline(window); diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 8bb67790..7bbf65e8 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -58,7 +58,7 @@ mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } void @@ -75,7 +75,7 @@ mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, con if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } void @@ -92,7 +92,7 @@ mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, c if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } @@ -110,7 +110,7 @@ mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const ch if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } void @@ -127,7 +127,7 @@ mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, c if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } void @@ -144,7 +144,7 @@ mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *cons if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } void @@ -154,7 +154,7 @@ mucwin_room_info_error(ProfMucWin *mucwin, const char *const error) ProfWin *window = (ProfWin*)mucwin; win_printf(window, '!', 0, NULL, 0, 0, "", "Room info request failed: %s", error); - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } void @@ -166,7 +166,7 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) if ((identities && (g_slist_length(identities) > 0)) || (features && (g_slist_length(features) > 0))) { if (identities) { - win_print(window, '!', 0, NULL, 0, 0, "", "Identities:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Identities:"); } while (identities) { DiscoIdentity *identity = identities->data; // anme trpe, cat @@ -182,19 +182,19 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) if (identity->category) { identity_str = g_string_append(identity_str, identity->category); } - win_print(window, '!', 0, NULL, 0, 0, "", identity_str->str); + win_printf(window, '!', 0, NULL, 0, 0, "", identity_str->str); g_string_free(identity_str, TRUE); identities = g_slist_next(identities); } if (features) { - win_print(window, '!', 0, NULL, 0, 0, "", "Features:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Features:"); } while (features) { win_printf(window, '!', 0, NULL, 0, 0, "", " %s", features->data); features = g_slist_next(features); } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } } @@ -206,7 +206,7 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) ProfWin *window = (ProfWin*)mucwin; if ((roster == NULL) || (g_list_length(roster) == 0)) { if (presence == NULL) { - win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room is empty."); + win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room is empty."); } else { win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "No occupants %s.", presence); } @@ -226,12 +226,12 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick); if (roster->next) { - win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", "); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", "); } roster = g_list_next(roster); } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ONLINE, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ONLINE, "", ""); } } @@ -305,7 +305,7 @@ mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *c win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", affiliation: %s", affiliation); } } - win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); } void @@ -355,7 +355,7 @@ mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, g_string_append(line, message); } - win_print(window, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", line->str); + win_printf(window, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", line->str); g_string_free(line, TRUE); plugins_on_room_history_message(mucwin->roomjid, nick, message, timestamp); @@ -371,10 +371,10 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co pos = GPOINTER_TO_INT(curr->data); char *before_str = g_strndup(message + last_pos, pos - last_pos); - win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION, "", before_str); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION, "", before_str); g_free(before_str); char *nick_str = g_strndup(message + pos, strlen(nick)); - win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION_TERM, "", nick_str); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION_TERM, "", nick_str); g_free(nick_str); last_pos = pos + strlen(nick); @@ -382,9 +382,9 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co curr = g_slist_next(curr); } if (last_pos < strlen(message)) { - win_print(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", &message[last_pos]); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", &message[last_pos]); } else { - win_print(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", ""); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", ""); } } @@ -442,7 +442,7 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge // no triggers found if (first_trigger_pos == -1) { - win_print(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER, "", message); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER, "", message); } else { if (first_trigger_pos > 0) { char message_section[strlen(message) + 1]; @@ -452,7 +452,7 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge i++; } message_section[i] = '\0'; - win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER, "", message_section); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER, "", message_section); } char trigger_section[first_trigger_len + 1]; int i = 0; @@ -463,10 +463,10 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge trigger_section[i] = '\0'; if (first_trigger_pos + first_trigger_len < strlen(message)) { - win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER_TERM, "", trigger_section); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER_TERM, "", trigger_section); _mucwin_print_triggers(window, &message[first_trigger_pos + first_trigger_len], triggers); } else { - win_print(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER_TERM, "", trigger_section); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER_TERM, "", trigger_section); } } } @@ -481,16 +481,16 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes if (g_strcmp0(nick, mynick) != 0) { if (g_slist_length(mentions) > 0) { - win_print(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMMENTION, nick, ""); + win_printf(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMMENTION, nick, ""); _mucwin_print_mention(window, message, mynick, mentions); } else if (triggers) { - win_print(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMTRIGGER, nick, ""); + win_printf(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMTRIGGER, nick, ""); _mucwin_print_triggers(window, message, triggers); } else { - win_print(window, '-', 0, NULL, NO_ME, THEME_TEXT_THEM, nick, message); + win_printf(window, '-', 0, NULL, NO_ME, THEME_TEXT_THEM, nick, message); } } else { - win_print(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, message); + win_printf(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, message); } } @@ -506,12 +506,12 @@ mucwin_requires_config(ProfMucWin *mucwin) ui_index = 0; } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room locked, requires configuration."); win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room accept' to accept the defaults"); win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room destroy' to cancel and destroy the room"); win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room config' to edit the room configuration"); - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); // currently in groupchat window if (wins_is_current(window)) { @@ -611,10 +611,10 @@ mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation win_printf(window, '!', 0, NULL, 0, 0, "", " %s", jid); curr_jid = g_slist_next(curr_jid); } - win_print(window, '!', 0, NULL, 0, 0, "", ""); + win_printf(window, '!', 0, NULL, 0, 0, "", ""); } else { win_printf(window, '!', 0, NULL, 0, 0, "", "No users found with affiliation: %s", affiliation); - win_print(window, '!', 0, NULL, 0, 0, "", ""); + win_printf(window, '!', 0, NULL, 0, 0, "", ""); } } @@ -629,34 +629,34 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) if (!occupants) { switch (affiliation) { case MUC_AFFILIATION_OWNER: - win_print(window, '!', 0, NULL, 0, 0, "", "No owners found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No owners found."); break; case MUC_AFFILIATION_ADMIN: - win_print(window, '!', 0, NULL, 0, 0, "", "No admins found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No admins found."); break; case MUC_AFFILIATION_MEMBER: - win_print(window, '!', 0, NULL, 0, 0, "", "No members found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No members found."); break; case MUC_AFFILIATION_OUTCAST: - win_print(window, '!', 0, NULL, 0, 0, "", "No outcasts found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No outcasts found."); break; default: break; } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } else { switch (affiliation) { case MUC_AFFILIATION_OWNER: - win_print(window, '!', 0, NULL, 0, 0, "", "Owners:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Owners:"); break; case MUC_AFFILIATION_ADMIN: - win_print(window, '!', 0, NULL, 0, 0, "", "Admins:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Admins:"); break; case MUC_AFFILIATION_MEMBER: - win_print(window, '!', 0, NULL, 0, 0, "", "Members:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Members:"); break; case MUC_AFFILIATION_OUTCAST: - win_print(window, '!', 0, NULL, 0, 0, "", "Outcasts:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Outcasts:"); break; default: break; @@ -676,7 +676,7 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) curr_occupant = g_slist_next(curr_occupant); } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } } @@ -712,10 +712,10 @@ mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nick } curr_nick = g_slist_next(curr_nick); } - win_print(window, '!', 0, NULL, 0, 0, "", ""); + win_printf(window, '!', 0, NULL, 0, 0, "", ""); } else { win_printf(window, '!', 0, NULL, 0, 0, "", "No occupants found with role: %s", role); - win_print(window, '!', 0, NULL, 0, 0, "", ""); + win_printf(window, '!', 0, NULL, 0, 0, "", ""); } } @@ -730,28 +730,28 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) if (!occupants) { switch (role) { case MUC_ROLE_MODERATOR: - win_print(window, '!', 0, NULL, 0, 0, "", "No moderators found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No moderators found."); break; case MUC_ROLE_PARTICIPANT: - win_print(window, '!', 0, NULL, 0, 0, "", "No participants found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No participants found."); break; case MUC_ROLE_VISITOR: - win_print(window, '!', 0, NULL, 0, 0, "", "No visitors found."); + win_printf(window, '!', 0, NULL, 0, 0, "", "No visitors found."); break; default: break; } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } else { switch (role) { case MUC_ROLE_MODERATOR: - win_print(window, '!', 0, NULL, 0, 0, "", "Moderators:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Moderators:"); break; case MUC_ROLE_PARTICIPANT: - win_print(window, '!', 0, NULL, 0, 0, "", "Participants:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Participants:"); break; case MUC_ROLE_VISITOR: - win_print(window, '!', 0, NULL, 0, 0, "", "Visitors:"); + win_printf(window, '!', 0, NULL, 0, 0, "", "Visitors:"); break; default: break; @@ -771,7 +771,7 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) curr_occupant = g_slist_next(curr_occupant); } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } } @@ -807,7 +807,7 @@ mucwin_info(ProfMucWin *mucwin) win_printf(window, '!', 0, NULL, 0, 0, "", "Room: %s", mucwin->roomjid); win_printf(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation); win_printf(window, '!', 0, NULL, 0, 0, "", "Role: %s", role); - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } void diff --git a/src/ui/privwin.c b/src/ui/privwin.c index b540fb44..fe98aa85 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -93,7 +93,7 @@ privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message) { assert(privwin != NULL); - win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message); + win_printf((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message); } void @@ -101,7 +101,7 @@ privwin_message_occupant_offline(ProfPrivateWin *privwin) { assert(privwin != NULL); - win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, occupant no longer present in room."); + win_printf((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, occupant no longer present in room."); } void @@ -109,7 +109,7 @@ privwin_message_left_room(ProfPrivateWin *privwin) { assert(privwin != NULL); - win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, you are no longer present in room."); + win_printf((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, you are no longer present in room."); } void diff --git a/src/ui/ui.h b/src/ui/ui.h index 95e26933..d7ea0e96 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -357,8 +357,8 @@ void win_hide_subwin(ProfWin *window); void win_show_subwin(ProfWin *window); void win_refresh_without_subwin(ProfWin *window); void win_refresh_with_subwin(ProfWin *window); -void win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const from, const char *const message); -void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const from, const char *const message, ...); +void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, + theme_item_t theme_item, const char *const from, const char *const message, ...); char* win_get_title(ProfWin *window); void win_show_occupant(ProfWin *window, Occupant *occupant); void win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupant); diff --git a/src/ui/window.c b/src/ui/window.c index ebcd9e53..a410d6d5 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -683,14 +683,14 @@ win_show_occupant(ProfWin *window, Occupant *occupant) theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); if (occupant->status) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); } - win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); + win_printf(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); } void @@ -705,9 +705,9 @@ win_show_contact(ProfWin *window, PContact contact) theme_item_t presence_colour = theme_main_presence_attrs(presence); if (name) { - win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", name); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", name); } else { - win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); } win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence); @@ -735,7 +735,7 @@ win_show_contact(ProfWin *window, PContact contact) win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", p_contact_status(contact)); } - win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); + win_printf(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); } void @@ -747,7 +747,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_print(window, '!', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); + win_printf(window, '!', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); if (occupant->status) { @@ -771,21 +771,21 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_print(window, '!', 0, NULL, NO_EOL, 0, "", " Identity: "); + win_printf(window, '!', 0, NULL, NO_EOL, 0, "", " Identity: "); if (identity->name) { - win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); if (identity->category || identity->type) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->type) { - win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); if (identity->category) { - win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->category) { - win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); } win_newline(window); } @@ -815,7 +815,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa caps_destroy(caps); } - win_print(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); } void @@ -829,12 +829,12 @@ win_show_info(ProfWin *window, PContact contact) theme_item_t presence_colour = theme_main_presence_attrs(presence); - win_print(window, '-', 0, NULL, 0, 0, "", ""); - win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); + win_printf(window, '-', 0, NULL, 0, 0, "", ""); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); if (name) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name); } - win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":"); + win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ":"); if (sub) { win_printf(window, '-', 0, NULL, 0, 0, "", "Subscription: %s", sub); @@ -863,7 +863,7 @@ win_show_info(ProfWin *window, PContact contact) GList *resources = p_contact_get_available_resources(contact); GList *ordered_resources = NULL; if (resources) { - win_print(window, '-', 0, NULL, 0, 0, "", "Resources:"); + win_printf(window, '-', 0, NULL, 0, 0, "", "Resources:"); // sort in order of availability GList *curr = resources; @@ -895,21 +895,21 @@ win_show_info(ProfWin *window, PContact contact) // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_print(window, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); + win_printf(window, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); if (identity->name) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); if (identity->category || identity->type) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->type) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); if (identity->category) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->category) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); } win_newline(window); } @@ -983,7 +983,7 @@ win_show_status_string(ProfWin *window, const char *const from, if (status) win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", status); - win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); + win_printf(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); } @@ -1001,10 +1001,10 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp, } else if (enc_mode == PROF_MSG_PGP) { enc_char = prefs_get_pgp_char(); } - win_print(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); + win_printf(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); break; case WIN_PRIVATE: - win_print(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); + win_printf(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); break; default: assert(FALSE); @@ -1015,19 +1015,6 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp, void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const from, const char *const message, ...) -{ - va_list arg; - va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); - g_string_vprintf(fmt_msg, message, arg); - win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str); - g_string_free(fmt_msg, TRUE); - va_end(arg); -} - -void -win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, - int flags, theme_item_t theme_item, const char *const from, const char *const message) { if (timestamp == NULL) { timestamp = g_date_time_new_now_local(); @@ -1035,11 +1022,20 @@ win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *time g_date_time_ref(timestamp); } - buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL); - _win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL); + va_list arg; + va_start(arg, message); + GString *fmt_msg = g_string_new(NULL); + g_string_vprintf(fmt_msg, message, arg); + + buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL); + + _win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL); // TODO: cross-reference.. this should be replaced by a real event-based system inp_nonblocking(TRUE); g_date_time_unref(timestamp); + + g_string_free(fmt_msg, TRUE); + va_end(arg); } void @@ -1098,7 +1094,7 @@ win_update_entry_theme(ProfWin *window, const char *const id, theme_item_t theme void win_println(ProfWin *window, int pad, const char *const message) { - win_print(window, '-', pad, NULL, 0, 0, "", message); + win_printf(window, '-', pad, NULL, 0, 0, "", message); } void @@ -1108,7 +1104,7 @@ win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) va_start(arg, message); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - win_print(window, ch, 0, NULL, 0, 0, "", fmt_msg->str); + win_printf(window, ch, 0, NULL, 0, 0, "", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); } @@ -1116,7 +1112,7 @@ win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) void win_newline(ProfWin *window) { - win_print(window, '-', 0, NULL, NO_DATE, 0, "", ""); + win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ""); } static void diff --git a/src/ui/window_list.c b/src/ui/window_list.c index 8a3ad299..c61f9635 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -835,7 +835,7 @@ wins_lost_connection(void) while (curr) { ProfWin *window = curr->data; if (window->type != WIN_CONSOLE) { - win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", "Lost connection."); + win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", "Lost connection."); // if current win, set current_win_dirty if (wins_is_current(window)) { diff --git a/src/ui/xmlwin.c b/src/ui/xmlwin.c index 80870b46..c8af2211 100644 --- a/src/ui/xmlwin.c +++ b/src/ui/xmlwin.c @@ -45,13 +45,13 @@ xmlwin_show(ProfXMLWin *xmlwin, const char *const msg) ProfWin *window = (ProfWin*)xmlwin; if (g_str_has_prefix(msg, "SENT:")) { - win_print(window, '-', 0, NULL, 0, 0, "", "SENT:"); - win_print(window, '-', 0, NULL, 0, THEME_ONLINE, "", &msg[6]); - win_print(window, '-', 0, NULL, 0, THEME_ONLINE, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", "SENT:"); + win_printf(window, '-', 0, NULL, 0, THEME_ONLINE, "", &msg[6]); + win_printf(window, '-', 0, NULL, 0, THEME_ONLINE, "", ""); } else if (g_str_has_prefix(msg, "RECV:")) { - win_print(window, '-', 0, NULL, 0, 0, "", "RECV:"); - win_print(window, '-', 0, NULL, 0, THEME_AWAY, "", &msg[6]); - win_print(window, '-', 0, NULL, 0, THEME_AWAY, "", ""); + win_printf(window, '-', 0, NULL, 0, 0, "", "RECV:"); + win_printf(window, '-', 0, NULL, 0, THEME_AWAY, "", &msg[6]); + win_printf(window, '-', 0, NULL, 0, THEME_AWAY, "", ""); } } diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index af3a18a0..275d2487 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -520,7 +520,6 @@ void win_hide_subwin(ProfWin *window) {} void win_show_subwin(ProfWin *window) {} void win_refresh_without_subwin(ProfWin *window) {} void win_refresh_with_subwin(ProfWin *window) {} -void win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message) {} void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, ...) {} char* win_get_title(ProfWin *window) { From af42bc4434a4eedaf13e057a73e17fe46e0eb110 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 11 Oct 2016 23:40:15 +0100 Subject: [PATCH 04/28] Add win_print_http_upload --- src/tools/http_upload.c | 2 +- src/ui/window.c | 6 ++++++ src/ui/window.h | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/tools/http_upload.c b/src/tools/http_upload.c index fc41ec5e..23315460 100644 --- a/src/tools/http_upload.c +++ b/src/tools/http_upload.c @@ -146,7 +146,7 @@ http_file_put(void *userdata) if (asprintf(&msg, "Uploading '%s': 0%%", upload->filename) == -1) { msg = strdup(FALLBACK_MSG); } - win_print_with_receipt(upload->window, '!', 0, NULL, 0, THEME_TEXT_ME, NULL, msg, upload->put_url); + win_print_http_upload(upload->window, msg, upload->put_url); free(msg); char *cert_path = prefs_get_string(PREF_TLS_CERTPATH); diff --git a/src/ui/window.c b/src/ui/window.c index a410d6d5..b0ca6215 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1038,6 +1038,12 @@ win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim va_end(arg); } +void +win_print_http_upload(ProfWin *window, const char *const message, char *url) +{ + win_print_with_receipt(window, '!', 0, NULL, 0, THEME_TEXT_ME, NULL, message, url); +} + void win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp, int flags, theme_item_t theme_item, const char *const from, const char *const message, char *id) diff --git a/src/ui/window.h b/src/ui/window.h index cc9ae8df..4b82b1d4 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -61,8 +61,12 @@ void win_show_status_string(ProfWin *window, const char *const from, const char *const default_show); void win_print_incoming_message(ProfWin *window, GDateTime *timestamp, const char *const from, const char *const message, prof_enc_t enc_mode); + +void win_print_http_upload(ProfWin *window, const char *const message, char *url); + void win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp, int flags, theme_item_t theme_item, const char *const from, const char *const message, char *id); + void win_newline(ProfWin *window); void win_redraw(ProfWin *window); int win_roster_cols(void); From 7b31af30609e7045a1f6b39668d7abedfb1755da Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 11 Oct 2016 23:47:13 +0100 Subject: [PATCH 05/28] Remove args from win_print_with_receipt --- src/ui/chatwin.c | 2 +- src/ui/window.c | 18 ++++++------------ src/ui/window.h | 4 ++-- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index a0b53749..0d7f01b0 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -306,7 +306,7 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, } if (request_receipt && id) { - win_print_with_receipt((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message, id); + win_print_with_receipt((ProfWin*)chatwin, enc_char, "me", message, id); } else { win_printf((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); } diff --git a/src/ui/window.c b/src/ui/window.c index b0ca6215..81ecb3cd 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1041,27 +1041,21 @@ win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim void win_print_http_upload(ProfWin *window, const char *const message, char *url) { - win_print_with_receipt(window, '!', 0, NULL, 0, THEME_TEXT_ME, NULL, message, url); + win_print_with_receipt(window, '!', NULL, message, url); } void -win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp, - int flags, theme_item_t theme_item, const char *const from, const char *const message, char *id) +win_print_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message, + char *id) { - GDateTime *time; - - if (tstamp == NULL) { - time = g_date_time_new_now_local(); - } else { - time = g_date_time_new_from_timeval_utc(tstamp); - } + GDateTime *time = g_date_time_new_now_local(); DeliveryReceipt *receipt = malloc(sizeof(struct delivery_receipt_t)); receipt->id = strdup(id); receipt->received = FALSE; - buffer_push(window->layout->buffer, show_char, pad_indent, time, flags, theme_item, from, message, receipt); - _win_print(window, show_char, pad_indent, time, flags, theme_item, from, message, receipt); + buffer_push(window->layout->buffer, show_char, 0, time, 0, THEME_TEXT_ME, from, message, receipt); + _win_print(window, show_char, 0, time, 0, THEME_TEXT_ME, from, message, receipt); // TODO: cross-reference.. this should be replaced by a real event-based system inp_nonblocking(TRUE); g_date_time_unref(time); diff --git a/src/ui/window.h b/src/ui/window.h index 4b82b1d4..ee53b1de 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -64,8 +64,8 @@ void win_print_incoming_message(ProfWin *window, GDateTime *timestamp, void win_print_http_upload(ProfWin *window, const char *const message, char *url); -void win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp, int flags, - theme_item_t theme_item, const char *const from, const char *const message, char *id); +void win_print_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message, + char *id); void win_newline(ProfWin *window); void win_redraw(ProfWin *window); From 97898ee082d314eb6d7f27a0b0d33027defc9a32 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 12 Oct 2016 00:14:55 +0100 Subject: [PATCH 06/28] Add win_printf_line --- src/command/cmd_funcs.c | 4 ++-- src/ui/ui.h | 1 + src/ui/window.c | 21 ++++++++++++++++++++- tests/unittests/ui/stub_ui.c | 2 ++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 0117029b..7d4f0064 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(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s commands", tag); + win_printf_line(console, THEME_WHITE_BOLD, "%s commands", tag); } else { - win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "All commands"); + win_printf_line(console, THEME_WHITE_BOLD, "All commands"); } GList *ordered_commands = NULL; diff --git a/src/ui/ui.h b/src/ui/ui.h index d7ea0e96..9ba7e65c 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -359,6 +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, ...); 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 81ecb3cd..133a3990 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1030,7 +1030,26 @@ win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL); _win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL); - // TODO: cross-reference.. this should be replaced by a real event-based system + inp_nonblocking(TRUE); + g_date_time_unref(timestamp); + + g_string_free(fmt_msg, TRUE); + va_end(arg); +} + +void +win_printf_line(ProfWin *window, theme_item_t theme_item, 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, '-', 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL); + + _win_print(window, '-', 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); g_date_time_unref(timestamp); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 275d2487..a4eb7e68 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -521,6 +521,8 @@ 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, ...) {} + char* win_get_title(ProfWin *window) { return NULL; From 24f0dc2734baf13ff5ecbb3e46bc08b809ee4736 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 12 Oct 2016 00:40:41 +0100 Subject: [PATCH 07/28] Always use string format in win_printf --- src/plugins/api.c | 6 +++--- src/ui/chatwin.c | 8 ++++---- src/ui/console.c | 26 +++++++++++++------------- src/ui/core.c | 14 +++++++------- src/ui/mucconfwin.c | 14 +++++++------- src/ui/mucwin.c | 22 +++++++++++----------- src/ui/privwin.c | 2 +- src/ui/window.c | 30 +++++++++++++++--------------- src/ui/xmlwin.c | 4 ++-- 9 files changed, 63 insertions(+), 63 deletions(-) diff --git a/src/plugins/api.c b/src/plugins/api.c index 3de5efab..670f8551 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(console, '-', 0, NULL, 0, themeitem, "", parsed); + win_printf(console, '-', 0, NULL, 0, themeitem, "", "%s", parsed); free(parsed); @@ -368,7 +368,7 @@ api_win_show(const char *tag, const char *line) } ProfWin *window = (ProfWin*)pluginwin; - win_printf(window, '!', 0, NULL, 0, 0, "", line); + win_printf(window, '!', 0, NULL, 0, 0, "", "%s", line); return 1; } @@ -393,7 +393,7 @@ api_win_show_themed(const char *tag, const char *const group, const char *const theme_item_t themeitem = plugin_themes_get(group, key, def); ProfWin *window = (ProfWin*)pluginwin; - win_printf(window, '!', 0, NULL, 0, themeitem, "", line); + win_printf(window, '!', 0, NULL, 0, themeitem, "", "%s", line); return 1; } diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 0d7f01b0..8fc06307 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -308,7 +308,7 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, if (request_receipt && id) { win_print_with_receipt((ProfWin*)chatwin, enc_char, "me", message, id); } else { - win_printf((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); + win_printf((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", "%s", message); } } @@ -322,7 +322,7 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_en enc_char = prefs_get_pgp_char(); } - win_printf((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); + win_printf((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", "%s", message); int num = wins_get_num((ProfWin*)chatwin); status_bar_active(num); } @@ -401,11 +401,11 @@ _chatwin_history(ProfChatWin *chatwin, const char *const contact) char mm[3]; memcpy(mm, &line[3], 2); mm[2] = '\0'; int imm = atoi(mm); char ss[3]; memcpy(ss, &line[6], 2); ss[2] = '\0'; int iss = atoi(ss); GDateTime *timestamp = g_date_time_new_local(2000, 1, 1, ihh, imm, iss); - win_printf((ProfWin*)chatwin, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", curr->data+11); + win_printf((ProfWin*)chatwin, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", "%s", curr->data+11); g_date_time_unref(timestamp); // header } else { - win_printf((ProfWin*)chatwin, '-', 0, NULL, 0, 0, "", curr->data); + win_printf((ProfWin*)chatwin, '-', 0, NULL, 0, 0, "", "%s", curr->data); } curr = g_slist_next(curr); } diff --git a/src/ui/console.c b/src/ui/console.c index 46c06b71..03e9f439 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -74,7 +74,7 @@ void cons_show_word(const char *const word) { ProfWin *console = wins_get_console(); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", word); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", word); } void @@ -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(console, '-', 0, NULL, 0, THEME_ERROR, "", fmt_msg->str); + win_printf(console, '-', 0, NULL, 0, THEME_ERROR, "", "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); @@ -562,19 +562,19 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) DiscoIdentity *identity = caps->identity; win_printf(console, '-', 0, NULL, NO_EOL, 0, "", "Identity: "); if (identity->name) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->name); if (identity->category || identity->type) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->type); if (identity->category) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->category); } win_newline(console); } @@ -1016,19 +1016,19 @@ cons_show_account(ProfAccount *account) DiscoIdentity *identity = caps->identity; win_printf(console, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); if (identity->name) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->name); if (identity->category || identity->type) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->type); if (identity->category) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->category); } win_newline(console); } @@ -2184,14 +2184,14 @@ _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, "", propstr->str); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", "%s", propstr->str); g_string_free(propstr, TRUE); GString *valstr = g_string_new(" "); char *setting = theme_get_string(prop); g_string_append_printf(valstr, "%s ", setting); theme_free_string(setting); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, theme, "", valstr->str); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, theme, "", "%s", valstr->str); win_printf(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); g_string_free(valstr, TRUE); } @@ -2203,14 +2203,14 @@ _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, "", propstr->str); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", "%s", propstr->str); g_string_free(propstr, TRUE); GString *valstr = g_string_new(""); char *setting = theme_get_string(prop); g_string_append_printf(valstr, "%s", setting); theme_free_string(setting); - win_printf(console, '-', 0, NULL, NO_DATE, theme, "", valstr->str); + win_printf(console, '-', 0, NULL, NO_DATE, theme, "", "%s", valstr->str); g_string_free(valstr, TRUE); } @@ -2393,7 +2393,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, "", title->str); + win_printf(console, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", title->str); g_string_free(title, TRUE); diff --git a/src/ui/core.c b/src/ui/core.c index daa54ef3..c1bba8ac 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -435,7 +435,7 @@ ui_handle_otr_error(const char *const barejid, const char *const message) { ProfChatWin *chatwin = wins_get_chat(barejid); if (chatwin) { - win_printf((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", message); + win_printf((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", "%s", message); } else { cons_show_error("%s - %s", barejid, message); } @@ -752,7 +752,7 @@ ui_current_print_formatted_line(const char show_char, int attrs, const char *con va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - win_printf(current, show_char, 0, NULL, 0, attrs, "", fmt_msg->str); + win_printf(current, show_char, 0, NULL, 0, attrs, "", "%s", fmt_msg->str); va_end(arg); g_string_free(fmt_msg, TRUE); } @@ -760,14 +760,14 @@ ui_current_print_formatted_line(const char show_char, int attrs, const char *con void ui_win_error_line(ProfWin *window, const char *const msg) { - win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", msg); + win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", "%s", msg); } void ui_current_error_line(const char *const msg) { ProfWin *current = wins_get_current(); - win_printf(current, '-', 0, NULL, 0, THEME_ERROR, "", msg); + win_printf(current, '-', 0, NULL, 0, THEME_ERROR, "", "%s", msg); } void @@ -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(window, '-', 0, NULL, 0, THEME_ERROR, "", message_str->str); + win_printf(window, '-', 0, NULL, 0, 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(window, '-', 0, NULL, 0, 0, "", lines[i]); + win_printf(window, '-', 0, NULL, 0, 0, "", "%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(window, '-', 0, NULL, 0, THEME_ERROR, "", message_str->str); + win_printf(window, '-', 0, NULL, 0, THEME_ERROR, "", "%s", message_str->str); g_string_free(message_str, TRUE); } diff --git a/src/ui/mucconfwin.c b/src/ui/mucconfwin.c index c834bb93..954e4e0e 100644 --- a/src/ui/mucconfwin.c +++ b/src/ui/mucconfwin.c @@ -48,7 +48,7 @@ mucconfwin_show_form(ProfMucConfWin *confwin) ProfWin *window = (ProfWin*) confwin; if (confwin->form->title) { win_printf(window, '-', 0, NULL, NO_EOL, 0, "", "Form title: "); - win_printf(window, '-', 0, NULL, NO_DATE, 0, "", confwin->form->title); + win_printf(window, '-', 0, NULL, NO_DATE, 0, "", "%s", confwin->form->title); } else { win_printf(window, '-', 0, NULL, 0, 0, "", "Configuration for room %s.", confwin->roomjid); } @@ -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(window, '-', 0, NULL, 0, 0, "", value); + win_printf(window, '-', 0, NULL, 0, 0, "", "%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); @@ -111,7 +111,7 @@ 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, 0, "", field->label); + win_printf(window, '-', 0, NULL, NO_EOL, 0, "", "%s", field->label); if (field->required) { win_printf(window, '-', 0, NULL, NO_DATE, 0, "", " (Required):"); } else { @@ -194,7 +194,7 @@ mucconfwin_form_help(ProfMucConfWin *confwin) if (confwin->form->instructions) { ProfWin *window = (ProfWin*) confwin; win_printf(window, '-', 0, NULL, 0, 0, "", "Supplied instructions:"); - win_printf(window, '-', 0, NULL, 0, 0, "", confwin->form->instructions); + win_printf(window, '-', 0, NULL, 0, 0, "", "%s", confwin->form->instructions); win_printf(window, '-', 0, NULL, 0, 0, "", ""); } } @@ -223,7 +223,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (g_strcmp0(field->var, "muc#roomconfig_roomsecret") == 0) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); } else { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "%s", value); } } } @@ -303,7 +303,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "%s", value); } } win_newline(window); @@ -320,7 +320,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", value); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", value); } } win_newline(window); diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 7bbf65e8..9b0341c2 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -182,7 +182,7 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) if (identity->category) { identity_str = g_string_append(identity_str, identity->category); } - win_printf(window, '!', 0, NULL, 0, 0, "", identity_str->str); + win_printf(window, '!', 0, NULL, 0, 0, "", "%s", identity_str->str); g_string_free(identity_str, TRUE); identities = g_slist_next(identities); } @@ -355,7 +355,7 @@ mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, g_string_append(line, message); } - win_printf(window, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", line->str); + win_printf(window, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", "%s", line->str); g_string_free(line, TRUE); plugins_on_room_history_message(mucwin->roomjid, nick, message, timestamp); @@ -371,10 +371,10 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co pos = GPOINTER_TO_INT(curr->data); char *before_str = g_strndup(message + last_pos, pos - last_pos); - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION, "", before_str); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION, "", "%s", before_str); g_free(before_str); char *nick_str = g_strndup(message + pos, strlen(nick)); - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION_TERM, "", nick_str); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION_TERM, "", "%s", nick_str); g_free(nick_str); last_pos = pos + strlen(nick); @@ -382,7 +382,7 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co curr = g_slist_next(curr); } if (last_pos < strlen(message)) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", &message[last_pos]); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", "%s", &message[last_pos]); } else { win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", ""); } @@ -442,7 +442,7 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge // no triggers found if (first_trigger_pos == -1) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER, "", message); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER, "", "%s", message); } else { if (first_trigger_pos > 0) { char message_section[strlen(message) + 1]; @@ -452,7 +452,7 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge i++; } message_section[i] = '\0'; - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER, "", message_section); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER, "", "%s", message_section); } char trigger_section[first_trigger_len + 1]; int i = 0; @@ -463,10 +463,10 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge trigger_section[i] = '\0'; if (first_trigger_pos + first_trigger_len < strlen(message)) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER_TERM, "", trigger_section); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER_TERM, "", "%s", trigger_section); _mucwin_print_triggers(window, &message[first_trigger_pos + first_trigger_len], triggers); } else { - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER_TERM, "", trigger_section); + win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER_TERM, "", "%s", trigger_section); } } } @@ -487,10 +487,10 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes win_printf(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMTRIGGER, nick, ""); _mucwin_print_triggers(window, message, triggers); } else { - win_printf(window, '-', 0, NULL, NO_ME, THEME_TEXT_THEM, nick, message); + win_printf(window, '-', 0, NULL, NO_ME, THEME_TEXT_THEM, nick, "%s", message); } } else { - win_printf(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, message); + win_printf(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, "%s", message); } } diff --git a/src/ui/privwin.c b/src/ui/privwin.c index fe98aa85..17a24138 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -93,7 +93,7 @@ privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message) { assert(privwin != NULL); - win_printf((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message); + win_printf((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", "%s", message); } void diff --git a/src/ui/window.c b/src/ui/window.c index 133a3990..7a0cc1b8 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -683,7 +683,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, "", occupant->nick); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", occupant->nick); win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); if (occupant->status) { @@ -705,9 +705,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, "", name); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", name); } else { - win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); + win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", barejid); } win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence); @@ -747,7 +747,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_printf(window, '!', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); + win_printf(window, '!', 0, NULL, NO_EOL, presence_colour, "", "%s", occupant->nick); win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); if (occupant->status) { @@ -773,19 +773,19 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa DiscoIdentity *identity = caps->identity; win_printf(window, '!', 0, NULL, NO_EOL, 0, "", " Identity: "); if (identity->name) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->name); if (identity->category || identity->type) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->type) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->type); if (identity->category) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->category) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->category); } win_newline(window); } @@ -830,7 +830,7 @@ win_show_info(ProfWin *window, PContact contact) theme_item_t presence_colour = theme_main_presence_attrs(presence); win_printf(window, '-', 0, NULL, 0, 0, "", ""); - win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); + 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); } @@ -897,19 +897,19 @@ win_show_info(ProfWin *window, PContact contact) DiscoIdentity *identity = caps->identity; win_printf(window, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); if (identity->name) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->name); if (identity->category || identity->type) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->type) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->type); if (identity->category) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->category) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->category); } win_newline(window); } @@ -1001,10 +1001,10 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp, } else if (enc_mode == PROF_MSG_PGP) { enc_char = prefs_get_pgp_char(); } - win_printf(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); + win_printf(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, "%s", message); break; case WIN_PRIVATE: - win_printf(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); + win_printf(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, "%s", message); break; default: assert(FALSE); @@ -1113,7 +1113,7 @@ win_update_entry_theme(ProfWin *window, const char *const id, theme_item_t theme void win_println(ProfWin *window, int pad, const char *const message) { - win_printf(window, '-', pad, NULL, 0, 0, "", message); + win_printf(window, '-', pad, NULL, 0, 0, "", "%s", message); } void @@ -1123,7 +1123,7 @@ win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) va_start(arg, message); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - win_printf(window, ch, 0, NULL, 0, 0, "", fmt_msg->str); + win_printf(window, ch, 0, NULL, 0, 0, "", "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); } diff --git a/src/ui/xmlwin.c b/src/ui/xmlwin.c index c8af2211..0172e9ad 100644 --- a/src/ui/xmlwin.c +++ b/src/ui/xmlwin.c @@ -46,11 +46,11 @@ xmlwin_show(ProfXMLWin *xmlwin, const char *const msg) ProfWin *window = (ProfWin*)xmlwin; if (g_str_has_prefix(msg, "SENT:")) { win_printf(window, '-', 0, NULL, 0, 0, "", "SENT:"); - win_printf(window, '-', 0, NULL, 0, THEME_ONLINE, "", &msg[6]); + win_printf(window, '-', 0, NULL, 0, THEME_ONLINE, "", "%s", &msg[6]); win_printf(window, '-', 0, NULL, 0, THEME_ONLINE, "", ""); } else if (g_str_has_prefix(msg, "RECV:")) { win_printf(window, '-', 0, NULL, 0, 0, "", "RECV:"); - win_printf(window, '-', 0, NULL, 0, THEME_AWAY, "", &msg[6]); + win_printf(window, '-', 0, NULL, 0, THEME_AWAY, "", "%s", &msg[6]); win_printf(window, '-', 0, NULL, 0, THEME_AWAY, "", ""); } } From 54cf1dbec43ccc3c300a04c26c8da54538f2da32 Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 14 Oct 2016 23:38:39 +0100 Subject: [PATCH 08/28] Add win_printf_line --- src/command/cmd_funcs.c | 6 ++-- src/config/theme.h | 2 ++ src/plugins/api.c | 2 +- src/ui/chatwin.c | 2 +- src/ui/console.c | 72 ++++++++++++++++++------------------- src/ui/core.c | 18 +++++----- src/ui/mucconfwin.c | 80 ++++++++++++++++++++--------------------- src/ui/mucwin.c | 18 +++++----- src/ui/privwin.c | 8 ++--- src/ui/window.c | 12 +++---- src/ui/window_list.c | 2 +- src/ui/xmlwin.c | 12 +++---- 12 files changed, 118 insertions(+), 116 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 7d4f0064..08d80466 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -3108,7 +3108,7 @@ cmd_status(ProfWin *window, const char *const command, gchar **args) if (occupant) { win_show_occupant(window, occupant); } else { - win_printf(window, '-', 0, NULL, 0, 0, "", "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(window, '-', 0, NULL, 0, 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(window, '-', 0, NULL, 0, THEME_ERROR, "", "Couldn't create tinyurl."); + win_printf_line(window, THEME_ERROR, "Couldn't create tinyurl."); return TRUE; } diff --git a/src/config/theme.h b/src/config/theme.h index c8e740b2..10b4b644 100644 --- a/src/config/theme.h +++ b/src/config/theme.h @@ -39,6 +39,8 @@ #include +#define THEME_DEFAULT 0 + typedef enum { THEME_TEXT, THEME_TEXT_ME, diff --git a/src/plugins/api.c b/src/plugins/api.c index 670f8551..6c27ef06 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(console, '-', 0, NULL, 0, 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 8fc06307..9443155b 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((ProfWin*)chatwin, '-', 0, NULL, 0, 0, "", "%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 03e9f439..ddee3f9a 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Synopsis"); + win_printf_line(console, THEME_WHITE_BOLD, "Synopsis"); ui_show_lines(console, help->synopsis); cons_show(""); - win_printf(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 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, 0, "", "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]); } @@ -156,7 +156,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) if (g_strv_length((gchar**)help->examples) > 0) { cons_show(""); - win_printf(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Examples"); + 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 0, "", "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(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %sdev", PACKAGE_VERSION); + win_printf_line(console, THEME_DEFAULT, "Welcome to Profanity, version %sdev", PACKAGE_VERSION); #endif } else { - win_printf(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %s", PACKAGE_VERSION); + win_printf_line(console, THEME_DEFAULT, "Welcome to Profanity, version %s", PACKAGE_VERSION); } } - win_printf(console, '-', 0, NULL, 0, 0, "", "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(console, '-', 0, NULL, 0, 0, "", "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(console, '-', 0, NULL, 0, 0, "", " %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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, 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(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ___ _ "); - win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", " / __) (_)_ "); - win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ____ ____ ___ | |__ ____ ____ _| |_ _ _ "); - win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |"); - win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| | | | | | |_| | | ( ( | | | | | | |_| |_| |"); - win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |"); - win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", "|_| (____/ "); - win_printf(console, '-', 0, NULL, 0, THEME_SPLASH, "", ""); + win_printf_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(console, '-', 0, NULL, 0, 0, "", "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(console, '-', 0, NULL, 0, 0, "", "Version %sdev", PACKAGE_VERSION); + win_printf_line(console, THEME_DEFAULT, "Version %sdev", PACKAGE_VERSION); #endif } else { - win_printf(console, '-', 0, NULL, 0, 0, "", "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 c1bba8ac..023af8ef 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(window, '-', 0, NULL, 0, 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(current, '-', 0, NULL, 0, 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(window, '-', 0, NULL, 0, 0, "", "*%s %s", barejid, message); + win_printf_line(window, THEME_DEFAULT, "*%s %s", barejid, message); } void @@ -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(window, '-', 0, NULL, 0, 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(window, '-', 0, NULL, 0, 0, "", "%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(window, '-', 0, NULL, 0, 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(window, '-', 0, NULL, 0, 0, "", "Name : %s", name); + win_printf_line(window, THEME_DEFAULT, "Name : %s", name); } if (version) { - win_printf(window, '-', 0, NULL, 0, 0, "", "Version : %s", version); + win_printf_line(window, THEME_DEFAULT, "Version : %s", version); } if (os) { - win_printf(window, '-', 0, NULL, 0, 0, "", "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 954e4e0e..64aede48 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, 0, "", "Form title: "); win_printf(window, '-', 0, NULL, NO_DATE, 0, "", "%s", confwin->form->title); } else { - win_printf(window, '-', 0, NULL, 0, 0, "", "Configuration for room %s.", confwin->roomjid); + win_printf_line(window, THEME_DEFAULT, "Configuration for room %s.", confwin->roomjid); } - win_printf(window, '-', 0, NULL, 0, 0, "", ""); + 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(window, '-', 0, NULL, 0, 0, "", "%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(window, '-', 0, NULL, 0, 0, "", ""); - win_printf(window, '-', 0, NULL, 0, 0, "", "Use '/form submit' to save changes."); - win_printf(window, '-', 0, NULL, 0, 0, "", "Use '/form cancel' to cancel changes."); - win_printf(window, '-', 0, NULL, 0, 0, "", "See '/form help' for more information."); - win_printf(window, '-', 0, NULL, 0, 0, "", ""); + 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, 0, "", ":"); } if (field->description) { - win_printf(window, '-', 0, NULL, 0, 0, "", " Description : %s", field->description); + win_printf_line(window, THEME_DEFAULT, " Description : %s", field->description); } - win_printf(window, '-', 0, NULL, 0, 0, "", " 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(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); - win_printf(window, '-', 0, NULL, 0, 0, "", " 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(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); - win_printf(window, '-', 0, NULL, 0, 0, "", " 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(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); - win_printf(window, '-', 0, NULL, 0, 0, "", " 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(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); - win_printf(window, '-', 0, NULL, 0, 0, "", " 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(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); - win_printf(window, '-', 0, NULL, 0, 0, "", " 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(window, '-', 0, NULL, 0, 0, "", " %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(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); - win_printf(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); - win_printf(window, '-', 0, NULL, 0, 0, "", " 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(window, '-', 0, NULL, 0, 0, "", " %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(window, '-', 0, NULL, 0, 0, "", " Set : /%s ", tag); - win_printf(window, '-', 0, NULL, 0, 0, "", " 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(window, '-', 0, NULL, 0, 0, "", " Add : /%s add ", tag); - win_printf(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove ", tag); - win_printf(window, '-', 0, NULL, 0, 0, "", " 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(window, '-', 0, NULL, 0, 0, "", "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(window, '-', 0, NULL, 0, 0, "", "Supplied instructions:"); - win_printf(window, '-', 0, NULL, 0, 0, "", "%s", confwin->form->instructions); - win_printf(window, '-', 0, NULL, 0, 0, "", ""); + 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(window, '-', 0, NULL, 0, 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(window, '-', 0, NULL, 0, THEME_ONLINE, "", " [%s] %s", option->value, option->label); + win_printf_line(window, THEME_ONLINE, " [%s] %s", option->value, option->label); } else { - win_printf(window, '-', 0, NULL, 0, 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(window, '-', 0, NULL, 0, THEME_ONLINE, "", " [%s] %s", option->value, option->label); + win_printf_line(window, THEME_ONLINE, " [%s] %s", option->value, option->label); } else { - win_printf(window, '-', 0, NULL, 0, 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(window, '-', 0, NULL, 0, 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 9b0341c2..64f859a1 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, 0, "", "Room info request failed: %s", error); - win_printf(window, '-', 0, NULL, 0, 0, "", ""); + 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, 0, "", " %s", features->data); features = g_slist_next(features); } - win_printf(window, '-', 0, NULL, 0, 0, "", ""); + win_printf_line(window, THEME_DEFAULT, ""); } } @@ -506,12 +506,12 @@ mucwin_requires_config(ProfMucWin *mucwin) ui_index = 0; } - win_printf(window, '-', 0, NULL, 0, 0, "", ""); + 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(window, '-', 0, NULL, 0, 0, "", ""); + 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(window, '-', 0, NULL, 0, 0, "", ""); + 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(window, '-', 0, NULL, 0, 0, "", ""); + win_printf_line(window, THEME_DEFAULT, ""); } } @@ -741,7 +741,7 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) default: break; } - win_printf(window, '-', 0, NULL, 0, 0, "", ""); + 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(window, '-', 0, NULL, 0, 0, "", ""); + win_printf_line(window, THEME_DEFAULT, ""); } } @@ -807,7 +807,7 @@ mucwin_info(ProfMucWin *mucwin) win_printf(window, '!', 0, NULL, 0, 0, "", "Room: %s", mucwin->roomjid); win_printf(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation); win_printf(window, '!', 0, NULL, 0, 0, "", "Role: %s", role); - win_printf(window, '-', 0, NULL, 0, 0, "", ""); + win_printf_line(window, THEME_DEFAULT, ""); } void diff --git a/src/ui/privwin.c b/src/ui/privwin.c index 17a24138..ca20b84b 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((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "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((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "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((ProfWin*)privwin, '-', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %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((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ONLINE, NULL, "-- %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/window.c b/src/ui/window.c index 7a0cc1b8..325e72e2 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(window, '-', 0, NULL, 0, 0, "", ""); + 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(window, '-', 0, NULL, 0, 0, "", ""); + 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, 0, "", ":"); if (sub) { - win_printf(window, '-', 0, NULL, 0, 0, "", "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(window, '-', 0, NULL, 0, 0, "", "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(window, '-', 0, NULL, 0, 0, "", "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(window, '-', 0, NULL, 0, 0, "", "Resources:"); + win_printf_line(window, THEME_DEFAULT, "Resources:"); // sort in order of availability GList *curr = resources; diff --git a/src/ui/window_list.c b/src/ui/window_list.c index c61f9635..ef0f30b1 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(window, '-', 0, NULL, 0, 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 0172e9ad..b24ae67b 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(window, '-', 0, NULL, 0, 0, "", "SENT:"); - win_printf(window, '-', 0, NULL, 0, THEME_ONLINE, "", "%s", &msg[6]); - win_printf(window, '-', 0, NULL, 0, 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(window, '-', 0, NULL, 0, 0, "", "RECV:"); - win_printf(window, '-', 0, NULL, 0, THEME_AWAY, "", "%s", &msg[6]); - win_printf(window, '-', 0, NULL, 0, THEME_AWAY, "", ""); + win_printf_line(window, THEME_DEFAULT, "RECV:"); + win_printf_line(window, THEME_AWAY, "%s", &msg[6]); + win_printf_line(window, THEME_AWAY, ""); } } From 2f888979c511c9260062dee71ba1060a23aa52d0 Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 14 Oct 2016 23:56:51 +0100 Subject: [PATCH 09/28] Use THEME_DEFAULT --- src/command/cmd_funcs.c | 8 ++-- src/plugins/api.c | 2 +- src/ui/chatwin.c | 2 +- src/ui/console.c | 72 +++++++++++++++++------------------ src/ui/mucconfwin.c | 18 ++++----- src/ui/mucwin.c | 84 ++++++++++++++++++++--------------------- src/ui/window.c | 54 +++++++++++++------------- 7 files changed, 120 insertions(+), 120 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 08d80466..15d2e0e8 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -3881,7 +3881,7 @@ cmd_kick(ProfWin *window, const char *const command, gchar **args) char *reason = args[1]; iq_room_kick_occupant(mucwin->roomjid, nick, reason); } else { - win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Occupant does not exist: %s", nick); + win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, THEME_DEFAULT, "", "Occupant does not exist: %s", nick); } } else { cons_bad_cmd_usage(command); @@ -3940,7 +3940,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) char *subject = muc_subject(mucwin->roomjid); if (subject) { win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: "); - win_printf(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", subject); } else { win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room has no subject"); } @@ -4050,7 +4050,7 @@ cmd_affiliation(ProfWin *window, const char *const command, gchar **args) iq_room_affiliation_list(mucwin->roomjid, "member"); iq_room_affiliation_list(mucwin->roomjid, "outcast"); } else if (g_strcmp0(affiliation, "none") == 0) { - win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no affiliation."); + win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, THEME_DEFAULT, "", "Cannot list users with no affiliation."); } else { iq_room_affiliation_list(mucwin->roomjid, affiliation); } @@ -4118,7 +4118,7 @@ cmd_role(ProfWin *window, const char *const command, gchar **args) iq_room_role_list(mucwin->roomjid, "participant"); iq_room_role_list(mucwin->roomjid, "visitor"); } else if (g_strcmp0(role, "none") == 0) { - win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no role."); + win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, THEME_DEFAULT, "", "Cannot list users with no role."); } else { iq_room_role_list(mucwin->roomjid, role); } diff --git a/src/plugins/api.c b/src/plugins/api.c index 6c27ef06..be5639dc 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -368,7 +368,7 @@ api_win_show(const char *tag, const char *line) } ProfWin *window = (ProfWin*)pluginwin; - win_printf(window, '!', 0, NULL, 0, 0, "", "%s", line); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "%s", line); return 1; } diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 9443155b..f8726f1e 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -401,7 +401,7 @@ _chatwin_history(ProfChatWin *chatwin, const char *const contact) char mm[3]; memcpy(mm, &line[3], 2); mm[2] = '\0'; int imm = atoi(mm); char ss[3]; memcpy(ss, &line[6], 2); ss[2] = '\0'; int iss = atoi(ss); GDateTime *timestamp = g_date_time_new_local(2000, 1, 1, ihh, imm, iss); - win_printf((ProfWin*)chatwin, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", "%s", curr->data+11); + win_printf((ProfWin*)chatwin, '-', 0, timestamp, NO_COLOUR_DATE, THEME_DEFAULT, "", "%s", curr->data+11); g_date_time_unref(timestamp); // header } else { diff --git a/src/ui/console.c b/src/ui/console.c index ddee3f9a..c6894e3d 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -67,14 +67,14 @@ void cons_show_time(void) { ProfWin *console = wins_get_console(); - win_printf(console, '-', 0, NULL, NO_EOL, 0, "", ""); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", ""); } void cons_show_word(const char *const word) { ProfWin *console = wins_get_console(); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", word); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", word); } void @@ -150,7 +150,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) cons_show(""); win_printf_line(console, THEME_WHITE_BOLD, "Arguments"); for (i = 0; help->args[i][0] != NULL; i++) { - win_printf(console, '-', maxlen + 3, NULL, 0, 0, "", "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]); + win_printf(console, '-', maxlen + 3, NULL, 0, THEME_DEFAULT, "", "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]); } } @@ -475,16 +475,16 @@ void cons_show_login_success(ProfAccount *account, gboolean secured) { ProfWin *console = wins_get_console(); - win_printf(console, '-', 0, NULL, NO_EOL, 0, "", "%s logged in successfully, ", account->jid); + win_printf(console, '-', 0, NULL, NO_EOL, 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); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)", + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " (priority %d)", accounts_get_priority_for_presence_type(account->name, presence)); - win_printf(console, '-', 0, NULL, NO_DATE, 0, "", "."); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", "."); if (!secured) { cons_show_error("TLS connection not established"); } @@ -555,26 +555,26 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); win_printf(console, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", fulljid); - win_printf(console, '-', 0, NULL, NO_DATE, 0, "", ":"); + 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, 0, "", "Identity: "); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", "Identity: "); if (identity->name) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->name); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); if (identity->category || identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); } } if (identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->type); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->type); if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); } } if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->category); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->category); } win_newline(console); } @@ -582,19 +582,19 @@ 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, 0, "", "Software: %s", software_version->software); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", "Software: %s", software_version->software); } if (software_version->software_version) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(console); } if (software_version->os) { - win_printf(console, '-', 0, NULL, NO_EOL, 0, "", "OS: %s", software_version->os); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", "OS: %s", software_version->os); } if (software_version->os_version) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(console); @@ -667,9 +667,9 @@ 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, 0, "", " %s", room->jid); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " %s", room->jid); if (room->name) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", room->name); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", (%s)", room->name); } win_newline(console); rooms = g_slist_next(rooms); @@ -784,11 +784,11 @@ 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, 0, "", " %s", item->jid); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " %s", item->jid); if (item->name) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", item->name); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", (%s)", item->name); } - win_printf(console, '-', 0, NULL, NO_DATE, 0, "", ""); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ""); items = g_slist_next(items); } } else { @@ -1005,7 +1005,7 @@ cons_show_account(ProfAccount *account) if (resource->status) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); } - win_printf(console, '-', 0, NULL, NO_DATE, 0, "", ""); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ""); Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name); EntityCapabilities *caps = caps_lookup(jidp->fulljid); jid_destroy(jidp); @@ -1014,21 +1014,21 @@ cons_show_account(ProfAccount *account) // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_printf(console, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " Identity: "); if (identity->name) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->name); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); if (identity->category || identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); } } if (identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->type); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->type); if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); } } if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->category); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->category); } win_newline(console); } @@ -1036,19 +1036,19 @@ 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, 0, "", " Software: %s", software_version->software); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " Software: %s", software_version->software); } if (software_version->software_version) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(console); } if (software_version->os) { - win_printf(console, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); + win_printf(console, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " OS: %s", software_version->os); } if (software_version->os_version) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(console); @@ -2397,7 +2397,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) g_string_free(title, TRUE); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " - "); + win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " - "); GString *sub = g_string_new(""); sub = g_string_append(sub, p_contact_subscription(contact)); if (p_contact_pending_out(contact)) { @@ -2431,10 +2431,10 @@ _show_roster_contacts(GSList *list, gboolean show_groups) } groups = g_slist_next(groups); } - win_printf(console, '-', 0, NULL, NO_DATE, 0, "", "%s", groups_str->str); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", groups_str->str); g_string_free(groups_str, TRUE); } else { - win_printf(console, '-', 0, NULL, NO_DATE, 0, "", " "); + win_printf(console, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", " "); } } diff --git a/src/ui/mucconfwin.c b/src/ui/mucconfwin.c index 64aede48..2c9aaf7a 100644 --- a/src/ui/mucconfwin.c +++ b/src/ui/mucconfwin.c @@ -47,8 +47,8 @@ mucconfwin_show_form(ProfMucConfWin *confwin) { ProfWin *window = (ProfWin*) confwin; if (confwin->form->title) { - win_printf(window, '-', 0, NULL, NO_EOL, 0, "", "Form title: "); - win_printf(window, '-', 0, NULL, NO_DATE, 0, "", "%s", confwin->form->title); + 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); } @@ -111,11 +111,11 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) ProfWin *window = (ProfWin*) confwin; FormField *field = form_get_field_by_tag(confwin->form, tag); if (field) { - win_printf(window, '-', 0, NULL, NO_EOL, 0, "", "%s", field->label); + win_printf(window, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", "%s", field->label); if (field->required) { - win_printf(window, '-', 0, NULL, NO_DATE, 0, "", " (Required):"); + win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", " (Required):"); } else { - win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ":"); + win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ":"); } if (field->description) { win_printf_line(window, THEME_DEFAULT, " Description : %s", field->description); @@ -203,11 +203,11 @@ static void _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) { win_printf(window, '-', 0, NULL, NO_EOL, THEME_AWAY, "", "[%s] ", tag); - win_printf(window, '-', 0, NULL, NO_EOL | NO_DATE, 0, "", "%s", field->label); + 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, 0, "", " (required): "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " (required): "); } else { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ": "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ": "); } GSList *values = field->values; @@ -320,7 +320,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", value); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", value); } } win_newline(window); diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 64f859a1..0b391189 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -153,7 +153,7 @@ mucwin_room_info_error(ProfMucWin *mucwin, const char *const error) assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf(window, '!', 0, NULL, 0, 0, "", "Room info request failed: %s", error); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Room info request failed: %s", error); win_printf_line(window, THEME_DEFAULT, ""); } @@ -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(window, '!', 0, NULL, 0, 0, "", "Identities:"); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Identities:"); } while (identities) { DiscoIdentity *identity = identities->data; // anme trpe, cat @@ -182,16 +182,16 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) if (identity->category) { identity_str = g_string_append(identity_str, identity->category); } - win_printf(window, '!', 0, NULL, 0, 0, "", "%s", identity_str->str); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "%s", identity_str->str); g_string_free(identity_str, TRUE); identities = g_slist_next(identities); } if (features) { - win_printf(window, '!', 0, NULL, 0, 0, "", "Features:"); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Features:"); } while (features) { - win_printf(window, '!', 0, NULL, 0, 0, "", " %s", features->data); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s", features->data); features = g_slist_next(features); } win_printf_line(window, THEME_DEFAULT, ""); @@ -226,7 +226,7 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick); if (roster->next) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", "); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", "); } roster = g_list_next(roster); @@ -534,10 +534,10 @@ 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_printf(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", subject); } else { win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: "); - win_printf(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", subject); } } else { if (nick) { @@ -575,7 +575,7 @@ mucwin_broadcast(ProfMucWin *mucwin, const char *const message) int num = wins_get_num(window); win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room message: "); - win_printf(window, '!', 0, NULL, NO_DATE, 0, "", "%s", message); + win_printf(window, '!', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", message); // currently in groupchat window if (wins_is_current(window)) { @@ -604,17 +604,17 @@ mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation ProfWin *window = (ProfWin*)mucwin; if (jids) { - win_printf(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Affiliation: %s", affiliation); GSList *curr_jid = jids; while (curr_jid) { const char *jid = curr_jid->data; - win_printf(window, '!', 0, NULL, 0, 0, "", " %s", jid); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s", jid); curr_jid = g_slist_next(curr_jid); } - win_printf(window, '!', 0, NULL, 0, 0, "", ""); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", ""); } else { - win_printf(window, '!', 0, NULL, 0, 0, "", "No users found with affiliation: %s", affiliation); - win_printf(window, '!', 0, NULL, 0, 0, "", ""); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No users found with affiliation: %s", affiliation); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", ""); } } @@ -629,16 +629,16 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) if (!occupants) { switch (affiliation) { case MUC_AFFILIATION_OWNER: - win_printf(window, '!', 0, NULL, 0, 0, "", "No owners found."); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No owners found."); break; case MUC_AFFILIATION_ADMIN: - win_printf(window, '!', 0, NULL, 0, 0, "", "No admins found."); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No admins found."); break; case MUC_AFFILIATION_MEMBER: - win_printf(window, '!', 0, NULL, 0, 0, "", "No members found."); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No members found."); break; case MUC_AFFILIATION_OUTCAST: - win_printf(window, '!', 0, NULL, 0, 0, "", "No outcasts found."); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No outcasts found."); break; default: break; @@ -647,16 +647,16 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) } else { switch (affiliation) { case MUC_AFFILIATION_OWNER: - win_printf(window, '!', 0, NULL, 0, 0, "", "Owners:"); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Owners:"); break; case MUC_AFFILIATION_ADMIN: - win_printf(window, '!', 0, NULL, 0, 0, "", "Admins:"); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Admins:"); break; case MUC_AFFILIATION_MEMBER: - win_printf(window, '!', 0, NULL, 0, 0, "", "Members:"); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Members:"); break; case MUC_AFFILIATION_OUTCAST: - win_printf(window, '!', 0, NULL, 0, 0, "", "Outcasts:"); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Outcasts:"); break; default: break; @@ -667,9 +667,9 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) Occupant *occupant = curr_occupant->data; if (occupant->affiliation == affiliation) { if (occupant->jid) { - win_printf(window, '!', 0, NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s (%s)", occupant->nick, occupant->jid); } else { - win_printf(window, '!', 0, NULL, 0, 0, "", " %s", occupant->nick); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s", occupant->nick); } } @@ -696,26 +696,26 @@ mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nick ProfWin *window = (ProfWin*)mucwin; if (nicks) { - win_printf(window, '!', 0, NULL, 0, 0, "", "Role: %s", role); + win_printf(window, '!', 0, NULL, 0, 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(window, '!', 0, NULL, 0, 0, "", " %s (%s)", nick, occupant->jid); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s (%s)", nick, occupant->jid); } else { - win_printf(window, '!', 0, NULL, 0, 0, "", " %s", nick); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s", nick); } } else { - win_printf(window, '!', 0, NULL, 0, 0, "", " %s", nick); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s", nick); } curr_nick = g_slist_next(curr_nick); } - win_printf(window, '!', 0, NULL, 0, 0, "", ""); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", ""); } else { - win_printf(window, '!', 0, NULL, 0, 0, "", "No occupants found with role: %s", role); - win_printf(window, '!', 0, NULL, 0, 0, "", ""); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No occupants found with role: %s", role); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", ""); } } @@ -730,13 +730,13 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) if (!occupants) { switch (role) { case MUC_ROLE_MODERATOR: - win_printf(window, '!', 0, NULL, 0, 0, "", "No moderators found."); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No moderators found."); break; case MUC_ROLE_PARTICIPANT: - win_printf(window, '!', 0, NULL, 0, 0, "", "No participants found."); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No participants found."); break; case MUC_ROLE_VISITOR: - win_printf(window, '!', 0, NULL, 0, 0, "", "No visitors found."); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No visitors found."); break; default: break; @@ -745,13 +745,13 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) } else { switch (role) { case MUC_ROLE_MODERATOR: - win_printf(window, '!', 0, NULL, 0, 0, "", "Moderators:"); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Moderators:"); break; case MUC_ROLE_PARTICIPANT: - win_printf(window, '!', 0, NULL, 0, 0, "", "Participants:"); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Participants:"); break; case MUC_ROLE_VISITOR: - win_printf(window, '!', 0, NULL, 0, 0, "", "Visitors:"); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Visitors:"); break; default: break; @@ -762,9 +762,9 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) Occupant *occupant = curr_occupant->data; if (occupant->role == role) { if (occupant->jid) { - win_printf(window, '!', 0, NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s (%s)", occupant->nick, occupant->jid); } else { - win_printf(window, '!', 0, NULL, 0, 0, "", " %s", occupant->nick); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s", occupant->nick); } } @@ -804,9 +804,9 @@ mucwin_info(ProfMucWin *mucwin) char *affiliation = muc_affiliation_str(mucwin->roomjid); ProfWin *window = (ProfWin*) mucwin; - win_printf(window, '!', 0, NULL, 0, 0, "", "Room: %s", mucwin->roomjid); - win_printf(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation); - win_printf(window, '!', 0, NULL, 0, 0, "", "Role: %s", role); + win_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, ""); } diff --git a/src/ui/window.c b/src/ui/window.c index 325e72e2..610c9480 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -757,11 +757,11 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_newline(window); if (occupant->jid) { - win_printf(window, '!', 0, NULL, 0, 0, "", " Jid: %s", occupant->jid); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " Jid: %s", occupant->jid); } - win_printf(window, '!', 0, NULL, 0, 0, "", " Affiliation: %s", occupant_affiliation); - win_printf(window, '!', 0, NULL, 0, 0, "", " Role: %s", occupant_role); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " Affiliation: %s", occupant_affiliation); + win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " Role: %s", occupant_role); Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick); EntityCapabilities *caps = caps_lookup(jidp->fulljid); @@ -771,21 +771,21 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_printf(window, '!', 0, NULL, NO_EOL, 0, "", " Identity: "); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_DEFAULT, "", " Identity: "); if (identity->name) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->name); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); if (identity->category || identity->type) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); } } if (identity->type) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->type); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->type); if (identity->category) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); } } if (identity->category) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->category); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->category); } win_newline(window); } @@ -793,19 +793,19 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { - win_printf(window, '!', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_DEFAULT, "", " Software: %s", software_version->software); } if (software_version->software_version) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(window); } if (software_version->os) { - win_printf(window, '!', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); + win_printf(window, '!', 0, NULL, NO_EOL, THEME_DEFAULT, "", " OS: %s", software_version->os); } if (software_version->os_version) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); + win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(window); @@ -834,7 +834,7 @@ win_show_info(ProfWin *window, PContact contact) if (name) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name); } - win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ":"); + win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ":"); if (sub) { win_printf_line(window, THEME_DEFAULT, "Subscription: %s", sub); @@ -895,21 +895,21 @@ win_show_info(ProfWin *window, PContact contact) // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; - win_printf(window, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); + win_printf(window, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " Identity: "); if (identity->name) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->name); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); if (identity->category || identity->type) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); } } if (identity->type) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->type); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->type); if (identity->category) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); } } if (identity->category) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", "%s", identity->category); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->category); } win_newline(window); } @@ -917,19 +917,19 @@ win_show_info(ProfWin *window, PContact contact) if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { - win_printf(window, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); + win_printf(window, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " Software: %s", software_version->software); } if (software_version->software_version) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(window); } if (software_version->os) { - win_printf(window, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); + win_printf(window, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " OS: %s", software_version->os); } if (software_version->os_version) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); + win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(window); @@ -1113,7 +1113,7 @@ win_update_entry_theme(ProfWin *window, const char *const id, theme_item_t theme void win_println(ProfWin *window, int pad, const char *const message) { - win_printf(window, '-', pad, NULL, 0, 0, "", "%s", message); + win_printf(window, '-', pad, NULL, 0, THEME_DEFAULT, "", "%s", message); } void @@ -1123,7 +1123,7 @@ win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) va_start(arg, message); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - win_printf(window, ch, 0, NULL, 0, 0, "", "%s", fmt_msg->str); + win_printf(window, ch, 0, NULL, 0, THEME_DEFAULT, "", "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); } @@ -1131,7 +1131,7 @@ win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) void win_newline(ProfWin *window) { - win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ""); + win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ""); } static void From 33b4b79f2e055ad5831bc428a3c98eaee5530b9e Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 00:04:57 +0100 Subject: [PATCH 10/28] 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) { From 8cf9e0ccccb616c3fec957b5a21a17e34172fced Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 00:39:57 +0100 Subject: [PATCH 11/28] Use win_printf_line where appropriate --- src/command/cmd_funcs.c | 12 ++--- src/plugins/api.c | 4 +- src/ui/chatwin.c | 12 ++--- src/ui/core.c | 46 ++++++++--------- src/ui/mucwin.c | 112 ++++++++++++++++++++-------------------- src/ui/privwin.c | 14 ++--- src/ui/window.c | 8 +-- src/ui/window_list.c | 2 +- 8 files changed, 105 insertions(+), 105 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index cd0328de..8aa1fceb 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -3881,7 +3881,7 @@ cmd_kick(ProfWin *window, const char *const command, gchar **args) char *reason = args[1]; iq_room_kick_occupant(mucwin->roomjid, nick, reason); } else { - win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, THEME_DEFAULT, "", "Occupant does not exist: %s", nick); + win_printf_line(window, THEME_DEFAULT, '!', "Occupant does not exist: %s", nick); } } else { cons_bad_cmd_usage(command); @@ -3942,7 +3942,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: "); win_printf(window, '!', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", subject); } else { - win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room has no subject"); + win_printf_line(window, THEME_ROOMINFO, '!', "Room has no subject"); } return TRUE; } @@ -4050,7 +4050,7 @@ cmd_affiliation(ProfWin *window, const char *const command, gchar **args) iq_room_affiliation_list(mucwin->roomjid, "member"); iq_room_affiliation_list(mucwin->roomjid, "outcast"); } else if (g_strcmp0(affiliation, "none") == 0) { - win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, THEME_DEFAULT, "", "Cannot list users with no affiliation."); + win_printf_line(window, THEME_DEFAULT, '!', "Cannot list users with no affiliation."); } else { iq_room_affiliation_list(mucwin->roomjid, affiliation); } @@ -4118,7 +4118,7 @@ cmd_role(ProfWin *window, const char *const command, gchar **args) iq_room_role_list(mucwin->roomjid, "participant"); iq_room_role_list(mucwin->roomjid, "visitor"); } else if (g_strcmp0(role, "none") == 0) { - win_printf((ProfWin*) mucwin, '!', 0, NULL, 0, THEME_DEFAULT, "", "Cannot list users with no role."); + win_printf_line(window, THEME_DEFAULT, '!', "Cannot list users with no role."); } else { iq_room_role_list(mucwin->roomjid, role); } @@ -4180,12 +4180,12 @@ cmd_room(ProfWin *window, const char *const command, gchar **args) if (g_strcmp0(args[0], "accept") == 0) { gboolean requires_config = muc_requires_config(mucwin->roomjid); if (!requires_config) { - win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Current room does not require configuration."); + win_printf_line(window, THEME_ROOMINFO, '!', "Current room does not require configuration."); return TRUE; } else { iq_confirm_instant_room(mucwin->roomjid); muc_set_requires_config(mucwin->roomjid, FALSE); - win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room unlocked."); + win_printf_line(window, THEME_ROOMINFO, '!', "Room unlocked."); return TRUE; } } diff --git a/src/plugins/api.c b/src/plugins/api.c index 4073b5f5..606a4811 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -368,7 +368,7 @@ api_win_show(const char *tag, const char *line) } ProfWin *window = (ProfWin*)pluginwin; - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "%s", line); + win_printf_line(window, THEME_DEFAULT, '!', "%s", line); return 1; } @@ -393,7 +393,7 @@ api_win_show_themed(const char *tag, const char *const group, const char *const theme_item_t themeitem = plugin_themes_get(group, key, def); ProfWin *window = (ProfWin*)pluginwin; - win_printf(window, '!', 0, NULL, 0, themeitem, "", "%s", line); + win_printf_line(window, themeitem, '!', "%s", line); return 1; } diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 550ba384..05a259f7 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(window, '!', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "OTR session started (trusted)."); + win_printf_line(window, THEME_OTR_STARTED_TRUSTED, '!', "OTR session started (trusted)."); } else { - win_printf(window, '!', 0, NULL, 0, THEME_OTR_STARTED_UNTRUSTED, "", "OTR session started (untrusted)."); + win_printf_line(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(window, '!', 0, NULL, 0, THEME_OTR_ENDED, "", "OTR session ended."); + win_printf_line(window, THEME_OTR_ENDED, '!', "OTR session ended."); if (wins_is_current(window)) { title_bar_switch(); } @@ -188,7 +188,7 @@ chatwin_otr_trust(ProfChatWin *chatwin) chatwin->otr_is_trusted = TRUE; ProfWin *window = (ProfWin*)chatwin; - win_printf(window, '!', 0, NULL, 0, THEME_OTR_TRUSTED, "", "OTR session trusted."); + win_printf_line(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(window, '!', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted."); + win_printf_line(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((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_GONE, "", "<- %s has left the conversation.", display_usr); + win_printf_line((ProfWin*)chatwin, THEME_GONE, '!', "<- %s has left the conversation.", display_usr); } void diff --git a/src/ui/core.c b/src/ui/core.c index 859b67f6..42881d30 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((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", "Error from %s: %s", recipient, err_msg); + win_printf_line((ProfWin*)chatwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); return; } ProfMucWin *mucwin = wins_get_muc(recipient); if (mucwin) { - win_printf((ProfWin*)mucwin, '!', 0, NULL, 0, THEME_ERROR, "", "Error from %s: %s", recipient, err_msg); + win_printf_line((ProfWin*)mucwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg); return; } ProfPrivateWin *privatewin = wins_get_private(recipient); if (privatewin) { - win_printf((ProfWin*)privatewin, '!', 0, NULL, 0, THEME_ERROR, "", "Error from %s: %s", recipient, err_msg); + win_printf_line((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((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", "%s", message); + win_printf_line((ProfWin*)chatwin, THEME_ERROR, '!', "%s", message); } else { cons_show_error("%s - %s", barejid, message); } @@ -752,7 +752,7 @@ ui_current_print_formatted_line(const char show_char, int attrs, const char *con va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - win_printf(current, show_char, 0, NULL, 0, attrs, "", "%s", fmt_msg->str); + win_printf_line(current, attrs, show_char, "%s", fmt_msg->str); va_end(arg); g_string_free(fmt_msg, TRUE); } @@ -823,7 +823,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(console, '!', 0, NULL, 0, THEME_TYPING, "", "-> Autojoined %s as %s (%d).", roomjid, nick, num); + win_printf_line(console, THEME_TYPING, '!', "-> Autojoined %s as %s (%d).", roomjid, nick, num); } GList *privwins = wins_get_private_chats(roomjid); @@ -898,16 +898,16 @@ ui_room_destroyed(const char *const roomjid, const char *const reason, const cha ProfWin *console = wins_get_console(); if (reason) { - win_printf(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- Room destroyed: %s, reason: %s", roomjid, reason); + win_printf_line(console, THEME_TYPING, '!', "<- Room destroyed: %s, reason: %s", roomjid, reason); } else { - win_printf(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- Room destroyed: %s", roomjid); + win_printf_line(console, THEME_TYPING, '!', "<- Room destroyed: %s", roomjid); } if (new_jid) { if (password) { - win_printf(console, '!', 0, NULL, 0, THEME_TYPING, "", "Replacement room: %s, password: %s", new_jid, password); + win_printf_line(console, THEME_TYPING, '!', "Replacement room: %s, password: %s", new_jid, password); } else { - win_printf(console, '!', 0, NULL, 0, THEME_TYPING, "", "Replacement room: %s", new_jid); + win_printf_line(console, THEME_TYPING, '!', "Replacement room: %s", new_jid); } } } @@ -944,7 +944,7 @@ ui_room_kicked(const char *const roomjid, const char *const actor, const char *c } ProfWin *console = wins_get_console(); - win_printf(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- %s", message->str); + win_printf_line(console, THEME_TYPING, '!', "<- %s", message->str); g_string_free(message, TRUE); } @@ -980,7 +980,7 @@ ui_room_banned(const char *const roomjid, const char *const actor, const char *c } ProfWin *console = wins_get_console(); - win_printf(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- %s", message->str); + win_printf_line(console, THEME_TYPING, '!', "<- %s", message->str); g_string_free(message, TRUE); } @@ -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, THEME_DEFAULT, "", "Incorrect passphrase"); + win_printf_line(current, THEME_DEFAULT, '!', "Incorrect passphrase"); } if (hint) { - win_printf(current, '!', 0, NULL, 0, THEME_DEFAULT, "", "Enter PGP key passphrase for %s", hint); + win_printf_line(current, THEME_DEFAULT, '!', "Enter PGP key passphrase for %s", hint); } else { - win_printf(current, '!', 0, NULL, 0, THEME_DEFAULT, "", "Enter PGP key passphrase"); + win_printf_line(current, THEME_DEFAULT, '!', "Enter PGP key passphrase"); } ui_update(); @@ -1182,7 +1182,7 @@ ui_handle_room_config_submit_result(const char *const roomjid) if (muc_window) { ui_focus_win((ProfWin*)muc_window); - win_printf(muc_window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room configuration successful"); + win_printf_line(muc_window, THEME_ROOMINFO, '!', "Room configuration successful"); } else { ProfWin *console = wins_get_console(); ui_focus_win(console); @@ -1209,25 +1209,25 @@ ui_handle_room_config_submit_result_error(const char *const roomjid, const char if (form_window) { if (message) { - win_printf(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message); + win_printf_line(form_window, THEME_ERROR, '!', "Configuration error: %s", message); } else { - win_printf(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); + win_printf_line(form_window, THEME_ERROR, '!', "Configuration error"); } } else if (muc_window) { if (message) { - win_printf(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message); + win_printf_line(muc_window, THEME_ERROR, '!', "Configuration error: %s", message); } else { - win_printf(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); + win_printf_line(muc_window, THEME_ERROR, '!', "Configuration error"); } } else { if (message) { - win_printf(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error for %s: %s", roomjid, message); + win_printf_line(console, THEME_ERROR, '!', "Configuration error for %s: %s", roomjid, message); } else { - win_printf(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error for %s", roomjid); + win_printf_line(console, THEME_ERROR, '!', "Configuration error for %s", roomjid); } } } else { - win_printf(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); + win_printf_line(console, THEME_ERROR, '!', "Configuration error"); } } diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index b9e095ae..75fbc8d4 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -153,7 +153,7 @@ mucwin_room_info_error(ProfMucWin *mucwin, const char *const error) assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Room info request failed: %s", error); + win_printf_line(window, THEME_DEFAULT, '!', "Room info request failed: %s", error); win_printf_line(window, THEME_DEFAULT, '-', ""); } @@ -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(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Identities:"); + win_printf_line(window, THEME_DEFAULT, '!', "Identities:"); } while (identities) { DiscoIdentity *identity = identities->data; // anme trpe, cat @@ -182,16 +182,16 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) if (identity->category) { identity_str = g_string_append(identity_str, identity->category); } - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "%s", identity_str->str); + win_printf_line(window, THEME_DEFAULT, '!', "%s", identity_str->str); g_string_free(identity_str, TRUE); identities = g_slist_next(identities); } if (features) { - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Features:"); + win_printf_line(window, THEME_DEFAULT, '!', "Features:"); } while (features) { - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s", features->data); + win_printf_line(window, THEME_DEFAULT, '!', " %s", features->data); features = g_slist_next(features); } win_printf_line(window, THEME_DEFAULT, '-', ""); @@ -206,9 +206,9 @@ 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(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room is empty."); + win_printf_line(window, THEME_ROOMINFO, '!', "Room is empty."); } else { - win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "No occupants %s.", presence); + win_printf_line(window, THEME_ROOMINFO, '!', "No occupants %s.", presence); } } else { int length = g_list_length(roster); @@ -242,7 +242,7 @@ mucwin_occupant_offline(ProfMucWin *mucwin, const char *const nick) assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf(window, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s has left the room.", nick); + win_printf_line(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(window, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); + win_printf_line(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(window, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); + win_printf_line(window, THEME_OFFLINE, '!', "<- %s", message->str); g_string_free(message, TRUE); } @@ -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(window, '!', 0, NULL, 0, THEME_THEM, "", "** %s is now known as %s", old_nick, nick); + win_printf_line(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(window, '!', 0, NULL, 0, THEME_ME, "", "** You are now known as %s", nick); + win_printf_line(window, THEME_ME, '!', "** You are now known as %s", nick); } void @@ -507,10 +507,10 @@ mucwin_requires_config(ProfMucWin *mucwin) } 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_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, '-', ""); // currently in groupchat window @@ -541,9 +541,9 @@ mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const sub } } else { if (nick) { - win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "*%s has cleared the room subject.", nick); + win_printf_line(window, THEME_ROOMINFO, '!', "*%s has cleared the room subject.", nick); } else { - win_printf(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room subject cleared"); + win_printf_line(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(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error kicking %s: %s", nick, error); + win_printf_line(window, THEME_ERROR, '!', "Error kicking %s: %s", nick, error); } void @@ -594,7 +594,7 @@ mucwin_affiliation_list_error(ProfMucWin *mucwin, const char *const affiliation, assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; - win_printf(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error retrieving %s list: %s", affiliation, error); + win_printf_line(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(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Affiliation: %s", affiliation); + win_printf_line(window, THEME_DEFAULT, '!', "Affiliation: %s", affiliation); GSList *curr_jid = jids; while (curr_jid) { const char *jid = curr_jid->data; - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s", jid); + win_printf_line(window, THEME_DEFAULT, '!', " %s", jid); curr_jid = g_slist_next(curr_jid); } - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", ""); + win_printf_line(window, THEME_DEFAULT, '!', ""); } else { - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No users found with affiliation: %s", affiliation); - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", ""); + win_printf_line(window, THEME_DEFAULT, '!', "No users found with affiliation: %s", affiliation); + win_printf_line(window, THEME_DEFAULT, '!', ""); } } @@ -629,16 +629,16 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) if (!occupants) { switch (affiliation) { case MUC_AFFILIATION_OWNER: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No owners found."); + win_printf_line(window, THEME_DEFAULT, '!', "No owners found."); break; case MUC_AFFILIATION_ADMIN: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No admins found."); + win_printf_line(window, THEME_DEFAULT, '!', "No admins found."); break; case MUC_AFFILIATION_MEMBER: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No members found."); + win_printf_line(window, THEME_DEFAULT, '!', "No members found."); break; case MUC_AFFILIATION_OUTCAST: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No outcasts found."); + win_printf_line(window, THEME_DEFAULT, '!', "No outcasts found."); break; default: break; @@ -647,16 +647,16 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) } else { switch (affiliation) { case MUC_AFFILIATION_OWNER: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Owners:"); + win_printf_line(window, THEME_DEFAULT, '!', "Owners:"); break; case MUC_AFFILIATION_ADMIN: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Admins:"); + win_printf_line(window, THEME_DEFAULT, '!', "Admins:"); break; case MUC_AFFILIATION_MEMBER: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Members:"); + win_printf_line(window, THEME_DEFAULT, '!', "Members:"); break; case MUC_AFFILIATION_OUTCAST: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Outcasts:"); + win_printf_line(window, THEME_DEFAULT, '!', "Outcasts:"); break; default: break; @@ -667,9 +667,9 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) Occupant *occupant = curr_occupant->data; if (occupant->affiliation == affiliation) { if (occupant->jid) { - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s (%s)", occupant->nick, occupant->jid); + win_printf_line(window, THEME_DEFAULT, '!', " %s (%s)", occupant->nick, occupant->jid); } else { - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s", occupant->nick); + win_printf_line(window, THEME_DEFAULT, '!', " %s", occupant->nick); } } @@ -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(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error retrieving %s list: %s", role, error); + win_printf_line(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(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Role: %s", role); + win_printf_line(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(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s (%s)", nick, occupant->jid); + win_printf_line(window, THEME_DEFAULT, '!', " %s (%s)", nick, occupant->jid); } else { - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s", nick); + win_printf_line(window, THEME_DEFAULT, '!', " %s", nick); } } else { - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s", nick); + win_printf_line(window, THEME_DEFAULT, '!', " %s", nick); } curr_nick = g_slist_next(curr_nick); } - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", ""); + win_printf_line(window, THEME_DEFAULT, '!', ""); } else { - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No occupants found with role: %s", role); - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", ""); + win_printf_line(window, THEME_DEFAULT, '!', "No occupants found with role: %s", role); + win_printf_line(window, THEME_DEFAULT, '!', ""); } } @@ -730,13 +730,13 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) if (!occupants) { switch (role) { case MUC_ROLE_MODERATOR: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No moderators found."); + win_printf_line(window, THEME_DEFAULT, '!', "No moderators found."); break; case MUC_ROLE_PARTICIPANT: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No participants found."); + win_printf_line(window, THEME_DEFAULT, '!', "No participants found."); break; case MUC_ROLE_VISITOR: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "No visitors found."); + win_printf_line(window, THEME_DEFAULT, '!', "No visitors found."); break; default: break; @@ -745,13 +745,13 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) } else { switch (role) { case MUC_ROLE_MODERATOR: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Moderators:"); + win_printf_line(window, THEME_DEFAULT, '!', "Moderators:"); break; case MUC_ROLE_PARTICIPANT: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Participants:"); + win_printf_line(window, THEME_DEFAULT, '!', "Participants:"); break; case MUC_ROLE_VISITOR: - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", "Visitors:"); + win_printf_line(window, THEME_DEFAULT, '!', "Visitors:"); break; default: break; @@ -762,9 +762,9 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) Occupant *occupant = curr_occupant->data; if (occupant->role == role) { if (occupant->jid) { - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s (%s)", occupant->nick, occupant->jid); + win_printf_line(window, THEME_DEFAULT, '!', " %s (%s)", occupant->nick, occupant->jid); } else { - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " %s", occupant->nick); + win_printf_line(window, THEME_DEFAULT, '!', " %s", occupant->nick); } } @@ -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(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error setting %s affiliation for %s: %s", affiliation, jid, error); + win_printf_line(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(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error setting %s role for %s: %s", role, nick, error); + win_printf_line(window, THEME_ERROR, '!', "Error setting %s role for %s: %s", role, nick, error); } void @@ -804,9 +804,9 @@ mucwin_info(ProfMucWin *mucwin) char *affiliation = muc_affiliation_str(mucwin->roomjid); ProfWin *window = (ProfWin*) 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, '!', "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, '-', ""); } diff --git a/src/ui/privwin.c b/src/ui/privwin.c index 47fb19a9..ae3f4fa0 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -142,7 +142,7 @@ privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const g_string_append(message, reason); } - win_printf((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %s", message->str); + win_printf_line((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((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %s", message->str); + win_printf_line((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); g_string_free(message, TRUE); } @@ -187,7 +187,7 @@ privwin_room_destroyed(ProfPrivateWin *privwin) privwin->room_left = TRUE; Jid *jidp = jid_create(privwin->fulljid); - win_printf((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- %s has been destroyed.", jidp->barejid); + win_printf_line((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((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- You have joined %s.", jidp->barejid); + win_printf_line((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((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- You have left %s.", jidp->barejid); + win_printf_line((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((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); + win_printf_line((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((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); + win_printf_line((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str); g_string_free(message, TRUE); } diff --git a/src/ui/window.c b/src/ui/window.c index 5a0c062b..6f63976e 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -757,11 +757,11 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_newline(window); if (occupant->jid) { - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " Jid: %s", occupant->jid); + win_printf_line(window, THEME_DEFAULT, '!', " Jid: %s", occupant->jid); } - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " Affiliation: %s", occupant_affiliation); - win_printf(window, '!', 0, NULL, 0, THEME_DEFAULT, "", " Role: %s", occupant_role); + win_printf_line(window, THEME_DEFAULT, '!', " Affiliation: %s", occupant_affiliation); + win_printf_line(window, THEME_DEFAULT, '!', " Role: %s", occupant_role); Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick); EntityCapabilities *caps = caps_lookup(jidp->fulljid); @@ -1123,7 +1123,7 @@ win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) va_start(arg, message); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - win_printf(window, ch, 0, NULL, 0, THEME_DEFAULT, "", "%s", fmt_msg->str); + win_printf_line(window, THEME_DEFAULT, ch, "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); } diff --git a/src/ui/window_list.c b/src/ui/window_list.c index 4996719d..2f95ff79 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((ProfWin*)privwin, '!', 0, NULL, 0, THEME_THEM, NULL, "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart); + win_printf_line((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); From 6ed04d87b304490e6394c94132ee4e1ab8fe1a3b Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 16:41:37 +0100 Subject: [PATCH 12/28] Rename win_get_string -> win_to_string --- src/ui/ui.h | 2 +- src/ui/window.c | 2 +- src/ui/window_list.c | 2 +- tests/unittests/ui/stub_ui.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ui/ui.h b/src/ui/ui.h index 401ca8bd..26febee8 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -368,7 +368,7 @@ void win_show_info(ProfWin *window, PContact contact); void win_println(ProfWin *window, int pad, const char *const message); void win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...); void win_clear(ProfWin *window); -char* win_get_string(ProfWin *window); +char* win_to_string(ProfWin *window); // desktop notifications void notifier_initialise(void); diff --git a/src/ui/window.c b/src/ui/window.c index 6f63976e..c5c2b9e4 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -314,7 +314,7 @@ win_get_title(ProfWin *window) } char* -win_get_string(ProfWin *window) +win_to_string(ProfWin *window) { assert(window != NULL); diff --git a/src/ui/window_list.c b/src/ui/window_list.c index 2f95ff79..6ef166d5 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -1051,7 +1051,7 @@ wins_create_summary(gboolean unread) GString *line = g_string_new(""); int ui_index = GPOINTER_TO_INT(curr->data); - char *winstring = win_get_string(window); + char *winstring = win_to_string(window); if (!winstring) { g_string_free(line, TRUE); continue; diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 740ce951..11f5b516 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -534,7 +534,7 @@ void win_show_info(ProfWin *window, PContact contact) {} void win_println(ProfWin *window, int pad, const char * const message) {} void win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) {} void win_clear(ProfWin *window) {} -char* win_get_string(ProfWin *window) +char* win_to_string(ProfWin *window) { return NULL; } From e29e532d8721712acf22fdd4f6c3a0bffa6ea427 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 16:42:23 +0100 Subject: [PATCH 13/28] Remove whitespace --- src/ui/window.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ui/window.c b/src/ui/window.c index c5c2b9e4..13edd847 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -517,7 +517,6 @@ win_page_down(ProfWin *window) void win_sub_page_down(ProfWin *window) { - if (window->layout->type == LAYOUT_SPLIT) { int rows = getmaxy(stdscr); int page_space = rows - 4; From 864939b809ce1fc2d5999316dddd0786aaac9d48 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 17:03:30 +0100 Subject: [PATCH 14/28] Use win_printf_line instead of win_println --- src/command/cmd_funcs.c | 14 +++++++------- src/event/server_events.c | 2 +- src/ui/console.c | 36 ++++++++++++++++++------------------ src/ui/core.c | 6 +++--- src/ui/mucconfwin.c | 2 +- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 8aa1fceb..b4b802b9 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -3124,7 +3124,7 @@ cmd_status(ProfWin *window, const char *const command, gchar **args) if (pcontact) { win_show_contact(window, pcontact); } else { - win_println(window, 0, "Error getting contact info."); + win_printf_line(window, THEME_DEFAULT, '-', "Error getting contact info."); } } break; @@ -3139,7 +3139,7 @@ cmd_status(ProfWin *window, const char *const command, gchar **args) if (occupant) { win_show_occupant(window, occupant); } else { - win_println(window, 0, "Error getting contact info."); + win_printf_line(window, THEME_DEFAULT, '-', "Error getting contact info."); } jid_destroy(jid); } @@ -3204,7 +3204,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args) if (pcontact) { win_show_info(window, pcontact); } else { - win_println(window, 0, "Error getting contact info."); + win_printf_line(window, THEME_DEFAULT, '-', "Error getting contact info."); } } break; @@ -3219,7 +3219,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args) if (occupant) { win_show_occupant_info(window, jid->barejid, occupant); } else { - win_println(window, 0, "Error getting contact info."); + win_printf_line(window, THEME_DEFAULT, '-', "Error getting contact info."); } jid_destroy(jid); } @@ -3372,7 +3372,7 @@ cmd_software(ProfWin *window, const char *const command, gchar **args) iq_send_software_version(fulljid->str); g_string_free(fulljid, TRUE); } else { - win_println(window, 0, "Unknown resource for /software command."); + win_printf_line(window, THEME_DEFAULT, '-', "Unknown resource for /software command."); } } break; @@ -5137,7 +5137,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) if (!args[0]) { ProfWin *current = wins_get_current(); if (current->type == WIN_MUC) { - win_println(current, 0, ""); + win_printf_line(current, THEME_DEFAULT, '-', ""); ProfMucWin *mucwin = (ProfMucWin *)current; win_vprintln_ch(window, '!', "Notification settings for %s:", mucwin->roomjid); @@ -5180,7 +5180,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) win_vprintln_ch(window, '!', " Triggers : OFF (global setting)"); } } - win_println(current, 0, ""); + win_printf_line(current, THEME_DEFAULT, '-', ""); } else { cons_show(""); cons_notify_setting(); diff --git a/src/event/server_events.c b/src/event/server_events.c index d271ec55..d6589bca 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -442,7 +442,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m #ifdef HAVE_LIBGPGME if (pgp_message) { if (chatwin->is_otr) { - win_println((ProfWin*)chatwin, 0, "PGP encrypted message received whilst in OTR session."); + win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '-', "PGP encrypted message received whilst in OTR session."); } else { // PROF_ENC_NONE, PROF_ENC_PGP _sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message, timestamp); } diff --git a/src/ui/console.c b/src/ui/console.c index 61c07b37..09946d5a 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -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_println(console, 0, fmt_msg->str); + win_printf_line(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_println(console, 0, fmt_msg->str); + win_printf_line(console, THEME_DEFAULT, '-', "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); } @@ -138,7 +138,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) cons_show(""); win_printf_line(console, THEME_WHITE_BOLD, '-', "Description"); - win_println(console, 0, help->desc); + win_printf_line(console, THEME_DEFAULT, '-', "%s", help->desc); int maxlen = 0; for (i = 0; help->args[i][0] != NULL; i++) { @@ -427,13 +427,13 @@ cons_about(void) } 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."); - win_println(console, 0, "There is NO WARRANTY, to the extent permitted by law."); - win_println(console, 0, ""); - win_println(console, 0, "Type '/help' to show complete help."); - win_println(console, 0, ""); + win_printf_line(console, THEME_DEFAULT, '-', "License GPLv3+: GNU GPL version 3 or later "); + 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, '-', ""); if (prefs_get_boolean(PREF_VERCHECK)) { cons_check_version(FALSE); @@ -456,12 +456,12 @@ 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_println(console, 0, "Check for details."); - win_println(console, 0, ""); + win_printf_line(console, THEME_DEFAULT, '-', "Check for details."); + win_printf_line(console, THEME_DEFAULT, '-', ""); } else { if (not_available_msg) { - win_println(console, 0, "No new version available."); - win_println(console, 0, ""); + win_printf_line(console, THEME_DEFAULT, '-', "No new version available."); + win_printf_line(console, THEME_DEFAULT, '-', ""); } } @@ -509,7 +509,7 @@ cons_show_wins(gboolean unread) GSList *curr = window_strings; while (curr) { - win_println(console, 0, curr->data); + win_printf_line(console, THEME_DEFAULT, '-', "%s", curr->data); curr = g_slist_next(curr); } g_slist_free_full(window_strings, free); @@ -602,7 +602,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) } if (caps->features) { - win_println(console, 0, "Features:"); + win_printf_line(console, THEME_DEFAULT, '-', "Features:"); GSList *feature = caps->features; while (feature) { win_printf_line(console, THEME_DEFAULT, '-', " %s", feature->data); @@ -982,7 +982,7 @@ cons_show_account(ProfAccount *account) GList *curr = resources; if (curr) { - win_println(console, 0, "Resources:"); + win_printf_line(console, THEME_DEFAULT, '-', "Resources:"); // sort in order of availability while (curr) { @@ -2348,7 +2348,7 @@ static void _cons_splash_logo(void) { ProfWin *console = wins_get_console(); - win_println(console, 0, "Welcome to"); + win_printf_line(console, THEME_DEFAULT, '-', "Welcome to"); win_printf_line(console, THEME_SPLASH, '-', " ___ _ "); win_printf_line(console, THEME_SPLASH, '-', " / __) (_)_ "); diff --git a/src/ui/core.c b/src/ui/core.c index 42881d30..9347ca66 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -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_println(window, 0, fmt_msg->str); + win_printf_line(window, THEME_DEFAULT, '-', "%s", fmt_msg->str); va_end(arg); g_string_free(fmt_msg, TRUE); } @@ -1025,7 +1025,7 @@ ui_ask_pgp_passphrase(const char *hint, int prev_fail) { ProfWin *current = wins_get_current(); - win_println(current, 0, ""); + win_printf_line(current, THEME_DEFAULT, '-', ""); if (prev_fail) { win_printf_line(current, THEME_DEFAULT, '!', "Incorrect passphrase"); @@ -1314,7 +1314,7 @@ ui_show_software_version(const char *const jid, const char *const presence, } if (name || version || os) { - win_println(window, 0, ""); + win_printf_line(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_printf(window, '-', 0, NULL, NO_DATE, 0, "", ":"); diff --git a/src/ui/mucconfwin.c b/src/ui/mucconfwin.c index 5bba3bfd..16a6bb2a 100644 --- a/src/ui/mucconfwin.c +++ b/src/ui/mucconfwin.c @@ -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_println(window, 0, ""); + win_printf_line(window, THEME_DEFAULT, '-', ""); } void From 9d075c980597306aec6e167bd84379e8211b4135 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 17:07:15 +0100 Subject: [PATCH 15/28] Remove ui_win_error_line --- src/otr/otr.c | 4 ++-- src/ui/core.c | 6 ------ src/ui/ui.h | 1 - tests/unittests/ui/stub_ui.c | 1 - 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/otr/otr.c b/src/otr/otr.c index 158e6d27..295c5f4f 100644 --- a/src/otr/otr.c +++ b/src/otr/otr.c @@ -352,14 +352,14 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re free(id); return TRUE; } else { - ui_win_error_line((ProfWin*)chatwin, "Failed to encrypt and send message."); + win_printf_line((ProfWin*)chatwin, THEME_ERROR, '-', "%s", "Failed to encrypt and send message."); return TRUE; } } // show error if not secure and policy always if (policy == PROF_OTRPOLICY_ALWAYS) { - ui_win_error_line((ProfWin*)chatwin, "Failed to send message. OTR policy set to: always"); + win_printf_line((ProfWin*)chatwin, THEME_ERROR, '-', "%s", "Failed to send message. OTR policy set to: always"); return TRUE; } diff --git a/src/ui/core.c b/src/ui/core.c index 9347ca66..dd6b56e1 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -757,12 +757,6 @@ ui_current_print_formatted_line(const char show_char, int attrs, const char *con g_string_free(fmt_msg, TRUE); } -void -ui_win_error_line(ProfWin *window, const char *const msg) -{ - win_printf_line(window, THEME_ERROR, '-', "%s", msg); -} - void ui_current_error_line(const char *const msg) { diff --git a/src/ui/ui.h b/src/ui/ui.h index 26febee8..f0302a3a 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -78,7 +78,6 @@ int ui_close_read_wins(void); void ui_current_print_line(const char *const msg, ...); void ui_current_print_formatted_line(const char show_char, int attrs, const char *const msg, ...); void ui_current_error_line(const char *const msg); -void ui_win_error_line(ProfWin *window, const char *const msg); void ui_close_win(int index); int ui_win_unread(int index); char* ui_ask_password(void); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 11f5b516..5b48c9b6 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -126,7 +126,6 @@ void ui_current_print_formatted_line(const char show_char, int attrs, const char } void ui_current_error_line(const char * const msg) {} -void ui_win_error_line(ProfWin *window, const char * const msg) {} void ui_close_win(int index) {} From 478c749ff96a78bdd97d4cc9928f8f3b25eec067 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 17:08:29 +0100 Subject: [PATCH 16/28] Remove ui_current_error_line --- src/ui/core.c | 7 ------- src/ui/ui.h | 1 - tests/unittests/ui/stub_ui.c | 2 -- 3 files changed, 10 deletions(-) diff --git a/src/ui/core.c b/src/ui/core.c index dd6b56e1..7e762398 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -757,13 +757,6 @@ ui_current_print_formatted_line(const char show_char, int attrs, const char *con g_string_free(fmt_msg, TRUE); } -void -ui_current_error_line(const char *const msg) -{ - ProfWin *current = wins_get_current(); - win_printf_line(current, THEME_ERROR, '-', "%s", msg); -} - void ui_print_system_msg_from_recipient(const char *const barejid, const char *message) { diff --git a/src/ui/ui.h b/src/ui/ui.h index f0302a3a..c858a889 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -77,7 +77,6 @@ int ui_close_all_wins(void); int ui_close_read_wins(void); void ui_current_print_line(const char *const msg, ...); void ui_current_print_formatted_line(const char show_char, int attrs, const char *const msg, ...); -void ui_current_error_line(const char *const msg); void ui_close_win(int index); int ui_win_unread(int index); char* ui_ask_password(void); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 5b48c9b6..1d357c54 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -125,8 +125,6 @@ void ui_current_print_formatted_line(const char show_char, int attrs, const char va_end(args); } -void ui_current_error_line(const char * const msg) {} - void ui_close_win(int index) {} int ui_win_unread(int index) From 5488fd6e72de5c2143dfb5532043e9e1f9fb8343 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 17:17:17 +0100 Subject: [PATCH 17/28] Remove win_vprintln_ch --- src/command/cmd_funcs.c | 42 ++++++++++++++++++------------------ src/ui/chatwin.c | 24 ++++++++++----------- src/ui/ui.h | 1 - src/ui/window.c | 12 ----------- tests/unittests/ui/stub_ui.c | 1 - 5 files changed, 33 insertions(+), 47 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index b4b802b9..9c6ea3c4 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -5140,44 +5140,44 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) win_printf_line(current, THEME_DEFAULT, '-', ""); ProfMucWin *mucwin = (ProfMucWin *)current; - win_vprintln_ch(window, '!', "Notification settings for %s:", mucwin->roomjid); + win_printf_line(window, THEME_DEFAULT, '!', "Notification settings for %s:", mucwin->roomjid); if (prefs_has_room_notify(mucwin->roomjid)) { if (prefs_get_room_notify(mucwin->roomjid)) { - win_vprintln_ch(window, '!', " Message : ON"); + win_printf_line(window, THEME_DEFAULT, '!', " Message : ON"); } else { - win_vprintln_ch(window, '!', " Message : OFF"); + win_printf_line(window, THEME_DEFAULT, '!', " Message : OFF"); } } else { if (prefs_get_boolean(PREF_NOTIFY_ROOM)) { - win_vprintln_ch(window, '!', " Message : ON (global setting)"); + win_printf_line(window, THEME_DEFAULT, '!', " Message : ON (global setting)"); } else { - win_vprintln_ch(window, '!', " Message : OFF (global setting)"); + win_printf_line(window, THEME_DEFAULT, '!', " Message : OFF (global setting)"); } } if (prefs_has_room_notify_mention(mucwin->roomjid)) { if (prefs_get_room_notify_mention(mucwin->roomjid)) { - win_vprintln_ch(window, '!', " Mention : ON"); + win_printf_line(window, THEME_DEFAULT, '!', " Mention : ON"); } else { - win_vprintln_ch(window, '!', " Mention : OFF"); + win_printf_line(window, THEME_DEFAULT, '!', " Mention : OFF"); } } else { if (prefs_get_boolean(PREF_NOTIFY_ROOM_MENTION)) { - win_vprintln_ch(window, '!', " Mention : ON (global setting)"); + win_printf_line(window, THEME_DEFAULT, '!', " Mention : ON (global setting)"); } else { - win_vprintln_ch(window, '!', " Mention : OFF (global setting)"); + win_printf_line(window, THEME_DEFAULT, '!', " Mention : OFF (global setting)"); } } if (prefs_has_room_notify_trigger(mucwin->roomjid)) { if (prefs_get_room_notify_trigger(mucwin->roomjid)) { - win_vprintln_ch(window, '!', " Triggers : ON"); + win_printf_line(window, THEME_DEFAULT, '!', " Triggers : ON"); } else { - win_vprintln_ch(window, '!', " Triggers : OFF"); + win_printf_line(window, THEME_DEFAULT, '!', " Triggers : OFF"); } } else { if (prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER)) { - win_vprintln_ch(window, '!', " Triggers : ON (global setting)"); + win_printf_line(window, THEME_DEFAULT, '!', " Triggers : ON (global setting)"); } else { - win_vprintln_ch(window, '!', " Triggers : OFF (global setting)"); + win_printf_line(window, THEME_DEFAULT, '!', " Triggers : OFF (global setting)"); } } win_printf_line(current, THEME_DEFAULT, '-', ""); @@ -5394,7 +5394,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify(mucwin->roomjid, TRUE); - win_vprintln_ch(window, '!', "Notifications enabled for %s", mucwin->roomjid); + win_printf_line(window, THEME_DEFAULT, '!', "Notifications enabled for %s", mucwin->roomjid); } } } else if (g_strcmp0(args[0], "off") == 0) { @@ -5409,7 +5409,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify(mucwin->roomjid, FALSE); - win_vprintln_ch(window, '!', "Notifications disabled for %s", mucwin->roomjid); + win_printf_line(window, THEME_DEFAULT, '!', "Notifications disabled for %s", mucwin->roomjid); } } } else if (g_strcmp0(args[0], "mention") == 0) { @@ -5425,7 +5425,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify_mention(mucwin->roomjid, TRUE); - win_vprintln_ch(window, '!', "Mention notifications enabled for %s", mucwin->roomjid); + win_printf_line(window, THEME_DEFAULT, '!', "Mention notifications enabled for %s", mucwin->roomjid); } } else if (g_strcmp0(args[1], "off") == 0) { ProfWin *window = wins_get_current(); @@ -5434,7 +5434,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify_mention(mucwin->roomjid, FALSE); - win_vprintln_ch(window, '!', "Mention notifications disabled for %s", mucwin->roomjid); + win_printf_line(window, THEME_DEFAULT, '!', "Mention notifications disabled for %s", mucwin->roomjid); } } else { cons_bad_cmd_usage(command); @@ -5453,7 +5453,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify_trigger(mucwin->roomjid, TRUE); - win_vprintln_ch(window, '!', "Custom trigger notifications enabled for %s", mucwin->roomjid); + win_printf_line(window, THEME_DEFAULT, '!', "Custom trigger notifications enabled for %s", mucwin->roomjid); } } else if (g_strcmp0(args[1], "off") == 0) { ProfWin *window = wins_get_current(); @@ -5462,7 +5462,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify_trigger(mucwin->roomjid, FALSE); - win_vprintln_ch(window, '!', "Custom trigger notifications disabled for %s", mucwin->roomjid); + win_printf_line(window, THEME_DEFAULT, '!', "Custom trigger notifications disabled for %s", mucwin->roomjid); } } else { cons_bad_cmd_usage(command); @@ -5481,9 +5481,9 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) ProfMucWin *mucwin = (ProfMucWin*)window; gboolean res = prefs_reset_room_notify(mucwin->roomjid); if (res) { - win_vprintln_ch(window, '!', "Notification settings set to global defaults for %s", mucwin->roomjid); + win_printf_line(window, THEME_DEFAULT, '!', "Notification settings set to global defaults for %s", mucwin->roomjid); } else { - win_vprintln_ch(window, '!', "No custom notification settings for %s", mucwin->roomjid); + win_printf_line(window, THEME_DEFAULT, '!', "No custom notification settings for %s", mucwin->roomjid); } } } diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 05a259f7..ba2bdc38 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -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_vprintln_ch((ProfWin*)chatwin, '!', + win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s wants to authenticate your identity, use '/otr secret '.", chatwin->barejid); break; case PROF_OTR_SMP_INIT_Q: - win_vprintln_ch((ProfWin*)chatwin, '!', + win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s wants to authenticate your identity with the following question:", chatwin->barejid); - win_vprintln_ch((ProfWin*)chatwin, '!', " %s", (char*)data); - win_vprintln_ch((ProfWin*)chatwin, '!', "use '/otr answer '."); + win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', " %s", (char*)data); + win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "use '/otr answer '."); break; case PROF_OTR_SMP_SENDER_FAIL: - win_vprintln_ch((ProfWin*)chatwin, '!', + win_printf_line((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_vprintln_ch((ProfWin*)chatwin, '!', + win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "Authentication failed, the secret entered by %s does not match yours.", chatwin->barejid); break; case PROF_OTR_SMP_ABORT: - win_vprintln_ch((ProfWin*)chatwin, '!', "SMP session aborted."); + win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "SMP session aborted."); break; case PROF_OTR_SMP_SUCCESS: - win_vprintln_ch((ProfWin*)chatwin, '!', "Authentication successful."); + win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "Authentication successful."); break; case PROF_OTR_SMP_SUCCESS_Q: - win_vprintln_ch((ProfWin*)chatwin, '!', "%s successfully authenticated you.", chatwin->barejid); + win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s successfully authenticated you.", chatwin->barejid); break; case PROF_OTR_SMP_FAIL_Q: - win_vprintln_ch((ProfWin*)chatwin, '!', "%s failed to authenticate you.", chatwin->barejid); + win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s failed to authenticate you.", chatwin->barejid); break; case PROF_OTR_SMP_AUTH: - win_vprintln_ch((ProfWin*)chatwin, '!', "Authenticating %s...", chatwin->barejid); + win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "Authenticating %s...", chatwin->barejid); break; case PROF_OTR_SMP_AUTH_WAIT: - win_vprintln_ch((ProfWin*)chatwin, '!', "Awaiting authentication from %s...", chatwin->barejid); + win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '!', "Awaiting authentication from %s...", chatwin->barejid); break; default: break; diff --git a/src/ui/ui.h b/src/ui/ui.h index c858a889..fbc6babb 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -364,7 +364,6 @@ void win_show_occupant_info(ProfWin *window, const char *const room, Occupant *o void win_show_contact(ProfWin *window, PContact contact); void win_show_info(ProfWin *window, PContact contact); void win_println(ProfWin *window, int pad, const char *const message); -void win_vprintln_ch(ProfWin *window, char ch, 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 13edd847..f5ab998f 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1115,18 +1115,6 @@ win_println(ProfWin *window, int pad, const char *const message) win_printf(window, '-', pad, NULL, 0, THEME_DEFAULT, "", "%s", message); } -void -win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) -{ - va_list arg; - va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); - g_string_vprintf(fmt_msg, message, arg); - win_printf_line(window, THEME_DEFAULT, ch, "%s", fmt_msg->str); - g_string_free(fmt_msg, TRUE); - va_end(arg); -} - void win_newline(ProfWin *window) { diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 1d357c54..bbd6fd34 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -529,7 +529,6 @@ void win_show_occupant_info(ProfWin *window, const char * const room, Occupant * void win_show_contact(ProfWin *window, PContact contact) {} void win_show_info(ProfWin *window, PContact contact) {} void win_println(ProfWin *window, int pad, const char * const message) {} -void win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) {} void win_clear(ProfWin *window) {} char* win_to_string(ProfWin *window) { From 3612270e90db7a824e7f818bb70c88021a1bc16a Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 17:23:02 +0100 Subject: [PATCH 18/28] Rename win_println -> win_println_indent --- src/ui/console.c | 2 +- src/ui/ui.h | 2 +- src/ui/window.c | 2 +- tests/unittests/ui/stub_ui.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ui/console.c b/src/ui/console.c index 09946d5a..d2e49b4c 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -113,7 +113,7 @@ cons_show_padded(int pad, const char *const msg, ...) va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - win_println(console, pad, fmt_msg->str); + win_println_indent(console, pad, fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); } diff --git a/src/ui/ui.h b/src/ui/ui.h index fbc6babb..1850105b 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -363,7 +363,7 @@ void win_show_occupant(ProfWin *window, Occupant *occupant); void win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupant); void win_show_contact(ProfWin *window, PContact contact); void win_show_info(ProfWin *window, PContact contact); -void win_println(ProfWin *window, int pad, const char *const message); +void win_println_indent(ProfWin *window, int pad, const char *const message); void win_clear(ProfWin *window); char* win_to_string(ProfWin *window); diff --git a/src/ui/window.c b/src/ui/window.c index f5ab998f..66dcf408 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1110,7 +1110,7 @@ win_update_entry_theme(ProfWin *window, const char *const id, theme_item_t theme } void -win_println(ProfWin *window, int pad, const char *const message) +win_println_indent(ProfWin *window, int pad, const char *const message) { win_printf(window, '-', pad, NULL, 0, THEME_DEFAULT, "", "%s", message); } diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index bbd6fd34..d5e21425 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -528,7 +528,7 @@ void win_show_occupant(ProfWin *window, Occupant *occupant) {} void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant) {} void win_show_contact(ProfWin *window, PContact contact) {} void win_show_info(ProfWin *window, PContact contact) {} -void win_println(ProfWin *window, int pad, const char * const message) {} +void win_println_indent(ProfWin *window, int pad, const char * const message) {} void win_clear(ProfWin *window) {} char* win_to_string(ProfWin *window) { From 8f1d3ab55c6108333351698518325b6291226e07 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 18:29:02 +0100 Subject: [PATCH 19/28] Add win_print --- src/command/cmd_funcs.c | 84 ++++++++-------- src/event/server_events.c | 2 +- src/otr/otr.c | 4 +- src/plugins/api.c | 6 +- src/ui/chatwin.c | 38 ++++---- src/ui/console.c | 183 ++++++++++++++++++----------------- src/ui/core.c | 70 +++++++------- src/ui/mucconfwin.c | 88 ++++++++--------- src/ui/mucwin.c | 154 ++++++++++++++--------------- src/ui/privwin.c | 22 ++--- src/ui/ui.h | 5 +- src/ui/window.c | 50 +++++++--- src/ui/window_list.c | 4 +- src/ui/xmlwin.c | 12 +-- tests/unittests/ui/stub_ui.c | 3 +- 15 files changed, 378 insertions(+), 347 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 9c6ea3c4..c0212f73 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_println(console, THEME_WHITE_BOLD, '-', "%s commands", tag); } else { - win_printf_line(console, THEME_WHITE_BOLD, '-', "All commands"); + win_println(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_println(window, THEME_DEFAULT, '-', "No such participant \"%s\" in room.", usr); } } else { ui_current_print_line("You must specify a nickname."); @@ -3124,7 +3124,7 @@ cmd_status(ProfWin *window, const char *const command, gchar **args) if (pcontact) { win_show_contact(window, pcontact); } else { - win_printf_line(window, THEME_DEFAULT, '-', "Error getting contact info."); + win_println(window, THEME_DEFAULT, '-', "Error getting contact info."); } } break; @@ -3139,7 +3139,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, '-', "Error getting contact info."); + win_println(window, THEME_DEFAULT, '-', "Error getting contact info."); } jid_destroy(jid); } @@ -3204,7 +3204,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args) if (pcontact) { win_show_info(window, pcontact); } else { - win_printf_line(window, THEME_DEFAULT, '-', "Error getting contact info."); + win_println(window, THEME_DEFAULT, '-', "Error getting contact info."); } } break; @@ -3219,7 +3219,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args) if (occupant) { win_show_occupant_info(window, jid->barejid, occupant); } else { - win_printf_line(window, THEME_DEFAULT, '-', "Error getting contact info."); + win_println(window, THEME_DEFAULT, '-', "Error getting contact info."); } jid_destroy(jid); } @@ -3372,7 +3372,7 @@ cmd_software(ProfWin *window, const char *const command, gchar **args) iq_send_software_version(fulljid->str); g_string_free(fulljid, TRUE); } else { - win_printf_line(window, THEME_DEFAULT, '-', "Unknown resource for /software command."); + win_println(window, THEME_DEFAULT, '-', "Unknown resource for /software command."); } } break; @@ -3881,7 +3881,7 @@ cmd_kick(ProfWin *window, const char *const command, gchar **args) char *reason = args[1]; iq_room_kick_occupant(mucwin->roomjid, nick, reason); } else { - win_printf_line(window, THEME_DEFAULT, '!', "Occupant does not exist: %s", nick); + win_println(window, THEME_DEFAULT, '!', "Occupant does not exist: %s", nick); } } else { cons_bad_cmd_usage(command); @@ -3939,10 +3939,10 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) if (args[0] == NULL) { char *subject = muc_subject(mucwin->roomjid); if (subject) { - 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 { - win_printf_line(window, THEME_ROOMINFO, '!', "Room has no subject"); + win_println(window, THEME_ROOMINFO, '!', "Room has no subject"); } return TRUE; } @@ -3974,7 +3974,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) message_send_groupchat_subject(mucwin->roomjid, new_subject->str); g_string_free(new_subject, TRUE); } else { - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room does not have a subject, use /subject set "); + win_print(window, THEME_ROOMINFO, '!', "Room does not have a subject, use /subject set "); } } else { cons_bad_cmd_usage(command); @@ -3991,7 +3991,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) message_send_groupchat_subject(mucwin->roomjid, new_subject->str); g_string_free(new_subject, TRUE); } else { - win_printf(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room does not have a subject, use /subject set "); + win_print(window, THEME_ROOMINFO, '!', "Room does not have a subject, use /subject set "); } } else { cons_bad_cmd_usage(command); @@ -4050,7 +4050,7 @@ cmd_affiliation(ProfWin *window, const char *const command, gchar **args) iq_room_affiliation_list(mucwin->roomjid, "member"); iq_room_affiliation_list(mucwin->roomjid, "outcast"); } else if (g_strcmp0(affiliation, "none") == 0) { - win_printf_line(window, THEME_DEFAULT, '!', "Cannot list users with no affiliation."); + win_println(window, THEME_DEFAULT, '!', "Cannot list users with no affiliation."); } else { iq_room_affiliation_list(mucwin->roomjid, affiliation); } @@ -4118,7 +4118,7 @@ cmd_role(ProfWin *window, const char *const command, gchar **args) iq_room_role_list(mucwin->roomjid, "participant"); iq_room_role_list(mucwin->roomjid, "visitor"); } else if (g_strcmp0(role, "none") == 0) { - win_printf_line(window, THEME_DEFAULT, '!', "Cannot list users with no role."); + win_println(window, THEME_DEFAULT, '!', "Cannot list users with no role."); } else { iq_room_role_list(mucwin->roomjid, role); } @@ -4180,12 +4180,12 @@ cmd_room(ProfWin *window, const char *const command, gchar **args) if (g_strcmp0(args[0], "accept") == 0) { gboolean requires_config = muc_requires_config(mucwin->roomjid); if (!requires_config) { - win_printf_line(window, THEME_ROOMINFO, '!', "Current room does not require configuration."); + win_println(window, THEME_ROOMINFO, '!', "Current room does not require configuration."); return TRUE; } else { iq_confirm_instant_room(mucwin->roomjid); muc_set_requires_config(mucwin->roomjid, FALSE); - win_printf_line(window, THEME_ROOMINFO, '!', "Room unlocked."); + win_println(window, THEME_ROOMINFO, '!', "Room unlocked."); return TRUE; } } @@ -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_println(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_println(window, THEME_ERROR, '-', "Couldn't create tinyurl."); return TRUE; } @@ -5137,50 +5137,50 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) if (!args[0]) { ProfWin *current = wins_get_current(); if (current->type == WIN_MUC) { - win_printf_line(current, THEME_DEFAULT, '-', ""); + win_println(current, THEME_DEFAULT, '-', ""); ProfMucWin *mucwin = (ProfMucWin *)current; - win_printf_line(window, THEME_DEFAULT, '!', "Notification settings for %s:", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "Notification settings for %s:", mucwin->roomjid); if (prefs_has_room_notify(mucwin->roomjid)) { if (prefs_get_room_notify(mucwin->roomjid)) { - win_printf_line(window, THEME_DEFAULT, '!', " Message : ON"); + win_println(window, THEME_DEFAULT, '!', " Message : ON"); } else { - win_printf_line(window, THEME_DEFAULT, '!', " Message : OFF"); + win_println(window, THEME_DEFAULT, '!', " Message : OFF"); } } else { if (prefs_get_boolean(PREF_NOTIFY_ROOM)) { - win_printf_line(window, THEME_DEFAULT, '!', " Message : ON (global setting)"); + win_println(window, THEME_DEFAULT, '!', " Message : ON (global setting)"); } else { - win_printf_line(window, THEME_DEFAULT, '!', " Message : OFF (global setting)"); + win_println(window, THEME_DEFAULT, '!', " Message : OFF (global setting)"); } } if (prefs_has_room_notify_mention(mucwin->roomjid)) { if (prefs_get_room_notify_mention(mucwin->roomjid)) { - win_printf_line(window, THEME_DEFAULT, '!', " Mention : ON"); + win_println(window, THEME_DEFAULT, '!', " Mention : ON"); } else { - win_printf_line(window, THEME_DEFAULT, '!', " Mention : OFF"); + win_println(window, THEME_DEFAULT, '!', " Mention : OFF"); } } else { if (prefs_get_boolean(PREF_NOTIFY_ROOM_MENTION)) { - win_printf_line(window, THEME_DEFAULT, '!', " Mention : ON (global setting)"); + win_println(window, THEME_DEFAULT, '!', " Mention : ON (global setting)"); } else { - win_printf_line(window, THEME_DEFAULT, '!', " Mention : OFF (global setting)"); + win_println(window, THEME_DEFAULT, '!', " Mention : OFF (global setting)"); } } if (prefs_has_room_notify_trigger(mucwin->roomjid)) { if (prefs_get_room_notify_trigger(mucwin->roomjid)) { - win_printf_line(window, THEME_DEFAULT, '!', " Triggers : ON"); + win_println(window, THEME_DEFAULT, '!', " Triggers : ON"); } else { - win_printf_line(window, THEME_DEFAULT, '!', " Triggers : OFF"); + win_println(window, THEME_DEFAULT, '!', " Triggers : OFF"); } } else { if (prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER)) { - win_printf_line(window, THEME_DEFAULT, '!', " Triggers : ON (global setting)"); + win_println(window, THEME_DEFAULT, '!', " Triggers : ON (global setting)"); } else { - win_printf_line(window, THEME_DEFAULT, '!', " Triggers : OFF (global setting)"); + win_println(window, THEME_DEFAULT, '!', " Triggers : OFF (global setting)"); } } - win_printf_line(current, THEME_DEFAULT, '-', ""); + win_println(current, THEME_DEFAULT, '-', ""); } else { cons_show(""); cons_notify_setting(); @@ -5394,7 +5394,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify(mucwin->roomjid, TRUE); - win_printf_line(window, THEME_DEFAULT, '!', "Notifications enabled for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "Notifications enabled for %s", mucwin->roomjid); } } } else if (g_strcmp0(args[0], "off") == 0) { @@ -5409,7 +5409,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify(mucwin->roomjid, FALSE); - win_printf_line(window, THEME_DEFAULT, '!', "Notifications disabled for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "Notifications disabled for %s", mucwin->roomjid); } } } else if (g_strcmp0(args[0], "mention") == 0) { @@ -5425,7 +5425,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify_mention(mucwin->roomjid, TRUE); - win_printf_line(window, THEME_DEFAULT, '!', "Mention notifications enabled for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "Mention notifications enabled for %s", mucwin->roomjid); } } else if (g_strcmp0(args[1], "off") == 0) { ProfWin *window = wins_get_current(); @@ -5434,7 +5434,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify_mention(mucwin->roomjid, FALSE); - win_printf_line(window, THEME_DEFAULT, '!', "Mention notifications disabled for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "Mention notifications disabled for %s", mucwin->roomjid); } } else { cons_bad_cmd_usage(command); @@ -5453,7 +5453,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify_trigger(mucwin->roomjid, TRUE); - win_printf_line(window, THEME_DEFAULT, '!', "Custom trigger notifications enabled for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "Custom trigger notifications enabled for %s", mucwin->roomjid); } } else if (g_strcmp0(args[1], "off") == 0) { ProfWin *window = wins_get_current(); @@ -5462,7 +5462,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) } else { ProfMucWin *mucwin = (ProfMucWin*)window; prefs_set_room_notify_trigger(mucwin->roomjid, FALSE); - win_printf_line(window, THEME_DEFAULT, '!', "Custom trigger notifications disabled for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "Custom trigger notifications disabled for %s", mucwin->roomjid); } } else { cons_bad_cmd_usage(command); @@ -5481,9 +5481,9 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args) ProfMucWin *mucwin = (ProfMucWin*)window; gboolean res = prefs_reset_room_notify(mucwin->roomjid); if (res) { - win_printf_line(window, THEME_DEFAULT, '!', "Notification settings set to global defaults for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "Notification settings set to global defaults for %s", mucwin->roomjid); } else { - win_printf_line(window, THEME_DEFAULT, '!', "No custom notification settings for %s", mucwin->roomjid); + win_println(window, THEME_DEFAULT, '!', "No custom notification settings for %s", mucwin->roomjid); } } } diff --git a/src/event/server_events.c b/src/event/server_events.c index d6589bca..ff77b3af 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -442,7 +442,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m #ifdef HAVE_LIBGPGME if (pgp_message) { if (chatwin->is_otr) { - win_printf_line((ProfWin*)chatwin, THEME_DEFAULT, '-', "PGP encrypted message received whilst in OTR session."); + win_println((ProfWin*)chatwin, THEME_DEFAULT, '-', "PGP encrypted message received whilst in OTR session."); } else { // PROF_ENC_NONE, PROF_ENC_PGP _sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message, timestamp); } diff --git a/src/otr/otr.c b/src/otr/otr.c index 295c5f4f..0dc56a59 100644 --- a/src/otr/otr.c +++ b/src/otr/otr.c @@ -352,14 +352,14 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re free(id); return TRUE; } else { - win_printf_line((ProfWin*)chatwin, THEME_ERROR, '-', "%s", "Failed to encrypt and send message."); + win_println((ProfWin*)chatwin, THEME_ERROR, '-', "%s", "Failed to encrypt and send message."); return TRUE; } } // show error if not secure and policy always if (policy == PROF_OTRPOLICY_ALWAYS) { - win_printf_line((ProfWin*)chatwin, THEME_ERROR, '-', "%s", "Failed to send message. OTR policy set to: always"); + win_println((ProfWin*)chatwin, THEME_ERROR, '-', "%s", "Failed to send message. OTR policy set to: always"); return TRUE; } diff --git a/src/plugins/api.c b/src/plugins/api.c index 606a4811..abec5300 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_println(console, themeitem, '-', "%s", parsed); free(parsed); @@ -368,7 +368,7 @@ api_win_show(const char *tag, const char *line) } ProfWin *window = (ProfWin*)pluginwin; - win_printf_line(window, THEME_DEFAULT, '!', "%s", line); + win_println(window, THEME_DEFAULT, '!', "%s", line); return 1; } @@ -393,7 +393,7 @@ api_win_show_themed(const char *tag, const char *const group, const char *const theme_item_t themeitem = plugin_themes_get(group, key, def); ProfWin *window = (ProfWin*)pluginwin; - win_printf_line(window, themeitem, '!', "%s", line); + win_println(window, themeitem, '!', "%s", line); return 1; } 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 '.", 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 '."); + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', " %s", (char*)data); + win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "use '/otr 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 "); - 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 "); + 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 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 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 ", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Where : is any text"); + win_println(window, THEME_DEFAULT, '-', " Set : /%s ", tag); + win_println(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_println(window, THEME_DEFAULT, '-', " Add : /%s add ", tag); + win_println(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_println(window, THEME_DEFAULT, '-', " Remove : /%s remove ", tag); + win_println(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_println(window, THEME_DEFAULT, '-', " Set : /%s ", tag); + win_println(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_println(window, THEME_DEFAULT, '-', " Set : /%s ", tag); + win_println(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_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 ", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Remove : /%s remove ", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Where : is one of"); + win_println(window, THEME_DEFAULT, '-', " Add : /%s add ", tag); + win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove ", tag); + win_println(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_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 ", tag); - win_printf_line(window, THEME_DEFAULT, '-', " Where : is a valid Jabber ID"); + win_println(window, THEME_DEFAULT, '-', " Set : /%s ", tag); + win_println(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_println(window, THEME_DEFAULT, '-', " Add : /%s add ", tag); + win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove ", tag); + win_println(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_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, '-', ""); } } diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index d5e21425..1cf58e6e 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -518,7 +518,8 @@ 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 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, ...) {} char* win_get_title(ProfWin *window) { From 711c5b8e452f2ebc121474269812095153f27608 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 19:19:44 +0100 Subject: [PATCH 20/28] Add win_appendln --- src/command/cmd_funcs.c | 2 +- src/ui/console.c | 52 ++++++++++++++++++------------------ src/ui/core.c | 5 ++-- src/ui/mucconfwin.c | 14 +++++----- src/ui/mucwin.c | 23 ++++++++-------- src/ui/ui.h | 1 + src/ui/window.c | 48 ++++++++++++++++++++++----------- tests/unittests/ui/stub_ui.c | 1 + 8 files changed, 82 insertions(+), 64 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index c0212f73..d052d77f 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -3940,7 +3940,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args) char *subject = muc_subject(mucwin->roomjid); if (subject) { win_print(window, THEME_ROOMINFO, '!', "Room subject: "); - win_printf(window, '!', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", subject); + win_appendln(window, THEME_DEFAULT, "%s", subject); } else { win_println(window, THEME_ROOMINFO, '!', "Room has no subject"); } diff --git a/src/ui/console.c b/src/ui/console.c index 48d33bfb..df9a7b43 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -130,7 +130,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) for (i = 0; i < strlen(cmd) - 1 ; i++) { win_printf(console, '-', 0, NULL, NO_EOL | NO_DATE, THEME_WHITE_BOLD, "", "-"); } - win_printf(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", ""); + win_appendln(console, THEME_WHITE_BOLD, ""); cons_show(""); win_println(console, THEME_WHITE_BOLD, '-', "Synopsis"); @@ -484,7 +484,7 @@ cons_show_login_success(ProfAccount *account, gboolean secured) win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str); win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " (priority %d)", accounts_get_priority_for_presence_type(account->name, presence)); - win_printf(console, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", "."); + win_appendln(console, THEME_DEFAULT, "."); if (!secured) { cons_show_error("TLS connection not established"); } @@ -555,7 +555,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); win_print(console, presence_colour, '-', "%s", fulljid); - win_printf(console, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ":"); + win_appendln(console, THEME_DEFAULT, ":"); // show identity if (caps->identity) { @@ -788,7 +788,7 @@ cons_show_disco_items(GSList *items, const char *const jid) if (item->name) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", (%s)", item->name); } - win_printf(console, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ""); + win_appendln(console, THEME_DEFAULT, ""); items = g_slist_next(items); } } else { @@ -1005,7 +1005,7 @@ cons_show_account(ProfAccount *account) if (resource->status) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); } - win_printf(console, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ""); + win_appendln(console, THEME_DEFAULT, ""); Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name); EntityCapabilities *caps = caps_lookup(jidp->fulljid); jid_destroy(jidp); @@ -2192,7 +2192,7 @@ _cons_theme_bar_prop(theme_item_t theme, char *prop) g_string_append_printf(valstr, "%s ", setting); theme_free_string(setting); win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, theme, "", "%s", valstr->str); - win_printf(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); + win_appendln(console, THEME_TEXT, ""); g_string_free(valstr, TRUE); } @@ -2210,7 +2210,7 @@ _cons_theme_prop(theme_item_t theme, char *prop) char *setting = theme_get_string(prop); g_string_append_printf(valstr, "%s", setting); theme_free_string(setting); - win_printf(console, '-', 0, NULL, NO_DATE, theme, "", "%s", valstr->str); + win_appendln(console, theme, "%s", valstr->str); g_string_free(valstr, TRUE); } @@ -2326,29 +2326,29 @@ cons_theme_colours(void) ProfWin *console = wins_get_console(); cons_show("Available colours:"); - win_print(console, THEME_WHITE, '-', " white "); - win_printf(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", " bold_white"); + win_print(console, THEME_WHITE, '-', " white "); + win_appendln(console, 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_GREEN, '-', " green "); + win_appendln(console, 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_RED, '-', " red "); + win_appendln(console, 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_YELLOW, '-', " yellow "); + win_appendln(console, 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_BLUE, '-', " blue "); + win_appendln(console, 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_CYAN, '-', " cyan "); + win_appendln(console, 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_MAGENTA, '-', " magenta "); + win_appendln(console, THEME_MAGENTA_BOLD, " bold_magenta"); - win_print(console, THEME_BLACK, '-', " black "); - win_printf(console, '-', 0, NULL, NO_DATE, THEME_BLACK_BOLD, "", " bold_black"); + win_print(console, THEME_BLACK, '-', " black "); + win_appendln(console, THEME_BLACK_BOLD, " bold_black"); cons_show(""); } @@ -2424,7 +2424,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) if (show_groups) { win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", sub->str); } else { - win_printf(console, '-', 0, NULL, NO_DATE, presence_colour, "", "%s", sub->str); + win_appendln(console, presence_colour, "%s", sub->str); } g_string_free(sub, TRUE); @@ -2440,10 +2440,10 @@ _show_roster_contacts(GSList *list, gboolean show_groups) } groups = g_slist_next(groups); } - win_printf(console, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", groups_str->str); + win_appendln(console, THEME_DEFAULT, "%s", groups_str->str); g_string_free(groups_str, TRUE); } else { - win_printf(console, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", " "); + win_appendln(console, THEME_DEFAULT, " "); } } diff --git a/src/ui/core.c b/src/ui/core.c index 178823c8..9866d93b 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -800,8 +800,7 @@ ui_room_join(const char *const roomjid, gboolean focus) win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", affiliation: %s", affiliation); } } - win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); - + win_appendln(window, THEME_ROOMINFO, ""); if (focus) { ui_focus_win(window); @@ -1304,7 +1303,7 @@ ui_show_software_version(const char *const jid, const char *const presence, win_println(window, THEME_DEFAULT, '-', ""); theme_item_t presence_colour = theme_main_presence_attrs(presence); win_print(window, presence_colour, '-', "%s", jid); - win_printf(window, '-', 0, NULL, NO_DATE, 0, "", ":"); + win_appendln(window, THEME_DEFAULT, ":"); } if (name) { win_println(window, THEME_DEFAULT, '-', "Name : %s", name); diff --git a/src/ui/mucconfwin.c b/src/ui/mucconfwin.c index 8a9c3951..65cc6b04 100644 --- a/src/ui/mucconfwin.c +++ b/src/ui/mucconfwin.c @@ -48,7 +48,7 @@ mucconfwin_show_form(ProfMucConfWin *confwin) ProfWin *window = (ProfWin*) confwin; if (confwin->form->title) { win_print(window, THEME_DEFAULT, '-', "Form title: "); - win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", confwin->form->title); + win_appendln(window, THEME_DEFAULT, "%s", confwin->form->title); } else { win_println(window, THEME_DEFAULT, '-', "Configuration for room %s.", confwin->roomjid); } @@ -113,9 +113,9 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag) if (field) { win_print(window, THEME_DEFAULT, '-', "%s", field->label); if (field->required) { - win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", " (Required):"); + win_appendln(window, THEME_DEFAULT, " (Required):"); } else { - win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ":"); + win_appendln(window, THEME_DEFAULT, ":"); } if (field->description) { win_println(window, THEME_DEFAULT, '-', " Description : %s", field->description); @@ -252,16 +252,16 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) break; case FIELD_BOOLEAN: if (curr_value == NULL) { - win_printf(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); + win_appendln(window, THEME_OFFLINE, "FALSE"); } else { char *value = curr_value->data; if (value == NULL) { - win_printf(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); + win_appendln(window, THEME_OFFLINE, "FALSE"); } else { if (g_strcmp0(value, "0") == 0) { - win_printf(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); + win_appendln(window, THEME_OFFLINE, "FALSE"); } else { - win_printf(window, '-', 0, NULL, NO_DATE, THEME_ONLINE, "", "TRUE"); + win_appendln(window, THEME_ONLINE, "TRUE"); } } } diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index a1196ac4..62e5b997 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -58,7 +58,7 @@ mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_appendln(window, THEME_ROOMINFO, ""); } void @@ -75,7 +75,7 @@ mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, con if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_appendln(window, THEME_ROOMINFO, ""); } void @@ -92,7 +92,7 @@ mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, c if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_appendln(window, THEME_ROOMINFO, ""); } @@ -110,7 +110,7 @@ mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const ch if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_appendln(window, THEME_ROOMINFO, ""); } void @@ -127,7 +127,7 @@ mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, c if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_appendln(window, THEME_ROOMINFO, ""); } void @@ -144,7 +144,7 @@ mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *cons if (reason) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); } - win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_appendln(window, THEME_ROOMINFO, ""); } void @@ -231,8 +231,7 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) roster = g_list_next(roster); } - win_printf(window, '!', 0, NULL, NO_DATE, THEME_ONLINE, "", ""); - + win_appendln(window, THEME_ONLINE, ""); } } @@ -305,7 +304,7 @@ mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *c win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", affiliation: %s", affiliation); } } - win_printf(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); + win_appendln(window, THEME_ROOMINFO, ""); } void @@ -534,10 +533,10 @@ mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const sub if (subject) { if (nick) { win_print(window, THEME_ROOMINFO, '!', "*%s has set the room subject: ", nick); - win_printf(window, '!', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", subject); + win_appendln(window, THEME_DEFAULT, "%s", subject); } else { win_print(window, THEME_ROOMINFO, '!', "Room subject: "); - win_printf(window, '!', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", subject); + win_appendln(window, THEME_DEFAULT, "%s", subject); } } else { if (nick) { @@ -575,7 +574,7 @@ mucwin_broadcast(ProfMucWin *mucwin, const char *const message) int num = wins_get_num(window); win_print(window, THEME_ROOMINFO, '!', "Room message: "); - win_printf(window, '!', 0, NULL, NO_DATE, THEME_DEFAULT, "", "%s", message); + win_appendln(window, THEME_DEFAULT, "%s", message); // currently in groupchat window if (wins_is_current(window)) { diff --git a/src/ui/ui.h b/src/ui/ui.h index 05cac699..0830639a 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -359,6 +359,7 @@ void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime theme_item_t theme_item, const char *const from, 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_appendln(ProfWin *window, theme_item_t theme_item, 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); diff --git a/src/ui/window.c b/src/ui/window.c index a5b063cf..c7016b6f 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -689,7 +689,7 @@ win_show_occupant(ProfWin *window, Occupant *occupant) win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); } - win_printf(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); + win_appendln(window, presence_colour, ""); } void @@ -734,7 +734,7 @@ win_show_contact(ProfWin *window, PContact contact) win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", p_contact_status(contact)); } - win_printf(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); + win_appendln(window, presence_colour, ""); } void @@ -792,7 +792,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { - win_printf(window, '!', 0, NULL, NO_EOL, THEME_DEFAULT, "", " Software: %s", software_version->software); + win_print(window, THEME_DEFAULT, '!', " Software: %s", software_version->software); } if (software_version->software_version) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); @@ -801,7 +801,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_newline(window); } if (software_version->os) { - win_printf(window, '!', 0, NULL, NO_EOL, THEME_DEFAULT, "", " OS: %s", software_version->os); + win_print(window, THEME_DEFAULT, '!', " OS: %s", software_version->os); } if (software_version->os_version) { win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); @@ -829,11 +829,11 @@ win_show_info(ProfWin *window, PContact contact) theme_item_t presence_colour = theme_main_presence_attrs(presence); win_println(window, THEME_DEFAULT, '-', ""); - win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", barejid); + win_print(window, presence_colour, '-', "%s", barejid); if (name) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name); } - win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ":"); + win_appendln(window, THEME_DEFAULT, ":"); if (sub) { win_println(window, THEME_DEFAULT, '-', "Subscription: %s", sub); @@ -880,7 +880,7 @@ win_show_info(ProfWin *window, PContact contact) 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(window, '-', 0, NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence); + win_print(window, presence_colour, '-', " %s (%d), %s", resource->name, resource->priority, resource_presence); if (resource->status) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); } @@ -894,7 +894,7 @@ win_show_info(ProfWin *window, PContact contact) // 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) { @@ -916,7 +916,7 @@ win_show_info(ProfWin *window, PContact contact) if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { - win_printf(window, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " Software: %s", software_version->software); + win_print(window, THEME_DEFAULT, '-', " Software: %s", software_version->software); } if (software_version->software_version) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); @@ -925,7 +925,7 @@ win_show_info(ProfWin *window, PContact contact) win_newline(window); } if (software_version->os) { - win_printf(window, '-', 0, NULL, NO_EOL, THEME_DEFAULT, "", " OS: %s", software_version->os); + win_print(window, THEME_DEFAULT, '-', " OS: %s", software_version->os); } if (software_version->os_version) { win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); @@ -959,8 +959,7 @@ win_show_status_string(ProfWin *window, const char *const from, presence_colour = THEME_OFFLINE; } - - win_printf(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s %s", pre, from); + win_print(window, presence_colour, '-', "%s %s", pre, from); if (show) win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", show); @@ -982,8 +981,7 @@ win_show_status_string(ProfWin *window, const char *const from, if (status) win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", status); - win_printf(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); - + win_appendln(window, presence_colour, ""); } void @@ -1076,6 +1074,26 @@ win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char va_end(arg); } +void +win_appendln(ProfWin *window, theme_item_t theme_item, 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, '-', 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL); + + _win_print(window, '-', 0, timestamp, NO_DATE, 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_print_http_upload(ProfWin *window, const char *const message, char *url) { @@ -1138,7 +1156,7 @@ win_println_indent(ProfWin *window, int pad, const char *const message) void win_newline(ProfWin *window) { - win_printf(window, '-', 0, NULL, NO_DATE, THEME_DEFAULT, "", ""); + win_appendln(window, THEME_DEFAULT, ""); } static void diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 1cf58e6e..ac08665e 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -520,6 +520,7 @@ 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_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_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...) {} char* win_get_title(ProfWin *window) { From ce5f07a012f163cc71e68ac605da50ad86b9338c Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 19:53:49 +0100 Subject: [PATCH 21/28] Add win_append --- src/ui/console.c | 57 ++++++++++++++++--------------- src/ui/core.c | 4 +-- src/ui/mucconfwin.c | 16 ++++----- src/ui/mucwin.c | 32 +++++++++--------- src/ui/ui.h | 7 +++- src/ui/window.c | 81 ++++++++++++++++++++++++++++----------------- 6 files changed, 110 insertions(+), 87 deletions(-) diff --git a/src/ui/console.c b/src/ui/console.c index df9a7b43..2efe85b5 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -74,7 +74,7 @@ void cons_show_word(const char *const word) { ProfWin *console = wins_get_console(); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", word); + win_append(console, THEME_DEFAULT, "%s", word); } void @@ -128,7 +128,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) 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, "", "-"); + win_append(console, THEME_WHITE_BOLD, "-"); } win_appendln(console, THEME_WHITE_BOLD, ""); cons_show(""); @@ -481,9 +481,8 @@ cons_show_login_success(ProfAccount *account, gboolean secured) const char *presence_str = string_from_resource_presence(presence); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " (priority %d)", - accounts_get_priority_for_presence_type(account->name, presence)); + win_append(console, presence_colour, "%s", presence_str); + win_append(console, THEME_DEFAULT, " (priority %d)", accounts_get_priority_for_presence_type(account->name, presence)); win_appendln(console, THEME_DEFAULT, "."); if (!secured) { cons_show_error("TLS connection not established"); @@ -562,19 +561,19 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) DiscoIdentity *identity = caps->identity; win_print(console, THEME_DEFAULT, '-', "Identity: "); if (identity->name) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); + win_append(console, THEME_DEFAULT, "%s", identity->name); if (identity->category || identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(console, THEME_DEFAULT, " "); } } if (identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->type); + win_append(console, THEME_DEFAULT, "%s", identity->type); if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(console, THEME_DEFAULT, " "); } } if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->category); + win_append(console, THEME_DEFAULT, "%s", identity->category); } win_newline(console); } @@ -585,7 +584,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) 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); + win_append(console, THEME_DEFAULT, ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(console); @@ -594,7 +593,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) 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); + win_append(console, THEME_DEFAULT, ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(console); @@ -669,7 +668,7 @@ cons_show_room_list(GSList *rooms, const char *const conference_node) DiscoItem *room = rooms->data; 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); + win_append(console, THEME_DEFAULT, ", (%s)", room->name); } win_newline(console); rooms = g_slist_next(rooms); @@ -703,19 +702,19 @@ cons_show_bookmarks(const GList *list) } 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); + win_append(console, presence_colour, "/%s", item->nick); } if (item->autojoin) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (autojoin)"); + win_append(console, presence_colour, " (autojoin)"); } if (item->password) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (private)"); + win_append(console, presence_colour, " (private)"); } if (muc_active(item->barejid)) { ProfWin *roomwin = (ProfWin*)wins_get_muc(item->barejid); if (roomwin) { int num = wins_get_num(roomwin); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (win %d)", num); + win_append(console, presence_colour, " (win %d)", num); } } win_newline(console); @@ -786,7 +785,7 @@ cons_show_disco_items(GSList *items, const char *const jid) DiscoItem *item = items->data; 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); + win_append(console, THEME_DEFAULT, ", (%s)", item->name); } win_appendln(console, THEME_DEFAULT, ""); items = g_slist_next(items); @@ -1003,7 +1002,7 @@ cons_show_account(ProfAccount *account) 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); + win_append(console, presence_colour, ", \"%s\"", resource->status); } win_appendln(console, THEME_DEFAULT, ""); Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name); @@ -1016,19 +1015,19 @@ cons_show_account(ProfAccount *account) DiscoIdentity *identity = caps->identity; win_print(console, THEME_DEFAULT, '-', " Identity: "); if (identity->name) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); + win_append(console, THEME_DEFAULT, "%s", identity->name); if (identity->category || identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(console, THEME_DEFAULT, " "); } } if (identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->type); + win_append(console, THEME_DEFAULT, "%s", identity->type); if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(console, THEME_DEFAULT, " "); } } if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->category); + win_append(console, THEME_DEFAULT, "%s", identity->category); } win_newline(console); } @@ -1039,7 +1038,7 @@ cons_show_account(ProfAccount *account) 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); + win_append(console, THEME_DEFAULT, ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(console); @@ -1048,7 +1047,7 @@ cons_show_account(ProfAccount *account) 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); + win_append(console, THEME_DEFAULT, ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(console); @@ -2191,7 +2190,7 @@ _cons_theme_bar_prop(theme_item_t theme, char *prop) char *setting = theme_get_string(prop); g_string_append_printf(valstr, "%s ", setting); theme_free_string(setting); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, theme, "", "%s", valstr->str); + win_append(console, theme, "%s", valstr->str); win_appendln(console, THEME_TEXT, ""); g_string_free(valstr, TRUE); } @@ -2406,7 +2405,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) g_string_free(title, TRUE); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " - "); + win_append(console, THEME_DEFAULT, " - "); GString *sub = g_string_new(""); sub = g_string_append(sub, p_contact_subscription(contact)); if (p_contact_pending_out(contact)) { @@ -2422,7 +2421,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) } if (show_groups) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", sub->str); + win_append(console, presence_colour, "%s", sub->str); } else { win_appendln(console, presence_colour, "%s", sub->str); } diff --git a/src/ui/core.c b/src/ui/core.c index 9866d93b..5b5d8d2a 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -794,10 +794,10 @@ ui_room_join(const char *const roomjid, gboolean focus) char *role = muc_role_str(roomjid); char *affiliation = muc_affiliation_str(roomjid); if (role) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", role: %s", role); + win_append(window, THEME_ROOMINFO, ", role: %s", role); } if (affiliation) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", affiliation: %s", affiliation); + win_append(window, THEME_ROOMINFO, ", affiliation: %s", affiliation); } } win_appendln(window, THEME_ROOMINFO, ""); diff --git a/src/ui/mucconfwin.c b/src/ui/mucconfwin.c index 65cc6b04..6bdf23fe 100644 --- a/src/ui/mucconfwin.c +++ b/src/ui/mucconfwin.c @@ -203,11 +203,11 @@ static void _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) { win_print(window, THEME_AWAY, '-', "[%s] ", tag); - win_printf(window, '-', 0, NULL, NO_EOL | NO_DATE, THEME_DEFAULT, "", "%s", field->label); + win_append(window, THEME_DEFAULT, "%s", field->label); if (field->required) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " (required): "); + win_append(window, THEME_DEFAULT, " (required): "); } else { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ": "); + win_append(window, THEME_DEFAULT, ": "); } GSList *values = field->values; @@ -221,9 +221,9 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) char *value = curr_value->data; if (value) { if (g_strcmp0(field->var, "muc#roomconfig_roomsecret") == 0) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); + win_append(window, THEME_ONLINE, "[hidden]"); } else { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "%s", value); + win_append(window, THEME_ONLINE, "%s", value); } } } @@ -233,7 +233,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); + win_append(window, THEME_ONLINE, "[hidden]"); } } win_newline(window); @@ -303,7 +303,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "%s", value); + win_append(window, THEME_ONLINE, "%s", value); } } win_newline(window); @@ -320,7 +320,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", value); + win_append(window, THEME_DEFAULT, "%s", value); } } win_newline(window); diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 62e5b997..7ad9411d 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -53,10 +53,10 @@ mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const ProfWin *window = (ProfWin*)mucwin; 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); + win_append(window, THEME_ROOMINFO, ", by: %s", actor); } if (reason) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_append(window, THEME_ROOMINFO, ", reason: %s", reason); } win_appendln(window, THEME_ROOMINFO, ""); } @@ -70,10 +70,10 @@ mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, con ProfWin *window = (ProfWin*)mucwin; 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); + win_append(window, THEME_ROOMINFO, ", by: %s", actor); } if (reason) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_append(window, THEME_ROOMINFO, ", reason: %s", reason); } win_appendln(window, THEME_ROOMINFO, ""); } @@ -87,10 +87,10 @@ mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, c ProfWin *window = (ProfWin*)mucwin; 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); + win_append(window, THEME_ROOMINFO, ", by: %s", actor); } if (reason) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_append(window, THEME_ROOMINFO, ", reason: %s", reason); } win_appendln(window, THEME_ROOMINFO, ""); } @@ -105,10 +105,10 @@ mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const ch ProfWin *window = (ProfWin*)mucwin; 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); + win_append(window, THEME_ROOMINFO, ", by: %s", actor); } if (reason) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_append(window, THEME_ROOMINFO, ", reason: %s", reason); } win_appendln(window, THEME_ROOMINFO, ""); } @@ -122,10 +122,10 @@ mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, c ProfWin *window = (ProfWin*)mucwin; 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); + win_append(window, THEME_ROOMINFO, ", by: %s", actor); } if (reason) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_append(window, THEME_ROOMINFO, ", reason: %s", reason); } win_appendln(window, THEME_ROOMINFO, ""); } @@ -139,10 +139,10 @@ mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *cons ProfWin *window = (ProfWin*)mucwin; 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); + win_append(window, THEME_ROOMINFO, ", by: %s", actor); } if (reason) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_append(window, THEME_ROOMINFO, ", reason: %s", reason); } win_appendln(window, THEME_ROOMINFO, ""); } @@ -223,10 +223,10 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) const char *presence_str = string_from_resource_presence(occupant->presence); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick); + win_append(window, presence_colour, "%s", occupant->nick); if (roster->next) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", "); + win_append(window, THEME_DEFAULT, ", "); } roster = g_list_next(roster); @@ -298,10 +298,10 @@ mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *c 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); + win_append(window, THEME_ONLINE, ", role: %s", role); } if (affiliation) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", affiliation: %s", affiliation); + win_append(window, THEME_ONLINE, ", affiliation: %s", affiliation); } } win_appendln(window, THEME_ROOMINFO, ""); diff --git a/src/ui/ui.h b/src/ui/ui.h index 0830639a..386b3eb4 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -355,12 +355,17 @@ void win_hide_subwin(ProfWin *window); void win_show_subwin(ProfWin *window); void win_refresh_without_subwin(ProfWin *window); void win_refresh_with_subwin(ProfWin *window); + void win_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_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_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...); void win_println_indent(ProfWin *window, int pad, const char *const message); + +void win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...); +void win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...); + 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 c7016b6f..f0243578 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -683,10 +683,10 @@ win_show_occupant(ProfWin *window, Occupant *occupant) theme_item_t presence_colour = theme_main_presence_attrs(presence_str); win_print(window, presence_colour, '-', "%s", occupant->nick); - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); + win_append(window, presence_colour, " is %s", presence_str); if (occupant->status) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); + win_append(window, presence_colour, ", \"%s\"", occupant->status); } win_appendln(window, presence_colour, ""); @@ -709,7 +709,7 @@ win_show_contact(ProfWin *window, PContact contact) win_print(window, presence_colour, '-', "%s", barejid); } - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence); + win_append(window, presence_colour, " is %s", presence); if (last_activity) { GDateTime *now = g_date_time_new_now_local(); @@ -723,15 +723,14 @@ win_show_contact(ProfWin *window, PContact contact) int seconds = span / G_TIME_SPAN_SECOND; if (hours > 0) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds); - } - else { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dm%ds", minutes, seconds); + win_append(window, presence_colour, ", idle %dh%dm%ds", hours, minutes, seconds); + } else { + win_append(window, presence_colour, ", idle %dm%ds", minutes, seconds); } } if (status) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", p_contact_status(contact)); + win_append(window, presence_colour, ", \"%s\"", p_contact_status(contact)); } win_appendln(window, presence_colour, ""); @@ -747,10 +746,10 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa theme_item_t presence_colour = theme_main_presence_attrs(presence_str); win_print(window, presence_colour, '!', "%s", occupant->nick); - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); + win_append(window, presence_colour, " is %s", presence_str); if (occupant->status) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); + win_append(window, presence_colour, ", \"%s\"", occupant->status); } win_newline(window); @@ -772,19 +771,19 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa DiscoIdentity *identity = caps->identity; win_print(window, THEME_DEFAULT, '!', " Identity: "); if (identity->name) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); + win_append(window, THEME_DEFAULT, "%s", identity->name); if (identity->category || identity->type) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(window, THEME_DEFAULT, " "); } } if (identity->type) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->type); + win_append(window, THEME_DEFAULT, "%s", identity->type); if (identity->category) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(window, THEME_DEFAULT, " "); } } if (identity->category) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->category); + win_append(window, THEME_DEFAULT, "%s", identity->category); } win_newline(window); } @@ -795,7 +794,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_print(window, THEME_DEFAULT, '!', " Software: %s", software_version->software); } if (software_version->software_version) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); + win_append(window, THEME_DEFAULT, ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(window); @@ -804,7 +803,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_print(window, THEME_DEFAULT, '!', " OS: %s", software_version->os); } if (software_version->os_version) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); + win_append(window, THEME_DEFAULT, ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(window); @@ -831,7 +830,7 @@ win_show_info(ProfWin *window, PContact contact) win_println(window, THEME_DEFAULT, '-', ""); win_print(window, presence_colour, '-', "%s", barejid); if (name) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name); + win_append(window, presence_colour, " (%s)", name); } win_appendln(window, THEME_DEFAULT, ":"); @@ -882,7 +881,7 @@ win_show_info(ProfWin *window, PContact contact) theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); win_print(window, presence_colour, '-', " %s (%d), %s", resource->name, resource->priority, resource_presence); if (resource->status) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); + win_append(window, presence_colour, ", \"%s\"", resource->status); } win_newline(window); @@ -896,19 +895,19 @@ win_show_info(ProfWin *window, PContact contact) DiscoIdentity *identity = caps->identity; win_print(window, THEME_DEFAULT, '-', " Identity: "); if (identity->name) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); + win_append(window, THEME_DEFAULT, "%s", identity->name); if (identity->category || identity->type) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(window, THEME_DEFAULT, " "); } } if (identity->type) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->type); + win_append(window, THEME_DEFAULT, "%s", identity->type); if (identity->category) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(window, THEME_DEFAULT, " "); } } if (identity->category) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->category); + win_append(window, THEME_DEFAULT, "%s", identity->category); } win_newline(window); } @@ -919,7 +918,7 @@ win_show_info(ProfWin *window, PContact contact) win_print(window, THEME_DEFAULT, '-', " Software: %s", software_version->software); } if (software_version->software_version) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); + win_append(window, THEME_DEFAULT, ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(window); @@ -928,7 +927,7 @@ win_show_info(ProfWin *window, PContact contact) win_print(window, THEME_DEFAULT, '-', " OS: %s", software_version->os); } if (software_version->os_version) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); + win_append(window, THEME_DEFAULT, ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(window); @@ -962,9 +961,9 @@ win_show_status_string(ProfWin *window, const char *const from, win_print(window, presence_colour, '-', "%s %s", pre, from); if (show) - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", show); + win_append(window, presence_colour, " is %s", show); else - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", default_show); + win_append(window, presence_colour, " is %s", default_show); if (last_activity) { gchar *date_fmt = NULL; @@ -973,13 +972,13 @@ win_show_status_string(ProfWin *window, const char *const from, prefs_free_string(time_pref); assert(date_fmt != NULL); - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", last activity: %s", date_fmt); + win_append(window, presence_colour, ", last activity: %s", date_fmt); g_free(date_fmt); } if (status) - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", status); + win_append(window, presence_colour, ", \"%s\"", status); win_appendln(window, presence_colour, ""); } @@ -1074,6 +1073,26 @@ win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char va_end(arg); } +void +win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...) +{ + GDateTime *timestamp = g_date_time_new_now_local(); + + 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, '-', 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL); + + _win_print(window, '-', 0, timestamp, NO_DATE | 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_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...) { @@ -1092,8 +1111,8 @@ win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message g_string_free(fmt_msg, TRUE); va_end(arg); - } + void win_print_http_upload(ProfWin *window, const char *const message, char *url) { From 3b2ceee89bb4c25434745d1e7085c509f6014d0b Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 20:07:33 +0100 Subject: [PATCH 22/28] Add win_print_outgoing --- src/ui/chatwin.c | 2 +- src/ui/privwin.c | 2 +- src/ui/window.c | 20 ++++++++++++++++++++ src/ui/window.h | 2 ++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 3482e1bc..f901f117 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -308,7 +308,7 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, if (request_receipt && id) { win_print_with_receipt((ProfWin*)chatwin, enc_char, "me", message, id); } else { - win_printf((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", "%s", message); + win_print_outgoing((ProfWin*)chatwin, enc_char, "%s", message); } } diff --git a/src/ui/privwin.c b/src/ui/privwin.c index 54c54564..e7fca112 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -93,7 +93,7 @@ privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message) { assert(privwin != NULL); - win_printf((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", "%s", message); + win_print_outgoing((ProfWin*)privwin, '-', "%s", message); } void diff --git a/src/ui/window.c b/src/ui/window.c index f0243578..2175ad6c 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1008,6 +1008,26 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp, } } +void +win_print_outgoing(ProfWin *window, 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, 0, THEME_TEXT_ME, "me", fmt_msg->str, NULL); + + _win_print(window, ch, 0, timestamp, 0, THEME_TEXT_ME, "me", fmt_msg->str, NULL); + inp_nonblocking(TRUE); + g_date_time_unref(timestamp); + + g_string_free(fmt_msg, TRUE); + va_end(arg); +} + 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, ...) diff --git a/src/ui/window.h b/src/ui/window.h index ee53b1de..4c1b31a6 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -59,6 +59,8 @@ void win_show_status_string(ProfWin *window, const char *const from, const char *const show, const char *const status, GDateTime *last_activity, const char *const pre, const char *const default_show); + +void win_print_outgoing(ProfWin *window, const char ch, const char *const message, ...); void win_print_incoming_message(ProfWin *window, GDateTime *timestamp, const char *const from, const char *const message, prof_enc_t enc_mode); From 80309462caf20a84ff444638c7a8b67b2c7bc0a9 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 20:09:14 +0100 Subject: [PATCH 23/28] Rename win_print_incoming_message -> win_print_incoming --- src/ui/chatwin.c | 4 ++-- src/ui/privwin.c | 4 ++-- src/ui/window.c | 2 +- src/ui/window.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index f901f117..4632e706 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -247,7 +247,7 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha // currently viewing chat window with sender if (wins_is_current(window)) { - win_print_incoming_message(window, timestamp, display_name, plugin_message, enc_mode); + win_print_incoming(window, timestamp, display_name, plugin_message, enc_mode); title_bar_set_typing(FALSE); status_bar_active(num); @@ -274,7 +274,7 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha } } - win_print_incoming_message(window, timestamp, display_name, plugin_message, enc_mode); + win_print_incoming(window, timestamp, display_name, plugin_message, enc_mode); } if (prefs_get_boolean(PREF_BEEP)) { diff --git a/src/ui/privwin.c b/src/ui/privwin.c index e7fca112..7fb9c62d 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -60,7 +60,7 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDat // currently viewing chat window with sender if (wins_is_current(window)) { - win_print_incoming_message(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN); + win_print_incoming(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN); title_bar_set_typing(FALSE); status_bar_active(num); @@ -68,7 +68,7 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDat } else { status_bar_new(num); cons_show_incoming_private_message(jidp->resourcepart, jidp->barejid, num, privatewin->unread); - win_print_incoming_message(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN); + win_print_incoming(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN); privatewin->unread++; diff --git a/src/ui/window.c b/src/ui/window.c index 2175ad6c..07dcc9dc 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -984,7 +984,7 @@ win_show_status_string(ProfWin *window, const char *const from, } void -win_print_incoming_message(ProfWin *window, GDateTime *timestamp, +win_print_incoming(ProfWin *window, GDateTime *timestamp, const char *const from, const char *const message, prof_enc_t enc_mode) { char enc_char = '-'; diff --git a/src/ui/window.h b/src/ui/window.h index 4c1b31a6..9f84eabf 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -61,7 +61,7 @@ void win_show_status_string(ProfWin *window, const char *const from, const char *const default_show); void win_print_outgoing(ProfWin *window, const char ch, const char *const message, ...); -void win_print_incoming_message(ProfWin *window, GDateTime *timestamp, +void win_print_incoming(ProfWin *window, GDateTime *timestamp, const char *const from, const char *const message, prof_enc_t enc_mode); void win_print_http_upload(ProfWin *window, const char *const message, char *url); From f761d403b3ba72595c8fb0328822b9cacd3aac9c Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 20:13:21 +0100 Subject: [PATCH 24/28] Use win_print_outgoing for carbons --- src/ui/chatwin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 4632e706..d7d0e62c 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -322,7 +322,7 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_en enc_char = prefs_get_pgp_char(); } - win_printf((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", "%s", message); + win_print_outgoing((ProfWin*)chatwin, enc_char, "%s", message); int num = wins_get_num((ProfWin*)chatwin); status_bar_active(num); } From c814cb44b8dafc04baf402cad7f7be165aa1ce6b Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 20:55:45 +0100 Subject: [PATCH 25/28] Add win_print_history --- src/ui/chatwin.c | 2 +- src/ui/mucwin.c | 2 +- src/ui/window.c | 20 ++++++++++++++++++++ src/ui/window.h | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index d7d0e62c..8eee3dee 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -401,7 +401,7 @@ _chatwin_history(ProfChatWin *chatwin, const char *const contact) char mm[3]; memcpy(mm, &line[3], 2); mm[2] = '\0'; int imm = atoi(mm); char ss[3]; memcpy(ss, &line[6], 2); ss[2] = '\0'; int iss = atoi(ss); GDateTime *timestamp = g_date_time_new_local(2000, 1, 1, ihh, imm, iss); - win_printf((ProfWin*)chatwin, '-', 0, timestamp, NO_COLOUR_DATE, THEME_DEFAULT, "", "%s", curr->data+11); + win_print_history((ProfWin*)chatwin, timestamp, "%s", curr->data+11); g_date_time_unref(timestamp); // header } else { diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 7ad9411d..6d1891d4 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -354,7 +354,7 @@ mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, g_string_append(line, message); } - win_printf(window, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", "%s", line->str); + win_print_history(window, timestamp, "%s", line->str); g_string_free(line, TRUE); plugins_on_room_history_message(mucwin->roomjid, nick, message, timestamp); diff --git a/src/ui/window.c b/src/ui/window.c index 07dcc9dc..1b456768 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1028,6 +1028,26 @@ win_print_outgoing(ProfWin *window, const char ch, const char *const message, .. va_end(arg); } +void +win_print_history(ProfWin *window, GDateTime *timestamp, const char *const message, ...) +{ + g_date_time_ref(timestamp); + + 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, '-', 0, timestamp, NO_COLOUR_DATE, THEME_DEFAULT, "", fmt_msg->str, NULL); + + _win_print(window, '-', 0, timestamp, NO_COLOUR_DATE, THEME_DEFAULT, "", fmt_msg->str, NULL); + inp_nonblocking(TRUE); + g_date_time_unref(timestamp); + + g_string_free(fmt_msg, TRUE); + va_end(arg); +} + void win_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, ...) diff --git a/src/ui/window.h b/src/ui/window.h index 9f84eabf..cdc18dfe 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -63,6 +63,7 @@ void win_show_status_string(ProfWin *window, const char *const from, void win_print_outgoing(ProfWin *window, const char ch, const char *const message, ...); void win_print_incoming(ProfWin *window, GDateTime *timestamp, const char *const from, const char *const message, prof_enc_t enc_mode); +void win_print_history(ProfWin *window, GDateTime *timestamp, const char *const message, ...); void win_print_http_upload(ProfWin *window, const char *const message, char *url); From f3aebd547cb40818f5b87be66354e359447a54c7 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 21:05:26 +0100 Subject: [PATCH 26/28] Use varargs in win_println_indent --- src/ui/console.c | 4 ++-- src/ui/ui.h | 2 +- src/ui/window.c | 26 ++++++++++++++++++++------ tests/unittests/ui/stub_ui.c | 2 +- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/ui/console.c b/src/ui/console.c index 2efe85b5..ff80750e 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -113,7 +113,7 @@ cons_show_padded(int pad, const char *const msg, ...) va_start(arg, msg); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); - win_println_indent(console, pad, fmt_msg->str); + win_println_indent(console, pad, "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); va_end(arg); } @@ -150,7 +150,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) cons_show(""); win_println(console, THEME_WHITE_BOLD, '-', "Arguments"); for (i = 0; help->args[i][0] != NULL; i++) { - win_printf(console, '-', maxlen + 3, NULL, 0, THEME_DEFAULT, "", "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]); + win_println_indent(console, maxlen + 3, "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]); } } diff --git a/src/ui/ui.h b/src/ui/ui.h index 386b3eb4..6fb97b3e 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -361,7 +361,7 @@ void win_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime void win_print(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...); void win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...); -void win_println_indent(ProfWin *window, int pad, const char *const message); +void win_println_indent(ProfWin *window, int pad, const char *const message, ...); void win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...); void win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...); diff --git a/src/ui/window.c b/src/ui/window.c index 1b456768..6630c60b 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1113,6 +1113,26 @@ win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char va_end(arg); } +void +win_println_indent(ProfWin *window, int pad, const char *const message, ...) +{ + GDateTime *timestamp = g_date_time_new_now_local(); + + va_list arg; + va_start(arg, message); + GString *fmt_msg = g_string_new(NULL); + g_string_vprintf(fmt_msg, message, arg); + + buffer_push(window->layout->buffer, '-', pad, timestamp, 0, THEME_DEFAULT, "", fmt_msg->str, NULL); + + _win_print(window, '-', pad, timestamp, 0, THEME_DEFAULT, "", fmt_msg->str, NULL); + inp_nonblocking(TRUE); + g_date_time_unref(timestamp); + + g_string_free(fmt_msg, TRUE); + va_end(arg); +} + void win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...) { @@ -1206,12 +1226,6 @@ win_update_entry_theme(ProfWin *window, const char *const id, theme_item_t theme } } -void -win_println_indent(ProfWin *window, int pad, const char *const message) -{ - win_printf(window, '-', pad, NULL, 0, THEME_DEFAULT, "", "%s", message); -} - void win_newline(ProfWin *window) { diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index ac08665e..c93f08fd 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -530,7 +530,7 @@ void win_show_occupant(ProfWin *window, Occupant *occupant) {} void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant) {} void win_show_contact(ProfWin *window, PContact contact) {} void win_show_info(ProfWin *window, PContact contact) {} -void win_println_indent(ProfWin *window, int pad, const char * const message) {} +void win_println_indent(ProfWin *window, int pad, const char * const message, ...) {} void win_clear(ProfWin *window) {} char* win_to_string(ProfWin *window) { From bb6540f7d8f4804f787b11fb6cfdcb2d8f3afff7 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 22:12:07 +0100 Subject: [PATCH 27/28] Add win highlight fuctions --- src/ui/mucwin.c | 24 ++++---- src/ui/ui.h | 6 +- src/ui/window.c | 144 ++++++++++++++++++++++++++++++++++++++---------- src/ui/window.h | 4 ++ 4 files changed, 135 insertions(+), 43 deletions(-) diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 6d1891d4..676e3aed 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -370,10 +370,10 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co pos = GPOINTER_TO_INT(curr->data); char *before_str = g_strndup(message + last_pos, pos - last_pos); - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION, "", "%s", before_str); + win_append_highlight(window, THEME_ROOMMENTION, "%s", before_str); g_free(before_str); char *nick_str = g_strndup(message + pos, strlen(nick)); - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION_TERM, "", "%s", nick_str); + win_append_highlight(window, THEME_ROOMMENTION_TERM, "%s", nick_str); g_free(nick_str); last_pos = pos + strlen(nick); @@ -381,9 +381,9 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co curr = g_slist_next(curr); } if (last_pos < strlen(message)) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", "%s", &message[last_pos]); + win_appendln_highlight(window, THEME_ROOMMENTION, "%s", &message[last_pos]); } else { - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", ""); + win_appendln_highlight(window, THEME_ROOMMENTION, ""); } } @@ -441,7 +441,7 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge // no triggers found if (first_trigger_pos == -1) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER, "", "%s", message); + win_appendln_highlight(window, THEME_ROOMTRIGGER, "%s", message); } else { if (first_trigger_pos > 0) { char message_section[strlen(message) + 1]; @@ -451,7 +451,7 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge i++; } message_section[i] = '\0'; - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER, "", "%s", message_section); + win_append_highlight(window, THEME_ROOMTRIGGER, "%s", message_section); } char trigger_section[first_trigger_len + 1]; int i = 0; @@ -462,10 +462,10 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge trigger_section[i] = '\0'; if (first_trigger_pos + first_trigger_len < strlen(message)) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER_TERM, "", "%s", trigger_section); + win_append_highlight(window, THEME_ROOMTRIGGER_TERM, "%s", trigger_section); _mucwin_print_triggers(window, &message[first_trigger_pos + first_trigger_len], triggers); } else { - win_printf(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER_TERM, "", "%s", trigger_section); + win_appendln_highlight(window, THEME_ROOMTRIGGER_TERM, "%s", trigger_section); } } } @@ -480,16 +480,16 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes if (g_strcmp0(nick, mynick) != 0) { if (g_slist_length(mentions) > 0) { - win_printf(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMMENTION, nick, ""); + win_print_them(window, THEME_ROOMMENTION, nick); _mucwin_print_mention(window, message, mynick, mentions); } else if (triggers) { - win_printf(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMTRIGGER, nick, ""); + win_print_them(window, THEME_ROOMTRIGGER, nick); _mucwin_print_triggers(window, message, triggers); } else { - win_printf(window, '-', 0, NULL, NO_ME, THEME_TEXT_THEM, nick, "%s", message); + win_println_them_message(window, nick, "%s", message); } } else { - win_printf(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, "%s", message); + win_println_me_message(window, mynick, "%s", message); } } diff --git a/src/ui/ui.h b/src/ui/ui.h index 6fb97b3e..55f21eea 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -356,9 +356,6 @@ 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_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, ...); @@ -366,6 +363,9 @@ void win_println_indent(ProfWin *window, int pad, const char *const message, ... void win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...); void win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...); +void win_append_highlight(ProfWin *window, theme_item_t theme_item, const char *const message, ...); +void win_appendln_highlight(ProfWin *window, theme_item_t theme_item, 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 6630c60b..71a4f3ae 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -61,6 +61,8 @@ #define CEILING(X) (X-(int)(X) > 0 ? (int)(X+1) : (int)(X)) +static 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, ...); static void _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *time, int flags, theme_item_t theme_item, const char *const from, const char *const message, DeliveryReceipt *receipt); static void _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pad_indent); @@ -997,10 +999,10 @@ win_print_incoming(ProfWin *window, GDateTime *timestamp, } else if (enc_mode == PROF_MSG_PGP) { enc_char = prefs_get_pgp_char(); } - win_printf(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, "%s", message); + _win_printf(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, "%s", message); break; case WIN_PRIVATE: - win_printf(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, "%s", message); + _win_printf(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, "%s", message); break; default: assert(FALSE); @@ -1008,6 +1010,52 @@ win_print_incoming(ProfWin *window, GDateTime *timestamp, } } +void +win_print_them(ProfWin *window, theme_item_t theme_item, const char *const them) +{ + _win_printf(window, '-', 0, NULL, NO_ME | NO_EOL, theme_item, them, ""); +} + +void +win_println_them_message(ProfWin *window, const char *const them, 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, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL); + + _win_print(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL); + inp_nonblocking(TRUE); + g_date_time_unref(timestamp); + + g_string_free(fmt_msg, TRUE); + va_end(arg); +} + +void +win_println_me_message(ProfWin *window, const char *const me, 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, '-', 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL); + + _win_print(window, '-', 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL); + inp_nonblocking(TRUE); + g_date_time_unref(timestamp); + + g_string_free(fmt_msg, TRUE); + va_end(arg); +} + void win_print_outgoing(ProfWin *window, const char ch, const char *const message, ...) { @@ -1048,31 +1096,6 @@ win_print_history(ProfWin *window, GDateTime *timestamp, const char *const messa va_end(arg); } -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, ...) -{ - if (timestamp == NULL) { - timestamp = g_date_time_new_now_local(); - } else { - g_date_time_ref(timestamp); - } - - va_list arg; - va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); - g_string_vprintf(fmt_msg, message, arg); - - buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL); - - _win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL); - inp_nonblocking(TRUE); - g_date_time_unref(timestamp); - - g_string_free(fmt_msg, TRUE); - va_end(arg); -} - void win_print(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...) { @@ -1163,7 +1186,7 @@ win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, '-', 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL); + buffer_push(window->layout->buffer, '-', 0, timestamp, NO_DATE, theme_item, "", fmt_msg->str, NULL); _win_print(window, '-', 0, timestamp, NO_DATE, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE); @@ -1173,6 +1196,46 @@ win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message va_end(arg); } +void +win_append_highlight(ProfWin *window, theme_item_t theme_item, 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, '-', 0, timestamp, NO_DATE | NO_ME | NO_EOL, theme_item, "", fmt_msg->str, NULL); + + _win_print(window, '-', 0, timestamp, NO_DATE | NO_ME | 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_appendln_highlight(ProfWin *window, theme_item_t theme_item, 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, '-', 0, timestamp, NO_DATE | NO_ME, theme_item, "", fmt_msg->str, NULL); + + _win_print(window, '-', 0, timestamp, NO_DATE | NO_ME, 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_print_http_upload(ProfWin *window, const char *const message, char *url) { @@ -1232,6 +1295,31 @@ win_newline(ProfWin *window) win_appendln(window, THEME_DEFAULT, ""); } +static 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, ...) +{ + if (timestamp == NULL) { + timestamp = g_date_time_new_now_local(); + } else { + g_date_time_ref(timestamp); + } + + va_list arg; + va_start(arg, message); + GString *fmt_msg = g_string_new(NULL); + g_string_vprintf(fmt_msg, message, arg); + + buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL); + + _win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL); + inp_nonblocking(TRUE); + g_date_time_unref(timestamp); + + g_string_free(fmt_msg, TRUE); + va_end(arg); +} + static void _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *time, int flags, theme_item_t theme_item, const char *const from, const char *const message, DeliveryReceipt *receipt) diff --git a/src/ui/window.h b/src/ui/window.h index cdc18dfe..e29cd62f 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -60,6 +60,10 @@ void win_show_status_string(ProfWin *window, const char *const from, GDateTime *last_activity, const char *const pre, const char *const default_show); +void win_print_them(ProfWin *window, theme_item_t theme_item, const char *const them); +void win_println_them_message(ProfWin *window, const char *const them, const char *const message, ...); +void win_println_me_message(ProfWin *window, const char *const me, const char *const message, ...); + void win_print_outgoing(ProfWin *window, const char ch, const char *const message, ...); void win_print_incoming(ProfWin *window, GDateTime *timestamp, const char *const from, const char *const message, prof_enc_t enc_mode); From 7ad722ae28aa662333237efb0315119902487858 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 15 Oct 2016 22:17:16 +0100 Subject: [PATCH 28/28] Fix win_append buffer push --- src/ui/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/window.c b/src/ui/window.c index 71a4f3ae..595d6852 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1166,7 +1166,7 @@ win_append(ProfWin *window, theme_item_t theme_item, const char *const message, GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - buffer_push(window->layout->buffer, '-', 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL); + buffer_push(window->layout->buffer, '-', 0, timestamp, NO_DATE | NO_EOL, theme_item, "", fmt_msg->str, NULL); _win_print(window, '-', 0, timestamp, NO_DATE | NO_EOL, theme_item, "", fmt_msg->str, NULL); inp_nonblocking(TRUE);