roster-state-colors.diff
changeset 36 b8854e2fe147
parent 29 335662766a88
child 57 cfa24a16e928
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/roster-state-colors.diff	Sat Jul 28 19:42:13 2012 +0300
@@ -0,0 +1,214 @@
+Change roster item colors on chatstate change
+
+diff -r 7222f7b386cb mcabber/contrib/themes/light.txt
+--- a/mcabber/contrib/themes/light.txt	Mon Apr 30 23:38:20 2012 +0300
++++ b/mcabber/contrib/themes/light.txt	Mon Apr 30 23:38:36 2012 +0300
+@@ -13,6 +13,5 @@
+ set color_bgrostersel  = green
+ set color_rostersel    = yellow
+ set color_rosterselmsg = red
+-set color_rosternewmsg = red
+ 
+ # vim:set ft=conf:
+diff -r 7222f7b386cb mcabber/contrib/themes/light2.txt
+--- a/mcabber/contrib/themes/light2.txt	Mon Apr 30 23:38:20 2012 +0300
++++ b/mcabber/contrib/themes/light2.txt	Mon Apr 30 23:38:36 2012 +0300
+@@ -13,6 +13,5 @@
+ set color_bgrostersel  = black
+ set color_rostersel    = brightgreen
+ set color_rosterselmsg = red
+-set color_rosternewmsg = red
+ 
+ # vim:set ft=conf:
+diff -r 7222f7b386cb mcabber/contrib/themes/oliver.txt
+--- a/mcabber/contrib/themes/oliver.txt	Mon Apr 30 23:38:20 2012 +0300
++++ b/mcabber/contrib/themes/oliver.txt	Mon Apr 30 23:38:36 2012 +0300
+@@ -13,6 +13,5 @@
+ set color_bgrostersel  = yellow
+ set color_rostersel    = blue
+ set color_rosterselmsg = red
+-set color_rosternewmsg = red
+ 
+ # vim:set ft=conf:
+diff -r 7222f7b386cb mcabber/doc/help/en/hlp_color.txt
+--- a/mcabber/doc/help/en/hlp_color.txt	Mon Apr 30 23:38:20 2012 +0300
++++ b/mcabber/doc/help/en/hlp_color.txt	Mon Apr 30 23:38:36 2012 +0300
+@@ -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 7222f7b386cb mcabber/doc/help/uk/hlp_color.txt
+--- a/mcabber/doc/help/uk/hlp_color.txt	Mon Apr 30 23:38:20 2012 +0300
++++ b/mcabber/doc/help/uk/hlp_color.txt	Mon Apr 30 23:38:36 2012 +0300
+@@ -11,6 +11,7 @@
+  Додає нове чи змінює існуюче правило кольору. "Статус" складений з літер статусу, до яких докладається це правило (наприклад "n_d?"). Зірочка ("*") відповідає будь-якому статусу. "Маска" подібна до файлової маски й докладається до jid. Правило встановлює колір контактів, що йому відповідають.
+  Щоб вилучити правило, вкажіть колір "-".
+  Коли є декілька правил, що відповідають контакту, спрацьовує останнє додане (_не_ змінене).
++ Також рядок статусів може містити символи '!', '#', '+' та '.', що відповідають користувачам, які відповідно мають негайні події, нові повідомлення, друкують та друкували але спинилися. Ці символи мають більший пріоритет ніж символи статусів.
+ /color muc (jid|.|*) [on|preset|off|-]
+  Встановлює режим забарвлення прізвиськ у чаті. Якщо замість jid вказано * режим докладається до всіх чатів, для яких не визначено особистого правила (з вказанням jid).
+  У режимі on забарвлюються усі прізвиська, у режимі preset - лише ті, для яких колір встановлено командою /color mucnick, а режим off вимикає забарвлення прізвиськ. Режим - прибирає з вказаних jid особисті режими забарвлення. Тоді до них докладається глобальний. Глобальний режим прибрати не можна.
+diff -r 7222f7b386cb mcabber/mcabber/screen.c
+--- a/mcabber/mcabber/screen.c	Mon Apr 30 23:38:20 2012 +0300
++++ b/mcabber/mcabber/screen.c	Mon Apr 30 23:38:36 2012 +0300
+@@ -435,7 +435,7 @@
+     "roster",
+     "rostersel",
+     "rosterselmsg",
+-    "rosternewmsg",
++    "rosternewmsg", /* not removing this to not break binary compatibility with mainstream */
+     "info",
+     "msgin",
+     "readmark",
+@@ -504,10 +504,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));
+@@ -805,6 +801,21 @@
+   settings_set_guard("color_rosterselmsg", scr_color_guard);
+   settings_set_guard("color_rosternewmsg", 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, '!'))
++          && (!strcmp(rule->wildcard, "*"))) {
++        found = TRUE;
++        break;
++      }
++    }
++    if (!found)
++      scr_roster_color("#!", "*", "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()
+@@ -2071,6 +2082,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 = '!';
+     }
+ 
+     if (ismuc) {
+@@ -2094,24 +2109,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)
+@@ -2119,13 +2132,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 = '!';
+-    }
+-
+     if (isgrp) {
+       if (ishid) {
+         int group_count = 0;
+diff -r 7222f7b386cb mcabber/mcabber/screen.h
+--- a/mcabber/mcabber/screen.h	Mon Apr 30 23:38:20 2012 +0300
++++ b/mcabber/mcabber/screen.h	Mon Apr 30 23:38:36 2012 +0300
+@@ -46,7 +46,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 7222f7b386cb mcabber/mcabberrc.example
+--- a/mcabber/mcabberrc.example	Mon Apr 30 23:38:20 2012 +0300
++++ b/mcabber/mcabberrc.example	Mon Apr 30 23:38:36 2012 +0300
+@@ -395,7 +395,6 @@
+ # bgrostersel: background color of the selected roster item
+ # rostersel:   text color of the selected roster item
+ # rosterselmsg:text color of the selected roster item, if there is a new msg
+-# rosternewmsg: text color of items with unread messages
+ #
+ #set color_background   = black
+ #set color_general      = white
+@@ -409,15 +408,24 @@
+ #set color_bgrostersel  = cyan
+ #set color_rostersel    = blue
+ #set color_rosterselmsg = red
+-#set color_rosternewmsg = red
+ #set color_readmark     = red
+ 
+-# 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: