changeset 2328:1e24d93746d6

Fix roster colors, closes issue #60 According to the X/Open Curses standard Issue 4 v2, it is unspecified whether wattrset can change attributes except A_BLINK, A_BOLD, A_DIM, A_REVERSE, A_STANDOUT, A_UNDERLINE. Thus we should use wbkgdset() for changing colors.
author franky
date Thu, 09 May 2019 21:19:31 +0200
parents 8ecc28068748
children 746d72c6e1b9
files mcabber/mcabber/screen.c
diffstat 1 files changed, 17 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/screen.c	Fri Sep 28 17:56:42 2018 +0200
+++ b/mcabber/mcabber/screen.c	Thu May 09 21:19:31 2019 +0200
@@ -1266,7 +1266,7 @@
         color = COLOR_GENERAL;
 
       if (color != COLOR_GENERAL)
-        wattrset(win_entry->win, get_color(color));
+        wbkgdset(win_entry->win, get_color(color));
 
       // Generate the prefix area and display it
 
@@ -1276,10 +1276,10 @@
 
         tmp = pref[timelen];
         pref[timelen] = '\0';
-        wattrset(win_entry->win, get_color(COLOR_TIMESTAMP));
+        wbkgdset(win_entry->win, get_color(COLOR_TIMESTAMP));
         wprintw(win_entry->win, pref);
         pref[timelen] = tmp;
-        wattrset(win_entry->win, get_color(color));
+        wbkgdset(win_entry->win, get_color(color));
         wprintw(win_entry->win, pref+timelen);
       } else
         wprintw(win_entry->win, pref);
@@ -1334,18 +1334,22 @@
         if (actual && ((type == MC_ALL) || (actual->manual))
             && (line->flags & HBB_PREFIX_IN) &&
            (!(line->flags & HBB_PREFIX_HLIGHT_OUT)))
-          wattrset(win_entry->win, compose_color(actual->color));
+          wbkgdset(win_entry->win, compose_color(actual->color));
         wprintw(win_entry->win, "%s", line->text);
         // Return the char
         line->text[line->mucnicklen] = tmp;
         // Return the color back
-        wattrset(win_entry->win, get_color(color));
+        wbkgdset(win_entry->win, get_color(color));
       }
 
       // Display text line
       wprintw(win_entry->win, "%s", line->text+line->mucnicklen);
       wclrtoeol(win_entry->win);
 
+      // Restore default ("general") color
+      if (color != COLOR_GENERAL)
+        wbkgdset(win_entry->win, get_color(COLOR_GENERAL));
+
 scr_update_window_skipline:
       skipline = FALSE;
       if (readmark && line->flags & HBB_PREFIX_READMARK) {
@@ -1355,21 +1359,15 @@
         // Display the mark
         winy = n + mark_offset;
         wmove(win_entry->win, winy, 0);
-        color = COLOR_READMARK;
-        wattrset(win_entry->win, get_color(color));
+        wbkgdset(win_entry->win, get_color(COLOR_READMARK));
         g_snprintf(pref, prefixwidth, "             == ");
         wprintw(win_entry->win, pref);
         w = scr_gettextwidth() / 3;
         for (i=0; i<w; i++)
           wprintw(win_entry->win, "== ");
         wclrtoeol(win_entry->win);
-        wattrset(win_entry->win, get_color(COLOR_GENERAL));
+        wbkgdset(win_entry->win, get_color(COLOR_GENERAL));
       }
-
-      // Restore default ("general") color
-      if (color != COLOR_GENERAL)
-        wattrset(win_entry->win, get_color(COLOR_GENERAL));
-
       g_free(line->text);
       g_free(line);
     } else {
@@ -1758,11 +1756,9 @@
     wbkgd(rosterWnd,      get_color(COLOR_GENERAL));
     wbkgd(chatWnd,        get_color(COLOR_GENERAL));
     wbkgd(activechatWnd,  get_color(COLOR_GENERAL));
-    wbkgd(logWnd,         get_color(COLOR_GENERAL));
+    wbkgd(logWnd,         get_color(COLOR_LOG));
     wbkgd(chatstatusWnd,  get_color(COLOR_STATUS));
     wbkgd(mainstatusWnd,  get_color(COLOR_STATUS));
-
-    wattrset(logWnd,      get_color(COLOR_LOG));
   } else {
     /* Resize/move windows */
     wresize(rosterWnd, CHAT_WIN_HEIGHT, Roster_Width);
@@ -2127,12 +2123,12 @@
     scr_update_chat_status(FALSE);
 
   // Cleanup of roster window
+  wbkgdset(rosterWnd, get_color(COLOR_GENERAL)); // clear background color
   werase(rosterWnd);
 
   if (Roster_Width) {
     int line_x_pos = roster_win_on_right ? 0 : Roster_Width-1;
     // Redraw the vertical line (not very good...)
-    wattrset(rosterWnd, get_color(COLOR_GENERAL));
     for (i=0 ; i < CHAT_WIN_HEIGHT ; i++)
       mvwaddch(rosterWnd, i, line_x_pos, ACS_VLINE);
   }
@@ -2242,16 +2238,16 @@
     }
     if (buddy == current_buddy) {
       if (pending == '#')
-        wattrset(rosterWnd, get_color(COLOR_ROSTERSELNMSG));
+        wbkgdset(rosterWnd, get_color(COLOR_ROSTERSELNMSG));
       else
-        wattrset(rosterWnd, get_color(COLOR_ROSTERSEL));
+        wbkgdset(rosterWnd, get_color(COLOR_ROSTERSEL));
       // The 3 following lines aim at coloring the whole line
       wmove(rosterWnd, i, x_pos);
       for (n = 0; n < maxx; n++)
         waddch(rosterWnd, ' ');
     } else {
       if (pending == '#')
-        wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG));
+        wbkgdset(rosterWnd, get_color(COLOR_ROSTERNMSG));
       else {
         int color = get_color(COLOR_ROSTER);
         if ((!isspe) && (!isgrp)) { // Look for color rules
@@ -2266,7 +2262,7 @@
             }
           }
         }
-        wattrset(rosterWnd, color);
+        wbkgdset(rosterWnd, color);
       }
     }