]> code.citadel.org Git - citadel.git/blobdiff - citadel/commands.c
* Added a fourth color mode in the client: "user" which turns color
[citadel.git] / citadel / commands.c
index 6262901d48d432423d3d38b403461634580a7a21..e30a34399407266d28b40bc413c2103f5eb762a8 100644 (file)
@@ -411,6 +411,8 @@ void load_command_set(void) {
                        rc_ansi_color = 1;
                if (!strncasecmp(&buf[11], "auto", 4)) 
                        rc_ansi_color = 2;      /* autodetect */
+               if (!strncasecmp(&buf[11], "user", 4)) 
+                       rc_ansi_color = 3;      /* user config */
                }
 
            if (!struncmp(buf,"username=",9))
@@ -577,6 +579,12 @@ int getcmd(char *argbuf)
        int this_lazy_cmd;
        struct citcmd *cptr;
 
+       /* Switch color support on or off if we're in user mode */
+       if (rc_ansi_color == 3) {
+               if (userflags & US_COLOR) enable_color = 1;
+               else enable_color = 0;
+               }
+
        /* if we're running in idiot mode, display a cute little menu */
        IFNEXPERT formout("mainmenu");
 
@@ -942,32 +950,35 @@ void look_for_ansi(void) {
        else if (rc_ansi_color == 1) {
                enable_color = 1;
                }
+       else if (rc_ansi_color == 2) {
 
-       /* otherwise, do the auto-detect */
+               /* otherwise, do the auto-detect */
 
-       strcpy(abuf, "");
-
-       time(&now);
-       if ( (now - AnsiDetect) < 2 ) sleep(1);
+               strcpy(abuf, "");
 
-       do {
-               FD_ZERO(&rfds);
-               FD_SET(0,&rfds);
-               tv.tv_sec = 0;
-               tv.tv_usec = 1;
-
-               select(1, &rfds, NULL, NULL, &tv);
-               if (FD_ISSET(0, &rfds)) {
-                       abuf[strlen(abuf)+1] = 0;
-                       read(0, &abuf[strlen(abuf)], 1);
-                       }
+               time(&now);
+               if ( (now - AnsiDetect) < 2 ) sleep(1);
 
-               } while (FD_ISSET(0, &rfds));
+               do {
+                       FD_ZERO(&rfds);
+                       FD_SET(0,&rfds);
+                       tv.tv_sec = 0;
+                       tv.tv_usec = 1;
 
-       for (a=0; a<strlen(abuf); ++a) {
-               if ( (abuf[a] == 27) && (abuf[a+1] == '[')
-                  && (abuf[a+2] == '?') ) {
-                       enable_color = 1;
+                       select(1, &rfds, NULL, NULL, &tv);
+                       if (FD_ISSET(0, &rfds)) {
+                               abuf[strlen(abuf)+1] = 0;
+                               read(0, &abuf[strlen(abuf)], 1);
+                               }
+       
+                       } while (FD_ISSET(0, &rfds));
+       
+               for (a=0; a<strlen(abuf); ++a) {
+                       if ( (abuf[a] == 27) && (abuf[a+1] == '[')
+                       && (abuf[a+2] == '?') ) {
+                               enable_color = 1;
+                               }
                        }
                }
+
        }