1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Replaced colours with theme_item_t

This commit is contained in:
James Booth 2014-11-16 20:40:19 +00:00
parent 90dd1de91a
commit ed4391ec8a
13 changed files with 411 additions and 324 deletions

View File

@ -2265,10 +2265,10 @@ cmd_subject(gchar **args, struct cmd_help_t help)
if (args[0] == NULL) { if (args[0] == NULL) {
char *subject = muc_subject(room); char *subject = muc_subject(room);
if (subject) { if (subject) {
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "Room subject: "); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: ");
win_save_vprint(window, '!', NULL, NO_DATE, 0, "", "%s", subject); win_save_vprint(window, '!', NULL, NO_DATE, 0, "", "%s", subject);
} else { } else {
win_save_print(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Room has no subject"); win_save_print(window, '!', NULL, 0, THEME_ROOMINFO, "", "Room has no subject");
} }
return TRUE; return TRUE;
} }
@ -2466,12 +2466,12 @@ cmd_room(gchar **args, struct cmd_help_t help)
if (g_strcmp0(args[0], "accept") == 0) { if (g_strcmp0(args[0], "accept") == 0) {
gboolean requires_config = muc_requires_config(room); gboolean requires_config = muc_requires_config(room);
if (!requires_config) { if (!requires_config) {
win_save_print(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Current room does not require configuration."); win_save_print(window, '!', NULL, 0, THEME_ROOMINFO, "", "Current room does not require configuration.");
return TRUE; return TRUE;
} else { } else {
iq_confirm_instant_room(room); iq_confirm_instant_room(room);
muc_set_requires_config(room, FALSE); muc_set_requires_config(room, FALSE);
win_save_print(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Room unlocked."); win_save_print(window, '!', NULL, 0, THEME_ROOMINFO, "", "Room unlocked.");
return TRUE; return TRUE;
} }
} }

View File

@ -529,3 +529,58 @@ _theme_find(const char * const theme_name)
return path; return path;
} }
int
theme_attrs(theme_item_t attrs)
{
int result = 0;
switch (attrs) {
case THEME_TEXT: result = COLOR_PAIR(1); break;
case THEME_TEXT_ME: result = COLOR_PAIR(2); break;
case THEME_TEXT_THEM: result = COLOR_PAIR(3); break;
case THEME_SPLASH: result = COLOR_PAIR(4); break;
case THEME_ERROR: result = COLOR_PAIR(5); break;
case THEME_INCOMING: result = COLOR_PAIR(6); break;
case THEME_INPUT_TEXT: result = COLOR_PAIR(7); break;
case THEME_TIME: result = COLOR_PAIR(8); break;
case THEME_TITLE_TEXT: result = COLOR_PAIR(9); break;
case THEME_TITLE_BRACKET: result = COLOR_PAIR(10); break;
case THEME_TITLE_UNENCRYPTED: result = COLOR_PAIR(11); break;
case THEME_TITLE_ENCRYPTED: result = COLOR_PAIR(12); break;
case THEME_TITLE_UNTRUSTED: result = COLOR_PAIR(13); break;
case THEME_TITLE_TRUSTED: result = COLOR_PAIR(14); break;
case THEME_TITLE_ONLINE: result = COLOR_PAIR(15); break;
case THEME_TITLE_OFFLINE: result = COLOR_PAIR(16); break;
case THEME_TITLE_AWAY: result = COLOR_PAIR(17); break;
case THEME_TITLE_CHAT: result = COLOR_PAIR(18); break;
case THEME_TITLE_DND: result = COLOR_PAIR(19); break;
case THEME_TITLE_XA: result = COLOR_PAIR(20); break;
case THEME_STATUS_TEXT: result = COLOR_PAIR(21); break;
case THEME_STATUS_BRACKET: result = COLOR_PAIR(22); break;
case THEME_STATUS_ACTIVE: result = COLOR_PAIR(23); break;
case THEME_STATUS_NEW: result = COLOR_PAIR(24); break;
case THEME_ME: result = COLOR_PAIR(25); break;
case THEME_THEM: result = COLOR_PAIR(26); break;
case THEME_ROOMINFO: result = COLOR_PAIR(27); break;
case THEME_ROOMMENTION: result = COLOR_PAIR(28); break;
case THEME_ONLINE: result = COLOR_PAIR(29); break;
case THEME_OFFLINE: result = COLOR_PAIR(30); break;
case THEME_AWAY: result = COLOR_PAIR(31); break;
case THEME_CHAT: result = COLOR_PAIR(32); break;
case THEME_DND: result = COLOR_PAIR(33); break;
case THEME_XA: result = COLOR_PAIR(34); break;
case THEME_TYPING: result = COLOR_PAIR(35); break;
case THEME_GONE: result = COLOR_PAIR(36); break;
case THEME_SUBSCRIBED: result = COLOR_PAIR(37); break;
case THEME_UNSUBSCRIBED: result = COLOR_PAIR(38); break;
case THEME_OTR_STARTED_TRUSTED: result = COLOR_PAIR(39); break;
case THEME_OTR_STARTED_UNTRUSTED: result = COLOR_PAIR(40); break;
case THEME_OTR_ENDED: result = COLOR_PAIR(41); break;
case THEME_OTR_TRUSTED: result = COLOR_PAIR(42); break;
case THEME_OTR_UNTRUSTED: result = COLOR_PAIR(43); break;
default: break;
}
return result;
}

View File

@ -44,54 +44,57 @@
#include <ncurses.h> #include <ncurses.h>
#endif #endif
#define COLOUR_TEXT COLOR_PAIR(1) typedef enum {
#define COLOUR_TEXT_ME COLOR_PAIR(2) THEME_TEXT,
#define COLOUR_TEXT_THEM COLOR_PAIR(3) THEME_TEXT_ME,
#define COLOUR_SPLASH COLOR_PAIR(4) THEME_TEXT_THEM,
#define COLOUR_ERROR COLOR_PAIR(5) THEME_SPLASH,
#define COLOUR_INCOMING COLOR_PAIR(6) THEME_ERROR,
#define COLOUR_INPUT_TEXT COLOR_PAIR(7) THEME_INCOMING,
#define COLOUR_TIME COLOR_PAIR(8) THEME_INPUT_TEXT,
#define COLOUR_TITLE_TEXT COLOR_PAIR(9) THEME_TIME,
#define COLOUR_TITLE_BRACKET COLOR_PAIR(10) THEME_TITLE_TEXT,
#define COLOUR_TITLE_UNENCRYPTED COLOR_PAIR(11) THEME_TITLE_BRACKET,
#define COLOUR_TITLE_ENCRYPTED COLOR_PAIR(12) THEME_TITLE_UNENCRYPTED,
#define COLOUR_TITLE_UNTRUSTED COLOR_PAIR(13) THEME_TITLE_ENCRYPTED,
#define COLOUR_TITLE_TRUSTED COLOR_PAIR(14) THEME_TITLE_UNTRUSTED,
#define COLOUR_TITLE_ONLINE COLOR_PAIR(15) THEME_TITLE_TRUSTED,
#define COLOUR_TITLE_OFFLINE COLOR_PAIR(16) THEME_TITLE_ONLINE,
#define COLOUR_TITLE_AWAY COLOR_PAIR(17) THEME_TITLE_OFFLINE,
#define COLOUR_TITLE_CHAT COLOR_PAIR(18) THEME_TITLE_AWAY,
#define COLOUR_TITLE_DND COLOR_PAIR(19) THEME_TITLE_CHAT,
#define COLOUR_TITLE_XA COLOR_PAIR(20) THEME_TITLE_DND,
#define COLOUR_STATUS_TEXT COLOR_PAIR(21) THEME_TITLE_XA,
#define COLOUR_STATUS_BRACKET COLOR_PAIR(22) THEME_STATUS_TEXT,
#define COLOUR_STATUS_ACTIVE COLOR_PAIR(23) THEME_STATUS_BRACKET,
#define COLOUR_STATUS_NEW COLOR_PAIR(24) THEME_STATUS_ACTIVE,
#define COLOUR_ME COLOR_PAIR(25) THEME_STATUS_NEW,
#define COLOUR_THEM COLOR_PAIR(26) THEME_ME,
#define COLOUR_ROOMINFO COLOR_PAIR(27) THEME_THEM,
#define COLOUR_ROOMMENTION COLOR_PAIR(28) THEME_ROOMINFO,
#define COLOUR_ONLINE COLOR_PAIR(29) THEME_ROOMMENTION,
#define COLOUR_OFFLINE COLOR_PAIR(30) THEME_ONLINE,
#define COLOUR_AWAY COLOR_PAIR(31) THEME_OFFLINE,
#define COLOUR_CHAT COLOR_PAIR(32) THEME_AWAY,
#define COLOUR_DND COLOR_PAIR(33) THEME_CHAT,
#define COLOUR_XA COLOR_PAIR(34) THEME_DND,
#define COLOUR_TYPING COLOR_PAIR(35) THEME_XA,
#define COLOUR_GONE COLOR_PAIR(36) THEME_TYPING,
#define COLOUR_SUBSCRIBED COLOR_PAIR(37) THEME_GONE,
#define COLOUR_UNSUBSCRIBED COLOR_PAIR(38) THEME_SUBSCRIBED,
#define COLOUR_OTR_STARTED_TRUSTED COLOR_PAIR(39) THEME_UNSUBSCRIBED,
#define COLOUR_OTR_STARTED_UNTRUSTED COLOR_PAIR(40) THEME_OTR_STARTED_TRUSTED,
#define COLOUR_OTR_ENDED COLOR_PAIR(41) THEME_OTR_STARTED_UNTRUSTED,
#define COLOUR_OTR_TRUSTED COLOR_PAIR(42) THEME_OTR_ENDED,
#define COLOUR_OTR_UNTRUSTED COLOR_PAIR(43) THEME_OTR_TRUSTED,
THEME_OTR_UNTRUSTED
} theme_item_t;
void theme_init(const char * const theme_name); void theme_init(const char * const theme_name);
void theme_init_colours(void); void theme_init_colours(void);
gboolean theme_load(const char * const theme_name); gboolean theme_load(const char * const theme_name);
GSList* theme_list(void); GSList* theme_list(void);
void theme_close(void); void theme_close(void);
int theme_attrs(theme_item_t attrs);
#endif #endif

View File

@ -81,12 +81,12 @@ buffer_free(ProfBuff buffer)
void void
buffer_push(ProfBuff buffer, const char show_char, GDateTime *time, buffer_push(ProfBuff buffer, const char show_char, GDateTime *time,
int flags, int attrs, const char * const from, const char * const message) int flags, theme_item_t theme_item, const char * const from, const char * const message)
{ {
ProfBuffEntry *e = malloc(sizeof(struct prof_buff_entry_t)); ProfBuffEntry *e = malloc(sizeof(struct prof_buff_entry_t));
e->show_char = show_char; e->show_char = show_char;
e->flags = flags; e->flags = flags;
e->attrs = attrs; e->theme_item = theme_item;
e->time = time; e->time = time;
e->from = strdup(from); e->from = strdup(from);
e->message = strdup(message); e->message = strdup(message);

View File

@ -36,6 +36,7 @@
#define UI_BUFFER_H #define UI_BUFFER_H
#include "config.h" #include "config.h"
#include "config/theme.h"
#include <glib.h> #include <glib.h>
@ -43,7 +44,7 @@ typedef struct prof_buff_entry_t {
char show_char; char show_char;
GDateTime *time; GDateTime *time;
int flags; int flags;
int attrs; theme_item_t theme_item;
char *from; char *from;
char *message; char *message;
} ProfBuffEntry; } ProfBuffEntry;
@ -52,7 +53,7 @@ typedef struct prof_buff_t *ProfBuff;
ProfBuff buffer_create(); ProfBuff buffer_create();
void buffer_free(ProfBuff buffer); void buffer_free(ProfBuff buffer);
void buffer_push(ProfBuff buffer, const char show_char, GDateTime *time, int flags, int attrs, const char * const from, const char * const message); void buffer_push(ProfBuff buffer, const char show_char, GDateTime *time, int flags, theme_item_t theme_item, const char * const from, const char * const message);
int buffer_size(ProfBuff buffer); int buffer_size(ProfBuff buffer);
ProfBuffEntry* buffer_yield_entry(ProfBuff buffer, int entry); ProfBuffEntry* buffer_yield_entry(ProfBuff buffer, int entry);
#endif #endif

View File

@ -113,7 +113,7 @@ _cons_show_error(const char * const msg, ...)
va_start(arg, msg); va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, msg, arg); g_string_vprintf(fmt_msg, msg, arg);
win_save_print(console, '-', NULL, 0, COLOUR_ERROR, "", fmt_msg->str); win_save_print(console, '-', NULL, 0, THEME_ERROR, "", fmt_msg->str);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
va_end(arg); va_end(arg);
@ -136,7 +136,7 @@ _cons_show_typing(const char * const barejid)
display_usr = barejid; display_usr = barejid;
} }
win_save_vprint(console, '-', NULL, 0, COLOUR_TYPING, "", "!! %s is typing a message...", display_usr); win_save_vprint(console, '-', NULL, 0, THEME_TYPING, "", "!! %s is typing a message...", display_usr);
cons_alert(); cons_alert();
} }
@ -149,7 +149,7 @@ _cons_show_incoming_message(const char * const short_from, const int win_index)
if (ui_index == 10) { if (ui_index == 10) {
ui_index = 0; ui_index = 0;
} }
win_save_vprint(console, '-', NULL, 0, COLOUR_INCOMING, "", "<< incoming from %s (%d)", short_from, ui_index); win_save_vprint(console, '-', NULL, 0, THEME_INCOMING, "", "<< incoming from %s (%d)", short_from, ui_index);
cons_alert(); cons_alert();
} }
@ -453,10 +453,10 @@ _cons_show_bookmarks(const GList *list)
while (list != NULL) { while (list != NULL) {
Bookmark *item = list->data; Bookmark *item = list->data;
int presence_colour = 0; theme_item_t presence_colour = THEME_TEXT;
if (muc_active(item->jid)) { if (muc_active(item->jid)) {
presence_colour = COLOUR_ONLINE; presence_colour = THEME_ONLINE;
} }
win_save_vprint(console, '-', NULL, NO_EOL, presence_colour, "", " %s", item->jid); win_save_vprint(console, '-', NULL, NO_EOL, presence_colour, "", " %s", item->jid);
if (item->nick != NULL) { if (item->nick != NULL) {
@ -1485,14 +1485,14 @@ _cons_splash_logo(void)
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
win_save_println(console, "Welcome to"); win_save_println(console, "Welcome to");
win_save_print(console, '-', NULL, 0, COLOUR_SPLASH, "", " ___ _ "); win_save_print(console, '-', NULL, 0, THEME_SPLASH, "", " ___ _ ");
win_save_print(console, '-', NULL, 0, COLOUR_SPLASH, "", " / __) (_)_ "); win_save_print(console, '-', NULL, 0, THEME_SPLASH, "", " / __) (_)_ ");
win_save_print(console, '-', NULL, 0, COLOUR_SPLASH, "", " ____ ____ ___ | |__ ____ ____ _| |_ _ _ "); win_save_print(console, '-', NULL, 0, THEME_SPLASH, "", " ____ ____ ___ | |__ ____ ____ _| |_ _ _ ");
win_save_print(console, '-', NULL, 0, COLOUR_SPLASH, "", "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |"); win_save_print(console, '-', NULL, 0, THEME_SPLASH, "", "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |");
win_save_print(console, '-', NULL, 0, COLOUR_SPLASH, "", "| | | | | | |_| | | ( ( | | | | | | |_| |_| |"); win_save_print(console, '-', NULL, 0, THEME_SPLASH, "", "| | | | | | |_| | | ( ( | | | | | | |_| |_| |");
win_save_print(console, '-', NULL, 0, COLOUR_SPLASH, "", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |"); win_save_print(console, '-', NULL, 0, THEME_SPLASH, "", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |");
win_save_print(console, '-', NULL, 0, COLOUR_SPLASH, "", "|_| (____/ "); win_save_print(console, '-', NULL, 0, THEME_SPLASH, "", "|_| (____/ ");
win_save_print(console, '-', NULL, 0, COLOUR_SPLASH, "", ""); win_save_print(console, '-', NULL, 0, THEME_SPLASH, "", "");
if (strcmp(PACKAGE_STATUS, "development") == 0) { if (strcmp(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION #ifdef HAVE_GIT_VERSION
@ -1522,7 +1522,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
} }
const char *presence = p_contact_presence(contact); const char *presence = p_contact_presence(contact);
int presence_colour; theme_item_t presence_colour = THEME_TEXT;
if (p_contact_subscribed(contact)) { if (p_contact_subscribed(contact)) {
presence_colour = win_presence_colour(presence); presence_colour = win_presence_colour(presence);
} else { } else {
@ -1542,9 +1542,9 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
sub = g_string_append(sub, ", request received"); sub = g_string_append(sub, ", request received");
} }
if (p_contact_subscribed(contact)) { if (p_contact_subscribed(contact)) {
presence_colour = COLOUR_SUBSCRIBED; presence_colour = THEME_SUBSCRIBED;
} else { } else {
presence_colour = COLOUR_UNSUBSCRIBED; presence_colour = THEME_UNSUBSCRIBED;
} }
if (show_groups) { if (show_groups) {

View File

@ -248,12 +248,12 @@ _ui_handle_stanza(const char * const msg)
if (g_str_has_prefix(msg, "SENT:")) { if (g_str_has_prefix(msg, "SENT:")) {
win_save_print(xmlconsole, '-', NULL, 0, 0, "", "SENT:"); win_save_print(xmlconsole, '-', NULL, 0, 0, "", "SENT:");
win_save_print(xmlconsole, '-', NULL, 0, COLOUR_ONLINE, "", &msg[6]); win_save_print(xmlconsole, '-', NULL, 0, THEME_ONLINE, "", &msg[6]);
win_save_print(xmlconsole, '-', NULL, 0, COLOUR_ONLINE, "", ""); win_save_print(xmlconsole, '-', NULL, 0, THEME_ONLINE, "", "");
} else if (g_str_has_prefix(msg, "RECV:")) { } else if (g_str_has_prefix(msg, "RECV:")) {
win_save_print(xmlconsole, '-', NULL, 0, 0, "", "RECV:"); win_save_print(xmlconsole, '-', NULL, 0, 0, "", "RECV:");
win_save_print(xmlconsole, '-', NULL, 0, COLOUR_AWAY, "", &msg[6]); win_save_print(xmlconsole, '-', NULL, 0, THEME_AWAY, "", &msg[6]);
win_save_print(xmlconsole, '-', NULL, 0, COLOUR_AWAY, "", ""); win_save_print(xmlconsole, '-', NULL, 0, THEME_AWAY, "", "");
} }
} }
} }
@ -517,13 +517,13 @@ _ui_handle_recipient_not_found(const char * const recipient, const char * const
} else if (win->type == WIN_MUC) { } else if (win->type == WIN_MUC) {
g_string_printf(msg, "Room %s not found: %s", recipient, err_msg); g_string_printf(msg, "Room %s not found: %s", recipient, err_msg);
cons_show_error(msg->str); cons_show_error(msg->str);
win_save_print(win, '!', NULL, 0, COLOUR_ERROR, "", msg->str); win_save_print(win, '!', NULL, 0, THEME_ERROR, "", msg->str);
// unknown chat recipient // unknown chat recipient
} else { } else {
g_string_printf(msg, "Recipient %s not found: %s", recipient, err_msg); g_string_printf(msg, "Recipient %s not found: %s", recipient, err_msg);
cons_show_error(msg->str); cons_show_error(msg->str);
win_save_print(win, '!', NULL, 0, COLOUR_ERROR, "", msg->str); win_save_print(win, '!', NULL, 0, THEME_ERROR, "", msg->str);
} }
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
@ -541,7 +541,7 @@ _ui_handle_recipient_error(const char * const recipient, const char * const err_
// show in window if exists for recipient // show in window if exists for recipient
if (win != NULL) { if (win != NULL) {
win_save_print(win, '!', NULL, 0, COLOUR_ERROR, "", msg->str); win_save_print(win, '!', NULL, 0, THEME_ERROR, "", msg->str);
} }
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
@ -838,9 +838,9 @@ _ui_gone_secure(const char * const recipient, gboolean trusted)
window->is_otr = TRUE; window->is_otr = TRUE;
window->is_trusted = trusted; window->is_trusted = trusted;
if (trusted) { if (trusted) {
win_save_print(window, '!', NULL, 0, COLOUR_OTR_STARTED_TRUSTED, "", "OTR session started (trusted)."); win_save_print(window, '!', NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "OTR session started (trusted).");
} else { } else {
win_save_print(window, '!', NULL, 0, COLOUR_OTR_STARTED_UNTRUSTED, "", "OTR session started (untrusted)."); win_save_print(window, '!', NULL, 0, THEME_OTR_STARTED_UNTRUSTED, "", "OTR session started (untrusted).");
} }
if (wins_is_current(window)) { if (wins_is_current(window)) {
@ -957,7 +957,7 @@ _ui_gone_insecure(const char * const recipient)
if (window != NULL) { if (window != NULL) {
window->is_otr = FALSE; window->is_otr = FALSE;
window->is_trusted = FALSE; window->is_trusted = FALSE;
win_save_print(window, '!', NULL, 0, COLOUR_OTR_ENDED, "", "OTR session ended."); win_save_print(window, '!', NULL, 0, THEME_OTR_ENDED, "", "OTR session ended.");
if (wins_is_current(window)) { if (wins_is_current(window)) {
GString *recipient_str = _get_recipient_string(window); GString *recipient_str = _get_recipient_string(window);
@ -974,7 +974,7 @@ _ui_trust(const char * const recipient)
if (window != NULL) { if (window != NULL) {
window->is_otr = TRUE; window->is_otr = TRUE;
window->is_trusted = TRUE; window->is_trusted = TRUE;
win_save_print(window, '!', NULL, 0, COLOUR_OTR_TRUSTED, "", "OTR session trusted."); win_save_print(window, '!', NULL, 0, THEME_OTR_TRUSTED, "", "OTR session trusted.");
if (wins_is_current(window)) { if (wins_is_current(window)) {
GString *recipient_str = _get_recipient_string(window); GString *recipient_str = _get_recipient_string(window);
@ -991,7 +991,7 @@ _ui_untrust(const char * const recipient)
if (window != NULL) { if (window != NULL) {
window->is_otr = TRUE; window->is_otr = TRUE;
window->is_trusted = FALSE; window->is_trusted = FALSE;
win_save_print(window, '!', NULL, 0, COLOUR_OTR_UNTRUSTED, "", "OTR session untrusted."); win_save_print(window, '!', NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted.");
if (wins_is_current(window)) { if (wins_is_current(window)) {
GString *recipient_str = _get_recipient_string(window); GString *recipient_str = _get_recipient_string(window);
@ -1197,7 +1197,7 @@ static void
_ui_current_error_line(const char * const msg) _ui_current_error_line(const char * const msg)
{ {
ProfWin *current = wins_get_current(); ProfWin *current = wins_get_current();
win_save_print(current, '-', NULL, 0, COLOUR_ERROR, "", msg); win_save_print(current, '-', NULL, 0, THEME_ERROR, "", msg);
} }
static void static void
@ -1247,7 +1247,7 @@ _ui_recipient_gone(const char * const barejid)
ProfWin *window = wins_get_by_recipient(barejid); ProfWin *window = wins_get_by_recipient(barejid);
if (window != NULL) { if (window != NULL) {
win_save_vprint(window, '!', NULL, 0, COLOUR_GONE, "", "<- %s has left the conversation.", display_usr); win_save_vprint(window, '!', NULL, 0, THEME_GONE, "", "<- %s has left the conversation.", display_usr);
} }
} }
@ -1351,7 +1351,7 @@ _ui_outgoing_msg(const char * const from, const char * const to,
num = wins_get_num(window); num = wins_get_num(window);
} }
win_save_print(window, '-', NULL, 0, COLOUR_TEXT_ME, from, message); win_save_print(window, '-', NULL, 0, THEME_TEXT_ME, from, message);
ui_switch_win(num); ui_switch_win(num);
} }
@ -1367,18 +1367,18 @@ _ui_room_join(const char * const room, gboolean focus)
} }
char *nick = muc_nick(room); char *nick = muc_nick(room);
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "-> You have joined the room as %s", nick); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "-> You have joined the room as %s", nick);
if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) {
char *role = muc_role_str(room); char *role = muc_role_str(room);
char *affiliation = muc_affiliation_str(room); char *affiliation = muc_affiliation_str(room);
if (role) { if (role) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", role: %s", role); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", role: %s", role);
} }
if (affiliation) { if (affiliation) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", affiliation: %s", affiliation); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", affiliation: %s", affiliation);
} }
} }
win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", ""); win_save_print(window, '!', NULL, NO_DATE, THEME_ROOMINFO, "", "");
num = wins_get_num(window); num = wins_get_num(window);
@ -1388,7 +1388,7 @@ _ui_room_join(const char * const room, gboolean focus)
status_bar_active(num); status_bar_active(num);
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
char *nick = muc_nick(room); char *nick = muc_nick(room);
win_save_vprint(console, '!', NULL, 0, COLOUR_TYPING, "", "-> Autojoined %s as %s (%d).", room, nick, num); win_save_vprint(console, '!', NULL, 0, THEME_TYPING, "", "-> Autojoined %s as %s (%d).", room, nick, num);
} }
} }
@ -1406,14 +1406,14 @@ _ui_room_role_change(const char * const room, const char * const role, const cha
const char * const reason) const char * const reason)
{ {
ProfWin *window = wins_get_by_recipient(room); ProfWin *window = wins_get_by_recipient(room);
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "Your role has been changed to: %s", role); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "Your role has been changed to: %s", role);
if (actor) { if (actor) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", by: %s", actor); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor);
} }
if (reason) { if (reason) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", reason: %s", reason); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason);
} }
win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", ""); win_save_print(window, '!', NULL, NO_DATE, THEME_ROOMINFO, "", "");
} }
static void static void
@ -1421,14 +1421,14 @@ _ui_room_affiliation_change(const char * const room, const char * const affiliat
const char * const reason) const char * const reason)
{ {
ProfWin *window = wins_get_by_recipient(room); ProfWin *window = wins_get_by_recipient(room);
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "Your affiliation has been changed to: %s", affiliation); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "Your affiliation has been changed to: %s", affiliation);
if (actor) { if (actor) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", by: %s", actor); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor);
} }
if (reason) { if (reason) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", reason: %s", reason); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason);
} }
win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", ""); win_save_print(window, '!', NULL, NO_DATE, THEME_ROOMINFO, "", "");
} }
static void static void
@ -1436,14 +1436,14 @@ _ui_room_role_and_affiliation_change(const char * const room, const char * const
const char * const actor, const char * const reason) const char * const actor, const char * const reason)
{ {
ProfWin *window = wins_get_by_recipient(room); ProfWin *window = wins_get_by_recipient(room);
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation);
if (actor) { if (actor) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", by: %s", actor); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor);
} }
if (reason) { if (reason) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", reason: %s", reason); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason);
} }
win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", ""); win_save_print(window, '!', NULL, NO_DATE, THEME_ROOMINFO, "", "");
} }
@ -1452,14 +1452,14 @@ _ui_room_occupant_role_change(const char * const room, const char * const nick,
const char * const actor, const char * const reason) const char * const actor, const char * const reason)
{ {
ProfWin *window = wins_get_by_recipient(room); ProfWin *window = wins_get_by_recipient(room);
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "%s's role has been changed to: %s", nick, role); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "%s's role has been changed to: %s", nick, role);
if (actor) { if (actor) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", by: %s", actor); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor);
} }
if (reason) { if (reason) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", reason: %s", reason); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason);
} }
win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", ""); win_save_print(window, '!', NULL, NO_DATE, THEME_ROOMINFO, "", "");
} }
static void static void
@ -1467,14 +1467,14 @@ _ui_room_occupant_affiliation_change(const char * const room, const char * const
const char * const actor, const char * const reason) const char * const actor, const char * const reason)
{ {
ProfWin *window = wins_get_by_recipient(room); ProfWin *window = wins_get_by_recipient(room);
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "%s's affiliation has been changed to: %s", nick, affiliation); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "%s's affiliation has been changed to: %s", nick, affiliation);
if (actor) { if (actor) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", by: %s", actor); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor);
} }
if (reason) { if (reason) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", reason: %s", reason); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason);
} }
win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", ""); win_save_print(window, '!', NULL, NO_DATE, THEME_ROOMINFO, "", "");
} }
static void static void
@ -1482,14 +1482,14 @@ _ui_room_occupant_role_and_affiliation_change(const char * const room, const cha
const char * const affiliation, const char * const actor, const char * const reason) const char * const affiliation, const char * const actor, const char * const reason)
{ {
ProfWin *window = wins_get_by_recipient(room); ProfWin *window = wins_get_by_recipient(room);
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation);
if (actor) { if (actor) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", by: %s", actor); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor);
} }
if (reason) { if (reason) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", reason: %s", reason); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason);
} }
win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", ""); win_save_print(window, '!', NULL, NO_DATE, THEME_ROOMINFO, "", "");
} }
static void static void
@ -1552,16 +1552,16 @@ _ui_room_roster(const char * const room, GList *roster, const char * const prese
} else { } else {
if ((roster == NULL) || (g_list_length(roster) == 0)) { if ((roster == NULL) || (g_list_length(roster) == 0)) {
if (presence == NULL) { if (presence == NULL) {
win_save_print(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Room is empty."); win_save_print(window, '!', NULL, 0, THEME_ROOMINFO, "", "Room is empty.");
} else { } else {
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "No occupants %s.", presence); win_save_vprint(window, '!', NULL, 0, THEME_ROOMINFO, "", "No occupants %s.", presence);
} }
} else { } else {
int length = g_list_length(roster); int length = g_list_length(roster);
if (presence == NULL) { if (presence == NULL) {
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "%d occupants: ", length); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "%d occupants: ", length);
} else { } else {
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "%d %s: ", length, presence); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "%d %s: ", length, presence);
} }
while (roster != NULL) { while (roster != NULL) {
@ -1577,7 +1577,7 @@ _ui_room_roster(const char * const room, GList *roster, const char * const prese
roster = g_list_next(roster); roster = g_list_next(roster);
} }
win_save_print(window, '!', NULL, NO_DATE, COLOUR_ONLINE, "", ""); win_save_print(window, '!', NULL, NO_DATE, THEME_ONLINE, "", "");
} }
} }
@ -1596,7 +1596,7 @@ _ui_room_member_offline(const char * const room, const char * const nick)
if (window == NULL) { if (window == NULL) {
log_error("Received offline presence for room participant %s, but no window open for %s.", nick, room); log_error("Received offline presence for room participant %s, but no window open for %s.", nick, room);
} else { } else {
win_save_vprint(window, '!', NULL, 0, COLOUR_OFFLINE, "", "<- %s has left the room.", nick); win_save_vprint(window, '!', NULL, 0, THEME_OFFLINE, "", "<- %s has left the room.", nick);
} }
} }
@ -1619,7 +1619,7 @@ _ui_room_member_kicked(const char * const room, const char * const nick, const c
g_string_append(message, reason); g_string_append(message, reason);
} }
win_save_vprint(window, '!', NULL, 0, COLOUR_OFFLINE, "", "<- %s", message->str); win_save_vprint(window, '!', NULL, 0, THEME_OFFLINE, "", "<- %s", message->str);
g_string_free(message, TRUE); g_string_free(message, TRUE);
} }
} }
@ -1643,7 +1643,7 @@ _ui_room_member_banned(const char * const room, const char * const nick, const c
g_string_append(message, reason); g_string_append(message, reason);
} }
win_save_vprint(window, '!', NULL, 0, COLOUR_OFFLINE, "", "<- %s", message->str); win_save_vprint(window, '!', NULL, 0, THEME_OFFLINE, "", "<- %s", message->str);
g_string_free(message, TRUE); g_string_free(message, TRUE);
} }
} }
@ -1656,16 +1656,16 @@ _ui_room_member_online(const char * const room, const char * const nick, const c
if (window == NULL) { if (window == NULL) {
log_error("Received online presence for room participant %s, but no window open for %s.", nick, room); log_error("Received online presence for room participant %s, but no window open for %s.", nick, room);
} else { } else {
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ONLINE, "", "-> %s has joined the room", nick); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ONLINE, "", "-> %s has joined the room", nick);
if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) {
if (role) { if (role) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ONLINE, "", ", role: %s", role); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", role: %s", role);
} }
if (affiliation) { if (affiliation) {
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ONLINE, "", ", affiliation: %s", affiliation); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", affiliation: %s", affiliation);
} }
} }
win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", ""); win_save_print(window, '!', NULL, NO_DATE, THEME_ROOMINFO, "", "");
} }
} }
@ -1689,7 +1689,7 @@ _ui_room_member_nick_change(const char * const room,
if (window == NULL) { if (window == NULL) {
log_error("Received nick change for room participant %s, but no window open for %s.", old_nick, room); log_error("Received nick change for room participant %s, but no window open for %s.", old_nick, room);
} else { } else {
win_save_vprint(window, '!', NULL, 0, COLOUR_THEM, "", "** %s is now known as %s", old_nick, nick); win_save_vprint(window, '!', NULL, 0, THEME_THEM, "", "** %s is now known as %s", old_nick, nick);
} }
} }
@ -1700,7 +1700,7 @@ _ui_room_nick_change(const char * const room, const char * const nick)
if (window == NULL) { if (window == NULL) {
log_error("Received self nick change %s, but no window open for %s.", nick, room); log_error("Received self nick change %s, but no window open for %s.", nick, room);
} else { } else {
win_save_vprint(window, '!', NULL, 0, COLOUR_ME, "", "** You are now known as %s", nick); win_save_vprint(window, '!', NULL, 0, THEME_ME, "", "** You are now known as %s", nick);
} }
} }
@ -1742,12 +1742,12 @@ _ui_room_message(const char * const room_jid, const char * const nick,
if (g_strcmp0(nick, my_nick) != 0) { if (g_strcmp0(nick, my_nick) != 0) {
if (g_strrstr(message, my_nick) != NULL) { if (g_strrstr(message, my_nick) != NULL) {
win_save_print(window, '-', NULL, NO_ME, COLOUR_ROOMMENTION, nick, message); win_save_print(window, '-', NULL, NO_ME, THEME_ROOMMENTION, nick, message);
} else { } else {
win_save_print(window, '-', NULL, NO_ME, COLOUR_TEXT_THEM, nick, message); win_save_print(window, '-', NULL, NO_ME, THEME_TEXT_THEM, nick, message);
} }
} else { } else {
win_save_print(window, '-', NULL, 0, COLOUR_TEXT_ME, nick, message); win_save_print(window, '-', NULL, 0, THEME_TEXT_ME, nick, message);
} }
// currently in groupchat window // currently in groupchat window
@ -1824,13 +1824,13 @@ _ui_room_requires_config(const char * const room_jid)
} }
win_save_print(window, '-', NULL, 0, 0, "", ""); win_save_print(window, '-', NULL, 0, 0, "", "");
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", win_save_vprint(window, '!', NULL, 0, THEME_ROOMINFO, "",
"Room locked, requires configuration."); "Room locked, requires configuration.");
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", win_save_vprint(window, '!', NULL, 0, THEME_ROOMINFO, "",
"Use '/room accept' to accept the defaults"); "Use '/room accept' to accept the defaults");
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", win_save_vprint(window, '!', NULL, 0, THEME_ROOMINFO, "",
"Use '/room destroy' to cancel and destroy the room"); "Use '/room destroy' to cancel and destroy the room");
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", win_save_vprint(window, '!', NULL, 0, THEME_ROOMINFO, "",
"Use '/room config' to edit the room configuration"); "Use '/room config' to edit the room configuration");
win_save_print(window, '-', NULL, 0, 0, "", ""); win_save_print(window, '-', NULL, 0, 0, "", "");
@ -1881,16 +1881,16 @@ _ui_room_destroyed(const char * const room, const char * const reason, const cha
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
if (reason) { if (reason) {
win_save_vprint(console, '!', NULL, 0, COLOUR_TYPING, "", "<- Room destroyed: %s, reason: %s", room, reason); win_save_vprint(console, '!', NULL, 0, THEME_TYPING, "", "<- Room destroyed: %s, reason: %s", room, reason);
} else { } else {
win_save_vprint(console, '!', NULL, 0, COLOUR_TYPING, "", "<- Room destroyed: %s", room); win_save_vprint(console, '!', NULL, 0, THEME_TYPING, "", "<- Room destroyed: %s", room);
} }
if (new_jid) { if (new_jid) {
if (password) { if (password) {
win_save_vprint(console, '!', NULL, 0, COLOUR_TYPING, "", "Replacement room: %s, password: %s", new_jid, password); win_save_vprint(console, '!', NULL, 0, THEME_TYPING, "", "Replacement room: %s, password: %s", new_jid, password);
} else { } else {
win_save_vprint(console, '!', NULL, 0, COLOUR_TYPING, "", "Replacement room: %s", new_jid); win_save_vprint(console, '!', NULL, 0, THEME_TYPING, "", "Replacement room: %s", new_jid);
} }
} }
} }
@ -1918,7 +1918,7 @@ _ui_room_kicked(const char * const room, const char * const actor, const char *
} }
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
win_save_vprint(console, '!', NULL, 0, COLOUR_TYPING, "", "<- %s", message->str); win_save_vprint(console, '!', NULL, 0, THEME_TYPING, "", "<- %s", message->str);
g_string_free(message, TRUE); g_string_free(message, TRUE);
} }
} }
@ -1945,7 +1945,7 @@ _ui_room_banned(const char * const room, const char * const actor, const char *
} }
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
win_save_vprint(console, '!', NULL, 0, COLOUR_TYPING, "", "<- %s", message->str); win_save_vprint(console, '!', NULL, 0, THEME_TYPING, "", "<- %s", message->str);
g_string_free(message, TRUE); g_string_free(message, TRUE);
} }
} }
@ -1961,17 +1961,17 @@ _ui_room_subject(const char * const room, const char * const nick, const char *
if (subject) { if (subject) {
if (nick) { if (nick) {
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "*%s has set the room subject: ", nick); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "*%s has set the room subject: ", nick);
win_save_vprint(window, '!', NULL, NO_DATE, 0, "", "%s", subject); win_save_vprint(window, '!', NULL, NO_DATE, 0, "", "%s", subject);
} else { } else {
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "Room subject: "); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: ");
win_save_vprint(window, '!', NULL, NO_DATE, 0, "", "%s", subject); win_save_vprint(window, '!', NULL, NO_DATE, 0, "", "%s", subject);
} }
} else { } else {
if (nick) { if (nick) {
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "*%s has cleared the room subject: ", nick); win_save_vprint(window, '!', NULL, 0, THEME_ROOMINFO, "", "*%s has cleared the room subject: ", nick);
} else { } else {
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Room subject cleared"); win_save_vprint(window, '!', NULL, 0, THEME_ROOMINFO, "", "Room subject cleared");
} }
} }
@ -1993,7 +1993,7 @@ _ui_handle_room_kick_error(const char * const room, const char * const nick, con
if (window == NULL) { if (window == NULL) {
log_error("Kick error received for %s, but no window open for %s.", nick, room); log_error("Kick error received for %s, but no window open for %s.", nick, room);
} else { } else {
win_save_vprint(window, '!', NULL, 0, COLOUR_ERROR, "", "Error kicking %s: %s", nick, error); win_save_vprint(window, '!', NULL, 0, THEME_ERROR, "", "Error kicking %s: %s", nick, error);
} }
} }
@ -2006,7 +2006,7 @@ _ui_room_broadcast(const char * const room_jid, const char * const message)
} else { } else {
int num = wins_get_num(window); int num = wins_get_num(window);
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "Room message: "); win_save_vprint(window, '!', NULL, NO_EOL, THEME_ROOMINFO, "", "Room message: ");
win_save_vprint(window, '!', NULL, NO_DATE, 0, "", "%s", message); win_save_vprint(window, '!', NULL, NO_DATE, 0, "", "%s", message);
// currently in groupchat window // currently in groupchat window
@ -2026,7 +2026,7 @@ _ui_handle_room_affiliation_list_error(const char * const room, const char * con
{ {
ProfWin *window = wins_get_by_recipient(room); ProfWin *window = wins_get_by_recipient(room);
if (window) { if (window) {
win_save_vprint(window, '!', NULL, 0, COLOUR_ERROR, "", "Error retrieving %s list: %s", affiliation, error); win_save_vprint(window, '!', NULL, 0, THEME_ERROR, "", "Error retrieving %s list: %s", affiliation, error);
} }
} }
@ -2056,7 +2056,7 @@ _ui_handle_room_role_list_error(const char * const room, const char * const role
{ {
ProfWin *window = wins_get_by_recipient(room); ProfWin *window = wins_get_by_recipient(room);
if (window) { if (window) {
win_save_vprint(window, '!', NULL, 0, COLOUR_ERROR, "", "Error retrieving %s list: %s", role, error); win_save_vprint(window, '!', NULL, 0, THEME_ERROR, "", "Error retrieving %s list: %s", role, error);
} }
} }
@ -2096,7 +2096,7 @@ _ui_handle_room_affiliation_set_error(const char * const room, const char * cons
{ {
ProfWin *window = wins_get_by_recipient(room); ProfWin *window = wins_get_by_recipient(room);
if (window) { if (window) {
win_save_vprint(window, '!', NULL, 0, COLOUR_ERROR, "", "Error setting %s affiliation for %s: %s", affiliation, jid, error); win_save_vprint(window, '!', NULL, 0, THEME_ERROR, "", "Error setting %s affiliation for %s: %s", affiliation, jid, error);
} }
} }
@ -2106,7 +2106,7 @@ _ui_handle_room_role_set_error(const char * const room, const char * const nick,
{ {
ProfWin *window = wins_get_by_recipient(room); ProfWin *window = wins_get_by_recipient(room);
if (window) { if (window) {
win_save_vprint(window, '!', NULL, 0, COLOUR_ERROR, "", "Error setting %s role for %s: %s", role, nick, error); win_save_vprint(window, '!', NULL, 0, THEME_ERROR, "", "Error setting %s role for %s: %s", role, nick, error);
} }
} }
@ -2425,7 +2425,7 @@ _ui_show_room_affiliation_list(ProfWin *window, const char * const room, muc_aff
static void static void
_ui_handle_form_field(ProfWin *window, char *tag, FormField *field) _ui_handle_form_field(ProfWin *window, char *tag, FormField *field)
{ {
win_save_vprint(window, '-', NULL, NO_EOL, COLOUR_AWAY, "", "[%s] ", tag); win_save_vprint(window, '-', NULL, NO_EOL, THEME_AWAY, "", "[%s] ", tag);
win_save_vprint(window, '-', NULL, NO_EOL | NO_DATE, 0, "", "%s", field->label); win_save_vprint(window, '-', NULL, NO_EOL | NO_DATE, 0, "", "%s", field->label);
if (field->required) { if (field->required) {
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", " (required): "); win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", " (required): ");
@ -2444,9 +2444,9 @@ _ui_handle_form_field(ProfWin *window, char *tag, FormField *field)
char *value = curr_value->data; char *value = curr_value->data;
if (value != NULL) { if (value != NULL) {
if (g_strcmp0(field->var, "muc#roomconfig_roomsecret") == 0) { if (g_strcmp0(field->var, "muc#roomconfig_roomsecret") == 0) {
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, COLOUR_ONLINE, "", "[hidden]"); win_save_print(window, '-', NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]");
} else { } else {
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, COLOUR_ONLINE, "", value); win_save_print(window, '-', NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value);
} }
} }
} }
@ -2456,7 +2456,7 @@ _ui_handle_form_field(ProfWin *window, char *tag, FormField *field)
if (curr_value != NULL) { if (curr_value != NULL) {
char *value = curr_value->data; char *value = curr_value->data;
if (value != NULL) { if (value != NULL) {
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, COLOUR_ONLINE, "", "[hidden]"); win_save_print(window, '-', NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]");
} }
} }
win_save_newline(window); win_save_newline(window);
@ -2468,23 +2468,23 @@ _ui_handle_form_field(ProfWin *window, char *tag, FormField *field)
char *value = curr_value->data; char *value = curr_value->data;
GString *val_tag = g_string_new(""); GString *val_tag = g_string_new("");
g_string_printf(val_tag, "val%d", index++); g_string_printf(val_tag, "val%d", index++);
win_save_vprint(window, '-', NULL, 0, COLOUR_ONLINE, "", " [%s] %s", val_tag->str, value); win_save_vprint(window, '-', NULL, 0, THEME_ONLINE, "", " [%s] %s", val_tag->str, value);
g_string_free(val_tag, TRUE); g_string_free(val_tag, TRUE);
curr_value = g_slist_next(curr_value); curr_value = g_slist_next(curr_value);
} }
break; break;
case FIELD_BOOLEAN: case FIELD_BOOLEAN:
if (curr_value == NULL) { if (curr_value == NULL) {
win_save_print(window, '-', NULL, NO_DATE, COLOUR_OFFLINE, "", "FALSE"); win_save_print(window, '-', NULL, NO_DATE, THEME_OFFLINE, "", "FALSE");
} else { } else {
char *value = curr_value->data; char *value = curr_value->data;
if (value == NULL) { if (value == NULL) {
win_save_print(window, '-', NULL, NO_DATE, COLOUR_OFFLINE, "", "FALSE"); win_save_print(window, '-', NULL, NO_DATE, THEME_OFFLINE, "", "FALSE");
} else { } else {
if (g_strcmp0(value, "0") == 0) { if (g_strcmp0(value, "0") == 0) {
win_save_print(window, '-', NULL, NO_DATE, COLOUR_OFFLINE, "", "FALSE"); win_save_print(window, '-', NULL, NO_DATE, THEME_OFFLINE, "", "FALSE");
} else { } else {
win_save_print(window, '-', NULL, NO_DATE, COLOUR_ONLINE, "", "TRUE"); win_save_print(window, '-', NULL, NO_DATE, THEME_ONLINE, "", "TRUE");
} }
} }
} }
@ -2498,9 +2498,9 @@ _ui_handle_form_field(ProfWin *window, char *tag, FormField *field)
while (curr_option != NULL) { while (curr_option != NULL) {
FormOption *option = curr_option->data; FormOption *option = curr_option->data;
if (g_strcmp0(option->value, value) == 0) { if (g_strcmp0(option->value, value) == 0) {
win_save_vprint(window, '-', NULL, 0, COLOUR_ONLINE, "", " [%s] %s", option->value, option->label); win_save_vprint(window, '-', NULL, 0, THEME_ONLINE, "", " [%s] %s", option->value, option->label);
} else { } else {
win_save_vprint(window, '-', NULL, 0, COLOUR_OFFLINE, "", " [%s] %s", option->value, option->label); win_save_vprint(window, '-', NULL, 0, THEME_OFFLINE, "", " [%s] %s", option->value, option->label);
} }
curr_option = g_slist_next(curr_option); curr_option = g_slist_next(curr_option);
} }
@ -2514,9 +2514,9 @@ _ui_handle_form_field(ProfWin *window, char *tag, FormField *field)
while (curr_option != NULL) { while (curr_option != NULL) {
FormOption *option = curr_option->data; FormOption *option = curr_option->data;
if (g_slist_find_custom(curr_value, option->value, (GCompareFunc)g_strcmp0) != NULL) { if (g_slist_find_custom(curr_value, option->value, (GCompareFunc)g_strcmp0) != NULL) {
win_save_vprint(window, '-', NULL, 0, COLOUR_ONLINE, "", " [%s] %s", option->value, option->label); win_save_vprint(window, '-', NULL, 0, THEME_ONLINE, "", " [%s] %s", option->value, option->label);
} else { } else {
win_save_vprint(window, '-', NULL, 0, COLOUR_OFFLINE, "", " [%s] %s", option->value, option->label); win_save_vprint(window, '-', NULL, 0, THEME_OFFLINE, "", " [%s] %s", option->value, option->label);
} }
curr_option = g_slist_next(curr_option); curr_option = g_slist_next(curr_option);
} }
@ -2526,7 +2526,7 @@ _ui_handle_form_field(ProfWin *window, char *tag, FormField *field)
if (curr_value != NULL) { if (curr_value != NULL) {
char *value = curr_value->data; char *value = curr_value->data;
if (value != NULL) { if (value != NULL) {
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, COLOUR_ONLINE, "", value); win_save_print(window, '-', NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value);
} }
} }
win_save_newline(window); win_save_newline(window);
@ -2535,7 +2535,7 @@ _ui_handle_form_field(ProfWin *window, char *tag, FormField *field)
win_save_newline(window); win_save_newline(window);
while (curr_value != NULL) { while (curr_value != NULL) {
char *value = curr_value->data; char *value = curr_value->data;
win_save_vprint(window, '-', NULL, 0, COLOUR_ONLINE, "", " %s", value); win_save_vprint(window, '-', NULL, 0, THEME_ONLINE, "", " %s", value);
curr_value = g_slist_next(curr_value); curr_value = g_slist_next(curr_value);
} }
break; break;
@ -2634,7 +2634,7 @@ _ui_handle_room_configuration_form_error(const char * const room, const char * c
g_string_append(message_str, message); g_string_append(message_str, message);
} }
win_save_print(window, '-', NULL, 0, COLOUR_ERROR, "", message_str->str); win_save_print(window, '-', NULL, 0, THEME_ERROR, "", message_str->str);
g_string_free(message_str, TRUE); g_string_free(message_str, TRUE);
} }
@ -2662,7 +2662,7 @@ _ui_handle_room_config_submit_result(const char * const room)
if (muc_window) { if (muc_window) {
int num = wins_get_num(muc_window); int num = wins_get_num(muc_window);
ui_switch_win(num); ui_switch_win(num);
win_save_print(muc_window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Room configuration successful"); win_save_print(muc_window, '!', NULL, 0, THEME_ROOMINFO, "", "Room configuration successful");
} else { } else {
ui_switch_win(1); ui_switch_win(1);
cons_show("Room configuration successful: %s", room); cons_show("Room configuration successful: %s", room);
@ -2689,25 +2689,25 @@ _ui_handle_room_config_submit_result_error(const char * const room, const char *
if (form_window) { if (form_window) {
if (message) { if (message) {
win_save_vprint(form_window, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error: %s", message); win_save_vprint(form_window, '!', NULL, 0, THEME_ERROR, "", "Configuration error: %s", message);
} else { } else {
win_save_print(form_window, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error"); win_save_print(form_window, '!', NULL, 0, THEME_ERROR, "", "Configuration error");
} }
} else if (muc_window) { } else if (muc_window) {
if (message) { if (message) {
win_save_vprint(muc_window, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error: %s", message); win_save_vprint(muc_window, '!', NULL, 0, THEME_ERROR, "", "Configuration error: %s", message);
} else { } else {
win_save_print(muc_window, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error"); win_save_print(muc_window, '!', NULL, 0, THEME_ERROR, "", "Configuration error");
} }
} else { } else {
if (message) { if (message) {
win_save_vprint(console, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error for %s: %s", room, message); win_save_vprint(console, '!', NULL, 0, THEME_ERROR, "", "Configuration error for %s: %s", room, message);
} else { } else {
win_save_vprint(console, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error for %s", room); win_save_vprint(console, '!', NULL, 0, THEME_ERROR, "", "Configuration error for %s", room);
} }
} }
} else { } else {
win_save_print(console, '!', NULL, 0, COLOUR_ERROR, "", "Configuration error"); win_save_print(console, '!', NULL, 0, THEME_ERROR, "", "Configuration error");
} }
} }
@ -2822,16 +2822,16 @@ _ui_roster_contact(PContact contact)
if ((g_strcmp0(presence, "offline") != 0) || ((g_strcmp0(presence, "offline") == 0) && if ((g_strcmp0(presence, "offline") != 0) || ((g_strcmp0(presence, "offline") == 0) &&
(prefs_get_boolean(PREF_ROSTER_OFFLINE)))) { (prefs_get_boolean(PREF_ROSTER_OFFLINE)))) {
int presence_colour = win_presence_colour(presence); theme_item_t presence_colour = win_presence_colour(presence);
wattron(window->subwin, presence_colour); wattron(window->subwin, theme_attrs(presence_colour));
GString *msg = g_string_new(" "); GString *msg = g_string_new(" ");
g_string_append(msg, name); g_string_append(msg, name);
win_printline_nowrap(window->subwin, msg->str); win_printline_nowrap(window->subwin, msg->str);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
wattroff(window->subwin, presence_colour); wattroff(window->subwin, theme_attrs(presence_colour));
if (prefs_get_boolean(PREF_ROSTER_RESOURCE)) { if (prefs_get_boolean(PREF_ROSTER_RESOURCE)) {
GList *resources = p_contact_get_available_resources(contact); GList *resources = p_contact_get_available_resources(contact);
@ -2839,15 +2839,15 @@ _ui_roster_contact(PContact contact)
while (curr_resource) { while (curr_resource) {
Resource *resource = curr_resource->data; Resource *resource = curr_resource->data;
const char *resource_presence = string_from_resource_presence(resource->presence); const char *resource_presence = string_from_resource_presence(resource->presence);
int resource_presence_colour = win_presence_colour(resource_presence); theme_item_t resource_presence_colour = win_presence_colour(resource_presence);
wattron(window->subwin, resource_presence_colour); wattron(window->subwin, theme_attrs(resource_presence_colour));
GString *msg = g_string_new(" "); GString *msg = g_string_new(" ");
g_string_append(msg, resource->name); g_string_append(msg, resource->name);
win_printline_nowrap(window->subwin, msg->str); win_printline_nowrap(window->subwin, msg->str);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
wattroff(window->subwin, resource_presence_colour); wattroff(window->subwin, theme_attrs(resource_presence_colour));
curr_resource = g_list_next(curr_resource); curr_resource = g_list_next(curr_resource);
} }
@ -2861,9 +2861,9 @@ static void
_ui_roster_contacts_by_presence(const char * const presence, char *title) _ui_roster_contacts_by_presence(const char * const presence, char *title)
{ {
ProfWin *window = wins_get_console(); ProfWin *window = wins_get_console();
wattron(window->subwin, COLOUR_ROOMINFO); wattron(window->subwin, theme_attrs(THEME_ROOMINFO));
win_printline_nowrap(window->subwin, title); win_printline_nowrap(window->subwin, title);
wattroff(window->subwin, COLOUR_ROOMINFO); wattroff(window->subwin, theme_attrs(THEME_ROOMINFO));
GSList *contacts = roster_get_contacts_by_presence(presence); GSList *contacts = roster_get_contacts_by_presence(presence);
if (contacts) { if (contacts) {
GSList *curr_contact = contacts; GSList *curr_contact = contacts;
@ -2880,12 +2880,12 @@ static void
_ui_roster_contacts_by_group(char *group) _ui_roster_contacts_by_group(char *group)
{ {
ProfWin *window = wins_get_console(); ProfWin *window = wins_get_console();
wattron(window->subwin, COLOUR_ROOMINFO); wattron(window->subwin, theme_attrs(THEME_ROOMINFO));
GString *title = g_string_new(" -"); GString *title = g_string_new(" -");
g_string_append(title, group); g_string_append(title, group);
win_printline_nowrap(window->subwin, title->str); win_printline_nowrap(window->subwin, title->str);
g_string_free(title, TRUE); g_string_free(title, TRUE);
wattroff(window->subwin, COLOUR_ROOMINFO); wattroff(window->subwin, theme_attrs(THEME_ROOMINFO));
GSList *contacts = roster_get_group(group); GSList *contacts = roster_get_group(group);
if (contacts) { if (contacts) {
GSList *curr_contact = contacts; GSList *curr_contact = contacts;
@ -2904,9 +2904,9 @@ _ui_roster_contacts_by_no_group(void)
ProfWin *window = wins_get_console(); ProfWin *window = wins_get_console();
GSList *contacts = roster_get_nogroup(); GSList *contacts = roster_get_nogroup();
if (contacts) { if (contacts) {
wattron(window->subwin, COLOUR_ROOMINFO); wattron(window->subwin, theme_attrs(THEME_ROOMINFO));
win_printline_nowrap(window->subwin, " -no group"); win_printline_nowrap(window->subwin, " -no group");
wattroff(window->subwin, COLOUR_ROOMINFO); wattroff(window->subwin, theme_attrs(THEME_ROOMINFO));
GSList *curr_contact = contacts; GSList *curr_contact = contacts;
while (curr_contact) { while (curr_contact) {
PContact contact = curr_contact->data; PContact contact = curr_contact->data;
@ -2947,9 +2947,9 @@ _ui_roster(void)
GSList *contacts = roster_get_contacts(); GSList *contacts = roster_get_contacts();
if (contacts) { if (contacts) {
werase(window->subwin); werase(window->subwin);
wattron(window->subwin, COLOUR_ROOMINFO); wattron(window->subwin, theme_attrs(THEME_ROOMINFO));
win_printline_nowrap(window->subwin, " -Roster"); win_printline_nowrap(window->subwin, " -Roster");
wattroff(window->subwin, COLOUR_ROOMINFO); wattroff(window->subwin, theme_attrs(THEME_ROOMINFO));
GSList *curr_contact = contacts; GSList *curr_contact = contacts;
while (curr_contact) { while (curr_contact) {
PContact contact = curr_contact->data; PContact contact = curr_contact->data;
@ -2973,85 +2973,85 @@ _ui_muc_roster(const char * const room)
werase(window->subwin); werase(window->subwin);
if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) {
wattron(window->subwin, COLOUR_ROOMINFO); wattron(window->subwin, theme_attrs(THEME_ROOMINFO));
win_printline_nowrap(window->subwin, " -Moderators"); win_printline_nowrap(window->subwin, " -Moderators");
wattroff(window->subwin, COLOUR_ROOMINFO); wattroff(window->subwin, theme_attrs(THEME_ROOMINFO));
GList *roster_curr = occupants; GList *roster_curr = occupants;
while (roster_curr) { while (roster_curr) {
Occupant *occupant = roster_curr->data; Occupant *occupant = roster_curr->data;
if (occupant->role == MUC_ROLE_MODERATOR) { if (occupant->role == MUC_ROLE_MODERATOR) {
const char *presence_str = string_from_resource_presence(occupant->presence); const char *presence_str = string_from_resource_presence(occupant->presence);
int presence_colour = win_presence_colour(presence_str); theme_item_t presence_colour = win_presence_colour(presence_str);
wattron(window->subwin, presence_colour); wattron(window->subwin, theme_attrs(presence_colour));
GString *msg = g_string_new(" "); GString *msg = g_string_new(" ");
g_string_append(msg, occupant->nick); g_string_append(msg, occupant->nick);
win_printline_nowrap(window->subwin, msg->str); win_printline_nowrap(window->subwin, msg->str);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
wattroff(window->subwin, presence_colour); wattroff(window->subwin, theme_attrs(presence_colour));
} }
roster_curr = g_list_next(roster_curr); roster_curr = g_list_next(roster_curr);
} }
wattron(window->subwin, COLOUR_ROOMINFO); wattron(window->subwin, theme_attrs(THEME_ROOMINFO));
win_printline_nowrap(window->subwin, " -Participants"); win_printline_nowrap(window->subwin, " -Participants");
wattroff(window->subwin, COLOUR_ROOMINFO); wattroff(window->subwin, theme_attrs(THEME_ROOMINFO));
roster_curr = occupants; roster_curr = occupants;
while (roster_curr) { while (roster_curr) {
Occupant *occupant = roster_curr->data; Occupant *occupant = roster_curr->data;
if (occupant->role == MUC_ROLE_PARTICIPANT) { if (occupant->role == MUC_ROLE_PARTICIPANT) {
const char *presence_str = string_from_resource_presence(occupant->presence); const char *presence_str = string_from_resource_presence(occupant->presence);
int presence_colour = win_presence_colour(presence_str); theme_item_t presence_colour = win_presence_colour(presence_str);
wattron(window->subwin, presence_colour); wattron(window->subwin, theme_attrs(presence_colour));
GString *msg = g_string_new(" "); GString *msg = g_string_new(" ");
g_string_append(msg, occupant->nick); g_string_append(msg, occupant->nick);
win_printline_nowrap(window->subwin, msg->str); win_printline_nowrap(window->subwin, msg->str);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
wattroff(window->subwin, presence_colour); wattroff(window->subwin, theme_attrs(presence_colour));
} }
roster_curr = g_list_next(roster_curr); roster_curr = g_list_next(roster_curr);
} }
wattron(window->subwin, COLOUR_ROOMINFO); wattron(window->subwin, theme_attrs(THEME_ROOMINFO));
win_printline_nowrap(window->subwin, " -Visitors"); win_printline_nowrap(window->subwin, " -Visitors");
wattroff(window->subwin, COLOUR_ROOMINFO); wattroff(window->subwin, theme_attrs(THEME_ROOMINFO));
roster_curr = occupants; roster_curr = occupants;
while (roster_curr) { while (roster_curr) {
Occupant *occupant = roster_curr->data; Occupant *occupant = roster_curr->data;
if (occupant->role == MUC_ROLE_VISITOR) { if (occupant->role == MUC_ROLE_VISITOR) {
const char *presence_str = string_from_resource_presence(occupant->presence); const char *presence_str = string_from_resource_presence(occupant->presence);
int presence_colour = win_presence_colour(presence_str); theme_item_t presence_colour = win_presence_colour(presence_str);
wattron(window->subwin, presence_colour); wattron(window->subwin, theme_attrs(presence_colour));
GString *msg = g_string_new(" "); GString *msg = g_string_new(" ");
g_string_append(msg, occupant->nick); g_string_append(msg, occupant->nick);
win_printline_nowrap(window->subwin, msg->str); win_printline_nowrap(window->subwin, msg->str);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
wattroff(window->subwin, presence_colour); wattroff(window->subwin, theme_attrs(presence_colour));
} }
roster_curr = g_list_next(roster_curr); roster_curr = g_list_next(roster_curr);
} }
} else { } else {
wattron(window->subwin, COLOUR_ROOMINFO); wattron(window->subwin, theme_attrs(THEME_ROOMINFO));
win_printline_nowrap(window->subwin, " -Occupants\n"); win_printline_nowrap(window->subwin, " -Occupants\n");
wattroff(window->subwin, COLOUR_ROOMINFO); wattroff(window->subwin, theme_attrs(THEME_ROOMINFO));
GList *roster_curr = occupants; GList *roster_curr = occupants;
while (roster_curr) { while (roster_curr) {
Occupant *occupant = roster_curr->data; Occupant *occupant = roster_curr->data;
const char *presence_str = string_from_resource_presence(occupant->presence); const char *presence_str = string_from_resource_presence(occupant->presence);
int presence_colour = win_presence_colour(presence_str); theme_item_t presence_colour = win_presence_colour(presence_str);
wattron(window->subwin, presence_colour); wattron(window->subwin, theme_attrs(presence_colour));
GString *msg = g_string_new(" "); GString *msg = g_string_new(" ");
g_string_append(msg, occupant->nick); g_string_append(msg, occupant->nick);
win_printline_nowrap(window->subwin, msg->str); win_printline_nowrap(window->subwin, msg->str);
g_string_free(msg, TRUE); g_string_free(msg, TRUE);
wattroff(window->subwin, presence_colour); wattroff(window->subwin, theme_attrs(presence_colour));
roster_curr = g_list_next(roster_curr); roster_curr = g_list_next(roster_curr);
} }
} }

View File

@ -83,7 +83,7 @@ create_input_window(void)
#endif #endif
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
inp_win = newpad(1, INP_WIN_MAX); inp_win = newpad(1, INP_WIN_MAX);
wbkgd(inp_win, COLOUR_INPUT_TEXT); wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));;
keypad(inp_win, TRUE); keypad(inp_win, TRUE);
wmove(inp_win, 0, 0); wmove(inp_win, 0, 0);
_inp_win_update_virtual(); _inp_win_update_virtual();

View File

@ -85,12 +85,14 @@ create_status_bar(void)
remaining_new = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL); remaining_new = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
current = 1; current = 1;
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
status_bar = newwin(1, cols, rows-2, 0); status_bar = newwin(1, cols, rows-2, 0);
wbkgd(status_bar, COLOUR_STATUS_TEXT); wbkgd(status_bar, theme_attrs(THEME_STATUS_TEXT));
wattron(status_bar, COLOUR_STATUS_BRACKET); wattron(status_bar, bracket_attrs);
mvwprintw(status_bar, 0, cols - 34, _active); mvwprintw(status_bar, 0, cols - 34, _active);
mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket);
wattroff(status_bar, COLOUR_STATUS_BRACKET); wattroff(status_bar, bracket_attrs);
if (last_time != NULL) { if (last_time != NULL) {
g_date_time_unref(last_time); g_date_time_unref(last_time);
@ -114,13 +116,15 @@ status_bar_resize(void)
werase(status_bar); werase(status_bar);
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
mvwin(status_bar, rows-2, 0); mvwin(status_bar, rows-2, 0);
wresize(status_bar, 1, cols); wresize(status_bar, 1, cols);
wbkgd(status_bar, COLOUR_STATUS_TEXT); wbkgd(status_bar, theme_attrs(THEME_STATUS_TEXT));
wattron(status_bar, COLOUR_STATUS_BRACKET); wattron(status_bar, bracket_attrs);
mvwprintw(status_bar, 0, cols - 34, _active); mvwprintw(status_bar, 0, cols - 34, _active);
mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket);
wattroff(status_bar, COLOUR_STATUS_BRACKET); wattroff(status_bar, bracket_attrs);
if (message != NULL) { if (message != NULL) {
mvwprintw(status_bar, 0, 10, message); mvwprintw(status_bar, 0, 10, message);
@ -160,10 +164,11 @@ status_bar_current(int i)
current = i; current = i;
} }
int cols = getmaxx(stdscr); int cols = getmaxx(stdscr);
wattron(status_bar, COLOUR_STATUS_BRACKET); int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
wattron(status_bar, bracket_attrs);
mvwprintw(status_bar, 0, cols - 34, _active); mvwprintw(status_bar, 0, cols - 34, _active);
mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket);
wattroff(status_bar, COLOUR_STATUS_BRACKET); wattroff(status_bar, bracket_attrs);
_status_bar_draw(); _status_bar_draw();
} }
@ -291,11 +296,12 @@ status_bar_print_message(const char * const msg)
mvwprintw(status_bar, 0, 10, message); mvwprintw(status_bar, 0, 10, message);
int cols = getmaxx(stdscr); int cols = getmaxx(stdscr);
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
wattron(status_bar, COLOUR_STATUS_BRACKET); wattron(status_bar, bracket_attrs);
mvwprintw(status_bar, 0, cols - 34, _active); mvwprintw(status_bar, 0, cols - 34, _active);
mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket);
wattroff(status_bar, COLOUR_STATUS_BRACKET); wattroff(status_bar, bracket_attrs);
_status_bar_draw(); _status_bar_draw();
} }
@ -311,11 +317,12 @@ status_bar_clear(void)
werase(status_bar); werase(status_bar);
int cols = getmaxx(stdscr); int cols = getmaxx(stdscr);
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
wattron(status_bar, COLOUR_STATUS_BRACKET); wattron(status_bar, bracket_attrs);
mvwprintw(status_bar, 0, cols - 34, _active); mvwprintw(status_bar, 0, cols - 34, _active);
mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket);
wattroff(status_bar, COLOUR_STATUS_BRACKET); wattroff(status_bar, bracket_attrs);
_status_bar_draw(); _status_bar_draw();
} }
@ -331,11 +338,12 @@ status_bar_clear_message(void)
werase(status_bar); werase(status_bar);
int cols = getmaxx(stdscr); int cols = getmaxx(stdscr);
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
wattron(status_bar, COLOUR_STATUS_BRACKET); wattron(status_bar, bracket_attrs);
mvwprintw(status_bar, 0, cols - 34, _active); mvwprintw(status_bar, 0, cols - 34, _active);
mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket); mvwprintw(status_bar, 0, cols - 34 + ((current - 1) * 3), bracket);
wattroff(status_bar, COLOUR_STATUS_BRACKET); wattroff(status_bar, bracket_attrs);
_status_bar_draw(); _status_bar_draw();
} }
@ -362,7 +370,8 @@ _mark_new(int num)
{ {
int active_pos = 1 + ((num-1) * 3); int active_pos = 1 + ((num-1) * 3);
int cols = getmaxx(stdscr); int cols = getmaxx(stdscr);
wattron(status_bar, COLOUR_STATUS_NEW); int status_attrs = theme_attrs(THEME_STATUS_NEW);
wattron(status_bar, status_attrs);
wattron(status_bar, A_BLINK); wattron(status_bar, A_BLINK);
if (num == 10) { if (num == 10) {
mvwprintw(status_bar, 0, cols - 34 + active_pos, "0"); mvwprintw(status_bar, 0, cols - 34 + active_pos, "0");
@ -371,7 +380,7 @@ _mark_new(int num)
} else { } else {
mvwprintw(status_bar, 0, cols - 34 + active_pos, "%d", num); mvwprintw(status_bar, 0, cols - 34 + active_pos, "%d", num);
} }
wattroff(status_bar, COLOUR_STATUS_NEW); wattroff(status_bar, status_attrs);
wattroff(status_bar, A_BLINK); wattroff(status_bar, A_BLINK);
} }
@ -380,7 +389,8 @@ _mark_active(int num)
{ {
int active_pos = 1 + ((num-1) * 3); int active_pos = 1 + ((num-1) * 3);
int cols = getmaxx(stdscr); int cols = getmaxx(stdscr);
wattron(status_bar, COLOUR_STATUS_ACTIVE); int status_attrs = theme_attrs(THEME_STATUS_ACTIVE);
wattron(status_bar, status_attrs);
if (num == 10) { if (num == 10) {
mvwprintw(status_bar, 0, cols - 34 + active_pos, "0"); mvwprintw(status_bar, 0, cols - 34 + active_pos, "0");
} else if (num > 10) { } else if (num > 10) {
@ -388,7 +398,7 @@ _mark_active(int num)
} else { } else {
mvwprintw(status_bar, 0, cols - 34 + active_pos, "%d", num); mvwprintw(status_bar, 0, cols - 34 + active_pos, "%d", num);
} }
wattroff(status_bar, COLOUR_STATUS_ACTIVE); wattroff(status_bar, status_attrs);
} }
static void static void
@ -409,13 +419,15 @@ _status_bar_draw(void)
gchar *date_fmt = g_date_time_format(last_time, "%H:%M"); gchar *date_fmt = g_date_time_format(last_time, "%H:%M");
assert(date_fmt != NULL); assert(date_fmt != NULL);
wattron(status_bar, COLOUR_STATUS_BRACKET); int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
wattron(status_bar, bracket_attrs);
mvwaddch(status_bar, 0, 1, '['); mvwaddch(status_bar, 0, 1, '[');
wattroff(status_bar, COLOUR_STATUS_BRACKET); wattroff(status_bar, bracket_attrs);
mvwprintw(status_bar, 0, 2, date_fmt); mvwprintw(status_bar, 0, 2, date_fmt);
wattron(status_bar, COLOUR_STATUS_BRACKET); wattron(status_bar, bracket_attrs);
mvwaddch(status_bar, 0, 7, ']'); mvwaddch(status_bar, 0, 7, ']');
wattroff(status_bar, COLOUR_STATUS_BRACKET); wattroff(status_bar, bracket_attrs);
g_free(date_fmt); g_free(date_fmt);
_update_win_statuses(); _update_win_statuses();

View File

@ -65,7 +65,7 @@ create_title_bar(void)
int cols = getmaxx(stdscr); int cols = getmaxx(stdscr);
win = newwin(1, cols, 0, 0); win = newwin(1, cols, 0, 0);
wbkgd(win, COLOUR_TITLE_TEXT); wbkgd(win, theme_attrs(THEME_TITLE_TEXT));
title_bar_console(); title_bar_console();
title_bar_set_presence(CONTACT_OFFLINE); title_bar_set_presence(CONTACT_OFFLINE);
wnoutrefresh(win); wnoutrefresh(win);
@ -98,7 +98,7 @@ title_bar_resize(void)
int cols = getmaxx(stdscr); int cols = getmaxx(stdscr);
wresize(win, 1, cols); wresize(win, 1, cols);
wbkgd(win, COLOUR_TITLE_TEXT); wbkgd(win, theme_attrs(THEME_TITLE_TEXT));
_title_bar_draw(); _title_bar_draw();
} }
@ -174,6 +174,8 @@ _title_bar_draw(void)
waddch(win, ' '); waddch(win, ' ');
mvwprintw(win, 0, 0, " %s", current_title); mvwprintw(win, 0, 0, " %s", current_title);
int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET);
// show presence // show presence
if (prefs_get_boolean(PREF_PRESENCE) && current_recipient) { if (prefs_get_boolean(PREF_PRESENCE) && current_recipient) {
char *recipient_jid = NULL; char *recipient_jid = NULL;
@ -190,29 +192,31 @@ _title_bar_draw(void)
PContact contact = roster_get_contact(recipient_jid); PContact contact = roster_get_contact(recipient_jid);
const char *presence = p_contact_presence(contact); const char *presence = p_contact_presence(contact);
int presence_colour = COLOUR_TITLE_ONLINE; theme_item_t presence_colour = THEME_TITLE_ONLINE;
if (g_strcmp0(presence, "offline") == 0) { if (g_strcmp0(presence, "offline") == 0) {
presence_colour = COLOUR_TITLE_OFFLINE; presence_colour = THEME_TITLE_OFFLINE;
} else if (g_strcmp0(presence, "away") == 0) { } else if (g_strcmp0(presence, "away") == 0) {
presence_colour = COLOUR_TITLE_AWAY; presence_colour = THEME_TITLE_AWAY;
} else if (g_strcmp0(presence, "xa") == 0) { } else if (g_strcmp0(presence, "xa") == 0) {
presence_colour = COLOUR_TITLE_XA; presence_colour = THEME_TITLE_XA;
} else if (g_strcmp0(presence, "chat") == 0) { } else if (g_strcmp0(presence, "chat") == 0) {
presence_colour = COLOUR_TITLE_CHAT; presence_colour = THEME_TITLE_CHAT;
} else if (g_strcmp0(presence, "dnd") == 0) { } else if (g_strcmp0(presence, "dnd") == 0) {
presence_colour = COLOUR_TITLE_DND; presence_colour = THEME_TITLE_DND;
} }
int presence_attrs = theme_attrs(presence_colour);
wprintw(win, " "); wprintw(win, " ");
wattron(win, COLOUR_TITLE_BRACKET); wattron(win, bracket_attrs);
wprintw(win, "["); wprintw(win, "[");
wattroff(win, COLOUR_TITLE_BRACKET); wattroff(win, bracket_attrs);
wattron(win, presence_colour); wattron(win, presence_attrs);
wprintw(win, presence); wprintw(win, presence);
wattroff(win, presence_colour); wattroff(win, presence_attrs);
wattron(win, COLOUR_TITLE_BRACKET); wattron(win, bracket_attrs);
wprintw(win, "]"); wprintw(win, "]");
wattroff(win, COLOUR_TITLE_BRACKET); wattroff(win, bracket_attrs);
} }
} }
} }
@ -233,50 +237,54 @@ _title_bar_draw(void)
if (current->type == WIN_CHAT) { if (current->type == WIN_CHAT) {
if (!current->is_otr) { if (!current->is_otr) {
if (prefs_get_boolean(PREF_OTR_WARN)) { if (prefs_get_boolean(PREF_OTR_WARN)) {
int unencrypted_attrs = theme_attrs(THEME_TITLE_UNENCRYPTED);
wprintw(win, " "); wprintw(win, " ");
wattron(win, COLOUR_TITLE_BRACKET); wattron(win, bracket_attrs);
wprintw(win, "["); wprintw(win, "[");
wattroff(win, COLOUR_TITLE_BRACKET); wattroff(win, bracket_attrs);
wattron(win, COLOUR_TITLE_UNENCRYPTED); wattron(win, unencrypted_attrs);
wprintw(win, "unencrypted"); wprintw(win, "unencrypted");
wattroff(win, COLOUR_TITLE_UNENCRYPTED); wattroff(win, unencrypted_attrs);
wattron(win, COLOUR_TITLE_BRACKET); wattron(win, bracket_attrs);
wprintw(win, "]"); wprintw(win, "]");
wattroff(win, COLOUR_TITLE_BRACKET); wattroff(win, bracket_attrs);
} }
} else { } else {
int encrypted_attrs = theme_attrs(THEME_TITLE_ENCRYPTED);
wprintw(win, " "); wprintw(win, " ");
wattron(win, COLOUR_TITLE_BRACKET); wattron(win, bracket_attrs);
wprintw(win, "["); wprintw(win, "[");
wattroff(win, COLOUR_TITLE_BRACKET); wattroff(win, bracket_attrs);
wattron(win, COLOUR_TITLE_ENCRYPTED); wattron(win, encrypted_attrs);
wprintw(win, "OTR"); wprintw(win, "OTR");
wattroff(win, COLOUR_TITLE_ENCRYPTED); wattroff(win, encrypted_attrs);
wattron(win, COLOUR_TITLE_BRACKET); wattron(win, bracket_attrs);
wprintw(win, "]"); wprintw(win, "]");
wattroff(win, COLOUR_TITLE_BRACKET); wattroff(win, bracket_attrs);
if (current->is_trusted) { if (current->is_trusted) {
int trusted_attrs = theme_attrs(THEME_TITLE_TRUSTED);
wprintw(win, " "); wprintw(win, " ");
wattron(win, COLOUR_TITLE_BRACKET); wattron(win, bracket_attrs);
wprintw(win, "["); wprintw(win, "[");
wattroff(win, COLOUR_TITLE_BRACKET); wattroff(win, bracket_attrs);
wattron(win, COLOUR_TITLE_TRUSTED); wattron(win, trusted_attrs);
wprintw(win, "trusted"); wprintw(win, "trusted");
wattroff(win, COLOUR_TITLE_TRUSTED); wattroff(win, trusted_attrs);
wattron(win, COLOUR_TITLE_BRACKET); wattron(win, bracket_attrs);
wprintw(win, "]"); wprintw(win, "]");
wattroff(win, COLOUR_TITLE_BRACKET); wattroff(win, bracket_attrs);
} else { } else {
int untrusted_attrs = theme_attrs(THEME_TITLE_UNTRUSTED);
wprintw(win, " "); wprintw(win, " ");
wattron(win, COLOUR_TITLE_BRACKET); wattron(win, bracket_attrs);
wprintw(win, "["); wprintw(win, "[");
wattroff(win, COLOUR_TITLE_BRACKET); wattroff(win, bracket_attrs);
wattron(win, COLOUR_TITLE_UNTRUSTED); wattron(win, untrusted_attrs);
wprintw(win, "untrusted"); wprintw(win, "untrusted");
wattroff(win, COLOUR_TITLE_UNTRUSTED); wattroff(win, untrusted_attrs);
wattron(win, COLOUR_TITLE_BRACKET); wattron(win, bracket_attrs);
wprintw(win, "]"); wprintw(win, "]");
wattroff(win, COLOUR_TITLE_BRACKET); wattroff(win, bracket_attrs);
} }
} }
} }
@ -300,47 +308,55 @@ _title_bar_draw(void)
// show presence // show presence
int cols = getmaxx(stdscr); int cols = getmaxx(stdscr);
wattron(win, COLOUR_TITLE_BRACKET); wattron(win, bracket_attrs);
mvwaddch(win, 0, cols - 14, '['); mvwaddch(win, 0, cols - 14, '[');
wattroff(win, COLOUR_TITLE_BRACKET); wattroff(win, bracket_attrs);
int presence_attrs = 0;
switch (current_presence) switch (current_presence)
{ {
case CONTACT_ONLINE: case CONTACT_ONLINE:
wattron(win, COLOUR_TITLE_ONLINE); presence_attrs = theme_attrs(THEME_TITLE_ONLINE);
wattron(win, presence_attrs);
mvwprintw(win, 0, cols - 13, " ...online "); mvwprintw(win, 0, cols - 13, " ...online ");
wattroff(win, COLOUR_TITLE_ONLINE); wattroff(win, presence_attrs);
break; break;
case CONTACT_AWAY: case CONTACT_AWAY:
wattron(win, COLOUR_TITLE_AWAY); presence_attrs = theme_attrs(THEME_TITLE_AWAY);
wattron(win, presence_attrs);
mvwprintw(win, 0, cols - 13, " .....away "); mvwprintw(win, 0, cols - 13, " .....away ");
wattroff(win, COLOUR_TITLE_AWAY); wattroff(win, presence_attrs);
break; break;
case CONTACT_DND: case CONTACT_DND:
wattron(win, COLOUR_TITLE_DND); presence_attrs = theme_attrs(THEME_TITLE_DND);
wattron(win, presence_attrs);
mvwprintw(win, 0, cols - 13, " ......dnd "); mvwprintw(win, 0, cols - 13, " ......dnd ");
wattroff(win, COLOUR_TITLE_DND); wattroff(win, presence_attrs);
break; break;
case CONTACT_CHAT: case CONTACT_CHAT:
wattron(win, COLOUR_TITLE_CHAT); presence_attrs = theme_attrs(THEME_TITLE_CHAT);
wattron(win, presence_attrs);
mvwprintw(win, 0, cols - 13, " .....chat "); mvwprintw(win, 0, cols - 13, " .....chat ");
wattroff(win, COLOUR_TITLE_CHAT); wattroff(win, presence_attrs);
break; break;
case CONTACT_XA: case CONTACT_XA:
wattron(win, COLOUR_TITLE_XA); presence_attrs = theme_attrs(THEME_TITLE_XA);
wattron(win, presence_attrs);
mvwprintw(win, 0, cols - 13, " .......xa "); mvwprintw(win, 0, cols - 13, " .......xa ");
wattroff(win, COLOUR_TITLE_XA); wattroff(win, presence_attrs);
break; break;
case CONTACT_OFFLINE: case CONTACT_OFFLINE:
wattron(win, COLOUR_TITLE_OFFLINE); presence_attrs = theme_attrs(THEME_TITLE_OFFLINE);
wattron(win, presence_attrs);
mvwprintw(win, 0, cols - 13, " ..offline "); mvwprintw(win, 0, cols - 13, " ..offline ");
wattroff(win, COLOUR_TITLE_OFFLINE); wattroff(win, presence_attrs);
break; break;
} }
wattron(win, COLOUR_TITLE_BRACKET); wattron(win, bracket_attrs);
mvwaddch(win, 0, cols - 2, ']'); mvwaddch(win, 0, cols - 2, ']');
wattroff(win, COLOUR_TITLE_BRACKET); wattroff(win, bracket_attrs);
wnoutrefresh(win); wnoutrefresh(win);
inp_put_back(); inp_put_back();

View File

@ -54,7 +54,7 @@
#define CEILING(X) (X-(int)(X) > 0 ? (int)(X+1) : (int)(X)) #define CEILING(X) (X-(int)(X) > 0 ? (int)(X+1) : (int)(X))
static void _win_print(ProfWin *window, const char show_char, GDateTime *time, static void _win_print(ProfWin *window, const char show_char, GDateTime *time,
int flags, int attrs, const char * const from, const char * const message); int flags, theme_item_t theme_item, const char * const from, const char * const message);
static void _win_print_wrapped(WINDOW *win, const char * const message); static void _win_print_wrapped(WINDOW *win, const char * const message);
int int
@ -83,13 +83,13 @@ win_create(const char * const title, win_type_t type)
if (type == WIN_MUC && prefs_get_boolean(PREF_OCCUPANTS)) { if (type == WIN_MUC && prefs_get_boolean(PREF_OCCUPANTS)) {
int subwin_cols = win_occpuants_cols(); int subwin_cols = win_occpuants_cols();
new_win->win = newpad(PAD_SIZE, cols - subwin_cols); new_win->win = newpad(PAD_SIZE, cols - subwin_cols);
wbkgd(new_win->win, COLOUR_TEXT); wbkgd(new_win->win, theme_attrs(THEME_TEXT));
new_win->subwin = newpad(PAD_SIZE, subwin_cols); new_win->subwin = newpad(PAD_SIZE, subwin_cols);
wbkgd(new_win->subwin, COLOUR_TEXT); wbkgd(new_win->subwin, theme_attrs(THEME_TEXT));
} else { } else {
new_win->win = newpad(PAD_SIZE, (cols)); new_win->win = newpad(PAD_SIZE, (cols));
wbkgd(new_win->win, COLOUR_TEXT); wbkgd(new_win->win, theme_attrs(THEME_TEXT));
new_win->subwin = NULL; new_win->subwin = NULL;
} }
@ -136,7 +136,7 @@ win_show_subwin(ProfWin *window)
} }
window->subwin = newpad(PAD_SIZE, subwin_cols); window->subwin = newpad(PAD_SIZE, subwin_cols);
wbkgd(window->subwin, COLOUR_TEXT); wbkgd(window->subwin, theme_attrs(THEME_TEXT));
wresize(window->win, PAD_SIZE, cols - subwin_cols); wresize(window->win, PAD_SIZE, cols - subwin_cols);
win_redraw(window); win_redraw(window);
@ -191,21 +191,21 @@ win_move_to_end(ProfWin *window)
} }
} }
int theme_item_t
win_presence_colour(const char * const presence) win_presence_colour(const char * const presence)
{ {
if (g_strcmp0(presence, "online") == 0) { if (g_strcmp0(presence, "online") == 0) {
return COLOUR_ONLINE; return THEME_ONLINE;
} else if (g_strcmp0(presence, "away") == 0) { } else if (g_strcmp0(presence, "away") == 0) {
return COLOUR_AWAY; return THEME_AWAY;
} else if (g_strcmp0(presence, "chat") == 0) { } else if (g_strcmp0(presence, "chat") == 0) {
return COLOUR_CHAT; return THEME_CHAT;
} else if (g_strcmp0(presence, "dnd") == 0) { } else if (g_strcmp0(presence, "dnd") == 0) {
return COLOUR_DND; return THEME_DND;
} else if (g_strcmp0(presence, "xa") == 0) { } else if (g_strcmp0(presence, "xa") == 0) {
return COLOUR_XA; return THEME_XA;
} else { } else {
return COLOUR_OFFLINE; return THEME_OFFLINE;
} }
} }
@ -214,7 +214,7 @@ win_show_occupant(ProfWin *window, Occupant *occupant)
{ {
const char *presence_str = string_from_resource_presence(occupant->presence); const char *presence_str = string_from_resource_presence(occupant->presence);
int presence_colour = win_presence_colour(presence_str); theme_item_t presence_colour = win_presence_colour(presence_str);
win_save_print(window, '-', NULL, NO_EOL, presence_colour, "", occupant->nick); win_save_print(window, '-', NULL, NO_EOL, presence_colour, "", occupant->nick);
win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); win_save_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
@ -235,7 +235,7 @@ win_show_contact(ProfWin *window, PContact contact)
const char *status = p_contact_status(contact); const char *status = p_contact_status(contact);
GDateTime *last_activity = p_contact_last_activity(contact); GDateTime *last_activity = p_contact_last_activity(contact);
int presence_colour = win_presence_colour(presence); theme_item_t presence_colour = win_presence_colour(presence);
if (name != NULL) { if (name != NULL) {
win_save_print(window, '-', NULL, NO_EOL, presence_colour, "", name); win_save_print(window, '-', NULL, NO_EOL, presence_colour, "", name);
@ -277,7 +277,7 @@ win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occup
const char *occupant_affiliation = muc_occupant_affiliation_str(occupant); const char *occupant_affiliation = muc_occupant_affiliation_str(occupant);
const char *occupant_role = muc_occupant_role_str(occupant); const char *occupant_role = muc_occupant_role_str(occupant);
int presence_colour = win_presence_colour(presence_str); theme_item_t presence_colour = win_presence_colour(presence_str);
win_save_print(window, '!', NULL, NO_EOL, presence_colour, "", occupant->nick); win_save_print(window, '!', NULL, NO_EOL, presence_colour, "", occupant->nick);
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
@ -355,7 +355,7 @@ win_show_info(ProfWin *window, PContact contact)
GList *ordered_resources = NULL; GList *ordered_resources = NULL;
GDateTime *last_activity = p_contact_last_activity(contact); GDateTime *last_activity = p_contact_last_activity(contact);
int presence_colour = win_presence_colour(presence); theme_item_t presence_colour = win_presence_colour(presence);
win_save_print(window, '-', NULL, 0, 0, "", ""); win_save_print(window, '-', NULL, 0, 0, "", "");
win_save_print(window, '-', NULL, NO_EOL, presence_colour, "", barejid); win_save_print(window, '-', NULL, NO_EOL, presence_colour, "", barejid);
@ -466,14 +466,14 @@ win_show_status_string(ProfWin *window, const char * const from,
GDateTime *last_activity, const char * const pre, GDateTime *last_activity, const char * const pre,
const char * const default_show) const char * const default_show)
{ {
int presence_colour; theme_item_t presence_colour;
if (show != NULL) { if (show != NULL) {
presence_colour = win_presence_colour(show); presence_colour = win_presence_colour(show);
} else if (strcmp(default_show, "online") == 0) { } else if (strcmp(default_show, "online") == 0) {
presence_colour = COLOUR_ONLINE; presence_colour = THEME_ONLINE;
} else { } else {
presence_colour = COLOUR_OFFLINE; presence_colour = THEME_OFFLINE;
} }
@ -518,7 +518,7 @@ win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
{ {
case WIN_CHAT: case WIN_CHAT:
case WIN_PRIVATE: case WIN_PRIVATE:
win_save_print(window, '-', tv_stamp, NO_ME, COLOUR_TEXT_THEM, from, message); win_save_print(window, '-', tv_stamp, NO_ME, THEME_TEXT_THEM, from, message);
break; break;
default: default:
assert(FALSE); assert(FALSE);
@ -528,19 +528,19 @@ win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
void void
win_save_vprint(ProfWin *window, const char show_char, GTimeVal *tstamp, win_save_vprint(ProfWin *window, const char show_char, GTimeVal *tstamp,
int flags, int attrs, const char * const from, const char * const message, ...) int flags, theme_item_t theme_item, const char * const from, const char * const message, ...)
{ {
va_list arg; va_list arg;
va_start(arg, message); va_start(arg, message);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, message, arg); g_string_vprintf(fmt_msg, message, arg);
win_save_print(window, show_char, tstamp, flags, attrs, from, fmt_msg->str); win_save_print(window, show_char, tstamp, flags, theme_item, from, fmt_msg->str);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
} }
void void
win_save_print(ProfWin *window, const char show_char, GTimeVal *tstamp, win_save_print(ProfWin *window, const char show_char, GTimeVal *tstamp,
int flags, int attrs, const char * const from, const char * const message) int flags, theme_item_t theme_item, const char * const from, const char * const message)
{ {
GDateTime *time; GDateTime *time;
@ -550,8 +550,8 @@ win_save_print(ProfWin *window, const char show_char, GTimeVal *tstamp,
time = g_date_time_new_from_timeval_utc(tstamp); time = g_date_time_new_from_timeval_utc(tstamp);
} }
buffer_push(window->buffer, show_char, time, flags, attrs, from, message); buffer_push(window->buffer, show_char, time, flags, theme_item, from, message);
_win_print(window, show_char, time, flags, attrs, from, message); _win_print(window, show_char, time, flags, theme_item, from, message);
} }
void void
@ -568,7 +568,7 @@ win_save_newline(ProfWin *window)
static void static void
_win_print(ProfWin *window, const char show_char, GDateTime *time, _win_print(ProfWin *window, const char show_char, GDateTime *time,
int flags, int attrs, const char * const from, const char * const message) int flags, theme_item_t theme_item, const char * const from, const char * const message)
{ {
// flags : 1st bit = 0/1 - me/not me // flags : 1st bit = 0/1 - me/not me
// 2nd bit = 0/1 - date/no date // 2nd bit = 0/1 - date/no date
@ -577,7 +577,7 @@ _win_print(ProfWin *window, const char show_char, GDateTime *time,
// 5th bit = 0/1 - color date/no date // 5th bit = 0/1 - color date/no date
int unattr_me = 0; int unattr_me = 0;
int offset = 0; int offset = 0;
int colour = COLOUR_ME; int colour = theme_attrs(THEME_ME);
if ((flags & NO_DATE) == 0) { if ((flags & NO_DATE) == 0) {
gchar *date_fmt = NULL; gchar *date_fmt = NULL;
@ -591,11 +591,11 @@ _win_print(ProfWin *window, const char show_char, GDateTime *time,
if (date_fmt) { if (date_fmt) {
if ((flags & NO_COLOUR_DATE) == 0) { if ((flags & NO_COLOUR_DATE) == 0) {
wattron(window->win, COLOUR_TIME); wattron(window->win, theme_attrs(THEME_TIME));
} }
wprintw(window->win, "%s %c ", date_fmt, show_char); wprintw(window->win, "%s %c ", date_fmt, show_char);
if ((flags & NO_COLOUR_DATE) == 0) { if ((flags & NO_COLOUR_DATE) == 0) {
wattroff(window->win, COLOUR_TIME); wattroff(window->win, theme_attrs(THEME_TIME));
} }
} }
g_free(date_fmt); g_free(date_fmt);
@ -603,7 +603,7 @@ _win_print(ProfWin *window, const char show_char, GDateTime *time,
if (strlen(from) > 0) { if (strlen(from) > 0) {
if (flags & NO_ME) { if (flags & NO_ME) {
colour = COLOUR_THEM; colour = theme_attrs(THEME_THEM);
} }
if (flags & NO_COLOUR_FROM) { if (flags & NO_COLOUR_FROM) {
@ -621,7 +621,7 @@ _win_print(ProfWin *window, const char show_char, GDateTime *time,
} }
} }
wattron(window->win, attrs); wattron(window->win, theme_attrs(theme_item));
if (prefs_get_boolean(PREF_WRAP)) { if (prefs_get_boolean(PREF_WRAP)) {
_win_print_wrapped(window->win, message+offset); _win_print_wrapped(window->win, message+offset);
@ -633,7 +633,7 @@ _win_print(ProfWin *window, const char show_char, GDateTime *time,
wprintw(window->win, "\n"); wprintw(window->win, "\n");
} }
wattroff(window->win, attrs); wattroff(window->win, theme_attrs(theme_item));
if (unattr_me) { if (unattr_me) {
wattroff(window->win, colour); wattroff(window->win, colour);
@ -718,7 +718,7 @@ win_redraw(ProfWin *window)
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
ProfBuffEntry *e = buffer_yield_entry(window->buffer, i); ProfBuffEntry *e = buffer_yield_entry(window->buffer, i);
_win_print(window, e->show_char, e->time, e->flags, e->attrs, e->from, e->message); _win_print(window, e->show_char, e->time, e->flags, e->theme_item, e->from, e->message);
} }
} }

View File

@ -86,7 +86,7 @@ ProfWin* win_create(const char * const title, win_type_t type);
void win_free(ProfWin *window); void win_free(ProfWin *window);
void win_update_virtual(ProfWin *window); void win_update_virtual(ProfWin *window);
void win_move_to_end(ProfWin *window); void win_move_to_end(ProfWin *window);
int win_presence_colour(const char * const presence); theme_item_t win_presence_colour(const char * const presence);
void win_show_contact(ProfWin *window, PContact contact); void win_show_contact(ProfWin *window, PContact contact);
void win_show_occupant(ProfWin *window, Occupant *occupant); void win_show_occupant(ProfWin *window, Occupant *occupant);
void win_show_status_string(ProfWin *window, const char * const from, void win_show_status_string(ProfWin *window, const char * const from,
@ -97,8 +97,8 @@ void win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
const char * const from, const char * const message); const char * const from, const char * const message);
void win_show_info(ProfWin *window, PContact contact); void win_show_info(ProfWin *window, PContact contact);
void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant); void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant);
void win_save_vprint(ProfWin *window, const char show_char, GTimeVal *tstamp, int flags, int attrs, const char * const from, const char * const message, ...); void win_save_vprint(ProfWin *window, const char show_char, GTimeVal *tstamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, ...);
void win_save_print(ProfWin *window, const char show_char, GTimeVal *tstamp, int flags, int attrs, const char * const from, const char * const message); void win_save_print(ProfWin *window, const char show_char, GTimeVal *tstamp, int flags, theme_item_t theme_item, const char * const from, const char * const message);
void win_save_println(ProfWin *window, const char * const message); void win_save_println(ProfWin *window, const char * const message);
void win_save_newline(ProfWin *window); void win_save_newline(ProfWin *window);
void win_redraw(ProfWin *window); void win_redraw(ProfWin *window);

View File

@ -438,7 +438,7 @@ wins_lost_connection(void)
while (curr != NULL) { while (curr != NULL) {
ProfWin *window = curr->data; ProfWin *window = curr->data;
if (window->type != WIN_CONSOLE) { if (window->type != WIN_CONSOLE) {
win_save_print(window, '-', NULL, 0, COLOUR_ERROR, "", "Lost connection."); win_save_print(window, '-', NULL, 0, THEME_ERROR, "", "Lost connection.");
// if current win, set current_win_dirty // if current win, set current_win_dirty
if (wins_is_current(window)) { if (wins_is_current(window)) {