Ejemplo n.º 1
0
        static ConsoleReportPrinter()
        {
            string term         = null;
            bool   xterm_colors = false;

            switch (term)
            {
            case "xterm":
            case "rxvt":
            case "rxvt-unicode":
                break;

            case "xterm-color":
                xterm_colors = true;
                break;
            }
            if (!xterm_colors)
            {
                return;
            }

            if (!(UnixUtils.isatty(1) && UnixUtils.isatty(2)))
            {
                return;
            }

            string config = null;

            if (config == null)
            {
                config = "errors=red";
                //config = "brightwhite,red";
            }

            if (config == "disable")
            {
                return;
            }

            if (!config.StartsWith("errors="))
            {
                return;
            }

            config = config.Substring(7);

            int p = config.IndexOf(",");

            if (p == -1)
            {
                prefix = GetForeground(config);
            }
            else
            {
                prefix = GetBackground(config.Substring(p + 1)) + GetForeground(config.Substring(0, p));
            }
            postfix = "\x001b[0m";
        }
Ejemplo n.º 2
0
		static ConsoleReportPrinter ()
		{
			string term = Environment.GetEnvironmentVariable ("TERM");
			bool xterm_colors = false;
			
			switch (term){
			case "xterm":
			case "rxvt":
			case "rxvt-unicode": 
				if (Environment.GetEnvironmentVariable ("COLORTERM") != null){
					xterm_colors = true;
				}
				break;

			case "xterm-color":
				xterm_colors = true;
				break;
			}
			if (!xterm_colors)
				return;

			if (!(UnixUtils.isatty (1) && UnixUtils.isatty (2)))
				return;
			
			string config = Environment.GetEnvironmentVariable ("MCS_COLORS");
			if (config == null){
				config = "errors=red";
				//config = "brightwhite,red";
			}

			if (config == "disable")
				return;

			if (!config.StartsWith ("errors="))
				return;

			config = config.Substring (7);
			
			int p = config.IndexOf (",");
			if (p == -1)
				prefix = GetForeground (config);
			else
				prefix = GetBackground (config.Substring (p+1)) + GetForeground (config.Substring (0, p));
			postfix = "\x001b[0m";
		}