changeset 2100:113d3b96ae3e

Add option 'attention_char'
author Mikael Berthe <mikael@lilotux.net>
date Sun, 11 May 2014 14:27:05 +0200
parents a9440a1d52e5
children f56c214a19dc
files mcabber/mcabber/screen.c mcabber/mcabberrc.example
diffstat 2 files changed, 31 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/screen.c	Thu May 08 21:52:39 2014 +0200
+++ b/mcabber/mcabber/screen.c	Sun May 11 14:27:05 2014 +0200
@@ -68,6 +68,8 @@
 #define DEFAULT_ROSTER_WIDTH    24
 #define CHAT_WIN_HEIGHT (maxY-1-Log_Win_Height)
 
+#define DEFAULT_ATTENTION_CHAR '!'
+
 const char *LocaleCharSet = "C";
 
 static unsigned short int Log_Win_Height;
@@ -1531,6 +1533,18 @@
   }
 }
 
+static unsigned int attention_sign(void)
+{
+  guint sign;
+  const char *as = settings_opt_get("attention_char");
+  if (!as)
+      return DEFAULT_ATTENTION_CHAR;
+  sign = get_char(as);
+  if (get_char_width(as) != 1 || !iswprint(sign)) // XXX Better use a guard
+      return DEFAULT_ATTENTION_CHAR;
+  return sign;
+}
+
 //  scr_update_main_status(forceupdate)
 // Redraw the main (bottom) status line.
 // You can set forceupdate to FALSE in order to optimize screen refresh
@@ -1541,7 +1555,7 @@
   const char *info = settings_opt_get("info");
   guint prio = 0;
   gpointer unread_ptr;
-  char unreadchar;
+  guint unreadchar;
 
   unread_ptr = unread_msg(NULL);
   if (unread_ptr) {
@@ -1554,7 +1568,7 @@
 
   // Status bar unread message flag
   if (prio >= ROSTER_UI_PRIO_MUC_HL_MESSAGE)
-    unreadchar = '!';
+    unreadchar = attention_sign();
   else if (prio > 0)
     unreadchar = '#';
   else
@@ -1563,12 +1577,12 @@
   werase(mainstatusWnd);
   if (info) {
     char *info_locale = from_utf8(info);
-    mvwprintw(mainstatusWnd, 0, 0, "%c[%c] %s %s", unreadchar,
+    mvwprintw(mainstatusWnd, 0, 0, "%lc[%c] %s %s", unreadchar,
               imstatus2char[xmpp_getstatus()],
               info_locale, (sm ? sm : ""));
     g_free(info_locale);
   } else
-    mvwprintw(mainstatusWnd, 0, 0, "%c[%c] %s", unreadchar,
+    mvwprintw(mainstatusWnd, 0, 0, "%lc[%c] %s", unreadchar,
               imstatus2char[xmpp_getstatus()], (sm ? sm : ""));
   if (forceupdate) {
     top_panel(inputPanel);
@@ -2001,7 +2015,7 @@
   int i, n;
   int rOffset;
   int cursor_backup;
-  char status, pending;
+  guint status, pending;
   enum imstatus currentstatus = xmpp_getstatus();
   int x_pos;
   char *space;
@@ -2170,7 +2184,7 @@
       // Attention sign?
       if ((ismuc && isurg >= ui_attn_sign_prio_level_muc) ||
           (!ismuc && isurg >= ui_attn_sign_prio_level))
-        pending = '!';
+        pending = attention_sign();
     }
 
     if (isgrp) {
@@ -2178,16 +2192,16 @@
         int group_count = 0;
         foreach_group_member(BUDDATA(buddy), increment_if_buddy_not_filtered,
                              &group_count);
-        snprintf(rline, 4*Roster_Width, "%s%c+++ %s (%i)", space, pending, name,
-                 group_count);
+        snprintf(rline, 4*Roster_Width, "%s%lc+++ %s (%i)", space, pending,
+                 name, group_count);
         /* Do not display the item count if there isn't enough space */
         if (g_utf8_strlen(rline, 4*Roster_Width) >= Roster_Width)
-          snprintf(rline, 4*Roster_Width, "%s%c+++ %s", space, pending, name);
+          snprintf(rline, 4*Roster_Width, "%s%lc+++ %s", space, pending, name);
       }
       else
-        snprintf(rline, 4*Roster_Width, "%s%c--- %s", space, pending, name);
+        snprintf(rline, 4*Roster_Width, "%s%lc--- %s", space, pending, name);
     } else if (isspe) {
-      snprintf(rline, 4*Roster_Width, "%s%c%s", space, pending, name);
+      snprintf(rline, 4*Roster_Width, "%s%lc%s", space, pending, name);
     } else {
       char sepleft  = '[';
       char sepright = ']';
@@ -2200,8 +2214,8 @@
           sepright = '}';
         }
       }
-      snprintf(rline, 4*Roster_Width,
-               "%s%c%c%c%c %s", space, pending, sepleft, status, sepright, name);
+      snprintf(rline, 4*Roster_Width, "%s%lc%c%c%c %s",
+               space, pending, sepleft, status, sepright, name);
     }
 
     rline_locale = from_utf8(rline);
--- a/mcabber/mcabberrc.example	Thu May 08 21:52:39 2014 +0200
+++ b/mcabber/mcabberrc.example	Sun May 11 14:27:05 2014 +0200
@@ -457,6 +457,10 @@
 #set log_win_on_top = 0
 #set roster_win_on_right = 0
 #
+# The attention sign (default: '!') used when a private message is received
+# can be changed with the 'attention_char' option.
+#set attention_char = !
+#
 # By default, the displayed name of a contact in the roster window will
 # be the JID if no name has been specified.  You can use the following
 # option if you only want to see the username part.