changeset 1295:33cb828282d5

Fix recognizing of bright colors
author Michal 'vorner' Vaner <vorner@ucw.cz>
date Tue, 28 Aug 2007 11:24:58 +0200
parents 86caabe72f3a
children 7a0eaa53bd53
files mcabber/src/screen.c
diffstat 1 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/screen.c	Tue Aug 28 10:52:15 2007 +0200
+++ b/mcabber/src/screen.c	Tue Aug 28 11:24:58 2007 +0200
@@ -241,6 +241,22 @@
   return -1;
 }
 
+static int get_user_color(const char *color)
+{
+  bool isbright = false;
+  int cl;
+  if (!strncmp(color, "bright", 6)) {
+    isbright = true;
+    color += 6;
+  }
+  cl = color_to_color_fg(FindColorInternal(color));
+  if (cl < 0)
+    return cl;
+  if (isbright)
+    cl += COLOR_BLACK_BOLD_FG - COLOR_BLACK_FG;
+  return cl;
+}
+
 static void ensure_string_htable(GHashTable **table,
     GDestroyNotify value_destroy_func)
 {
@@ -302,7 +318,7 @@
     g_free(mnick);
     need_update = true;
   } else {
-    int cl = color_to_color_fg(FindColorInternal(color));
+    int cl = get_user_color(color);
     if (cl < 0) {
       scr_LogPrint(LPRINT_NORMAL, "No such color name");
       g_free(snick);
@@ -373,15 +389,7 @@
       return FALSE;
     }
   } else {
-    bool isbright = false;
-    int cl;
-    if (!strncmp(color, "bright", 6)) {
-      isbright = true;
-      color += 6;
-    }
-    cl = color_to_color_fg(FindColorInternal(color));
-    if (isbright)
-      cl += COLOR_BLACK_BOLD_FG - COLOR_BLACK_FG;
+    int cl = get_user_color(color);
     if (cl < 0 ) {
       scr_LogPrint(LPRINT_NORMAL, "No such color name");
       return FALSE;