diff --git a/src/preferences.h b/src/preferences.h index 83704529..2c644b9f 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -49,6 +49,10 @@ void prefs_add_login(const char *jid); NCURSES_COLOR_T prefs_get_bkgnd(); NCURSES_COLOR_T prefs_get_text(); NCURSES_COLOR_T prefs_get_online(); +NCURSES_COLOR_T prefs_get_away(); +NCURSES_COLOR_T prefs_get_chat(); +NCURSES_COLOR_T prefs_get_dnd(); +NCURSES_COLOR_T prefs_get_xa(); NCURSES_COLOR_T prefs_get_offline(); NCURSES_COLOR_T prefs_get_err(); NCURSES_COLOR_T prefs_get_inc(); diff --git a/src/status_bar.c b/src/status_bar.c index 7d194600..5005f2b9 100644 --- a/src/status_bar.c +++ b/src/status_bar.c @@ -50,10 +50,10 @@ create_status_bar(void) } status_bar = newwin(1, cols, rows-2, 0); - wbkgd(status_bar, COLOR_PAIR(8)); - wattron(status_bar, COLOR_PAIR(4)); + wbkgd(status_bar, COLOUR_BAR_DEF); + wattron(status_bar, COLOUR_BAR_DRAW); mvwprintw(status_bar, 0, cols - 29, _active); - wattroff(status_bar, COLOR_PAIR(4)); + wattroff(status_bar, COLOUR_BAR_DRAW); get_time(curr_time); dirty = TRUE; @@ -86,11 +86,11 @@ status_bar_resize(void) mvwin(status_bar, rows-2, 0); wresize(status_bar, 1, cols); - wbkgd(status_bar, COLOR_PAIR(8)); + wbkgd(status_bar, COLOUR_BAR_DEF); wclear(status_bar); - wattron(status_bar, COLOR_PAIR(4)); + wattron(status_bar, COLOUR_BAR_DRAW); mvwprintw(status_bar, 0, cols - 29, _active); - wattroff(status_bar, COLOR_PAIR(4)); + wattroff(status_bar, COLOUR_BAR_DRAW); for(i = 0; i < 9; i++) { if (is_new[i]) @@ -135,12 +135,12 @@ status_bar_active(const int win) int rows, cols; getmaxyx(stdscr, rows, cols); - wattron(status_bar, COLOR_PAIR(4)); + wattron(status_bar, COLOUR_BAR_DRAW); if (win < 9) mvwprintw(status_bar, 0, cols - 29 + active_pos, "%d", win+1); else mvwprintw(status_bar, 0, cols - 29 + active_pos, "10"); - wattroff(status_bar, COLOR_PAIR(4)); + wattroff(status_bar, COLOUR_BAR_DRAW); dirty = TRUE; } @@ -156,13 +156,13 @@ status_bar_new(const int win) int rows, cols; getmaxyx(stdscr, rows, cols); - wattron(status_bar, COLOR_PAIR(3)); + wattron(status_bar, COLOUR_BAR_TEXT); wattron(status_bar, A_BLINK); if (win < 9) mvwprintw(status_bar, 0, cols - 29 + active_pos, "%d", win+1); else mvwprintw(status_bar, 0, cols - 29 + active_pos, "10"); - wattroff(status_bar, COLOR_PAIR(3)); + wattroff(status_bar, COLOUR_BAR_TEXT); wattroff(status_bar, A_BLINK); dirty = TRUE; @@ -206,9 +206,9 @@ status_bar_clear(void) int rows, cols; getmaxyx(stdscr, rows, cols); - wattron(status_bar, COLOR_PAIR(4)); + wattron(status_bar, COLOUR_BAR_DRAW); mvwprintw(status_bar, 0, cols - 29, _active); - wattroff(status_bar, COLOR_PAIR(4)); + wattroff(status_bar, COLOUR_BAR_DRAW); dirty = TRUE; } @@ -221,13 +221,13 @@ _status_bar_update_time(void) get_time(tstmp); sprintf(bar_time, "%s", tstmp); - wattron(status_bar, COLOR_PAIR(4)); + wattron(status_bar, COLOUR_BAR_DRAW); mvwaddch(status_bar, 0, 1, '['); - wattroff(status_bar, COLOR_PAIR(4)); + wattroff(status_bar, COLOUR_BAR_DRAW); mvwprintw(status_bar, 0, 2, bar_time); - wattron(status_bar, COLOR_PAIR(4)); + wattron(status_bar, COLOUR_BAR_DRAW); mvwaddch(status_bar, 0, 7, ']'); - wattroff(status_bar, COLOR_PAIR(4)); + wattroff(status_bar, COLOUR_BAR_DRAW); dirty = TRUE; } diff --git a/src/title_bar.c b/src/title_bar.c index 9fa184c0..5af45c94 100644 --- a/src/title_bar.c +++ b/src/title_bar.c @@ -46,7 +46,7 @@ create_title_bar(void) getmaxyx(stdscr, rows, cols); title_bar = newwin(1, cols, 0, 0); - wbkgd(title_bar, COLOR_PAIR(8)); + wbkgd(title_bar, COLOUR_BAR_DEF); title_bar_title(); title_bar_set_status(PRESENCE_OFFLINE); dirty = TRUE; @@ -68,7 +68,7 @@ title_bar_resize(void) getmaxyx(stdscr, rows, cols); wresize(title_bar, 1, cols); - wbkgd(title_bar, COLOR_PAIR(8)); + wbkgd(title_bar, COLOUR_BAR_DEF); wclear(title_bar); _title_bar_draw_title(); _title_bar_draw_status(); @@ -179,9 +179,9 @@ _title_bar_draw_status(void) int rows, cols; getmaxyx(stdscr, rows, cols); - wattron(title_bar, COLOR_PAIR(4)); + wattron(title_bar, COLOUR_BAR_DRAW); mvwaddch(title_bar, 0, cols - 14, '['); - wattroff(title_bar, COLOR_PAIR(4)); + wattroff(title_bar, COLOUR_BAR_DRAW); if (current_status == PRESENCE_ONLINE) { mvwprintw(title_bar, 0, cols - 13, " ...online "); @@ -197,9 +197,9 @@ _title_bar_draw_status(void) mvwprintw(title_bar, 0, cols - 13, " ..offline "); } - wattron(title_bar, COLOR_PAIR(4)); + wattron(title_bar, COLOUR_BAR_DRAW); mvwaddch(title_bar, 0, cols - 2, ']'); - wattroff(title_bar, COLOR_PAIR(4)); + wattroff(title_bar, COLOUR_BAR_DRAW); dirty = TRUE; } diff --git a/src/ui.h b/src/ui.h index 5d0284e6..0ba23dc8 100644 --- a/src/ui.h +++ b/src/ui.h @@ -30,6 +30,19 @@ #define INP_WIN_MAX 1000 +#define COLOUR_TEXT COLOR_PAIR(1) +#define COLOUR_ONLINE COLOR_PAIR(2) +#define COLOUR_BAR_TEXT COLOR_PAIR(3) +#define COLOUR_BAR_DRAW COLOR_PAIR(4) +#define COLOUR_OFFLINE COLOR_PAIR(5) +#define COLOUR_ERR COLOR_PAIR(6) +#define COLOUR_INC COLOR_PAIR(7) +#define COLOUR_BAR_DEF COLOR_PAIR(8) +#define COLOUR_AWAY COLOR_PAIR(9) +#define COLOUR_CHAT COLOR_PAIR(10) +#define COLOUR_DND COLOR_PAIR(11) +#define COLOUR_XA COLOR_PAIR(12) + struct prof_win { char from[100]; WINDOW *win; diff --git a/src/windows.c b/src/windows.c index 96d606d5..3426258f 100644 --- a/src/windows.c +++ b/src/windows.c @@ -100,6 +100,12 @@ gui_init(void) init_pair(6, prefs_get_err(), prefs_get_bkgnd()); init_pair(7, prefs_get_inc(), prefs_get_bkgnd()); init_pair(8, prefs_get_bar_text(), prefs_get_bar()); + + //statuses + init_pair(9, prefs_get_away(), prefs_get_bkgnd()); + init_pair(10, prefs_get_chat(), prefs_get_bkgnd()); + init_pair(11, prefs_get_dnd(), prefs_get_bkgnd()); + init_pair(12, prefs_get_xa(), prefs_get_bkgnd()); } refresh(); @@ -344,9 +350,9 @@ win_bad_show(const char * const msg) { WINDOW *win = _wins[_curr_prof_win].win; _win_show_time(win); - wattron(win, COLOR_PAIR(6)); + wattron(win, COLOUR_ERR); wprintw(win, "%s\n", msg); - wattroff(win, COLOR_PAIR(6)); + wattroff(win, COLOUR_ERR); dirty = TRUE; } @@ -392,9 +398,9 @@ win_disconnected(void) if (strcmp(_wins[i].from, "") != 0) { WINDOW *win = _wins[_curr_prof_win].win; _win_show_time(win); - wattron(win, COLOR_PAIR(6)); + wattron(win, COLOUR_ERR); wprintw(win, "%s\n", "Lost connection."); - wattroff(win, COLOR_PAIR(6)); + wattroff(win, COLOUR_ERR); // if current win, set dirty if (i == _curr_prof_win) { @@ -523,14 +529,16 @@ cons_show_online_contacts(GSList *list) while(curr) { PContact contact = curr->data; _win_show_time(_cons_win); - wattron(_cons_win, COLOR_PAIR(2)); + + wattron(_cons_win, COLOUR_ONLINE); wprintw(_cons_win, "%s", p_contact_name(contact)); - if (p_contact_show(contact)) - wprintw(_cons_win, " is %s", p_contact_show(contact)); + wprintw(_cons_win, " is %s", p_contact_show(contact)); + if (p_contact_status(contact)) wprintw(_cons_win, ", \"%s\"", p_contact_status(contact)); + wprintw(_cons_win, "\n"); - wattroff(_cons_win, COLOR_PAIR(2)); + wattroff(_cons_win, COLOUR_ONLINE); curr = g_slist_next(curr); } @@ -540,9 +548,9 @@ void cons_bad_show(const char * const msg) { _win_show_time(_cons_win); - wattron(_cons_win, COLOR_PAIR(6)); + wattron(_cons_win, COLOUR_ERR); wprintw(_cons_win, "%s\n", msg); - wattroff(_cons_win, COLOR_PAIR(6)); + wattroff(_cons_win, COLOUR_ERR); if (_curr_prof_win == 0) dirty = TRUE; @@ -605,7 +613,7 @@ _create_windows(void) struct prof_win cons; strcpy(cons.from, CONS_WIN_TITLE); cons.win = newpad(PAD_SIZE, cols); - wbkgd(cons.win, COLOR_PAIR(1)); + wbkgd(cons.win, COLOUR_TEXT); cons.y_pos = 0; cons.paged = 0; scrollok(cons.win, TRUE); @@ -646,7 +654,7 @@ _create_windows(void) struct prof_win chat; strcpy(chat.from, ""); chat.win = newpad(PAD_SIZE, cols); - wbkgd(chat.win, COLOR_PAIR(1)); + wbkgd(chat.win, COLOUR_TEXT); chat.y_pos = 0; chat.paged = 0; // wattrset(chat.win, A_BOLD); @@ -659,7 +667,7 @@ static void _print_splash_logo(WINDOW *win) { wprintw(win, "Welcome to\n"); - wattron(win, COLOR_PAIR(5)); + wattron(win, COLOUR_OFFLINE); wprintw(win, " ___ _ \n"); wprintw(win, " / __) (_)_ \n"); wprintw(win, " ____ ____ ___ | |__ ____ ____ _| |_ _ _ \n"); @@ -667,7 +675,7 @@ _print_splash_logo(WINDOW *win) wprintw(win, "| | | | | | |_| | | ( ( | | | | | | |_| |_| |\n"); wprintw(win, "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |\n"); wprintw(win, "|_| (____/ \n"); - wattroff(win, COLOR_PAIR(5)); + wattroff(win, COLOUR_OFFLINE); } static int @@ -730,10 +738,10 @@ static void _win_show_user(WINDOW *win, const char * const user, const int colour) { if (colour) - wattron(win, COLOR_PAIR(2)); + wattron(win, COLOUR_ONLINE); wprintw(win, "%s: ", user); if (colour) - wattroff(win, COLOR_PAIR(2)); + wattroff(win, COLOUR_ONLINE); } static void @@ -779,10 +787,9 @@ _show_status_string(WINDOW *win, const char * const from, { _win_show_time(win); if (strcmp(default_show, "online") == 0) { - wattron(win, COLOR_PAIR(2)); + wattron(win, COLOUR_ONLINE); } else { - wattron(win, COLOR_PAIR(5)); -// wattroff(win, A_BOLD); + wattron(win, COLOUR_OFFLINE); } wprintw(win, "%s %s", pre, from); @@ -798,10 +805,9 @@ _show_status_string(WINDOW *win, const char * const from, wprintw(win, "\n"); if (strcmp(default_show, "online") == 0) { - wattroff(win, COLOR_PAIR(2)); + wattroff(win, COLOUR_ONLINE); } else { - wattroff(win, COLOR_PAIR(5)); -// wattron(win, A_BOLD); + wattroff(win, COLOUR_OFFLINE); } } @@ -809,18 +815,18 @@ static void _cons_show_typing(const char * const short_from) { _win_show_time(_cons_win); - wattron(_cons_win, COLOR_PAIR(7)); + wattron(_cons_win, COLOUR_INC); wprintw(_cons_win, "!! %s is typing a message...\n", short_from); - wattroff(_cons_win, COLOR_PAIR(7)); + wattroff(_cons_win, COLOUR_INC); } static void _cons_show_incoming_message(const char * const short_from, const int win_index) { _win_show_time(_cons_win); - wattron(_cons_win, COLOR_PAIR(7)); + wattron(_cons_win, COLOUR_INC); wprintw(_cons_win, "<< incoming from %s (%d)\n", short_from, win_index + 1); - wattroff(_cons_win, COLOR_PAIR(7)); + wattroff(_cons_win, COLOUR_INC); } static void