roster-state-colors.diff
author Myhailo Danylenko <isbear@isbear.org.ua>
Fri, 09 Dec 2016 02:12:34 +0200
changeset 92 66f7e2aa040c
parent 87 78238d26911a
permissions -rw-r--r--
Add fix-compile-warning-xmpp_c, refresh queue

# HG changeset patch
# Parent  d4907cafba880f45f2dcf2ced4352c2adf1325ea
Change roster item colors on chatstate change

diff -r d4907cafba88 mcabber/contrib/themes/light.txt
--- a/mcabber/contrib/themes/light.txt	Fri Dec 09 01:38:34 2016 +0200
+++ b/mcabber/contrib/themes/light.txt	Fri Dec 09 01:48:40 2016 +0200
@@ -14,7 +14,6 @@
 set color_bgrostersel  = green
 set color_rostersel    = yellow
 set color_rosterselmsg = red
-set color_rosternewmsg = red
 set color_readmark     = red
 
 # vim:set ft=conf:
diff -r d4907cafba88 mcabber/contrib/themes/light2.txt
--- a/mcabber/contrib/themes/light2.txt	Fri Dec 09 01:38:34 2016 +0200
+++ b/mcabber/contrib/themes/light2.txt	Fri Dec 09 01:48:40 2016 +0200
@@ -14,7 +14,6 @@
 set color_bgrostersel  = black
 set color_rostersel    = brightgreen
 set color_rosterselmsg = red
-set color_rosternewmsg = red
 set color_readmark     = red
 
 # vim:set ft=conf:
diff -r d4907cafba88 mcabber/contrib/themes/oliver.txt
--- a/mcabber/contrib/themes/oliver.txt	Fri Dec 09 01:38:34 2016 +0200
+++ b/mcabber/contrib/themes/oliver.txt	Fri Dec 09 01:48:40 2016 +0200
@@ -14,7 +14,6 @@
 set color_bgrostersel  = yellow
 set color_rostersel    = blue
 set color_rosterselmsg = red
-set color_rosternewmsg = red
 set color_readmark     = red
 
 # vim:set ft=conf:
diff -r d4907cafba88 mcabber/doc/help/en/hlp_color.txt
--- a/mcabber/doc/help/en/hlp_color.txt	Fri Dec 09 01:38:34 2016 +0200
+++ b/mcabber/doc/help/en/hlp_color.txt	Fri Dec 09 01:48:40 2016 +0200
@@ -11,6 +11,7 @@
  Set a color rule (or overwrite, if it already exists).  The status is string containing all statuses the roster item can have for the rule to match, or * if any status is OK.  Wildcard is the file-matching wildcard that will be applied to JID.  Color is the wanted color.
  If color is -, the rule is removed.
  If more than one rule matches, the color from the last created (not overwritten) is used.
+ Also mask can contain symbols '!', '#', '+' and '.', that represent buddies with urgent condition, with new messages, that are typing and that have ceased typing. These symbols have higher priority than status ones.
 /color mucnick nick (color|-)
  Marks the nick to be colored by given color.  If a MUC has colored nicks, this one will be used.  If color is -, the color is marked as chosen automatically, which means it will not be used in 'preset' coloring mode, but will stay the same in 'on' coloring mode.
 /color muc (jid|.|*) [on|preset|off|-]
diff -r d4907cafba88 mcabber/doc/help/uk/hlp_color.txt
--- a/mcabber/doc/help/uk/hlp_color.txt	Fri Dec 09 01:38:34 2016 +0200
+++ b/mcabber/doc/help/uk/hlp_color.txt	Fri Dec 09 01:48:40 2016 +0200
@@ -11,6 +11,7 @@
  Додає нове чи змінює існуюче правило кольору. "Статус" складений з літер статусу, до яких докладається це правило (наприклад "n_d?"). Зірочка ("*") відповідає будь-якому статусу. "Маска" подібна до файлової маски й докладається до jid. Правило встановлює колір контактів, що йому відповідають.
  Щоб вилучити правило, вкажіть колір "-".
  Коли є декілька правил, що відповідають контакту, спрацьовує останнє додане (_не_ змінене).
+ Також рядок статусів може містити символи '!', '#', '+' та '.', що відповідають користувачам, які відповідно мають негайні події, нові повідомлення, друкують та друкували але спинилися. Ці символи мають більший пріоритет ніж символи статусів.
 /color muc (jid|.|*) [on|preset|off|-]
  Встановлює режим забарвлення прізвиськ у чаті. Якщо замість jid вказано * режим докладається до всіх чатів, для яких не визначено особистого правила (з вказанням jid).
  У режимі on забарвлюються усі прізвиська, у режимі preset - лише ті, для яких колір встановлено командою /color mucnick, а режим off вимикає забарвлення прізвиськ. Режим - прибирає з вказаних jid особисті режими забарвлення. Тоді до них докладається глобальний. Глобальний режим прибрати не можна.
diff -r d4907cafba88 mcabber/mcabber/screen.c
--- a/mcabber/mcabber/screen.c	Fri Dec 09 01:38:34 2016 +0200
+++ b/mcabber/mcabber/screen.c	Fri Dec 09 01:48:40 2016 +0200
@@ -229,6 +229,8 @@
 
 /* Functions */
 
+static unsigned int attention_sign(void);
+
 static int find_color(const char *name)
 {
   int result;
@@ -448,7 +450,7 @@
     "roster",
     "rostersel",
     "rosterselmsg",
-    "rosternewmsg",
+    "rosternewmsg", /* not removing this to not break binary compatibility with mainstream */
     "info",
     "msgin",
     "readmark",
@@ -522,10 +524,6 @@
           init_pair(i+1, ((color) ? find_color(color) : COLOR_RED),
                     find_color(backselected));
           break;
-      case COLOR_ROSTERNMSG:
-          init_pair(i+1, ((color) ? find_color(color) : COLOR_RED),
-                    find_color(background));
-          break;
       case COLOR_INFO:
           init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE),
                     find_color(background));
@@ -829,6 +827,24 @@
   settings_set_guard("color_rosternewmsg", scr_color_guard);
   settings_set_guard("color_timestamp", scr_color_guard);
 
+  { // Add default rule only if user has not defined one already
+    GSList *rel;
+    gboolean found = FALSE;
+    for (rel = rostercolrules; rel; rel = rel->next) {
+      rostercolor *rule = rel->data;
+      if ((strchr(rule->status, '#') || strchr(rule->status, attention_sign()))
+          && (!strcmp(rule->wildcard, "*"))) {
+        found = TRUE;
+        break;
+      }
+    }
+    if (!found) {
+      char statuses[3] = "#!";
+      statuses[1] = attention_sign();
+      scr_roster_color(statuses, "*", "red");
+    }
+  }
+
   getmaxyx(stdscr, maxY, maxX);
   Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT;
   // Note scr_draw_main_window() should be called early after scr_init_curses()
@@ -2200,6 +2216,10 @@
     // for unfolded groups.
     if (ismsg && (!isgrp || ishid)) {
       pending = '#';
+      // Attention sign?
+      if ((ismuc && isurg >= ui_attn_sign_prio_level_muc) ||
+          (!ismuc && isurg >= ui_attn_sign_prio_level))
+        pending = attention_sign();
     }
 
     if (ismuc) {
@@ -2223,24 +2243,22 @@
       for (n = 0; n < maxx; n++)
         waddch(rosterWnd, ' ');
     } else {
-      if (pending == '#')
-        wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG));
-      else {
-        int color = get_color(COLOR_ROSTER);
-        if ((!isspe) && (!isgrp)) { // Look for color rules
-          GSList *head;
-          const char *bjid = buddy_getjid(BUDDATA(buddy));
-          for (head = rostercolrules; head; head = g_slist_next(head)) {
-            rostercolor *rc = head->data;
-            if (g_pattern_match_string(rc->compiled, bjid) &&
-                (!strcmp("*", rc->status) || strchr(rc->status, status))) {
-              color = compose_color(rc->color);
-              break;
-            }
+      int color = get_color(COLOR_ROSTER);
+      if ((!isspe) && (!isgrp)) { // Look for color rules
+        GSList *head;
+        const char *jid = buddy_getjid(BUDDATA(buddy));
+        for (head = rostercolrules; head; head = g_slist_next(head)) {
+          rostercolor *rc = head->data;
+          if (g_pattern_match_string(rc->compiled, jid) &&
+              (!strcmp("*", rc->status) ||
+               strchr(rc->status, pending) ||
+               strchr(rc->status, status))) {
+            color = compose_color(rc->color);
+            break;
           }
         }
-        wattrset(rosterWnd, color);
       }
+      wattrset(rosterWnd, color);
     }
 
     if (Roster_Width > prefix_length)
@@ -2248,13 +2266,6 @@
     else
       name[0] = 0;
 
-    if (pending == '#') {
-      // Attention sign?
-      if ((ismuc && isurg >= ui_attn_sign_prio_level_muc) ||
-          (!ismuc && isurg >= ui_attn_sign_prio_level))
-        pending = attention_sign();
-    }
-
     if (isgrp) {
       if (ishid) {
         int group_count = 0;
diff -r d4907cafba88 mcabber/mcabber/screen.h
--- a/mcabber/mcabber/screen.h	Fri Dec 09 01:38:34 2016 +0200
+++ b/mcabber/mcabber/screen.h	Fri Dec 09 01:48:40 2016 +0200
@@ -47,7 +47,7 @@
   COLOR_ROSTER,
   COLOR_ROSTERSEL,
   COLOR_ROSTERSELNMSG,
-  COLOR_ROSTERNMSG,
+  COLOR_ROSTERNMSG, /* not removing this to not break binary compatibility with mainstream */
   COLOR_INFO,
   COLOR_MSGIN,
   COLOR_READMARK,
diff -r d4907cafba88 mcabber/mcabberrc.example
--- a/mcabber/mcabberrc.example	Fri Dec 09 01:38:34 2016 +0200
+++ b/mcabber/mcabberrc.example	Fri Dec 09 01:48:40 2016 +0200
@@ -457,16 +457,25 @@
 #set color_bgrostersel  = cyan
 #set color_rostersel    = blue
 #set color_rosterselmsg = red
-#set color_rosternewmsg = red
 #set color_readmark     = red
 #set color_timestamp    = brightblue
 
-# You can color roster items by their status and JID.  For example, to have
-# all roster items white, just all contacts from jabber.org that are away,
-# not available or do not disturb yellow, you do this:
+# You can color roster items by their status, state and JID.  For example,
+# to have all roster items white, just all contacts from jabber.org that
+# are away, not available or do not disturb yellow, you do this:
 #
 #color roster * * white
 #color roster adn *@jabber.org yellow
+#
+# You can specify '!', '#', '+' and '.' in status mask, they will take
+# precedence over status letters and will select buddies accordingly with
+# urgent condition, with new messages, that are typing and that ceased
+# typing. By default there exists one rule:
+#
+#color roster !# * red
+#
+# However, if you define a rule with either '!' or '#', this default rule
+# will not be added.
 
 # You can let mcabber color nicks in MUC.
 # These colors will by used automatically: