]> Pileus Git - ~andy/lamechat/commitdiff
Fix color schemes
authorAndy Spencer <andy753421@gmail.com>
Mon, 23 Oct 2017 05:37:52 +0000 (05:37 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 23 Oct 2017 05:37:52 +0000 (05:37 +0000)
view.c

diff --git a/view.c b/view.c
index 56b9d0eaed694b474d2344e8b42679eb07668bd1..897e432e83efe354b3a2d92bdf6d1a20c80108c8 100644 (file)
--- a/view.c
+++ b/view.c
@@ -135,7 +135,7 @@ static int str_color(const char *str)
 {
        int h,s,l, t,c,x,m, r,g,b;
 
-       int n = str_hash(str);
+       unsigned int n = str_hash(str);
 
        h = (n /     0x1) % 0x100;            // 0..256
        s = (n /   0x100) % 0x100;            // 0..256
@@ -145,9 +145,9 @@ static int str_color(const char *str)
        s = s / 0x4 + 0xC0;                   // 0..256
 
        switch (theme) {
-               case THEME_NORMAL: l =  l / 0x4 + 0x80; break;
-               case THEME_DARK:   l =  l / 0x4 + 0x30; break;
-               case THEME_LIGHT:  l =  l / 0x4 + 0x60; break;
+               case THEME_DARK:   l =  l / 0x4 + 0x80; break;
+               case THEME_LIGHT:  l =  l / 0x4 + 0x30; break;
+               case THEME_NORMAL: l =  l / 0x4 + 0x60; break;
        }
 
        t = h / 60;                           // ,1,2,3,4,5
@@ -169,7 +169,7 @@ static int str_color(const char *str)
        //debug("%12s %3d,%02x,%02x -> "
        //      "tcxm=%d,%02x,%02x,%02x -> "
        //      "rgb=%02x,%02x,%02x -> %d",
-       //           name, h,s,l, t,c,x,m, r,g,b, x);
+       //           str, h,s,l, t,c,x,m, r,g,b, x);
 
        return color(x, -1);
 }
@@ -391,6 +391,11 @@ static int send_command(const char *text)
        else if (match(text, "/sort")) {
                qsort(messages, history, sizeof(message_t), msg_compare);
        }
+       else if (prefix(text, "/theme", &arg)) {
+               for (int i = 0; i < N_ELEMENTS(themes); i++)
+                       if (match(themes[i], arg))
+                               theme = i;
+       }
        else if (prefix(text, "/open", &arg)) {
                if (!arg && focus)
                        arg = focus->channel->name;
@@ -425,7 +430,7 @@ static int send_command(const char *text)
                if (focus->filter)
                        regcomp(&focus->regex, focus->filter, RE_FLAGS);
        }
-       else if (focus) {
+       else if (focus && focus->channel) {
                chat_send(focus->channel, text);
        }
        else {